@aztec/simulator 0.81.0 → 0.82.1-alpha-testnet.1
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/common/db_interfaces.d.ts +6 -12
- package/dest/common/db_interfaces.d.ts.map +1 -1
- package/dest/common/db_interfaces.js +1 -1
- package/dest/common/debug_fn_name.js +5 -2
- package/dest/common/message_load_oracle_inputs.d.ts +4 -0
- package/dest/common/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/common/message_load_oracle_inputs.js +9 -0
- package/dest/private/acvm/acvm.d.ts +6 -1
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +7 -13
- package/dest/private/acvm/deserialize.d.ts +0 -18
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.js +3 -24
- package/dest/private/acvm/oracle/oracle.d.ts +34 -34
- package/dest/private/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/oracle.js +116 -82
- package/dest/private/acvm/oracle/typed_oracle.d.ts +4 -4
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/typed_oracle.js +8 -8
- package/dest/private/execution_data_provider.d.ts +3 -9
- package/dest/private/execution_data_provider.d.ts.map +1 -1
- package/dest/private/hashed_values_cache.d.ts +2 -2
- package/dest/private/hashed_values_cache.d.ts.map +1 -1
- package/dest/private/hashed_values_cache.js +5 -15
- package/dest/private/private_execution.d.ts +2 -2
- package/dest/private/private_execution.d.ts.map +1 -1
- package/dest/private/private_execution.js +4 -7
- package/dest/private/private_execution_oracle.d.ts +9 -37
- package/dest/private/private_execution_oracle.d.ts.map +1 -1
- package/dest/private/private_execution_oracle.js +32 -92
- package/dest/private/providers/acvm_native.d.ts +6 -4
- package/dest/private/providers/acvm_native.d.ts.map +1 -1
- package/dest/private/providers/acvm_native.js +6 -3
- package/dest/private/providers/acvm_wasm.d.ts +6 -7
- package/dest/private/providers/acvm_wasm.d.ts.map +1 -1
- package/dest/private/providers/acvm_wasm.js +13 -15
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts +5 -5
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +1 -1
- package/dest/private/providers/acvm_wasm_with_blobs.js +7 -9
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts +90 -0
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts.map +1 -0
- package/dest/private/providers/circuit_recording/circuit_recorder.js +246 -0
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts +18 -0
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts.map +1 -0
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.js +39 -0
- package/dest/private/providers/simulation_provider.d.ts +21 -7
- package/dest/private/providers/simulation_provider.d.ts.map +1 -1
- package/dest/private/simulator.d.ts +3 -2
- package/dest/private/simulator.d.ts.map +1 -1
- package/dest/private/simulator.js +14 -4
- package/dest/private/unconstrained_execution.d.ts +2 -2
- package/dest/private/unconstrained_execution.d.ts.map +1 -1
- package/dest/private/unconstrained_execution.js +1 -2
- package/dest/private/unconstrained_execution_oracle.d.ts +1 -1
- package/dest/private/unconstrained_execution_oracle.d.ts.map +1 -1
- package/dest/private/unconstrained_execution_oracle.js +3 -3
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +0 -2
- package/dest/public/avm/fixtures/avm_simulation_tester.js +2 -2
- package/dest/public/avm/fixtures/index.d.ts +2 -1
- package/dest/public/avm/fixtures/index.d.ts.map +1 -1
- package/dest/public/avm/fixtures/index.js +7 -12
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts +2 -2
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +1 -1
- package/dest/public/avm/fixtures/simple_contract_data_source.js +1 -1
- package/dest/public/avm/journal/journal.d.ts +2 -2
- package/dest/public/avm/journal/journal.d.ts.map +1 -1
- package/dest/public/avm/journal/journal.js +4 -4
- package/dest/public/avm/test_utils.js +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +2 -2
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +27 -47
- 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 +18 -22
- package/dest/public/index.d.ts +1 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +1 -1
- package/dest/public/public_db_sources.d.ts +1 -1
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +4 -4
- package/dest/public/public_processor/public_processor.js +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +3 -10
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +4 -22
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +2 -3
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +20 -24
- package/dest/public/utils.d.ts +2 -4
- package/dest/public/utils.d.ts.map +1 -1
- package/dest/public/utils.js +4 -21
- package/dest/testing.d.ts +2 -0
- package/dest/testing.d.ts.map +1 -0
- package/dest/testing.js +1 -0
- package/package.json +15 -14
- package/src/common/db_interfaces.ts +6 -13
- package/src/common/debug_fn_name.ts +5 -5
- package/src/common/message_load_oracle_inputs.ts +8 -0
- package/src/private/acvm/acvm.ts +8 -24
- package/src/private/acvm/deserialize.ts +3 -30
- package/src/private/acvm/oracle/oracle.ts +148 -144
- package/src/private/acvm/oracle/typed_oracle.ts +12 -14
- package/src/private/execution_data_provider.ts +6 -10
- package/src/private/hashed_values_cache.ts +6 -14
- package/src/private/private_execution.ts +11 -11
- package/src/private/private_execution_oracle.ts +39 -138
- package/src/private/providers/acvm_native.ts +17 -6
- package/src/private/providers/acvm_wasm.ts +27 -20
- package/src/private/providers/acvm_wasm_with_blobs.ts +15 -12
- package/src/private/providers/circuit_recording/circuit_recorder.ts +283 -0
- package/src/private/providers/circuit_recording/simulation_provider_recorder_wrapper.ts +82 -0
- package/src/private/providers/simulation_provider.ts +30 -5
- package/src/private/simulator.ts +19 -5
- package/src/private/unconstrained_execution.ts +8 -4
- package/src/private/unconstrained_execution_oracle.ts +3 -6
- package/src/public/avm/avm_simulator.ts +0 -2
- package/src/public/avm/fixtures/avm_simulation_tester.ts +2 -2
- package/src/public/avm/fixtures/index.ts +15 -17
- package/src/public/avm/fixtures/simple_contract_data_source.ts +2 -2
- package/src/public/avm/journal/journal.ts +7 -7
- package/src/public/avm/test_utils.ts +1 -1
- package/src/public/fixtures/public_tx_simulation_tester.ts +31 -88
- package/src/public/fixtures/utils.ts +28 -26
- package/src/public/index.ts +1 -2
- package/src/public/public_db_sources.ts +4 -4
- package/src/public/public_processor/public_processor.ts +1 -1
- package/src/public/public_tx_simulator/public_tx_context.ts +12 -32
- package/src/public/public_tx_simulator/public_tx_simulator.ts +24 -30
- package/src/public/utils.ts +5 -21
- package/src/testing.ts +1 -0
- package/dest/public/avm/bytecode_utils.d.ts +0 -5
- package/dest/public/avm/bytecode_utils.d.ts.map +0 -1
- package/dest/public/avm/bytecode_utils.js +0 -17
- package/dest/public/execution.d.ts +0 -108
- package/dest/public/execution.d.ts.map +0 -1
- package/dest/public/execution.js +0 -9
- package/src/public/avm/bytecode_utils.ts +0 -17
- package/src/public/execution.ts +0 -140
|
@@ -14,7 +14,7 @@ import { inspect } from 'util';
|
|
|
14
14
|
import { AvmPersistableStateManager } from '../avm/index.js';
|
|
15
15
|
import { HintingPublicContractsDB } from '../hinting_db_sources.js';
|
|
16
16
|
import { SideEffectArrayLengths, SideEffectTrace } from '../side_effect_trace.js';
|
|
17
|
-
import {
|
|
17
|
+
import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
18
18
|
/**
|
|
19
19
|
* The transaction-level context for public execution.
|
|
20
20
|
*/ export class PublicTxContext {
|
|
@@ -28,9 +28,6 @@ import { getCallRequestsByPhase, getExecutionRequestsByPhase } from '../utils.js
|
|
|
28
28
|
setupCallRequests;
|
|
29
29
|
appLogicCallRequests;
|
|
30
30
|
teardownCallRequests;
|
|
31
|
-
setupExecutionRequests;
|
|
32
|
-
appLogicExecutionRequests;
|
|
33
|
-
teardownExecutionRequests;
|
|
34
31
|
nonRevertibleAccumulatedDataFromPrivate;
|
|
35
32
|
revertibleAccumulatedDataFromPrivate;
|
|
36
33
|
feePayer;
|
|
@@ -42,7 +39,7 @@ import { getCallRequestsByPhase, getExecutionRequestsByPhase } from '../utils.js
|
|
|
42
39
|
/* Entire transaction execution is done. */ halted;
|
|
43
40
|
/* Where did reverts happen (if at all)? */ revertCode;
|
|
44
41
|
/* What caused a revert (if one occurred)? */ revertReason;
|
|
45
|
-
constructor(txHash, state, globalVariables, startStateReference, gasSettings, gasUsedByPrivate, gasAllocatedToPublic, setupCallRequests, appLogicCallRequests, teardownCallRequests,
|
|
42
|
+
constructor(txHash, state, globalVariables, startStateReference, gasSettings, gasUsedByPrivate, gasAllocatedToPublic, setupCallRequests, appLogicCallRequests, teardownCallRequests, nonRevertibleAccumulatedDataFromPrivate, revertibleAccumulatedDataFromPrivate, feePayer, trace, hints){
|
|
46
43
|
this.txHash = txHash;
|
|
47
44
|
this.state = state;
|
|
48
45
|
this.globalVariables = globalVariables;
|
|
@@ -53,9 +50,6 @@ import { getCallRequestsByPhase, getExecutionRequestsByPhase } from '../utils.js
|
|
|
53
50
|
this.setupCallRequests = setupCallRequests;
|
|
54
51
|
this.appLogicCallRequests = appLogicCallRequests;
|
|
55
52
|
this.teardownCallRequests = teardownCallRequests;
|
|
56
|
-
this.setupExecutionRequests = setupExecutionRequests;
|
|
57
|
-
this.appLogicExecutionRequests = appLogicExecutionRequests;
|
|
58
|
-
this.teardownExecutionRequests = teardownExecutionRequests;
|
|
59
53
|
this.nonRevertibleAccumulatedDataFromPrivate = nonRevertibleAccumulatedDataFromPrivate;
|
|
60
54
|
this.revertibleAccumulatedDataFromPrivate = revertibleAccumulatedDataFromPrivate;
|
|
61
55
|
this.feePayer = feePayer;
|
|
@@ -82,7 +76,7 @@ import { getCallRequestsByPhase, getExecutionRequestsByPhase } from '../utils.js
|
|
|
82
76
|
const gasUsedByPrivate = tx.data.gasUsed;
|
|
83
77
|
// Gas allocated to public is "whatever's left" after private, but with some max applied.
|
|
84
78
|
const gasAllocatedToPublic = applyMaxToAvailableGas(gasSettings.gasLimits.sub(gasUsedByPrivate));
|
|
85
|
-
return new PublicTxContext(await tx.getTxHash(), new PhaseStateManager(txStateManager), globalVariables, await treesDB.getStateReference(), gasSettings, gasUsedByPrivate, gasAllocatedToPublic,
|
|
79
|
+
return new PublicTxContext(await tx.getTxHash(), new PhaseStateManager(txStateManager), globalVariables, await treesDB.getStateReference(), gasSettings, gasUsedByPrivate, gasAllocatedToPublic, getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP), getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.APP_LOGIC), getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.TEARDOWN), tx.data.forPublic.nonRevertibleAccumulatedData, tx.data.forPublic.revertibleAccumulatedData, tx.data.feePayer, trace, hints);
|
|
86
80
|
}
|
|
87
81
|
/**
|
|
88
82
|
* Signal that the entire transaction execution is done.
|
|
@@ -154,18 +148,6 @@ import { getCallRequestsByPhase, getExecutionRequestsByPhase } from '../utils.js
|
|
|
154
148
|
}
|
|
155
149
|
}
|
|
156
150
|
/**
|
|
157
|
-
* Get the call requests for the specified phase (including actual args).
|
|
158
|
-
*/ getExecutionRequestsForPhase(phase) {
|
|
159
|
-
switch(phase){
|
|
160
|
-
case TxExecutionPhase.SETUP:
|
|
161
|
-
return this.setupExecutionRequests;
|
|
162
|
-
case TxExecutionPhase.APP_LOGIC:
|
|
163
|
-
return this.appLogicExecutionRequests;
|
|
164
|
-
case TxExecutionPhase.TEARDOWN:
|
|
165
|
-
return this.teardownExecutionRequests;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
151
|
* How much gas is left as of the specified phase?
|
|
170
152
|
*/ getGasLeftAtPhase(phase) {
|
|
171
153
|
if (phase === TxExecutionPhase.TEARDOWN) {
|
|
@@ -239,7 +221,7 @@ import { getCallRequestsByPhase, getExecutionRequestsByPhase } from '../utils.js
|
|
|
239
221
|
const startTreeSnapshots = new TreeSnapshots(this.startStateReference.l1ToL2MessageTree, this.startStateReference.partial.noteHashTree, this.startStateReference.partial.nullifierTree, this.startStateReference.partial.publicDataTree);
|
|
240
222
|
// Will be patched/padded at the end of this fn
|
|
241
223
|
const endTreeSnapshots = new TreeSnapshots(endStateReference.l1ToL2MessageTree, endStateReference.partial.noteHashTree, endStateReference.partial.nullifierTree, endStateReference.partial.publicDataTree);
|
|
242
|
-
const avmCircuitPublicInputs = this.trace.toAvmCircuitPublicInputs(this.globalVariables, startTreeSnapshots, /*startGasUsed=*/ this.gasUsedByPrivate, this.gasSettings, this.feePayer, this.setupCallRequests, this.appLogicCallRequests, /*teardownCallRequest=*/ this.teardownCallRequests.length ? this.teardownCallRequests[0] : PublicCallRequest.empty(), endTreeSnapshots, /*endGasUsed=*/ this.getTotalGasUsed(), /*transactionFee=*/ this.getTransactionFeeUnsafe(), /*reverted=*/ !this.revertCode.isOK());
|
|
224
|
+
const avmCircuitPublicInputs = this.trace.toAvmCircuitPublicInputs(this.globalVariables, startTreeSnapshots, /*startGasUsed=*/ this.gasUsedByPrivate, this.gasSettings, this.feePayer, this.setupCallRequests.map((r)=>r.request), this.appLogicCallRequests.map((r)=>r.request), /*teardownCallRequest=*/ this.teardownCallRequests.length ? this.teardownCallRequests[0].request : PublicCallRequest.empty(), endTreeSnapshots, /*endGasUsed=*/ this.getTotalGasUsed(), /*transactionFee=*/ this.getTransactionFeeUnsafe(), /*reverted=*/ !this.revertCode.isOK());
|
|
243
225
|
const getArrayLengths = (from)=>new PrivateToAvmAccumulatedDataArrayLengths(countAccumulatedItems(from.noteHashes), countAccumulatedItems(from.nullifiers), countAccumulatedItems(from.l2ToL1Msgs));
|
|
244
226
|
const convertAccumulatedData = (from)=>new PrivateToAvmAccumulatedData(from.noteHashes, from.nullifiers, from.l2ToL1Msgs);
|
|
245
227
|
// Temporary overrides as these entries aren't yet populated in trace
|
|
@@ -67,8 +67,7 @@ export declare class PublicTxSimulator {
|
|
|
67
67
|
* Simulate an enqueued public call.
|
|
68
68
|
* @param phase - The current phase of public execution
|
|
69
69
|
* @param context - WILL BE MUTATED. The context of the currently executing public transaction portion
|
|
70
|
-
* @param callRequest - The
|
|
71
|
-
* @param executionRequest - The execution request (includes args)
|
|
70
|
+
* @param callRequest - The public function call request, including the calldata.
|
|
72
71
|
* @returns The result of execution.
|
|
73
72
|
*/
|
|
74
73
|
private simulateEnqueuedCall;
|
|
@@ -81,7 +80,7 @@ export declare class PublicTxSimulator {
|
|
|
81
80
|
*
|
|
82
81
|
* @param stateManager - The state manager for AvmSimulation
|
|
83
82
|
* @param context - The context of the currently executing public transaction portion
|
|
84
|
-
* @param
|
|
83
|
+
* @param callRequest - The public function call request, including the calldata.
|
|
85
84
|
* @param allocatedGas - The gas allocated to the enqueued call
|
|
86
85
|
* @param fnName - The name of the function
|
|
87
86
|
* @returns The result of execution.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator.ts"],"names":[],"mappings":"AAKA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAO,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator.ts"],"names":[],"mappings":"AAKA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAO,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EACL,KAAK,eAAe,EACpB,yBAAyB,EAEzB,EAAE,EACF,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAc,KAAK,eAAe,EAAE,KAAK,MAAM,EAAiC,MAAM,yBAAyB,CAAC;AAQvH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,gBAAgB,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,yBAAyB,EAAE,CAAC;IAC1C,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,+CAA+C;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,4BAA4B;IAC5B,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC,CAAC;AAEF,qBAAa,iBAAiB;IAM1B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,kBAAkB;IAT5B,OAAO,EAAE,eAAe,CAAC;IAEzB,OAAO,CAAC,GAAG,CAAS;gBAGV,OAAO,EAAE,aAAa,EACtB,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAChC,kBAAkB,GAAE,OAAe,EACnC,kBAAkB,GAAE,OAAe,EAC3C,eAAe,GAAE,eAAsC;IAMzD,IAAI,MAAM,IAAI,MAAM,CAEnB;IACD;;;;OAIG;IACU,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAyFtD;;;;OAIG;YACW,kBAAkB;IAIhC;;;;OAIG;YACW,qBAAqB;IAkBnC;;;;OAIG;YACW,qBAAqB;IAoBnC;;;;;OAKG;YACW,aAAa;IAuC3B;;;;;;OAMG;YAOW,oBAAoB;IA8ClC;;;;;;;;;;;;;OAaG;YAOW,4BAA4B;IAgD1C;;OAEG;IACU,+BAA+B,CAAC,OAAO,EAAE,eAAe;IAkBrE;;;OAGG;IACU,4BAA4B,CAAC,OAAO,EAAE,eAAe,GAAgB,OAAO,CAAC,OAAO,CAAC;YA+BpF,MAAM;IAgCpB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAStC"}
|
|
@@ -47,7 +47,7 @@ export class PublicTxSimulator {
|
|
|
47
47
|
try {
|
|
48
48
|
const startTime = process.hrtime.bigint();
|
|
49
49
|
const txHash = await tx.getTxHash();
|
|
50
|
-
this.log.debug(`Simulating ${tx.
|
|
50
|
+
this.log.debug(`Simulating ${tx.publicFunctionCalldata.length} public calls for tx ${txHash}`, {
|
|
51
51
|
txHash
|
|
52
52
|
});
|
|
53
53
|
const context = await PublicTxContext.create(this.treesDB, this.contractsDB, tx, this.globalVariables, this.doMerkleOperations);
|
|
@@ -166,12 +166,10 @@ export class PublicTxSimulator {
|
|
|
166
166
|
* @returns The phase result.
|
|
167
167
|
*/ async simulatePhase(phase, context) {
|
|
168
168
|
const callRequests = context.getCallRequestsForPhase(phase);
|
|
169
|
-
const executionRequests = context.getExecutionRequestsForPhase(phase);
|
|
170
169
|
this.log.debug(`Processing phase ${TxExecutionPhase[phase]} for tx ${context.txHash}`, {
|
|
171
170
|
txHash: context.txHash.toString(),
|
|
172
171
|
phase: TxExecutionPhase[phase],
|
|
173
|
-
callRequests: callRequests.length
|
|
174
|
-
executionRequests: executionRequests.length
|
|
172
|
+
callRequests: callRequests.length
|
|
175
173
|
});
|
|
176
174
|
const returnValues = [];
|
|
177
175
|
let reverted = false;
|
|
@@ -182,8 +180,7 @@ export class PublicTxSimulator {
|
|
|
182
180
|
break;
|
|
183
181
|
}
|
|
184
182
|
const callRequest = callRequests[i];
|
|
185
|
-
const
|
|
186
|
-
const enqueuedCallResult = await this.simulateEnqueuedCall(phase, context, callRequest, executionRequest);
|
|
183
|
+
const enqueuedCallResult = await this.simulateEnqueuedCall(phase, context, callRequest);
|
|
187
184
|
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output));
|
|
188
185
|
if (enqueuedCallResult.reverted) {
|
|
189
186
|
reverted = true;
|
|
@@ -202,25 +199,24 @@ export class PublicTxSimulator {
|
|
|
202
199
|
* Simulate an enqueued public call.
|
|
203
200
|
* @param phase - The current phase of public execution
|
|
204
201
|
* @param context - WILL BE MUTATED. The context of the currently executing public transaction portion
|
|
205
|
-
* @param callRequest - The
|
|
206
|
-
* @param executionRequest - The execution request (includes args)
|
|
202
|
+
* @param callRequest - The public function call request, including the calldata.
|
|
207
203
|
* @returns The result of execution.
|
|
208
|
-
*/ async simulateEnqueuedCall(phase, context, callRequest
|
|
204
|
+
*/ async simulateEnqueuedCall(phase, context, callRequest) {
|
|
209
205
|
const stateManager = context.state.getActiveStateManager();
|
|
210
|
-
const
|
|
211
|
-
const fnName = await getPublicFunctionDebugName(this.contractsDB,
|
|
206
|
+
const contractAddress = callRequest.request.contractAddress;
|
|
207
|
+
const fnName = await getPublicFunctionDebugName(this.contractsDB, contractAddress, callRequest.calldata);
|
|
212
208
|
const allocatedGas = context.getGasLeftAtPhase(phase);
|
|
213
209
|
// The reason we need enqueued hints at all (and cannot just use the public inputs) is
|
|
214
210
|
// because they don't have the actual calldata, just the hash of it.
|
|
215
211
|
// If/when we pass the whole TX to C++, we can remove this class of hints.
|
|
216
|
-
stateManager.traceEnqueuedCall(callRequest);
|
|
217
|
-
context.hints.enqueuedCalls.push(new AvmEnqueuedCallHint(
|
|
218
|
-
const result = await this.simulateEnqueuedCallInternal(context.state.getActiveStateManager(),
|
|
212
|
+
stateManager.traceEnqueuedCall(callRequest.request);
|
|
213
|
+
context.hints.enqueuedCalls.push(new AvmEnqueuedCallHint(callRequest.request.msgSender, contractAddress, callRequest.calldata, callRequest.request.isStaticCall));
|
|
214
|
+
const result = await this.simulateEnqueuedCallInternal(context.state.getActiveStateManager(), callRequest, allocatedGas, /*transactionFee=*/ context.getTransactionFee(phase), fnName);
|
|
219
215
|
const gasUsed = allocatedGas.sub(result.gasLeft); // by enqueued call
|
|
220
216
|
context.consumeGas(phase, gasUsed);
|
|
221
217
|
this.log.debug(`Simulated enqueued public call (${fnName}) consumed ${gasUsed.l2Gas} L2 gas ending with ${result.gasLeft.l2Gas} L2 gas left.`);
|
|
222
218
|
if (result.reverted) {
|
|
223
|
-
const culprit = `${
|
|
219
|
+
const culprit = `${contractAddress}:${callRequest.functionSelector}`;
|
|
224
220
|
context.revert(phase, result.revertReason, culprit); // throws if in setup (non-revertible) phase
|
|
225
221
|
}
|
|
226
222
|
return result;
|
|
@@ -234,16 +230,16 @@ export class PublicTxSimulator {
|
|
|
234
230
|
*
|
|
235
231
|
* @param stateManager - The state manager for AvmSimulation
|
|
236
232
|
* @param context - The context of the currently executing public transaction portion
|
|
237
|
-
* @param
|
|
233
|
+
* @param callRequest - The public function call request, including the calldata.
|
|
238
234
|
* @param allocatedGas - The gas allocated to the enqueued call
|
|
239
235
|
* @param fnName - The name of the function
|
|
240
236
|
* @returns The result of execution.
|
|
241
|
-
*/ async simulateEnqueuedCallInternal(stateManager,
|
|
242
|
-
const address =
|
|
243
|
-
const sender =
|
|
237
|
+
*/ async simulateEnqueuedCallInternal(stateManager, { request, calldata }, allocatedGas, transactionFee, fnName) {
|
|
238
|
+
const address = request.contractAddress;
|
|
239
|
+
const sender = request.msgSender;
|
|
244
240
|
this.log.debug(`Executing enqueued public call to external function ${fnName}@${address} with ${allocatedGas.l2Gas} allocated L2 gas.`);
|
|
245
241
|
const timer = new Timer();
|
|
246
|
-
const simulator = await AvmSimulator.create(stateManager, address, sender, transactionFee, this.globalVariables,
|
|
242
|
+
const simulator = await AvmSimulator.create(stateManager, address, sender, transactionFee, this.globalVariables, request.isStaticCall, calldata, allocatedGas);
|
|
247
243
|
const avmCallResult = await simulator.execute();
|
|
248
244
|
const result = avmCallResult.finalize();
|
|
249
245
|
this.log.verbose(result.reverted ? `Simulation of enqueued public call ${fnName} reverted with reason ${result.revertReason}.` : `Simulation of enqueued public call ${fnName} completed successfully.`, {
|
|
@@ -334,15 +330,15 @@ export class PublicTxSimulator {
|
|
|
334
330
|
}
|
|
335
331
|
}
|
|
336
332
|
_ts_decorate([
|
|
337
|
-
trackSpan('PublicTxSimulator.simulateEnqueuedCall', (phase, context,
|
|
333
|
+
trackSpan('PublicTxSimulator.simulateEnqueuedCall', (phase, context, callRequest)=>({
|
|
338
334
|
[Attributes.TX_HASH]: context.txHash.toString(),
|
|
339
|
-
[Attributes.TARGET_ADDRESS]:
|
|
340
|
-
[Attributes.SENDER_ADDRESS]:
|
|
335
|
+
[Attributes.TARGET_ADDRESS]: callRequest.request.contractAddress.toString(),
|
|
336
|
+
[Attributes.SENDER_ADDRESS]: callRequest.request.msgSender.toString(),
|
|
341
337
|
[Attributes.SIMULATOR_PHASE]: TxExecutionPhase[phase].toString()
|
|
342
338
|
}))
|
|
343
339
|
], PublicTxSimulator.prototype, "simulateEnqueuedCall", null);
|
|
344
340
|
_ts_decorate([
|
|
345
|
-
trackSpan('PublicTxSimulator.simulateEnqueuedCallInternal', (_stateManager,
|
|
341
|
+
trackSpan('PublicTxSimulator.simulateEnqueuedCallInternal', (_stateManager, _callRequest, _allocatedGas, _transactionFee, fnName)=>({
|
|
346
342
|
[Attributes.APP_CIRCUIT_NAME]: fnName
|
|
347
343
|
}))
|
|
348
344
|
], PublicTxSimulator.prototype, "simulateEnqueuedCallInternal", null);
|
package/dest/public/utils.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export declare function getExecutionRequestsByPhase(tx: Tx, phase: TxExecutionPhase): PublicExecutionRequest[];
|
|
4
|
-
export declare function getCallRequestsByPhase(tx: Tx, phase: TxExecutionPhase): PublicCallRequest[];
|
|
1
|
+
import { PublicCallRequestWithCalldata, type Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
2
|
+
export declare function getCallRequestsWithCalldataByPhase(tx: Tx, phase: TxExecutionPhase): PublicCallRequestWithCalldata[];
|
|
5
3
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/public/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/public/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,KAAK,EAAE,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE5F,wBAAgB,kCAAkC,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,gBAAgB,GAAG,6BAA6B,EAAE,CAanH"}
|
package/dest/public/utils.js
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
import { TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
2
|
-
export function
|
|
2
|
+
export function getCallRequestsWithCalldataByPhase(tx, phase) {
|
|
3
3
|
switch(phase){
|
|
4
4
|
case TxExecutionPhase.SETUP:
|
|
5
|
-
return tx.
|
|
5
|
+
return tx.getNonRevertiblePublicCallRequestsWithCalldata();
|
|
6
6
|
case TxExecutionPhase.APP_LOGIC:
|
|
7
|
-
return tx.
|
|
7
|
+
return tx.getRevertiblePublicCallRequestsWithCalldata();
|
|
8
8
|
case TxExecutionPhase.TEARDOWN:
|
|
9
9
|
{
|
|
10
|
-
const request = tx.
|
|
11
|
-
return request ? [
|
|
12
|
-
request
|
|
13
|
-
] : [];
|
|
14
|
-
}
|
|
15
|
-
default:
|
|
16
|
-
throw new Error(`Unknown phase: ${phase}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export function getCallRequestsByPhase(tx, phase) {
|
|
20
|
-
switch(phase){
|
|
21
|
-
case TxExecutionPhase.SETUP:
|
|
22
|
-
return tx.data.getNonRevertiblePublicCallRequests();
|
|
23
|
-
case TxExecutionPhase.APP_LOGIC:
|
|
24
|
-
return tx.data.getRevertiblePublicCallRequests();
|
|
25
|
-
case TxExecutionPhase.TEARDOWN:
|
|
26
|
-
{
|
|
27
|
-
const request = tx.data.getTeardownPublicCallRequest();
|
|
10
|
+
const request = tx.getTeardownPublicCallRequestWithCalldata();
|
|
28
11
|
return request ? [
|
|
29
12
|
request
|
|
30
13
|
] : [];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,+EAA+E,CAAC"}
|
package/dest/testing.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SimulationProviderRecorderWrapper } from './private/providers/circuit_recording/simulation_provider_recorder_wrapper.js';
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.1-alpha-testnet.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
7
7
|
"./client": "./dest/client.js",
|
|
8
|
+
"./testing": "./dest/testing.js",
|
|
8
9
|
"./public/fixtures": "./dest/public/fixtures/index.js"
|
|
9
10
|
},
|
|
10
11
|
"typedocOptions": {
|
|
@@ -59,16 +60,16 @@
|
|
|
59
60
|
]
|
|
60
61
|
},
|
|
61
62
|
"dependencies": {
|
|
62
|
-
"@aztec/constants": "0.
|
|
63
|
-
"@aztec/foundation": "0.
|
|
64
|
-
"@aztec/noir-acvm_js": "0.
|
|
65
|
-
"@aztec/noir-noirc_abi": "0.
|
|
66
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
67
|
-
"@aztec/noir-types": "0.
|
|
68
|
-
"@aztec/protocol-contracts": "0.
|
|
69
|
-
"@aztec/stdlib": "0.
|
|
70
|
-
"@aztec/telemetry-client": "0.
|
|
71
|
-
"@aztec/world-state": "0.
|
|
63
|
+
"@aztec/constants": "0.82.1-alpha-testnet.1",
|
|
64
|
+
"@aztec/foundation": "0.82.1-alpha-testnet.1",
|
|
65
|
+
"@aztec/noir-acvm_js": "0.82.1-alpha-testnet.1",
|
|
66
|
+
"@aztec/noir-noirc_abi": "0.82.1-alpha-testnet.1",
|
|
67
|
+
"@aztec/noir-protocol-circuits-types": "0.82.1-alpha-testnet.1",
|
|
68
|
+
"@aztec/noir-types": "0.82.1-alpha-testnet.1",
|
|
69
|
+
"@aztec/protocol-contracts": "0.82.1-alpha-testnet.1",
|
|
70
|
+
"@aztec/stdlib": "0.82.1-alpha-testnet.1",
|
|
71
|
+
"@aztec/telemetry-client": "0.82.1-alpha-testnet.1",
|
|
72
|
+
"@aztec/world-state": "0.82.1-alpha-testnet.1",
|
|
72
73
|
"levelup": "^5.1.1",
|
|
73
74
|
"lodash.clonedeep": "^4.5.0",
|
|
74
75
|
"lodash.merge": "^4.6.2",
|
|
@@ -76,9 +77,9 @@
|
|
|
76
77
|
"tslib": "^2.4.0"
|
|
77
78
|
},
|
|
78
79
|
"devDependencies": {
|
|
79
|
-
"@aztec/kv-store": "0.
|
|
80
|
-
"@aztec/merkle-tree": "0.
|
|
81
|
-
"@aztec/noir-contracts.js": "0.
|
|
80
|
+
"@aztec/kv-store": "0.82.1-alpha-testnet.1",
|
|
81
|
+
"@aztec/merkle-tree": "0.82.1-alpha-testnet.1",
|
|
82
|
+
"@aztec/noir-contracts.js": "0.82.1-alpha-testnet.1",
|
|
82
83
|
"@jest/globals": "^29.5.0",
|
|
83
84
|
"@types/jest": "^29.5.0",
|
|
84
85
|
"@types/levelup": "^5.1.3",
|
|
@@ -63,7 +63,7 @@ export interface PublicContractsDBInterface {
|
|
|
63
63
|
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
/** Database interface for providing access to
|
|
66
|
+
/** Database interface for providing access to note hash tree, l1 to l2 message tree, and nullifier tree. */
|
|
67
67
|
export interface CommitmentsDBInterface {
|
|
68
68
|
/**
|
|
69
69
|
* Fetches a message from the db, given its key.
|
|
@@ -81,23 +81,16 @@ export interface CommitmentsDBInterface {
|
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* @param leafIndex the leaf to look up
|
|
84
|
-
* @returns The l1 to l2 leaf
|
|
84
|
+
* @returns The l1 to l2 leaf message hash or undefined if not found.
|
|
85
85
|
*/
|
|
86
|
-
|
|
86
|
+
getL1ToL2MessageHash(leafIndex: bigint): Promise<Fr | undefined>;
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* Gets
|
|
90
|
-
* @param commitment - The commitment.
|
|
91
|
-
* @returns - The index of the commitment. Undefined if it does not exist in the tree.
|
|
92
|
-
*/
|
|
93
|
-
getCommitmentIndex(commitment: Fr): Promise<bigint | undefined>;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Gets commitment in the note hash tree given a leaf index.
|
|
89
|
+
* Gets note hash in the note hash tree at the given leaf index.
|
|
97
90
|
* @param leafIndex - the leaf to look up.
|
|
98
|
-
* @returns - The
|
|
91
|
+
* @returns - The note hash at that index. Undefined if leaf index is not found.
|
|
99
92
|
*/
|
|
100
|
-
|
|
93
|
+
getNoteHash(leafIndex: bigint): Promise<Fr | undefined>;
|
|
101
94
|
|
|
102
95
|
/**
|
|
103
96
|
* Gets the index of a nullifier in the nullifier tree.
|
|
@@ -10,9 +10,9 @@ export async function getPublicFunctionDebugName(
|
|
|
10
10
|
calldata: Fr[],
|
|
11
11
|
): Promise<string> {
|
|
12
12
|
// Public function is dispatched and therefore the target function is passed in the first argument.
|
|
13
|
-
|
|
14
|
-
calldata[0]
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return
|
|
13
|
+
if (!calldata[0]) {
|
|
14
|
+
return `<calldata[0] undefined> (Contract Address: ${contractAddress})`;
|
|
15
|
+
}
|
|
16
|
+
const selector = FunctionSelector.fromField(calldata[0]);
|
|
17
|
+
return (await db.getDebugFunctionName(contractAddress, selector)) ?? selector.toString();
|
|
18
18
|
}
|
|
@@ -12,4 +12,12 @@ export class MessageLoadOracleInputs<N extends number> {
|
|
|
12
12
|
toFields(): Fr[] {
|
|
13
13
|
return [new Fr(this.index), ...this.siblingPath.toFields()];
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Returns a representation of the public data witness as expected by intrinsic Noir deserialization.
|
|
18
|
+
*/
|
|
19
|
+
public toNoirRepresentation(): (string | string[])[] {
|
|
20
|
+
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
21
|
+
return [new Fr(this.index).toString() as string, this.siblingPath.toFields().map(fr => fr.toString()) as string[]];
|
|
22
|
+
}
|
|
15
23
|
}
|
package/src/private/acvm/acvm.ts
CHANGED
|
@@ -15,18 +15,7 @@ import type { ORACLE_NAMES } from './oracle/index.js';
|
|
|
15
15
|
/**
|
|
16
16
|
* The callback interface for the ACIR.
|
|
17
17
|
*/
|
|
18
|
-
export type ACIRCallback = Record<
|
|
19
|
-
ORACLE_NAMES,
|
|
20
|
-
(
|
|
21
|
-
...args: ForeignCallInput[]
|
|
22
|
-
) =>
|
|
23
|
-
| void
|
|
24
|
-
| Promise<void>
|
|
25
|
-
| ForeignCallOutput
|
|
26
|
-
| ForeignCallOutput[]
|
|
27
|
-
| Promise<ForeignCallOutput>
|
|
28
|
-
| Promise<ForeignCallOutput[]>
|
|
29
|
-
>;
|
|
18
|
+
export type ACIRCallback = Record<ORACLE_NAMES, (...args: ForeignCallInput[]) => Promise<ForeignCallOutput[]>>;
|
|
30
19
|
|
|
31
20
|
/**
|
|
32
21
|
* The result of executing an ACIR.
|
|
@@ -43,6 +32,11 @@ export interface ACIRExecutionResult {
|
|
|
43
32
|
|
|
44
33
|
/**
|
|
45
34
|
* The function call that executes an ACIR.
|
|
35
|
+
* @param acir - The ACIR circuit bytecode to execute.
|
|
36
|
+
* @param initialWitness - The initial witness map defining all of the inputs to `circuit`.
|
|
37
|
+
* @param callback - A callback to process any foreign calls from the circuit.
|
|
38
|
+
* @returns The solved witness calculated by executing the circuit on the provided inputs, as well as the return
|
|
39
|
+
* witness indices as specified by the circuit.
|
|
46
40
|
*/
|
|
47
41
|
export async function acvm(
|
|
48
42
|
acir: Buffer,
|
|
@@ -54,7 +48,7 @@ export async function acvm(
|
|
|
54
48
|
const solvedAndReturnWitness = await executeCircuitWithReturnWitness(
|
|
55
49
|
acir,
|
|
56
50
|
initialWitness,
|
|
57
|
-
|
|
51
|
+
(name: string, args: ForeignCallInput[]) => {
|
|
58
52
|
try {
|
|
59
53
|
logger.debug(`Oracle callback ${name}`);
|
|
60
54
|
const oracleFunction = callback[name as ORACLE_NAMES];
|
|
@@ -62,17 +56,7 @@ export async function acvm(
|
|
|
62
56
|
throw new Error(`Oracle callback ${name} not found`);
|
|
63
57
|
}
|
|
64
58
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (typeof result === 'undefined') {
|
|
68
|
-
return [];
|
|
69
|
-
} else if (result instanceof Array && !result.every(item => typeof item === 'string')) {
|
|
70
|
-
// We are dealing with a nested array which means that we do not need it wrap it in another array as to have
|
|
71
|
-
// the nested array structure it is already "wrapped".
|
|
72
|
-
return result;
|
|
73
|
-
} else {
|
|
74
|
-
return [result] as ForeignCallOutput[];
|
|
75
|
-
}
|
|
59
|
+
return oracleFunction.call(callback, ...args);
|
|
76
60
|
} catch (err) {
|
|
77
61
|
let typedError: Error;
|
|
78
62
|
if (err instanceof Error) {
|
|
@@ -3,33 +3,6 @@ import { hexToBuffer } from '@aztec/foundation/string';
|
|
|
3
3
|
|
|
4
4
|
import type { ACVMField, ACVMWitness } from './acvm_types.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Converts an ACVM field to a Fr.
|
|
8
|
-
* @param field - The ACVM field to convert.
|
|
9
|
-
* @returns The Fr.
|
|
10
|
-
*/
|
|
11
|
-
export function fromACVMField(field: ACVMField): Fr {
|
|
12
|
-
return Fr.fromBuffer(Buffer.from(field.slice(2), 'hex'));
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Converts a field to a number.
|
|
17
|
-
* @param fr - The field to convert.
|
|
18
|
-
* @returns The number.
|
|
19
|
-
* TODO(#4102): Nuke this once block number is big int.
|
|
20
|
-
*/
|
|
21
|
-
export function frToNumber(fr: Fr): number {
|
|
22
|
-
return Number(fr.value);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Converts a field to a boolean.
|
|
27
|
-
* @param fr - The field to convert.
|
|
28
|
-
*/
|
|
29
|
-
export function frToBoolean(fr: Fr): boolean {
|
|
30
|
-
return fr.toBigInt() === BigInt(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
6
|
/**
|
|
34
7
|
* Converts a Noir BoundedVec of Fields into an Fr array. Note that BoundedVecs are structs, and therefore translated as
|
|
35
8
|
* two separate ACVMField values (an array and a single field).
|
|
@@ -39,7 +12,7 @@ export function frToBoolean(fr: Fr): boolean {
|
|
|
39
12
|
* @returns An array with the same content as the Noir version. Elements past the length are discarded.
|
|
40
13
|
*/
|
|
41
14
|
export function fromBoundedVec(storage: ACVMField[], length: ACVMField): Fr[] {
|
|
42
|
-
return storage.slice(0,
|
|
15
|
+
return storage.slice(0, Fr.fromString(length).toNumber()).map(Fr.fromString);
|
|
43
16
|
}
|
|
44
17
|
|
|
45
18
|
/**
|
|
@@ -56,7 +29,7 @@ export function fromUintBoundedVec(storage: ACVMField[], length: ACVMField, uint
|
|
|
56
29
|
throw new Error(`u${uintBitSize} is not a supported type in Noir`);
|
|
57
30
|
}
|
|
58
31
|
const uintByteSize = uintBitSize / 8;
|
|
59
|
-
const boundedStorage = storage.slice(0,
|
|
32
|
+
const boundedStorage = storage.slice(0, Fr.fromString(length).toNumber());
|
|
60
33
|
return Buffer.concat(boundedStorage.map(str => hexToBuffer(str).subarray(-uintByteSize)));
|
|
61
34
|
}
|
|
62
35
|
|
|
@@ -67,7 +40,7 @@ export function fromUintBoundedVec(storage: ACVMField[], length: ACVMField, uint
|
|
|
67
40
|
*/
|
|
68
41
|
export function witnessMapToFields(witness: ACVMWitness): Fr[] {
|
|
69
42
|
const sortedKeys = [...witness.keys()].sort((a, b) => a - b);
|
|
70
|
-
return sortedKeys.map(key => witness.get(key)!).map(
|
|
43
|
+
return sortedKeys.map(key => witness.get(key)!).map(Fr.fromString);
|
|
71
44
|
}
|
|
72
45
|
|
|
73
46
|
/**
|