@aztec/simulator 0.0.1-commit.c7c42ec → 0.0.1-commit.c80b6263
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/README.md +2 -0
- package/dest/common/errors.d.ts +7 -1
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/private/acvm/acvm.d.ts +4 -2
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +4 -3
- package/dest/private/acvm_native.d.ts +5 -3
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/acvm_native.js +8 -6
- package/dest/private/acvm_wasm.d.ts +4 -3
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm.js +4 -4
- package/dest/private/circuit_recording/circuit_recorder.d.ts +4 -3
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +20 -17
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
- package/dest/private/factory.d.ts +3 -3
- package/dest/private/factory.d.ts.map +1 -1
- package/dest/private/factory.js +7 -4
- package/dest/public/avm/avm_context.d.ts +3 -3
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +6 -6
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.js +3 -3
- package/dest/public/avm/avm_execution_environment.d.ts +6 -5
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.d.ts +6 -5
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.js +3 -2
- package/dest/public/avm/avm_memory_types.d.ts +1 -1
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +3 -0
- package/dest/public/avm/avm_simulator.d.ts +3 -2
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +5 -4
- package/dest/public/avm/calldata.d.ts +51 -0
- package/dest/public/avm/calldata.d.ts.map +1 -0
- package/dest/public/avm/calldata.js +63 -0
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +3 -2
- package/dest/public/avm/fixtures/initializers.d.ts +1 -1
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -1
- package/dest/public/avm/fixtures/initializers.js +2 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts +16 -17
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +39 -39
- package/dest/public/avm/opcodes/arithmetic.d.ts +8 -8
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/public/avm/opcodes/arithmetic.js +1 -1
- package/dest/public/avm/opcodes/bitwise.d.ts +7 -7
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/public/avm/opcodes/bitwise.js +5 -5
- package/dest/public/avm/opcodes/comparators.d.ts +4 -4
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.js +1 -1
- package/dest/public/avm/opcodes/contract.d.ts +3 -3
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +8 -8
- package/dest/public/avm/opcodes/control_flow.d.ts +3 -3
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.js +4 -4
- package/dest/public/avm/opcodes/conversion.d.ts +3 -3
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +4 -4
- package/dest/public/avm/opcodes/ec_add.d.ts +4 -4
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +15 -6
- package/dest/public/avm/opcodes/environment_getters.d.ts +5 -5
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +6 -6
- package/dest/public/avm/opcodes/external_calls.d.ts +9 -9
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +23 -22
- package/dest/public/avm/opcodes/hashing.d.ts +8 -8
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +12 -12
- package/dest/public/avm/opcodes/instruction_impl.d.ts +4 -4
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction_impl.js +4 -4
- package/dest/public/avm/opcodes/memory.d.ts +14 -14
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +25 -25
- package/dest/public/avm/opcodes/misc.d.ts +3 -3
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +4 -4
- package/dest/public/avm/opcodes/storage.d.ts +16 -15
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/public/avm/opcodes/storage.js +34 -24
- package/dest/public/debug_fn_name.d.ts +4 -4
- package/dest/public/debug_fn_name.d.ts.map +1 -1
- package/dest/public/debug_fn_name.js +7 -5
- package/dest/public/executor_metrics.d.ts +1 -1
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +12 -33
- package/dest/public/fixtures/bulk_test.d.ts +3 -3
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +1 -17
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +11 -11
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +18 -18
- package/dest/public/fixtures/minimal_public_tx.js +2 -2
- package/dest/public/fixtures/opcode_spammer.d.ts +3 -4
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -1
- package/dest/public/fixtures/opcode_spammer.js +95 -123
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +21 -7
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -1
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +42 -10
- package/dest/public/fuzzing/avm_simulator_bin.js +29 -11
- package/dest/public/hinting_db_sources.js +3 -1
- package/dest/public/public_db_sources.d.ts +4 -3
- 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/guarded_merkle_tree.js +3 -1
- package/dest/public/public_processor/public_processor.d.ts +6 -4
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +410 -26
- package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +28 -45
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +3 -2
- 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 +2 -2
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +5 -5
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +10 -9
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +4 -4
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +5 -5
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +4 -4
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +6 -6
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +3 -2
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.js +2 -2
- package/dest/public/public_tx_simulator/factories.d.ts +3 -2
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/factories.js +3 -3
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +4 -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 -8
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +6 -4
- 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/public_tx_simulator/telemetry_public_tx_simulator.js +395 -19
- package/dest/public/side_effect_trace.d.ts +5 -4
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +3 -3
- package/dest/public/state_manager/state_manager.d.ts +10 -4
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +14 -7
- package/dest/public/test_executor_metrics.d.ts +3 -2
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +2 -2
- package/package.json +17 -17
- package/src/private/acvm/acvm.ts +4 -3
- package/src/private/acvm_native.ts +11 -5
- package/src/private/acvm_wasm.ts +7 -3
- package/src/private/circuit_recording/circuit_recorder.ts +21 -18
- package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
- package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
- package/src/private/factory.ts +7 -4
- package/src/public/avm/avm_context.ts +2 -2
- package/src/public/avm/avm_contract_call_result.ts +8 -6
- package/src/public/avm/avm_execution_environment.ts +9 -4
- package/src/public/avm/avm_machine_state.ts +6 -5
- package/src/public/avm/avm_memory_types.ts +4 -0
- package/src/public/avm/avm_simulator.ts +8 -5
- package/src/public/avm/calldata.ts +100 -0
- package/src/public/avm/fixtures/avm_simulation_tester.ts +8 -2
- package/src/public/avm/fixtures/initializers.ts +2 -1
- package/src/public/avm/opcodes/accrued_substate.ts +28 -30
- package/src/public/avm/opcodes/arithmetic.ts +1 -1
- package/src/public/avm/opcodes/bitwise.ts +3 -3
- package/src/public/avm/opcodes/comparators.ts +1 -1
- package/src/public/avm/opcodes/contract.ts +4 -7
- package/src/public/avm/opcodes/control_flow.ts +2 -2
- package/src/public/avm/opcodes/conversion.ts +3 -3
- package/src/public/avm/opcodes/ec_add.ts +13 -4
- package/src/public/avm/opcodes/environment_getters.ts +7 -7
- package/src/public/avm/opcodes/external_calls.ts +17 -15
- package/src/public/avm/opcodes/hashing.ts +6 -6
- package/src/public/avm/opcodes/instruction_impl.ts +2 -2
- package/src/public/avm/opcodes/memory.ts +19 -19
- package/src/public/avm/opcodes/misc.ts +2 -2
- package/src/public/avm/opcodes/storage.ts +30 -22
- package/src/public/debug_fn_name.ts +10 -8
- package/src/public/executor_metrics.ts +9 -33
- package/src/public/fixtures/bulk_test.ts +2 -2
- package/src/public/fixtures/custom_bytecode_tests.ts +27 -18
- package/src/public/fixtures/minimal_public_tx.ts +2 -2
- package/src/public/fixtures/opcode_spammer.ts +196 -113
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +60 -12
- package/src/public/fuzzing/avm_simulator_bin.ts +43 -8
- package/src/public/public_db_sources.ts +15 -5
- package/src/public/public_processor/public_processor.ts +21 -7
- package/src/public/public_processor/public_processor_metrics.ts +16 -44
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +6 -3
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +18 -7
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +6 -4
- package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +7 -5
- package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +3 -1
- package/src/public/public_tx_simulator/factories.ts +4 -2
- package/src/public/public_tx_simulator/public_tx_context.ts +13 -6
- package/src/public/public_tx_simulator/public_tx_simulator.ts +18 -7
- package/src/public/side_effect_trace.ts +5 -2
- package/src/public/state_manager/state_manager.ts +29 -20
- package/src/public/test_executor_metrics.ts +3 -3
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '@aztec/constants';
|
|
8
8
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
9
9
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
10
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
11
11
|
import {
|
|
12
12
|
AvmAccumulatedData,
|
|
13
13
|
AvmAccumulatedDataArrayLengths,
|
|
@@ -87,8 +87,9 @@ export class PublicTxContext {
|
|
|
87
87
|
public readonly revertibleAccumulatedDataFromPrivate: PrivateToPublicAccumulatedData,
|
|
88
88
|
public readonly feePayer: AztecAddress,
|
|
89
89
|
private readonly trace: SideEffectTrace,
|
|
90
|
+
bindings?: LoggerBindings,
|
|
90
91
|
) {
|
|
91
|
-
this.log = createLogger(`simulator:public_tx_context
|
|
92
|
+
this.log = createLogger(`simulator:public_tx_context`, bindings);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
public static async create(
|
|
@@ -98,13 +99,14 @@ export class PublicTxContext {
|
|
|
98
99
|
globalVariables: GlobalVariables,
|
|
99
100
|
protocolContracts: ProtocolContracts,
|
|
100
101
|
proverId: Fr,
|
|
102
|
+
bindings?: LoggerBindings,
|
|
101
103
|
) {
|
|
102
104
|
const contractDeploymentData = AllContractDeploymentData.fromTx(tx);
|
|
103
105
|
const nonRevertibleContractDeploymentData = contractDeploymentData.getNonRevertibleContractDeploymentData();
|
|
104
106
|
const revertibleContractDeploymentData = contractDeploymentData.getRevertibleContractDeploymentData();
|
|
105
107
|
const nonRevertibleAccumulatedDataFromPrivate = tx.data.forPublic!.nonRevertibleAccumulatedData;
|
|
106
108
|
|
|
107
|
-
const trace = new SideEffectTrace();
|
|
109
|
+
const trace = new SideEffectTrace(0, bindings);
|
|
108
110
|
|
|
109
111
|
const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
|
|
110
112
|
|
|
@@ -115,6 +117,7 @@ export class PublicTxContext {
|
|
|
115
117
|
trace,
|
|
116
118
|
firstNullifier,
|
|
117
119
|
globalVariables.timestamp,
|
|
120
|
+
bindings,
|
|
118
121
|
);
|
|
119
122
|
|
|
120
123
|
const gasSettings = tx.data.constants.txContext.gasSettings;
|
|
@@ -124,7 +127,7 @@ export class PublicTxContext {
|
|
|
124
127
|
|
|
125
128
|
return new PublicTxContext(
|
|
126
129
|
tx.getTxHash(),
|
|
127
|
-
new PhaseStateManager(txStateManager),
|
|
130
|
+
new PhaseStateManager(txStateManager, bindings),
|
|
128
131
|
await txStateManager.getTreeSnapshots(),
|
|
129
132
|
globalVariables,
|
|
130
133
|
protocolContracts,
|
|
@@ -142,6 +145,7 @@ export class PublicTxContext {
|
|
|
142
145
|
tx.data.forPublic!.revertibleAccumulatedData,
|
|
143
146
|
tx.data.feePayer,
|
|
144
147
|
trace,
|
|
148
|
+
bindings,
|
|
145
149
|
);
|
|
146
150
|
}
|
|
147
151
|
|
|
@@ -441,8 +445,11 @@ class PhaseStateManager {
|
|
|
441
445
|
|
|
442
446
|
private currentlyActiveStateManager: PublicPersistableStateManager | undefined;
|
|
443
447
|
|
|
444
|
-
constructor(
|
|
445
|
-
|
|
448
|
+
constructor(
|
|
449
|
+
private readonly txStateManager: PublicPersistableStateManager,
|
|
450
|
+
bindings?: LoggerBindings,
|
|
451
|
+
) {
|
|
452
|
+
this.log = createLogger(`simulator:public_phase_state_manager`, bindings);
|
|
446
453
|
}
|
|
447
454
|
|
|
448
455
|
async fork() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AVM_MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { ProtocolContractAddress, ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
5
5
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
6
6
|
import { AvmExecutionHints, AvmTxHint, PublicSimulatorConfig, PublicTxEffect, PublicTxResult } from '@aztec/stdlib/avm';
|
|
@@ -10,6 +10,7 @@ import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
|
10
10
|
import {
|
|
11
11
|
type GlobalVariables,
|
|
12
12
|
NestedProcessReturnValues,
|
|
13
|
+
ProtocolContracts,
|
|
13
14
|
PublicCallRequestWithCalldata,
|
|
14
15
|
Tx,
|
|
15
16
|
TxExecutionPhase,
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
import { strict as assert } from 'assert';
|
|
19
20
|
|
|
20
21
|
import type { AvmFinalizedCallResult } from '../avm/avm_contract_call_result.js';
|
|
22
|
+
import { CallDataArray } from '../avm/calldata.js';
|
|
21
23
|
import { AvmSimulator } from '../avm/index.js';
|
|
22
24
|
import { getPublicFunctionDebugName } from '../debug_fn_name.js';
|
|
23
25
|
import { HintingMerkleWriteOperations, HintingPublicContractsDB } from '../hinting_db_sources.js';
|
|
@@ -79,15 +81,19 @@ type ProcessedPhase = {
|
|
|
79
81
|
export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
80
82
|
protected log: Logger;
|
|
81
83
|
protected readonly config: PublicSimulatorConfig;
|
|
84
|
+
protected readonly bindings?: LoggerBindings;
|
|
82
85
|
|
|
83
86
|
constructor(
|
|
84
87
|
protected merkleTree: MerkleTreeWriteOperations,
|
|
85
88
|
protected contractsDB: PublicContractsDB,
|
|
86
89
|
protected globalVariables: GlobalVariables,
|
|
87
90
|
config?: Partial<PublicSimulatorConfig>,
|
|
91
|
+
protected protocolContracts: ProtocolContracts = ProtocolContractsList,
|
|
92
|
+
bindings?: LoggerBindings,
|
|
88
93
|
) {
|
|
89
94
|
this.config = PublicSimulatorConfig.from(config ?? {});
|
|
90
|
-
this.
|
|
95
|
+
this.bindings = bindings;
|
|
96
|
+
this.log = createLogger(`simulator:public_tx_simulator`, bindings);
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
/**
|
|
@@ -103,7 +109,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
103
109
|
const hints = new AvmExecutionHints(
|
|
104
110
|
this.globalVariables,
|
|
105
111
|
AvmTxHint.fromTx(tx, this.globalVariables.gasFees),
|
|
106
|
-
|
|
112
|
+
this.protocolContracts,
|
|
107
113
|
);
|
|
108
114
|
const hintingMerkleTree = await HintingMerkleWriteOperations.create(this.merkleTree, hints);
|
|
109
115
|
const hintingTreesDB = new PublicTreesDB(hintingMerkleTree);
|
|
@@ -114,8 +120,9 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
114
120
|
hintingContractsDB,
|
|
115
121
|
tx,
|
|
116
122
|
this.globalVariables,
|
|
117
|
-
|
|
123
|
+
this.protocolContracts,
|
|
118
124
|
this.config.proverId,
|
|
125
|
+
this.bindings,
|
|
119
126
|
);
|
|
120
127
|
|
|
121
128
|
// This will throw if there is a nullifier collision.
|
|
@@ -265,7 +272,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
265
272
|
|
|
266
273
|
const enqueuedCallResult = await this.simulateEnqueuedCall(phase, context, callRequest);
|
|
267
274
|
|
|
268
|
-
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output));
|
|
275
|
+
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output.bestEffortReadAll()));
|
|
269
276
|
|
|
270
277
|
if (enqueuedCallResult.reverted) {
|
|
271
278
|
reverted = true;
|
|
@@ -295,7 +302,11 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
295
302
|
): Promise<AvmFinalizedCallResult> {
|
|
296
303
|
const stateManager = context.state.getActiveStateManager();
|
|
297
304
|
const contractAddress = callRequest.request.contractAddress;
|
|
298
|
-
const fnName = await getPublicFunctionDebugName(
|
|
305
|
+
const fnName = await getPublicFunctionDebugName(
|
|
306
|
+
this.contractsDB,
|
|
307
|
+
contractAddress,
|
|
308
|
+
new CallDataArray(callRequest.calldata),
|
|
309
|
+
);
|
|
299
310
|
|
|
300
311
|
const allocatedGas = context.getGasLeftAtPhase(phase);
|
|
301
312
|
|
|
@@ -355,7 +366,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
355
366
|
transactionFee,
|
|
356
367
|
this.globalVariables,
|
|
357
368
|
request.isStaticCall,
|
|
358
|
-
calldata,
|
|
369
|
+
new CallDataArray(calldata),
|
|
359
370
|
allocatedGas,
|
|
360
371
|
this.config,
|
|
361
372
|
);
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@aztec/constants';
|
|
10
10
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
11
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
|
-
import { type LogLevel, createLogger } from '@aztec/foundation/log';
|
|
12
|
+
import { type LogLevel, type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
13
13
|
import { PublicDataUpdateRequest } from '@aztec/stdlib/avm';
|
|
14
14
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
15
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
@@ -61,7 +61,7 @@ export class SideEffectArrayLengths {
|
|
|
61
61
|
* Trace side effects for an enqueued public call's execution.
|
|
62
62
|
*/
|
|
63
63
|
export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
64
|
-
public log
|
|
64
|
+
public log: Logger;
|
|
65
65
|
|
|
66
66
|
/** The side effect counter increments with every call to the trace. */
|
|
67
67
|
private sideEffectCounter: number;
|
|
@@ -79,6 +79,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
79
79
|
constructor(
|
|
80
80
|
/** The counter of this trace's first side effect. */
|
|
81
81
|
public readonly startSideEffectCounter: number = 0,
|
|
82
|
+
bindings?: LoggerBindings,
|
|
82
83
|
/** Track parent's (or previous kernel's) lengths so the AVM can properly enforce TX-wide limits,
|
|
83
84
|
* otherwise the public kernel can fail to prove because TX limits are breached.
|
|
84
85
|
*/
|
|
@@ -90,11 +91,13 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
90
91
|
private debugLogMemoryReads: number = 0,
|
|
91
92
|
) {
|
|
92
93
|
this.sideEffectCounter = startSideEffectCounter;
|
|
94
|
+
this.log = createLogger('simulator:side_effect_trace', bindings);
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
public fork() {
|
|
96
98
|
return new SideEffectTrace(
|
|
97
99
|
this.sideEffectCounter,
|
|
100
|
+
this.log.getBindings(),
|
|
98
101
|
new SideEffectArrayLengths(
|
|
99
102
|
this.previousSideEffectArrayLengths.publicDataWrites + this.userPublicDataWritesLength,
|
|
100
103
|
this.previousSideEffectArrayLengths.protocolPublicDataWrites + this.protocolPublicDataWritesLength,
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CANONICAL_AUTH_REGISTRY_ADDRESS,
|
|
3
|
-
CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS,
|
|
4
|
-
CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
|
|
5
|
-
FEE_JUICE_ADDRESS,
|
|
6
|
-
MULTI_CALL_ENTRYPOINT_ADDRESS,
|
|
7
|
-
ROUTER_ADDRESS,
|
|
8
|
-
} from '@aztec/constants';
|
|
1
|
+
import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, MAX_PROTOCOL_CONTRACTS } from '@aztec/constants';
|
|
9
2
|
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
10
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
4
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
12
|
-
import { type LogLevel, createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { type LogLevel, type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
13
6
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
14
7
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
15
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -49,7 +42,7 @@ import { PublicStorage } from './public_storage.js';
|
|
|
49
42
|
* Manages merging of successful/reverted child state into current state.
|
|
50
43
|
*/
|
|
51
44
|
export class PublicPersistableStateManager {
|
|
52
|
-
private readonly log
|
|
45
|
+
private readonly log: Logger;
|
|
53
46
|
|
|
54
47
|
/** Make sure a forked state is never merged twice. */
|
|
55
48
|
private alreadyMergedIntoParent = false;
|
|
@@ -63,7 +56,10 @@ export class PublicPersistableStateManager {
|
|
|
63
56
|
private readonly doMerkleOperations: boolean = true,
|
|
64
57
|
private readonly publicStorage: PublicStorage = new PublicStorage(treesDB),
|
|
65
58
|
private readonly nullifiers: NullifierManager = new NullifierManager(treesDB),
|
|
66
|
-
|
|
59
|
+
bindings?: LoggerBindings,
|
|
60
|
+
) {
|
|
61
|
+
this.log = createLogger('simulator:state_manager', bindings);
|
|
62
|
+
}
|
|
67
63
|
|
|
68
64
|
/**
|
|
69
65
|
* Create a new state manager
|
|
@@ -74,8 +70,19 @@ export class PublicPersistableStateManager {
|
|
|
74
70
|
trace: PublicSideEffectTraceInterface,
|
|
75
71
|
firstNullifier: Fr,
|
|
76
72
|
timestamp: UInt64,
|
|
73
|
+
bindings?: LoggerBindings,
|
|
77
74
|
): PublicPersistableStateManager {
|
|
78
|
-
return new PublicPersistableStateManager(
|
|
75
|
+
return new PublicPersistableStateManager(
|
|
76
|
+
treesDB,
|
|
77
|
+
contractsDB,
|
|
78
|
+
trace,
|
|
79
|
+
firstNullifier,
|
|
80
|
+
timestamp,
|
|
81
|
+
undefined,
|
|
82
|
+
undefined,
|
|
83
|
+
undefined,
|
|
84
|
+
bindings,
|
|
85
|
+
);
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
/**
|
|
@@ -92,6 +99,7 @@ export class PublicPersistableStateManager {
|
|
|
92
99
|
this.doMerkleOperations,
|
|
93
100
|
this.publicStorage.fork(),
|
|
94
101
|
this.nullifiers.fork(),
|
|
102
|
+
this.log.getBindings(),
|
|
95
103
|
);
|
|
96
104
|
}
|
|
97
105
|
|
|
@@ -240,7 +248,15 @@ export class PublicPersistableStateManager {
|
|
|
240
248
|
public async checkNullifierExists(contractAddress: AztecAddress, nullifier: Fr): Promise<boolean> {
|
|
241
249
|
this.log.trace(`Checking existence of nullifier (address=${contractAddress}, nullifier=${nullifier})`);
|
|
242
250
|
const siloedNullifier = await siloNullifier(contractAddress, nullifier);
|
|
251
|
+
return this.checkSiloedNullifierExists(siloedNullifier);
|
|
252
|
+
}
|
|
243
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Check if a siloed nullifier exists.
|
|
256
|
+
* @param siloedNullifier - the siloed nullifier to check
|
|
257
|
+
* @returns exists - whether the nullifier exists in the nullifier set
|
|
258
|
+
*/
|
|
259
|
+
public async checkSiloedNullifierExists(siloedNullifier: Fr): Promise<boolean> {
|
|
244
260
|
if (this.doMerkleOperations) {
|
|
245
261
|
const exists = await this.treesDB.checkNullifierExists(siloedNullifier);
|
|
246
262
|
this.log.trace(`Checked siloed nullifier ${siloedNullifier} (exists=${exists})`);
|
|
@@ -549,12 +565,5 @@ export class PublicPersistableStateManager {
|
|
|
549
565
|
}
|
|
550
566
|
|
|
551
567
|
function contractAddressIsCanonical(contractAddress: AztecAddress): boolean {
|
|
552
|
-
return (
|
|
553
|
-
contractAddress.equals(AztecAddress.fromNumber(CANONICAL_AUTH_REGISTRY_ADDRESS)) ||
|
|
554
|
-
contractAddress.equals(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS)) ||
|
|
555
|
-
contractAddress.equals(AztecAddress.fromNumber(CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS)) ||
|
|
556
|
-
contractAddress.equals(AztecAddress.fromNumber(MULTI_CALL_ENTRYPOINT_ADDRESS)) ||
|
|
557
|
-
contractAddress.equals(AztecAddress.fromNumber(FEE_JUICE_ADDRESS)) ||
|
|
558
|
-
contractAddress.equals(AztecAddress.fromNumber(ROUTER_ADDRESS))
|
|
559
|
-
);
|
|
568
|
+
return contractAddress.toBigInt() >= 1 && contractAddress.toBigInt() <= MAX_PROTOCOL_CONTRACTS;
|
|
560
569
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sum } from '@aztec/foundation/collection';
|
|
2
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import type { RevertCode } from '@aztec/stdlib/avm';
|
|
5
5
|
import type { GasUsed } from '@aztec/stdlib/gas';
|
|
@@ -88,8 +88,8 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
88
88
|
private currentTxLabel: string | undefined;
|
|
89
89
|
private txTimer: Timer | undefined;
|
|
90
90
|
|
|
91
|
-
constructor() {
|
|
92
|
-
this.logger = createLogger(`simulator:test_executor_metrics
|
|
91
|
+
constructor(bindings?: LoggerBindings) {
|
|
92
|
+
this.logger = createLogger(`simulator:test_executor_metrics`, bindings);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
startRecordingTxSimulation(txLabel: string) {
|