@aztec/simulator 0.55.1 → 0.57.0
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/acvm/oracle/oracle.d.ts +2 -5
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +6 -37
- package/dest/acvm/oracle/typed_oracle.d.ts +3 -6
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +1 -10
- package/dest/avm/avm_execution_environment.d.ts +2 -11
- package/dest/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/avm/avm_execution_environment.js +3 -22
- package/dest/avm/avm_gas.d.ts +2 -2
- package/dest/avm/avm_gas.d.ts.map +1 -1
- package/dest/avm/avm_gas.js +31 -116
- package/dest/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/avm/avm_machine_state.js +6 -6
- package/dest/avm/avm_memory_types.d.ts +38 -9
- package/dest/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/avm/avm_memory_types.js +27 -13
- package/dest/avm/avm_simulator.d.ts.map +1 -1
- package/dest/avm/avm_simulator.js +5 -6
- package/dest/avm/bytecode_utils.d.ts +1 -2
- package/dest/avm/bytecode_utils.d.ts.map +1 -1
- package/dest/avm/bytecode_utils.js +3 -17
- package/dest/avm/errors.d.ts +1 -1
- package/dest/avm/errors.d.ts.map +1 -1
- package/dest/avm/errors.js +12 -3
- package/dest/avm/fixtures/index.d.ts +4 -16
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +11 -27
- package/dest/avm/journal/index.d.ts +0 -1
- package/dest/avm/journal/index.d.ts.map +1 -1
- package/dest/avm/journal/index.js +1 -2
- package/dest/avm/journal/journal.d.ts +6 -5
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +18 -16
- package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/avm/opcodes/accrued_substate.js +37 -30
- package/dest/avm/opcodes/addressing_mode.d.ts +3 -2
- package/dest/avm/opcodes/addressing_mode.d.ts.map +1 -1
- package/dest/avm/opcodes/addressing_mode.js +25 -21
- package/dest/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/avm/opcodes/arithmetic.js +6 -5
- package/dest/avm/opcodes/bitwise.d.ts +10 -4
- package/dest/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/avm/opcodes/bitwise.js +26 -18
- package/dest/avm/opcodes/commitment.d.ts.map +1 -1
- package/dest/avm/opcodes/commitment.js +6 -5
- package/dest/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/avm/opcodes/comparators.js +8 -7
- package/dest/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/avm/opcodes/contract.js +6 -5
- package/dest/avm/opcodes/control_flow.js +6 -6
- package/dest/avm/opcodes/conversion.d.ts +3 -2
- package/dest/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/avm/opcodes/conversion.js +21 -13
- package/dest/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/avm/opcodes/ec_add.js +8 -7
- package/dest/avm/opcodes/environment_getters.d.ts +27 -63
- package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/avm/opcodes/environment_getters.js +76 -80
- package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/avm/opcodes/external_calls.js +27 -16
- package/dest/avm/opcodes/hashing.d.ts +5 -5
- package/dest/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/avm/opcodes/hashing.js +47 -40
- package/dest/avm/opcodes/index.d.ts +3 -0
- package/dest/avm/opcodes/index.d.ts.map +1 -1
- package/dest/avm/opcodes/index.js +4 -1
- package/dest/avm/opcodes/instruction.d.ts +2 -6
- package/dest/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/avm/opcodes/instruction.js +3 -9
- package/dest/avm/opcodes/instruction_impl.d.ts +0 -26
- package/dest/avm/opcodes/instruction_impl.d.ts.map +1 -1
- package/dest/avm/opcodes/instruction_impl.js +1 -51
- package/dest/avm/opcodes/memory.d.ts +5 -12
- package/dest/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/avm/opcodes/memory.js +40 -53
- package/dest/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/avm/opcodes/misc.js +6 -5
- package/dest/avm/opcodes/multi_scalar_mul.d.ts.map +1 -1
- package/dest/avm/opcodes/multi_scalar_mul.js +17 -16
- package/dest/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/avm/opcodes/storage.js +11 -9
- package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/bytecode_serialization.js +5 -25
- package/dest/avm/serialization/instruction_serialization.d.ts +40 -54
- package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/instruction_serialization.js +41 -57
- package/dest/avm/test_utils.d.ts +8 -8
- package/dest/avm/test_utils.d.ts.map +1 -1
- package/dest/avm/test_utils.js +15 -15
- package/dest/client/client_execution_context.d.ts +6 -30
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +31 -53
- package/dest/client/index.d.ts +0 -1
- package/dest/client/index.d.ts.map +1 -1
- package/dest/client/index.js +1 -2
- package/dest/client/private_execution.d.ts +2 -2
- package/dest/client/private_execution.d.ts.map +1 -1
- package/dest/client/private_execution.js +5 -19
- package/dest/client/simulator.d.ts +3 -4
- package/dest/client/simulator.d.ts.map +1 -1
- package/dest/client/simulator.js +1 -1
- package/dest/client/test_utils.d.ts.map +1 -1
- package/dest/client/test_utils.js +12 -6
- package/dest/client/unconstrained_execution.d.ts +2 -2
- package/dest/client/unconstrained_execution.d.ts.map +1 -1
- package/dest/client/unconstrained_execution.js +3 -3
- package/dest/common/debug_fn_name.d.ts +4 -0
- package/dest/common/debug_fn_name.d.ts.map +1 -0
- package/dest/common/debug_fn_name.js +15 -0
- package/dest/common/index.d.ts +0 -1
- package/dest/common/index.d.ts.map +1 -1
- package/dest/common/index.js +1 -2
- package/dest/public/enqueued_call_simulator.d.ts +43 -0
- package/dest/public/enqueued_call_simulator.d.ts.map +1 -0
- package/dest/public/enqueued_call_simulator.js +154 -0
- package/dest/public/enqueued_calls_processor.d.ts +44 -0
- package/dest/public/enqueued_calls_processor.d.ts.map +1 -0
- package/dest/public/enqueued_calls_processor.js +218 -0
- package/dest/public/execution.d.ts +10 -8
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +15 -8
- package/dest/public/executor.d.ts +4 -7
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +10 -14
- package/dest/public/hints_builder.d.ts +4 -3
- package/dest/public/hints_builder.d.ts.map +1 -1
- package/dest/public/hints_builder.js +5 -5
- package/dest/public/index.d.ts +3 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +3 -3
- package/dest/public/public_db_sources.d.ts +17 -24
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +58 -65
- package/dest/public/public_kernel.d.ts +3 -9
- package/dest/public/public_kernel.d.ts.map +1 -1
- package/dest/public/public_kernel.js +13 -40
- package/dest/public/public_kernel_circuit_simulator.d.ts +5 -11
- package/dest/public/public_kernel_circuit_simulator.d.ts.map +1 -1
- package/dest/public/public_kernel_tail_simulator.d.ts +19 -0
- package/dest/public/public_kernel_tail_simulator.d.ts.map +1 -0
- package/dest/public/public_kernel_tail_simulator.js +45 -0
- package/dest/public/public_processor.d.ts +9 -5
- package/dest/public/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor.js +34 -48
- package/dest/public/public_processor_metrics.d.ts +3 -3
- package/dest/public/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor_metrics.js +1 -1
- package/dest/public/side_effect_errors.d.ts +4 -0
- package/dest/public/side_effect_errors.d.ts.map +1 -0
- package/dest/public/side_effect_errors.js +7 -0
- package/dest/public/side_effect_trace.d.ts +2 -2
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +56 -35
- package/dest/public/side_effect_trace_interface.d.ts +1 -1
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/package.json +12 -9
- package/src/acvm/oracle/oracle.ts +7 -85
- package/src/acvm/oracle/typed_oracle.ts +2 -31
- package/src/avm/avm_execution_environment.ts +2 -24
- package/src/avm/avm_gas.ts +30 -115
- package/src/avm/avm_machine_state.ts +5 -5
- package/src/avm/avm_memory_types.ts +41 -14
- package/src/avm/avm_simulator.ts +4 -5
- package/src/avm/bytecode_utils.ts +2 -17
- package/src/avm/errors.ts +11 -3
- package/src/avm/fixtures/index.ts +13 -46
- package/src/avm/journal/index.ts +0 -1
- package/src/avm/journal/journal.ts +22 -22
- package/src/avm/opcodes/accrued_substate.ts +36 -44
- package/src/avm/opcodes/addressing_mode.ts +27 -24
- package/src/avm/opcodes/arithmetic.ts +5 -7
- package/src/avm/opcodes/bitwise.ts +23 -20
- package/src/avm/opcodes/commitment.ts +6 -7
- package/src/avm/opcodes/comparators.ts +7 -9
- package/src/avm/opcodes/contract.ts +5 -7
- package/src/avm/opcodes/control_flow.ts +5 -5
- package/src/avm/opcodes/conversion.ts +19 -12
- package/src/avm/opcodes/ec_add.ts +14 -16
- package/src/avm/opcodes/environment_getters.ts +73 -99
- package/src/avm/opcodes/external_calls.ts +27 -20
- package/src/avm/opcodes/hashing.ts +52 -52
- package/src/avm/opcodes/index.ts +3 -0
- package/src/avm/opcodes/instruction.ts +3 -10
- package/src/avm/opcodes/instruction_impl.ts +0 -62
- package/src/avm/opcodes/memory.ts +37 -67
- package/src/avm/opcodes/misc.ts +5 -7
- package/src/avm/opcodes/multi_scalar_mul.ts +16 -19
- package/src/avm/opcodes/storage.ts +10 -8
- package/src/avm/serialization/bytecode_serialization.ts +11 -35
- package/src/avm/serialization/instruction_serialization.ts +3 -19
- package/src/avm/test_utils.ts +20 -16
- package/src/client/client_execution_context.ts +40 -96
- package/src/client/index.ts +0 -1
- package/src/client/private_execution.ts +9 -9
- package/src/client/simulator.ts +2 -3
- package/src/client/test_utils.ts +36 -9
- package/src/client/unconstrained_execution.ts +3 -8
- package/src/common/debug_fn_name.ts +22 -0
- package/src/common/index.ts +0 -1
- package/src/public/enqueued_call_simulator.ts +335 -0
- package/src/public/enqueued_calls_processor.ts +388 -0
- package/src/public/execution.ts +16 -12
- package/src/public/executor.ts +8 -22
- package/src/public/hints_builder.ts +21 -21
- package/src/public/index.ts +3 -2
- package/src/public/public_db_sources.ts +62 -67
- package/src/public/public_kernel.ts +15 -49
- package/src/public/public_kernel_circuit_simulator.ts +6 -10
- package/src/public/public_kernel_tail_simulator.ts +106 -0
- package/src/public/public_processor.ts +65 -86
- package/src/public/public_processor_metrics.ts +3 -3
- package/src/public/side_effect_errors.ts +6 -0
- package/src/public/side_effect_trace.ts +77 -39
- package/src/public/side_effect_trace_interface.ts +2 -2
- package/dest/avm/journal/host_storage.d.ts +0 -13
- package/dest/avm/journal/host_storage.d.ts.map +0 -1
- package/dest/avm/journal/host_storage.js +0 -13
- package/dest/avm/opcodes/context_getters.d.ts +0 -15
- package/dest/avm/opcodes/context_getters.d.ts.map +0 -1
- package/dest/avm/opcodes/context_getters.js +0 -19
- package/dest/client/execution_result.d.ts +0 -104
- package/dest/client/execution_result.d.ts.map +0 -1
- package/dest/client/execution_result.js +0 -136
- package/dest/common/return_values.d.ts +0 -11
- package/dest/common/return_values.d.ts.map +0 -1
- package/dest/common/return_values.js +0 -13
- package/dest/public/abstract_phase_manager.d.ts +0 -93
- package/dest/public/abstract_phase_manager.d.ts.map +0 -1
- package/dest/public/abstract_phase_manager.js +0 -285
- package/dest/public/app_logic_phase_manager.d.ts +0 -25
- package/dest/public/app_logic_phase_manager.d.ts.map +0 -1
- package/dest/public/app_logic_phase_manager.js +0 -52
- package/dest/public/phase_manager_factory.d.ts +0 -18
- package/dest/public/phase_manager_factory.d.ts.map +0 -1
- package/dest/public/phase_manager_factory.js +0 -56
- package/dest/public/setup_phase_manager.d.ts +0 -25
- package/dest/public/setup_phase_manager.d.ts.map +0 -1
- package/dest/public/setup_phase_manager.js +0 -39
- package/dest/public/tail_phase_manager.d.ts +0 -23
- package/dest/public/tail_phase_manager.d.ts.map +0 -1
- package/dest/public/tail_phase_manager.js +0 -50
- package/dest/public/teardown_phase_manager.d.ts +0 -27
- package/dest/public/teardown_phase_manager.d.ts.map +0 -1
- package/dest/public/teardown_phase_manager.js +0 -56
- package/src/avm/journal/host_storage.ts +0 -14
- package/src/avm/opcodes/context_getters.ts +0 -23
- package/src/client/execution_result.ts +0 -228
- package/src/common/return_values.ts +0 -18
- package/src/public/abstract_phase_manager.ts +0 -522
- package/src/public/app_logic_phase_manager.ts +0 -81
- package/src/public/phase_manager_factory.ts +0 -126
- package/src/public/setup_phase_manager.ts +0 -61
- package/src/public/tail_phase_manager.ts +0 -127
- package/src/public/teardown_phase_manager.ts +0 -86
|
@@ -3,9 +3,6 @@ import {
|
|
|
3
3
|
NestedProcessReturnValues,
|
|
4
4
|
type ProcessedTx,
|
|
5
5
|
type ProcessedTxHandler,
|
|
6
|
-
PublicKernelType,
|
|
7
|
-
type PublicProvingRequest,
|
|
8
|
-
type SimulationError,
|
|
9
6
|
Tx,
|
|
10
7
|
type TxValidator,
|
|
11
8
|
makeProcessedTx,
|
|
@@ -17,7 +14,6 @@ import {
|
|
|
17
14
|
FEE_JUICE_ADDRESS,
|
|
18
15
|
type GlobalVariables,
|
|
19
16
|
type Header,
|
|
20
|
-
type KernelCircuitPublicInputs,
|
|
21
17
|
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
22
18
|
PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
23
19
|
PublicDataUpdateRequest,
|
|
@@ -25,22 +21,16 @@ import {
|
|
|
25
21
|
import { times } from '@aztec/foundation/collection';
|
|
26
22
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
27
23
|
import { Timer } from '@aztec/foundation/timer';
|
|
28
|
-
import { type ProtocolArtifact } from '@aztec/noir-protocol-circuits-types';
|
|
29
24
|
import { ClassRegistererAddress } from '@aztec/protocol-contracts/class-registerer';
|
|
30
|
-
import {
|
|
31
|
-
PublicExecutor,
|
|
32
|
-
type PublicStateDB,
|
|
33
|
-
type SimulationProvider,
|
|
34
|
-
computeFeePayerBalanceLeafSlot,
|
|
35
|
-
computeFeePayerBalanceStorageSlot,
|
|
36
|
-
} from '@aztec/simulator';
|
|
37
25
|
import { Attributes, type TelemetryClient, type Tracer, trackSpan } from '@aztec/telemetry-client';
|
|
38
26
|
import { type ContractDataSource } from '@aztec/types/contracts';
|
|
39
27
|
import { type MerkleTreeOperations } from '@aztec/world-state';
|
|
40
28
|
|
|
41
|
-
import { type
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
29
|
+
import { type SimulationProvider } from '../providers/index.js';
|
|
30
|
+
import { EnqueuedCallsProcessor } from './enqueued_calls_processor.js';
|
|
31
|
+
import { PublicExecutor } from './executor.js';
|
|
32
|
+
import { computeFeePayerBalanceLeafSlot, computeFeePayerBalanceStorageSlot } from './fee_payment.js';
|
|
33
|
+
import { WorldStateDB } from './public_db_sources.js';
|
|
44
34
|
import { RealPublicKernelCircuitSimulator } from './public_kernel.js';
|
|
45
35
|
import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js';
|
|
46
36
|
import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
@@ -65,28 +55,25 @@ export class PublicProcessorFactory {
|
|
|
65
55
|
public create(maybeHistoricalHeader: Header | undefined, globalVariables: GlobalVariables): PublicProcessor {
|
|
66
56
|
const { merkleTree, telemetryClient } = this;
|
|
67
57
|
const historicalHeader = maybeHistoricalHeader ?? merkleTree.getInitialHeader();
|
|
68
|
-
const publicContractsDB = new ContractsDataSourcePublicDB(this.contractDataSource);
|
|
69
58
|
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
worldStateDB,
|
|
76
|
-
historicalHeader,
|
|
77
|
-
telemetryClient,
|
|
78
|
-
);
|
|
79
|
-
return new PublicProcessor(
|
|
59
|
+
const worldStateDB = new WorldStateDB(merkleTree, this.contractDataSource);
|
|
60
|
+
const publicExecutor = new PublicExecutor(worldStateDB, telemetryClient);
|
|
61
|
+
const publicKernelSimulator = new RealPublicKernelCircuitSimulator(this.simulator);
|
|
62
|
+
|
|
63
|
+
return PublicProcessor.create(
|
|
80
64
|
merkleTree,
|
|
81
65
|
publicExecutor,
|
|
82
|
-
|
|
66
|
+
publicKernelSimulator,
|
|
83
67
|
globalVariables,
|
|
84
68
|
historicalHeader,
|
|
85
|
-
|
|
86
|
-
worldStatePublicDB,
|
|
69
|
+
worldStateDB,
|
|
87
70
|
this.telemetryClient,
|
|
88
71
|
);
|
|
89
72
|
}
|
|
73
|
+
|
|
74
|
+
public getInitialHeader() {
|
|
75
|
+
return this.merkleTree.getInitialHeader();
|
|
76
|
+
}
|
|
90
77
|
}
|
|
91
78
|
|
|
92
79
|
/**
|
|
@@ -101,14 +88,44 @@ export class PublicProcessor {
|
|
|
101
88
|
protected publicKernel: PublicKernelCircuitSimulator,
|
|
102
89
|
protected globalVariables: GlobalVariables,
|
|
103
90
|
protected historicalHeader: Header,
|
|
104
|
-
protected
|
|
105
|
-
protected
|
|
91
|
+
protected worldStateDB: WorldStateDB,
|
|
92
|
+
protected enqueuedCallsProcessor: EnqueuedCallsProcessor,
|
|
106
93
|
telemetryClient: TelemetryClient,
|
|
107
94
|
private log = createDebugLogger('aztec:sequencer:public-processor'),
|
|
108
95
|
) {
|
|
109
96
|
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
110
97
|
}
|
|
111
98
|
|
|
99
|
+
static create(
|
|
100
|
+
db: MerkleTreeOperations,
|
|
101
|
+
publicExecutor: PublicExecutor,
|
|
102
|
+
publicKernelSimulator: PublicKernelCircuitSimulator,
|
|
103
|
+
globalVariables: GlobalVariables,
|
|
104
|
+
historicalHeader: Header,
|
|
105
|
+
worldStateDB: WorldStateDB,
|
|
106
|
+
telemetryClient: TelemetryClient,
|
|
107
|
+
) {
|
|
108
|
+
const enqueuedCallsProcessor = EnqueuedCallsProcessor.create(
|
|
109
|
+
db,
|
|
110
|
+
publicExecutor,
|
|
111
|
+
publicKernelSimulator,
|
|
112
|
+
globalVariables,
|
|
113
|
+
historicalHeader,
|
|
114
|
+
worldStateDB,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
return new PublicProcessor(
|
|
118
|
+
db,
|
|
119
|
+
publicExecutor,
|
|
120
|
+
publicKernelSimulator,
|
|
121
|
+
globalVariables,
|
|
122
|
+
historicalHeader,
|
|
123
|
+
worldStateDB,
|
|
124
|
+
enqueuedCallsProcessor,
|
|
125
|
+
telemetryClient,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
112
129
|
get tracer(): Tracer {
|
|
113
130
|
return this.metrics.tracer;
|
|
114
131
|
}
|
|
@@ -151,7 +168,7 @@ export class PublicProcessor {
|
|
|
151
168
|
processedTx.finalPublicDataUpdateRequests = await this.createFinalDataUpdateRequests(processedTx);
|
|
152
169
|
|
|
153
170
|
// Commit the state updates from this transaction
|
|
154
|
-
await this.
|
|
171
|
+
await this.worldStateDB.commit();
|
|
155
172
|
validateProcessedTx(processedTx);
|
|
156
173
|
|
|
157
174
|
// Re-validate the transaction
|
|
@@ -217,14 +234,14 @@ export class PublicProcessor {
|
|
|
217
234
|
const balance =
|
|
218
235
|
existingBalanceWriteIndex > -1
|
|
219
236
|
? finalPublicDataUpdateRequests[existingBalanceWriteIndex].newValue
|
|
220
|
-
: await this.
|
|
237
|
+
: await this.worldStateDB.storageRead(feeJuiceAddress, balanceSlot);
|
|
221
238
|
|
|
222
239
|
if (balance.lt(txFee)) {
|
|
223
240
|
throw new Error(`Not enough balance for fee payer to pay for transaction (got ${balance} needs ${txFee})`);
|
|
224
241
|
}
|
|
225
242
|
|
|
226
243
|
const updatedBalance = balance.sub(txFee);
|
|
227
|
-
await this.
|
|
244
|
+
await this.worldStateDB.storageWrite(feeJuiceAddress, balanceSlot, updatedBalance);
|
|
228
245
|
|
|
229
246
|
finalPublicDataUpdateRequests[
|
|
230
247
|
existingBalanceWriteIndex > -1 ? existingBalanceWriteIndex : MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
|
|
@@ -238,69 +255,31 @@ export class PublicProcessor {
|
|
|
238
255
|
}))
|
|
239
256
|
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
|
|
240
257
|
const timer = new Timer();
|
|
241
|
-
let returnValues: NestedProcessReturnValues[] = [];
|
|
242
|
-
const publicProvingRequests: PublicProvingRequest[] = [];
|
|
243
|
-
let phase: AbstractPhaseManager | undefined = PhaseManagerFactory.phaseFromTx(
|
|
244
|
-
tx,
|
|
245
|
-
this.db,
|
|
246
|
-
this.publicExecutor,
|
|
247
|
-
this.publicKernel,
|
|
248
|
-
this.globalVariables,
|
|
249
|
-
this.historicalHeader,
|
|
250
|
-
this.publicContractsDB,
|
|
251
|
-
this.publicStateDB,
|
|
252
|
-
);
|
|
253
|
-
this.log.debug(`Beginning processing in phase ${phase?.phase} for tx ${tx.getTxHash()}`);
|
|
254
|
-
let publicKernelPublicInput = tx.data.toPublicKernelCircuitPublicInputs();
|
|
255
|
-
let lastKernelArtifact: ProtocolArtifact = 'PrivateKernelTailToPublicArtifact'; // All txs with public calls must carry tail to public proofs
|
|
256
|
-
let finalKernelOutput: KernelCircuitPublicInputs | undefined;
|
|
257
|
-
let revertReason: SimulationError | undefined;
|
|
258
|
-
const gasUsed: ProcessedTx['gasUsed'] = {};
|
|
259
|
-
let phaseCount = 0;
|
|
260
|
-
while (phase) {
|
|
261
|
-
phaseCount++;
|
|
262
|
-
const phaseTimer = new Timer();
|
|
263
|
-
const output = await phase.handle(tx, publicKernelPublicInput, lastKernelArtifact);
|
|
264
|
-
|
|
265
|
-
if (output.revertReason) {
|
|
266
|
-
this.metrics.recordRevertedPhase(phase.phase);
|
|
267
|
-
} else {
|
|
268
|
-
this.metrics.recordPhaseDuration(phase.phase, phaseTimer.ms());
|
|
269
|
-
}
|
|
270
258
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
returnValues = output.returnValues;
|
|
274
|
-
}
|
|
275
|
-
publicProvingRequests.push(...output.publicProvingRequests);
|
|
276
|
-
publicKernelPublicInput = output.publicKernelOutput;
|
|
277
|
-
lastKernelArtifact = output.lastKernelArtifact;
|
|
278
|
-
finalKernelOutput = output.finalKernelOutput;
|
|
279
|
-
revertReason ??= output.revertReason;
|
|
280
|
-
phase = PhaseManagerFactory.phaseFromOutput(
|
|
281
|
-
publicKernelPublicInput,
|
|
282
|
-
phase,
|
|
283
|
-
this.db,
|
|
284
|
-
this.publicExecutor,
|
|
285
|
-
this.publicKernel,
|
|
286
|
-
this.globalVariables,
|
|
287
|
-
this.historicalHeader,
|
|
288
|
-
this.publicContractsDB,
|
|
289
|
-
this.publicStateDB,
|
|
290
|
-
);
|
|
291
|
-
}
|
|
259
|
+
const { tailKernelOutput, returnValues, revertReason, provingRequests, gasUsed, processedPhases } =
|
|
260
|
+
await this.enqueuedCallsProcessor.process(tx);
|
|
292
261
|
|
|
293
|
-
if (!
|
|
262
|
+
if (!tailKernelOutput) {
|
|
294
263
|
this.metrics.recordFailedTx();
|
|
295
264
|
throw new Error('Final public kernel was not executed.');
|
|
296
265
|
}
|
|
297
266
|
|
|
267
|
+
processedPhases.forEach(phase => {
|
|
268
|
+
if (phase.revertReason) {
|
|
269
|
+
this.metrics.recordRevertedPhase(phase.phase);
|
|
270
|
+
} else {
|
|
271
|
+
this.metrics.recordPhaseDuration(phase.phase, phase.durationMs);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
|
|
298
275
|
this.metrics.recordClassRegistration(
|
|
299
276
|
...ContractClassRegisteredEvent.fromLogs(tx.unencryptedLogs.unrollLogs(), ClassRegistererAddress),
|
|
300
277
|
);
|
|
301
278
|
|
|
279
|
+
const phaseCount = processedPhases.length;
|
|
302
280
|
this.metrics.recordTx(phaseCount, timer.ms());
|
|
303
|
-
|
|
281
|
+
|
|
282
|
+
const processedTx = makeProcessedTx(tx, tailKernelOutput, provingRequests, revertReason, gasUsed);
|
|
304
283
|
return [processedTx, returnValues];
|
|
305
284
|
}
|
|
306
285
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PublicKernelPhase } from '@aztec/circuit-types';
|
|
2
2
|
import { type ContractClassRegisteredEvent } from '@aztec/circuits.js';
|
|
3
3
|
import {
|
|
4
4
|
Attributes,
|
|
@@ -56,7 +56,7 @@ export class PublicProcessorMetrics {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
recordPhaseDuration(phaseName:
|
|
59
|
+
recordPhaseDuration(phaseName: PublicKernelPhase, durationMs: number) {
|
|
60
60
|
this.phaseCount.add(1, { [Attributes.TX_PHASE_NAME]: phaseName, [Attributes.OK]: true });
|
|
61
61
|
this.phaseDuration.record(Math.ceil(durationMs), { [Attributes.TX_PHASE_NAME]: phaseName });
|
|
62
62
|
}
|
|
@@ -75,7 +75,7 @@ export class PublicProcessorMetrics {
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
recordRevertedPhase(phaseName:
|
|
78
|
+
recordRevertedPhase(phaseName: PublicKernelPhase) {
|
|
79
79
|
this.phaseCount.add(1, { [Attributes.TX_PHASE_NAME]: phaseName, [Attributes.OK]: false });
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -12,9 +12,19 @@ import {
|
|
|
12
12
|
Gas,
|
|
13
13
|
L2ToL1Message,
|
|
14
14
|
LogHash,
|
|
15
|
+
MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX,
|
|
16
|
+
MAX_L2_TO_L1_MSGS_PER_TX,
|
|
17
|
+
MAX_NOTE_HASHES_PER_TX,
|
|
18
|
+
MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
|
|
19
|
+
MAX_NULLIFIERS_PER_TX,
|
|
20
|
+
MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX,
|
|
21
|
+
MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
22
|
+
MAX_PUBLIC_DATA_READS_PER_TX,
|
|
23
|
+
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
24
|
+
MAX_UNENCRYPTED_LOGS_PER_TX,
|
|
15
25
|
NoteHash,
|
|
16
26
|
Nullifier,
|
|
17
|
-
type
|
|
27
|
+
type PublicInnerCallRequest,
|
|
18
28
|
ReadRequest,
|
|
19
29
|
TreeLeafReadRequest,
|
|
20
30
|
} from '@aztec/circuits.js';
|
|
@@ -26,6 +36,7 @@ import { type AvmContractCallResult } from '../avm/avm_contract_call_result.js';
|
|
|
26
36
|
import { type AvmExecutionEnvironment } from '../avm/avm_execution_environment.js';
|
|
27
37
|
import { createSimulationError } from '../common/errors.js';
|
|
28
38
|
import { type PublicExecutionResult, resultToPublicCallRequest } from './execution.js';
|
|
39
|
+
import { SideEffectLimitReachedError } from './side_effect_errors.js';
|
|
29
40
|
import { type PublicSideEffectTraceInterface } from './side_effect_trace_interface.js';
|
|
30
41
|
|
|
31
42
|
export type TracedContractInstance = { exists: boolean } & ContractInstanceWithAddress;
|
|
@@ -53,9 +64,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
53
64
|
private allUnencryptedLogs: UnencryptedL2Log[] = [];
|
|
54
65
|
private unencryptedLogsHashes: LogHash[] = [];
|
|
55
66
|
|
|
56
|
-
private publicCallRequests:
|
|
57
|
-
|
|
58
|
-
private gotContractInstances: ContractInstanceWithAddress[] = [];
|
|
67
|
+
private publicCallRequests: PublicInnerCallRequest[] = [];
|
|
59
68
|
|
|
60
69
|
private nestedExecutions: PublicExecutionResult[] = [];
|
|
61
70
|
|
|
@@ -81,10 +90,13 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
81
90
|
this.sideEffectCounter++;
|
|
82
91
|
}
|
|
83
92
|
|
|
93
|
+
// TODO(dbanks12): checks against tx-wide limit need access to parent trace's length
|
|
94
|
+
|
|
84
95
|
public tracePublicStorageRead(storageAddress: Fr, slot: Fr, value: Fr, _exists: boolean, _cached: boolean) {
|
|
85
|
-
// TODO(4805): check if some threshold is reached for max storage reads
|
|
86
|
-
// (need access to parent length, or trace needs to be initialized with parent's contents)
|
|
87
96
|
// NOTE: exists and cached are unused for now but may be used for optimizations or kernel hints later
|
|
97
|
+
if (this.contractStorageReads.length >= MAX_PUBLIC_DATA_READS_PER_TX) {
|
|
98
|
+
throw new SideEffectLimitReachedError('contract storage read', MAX_PUBLIC_DATA_READS_PER_TX);
|
|
99
|
+
}
|
|
88
100
|
this.contractStorageReads.push(
|
|
89
101
|
new ContractStorageRead(slot, value, this.sideEffectCounter, AztecAddress.fromField(storageAddress)),
|
|
90
102
|
);
|
|
@@ -96,8 +108,9 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
96
108
|
}
|
|
97
109
|
|
|
98
110
|
public tracePublicStorageWrite(storageAddress: Fr, slot: Fr, value: Fr) {
|
|
99
|
-
|
|
100
|
-
|
|
111
|
+
if (this.contractStorageUpdateRequests.length >= MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) {
|
|
112
|
+
throw new SideEffectLimitReachedError('contract storage write', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
|
|
113
|
+
}
|
|
101
114
|
this.contractStorageUpdateRequests.push(
|
|
102
115
|
new ContractStorageUpdateRequest(slot, value, this.sideEffectCounter, storageAddress),
|
|
103
116
|
);
|
|
@@ -107,32 +120,32 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
107
120
|
|
|
108
121
|
// TODO(8287): _exists can be removed once we have the vm properly handling the equality check
|
|
109
122
|
public traceNoteHashCheck(_storageAddress: Fr, noteHash: Fr, leafIndex: Fr, exists: boolean) {
|
|
110
|
-
// TODO(4805): check if some threshold is reached for max note hash checks
|
|
111
123
|
// NOTE: storageAddress is unused but will be important when an AVM circuit processes an entire enqueued call
|
|
112
|
-
|
|
113
|
-
|
|
124
|
+
if (this.noteHashReadRequests.length >= MAX_NOTE_HASH_READ_REQUESTS_PER_TX) {
|
|
125
|
+
throw new SideEffectLimitReachedError('note hash read request', MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
126
|
+
}
|
|
114
127
|
this.noteHashReadRequests.push(new TreeLeafReadRequest(noteHash, leafIndex));
|
|
115
128
|
this.avmCircuitHints.noteHashExists.items.push(
|
|
116
129
|
new AvmKeyValueHint(/*key=*/ new Fr(leafIndex), /*value=*/ exists ? Fr.ONE : Fr.ZERO),
|
|
117
130
|
);
|
|
131
|
+
// NOTE: counter does not increment for note hash checks (because it doesn't rely on pending note hashes)
|
|
118
132
|
}
|
|
119
133
|
|
|
120
134
|
public traceNewNoteHash(_storageAddress: Fr, noteHash: Fr) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// IS there, and the AVM circuit should accept THAT noteHash as a hint. The circuit will then compare
|
|
125
|
-
// the noteHash against the one provided by the user code to determine what to return to the user (exists or not),
|
|
126
|
-
// and will then propagate the actually-present noteHash to its public inputs.
|
|
135
|
+
if (this.noteHashes.length >= MAX_NOTE_HASHES_PER_TX) {
|
|
136
|
+
throw new SideEffectLimitReachedError('note hash', MAX_NOTE_HASHES_PER_TX);
|
|
137
|
+
}
|
|
127
138
|
this.noteHashes.push(new NoteHash(noteHash, this.sideEffectCounter));
|
|
128
139
|
this.logger.debug(`NEW_NOTE_HASH cnt: ${this.sideEffectCounter}`);
|
|
129
140
|
this.incrementSideEffectCounter();
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
public traceNullifierCheck(_storageAddress: Fr, nullifier: Fr, _leafIndex: Fr, exists: boolean, _isPending: boolean) {
|
|
133
|
-
// TODO(4805): check if some threshold is reached for max new nullifier
|
|
134
144
|
// NOTE: storageAddress is unused but will be important when an AVM circuit processes an entire enqueued call
|
|
135
145
|
// NOTE: isPending and leafIndex are unused for now but may be used for optimizations or kernel hints later
|
|
146
|
+
|
|
147
|
+
this.enforceLimitOnNullifierChecks();
|
|
148
|
+
|
|
136
149
|
const readRequest = new ReadRequest(nullifier, this.sideEffectCounter);
|
|
137
150
|
if (exists) {
|
|
138
151
|
this.nullifierReadRequests.push(readRequest);
|
|
@@ -147,8 +160,10 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
147
160
|
}
|
|
148
161
|
|
|
149
162
|
public traceNewNullifier(_storageAddress: Fr, nullifier: Fr) {
|
|
150
|
-
// TODO(4805): check if some threshold is reached for max new nullifier
|
|
151
163
|
// NOTE: storageAddress is unused but will be important when an AVM circuit processes an entire enqueued call
|
|
164
|
+
if (this.nullifiers.length >= MAX_NULLIFIERS_PER_TX) {
|
|
165
|
+
throw new SideEffectLimitReachedError('nullifier', MAX_NULLIFIERS_PER_TX);
|
|
166
|
+
}
|
|
152
167
|
this.nullifiers.push(new Nullifier(nullifier, this.sideEffectCounter, /*noteHash=*/ Fr.ZERO));
|
|
153
168
|
this.logger.debug(`NEW_NULLIFIER cnt: ${this.sideEffectCounter}`);
|
|
154
169
|
this.incrementSideEffectCounter();
|
|
@@ -156,18 +171,21 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
156
171
|
|
|
157
172
|
// TODO(8287): _exists can be removed once we have the vm properly handling the equality check
|
|
158
173
|
public traceL1ToL2MessageCheck(_contractAddress: Fr, msgHash: Fr, msgLeafIndex: Fr, exists: boolean) {
|
|
159
|
-
// TODO(4805): check if some threshold is reached for max message reads
|
|
160
174
|
// NOTE: contractAddress is unused but will be important when an AVM circuit processes an entire enqueued call
|
|
161
|
-
|
|
162
|
-
|
|
175
|
+
if (this.l1ToL2MsgReadRequests.length >= MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX) {
|
|
176
|
+
throw new SideEffectLimitReachedError('l1 to l2 message read request', MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX);
|
|
177
|
+
}
|
|
163
178
|
this.l1ToL2MsgReadRequests.push(new TreeLeafReadRequest(msgHash, msgLeafIndex));
|
|
164
179
|
this.avmCircuitHints.l1ToL2MessageExists.items.push(
|
|
165
180
|
new AvmKeyValueHint(/*key=*/ new Fr(msgLeafIndex), /*value=*/ exists ? Fr.ONE : Fr.ZERO),
|
|
166
181
|
);
|
|
182
|
+
// NOTE: counter does not increment for l1tol2 message checks (because it doesn't rely on pending messages)
|
|
167
183
|
}
|
|
168
184
|
|
|
169
|
-
public traceNewL2ToL1Message(recipient: Fr, content: Fr) {
|
|
170
|
-
|
|
185
|
+
public traceNewL2ToL1Message(_contractAddress: Fr, recipient: Fr, content: Fr) {
|
|
186
|
+
if (this.newL2ToL1Messages.length >= MAX_L2_TO_L1_MSGS_PER_TX) {
|
|
187
|
+
throw new SideEffectLimitReachedError('l2 to l1 message', MAX_L2_TO_L1_MSGS_PER_TX);
|
|
188
|
+
}
|
|
171
189
|
const recipientAddress = EthAddress.fromField(recipient);
|
|
172
190
|
this.newL2ToL1Messages.push(new L2ToL1Message(recipientAddress, content, this.sideEffectCounter));
|
|
173
191
|
this.logger.debug(`NEW_L2_TO_L1_MSG cnt: ${this.sideEffectCounter}`);
|
|
@@ -175,7 +193,9 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
175
193
|
}
|
|
176
194
|
|
|
177
195
|
public traceUnencryptedLog(contractAddress: Fr, log: Fr[]) {
|
|
178
|
-
|
|
196
|
+
if (this.unencryptedLogs.length >= MAX_UNENCRYPTED_LOGS_PER_TX) {
|
|
197
|
+
throw new SideEffectLimitReachedError('unencrypted log', MAX_UNENCRYPTED_LOGS_PER_TX);
|
|
198
|
+
}
|
|
179
199
|
const ulog = new UnencryptedL2Log(
|
|
180
200
|
AztecAddress.fromField(contractAddress),
|
|
181
201
|
Buffer.concat(log.map(f => f.toBuffer())),
|
|
@@ -183,18 +203,17 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
183
203
|
const basicLogHash = Fr.fromBuffer(ulog.hash());
|
|
184
204
|
this.unencryptedLogs.push(ulog);
|
|
185
205
|
this.allUnencryptedLogs.push(ulog);
|
|
186
|
-
//
|
|
187
|
-
// The
|
|
188
|
-
// we need to add four to the length here.
|
|
189
|
-
// https://github.com/AztecProtocol/aztec-packages/issues/6578#issuecomment-2125003435
|
|
206
|
+
// This length is for charging DA and is checked on-chain - has to be length of log preimage + 4 bytes.
|
|
207
|
+
// The .length call also has a +4 but that is unrelated
|
|
190
208
|
this.unencryptedLogsHashes.push(new LogHash(basicLogHash, this.sideEffectCounter, new Fr(ulog.length + 4)));
|
|
191
209
|
this.logger.debug(`NEW_UNENCRYPTED_LOG cnt: ${this.sideEffectCounter}`);
|
|
192
210
|
this.incrementSideEffectCounter();
|
|
193
211
|
}
|
|
194
212
|
|
|
195
213
|
public traceGetContractInstance(instance: TracedContractInstance) {
|
|
196
|
-
|
|
197
|
-
|
|
214
|
+
this.enforceLimitOnNullifierChecks('(contract address nullifier from GETCONTRACTINSTANCE)');
|
|
215
|
+
// TODO(dbanks12): should emit a nullifier read request
|
|
216
|
+
|
|
198
217
|
this.avmCircuitHints.contractInstances.items.push(
|
|
199
218
|
new AvmContractInstanceHint(
|
|
200
219
|
instance.address,
|
|
@@ -230,6 +249,11 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
230
249
|
/** Function name for logging */
|
|
231
250
|
functionName: string = 'unknown',
|
|
232
251
|
) {
|
|
252
|
+
// TODO(4805): check if some threshold is reached for max nested calls (to unique contracts?)
|
|
253
|
+
// TODO(dbanks12): should emit a nullifier read request. There should be two thresholds.
|
|
254
|
+
// one for max unique contract calls, and another based on max nullifier reads.
|
|
255
|
+
// Since this trace function happens _after_ a nested call, such threshold limits must take
|
|
256
|
+
// place in another trace function that occurs _before_ a nested call.
|
|
233
257
|
const result = nestedCallTrace.toPublicExecutionResult(
|
|
234
258
|
nestedEnvironment,
|
|
235
259
|
startGasLeft,
|
|
@@ -307,8 +331,6 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
307
331
|
unencryptedLogs: new UnencryptedFunctionL2Logs(this.unencryptedLogs),
|
|
308
332
|
allUnencryptedLogs: new UnencryptedFunctionL2Logs(this.allUnencryptedLogs),
|
|
309
333
|
unencryptedLogsHashes: this.unencryptedLogsHashes,
|
|
310
|
-
// TODO(dbanks12): process contract instance read requests in public kernel
|
|
311
|
-
//gotContractInstances: this.gotContractInstances,
|
|
312
334
|
|
|
313
335
|
publicCallRequests: this.publicCallRequests,
|
|
314
336
|
nestedExecutions: this.nestedExecutions,
|
|
@@ -318,6 +340,27 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
318
340
|
functionName,
|
|
319
341
|
};
|
|
320
342
|
}
|
|
343
|
+
|
|
344
|
+
private enforceLimitOnNullifierChecks(errorMsgOrigin: string = '') {
|
|
345
|
+
// NOTE: Why error if _either_ limit was reached? If user code emits either an existent or non-existent
|
|
346
|
+
// nullifier read request (NULLIFIEREXISTS, GETCONTRACTINSTANCE, *CALL), and one of the limits has been
|
|
347
|
+
// reached (MAX_NULLIFIER_NON_EXISTENT_RRS vs MAX_NULLIFIER_RRS), but not the other, we must prevent the
|
|
348
|
+
// sequencer from lying and saying "this nullifier exists, but MAX_NULLIFIER_RRS has been reached, so I'm
|
|
349
|
+
// going to skip the read request and just revert instead" when the nullifier actually doesn't exist
|
|
350
|
+
// (or vice versa). So, if either maximum has been reached, any nullifier-reading operation must error.
|
|
351
|
+
if (this.nullifierReadRequests.length >= MAX_NULLIFIER_READ_REQUESTS_PER_TX) {
|
|
352
|
+
throw new SideEffectLimitReachedError(
|
|
353
|
+
`nullifier read request ${errorMsgOrigin}`,
|
|
354
|
+
MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
if (this.nullifierNonExistentReadRequests.length >= MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX) {
|
|
358
|
+
throw new SideEffectLimitReachedError(
|
|
359
|
+
`nullifier non-existent read request ${errorMsgOrigin}`,
|
|
360
|
+
MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX,
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
321
364
|
}
|
|
322
365
|
|
|
323
366
|
/**
|
|
@@ -331,10 +374,5 @@ function createPublicExecutionRequest(avmEnvironment: AvmExecutionEnvironment):
|
|
|
331
374
|
isDelegateCall: avmEnvironment.isDelegateCall,
|
|
332
375
|
isStaticCall: avmEnvironment.isStaticCall,
|
|
333
376
|
});
|
|
334
|
-
return new PublicExecutionRequest(
|
|
335
|
-
avmEnvironment.address,
|
|
336
|
-
callContext,
|
|
337
|
-
// execution request does not contain AvmContextInputs prefix
|
|
338
|
-
avmEnvironment.getCalldataWithoutPrefix(),
|
|
339
|
-
);
|
|
377
|
+
return new PublicExecutionRequest(avmEnvironment.address, callContext, avmEnvironment.calldata);
|
|
340
378
|
}
|
|
@@ -8,6 +8,7 @@ import { type TracedContractInstance } from './side_effect_trace.js';
|
|
|
8
8
|
export interface PublicSideEffectTraceInterface {
|
|
9
9
|
fork(): PublicSideEffectTraceInterface;
|
|
10
10
|
getCounter(): number;
|
|
11
|
+
// all "trace*" functions can throw SideEffectLimitReachedError
|
|
11
12
|
tracePublicStorageRead(storageAddress: Fr, slot: Fr, value: Fr, exists: boolean, cached: boolean): void;
|
|
12
13
|
tracePublicStorageWrite(storageAddress: Fr, slot: Fr, value: Fr): void;
|
|
13
14
|
traceNoteHashCheck(storageAddress: Fr, noteHash: Fr, leafIndex: Fr, exists: boolean): void;
|
|
@@ -15,8 +16,7 @@ export interface PublicSideEffectTraceInterface {
|
|
|
15
16
|
traceNullifierCheck(storageAddress: Fr, nullifier: Fr, leafIndex: Fr, exists: boolean, isPending: boolean): void;
|
|
16
17
|
traceNewNullifier(storageAddress: Fr, nullifier: Fr): void;
|
|
17
18
|
traceL1ToL2MessageCheck(contractAddress: Fr, msgHash: Fr, msgLeafIndex: Fr, exists: boolean): void;
|
|
18
|
-
|
|
19
|
-
traceNewL2ToL1Message(recipient: Fr, content: Fr): void;
|
|
19
|
+
traceNewL2ToL1Message(contractAddress: Fr, recipient: Fr, content: Fr): void;
|
|
20
20
|
traceUnencryptedLog(contractAddress: Fr, log: Fr[]): void;
|
|
21
21
|
// TODO(dbanks12): odd that getContractInstance is a one-off in that it accepts an entire object instead of components
|
|
22
22
|
traceGetContractInstance(instance: TracedContractInstance): void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type CommitmentsDB, type PublicContractsDB, type PublicStateDB } from '../../public/db_interfaces.js';
|
|
2
|
-
/**
|
|
3
|
-
* Host storage
|
|
4
|
-
*
|
|
5
|
-
* A wrapper around the node dbs
|
|
6
|
-
*/
|
|
7
|
-
export declare class HostStorage {
|
|
8
|
-
readonly publicStateDb: PublicStateDB;
|
|
9
|
-
readonly contractsDb: PublicContractsDB;
|
|
10
|
-
readonly commitmentsDb: CommitmentsDB;
|
|
11
|
-
constructor(publicStateDb: PublicStateDB, contractsDb: PublicContractsDB, commitmentsDb: CommitmentsDB);
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=host_storage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"host_storage.d.ts","sourceRoot":"","sources":["../../../src/avm/journal/host_storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE/G;;;;GAIG;AACH,qBAAa,WAAW;aAEJ,aAAa,EAAE,aAAa;aAC5B,WAAW,EAAE,iBAAiB;aAC9B,aAAa,EAAE,aAAa;gBAF5B,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,iBAAiB,EAC9B,aAAa,EAAE,aAAa;CAE/C"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host storage
|
|
3
|
-
*
|
|
4
|
-
* A wrapper around the node dbs
|
|
5
|
-
*/
|
|
6
|
-
export class HostStorage {
|
|
7
|
-
constructor(publicStateDb, contractsDb, commitmentsDb) {
|
|
8
|
-
this.publicStateDb = publicStateDb;
|
|
9
|
-
this.contractsDb = contractsDb;
|
|
10
|
-
this.commitmentsDb = commitmentsDb;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaG9zdF9zdG9yYWdlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2F2bS9qb3VybmFsL2hvc3Rfc3RvcmFnZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQTs7OztHQUlHO0FBQ0gsTUFBTSxPQUFPLFdBQVc7SUFDdEIsWUFDa0IsYUFBNEIsRUFDNUIsV0FBOEIsRUFDOUIsYUFBNEI7UUFGNUIsa0JBQWEsR0FBYixhQUFhLENBQWU7UUFDNUIsZ0JBQVcsR0FBWCxXQUFXLENBQW1CO1FBQzlCLGtCQUFhLEdBQWIsYUFBYSxDQUFlO0lBQzNDLENBQUM7Q0FDTCJ9
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { AvmContext } from '../avm_context.js';
|
|
2
|
-
import { type MemoryValue } from '../avm_memory_types.js';
|
|
3
|
-
import { Opcode } from '../serialization/instruction_serialization.js';
|
|
4
|
-
import { GetterInstruction } from './instruction_impl.js';
|
|
5
|
-
export declare class L2GasLeft extends GetterInstruction {
|
|
6
|
-
static type: string;
|
|
7
|
-
static readonly opcode: Opcode;
|
|
8
|
-
protected getValue(context: AvmContext): MemoryValue;
|
|
9
|
-
}
|
|
10
|
-
export declare class DAGasLeft extends GetterInstruction {
|
|
11
|
-
static type: string;
|
|
12
|
-
static readonly opcode: Opcode;
|
|
13
|
-
protected getValue(context: AvmContext): MemoryValue;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=context_getters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context_getters.d.ts","sourceRoot":"","sources":["../../../src/avm/opcodes/context_getters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAS,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,+CAA+C,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,qBAAa,SAAU,SAAQ,iBAAiB;IAC9C,MAAM,CAAC,IAAI,EAAE,MAAM,CAAe;IAClC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAoB;IAGlD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,WAAW;CAGrD;AAED,qBAAa,SAAU,SAAQ,iBAAiB;IAC9C,MAAM,CAAC,IAAI,EAAE,MAAM,CAAe;IAClC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAoB;IAElD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,WAAW;CAGrD"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Field } from '../avm_memory_types.js';
|
|
2
|
-
import { Opcode } from '../serialization/instruction_serialization.js';
|
|
3
|
-
import { GetterInstruction } from './instruction_impl.js';
|
|
4
|
-
export class L2GasLeft extends GetterInstruction {
|
|
5
|
-
// TODO(@spalladino) Protocol specs specifies that the value should be an Uint32, not a Field.
|
|
6
|
-
getValue(context) {
|
|
7
|
-
return new Field(context.machineState.l2GasLeft);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
L2GasLeft.type = 'L2GASLEFT';
|
|
11
|
-
L2GasLeft.opcode = Opcode.L2GASLEFT;
|
|
12
|
-
export class DAGasLeft extends GetterInstruction {
|
|
13
|
-
getValue(context) {
|
|
14
|
-
return new Field(context.machineState.daGasLeft);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
DAGasLeft.type = 'DAGASLEFT';
|
|
18
|
-
DAGasLeft.opcode = Opcode.DAGASLEFT;
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4dF9nZXR0ZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2F2bS9vcGNvZGVzL2NvbnRleHRfZ2V0dGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsS0FBSyxFQUFvQixNQUFNLHdCQUF3QixDQUFDO0FBQ2pFLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSwrQ0FBK0MsQ0FBQztBQUN2RSxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUUxRCxNQUFNLE9BQU8sU0FBVSxTQUFRLGlCQUFpQjtJQUk5Qyw4RkFBOEY7SUFDcEYsUUFBUSxDQUFDLE9BQW1CO1FBQ3BDLE9BQU8sSUFBSSxLQUFLLENBQUMsT0FBTyxDQUFDLFlBQVksQ0FBQyxTQUFTLENBQUMsQ0FBQztJQUNuRCxDQUFDOztBQU5NLGNBQUksR0FBVyxXQUFXLENBQUM7QUFDbEIsZ0JBQU0sR0FBVyxNQUFNLENBQUMsU0FBUyxDQUFDO0FBUXBELE1BQU0sT0FBTyxTQUFVLFNBQVEsaUJBQWlCO0lBSXBDLFFBQVEsQ0FBQyxPQUFtQjtRQUNwQyxPQUFPLElBQUksS0FBSyxDQUFDLE9BQU8sQ0FBQyxZQUFZLENBQUMsU0FBUyxDQUFDLENBQUM7SUFDbkQsQ0FBQzs7QUFMTSxjQUFJLEdBQVcsV0FBVyxDQUFDO0FBQ2xCLGdCQUFNLEdBQVcsTUFBTSxDQUFDLFNBQVMsQ0FBQyJ9
|