@aztec/simulator 0.0.1-commit.f504929 → 0.0.1-commit.f5a9928
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/client.d.ts +1 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +0 -2
- 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.d.ts +36 -23
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +65 -69
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +7 -19
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +38 -42
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.js +11 -14
- 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 +18 -3
- 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 +4 -1
- 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/amm_test.js +2 -2
- 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 +33 -6
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.js +2 -2
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +8 -1
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +91 -2
- 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 +11 -9
- package/dest/public/fixtures/token_test.js +3 -3
- 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 +17 -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 +107 -63
- 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 +5 -4
- 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/dest/public/state_manager/state_manager.js +1 -1
- package/package.json +16 -16
- package/src/client.ts +0 -2
- package/src/private/acvm_wasm.ts +4 -1
- package/src/private/circuit_recording/circuit_recorder.ts +84 -78
- package/src/private/circuit_recording/file_circuit_recorder.ts +38 -48
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +9 -15
- 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 +23 -3
- package/src/public/avm/fixtures/utils.ts +4 -1
- 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/amm_test.ts +2 -2
- package/src/public/fixtures/bulk_test.ts +31 -6
- package/src/public/fixtures/custom_bytecode_tester.ts +2 -2
- package/src/public/fixtures/custom_bytecode_tests.ts +209 -2
- package/src/public/fixtures/opcode_spammer.ts +4 -8
- package/src/public/fixtures/public_tx_simulation_tester.ts +21 -12
- package/src/public/fixtures/token_test.ts +3 -3
- package/src/public/fixtures/utils.ts +19 -20
- 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 +138 -77
- package/src/public/public_processor/public_processor_metrics.ts +12 -0
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +5 -4
- package/src/public/public_tx_simulator/public_tx_context.ts +8 -10
- package/src/public/public_tx_simulator/public_tx_simulator.ts +11 -7
- package/src/public/state_manager/state_manager.ts +1 -1
|
@@ -13,7 +13,7 @@ export class ContractProviderForCpp {
|
|
|
13
13
|
this.globalVariables = globalVariables;
|
|
14
14
|
this.getContractInstance = async (address)=>{
|
|
15
15
|
this.log.trace(`Contract provider callback: getContractInstance(${address})`);
|
|
16
|
-
const aztecAddr = AztecAddress.
|
|
16
|
+
const aztecAddr = AztecAddress.fromStringUnsafe(address);
|
|
17
17
|
const instance = await this.contractsDB.getContractInstance(aztecAddr, this.globalVariables.timestamp);
|
|
18
18
|
if (!instance) {
|
|
19
19
|
this.log.debug(`Contract instance not found: ${address}`);
|
|
@@ -39,8 +39,8 @@ export class ContractProviderForCpp {
|
|
|
39
39
|
// Construct ContractDeploymentData from plain object.
|
|
40
40
|
const contractDeploymentData = ContractDeploymentData.fromPlainObject(rawData);
|
|
41
41
|
// Add contracts to the contracts DB
|
|
42
|
-
this.log.trace(`Calling contractsDB.
|
|
43
|
-
|
|
42
|
+
this.log.trace(`Calling contractsDB.addContractsFromLogs`);
|
|
43
|
+
this.contractsDB.addContractsFromLogs(contractDeploymentData);
|
|
44
44
|
};
|
|
45
45
|
this.getBytecodeCommitment = async (classId)=>{
|
|
46
46
|
this.log.trace(`Contract provider callback: getBytecodeCommitment(${classId})`);
|
|
@@ -58,7 +58,7 @@ export class ContractProviderForCpp {
|
|
|
58
58
|
this.getDebugFunctionName = async (address, selector)=>{
|
|
59
59
|
this.log.trace(`Contract provider callback: getDebugFunctionName(${address}, ${selector})`);
|
|
60
60
|
// Parse address and selector strings
|
|
61
|
-
const aztecAddr = AztecAddress.
|
|
61
|
+
const aztecAddr = AztecAddress.fromStringUnsafe(address);
|
|
62
62
|
const selectorFr = Fr.fromString(selector);
|
|
63
63
|
const functionSelector = FunctionSelector.fromFieldOrUndefined(selectorFr);
|
|
64
64
|
if (!functionSelector) {
|
|
@@ -89,6 +89,7 @@ export class ContractProviderForCpp {
|
|
|
89
89
|
}
|
|
90
90
|
getContractInstance;
|
|
91
91
|
getContractClass;
|
|
92
|
+
// eslint-disable-next-line require-await
|
|
92
93
|
addContracts;
|
|
93
94
|
getBytecodeCommitment;
|
|
94
95
|
getDebugFunctionName;
|
|
@@ -75,8 +75,12 @@ export declare class PublicTxContext {
|
|
|
75
75
|
*/
|
|
76
76
|
consumeGas(phase: TxExecutionPhase, gas: Gas): void;
|
|
77
77
|
/**
|
|
78
|
-
* The gasUsed by public and private,
|
|
79
|
-
*
|
|
78
|
+
* The gasUsed by public and private, as if the entire teardown gas limit was consumed.
|
|
79
|
+
*
|
|
80
|
+
* This is intentional: teardown is used for gas accounting and refunds, so the transaction
|
|
81
|
+
* fee must be deterministic _before_ teardown executes. If fees depended on teardown's actual
|
|
82
|
+
* consumption there would be a circular dependency. Billing the full teardown gas limit
|
|
83
|
+
* (set by the user) makes the fee known in advance and available to the teardown function.
|
|
80
84
|
*/
|
|
81
85
|
getTotalGasUsed(): Gas;
|
|
82
86
|
/**
|
|
@@ -128,4 +132,4 @@ declare class PhaseStateManager {
|
|
|
128
132
|
discardForkedState(): Promise<void>;
|
|
129
133
|
}
|
|
130
134
|
export {};
|
|
131
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
135
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3R4X2NvbnRleHQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvcHVibGljX3R4X3NpbXVsYXR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AAc,4BAgD1B;IAED;;;;OAIG;IACH,IAAI,SAGH;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAAE,YAAY,GAAE,eAAe,GAAG,SAAqB,EAAE,OAAO,SAAK,
|
|
1
|
+
{"version":3,"file":"public_tx_context.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_context.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAGL,sBAAsB,EAEtB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAA6B,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAe,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAGL,8BAA8B,EAI/B,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,KAAK,eAAe,EACpB,iBAAiB,EACjB,6BAA6B,EAE7B,KAAK,EAAE,EACP,gBAAgB,EAChB,KAAK,MAAM,EACZ,MAAM,kBAAkB,CAAC;AAK1B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAGlF;;GAEG;AACH,qBAAa,eAAe;aAeR,MAAM,EAAE,MAAM;aACd,KAAK,EAAE,iBAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,Q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,EAAE,CAShF;IAED;;OAEG;IACH,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,GAAG,CAQ9C;IAED;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,QAM3C;IAED;;;;;;;OAOG;IACH,eAAe,IAAI,GAAG,CAErB;IAED;;;;;OAKG;IACH,gBAAgB,IAAI,GAAG,CAKtB;IAED;;;OAGG;IACH,sBAAsB,IAAI,GAAG,CAG5B;IAED;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,EAAE,CAM7C;IAED;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;OAEG;IACU,8BAA8B,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAuH7E;CACF;AAED;;;;;;;;;GASG;AACH,cAAM,iBAAiB;IAMnB,OAAO,CAAC,QAAQ,CAAC,cAAc;IALjC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,2BAA2B,CAA4C;IAE/E,YACmB,cAAc,EAAE,6BAA6B,EAC9D,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAEK,IAAI,kBAIT;IAED,qBAAqB,kCAEpB;IAED,QAAQ,YAEP;IAEK,gBAAgB,kBAMrB;IAEK,kBAAkB,kBAMvB;CACF"}
|
|
@@ -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 payF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"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;
|
|
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,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AAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAmCxG;IAED;;;;;;OAMG;IACH,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);
|
|
@@ -287,7 +287,7 @@ import { PublicStorage } from './public_storage.js';
|
|
|
287
287
|
// Nullifier check! We do this regardless of whether or not the instance exists,
|
|
288
288
|
// as even for non-existence, we need to generate nullifier check hints.
|
|
289
289
|
// This will internally decide whether to check the nullifier tree or not depending on doMerkleOperations.
|
|
290
|
-
const nullifierExistsInTree = await this.checkNullifierExists(AztecAddress.
|
|
290
|
+
const nullifierExistsInTree = await this.checkNullifierExists(AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractAddress.toField());
|
|
291
291
|
assert(exists == nullifierExistsInTree, `Contract instance for address ${contractAddress} in DB: ${exists} != nullifier tree: ${nullifierExistsInTree}. This is a bug!`);
|
|
292
292
|
if (!exists) {
|
|
293
293
|
this.log.debug(`Contract instance NOT FOUND (address=${contractAddress})`);
|
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.f5a9928",
|
|
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.f5a9928",
|
|
68
|
+
"@aztec/foundation": "0.0.1-commit.f5a9928",
|
|
69
|
+
"@aztec/native": "0.0.1-commit.f5a9928",
|
|
70
|
+
"@aztec/noir-acvm_js": "0.0.1-commit.f5a9928",
|
|
71
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.f5a9928",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.f5a9928",
|
|
73
|
+
"@aztec/noir-types": "0.0.1-commit.f5a9928",
|
|
74
|
+
"@aztec/protocol-contracts": "0.0.1-commit.f5a9928",
|
|
75
|
+
"@aztec/standard-contracts": "0.0.1-commit.f5a9928",
|
|
76
|
+
"@aztec/stdlib": "0.0.1-commit.f5a9928",
|
|
77
|
+
"@aztec/telemetry-client": "0.0.1-commit.f5a9928",
|
|
78
|
+
"@aztec/world-state": "0.0.1-commit.f5a9928",
|
|
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.f504929",
|
|
84
|
+
"@aztec/kv-store": "0.0.1-commit.f5a9928",
|
|
85
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.f5a9928",
|
|
86
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.f5a9928",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
88
|
"@types/jest": "^30.0.0",
|
|
89
89
|
"@types/lodash.clonedeep": "^4.5.7",
|
package/src/client.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export * from './private/acvm/index.js';
|
|
2
2
|
export { WASMSimulator } from './private/acvm_wasm.js';
|
|
3
|
-
export { SimulatorRecorderWrapper } from './private/circuit_recording/simulator_recorder_wrapper.js';
|
|
4
|
-
export { MemoryCircuitRecorder } from './private/circuit_recording/memory_circuit_recorder.js';
|
|
5
3
|
export { type CircuitSimulator, type DecodedError } from './private/circuit_simulator.js';
|
|
6
4
|
export * from './common/index.js';
|
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
|
|
|
@@ -3,6 +3,8 @@ import { type Logger, type LoggerBindings, resolveLogger } from '@aztec/foundati
|
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import type { ForeignCallHandler, ForeignCallInput, ForeignCallOutput } from '@aztec/noir-acvm_js';
|
|
5
5
|
|
|
6
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
7
|
+
|
|
6
8
|
import type { ACIRCallback } from '../acvm/acvm.js';
|
|
7
9
|
import type { ACVMWitness } from '../acvm/acvm_types.js';
|
|
8
10
|
|
|
@@ -43,10 +45,23 @@ export class CircuitRecording {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
/** Inputs needed to open a recording for a single circuit execution. */
|
|
49
|
+
export type RecordingMetadata = {
|
|
50
|
+
input: ACVMWitness;
|
|
51
|
+
bytecode: Buffer;
|
|
52
|
+
circuitName: string;
|
|
53
|
+
functionName: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
46
56
|
/**
|
|
47
57
|
* Class responsible for recording circuit inputs necessary to replay the circuit. These inputs are the initial witness
|
|
48
58
|
* map and the oracle calls made during the circuit execution/witness generation.
|
|
49
59
|
*
|
|
60
|
+
* The active recording for an execution lives in `AsyncLocalStorage`, so each (possibly nested) circuit execution owns
|
|
61
|
+
* its own recording and concurrent or re-entrant executions cannot corrupt one another's state. Nested executions
|
|
62
|
+
* (`aztec_prv_callPrivateFunction`, utility calls) re-enter {@link record}, which links the child to the recording
|
|
63
|
+
* active in the enclosing async context and lets ALS restore the parent automatically when the child completes.
|
|
64
|
+
*
|
|
50
65
|
* Example recording object:
|
|
51
66
|
* ```json
|
|
52
67
|
* {
|
|
@@ -91,37 +106,44 @@ export class CircuitRecording {
|
|
|
91
106
|
export class CircuitRecorder {
|
|
92
107
|
protected readonly logger: Logger;
|
|
93
108
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
private stackDepth: number = 0;
|
|
97
|
-
private newCircuit: boolean = true;
|
|
109
|
+
readonly #recordings = new AsyncLocalStorage<CircuitRecording>();
|
|
98
110
|
|
|
99
111
|
protected constructor(loggerOrBindings?: Logger | LoggerBindings) {
|
|
100
112
|
this.logger = resolveLogger('simulator:acvm:recording', loggerOrBindings);
|
|
101
113
|
}
|
|
102
114
|
|
|
103
115
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
116
|
+
* Records a single circuit execution. Opens a recording for the circuit (linked as a child of the recording active
|
|
117
|
+
* in the current async context, if any), runs `fn` within that recording's context, and finalizes it. The recording
|
|
118
|
+
* is returned alongside the result so callers can derive per-circuit stats (e.g. oracle timings).
|
|
119
|
+
*
|
|
120
|
+
* Recorder bookkeeping never alters execution: if `fn` throws, the error is attached to the recording and re-thrown
|
|
121
|
+
* unchanged.
|
|
122
|
+
* @param metadata - Identifies the circuit and its initial witness.
|
|
123
|
+
* @param fn - Runs the circuit execution; its oracle calls are recorded into this recording.
|
|
111
124
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.recording.setParent(parentRef);
|
|
122
|
-
}
|
|
125
|
+
record<T>(metadata: RecordingMetadata, fn: () => Promise<T>): Promise<{ result: T; recording: CircuitRecording }> {
|
|
126
|
+
const parent = this.#recordings.getStore();
|
|
127
|
+
const recording = new CircuitRecording(
|
|
128
|
+
metadata.circuitName,
|
|
129
|
+
metadata.functionName,
|
|
130
|
+
sha512(metadata.bytecode).toString('hex'),
|
|
131
|
+
Object.fromEntries(metadata.input),
|
|
132
|
+
);
|
|
133
|
+
recording.setParent(parent);
|
|
123
134
|
|
|
124
|
-
return
|
|
135
|
+
return this.#recordings.run(recording, async () => {
|
|
136
|
+
await this.onStart(recording);
|
|
137
|
+
try {
|
|
138
|
+
const result = await fn();
|
|
139
|
+
await this.onFinish(recording);
|
|
140
|
+
return { result, recording };
|
|
141
|
+
} catch (error) {
|
|
142
|
+
recording.error = JSON.stringify(error);
|
|
143
|
+
await this.onError(recording, error);
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
125
147
|
}
|
|
126
148
|
|
|
127
149
|
/**
|
|
@@ -147,7 +169,9 @@ export class CircuitRecorder {
|
|
|
147
169
|
}
|
|
148
170
|
|
|
149
171
|
/**
|
|
150
|
-
* Wraps a user circuit callback to record all oracle calls.
|
|
172
|
+
* Wraps a user circuit callback to record all oracle calls. A nested circuit entered via an oracle (e.g.
|
|
173
|
+
* `aztec_prv_callPrivateFunction`) re-enters {@link record}, so its own oracle calls land on the child recording and
|
|
174
|
+
* this circuit's calls (including the entering oracle call itself) land on this recording once the child completes.
|
|
151
175
|
* @param callback - The original circuit callback.
|
|
152
176
|
* @returns A wrapped callback that records all oracle interactions which is to be provided to the ACVM.
|
|
153
177
|
*/
|
|
@@ -161,38 +185,16 @@ export class CircuitRecorder {
|
|
|
161
185
|
throw new Error(`Oracle method ${name} not found when setting up recording callback`);
|
|
162
186
|
}
|
|
163
187
|
|
|
164
|
-
const isExternalCall = (name as keyof ACIRCallback) === 'aztec_prv_callPrivateFunction';
|
|
165
|
-
|
|
166
188
|
recordingCallback[name as keyof ACIRCallback] = (...args: ForeignCallInput[]): ReturnType<typeof fn> => {
|
|
167
189
|
const timer = new Timer();
|
|
168
|
-
// If we're entering another circuit via `aztec_prv_callPrivateFunction`, we increase the stack depth and set the
|
|
169
|
-
// newCircuit variable to ensure we are creating a new recording object.
|
|
170
|
-
if (isExternalCall) {
|
|
171
|
-
this.stackDepth++;
|
|
172
|
-
this.newCircuit = true;
|
|
173
|
-
}
|
|
174
190
|
const result = fn.call(callback, ...args);
|
|
175
191
|
if (result instanceof Promise) {
|
|
176
192
|
return result.then(async r => {
|
|
177
|
-
|
|
178
|
-
// so that the parent circuit continues with its existing recording
|
|
179
|
-
// Note: recording restoration is handled by finish()
|
|
180
|
-
if (isExternalCall) {
|
|
181
|
-
this.stackDepth--;
|
|
182
|
-
this.newCircuit = false;
|
|
183
|
-
}
|
|
184
|
-
await this.recordCall(name, args, r, timer.ms(), this.stackDepth);
|
|
193
|
+
await this.recordCall(name, args, r, timer.ms());
|
|
185
194
|
return r;
|
|
186
195
|
}) as ReturnType<typeof fn>;
|
|
187
196
|
}
|
|
188
|
-
|
|
189
|
-
// so that the parent circuit continues with its existing recording
|
|
190
|
-
// Note: recording restoration is handled by finish()
|
|
191
|
-
if (isExternalCall) {
|
|
192
|
-
this.stackDepth--;
|
|
193
|
-
this.newCircuit = false;
|
|
194
|
-
}
|
|
195
|
-
void this.recordCall(name, args, result, timer.ms(), this.stackDepth);
|
|
197
|
+
void this.recordCall(name, args, result, timer.ms());
|
|
196
198
|
return result;
|
|
197
199
|
};
|
|
198
200
|
}
|
|
@@ -209,55 +211,59 @@ export class CircuitRecorder {
|
|
|
209
211
|
return async (name: string, inputs: ForeignCallInput[]): Promise<ForeignCallOutput[]> => {
|
|
210
212
|
const timer = new Timer();
|
|
211
213
|
const result = await callback(name, inputs);
|
|
212
|
-
await this.recordCall(name, inputs, result, timer.ms()
|
|
214
|
+
await this.recordCall(name, inputs, result, timer.ms());
|
|
213
215
|
return result;
|
|
214
216
|
};
|
|
215
217
|
}
|
|
216
218
|
|
|
217
219
|
/**
|
|
218
|
-
* Records a single oracle/foreign call with its inputs and outputs
|
|
220
|
+
* Records a single oracle/foreign call with its inputs and outputs against the recording active in the current
|
|
221
|
+
* async context.
|
|
219
222
|
* @param name - Name of the call
|
|
220
223
|
* @param inputs - Input arguments
|
|
221
224
|
* @param outputs - Output results
|
|
222
225
|
*/
|
|
223
|
-
recordCall(name: string, inputs: unknown[], outputs: unknown, time: number
|
|
226
|
+
recordCall(name: string, inputs: unknown[], outputs: unknown, time: number): Promise<OracleCall> {
|
|
227
|
+
const recording = this.#recordings.getStore();
|
|
224
228
|
const entry = {
|
|
225
229
|
name,
|
|
226
230
|
inputs,
|
|
227
231
|
outputs,
|
|
228
232
|
time,
|
|
229
|
-
stackDepth,
|
|
233
|
+
stackDepth: depthOf(recording),
|
|
230
234
|
};
|
|
231
|
-
|
|
235
|
+
// Outside any active recording context (e.g. a stray call after the scope closed, or a direct unit-test call)
|
|
236
|
+
// there is nowhere to record; return the entry without throwing into the execution path.
|
|
237
|
+
recording?.oracleCalls.push(entry);
|
|
232
238
|
return Promise.resolve(entry);
|
|
233
239
|
}
|
|
234
240
|
|
|
235
|
-
/**
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
finish(): Promise<CircuitRecording> {
|
|
239
|
-
const result = this.recording;
|
|
240
|
-
// If this is the top-level circuit recording, we reset the state for the next simulator call
|
|
241
|
-
if (!result!.parent) {
|
|
242
|
-
this.newCircuit = true;
|
|
243
|
-
this.recording = undefined;
|
|
244
|
-
} else {
|
|
245
|
-
// For nested circuits (utility calls, nested contract calls), restore to parent recording
|
|
246
|
-
// Note: we don't set newCircuit=false here because:
|
|
247
|
-
// - For privateCallPrivateFunction, the callback wrapper will set it to false
|
|
248
|
-
// - For utility calls, we want newCircuit to remain true so the next circuit creates its own recording
|
|
249
|
-
this.recording = result!.parent;
|
|
250
|
-
}
|
|
251
|
-
return Promise.resolve(result!);
|
|
241
|
+
/** The recording active in the current async context, if any. */
|
|
242
|
+
protected currentRecording(): CircuitRecording | undefined {
|
|
243
|
+
return this.#recordings.getStore();
|
|
252
244
|
}
|
|
253
245
|
|
|
254
|
-
/**
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return
|
|
246
|
+
/** Hook invoked when a recording opens, within the recording's context. Overridden to persist recordings. */
|
|
247
|
+
protected onStart(_recording: CircuitRecording): Promise<void> {
|
|
248
|
+
return Promise.resolve();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Hook invoked when a recording completes successfully, within the recording's context. */
|
|
252
|
+
protected onFinish(_recording: CircuitRecording): Promise<void> {
|
|
253
|
+
return Promise.resolve();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** Hook invoked when a recording's execution throws, within the recording's context. */
|
|
257
|
+
protected onError(_recording: CircuitRecording, _error: unknown): Promise<void> {
|
|
258
|
+
return Promise.resolve();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Depth of a recording in the call tree: 0 for a top-level circuit, incremented per nested circuit. */
|
|
263
|
+
function depthOf(recording: CircuitRecording | undefined): number {
|
|
264
|
+
let depth = 0;
|
|
265
|
+
for (let ancestor = recording?.parent; ancestor; ancestor = ancestor.parent) {
|
|
266
|
+
depth++;
|
|
262
267
|
}
|
|
268
|
+
return depth;
|
|
263
269
|
}
|