@aztec/simulator 0.43.0 → 0.45.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 +3 -1
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +12 -6
- package/dest/acvm/oracle/typed_oracle.d.ts +6 -4
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +8 -2
- package/dest/avm/avm_context.d.ts +1 -1
- package/dest/avm/avm_context.d.ts.map +1 -1
- package/dest/avm/avm_context.js +3 -3
- package/dest/avm/{avm_message_call_result.d.ts → avm_contract_call_result.d.ts} +2 -2
- package/dest/avm/avm_contract_call_result.d.ts.map +1 -0
- package/dest/avm/avm_contract_call_result.js +18 -0
- package/dest/avm/avm_execution_environment.d.ts +8 -10
- package/dest/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/avm/avm_execution_environment.js +15 -19
- package/dest/avm/avm_gas.js +2 -2
- package/dest/avm/avm_simulator.d.ts +4 -4
- package/dest/avm/avm_simulator.d.ts.map +1 -1
- package/dest/avm/avm_simulator.js +7 -8
- package/dest/avm/bytecode_utils.d.ts +5 -0
- package/dest/avm/bytecode_utils.d.ts.map +1 -0
- package/dest/avm/bytecode_utils.js +29 -0
- package/dest/avm/errors.js +2 -2
- package/dest/avm/fixtures/index.d.ts +10 -6
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +10 -17
- package/dest/avm/journal/journal.d.ts +56 -65
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +80 -117
- package/dest/avm/journal/nullifiers.d.ts +21 -8
- package/dest/avm/journal/nullifiers.d.ts.map +1 -1
- package/dest/avm/journal/nullifiers.js +26 -8
- package/dest/avm/journal/public_storage.d.ts +5 -1
- package/dest/avm/journal/public_storage.d.ts.map +1 -1
- package/dest/avm/journal/public_storage.js +11 -2
- package/dest/avm/opcodes/accrued_substate.d.ts +1 -2
- package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/avm/opcodes/accrued_substate.js +8 -17
- package/dest/avm/opcodes/environment_getters.d.ts +13 -8
- package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/avm/opcodes/environment_getters.js +20 -13
- package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/avm/opcodes/external_calls.js +11 -27
- package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/bytecode_serialization.js +5 -5
- package/dest/avm/serialization/instruction_serialization.d.ts +9 -9
- package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/instruction_serialization.js +10 -10
- package/dest/avm/test_utils.d.ts +14 -0
- package/dest/avm/test_utils.d.ts.map +1 -0
- package/dest/avm/test_utils.js +36 -0
- package/dest/client/client_execution_context.d.ts +6 -4
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +8 -6
- package/dest/client/execution_note_cache.d.ts.map +1 -1
- package/dest/client/execution_note_cache.js +1 -1
- package/dest/client/execution_result.d.ts +2 -1
- package/dest/client/execution_result.d.ts.map +1 -1
- package/dest/client/execution_result.js +1 -1
- package/dest/client/index.d.ts +2 -0
- package/dest/client/index.d.ts.map +1 -1
- package/dest/client/index.js +3 -1
- package/dest/client/simulator.d.ts +3 -3
- package/dest/client/simulator.d.ts.map +1 -1
- package/dest/client/simulator.js +1 -1
- package/dest/client/view_data_oracle.d.ts +5 -1
- package/dest/client/view_data_oracle.d.ts.map +1 -1
- package/dest/client/view_data_oracle.js +12 -4
- package/dest/mocks/fixtures.d.ts +3 -3
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +6 -5
- package/dest/public/abstract_phase_manager.d.ts +1 -0
- package/dest/public/abstract_phase_manager.d.ts.map +1 -1
- package/dest/public/abstract_phase_manager.js +17 -14
- package/dest/public/app_logic_phase_manager.d.ts.map +1 -1
- package/dest/public/app_logic_phase_manager.js +2 -1
- package/dest/public/execution.d.ts +33 -30
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +2 -2
- package/dest/public/executor.d.ts +12 -7
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +42 -33
- package/dest/public/hints_builder.d.ts +1 -1
- package/dest/public/index.d.ts +1 -1
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +1 -1
- package/dest/public/public_kernel.d.ts +1 -1
- package/dest/public/public_kernel.d.ts.map +1 -1
- package/dest/public/public_kernel.js +2 -2
- package/dest/public/public_processor.d.ts +5 -2
- package/dest/public/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor.js +142 -123
- package/dest/public/side_effect_trace.d.ts +87 -0
- package/dest/public/side_effect_trace.d.ts.map +1 -0
- package/dest/public/side_effect_trace.js +236 -0
- package/dest/public/side_effect_trace_interface.d.ts +36 -0
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -0
- package/dest/public/side_effect_trace_interface.js +2 -0
- package/dest/public/teardown_phase_manager.d.ts.map +1 -1
- package/dest/public/teardown_phase_manager.js +2 -1
- package/dest/rollup/rollup.d.ts +1 -1
- package/dest/rollup/rollup.d.ts.map +1 -1
- package/dest/rollup/rollup.js +2 -2
- package/package.json +18 -9
- package/src/acvm/oracle/oracle.ts +23 -5
- package/src/acvm/oracle/typed_oracle.ts +23 -4
- package/src/avm/avm_context.ts +2 -2
- package/src/avm/{avm_message_call_result.ts → avm_contract_call_result.ts} +1 -1
- package/src/avm/avm_execution_environment.ts +16 -26
- package/src/avm/avm_gas.ts +1 -1
- package/src/avm/avm_simulator.ts +10 -13
- package/src/avm/bytecode_utils.ts +32 -0
- package/src/avm/errors.ts +1 -1
- package/src/avm/fixtures/index.ts +21 -23
- package/src/avm/journal/journal.ts +118 -224
- package/src/avm/journal/nullifiers.ts +30 -13
- package/src/avm/journal/public_storage.ts +12 -2
- package/src/avm/opcodes/accrued_substate.ts +12 -21
- package/src/avm/opcodes/environment_getters.ts +23 -14
- package/src/avm/opcodes/external_calls.ts +13 -36
- package/src/avm/serialization/bytecode_serialization.ts +4 -3
- package/src/avm/serialization/instruction_serialization.ts +3 -3
- package/src/avm/test_utils.ts +53 -0
- package/src/client/client_execution_context.ts +22 -7
- package/src/client/execution_note_cache.ts +0 -1
- package/src/client/execution_result.ts +2 -1
- package/src/client/index.ts +2 -0
- package/src/client/simulator.ts +8 -2
- package/src/client/view_data_oracle.ts +20 -3
- package/src/mocks/fixtures.ts +7 -6
- package/src/public/abstract_phase_manager.ts +32 -21
- package/src/public/app_logic_phase_manager.ts +1 -0
- package/src/public/execution.ts +45 -31
- package/src/public/executor.ts +71 -49
- package/src/public/index.ts +1 -1
- package/src/public/public_kernel.ts +2 -1
- package/src/public/public_processor.ts +11 -2
- package/src/public/side_effect_trace.ts +341 -0
- package/src/public/side_effect_trace_interface.ts +41 -0
- package/src/public/teardown_phase_manager.ts +1 -0
- package/src/rollup/rollup.ts +3 -1
- package/dest/avm/avm_message_call_result.d.ts.map +0 -1
- package/dest/avm/avm_message_call_result.js +0 -18
- package/dest/avm/journal/trace.d.ts +0 -33
- package/dest/avm/journal/trace.d.ts.map +0 -1
- package/dest/avm/journal/trace.js +0 -152
- package/dest/avm/journal/trace_types.d.ts +0 -55
- package/dest/avm/journal/trace_types.d.ts.map +0 -1
- package/dest/avm/journal/trace_types.js +0 -2
- package/dest/public/transitional_adaptors.d.ts +0 -21
- package/dest/public/transitional_adaptors.d.ts.map +0 -1
- package/dest/public/transitional_adaptors.js +0 -90
- package/src/avm/journal/trace.ts +0 -181
- package/src/avm/journal/trace_types.ts +0 -91
- package/src/public/transitional_adaptors.ts +0 -168
package/src/public/execution.ts
CHANGED
|
@@ -18,18 +18,39 @@ import { type Gas } from '../avm/avm_gas.js';
|
|
|
18
18
|
* The public function execution result.
|
|
19
19
|
*/
|
|
20
20
|
export interface PublicExecutionResult {
|
|
21
|
-
/** The execution that triggered this result. */
|
|
22
|
-
|
|
21
|
+
/** The execution request that triggered this result. */
|
|
22
|
+
executionRequest: PublicExecutionRequest;
|
|
23
|
+
|
|
24
|
+
/** The side effect counter at the start of the function call. */
|
|
25
|
+
startSideEffectCounter: Fr;
|
|
26
|
+
/** The side effect counter after executing this function call */
|
|
27
|
+
endSideEffectCounter: Fr;
|
|
28
|
+
/** How much gas was available for this public execution. */
|
|
29
|
+
startGasLeft: Gas;
|
|
30
|
+
/** How much gas was left after this public execution. */
|
|
31
|
+
endGasLeft: Gas;
|
|
32
|
+
/** Transaction fee set for this tx. */
|
|
33
|
+
transactionFee: Fr;
|
|
34
|
+
|
|
35
|
+
/** Bytecode used for this execution. */
|
|
36
|
+
bytecode?: Buffer;
|
|
37
|
+
/** Calldata used for this execution. */
|
|
38
|
+
calldata: Fr[];
|
|
23
39
|
/** The return values of the function. */
|
|
24
40
|
returnValues: Fr[];
|
|
41
|
+
/** Whether the execution reverted. */
|
|
42
|
+
reverted: boolean;
|
|
43
|
+
/** The revert reason if the execution reverted. */
|
|
44
|
+
revertReason?: SimulationError;
|
|
45
|
+
|
|
46
|
+
/** The contract storage reads performed by the function. */
|
|
47
|
+
contractStorageReads: ContractStorageRead[];
|
|
48
|
+
/** The contract storage update requests performed by the function. */
|
|
49
|
+
contractStorageUpdateRequests: ContractStorageUpdateRequest[];
|
|
25
50
|
/** The new note hashes to be inserted into the note hashes tree. */
|
|
26
51
|
newNoteHashes: NoteHash[];
|
|
27
52
|
/** The new l2 to l1 messages generated in this call. */
|
|
28
53
|
newL2ToL1Messages: L2ToL1Message[];
|
|
29
|
-
/** The side effect counter at the start of the function call. */
|
|
30
|
-
startSideEffectCounter: Fr;
|
|
31
|
-
/** The side effect counter after executing this function call */
|
|
32
|
-
endSideEffectCounter: Fr;
|
|
33
54
|
/** The new nullifiers to be inserted into the nullifier tree. */
|
|
34
55
|
newNullifiers: Nullifier[];
|
|
35
56
|
/** The note hash read requests emitted in this call. */
|
|
@@ -40,12 +61,6 @@ export interface PublicExecutionResult {
|
|
|
40
61
|
nullifierNonExistentReadRequests: ReadRequest[];
|
|
41
62
|
/** L1 to L2 message read requests emitted in this call. */
|
|
42
63
|
l1ToL2MsgReadRequests: ReadRequest[];
|
|
43
|
-
/** The contract storage reads performed by the function. */
|
|
44
|
-
contractStorageReads: ContractStorageRead[];
|
|
45
|
-
/** The contract storage update requests performed by the function. */
|
|
46
|
-
contractStorageUpdateRequests: ContractStorageUpdateRequest[];
|
|
47
|
-
/** The results of nested calls. */
|
|
48
|
-
nestedExecutions: this[];
|
|
49
64
|
/**
|
|
50
65
|
* The hashed logs with side effect counter.
|
|
51
66
|
* Note: required as we don't track the counter anywhere else.
|
|
@@ -61,28 +76,27 @@ export interface PublicExecutionResult {
|
|
|
61
76
|
* Useful for maintaining correct ordering in ts.
|
|
62
77
|
*/
|
|
63
78
|
allUnencryptedLogs: UnencryptedFunctionL2Logs;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/** How much gas was left after this public execution. */
|
|
71
|
-
endGasLeft: Gas;
|
|
72
|
-
/** Transaction fee set for this tx. */
|
|
73
|
-
transactionFee: Fr;
|
|
74
|
-
/** Bytecode used for this execution. */
|
|
75
|
-
bytecode?: Buffer;
|
|
76
|
-
/** Calldata used for this execution. */
|
|
77
|
-
calldata: Fr[];
|
|
79
|
+
|
|
80
|
+
// TODO(dbanks12): add contract instance read requests
|
|
81
|
+
|
|
82
|
+
/** The results of nested calls. */
|
|
83
|
+
nestedExecutions: this[];
|
|
84
|
+
|
|
78
85
|
/** Hints for proving AVM execution. */
|
|
79
|
-
|
|
86
|
+
avmCircuitHints: AvmExecutionHints;
|
|
87
|
+
|
|
88
|
+
/** The name of the function that was executed. Only used for logging. */
|
|
89
|
+
functionName: string;
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
/**
|
|
83
|
-
* The execution of a public function.
|
|
93
|
+
* The execution request of a public function.
|
|
94
|
+
* A subset of PublicCallRequest
|
|
84
95
|
*/
|
|
85
|
-
export type
|
|
96
|
+
export type PublicExecutionRequest = Pick<
|
|
97
|
+
PublicCallRequest,
|
|
98
|
+
'contractAddress' | 'functionSelector' | 'callContext' | 'args'
|
|
99
|
+
>;
|
|
86
100
|
|
|
87
101
|
/**
|
|
88
102
|
* Returns if the input is a public execution result and not just a public execution.
|
|
@@ -90,9 +104,9 @@ export type PublicExecution = Pick<PublicCallRequest, 'contractAddress' | 'funct
|
|
|
90
104
|
* @returns Whether the input is a public execution result and not just a public execution.
|
|
91
105
|
*/
|
|
92
106
|
export function isPublicExecutionResult(
|
|
93
|
-
input:
|
|
107
|
+
input: PublicExecutionRequest | PublicExecutionResult,
|
|
94
108
|
): input is PublicExecutionResult {
|
|
95
|
-
return '
|
|
109
|
+
return 'executionRequest' in input && input.executionRequest !== undefined;
|
|
96
110
|
}
|
|
97
111
|
|
|
98
112
|
/**
|
package/src/public/executor.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { type AvmSimulationStats } from '@aztec/circuit-types/stats';
|
|
2
|
-
import { Fr,
|
|
2
|
+
import { Fr, Gas, type GlobalVariables, type Header, type Nullifier, type TxContext } from '@aztec/circuits.js';
|
|
3
3
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
5
|
|
|
6
6
|
import { AvmContext } from '../avm/avm_context.js';
|
|
7
|
+
import { AvmExecutionEnvironment } from '../avm/avm_execution_environment.js';
|
|
7
8
|
import { AvmMachineState } from '../avm/avm_machine_state.js';
|
|
8
9
|
import { AvmSimulator } from '../avm/avm_simulator.js';
|
|
9
10
|
import { HostStorage } from '../avm/journal/host_storage.js';
|
|
10
11
|
import { AvmPersistableStateManager } from '../avm/journal/index.js';
|
|
11
12
|
import { type CommitmentsDB, type PublicContractsDB, type PublicStateDB } from './db_interfaces.js';
|
|
12
|
-
import { type
|
|
13
|
-
import {
|
|
13
|
+
import { type PublicExecutionRequest, type PublicExecutionResult } from './execution.js';
|
|
14
|
+
import { PublicSideEffectTrace } from './side_effect_trace.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Handles execution of public functions.
|
|
17
18
|
*/
|
|
18
19
|
export class PublicExecutor {
|
|
19
20
|
constructor(
|
|
20
|
-
private readonly
|
|
21
|
+
private readonly publicStorageDB: PublicStateDB,
|
|
21
22
|
private readonly contractsDb: PublicContractsDB,
|
|
22
23
|
private readonly commitmentsDb: CommitmentsDB,
|
|
23
24
|
private readonly header: Header,
|
|
@@ -27,54 +28,56 @@ export class PublicExecutor {
|
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Executes a public execution request.
|
|
30
|
-
* @param
|
|
31
|
+
* @param executionRequest - The execution to run.
|
|
31
32
|
* @param globalVariables - The global variables to use.
|
|
32
|
-
* @
|
|
33
|
+
* @param availableGas - The gas available at the start of this enqueued call.
|
|
34
|
+
* @param txContext - Transaction context.
|
|
35
|
+
* @param pendingSiloedNullifiers - The pending nullifier set from earlier parts of this TX.
|
|
36
|
+
* @param transactionFee - Fee offered for this TX.
|
|
37
|
+
* @param startSideEffectCounter - The counter of the first side-effect generated by this simulation.
|
|
38
|
+
* @returns The result of execution, including the results of all nested calls.
|
|
33
39
|
*/
|
|
34
40
|
public async simulate(
|
|
35
|
-
|
|
41
|
+
executionRequest: PublicExecutionRequest,
|
|
36
42
|
globalVariables: GlobalVariables,
|
|
37
43
|
availableGas: Gas,
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
_txContext: TxContext,
|
|
45
|
+
pendingSiloedNullifiers: Nullifier[],
|
|
40
46
|
transactionFee: Fr = Fr.ZERO,
|
|
41
47
|
startSideEffectCounter: number = 0,
|
|
42
48
|
): Promise<PublicExecutionResult> {
|
|
43
|
-
const address =
|
|
44
|
-
const selector =
|
|
45
|
-
const
|
|
46
|
-
const fnName = await this.contractsDb.getDebugFunctionName(address, selector);
|
|
49
|
+
const address = executionRequest.contractAddress;
|
|
50
|
+
const selector = executionRequest.functionSelector;
|
|
51
|
+
const fnName = (await this.contractsDb.getDebugFunctionName(address, selector)) ?? `${address}:${selector}`;
|
|
47
52
|
|
|
48
53
|
PublicExecutor.log.verbose(`[AVM] Executing public external function ${fnName}.`);
|
|
49
54
|
const timer = new Timer();
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
worldStateJournal.trace.accessCounter = startSideEffectCounter;
|
|
56
|
+
const hostStorage = new HostStorage(this.publicStorageDB, this.contractsDb, this.commitmentsDb);
|
|
57
|
+
const trace = new PublicSideEffectTrace(startSideEffectCounter);
|
|
58
|
+
const avmPersistableState = AvmPersistableStateManager.newWithPendingSiloedNullifiers(
|
|
59
|
+
hostStorage,
|
|
60
|
+
trace,
|
|
61
|
+
pendingSiloedNullifiers.map(n => n.value),
|
|
62
|
+
);
|
|
60
63
|
|
|
61
|
-
const
|
|
62
|
-
|
|
64
|
+
const avmExecutionEnv = createAvmExecutionEnvironment(
|
|
65
|
+
executionRequest,
|
|
63
66
|
this.header,
|
|
64
67
|
globalVariables,
|
|
65
|
-
txContext.gasSettings,
|
|
66
68
|
transactionFee,
|
|
67
69
|
);
|
|
68
70
|
|
|
69
|
-
const
|
|
70
|
-
const avmContext = new AvmContext(
|
|
71
|
+
const avmMachineState = new AvmMachineState(availableGas);
|
|
72
|
+
const avmContext = new AvmContext(avmPersistableState, avmExecutionEnv, avmMachineState);
|
|
71
73
|
const simulator = new AvmSimulator(avmContext);
|
|
72
74
|
const avmResult = await simulator.execute();
|
|
73
|
-
const bytecode = simulator.getBytecode()
|
|
75
|
+
const bytecode = simulator.getBytecode()!;
|
|
74
76
|
|
|
75
|
-
// Commit the
|
|
77
|
+
// Commit the public storage state to the DBs since this is a top-level execution.
|
|
76
78
|
// Observe that this will write all the state changes to the DBs, not only the latest for each slot.
|
|
77
79
|
// However, the underlying DB keep a cache and will only write the latest state to disk.
|
|
80
|
+
// TODO(dbanks12): this should be unnecessary here or should be exposed by state manager
|
|
78
81
|
await avmContext.persistableState.publicStorage.commitToDB();
|
|
79
82
|
|
|
80
83
|
PublicExecutor.log.verbose(
|
|
@@ -83,33 +86,52 @@ export class PublicExecutor {
|
|
|
83
86
|
}.`,
|
|
84
87
|
{
|
|
85
88
|
eventName: 'avm-simulation',
|
|
86
|
-
appCircuitName: fnName
|
|
89
|
+
appCircuitName: fnName,
|
|
87
90
|
duration: timer.ms(),
|
|
88
91
|
bytecodeSize: bytecode!.length,
|
|
89
92
|
} satisfies AvmSimulationStats,
|
|
90
93
|
);
|
|
91
94
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
startGas,
|
|
97
|
-
avmContext,
|
|
95
|
+
const publicExecutionResult = trace.toPublicExecutionResult(
|
|
96
|
+
avmExecutionEnv,
|
|
97
|
+
/*startGasLeft=*/ availableGas,
|
|
98
|
+
/*endGasLeft=*/ Gas.from(avmContext.machineState.gasLeft),
|
|
98
99
|
bytecode,
|
|
100
|
+
avmResult,
|
|
101
|
+
fnName,
|
|
102
|
+
/*requestSideEffectCounter=*/ executionRequest.callContext.sideEffectCounter,
|
|
103
|
+
// NOTE: startSideEffectCounter is not the same as the executionRequest's sideEffectCounter
|
|
104
|
+
// (which counts the request itself)
|
|
99
105
|
);
|
|
100
106
|
|
|
101
|
-
|
|
102
|
-
// should already be handled in simulation.
|
|
103
|
-
if (execution.callContext.isStaticCall) {
|
|
104
|
-
checkValidStaticCall(
|
|
105
|
-
executionResult.newNoteHashes,
|
|
106
|
-
executionResult.newNullifiers,
|
|
107
|
-
executionResult.contractStorageUpdateRequests,
|
|
108
|
-
executionResult.newL2ToL1Messages,
|
|
109
|
-
executionResult.unencryptedLogs,
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return executionResult;
|
|
107
|
+
return publicExecutionResult;
|
|
114
108
|
}
|
|
115
109
|
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Convert a PublicExecutionRequest object to an AvmExecutionEnvironment
|
|
113
|
+
*
|
|
114
|
+
* @param executionRequest
|
|
115
|
+
* @param globalVariables
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
function createAvmExecutionEnvironment(
|
|
119
|
+
executionRequest: PublicExecutionRequest,
|
|
120
|
+
header: Header,
|
|
121
|
+
globalVariables: GlobalVariables,
|
|
122
|
+
transactionFee: Fr,
|
|
123
|
+
): AvmExecutionEnvironment {
|
|
124
|
+
return new AvmExecutionEnvironment(
|
|
125
|
+
executionRequest.contractAddress,
|
|
126
|
+
executionRequest.callContext.storageContractAddress,
|
|
127
|
+
executionRequest.callContext.msgSender,
|
|
128
|
+
executionRequest.functionSelector,
|
|
129
|
+
/*contractCallDepth=*/ Fr.zero(),
|
|
130
|
+
transactionFee,
|
|
131
|
+
header,
|
|
132
|
+
globalVariables,
|
|
133
|
+
executionRequest.callContext.isStaticCall,
|
|
134
|
+
executionRequest.callContext.isDelegateCall,
|
|
135
|
+
executionRequest.args,
|
|
136
|
+
);
|
|
137
|
+
}
|
package/src/public/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './abstract_phase_manager.js';
|
|
2
2
|
export * from './db_interfaces.js';
|
|
3
|
-
export { isPublicExecutionResult, type
|
|
3
|
+
export { isPublicExecutionResult, type PublicExecutionRequest, type PublicExecutionResult } from './execution.js';
|
|
4
4
|
export { PublicExecutor } from './executor.js';
|
|
5
5
|
export * from './fee_payment.js';
|
|
6
6
|
export { HintsBuilder } from './hints_builder.js';
|
|
@@ -21,8 +21,9 @@ import {
|
|
|
21
21
|
convertSimulatedPublicTeardownInputsToWitnessMap,
|
|
22
22
|
convertSimulatedPublicTeardownOutputFromWitnessMap,
|
|
23
23
|
} from '@aztec/noir-protocol-circuits-types';
|
|
24
|
-
import { type SimulationProvider, WASMSimulator } from '@aztec/simulator';
|
|
25
24
|
|
|
25
|
+
import { WASMSimulator } from '../providers/acvm_wasm.js';
|
|
26
|
+
import { type SimulationProvider } from '../providers/simulation_provider.js';
|
|
26
27
|
import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js';
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
computeFeePayerBalanceLeafSlot,
|
|
31
31
|
computeFeePayerBalanceStorageSlot,
|
|
32
32
|
} from '@aztec/simulator';
|
|
33
|
+
import { Attributes, type TelemetryClient, type Tracer, trackSpan } from '@aztec/telemetry-client';
|
|
33
34
|
import { type ContractDataSource } from '@aztec/types/contracts';
|
|
34
35
|
import { type MerkleTreeOperations } from '@aztec/world-state';
|
|
35
36
|
|
|
@@ -47,6 +48,7 @@ export class PublicProcessorFactory {
|
|
|
47
48
|
private merkleTree: MerkleTreeOperations,
|
|
48
49
|
private contractDataSource: ContractDataSource,
|
|
49
50
|
private simulator: SimulationProvider,
|
|
51
|
+
private telemetryClient: TelemetryClient,
|
|
50
52
|
) {}
|
|
51
53
|
|
|
52
54
|
/**
|
|
@@ -74,6 +76,7 @@ export class PublicProcessorFactory {
|
|
|
74
76
|
historicalHeader,
|
|
75
77
|
publicContractsDB,
|
|
76
78
|
worldStatePublicDB,
|
|
79
|
+
this.telemetryClient,
|
|
77
80
|
);
|
|
78
81
|
}
|
|
79
82
|
}
|
|
@@ -83,6 +86,7 @@ export class PublicProcessorFactory {
|
|
|
83
86
|
* any public function calls in them. Txs with private calls only are unaffected.
|
|
84
87
|
*/
|
|
85
88
|
export class PublicProcessor {
|
|
89
|
+
public readonly tracer: Tracer;
|
|
86
90
|
constructor(
|
|
87
91
|
protected db: MerkleTreeOperations,
|
|
88
92
|
protected publicExecutor: PublicExecutor,
|
|
@@ -91,9 +95,11 @@ export class PublicProcessor {
|
|
|
91
95
|
protected historicalHeader: Header,
|
|
92
96
|
protected publicContractsDB: ContractsDataSourcePublicDB,
|
|
93
97
|
protected publicStateDB: PublicStateDB,
|
|
94
|
-
|
|
98
|
+
telemetryClient: TelemetryClient,
|
|
95
99
|
private log = createDebugLogger('aztec:sequencer:public-processor'),
|
|
96
|
-
) {
|
|
100
|
+
) {
|
|
101
|
+
this.tracer = telemetryClient.getTracer('PublicProcessor');
|
|
102
|
+
}
|
|
97
103
|
|
|
98
104
|
/**
|
|
99
105
|
* Run each tx through the public circuit and the public kernel circuit if needed.
|
|
@@ -208,6 +214,9 @@ export class PublicProcessor {
|
|
|
208
214
|
return finalPublicDataUpdateRequests;
|
|
209
215
|
}
|
|
210
216
|
|
|
217
|
+
@trackSpan('PublicProcessor.processTxWithPublicCalls', tx => ({
|
|
218
|
+
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
219
|
+
}))
|
|
211
220
|
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
|
|
212
221
|
let returnValues: NestedProcessReturnValues[] = [];
|
|
213
222
|
const publicProvingRequests: PublicProvingRequest[] = [];
|