@aztec/simulator 0.0.1-commit.733c4a3 → 0.0.1-commit.7689c7f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/private/acvm_wasm.d.ts +1 -1
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm.js +3 -1
- package/dest/private/circuit_recording/circuit_recorder.js +2 -2
- package/dest/public/avm/avm_simulator.js +1 -1
- package/dest/public/avm/calldata.d.ts +1 -1
- package/dest/public/avm/calldata.d.ts.map +1 -1
- package/dest/public/avm/calldata.js +3 -2
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +2 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +17 -2
- package/dest/public/avm/fixtures/utils.d.ts +1 -1
- package/dest/public/avm/fixtures/utils.d.ts.map +1 -1
- package/dest/public/avm/fixtures/utils.js +3 -0
- package/dest/public/avm/opcodes/contract.d.ts +3 -2
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +5 -1
- package/dest/public/avm/opcodes/ec_add.d.ts +2 -4
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +13 -27
- package/dest/public/contracts_db_checkpoint.d.ts +2 -2
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -1
- package/dest/public/contracts_db_checkpoint.js +1 -1
- package/dest/public/fixtures/bulk_test.d.ts +1 -1
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +31 -4
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +3 -1
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +61 -1
- package/dest/public/fixtures/opcode_spammer.d.ts +1 -1
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -1
- package/dest/public/fixtures/opcode_spammer.js +2 -10
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +6 -5
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +10 -10
- package/dest/public/fixtures/utils.d.ts +2 -2
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +15 -16
- package/dest/public/hinting_db_sources.d.ts +4 -4
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +7 -6
- package/dest/public/public_db_sources.d.ts +6 -3
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +16 -10
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +4 -4
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +4 -4
- package/dest/public/public_processor/public_processor.d.ts +5 -4
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +93 -68
- package/dest/public/public_processor/public_processor_metrics.d.ts +4 -1
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +8 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +3 -2
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +7 -3
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +8 -10
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +6 -2
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +12 -7
- package/package.json +16 -16
- package/src/private/acvm_wasm.ts +4 -1
- package/src/private/circuit_recording/circuit_recorder.ts +2 -2
- package/src/public/avm/avm_simulator.ts +1 -1
- package/src/public/avm/calldata.ts +3 -2
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +22 -2
- package/src/public/avm/fixtures/utils.ts +3 -0
- package/src/public/avm/opcodes/contract.ts +5 -1
- package/src/public/avm/opcodes/ec_add.ts +12 -31
- package/src/public/avm/opcodes/external_calls.ts +1 -1
- package/src/public/contracts_db_checkpoint.ts +1 -1
- package/src/public/fixtures/bulk_test.ts +29 -4
- package/src/public/fixtures/custom_bytecode_tests.ts +139 -1
- package/src/public/fixtures/opcode_spammer.ts +4 -8
- package/src/public/fixtures/public_tx_simulation_tester.ts +21 -11
- package/src/public/fixtures/utils.ts +22 -18
- package/src/public/hinting_db_sources.ts +9 -6
- package/src/public/public_db_sources.ts +21 -14
- package/src/public/public_processor/guarded_merkle_tree.ts +5 -5
- package/src/public/public_processor/public_processor.ts +120 -80
- package/src/public/public_processor/public_processor_metrics.ts +12 -0
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +3 -2
- package/src/public/public_tx_simulator/public_tx_context.ts +8 -10
- package/src/public/public_tx_simulator/public_tx_simulator.ts +11 -7
|
@@ -106,14 +106,8 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
106
106
|
}
|
|
107
107
|
if (phase === TxExecutionPhase.SETUP) {
|
|
108
108
|
this.log.warn(`Setup phase reverted! The transaction will be thrown out.`);
|
|
109
|
-
} else if (phase === TxExecutionPhase.APP_LOGIC) {
|
|
110
|
-
this.revertCode = RevertCode.
|
|
111
|
-
} else if (phase === TxExecutionPhase.TEARDOWN) {
|
|
112
|
-
if (this.revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
|
|
113
|
-
this.revertCode = RevertCode.BOTH_REVERTED;
|
|
114
|
-
} else {
|
|
115
|
-
this.revertCode = RevertCode.TEARDOWN_REVERTED;
|
|
116
|
-
}
|
|
109
|
+
} else if (phase === TxExecutionPhase.APP_LOGIC || phase === TxExecutionPhase.TEARDOWN) {
|
|
110
|
+
this.revertCode = RevertCode.REVERTED;
|
|
117
111
|
}
|
|
118
112
|
}
|
|
119
113
|
/**
|
|
@@ -168,8 +162,12 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
168
162
|
}
|
|
169
163
|
}
|
|
170
164
|
/**
|
|
171
|
-
* The gasUsed by public and private,
|
|
172
|
-
*
|
|
165
|
+
* The gasUsed by public and private, as if the entire teardown gas limit was consumed.
|
|
166
|
+
*
|
|
167
|
+
* This is intentional: teardown is used for gas accounting and refunds, so the transaction
|
|
168
|
+
* fee must be deterministic _before_ teardown executes. If fees depended on teardown's actual
|
|
169
|
+
* consumption there would be a circular dependency. Billing the full teardown gas limit
|
|
170
|
+
* (set by the user) makes the fee known in advance and available to the teardown function.
|
|
173
171
|
*/ getTotalGasUsed() {
|
|
174
172
|
return this.gasUsedByPrivate.add(this.gasUsedByPublic);
|
|
175
173
|
}
|
|
@@ -71,12 +71,16 @@ export declare class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
71
71
|
* Throws TxSimRevertibleInsertionsRevert if there is some checked error during revertible insertions.
|
|
72
72
|
* This function checks for the following errors:
|
|
73
73
|
* - NullifierLimitReachedError
|
|
74
|
-
* - NullifierCollisionError
|
|
75
74
|
* - NoteHashLimitReachedError
|
|
76
75
|
* - L2ToL1MessageLimitReachedError
|
|
76
|
+
*
|
|
77
|
+
* Note: NullifierCollisionError is intentionally NOT caught here. A nullifier collision
|
|
78
|
+
* during revertible insertions is unprovable (the nullifier originated from private, so
|
|
79
|
+
* a collision indicates the tx should never have been proposed). It propagates as-is to
|
|
80
|
+
* make the transaction unrecoverable, matching the AVM circuit behavior.
|
|
77
81
|
*/
|
|
78
82
|
protected insertRevertiblesFromPrivate(context: PublicTxContext): Promise<void>;
|
|
79
83
|
private payFee;
|
|
80
84
|
}
|
|
81
85
|
export {};
|
|
82
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
86
|
+
//# sourceMapping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AAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAGvF,OAAO,EAAgC,qBAAqB,EAAkB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,KAAK,eAAe,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,6BAA6B,EAC7B,EAAE,EACF,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAKjF,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAGvF,OAAO,EAAgC,qBAAqB,EAAkB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,KAAK,eAAe,EACpB,yBAAyB,EACzB,iBAAiB,EACjB,6BAA6B,EAC7B,EAAE,EACF,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAKjF,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,yBAAyB,CAAC;AAMhF,OAAO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ACH,UAAgB,oBAAoB,CAClC,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,6BAA6B,GACzC,OAAO,CAAC,sBAAsB,CAAC,CA+BjC;IAED;;;;;;;;;;;;OAYG;IACH,UAAgB,4BAA4B,CAC1C,YAAY,EAAE,6BAA6B,EAC3C,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,6BAA6B,EACpD,YAAY,EAAE,GAAG,EACjB,cAAc,EAAE,EAAE,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,sBAAsB,CAAC,CAqBjC;IAED;;OAEG;IACH,UAAgB,+BAA+B,CAAC,OAAO,EAAE,eAAe,iBAyBvE;IAED;;;;;;;;;;;;OAYG;IACH,UAAgB,4BAA4B,CAAC,OAAO,EAAE,eAAe,iBA0EpE;YAEa,MAAM;CAmCrB"}
|
|
@@ -11,7 +11,7 @@ import { AvmSimulator } from '../avm/index.js';
|
|
|
11
11
|
import { getPublicFunctionDebugName } from '../debug_fn_name.js';
|
|
12
12
|
import { HintingMerkleWriteOperations, HintingPublicContractsDB } from '../hinting_db_sources.js';
|
|
13
13
|
import { PublicTreesDB } from '../public_db_sources.js';
|
|
14
|
-
import { L2ToL1MessageLimitReachedError, NoteHashLimitReachedError,
|
|
14
|
+
import { L2ToL1MessageLimitReachedError, NoteHashLimitReachedError, NullifierLimitReachedError } from '../side_effect_errors.js';
|
|
15
15
|
import { PublicTxContext } from './public_tx_context.js';
|
|
16
16
|
// The errors below are only thrown here in the public tx simulator,
|
|
17
17
|
// and only during revertible phases (revertible insertions, app logic and teardown).
|
|
@@ -90,7 +90,8 @@ export class PublicTxSimulator {
|
|
|
90
90
|
await context.state.fork();
|
|
91
91
|
hintingContractsDB.createCheckpoint();
|
|
92
92
|
try {
|
|
93
|
-
// This
|
|
93
|
+
// This may throw: a side-effect limit error triggers a soft revert (caught below), while a
|
|
94
|
+
// nullifier collision is unrecoverable and propagates out of simulate() to throw out the tx.
|
|
94
95
|
await this.insertRevertiblesFromPrivate(context);
|
|
95
96
|
// Only proceed with app logic if there was no revert during revertible insertion.
|
|
96
97
|
if (context.hasPhase(TxExecutionPhase.APP_LOGIC)) {
|
|
@@ -255,16 +256,20 @@ export class PublicTxSimulator {
|
|
|
255
256
|
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
256
257
|
// will pick up the new contracts and will generate the necessary hints.
|
|
257
258
|
// So, a consumer of the hints will always see the new contracts.
|
|
258
|
-
|
|
259
|
+
this.contractsDB.addContractsFromLogs(context.nonRevertibleContractDeploymentData);
|
|
259
260
|
}
|
|
260
261
|
/**
|
|
261
262
|
* Insert the revertible accumulated data from private into the public state.
|
|
262
263
|
* Throws TxSimRevertibleInsertionsRevert if there is some checked error during revertible insertions.
|
|
263
264
|
* This function checks for the following errors:
|
|
264
265
|
* - NullifierLimitReachedError
|
|
265
|
-
* - NullifierCollisionError
|
|
266
266
|
* - NoteHashLimitReachedError
|
|
267
267
|
* - L2ToL1MessageLimitReachedError
|
|
268
|
+
*
|
|
269
|
+
* Note: NullifierCollisionError is intentionally NOT caught here. A nullifier collision
|
|
270
|
+
* during revertible insertions is unprovable (the nullifier originated from private, so
|
|
271
|
+
* a collision indicates the tx should never have been proposed). It propagates as-is to
|
|
272
|
+
* make the transaction unrecoverable, matching the AVM circuit behavior.
|
|
268
273
|
*/ async insertRevertiblesFromPrivate(context) {
|
|
269
274
|
const stateManager = context.state.getActiveStateManager();
|
|
270
275
|
try {
|
|
@@ -272,11 +277,11 @@ export class PublicTxSimulator {
|
|
|
272
277
|
await stateManager.writeSiloedNullifier(siloedNullifier);
|
|
273
278
|
}
|
|
274
279
|
} catch (e) {
|
|
275
|
-
if (e instanceof NullifierLimitReachedError
|
|
280
|
+
if (e instanceof NullifierLimitReachedError) {
|
|
276
281
|
context.revert(TxExecutionPhase.APP_LOGIC, new SimulationError(`Error encountered when inserting revertible nullifiers from private.\nDetails: ${e.message}`, []));
|
|
277
282
|
throw new TxSimRevertibleInsertionsRevert();
|
|
278
283
|
} else {
|
|
279
|
-
// Unchecked/unknown error - re-throw as-is
|
|
284
|
+
// Unchecked/unknown error or NullifierCollisionError (unrecoverable) - re-throw as-is
|
|
280
285
|
throw e;
|
|
281
286
|
}
|
|
282
287
|
}
|
|
@@ -316,7 +321,7 @@ export class PublicTxSimulator {
|
|
|
316
321
|
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
317
322
|
// will pick up the new contracts and will generate the necessary hints.
|
|
318
323
|
// So, a consumer of the hints will always see the new contracts.
|
|
319
|
-
|
|
324
|
+
this.contractsDB.addContractsFromLogs(context.revertibleContractDeploymentData);
|
|
320
325
|
}
|
|
321
326
|
async payFee(context) {
|
|
322
327
|
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.7689c7f",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -64,26 +64,26 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/constants": "0.0.1-commit.
|
|
68
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
69
|
-
"@aztec/native": "0.0.1-commit.
|
|
70
|
-
"@aztec/noir-acvm_js": "0.0.1-commit.
|
|
71
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
73
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
74
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
75
|
-
"@aztec/
|
|
76
|
-
"@aztec/
|
|
77
|
-
"@aztec/
|
|
67
|
+
"@aztec/constants": "0.0.1-commit.7689c7f",
|
|
68
|
+
"@aztec/foundation": "0.0.1-commit.7689c7f",
|
|
69
|
+
"@aztec/native": "0.0.1-commit.7689c7f",
|
|
70
|
+
"@aztec/noir-acvm_js": "0.0.1-commit.7689c7f",
|
|
71
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.7689c7f",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.7689c7f",
|
|
73
|
+
"@aztec/noir-types": "0.0.1-commit.7689c7f",
|
|
74
|
+
"@aztec/protocol-contracts": "0.0.1-commit.7689c7f",
|
|
75
|
+
"@aztec/standard-contracts": "0.0.1-commit.7689c7f",
|
|
76
|
+
"@aztec/stdlib": "0.0.1-commit.7689c7f",
|
|
77
|
+
"@aztec/telemetry-client": "0.0.1-commit.7689c7f",
|
|
78
|
+
"@aztec/world-state": "0.0.1-commit.7689c7f",
|
|
78
79
|
"lodash.clonedeep": "^4.5.0",
|
|
79
80
|
"lodash.merge": "^4.6.2",
|
|
80
81
|
"tslib": "^2.4.0"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
83
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
84
|
-
"@aztec/
|
|
85
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
86
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.733c4a3",
|
|
84
|
+
"@aztec/kv-store": "0.0.1-commit.7689c7f",
|
|
85
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.7689c7f",
|
|
86
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.7689c7f",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
88
|
"@types/jest": "^30.0.0",
|
|
89
89
|
"@types/lodash.clonedeep": "^4.5.7",
|
package/src/private/acvm_wasm.ts
CHANGED
|
@@ -10,6 +10,8 @@ import type { ACVMWitness } from './acvm/acvm_types.js';
|
|
|
10
10
|
import type { ACVMSuccess } from './acvm_native.js';
|
|
11
11
|
import { type CircuitSimulator, enrichNoirError } from './circuit_simulator.js';
|
|
12
12
|
|
|
13
|
+
let wasmInitPromise: Promise<unknown> | undefined;
|
|
14
|
+
|
|
13
15
|
export class WASMSimulator implements CircuitSimulator {
|
|
14
16
|
protected log: Logger;
|
|
15
17
|
|
|
@@ -23,7 +25,8 @@ export class WASMSimulator implements CircuitSimulator {
|
|
|
23
25
|
// is a no-op.
|
|
24
26
|
if (typeof initAbi === 'function') {
|
|
25
27
|
/** @ts-expect-error The node bundle doesn't include these default imports, so TS complains */
|
|
26
|
-
|
|
28
|
+
wasmInitPromise ??= Promise.all([initAbi(), initACVM()]);
|
|
29
|
+
await wasmInitPromise;
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -161,11 +161,11 @@ export class CircuitRecorder {
|
|
|
161
161
|
throw new Error(`Oracle method ${name} not found when setting up recording callback`);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
const isExternalCall = (name as keyof ACIRCallback) === '
|
|
164
|
+
const isExternalCall = (name as keyof ACIRCallback) === 'aztec_prv_callPrivateFunction';
|
|
165
165
|
|
|
166
166
|
recordingCallback[name as keyof ACIRCallback] = (...args: ForeignCallInput[]): ReturnType<typeof fn> => {
|
|
167
167
|
const timer = new Timer();
|
|
168
|
-
// If we're entering another circuit via `
|
|
168
|
+
// If we're entering another circuit via `aztec_prv_callPrivateFunction`, we increase the stack depth and set the
|
|
169
169
|
// newCircuit variable to ensure we are creating a new recording object.
|
|
170
170
|
if (isExternalCall) {
|
|
171
171
|
this.stackDepth++;
|
|
@@ -63,7 +63,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
63
63
|
public static async build(context: AvmContext): Promise<AvmSimulator> {
|
|
64
64
|
const simulator = new AvmSimulator(context);
|
|
65
65
|
const fnName = await context.persistableState.getPublicFunctionDebugName(context.environment);
|
|
66
|
-
simulator.log = createLogger(`simulator:avm(f:${fnName})`);
|
|
66
|
+
simulator.log = createLogger(`simulator:avm(f:${fnName.slice(0, 128)})`);
|
|
67
67
|
|
|
68
68
|
return simulator;
|
|
69
69
|
}
|
|
@@ -33,13 +33,14 @@ export class LazyReaderMemory implements LazyReader {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
public slice(start: number, end: number): Fr[] {
|
|
36
|
-
const clampedEnd = Math.min(end, this.size);
|
|
36
|
+
const clampedEnd = Math.min(end, this.size, TaggedMemory.MAX_MEMORY_SIZE - this.offset);
|
|
37
37
|
const length = Math.max(0, clampedEnd - start);
|
|
38
38
|
return this.memory.getSlice(this.offset + start, length).map(word => word.toFr());
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
public readAll(): Fr[] {
|
|
42
|
-
|
|
42
|
+
const size = Math.min(this.size, TaggedMemory.MAX_MEMORY_SIZE - this.offset);
|
|
43
|
+
return this.memory.getSlice(this.offset, size).map(word => word.toFr());
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
public length(): number {
|
|
@@ -2,9 +2,10 @@ import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
|
-
import {
|
|
5
|
+
import { getCanonicalClassRegistry } from '@aztec/protocol-contracts/class-registry';
|
|
6
6
|
import { computeFeePayerBalanceStorageSlot, getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
|
|
7
7
|
import { getCanonicalInstanceRegistry } from '@aztec/protocol-contracts/instance-registry';
|
|
8
|
+
import { getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
8
9
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
9
10
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
10
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -91,7 +92,7 @@ export abstract class BaseAvmSimulationTester {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
async registerAuthContract(): Promise<ContractInstanceWithAddress> {
|
|
94
|
-
const authRegistry = await
|
|
95
|
+
const authRegistry = await getStandardAuthRegistry();
|
|
95
96
|
const authRegistryContractClassPublic = {
|
|
96
97
|
...authRegistry.contractClass,
|
|
97
98
|
privateFunctions: [],
|
|
@@ -102,9 +103,28 @@ export abstract class BaseAvmSimulationTester {
|
|
|
102
103
|
authRegistryContractClassPublic,
|
|
103
104
|
authRegistry.instance,
|
|
104
105
|
);
|
|
106
|
+
// AuthRegistry is a standard contract (not a protocol contract), so the AVM enforces a
|
|
107
|
+
// deployment-nullifier check on every instance retrieval. Insert the nullifier here so
|
|
108
|
+
// calls to AuthRegistry don't EXCEPTIONAL_HALT during simulation.
|
|
109
|
+
await this.insertContractAddressNullifier(authRegistry.instance.address);
|
|
105
110
|
return authRegistry.instance;
|
|
106
111
|
}
|
|
107
112
|
|
|
113
|
+
async registerClassRegistryContract(): Promise<ContractInstanceWithAddress> {
|
|
114
|
+
const classRegistry = await getCanonicalClassRegistry();
|
|
115
|
+
const classRegistryContractClassPublic = {
|
|
116
|
+
...classRegistry.contractClass,
|
|
117
|
+
privateFunctions: [],
|
|
118
|
+
utilityFunctions: [],
|
|
119
|
+
};
|
|
120
|
+
await this.contractDataSource.addNewContract(
|
|
121
|
+
classRegistry.artifact,
|
|
122
|
+
classRegistryContractClassPublic,
|
|
123
|
+
classRegistry.instance,
|
|
124
|
+
);
|
|
125
|
+
return classRegistry.instance;
|
|
126
|
+
}
|
|
127
|
+
|
|
108
128
|
async registerInstanceRegistryContract(): Promise<ContractInstanceWithAddress> {
|
|
109
129
|
const instanceRegistry = await getCanonicalInstanceRegistry();
|
|
110
130
|
const instanceRegistryContractClassPublic = {
|
|
@@ -128,17 +128,20 @@ export async function createContractClassAndInstance(
|
|
|
128
128
|
const constructorAbi = getContractFunctionAbi('constructor', contractArtifact);
|
|
129
129
|
const { publicKeys } = await deriveKeys(new Fr(seed));
|
|
130
130
|
const initializationHash = await computeInitializationHash(constructorAbi, constructorArgs);
|
|
131
|
+
const immutablesHash = new Fr(seed + 1);
|
|
131
132
|
const contractInstance =
|
|
132
133
|
originalContractClassId === undefined
|
|
133
134
|
? await makeContractInstanceFromClassId(contractClass.id, seed, {
|
|
134
135
|
deployer,
|
|
135
136
|
initializationHash,
|
|
137
|
+
immutablesHash,
|
|
136
138
|
publicKeys,
|
|
137
139
|
})
|
|
138
140
|
: await makeContractInstanceFromClassId(originalContractClassId, seed, {
|
|
139
141
|
deployer,
|
|
140
142
|
initializationHash,
|
|
141
143
|
currentClassId: contractClass.id,
|
|
144
|
+
immutablesHash,
|
|
142
145
|
publicKeys,
|
|
143
146
|
});
|
|
144
147
|
|
|
@@ -9,6 +9,7 @@ export enum ContractInstanceMember {
|
|
|
9
9
|
DEPLOYER,
|
|
10
10
|
CLASS_ID,
|
|
11
11
|
INIT_HASH,
|
|
12
|
+
IMMUTABLES_HASH,
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export class GetContractInstance extends Instruction {
|
|
@@ -41,7 +42,7 @@ export class GetContractInstance extends Instruction {
|
|
|
41
42
|
);
|
|
42
43
|
|
|
43
44
|
if (!(this.memberEnum in ContractInstanceMember)) {
|
|
44
|
-
throw new InstructionExecutionError(`Invalid
|
|
45
|
+
throw new InstructionExecutionError(`Invalid GETCONTRACTINSTANCE member enum ${this.memberEnum}`);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
const operands = [this.addressOffset, this.dstOffset];
|
|
@@ -64,6 +65,9 @@ export class GetContractInstance extends Instruction {
|
|
|
64
65
|
case ContractInstanceMember.INIT_HASH:
|
|
65
66
|
memberValue = new Field(instance.initializationHash);
|
|
66
67
|
break;
|
|
68
|
+
case ContractInstanceMember.IMMUTABLES_HASH:
|
|
69
|
+
memberValue = new Field(instance.immutablesHash);
|
|
70
|
+
break;
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
|
|
@@ -2,7 +2,7 @@ import { Grumpkin } from '@aztec/foundation/crypto/grumpkin';
|
|
|
2
2
|
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
3
3
|
|
|
4
4
|
import type { AvmContext } from '../avm_context.js';
|
|
5
|
-
import { Field, TypeTag
|
|
5
|
+
import { Field, TypeTag } from '../avm_memory_types.js';
|
|
6
6
|
import { EcAddPointNotOnCurveError } from '../errors.js';
|
|
7
7
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
8
8
|
import { Addressing } from './addressing_mode.js';
|
|
@@ -18,10 +18,8 @@ export class EcAdd extends Instruction {
|
|
|
18
18
|
OperandType.UINT16, // indirect
|
|
19
19
|
OperandType.UINT16, // p1X
|
|
20
20
|
OperandType.UINT16, // p1Y
|
|
21
|
-
OperandType.UINT16, // p1IsInfinite
|
|
22
21
|
OperandType.UINT16, // p2X
|
|
23
22
|
OperandType.UINT16, // p2Y
|
|
24
|
-
OperandType.UINT16, // p2IsInfinite
|
|
25
23
|
OperandType.UINT16, // dst
|
|
26
24
|
];
|
|
27
25
|
|
|
@@ -29,10 +27,8 @@ export class EcAdd extends Instruction {
|
|
|
29
27
|
private addressingMode: number,
|
|
30
28
|
private p1XOffset: number,
|
|
31
29
|
private p1YOffset: number,
|
|
32
|
-
private p1IsInfiniteOffset: number,
|
|
33
30
|
private p2XOffset: number,
|
|
34
31
|
private p2YOffset: number,
|
|
35
|
-
private p2IsInfiniteOffset: number,
|
|
36
32
|
private dstOffset: number,
|
|
37
33
|
) {
|
|
38
34
|
super();
|
|
@@ -46,51 +42,38 @@ export class EcAdd extends Instruction {
|
|
|
46
42
|
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
47
43
|
);
|
|
48
44
|
|
|
49
|
-
const operands = [
|
|
50
|
-
|
|
51
|
-
this.p1YOffset,
|
|
52
|
-
this.p1IsInfiniteOffset,
|
|
53
|
-
this.p2XOffset,
|
|
54
|
-
this.p2YOffset,
|
|
55
|
-
this.p2IsInfiniteOffset,
|
|
56
|
-
this.dstOffset,
|
|
57
|
-
];
|
|
58
|
-
const [p1XOffset, p1YOffset, p1IsInfiniteOffset, p2XOffset, p2YOffset, p2IsInfiniteOffset, dstOffset] =
|
|
59
|
-
addressing.resolve(operands, memory);
|
|
45
|
+
const operands = [this.p1XOffset, this.p1YOffset, this.p2XOffset, this.p2YOffset, this.dstOffset];
|
|
46
|
+
const [p1XOffset, p1YOffset, p2XOffset, p2YOffset, dstOffset] = addressing.resolve(operands, memory);
|
|
60
47
|
|
|
61
48
|
memory.checkTags(TypeTag.FIELD, p1XOffset, p1YOffset, p2XOffset, p2YOffset);
|
|
62
|
-
memory.checkTags(TypeTag.UINT1, p1IsInfiniteOffset, p2IsInfiniteOffset);
|
|
63
49
|
|
|
64
50
|
const p1X = memory.get(p1XOffset);
|
|
65
51
|
const p1Y = memory.get(p1YOffset);
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
if (!p1.isOnGrumpkin()) {
|
|
52
|
+
const p1 = new Point(p1X.toFr(), p1Y.toFr());
|
|
53
|
+
if (!p1.isOnCurve()) {
|
|
69
54
|
throw new EcAddPointNotOnCurveError(/*pointIndex=*/ 1, p1);
|
|
70
55
|
}
|
|
71
56
|
|
|
72
57
|
const p2X = memory.get(p2XOffset);
|
|
73
58
|
const p2Y = memory.get(p2YOffset);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const p2 = new Point(p2X.toFr(), p2Y.toFr(), p2IsInfinite);
|
|
77
|
-
if (!p2.isOnGrumpkin()) {
|
|
59
|
+
const p2 = new Point(p2X.toFr(), p2Y.toFr());
|
|
60
|
+
if (!p2.isOnCurve()) {
|
|
78
61
|
throw new EcAddPointNotOnCurveError(/*pointIndex=*/ 2, p2);
|
|
79
62
|
}
|
|
80
63
|
|
|
81
64
|
let dest;
|
|
82
|
-
if (
|
|
83
|
-
dest = Point.
|
|
84
|
-
} else if (
|
|
65
|
+
if (p1.isInfinite && p2.isInfinite) {
|
|
66
|
+
dest = Point.INFINITY;
|
|
67
|
+
} else if (p1.isInfinite) {
|
|
85
68
|
dest = p2;
|
|
86
|
-
} else if (
|
|
69
|
+
} else if (p2.isInfinite) {
|
|
87
70
|
dest = p1;
|
|
88
71
|
} else {
|
|
89
72
|
// TS<>BB ecc add communication is broken for points that add up to infinity.
|
|
90
73
|
// However, here we know that both points are on the curve, and that none is infinity
|
|
91
74
|
// so we can check for the case where you add p + (-p) = infinity.
|
|
92
75
|
if (p1.x.equals(p2.x) && !p1.y.equals(p2.y)) {
|
|
93
|
-
dest = Point.
|
|
76
|
+
dest = Point.INFINITY;
|
|
94
77
|
} else {
|
|
95
78
|
dest = await Grumpkin.add(p1, p2);
|
|
96
79
|
}
|
|
@@ -99,7 +82,5 @@ export class EcAdd extends Instruction {
|
|
|
99
82
|
// Important to use setSlice() and not set() in the two following statements as
|
|
100
83
|
// this checks that the offsets lie within memory range.
|
|
101
84
|
memory.setSlice(dstOffset, [new Field(dest.x), new Field(dest.y)]);
|
|
102
|
-
// Check representation of infinity for grumpkin
|
|
103
|
-
memory.setSlice(dstOffset + 2, [new Uint1(dest.equals(Point.ZERO) ? 1 : 0)]);
|
|
104
85
|
}
|
|
105
86
|
}
|
|
@@ -14,8 +14,8 @@ abstract class ExternalCall extends Instruction {
|
|
|
14
14
|
OperandType.UINT16, // L2 gas offset
|
|
15
15
|
OperandType.UINT16, // DA gas offset
|
|
16
16
|
OperandType.UINT16, // Address offset
|
|
17
|
-
OperandType.UINT16, // Args offset
|
|
18
17
|
OperandType.UINT16, // Args size offset
|
|
18
|
+
OperandType.UINT16, // Args offset
|
|
19
19
|
];
|
|
20
20
|
|
|
21
21
|
constructor(
|
|
@@ -31,7 +31,7 @@ export class ContractsDbCheckpoint {
|
|
|
31
31
|
return this.bytecodeCommitments.get(classId.toString());
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
public
|
|
34
|
+
public fork(): ContractsDbCheckpoint {
|
|
35
35
|
const copy = new ContractsDbCheckpoint();
|
|
36
36
|
this.instances.forEach((value, key) => copy.instances.set(key, value));
|
|
37
37
|
this.classes.forEach((value, key) => copy.classes.set(key, value));
|
|
@@ -25,14 +25,26 @@ export async function bulkTest(
|
|
|
25
25
|
// Register multiple different protocol contracts (to ensure we don't dedup bytecode hashing events):
|
|
26
26
|
await tester.registerAuthContract();
|
|
27
27
|
await tester.registerInstanceRegistryContract();
|
|
28
|
+
await tester.registerClassRegistryContract();
|
|
28
29
|
|
|
29
30
|
// Get a deployed contract instance to pass to the contract
|
|
30
31
|
// for it to use as "expected" values when testing contract instance retrieval.
|
|
31
32
|
const expectContractInstance = avmTestContract;
|
|
32
33
|
const argsField = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
33
|
-
const argsU8 = [1, 2, 3, 4, 5, 6, 7, 8].map(x => new Fr(x));
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const argsU8 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
35
|
+
// Pinned grumpkin-Poseidon2 Schnorr signature (mirrors the C++ `pinned_test_vector_large`
|
|
36
|
+
// and noir-lang/schnorr v0.4.0's `pinned_vector_large`). Passing these in as calldata
|
|
37
|
+
// (rather than baking them into Noir as constants) keeps MSM + Poseidon2 from being folded
|
|
38
|
+
// by the Noir compiler.
|
|
39
|
+
const schnorrInputs = [
|
|
40
|
+
Fr.fromHexString('0x065812e335a97c2108ea8cf4ccfe2f9dd6b117a0714f5e18461575be93f61da6'), // pubkey.x
|
|
41
|
+
Fr.fromHexString('0x1a915003e8ec534f9a15d926a7ded478e178468ccc4f28e236e67450a55ac622'), // pubkey.y
|
|
42
|
+
Fr.fromHexString('0xf3bc3b7147acb9c621fd9f72dbf15ffa'), // sig_s.lo
|
|
43
|
+
Fr.fromHexString('0x08599f379f0301dfefdbd0272554454d'), // sig_s.hi
|
|
44
|
+
Fr.fromHexString('0x97065383ebbbd76620398792bd259bc2'), // sig_e.lo
|
|
45
|
+
Fr.fromHexString('0x2ceaee87f45b7a417f0ffb05451a8c92'), // sig_e.hi
|
|
46
|
+
Fr.fromHexString('0x0123456789abcdef0fedcba9876543210123456789abcdef0fedcba987654321'), // message
|
|
47
|
+
];
|
|
36
48
|
const args = [
|
|
37
49
|
argsField,
|
|
38
50
|
argsU8,
|
|
@@ -40,6 +52,8 @@ export async function bulkTest(
|
|
|
40
52
|
/*expectedDeployer=*/ expectContractInstance.deployer,
|
|
41
53
|
/*expectedClassId=*/ expectContractInstance.currentContractClassId,
|
|
42
54
|
/*expectedInitializationHash=*/ expectContractInstance.initializationHash,
|
|
55
|
+
/*expectedImmutablesHash=*/ expectContractInstance.immutablesHash,
|
|
56
|
+
/*schnorrInputs=*/ schnorrInputs,
|
|
43
57
|
/*skip_strictly_limited_side_effects=*/ false,
|
|
44
58
|
];
|
|
45
59
|
|
|
@@ -62,7 +76,7 @@ export async function bulkTest(
|
|
|
62
76
|
{
|
|
63
77
|
address: avmTestContract.address,
|
|
64
78
|
fnName: 'assert_calldata_copy',
|
|
65
|
-
args: [argsField.slice(3), /* with_selector: */ true],
|
|
79
|
+
args: [argsField.slice(0, 3), /* with_selector: */ true],
|
|
66
80
|
},
|
|
67
81
|
{
|
|
68
82
|
address: avmTestContract.address,
|
|
@@ -123,6 +137,15 @@ export async function megaBulkTest(
|
|
|
123
137
|
//const argsField7 = [15, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
124
138
|
//const argsField8 = [17, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
125
139
|
const argsU8 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
140
|
+
const schnorrInputs = [
|
|
141
|
+
Fr.fromHexString('0x065812e335a97c2108ea8cf4ccfe2f9dd6b117a0714f5e18461575be93f61da6'), // pubkey.x
|
|
142
|
+
Fr.fromHexString('0x1a915003e8ec534f9a15d926a7ded478e178468ccc4f28e236e67450a55ac622'), // pubkey.y
|
|
143
|
+
Fr.fromHexString('0xf3bc3b7147acb9c621fd9f72dbf15ffa'), // sig_s.lo
|
|
144
|
+
Fr.fromHexString('0x08599f379f0301dfefdbd0272554454d'), // sig_s.hi
|
|
145
|
+
Fr.fromHexString('0x97065383ebbbd76620398792bd259bc2'), // sig_e.lo
|
|
146
|
+
Fr.fromHexString('0x2ceaee87f45b7a417f0ffb05451a8c92'), // sig_e.hi
|
|
147
|
+
Fr.fromHexString('0x0123456789abcdef0fedcba9876543210123456789abcdef0fedcba987654321'), // message
|
|
148
|
+
];
|
|
126
149
|
const genArgs = (argsField: Fr[]) => [
|
|
127
150
|
argsField,
|
|
128
151
|
argsU8,
|
|
@@ -130,6 +153,8 @@ export async function megaBulkTest(
|
|
|
130
153
|
/*expectedDeployer=*/ expectContractInstance.deployer.toField(),
|
|
131
154
|
/*expectedClassId=*/ expectContractInstance.currentContractClassId.toField(),
|
|
132
155
|
/*expectedInitializationHash=*/ expectContractInstance.initializationHash.toField(),
|
|
156
|
+
/*expectedImmutablesHash=*/ expectContractInstance.immutablesHash.toField(),
|
|
157
|
+
/*schnorrInputs=*/ schnorrInputs,
|
|
133
158
|
// Must skip strictly limited side effects (logs, messages) so we can spam the bulk test several times.
|
|
134
159
|
/*skip_strictly_limited_side_effects=*/ true,
|
|
135
160
|
];
|