@aztec/simulator 0.41.0 → 0.43.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/acvm.d.ts +2 -2
- package/dest/acvm/acvm.d.ts.map +1 -1
- package/dest/acvm/acvm.js +3 -3
- package/dest/acvm/oracle/oracle.d.ts +7 -4
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +32 -12
- package/dest/acvm/oracle/typed_oracle.d.ts +6 -3
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +15 -6
- package/dest/acvm/serialize.js +2 -2
- package/dest/avm/avm_gas.d.ts +1 -5
- package/dest/avm/avm_gas.d.ts.map +1 -1
- package/dest/avm/avm_gas.js +69 -73
- package/dest/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/avm/avm_memory_types.js +2 -4
- package/dest/avm/avm_simulator.d.ts +5 -0
- package/dest/avm/avm_simulator.d.ts.map +1 -1
- package/dest/avm/avm_simulator.js +8 -1
- package/dest/avm/fixtures/index.d.ts +6 -0
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +18 -1
- package/dest/avm/index.d.ts +2 -0
- package/dest/avm/index.d.ts.map +1 -0
- package/dest/avm/index.js +2 -0
- package/dest/avm/journal/host_storage.d.ts +1 -1
- package/dest/avm/journal/host_storage.d.ts.map +1 -1
- package/dest/avm/journal/journal.d.ts +5 -3
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +23 -14
- package/dest/avm/journal/trace.d.ts +3 -1
- package/dest/avm/journal/trace.d.ts.map +1 -1
- package/dest/avm/journal/trace.js +8 -1
- package/dest/avm/journal/trace_types.d.ts +5 -0
- package/dest/avm/journal/trace_types.d.ts.map +1 -1
- package/dest/avm/journal/trace_types.js +1 -5
- package/dest/avm/opcodes/accrued_substate.d.ts +2 -2
- package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/avm/opcodes/accrued_substate.js +36 -21
- package/dest/avm/opcodes/arithmetic.d.ts +1 -7
- package/dest/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/avm/opcodes/arithmetic.js +12 -20
- package/dest/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/avm/opcodes/bitwise.js +11 -8
- package/dest/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/avm/opcodes/comparators.js +7 -5
- package/dest/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/avm/opcodes/contract.js +20 -24
- package/dest/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/avm/opcodes/control_flow.js +4 -2
- package/dest/avm/opcodes/conversion.js +2 -2
- package/dest/avm/opcodes/ec_add.d.ts +19 -0
- package/dest/avm/opcodes/ec_add.d.ts.map +1 -0
- package/dest/avm/opcodes/ec_add.js +78 -0
- package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/avm/opcodes/external_calls.js +11 -5
- package/dest/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/avm/opcodes/hashing.js +10 -2
- package/dest/avm/opcodes/instruction.d.ts +1 -1
- package/dest/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/avm/opcodes/instruction.js +6 -4
- package/dest/avm/opcodes/instruction_impl.d.ts.map +1 -1
- package/dest/avm/opcodes/instruction_impl.js +4 -2
- package/dest/avm/opcodes/memory.d.ts +1 -5
- package/dest/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/avm/opcodes/memory.js +14 -18
- package/dest/avm/opcodes/multi_scalar_mul.d.ts +16 -0
- package/dest/avm/opcodes/multi_scalar_mul.d.ts.map +1 -0
- package/dest/avm/opcodes/multi_scalar_mul.js +95 -0
- package/dest/avm/opcodes/storage.d.ts +1 -6
- package/dest/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/avm/opcodes/storage.js +11 -14
- package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/bytecode_serialization.js +6 -2
- package/dest/avm/serialization/instruction_serialization.d.ts +3 -1
- package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/instruction_serialization.js +4 -2
- package/dest/client/client_execution_context.d.ts +24 -20
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +52 -55
- package/dest/client/db_oracle.d.ts +7 -1
- package/dest/client/db_oracle.d.ts.map +1 -1
- package/dest/client/execution_note_cache.d.ts +0 -17
- package/dest/client/execution_note_cache.d.ts.map +1 -1
- package/dest/client/execution_note_cache.js +1 -24
- package/dest/client/execution_result.d.ts +8 -4
- package/dest/client/execution_result.d.ts.map +1 -1
- package/dest/client/execution_result.js +16 -6
- package/dest/client/private_execution.d.ts +2 -3
- package/dest/client/private_execution.d.ts.map +1 -1
- package/dest/client/private_execution.js +20 -9
- package/dest/client/simulator.d.ts +2 -17
- package/dest/client/simulator.d.ts.map +1 -1
- package/dest/client/simulator.js +24 -33
- package/dest/client/unconstrained_execution.d.ts +2 -3
- package/dest/client/unconstrained_execution.d.ts.map +1 -1
- package/dest/client/unconstrained_execution.js +5 -7
- package/dest/client/view_data_oracle.d.ts +2 -0
- package/dest/client/view_data_oracle.d.ts.map +1 -1
- package/dest/client/view_data_oracle.js +7 -1
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +4 -2
- package/dest/mocks/fixtures.d.ts +14 -10
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +22 -16
- package/dest/{simulator → providers}/acvm_native.d.ts.map +1 -1
- package/dest/{simulator → providers}/acvm_native.js +13 -14
- package/dest/providers/acvm_wasm.d.ts.map +1 -0
- package/dest/providers/acvm_wasm.js +15 -0
- package/dest/providers/index.d.ts.map +1 -0
- package/dest/{simulator → providers}/index.js +1 -1
- package/dest/{simulator → providers}/simulation_provider.d.ts.map +1 -1
- package/dest/{simulator → providers}/simulation_provider.js +1 -1
- package/dest/public/abstract_phase_manager.d.ts +53 -53
- package/dest/public/abstract_phase_manager.d.ts.map +1 -1
- package/dest/public/abstract_phase_manager.js +146 -153
- package/dest/public/app_logic_phase_manager.d.ts +8 -9
- package/dest/public/app_logic_phase_manager.d.ts.map +1 -1
- package/dest/public/app_logic_phase_manager.js +15 -15
- package/dest/public/{db.d.ts → db_interfaces.d.ts} +4 -3
- package/dest/public/db_interfaces.d.ts.map +1 -0
- package/dest/public/db_interfaces.js +2 -0
- package/dest/public/execution.d.ts +16 -23
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +1 -51
- package/dest/public/executor.d.ts +4 -31
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +40 -283
- package/dest/public/fee_payment.d.ts +11 -0
- package/dest/public/fee_payment.d.ts.map +1 -0
- package/dest/public/fee_payment.js +24 -0
- package/dest/public/hints_builder.d.ts +2 -1
- package/dest/public/hints_builder.d.ts.map +1 -1
- package/dest/public/hints_builder.js +6 -2
- package/dest/public/index.d.ts +8 -6
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +9 -7
- package/dest/public/phase_manager_factory.d.ts +4 -4
- package/dest/public/phase_manager_factory.d.ts.map +1 -1
- package/dest/public/phase_manager_factory.js +5 -5
- package/dest/public/{public_executor.d.ts → public_db_sources.d.ts} +6 -3
- package/dest/public/public_db_sources.d.ts.map +1 -0
- package/dest/public/public_db_sources.js +244 -0
- package/dest/public/public_kernel.js +14 -14
- package/dest/public/public_processor.d.ts +6 -4
- package/dest/public/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor.js +48 -30
- package/dest/public/setup_phase_manager.d.ts +8 -10
- package/dest/public/setup_phase_manager.d.ts.map +1 -1
- package/dest/public/setup_phase_manager.js +12 -21
- package/dest/public/tail_phase_manager.d.ts +7 -13
- package/dest/public/tail_phase_manager.d.ts.map +1 -1
- package/dest/public/tail_phase_manager.js +17 -37
- package/dest/public/teardown_phase_manager.d.ts +8 -10
- package/dest/public/teardown_phase_manager.d.ts.map +1 -1
- package/dest/public/teardown_phase_manager.js +16 -22
- package/dest/public/transitional_adaptors.d.ts +2 -2
- package/dest/public/transitional_adaptors.d.ts.map +1 -1
- package/dest/public/transitional_adaptors.js +14 -6
- package/package.json +12 -9
- package/src/acvm/acvm.ts +0 -3
- package/src/acvm/oracle/oracle.ts +68 -16
- package/src/acvm/oracle/typed_oracle.ts +31 -6
- package/src/acvm/serialize.ts +1 -1
- package/src/avm/avm_gas.ts +68 -73
- package/src/avm/avm_memory_types.ts +1 -3
- package/src/avm/avm_simulator.ts +9 -0
- package/src/avm/fixtures/index.ts +24 -0
- package/src/avm/index.ts +1 -0
- package/src/avm/journal/host_storage.ts +1 -1
- package/src/avm/journal/journal.ts +32 -22
- package/src/avm/journal/trace.ts +9 -0
- package/src/avm/journal/trace_types.ts +4 -0
- package/src/avm/opcodes/accrued_substate.ts +53 -20
- package/src/avm/opcodes/arithmetic.ts +18 -22
- package/src/avm/opcodes/bitwise.ts +13 -8
- package/src/avm/opcodes/comparators.ts +9 -4
- package/src/avm/opcodes/contract.ts +22 -26
- package/src/avm/opcodes/control_flow.ts +3 -1
- package/src/avm/opcodes/conversion.ts +1 -1
- package/src/avm/opcodes/ec_add.ts +92 -0
- package/src/avm/opcodes/external_calls.ts +11 -3
- package/src/avm/opcodes/hashing.ts +11 -1
- package/src/avm/opcodes/instruction.ts +5 -3
- package/src/avm/opcodes/instruction_impl.ts +4 -1
- package/src/avm/opcodes/memory.ts +19 -19
- package/src/avm/opcodes/multi_scalar_mul.ts +114 -0
- package/src/avm/opcodes/storage.ts +10 -17
- package/src/avm/serialization/bytecode_serialization.ts +5 -1
- package/src/avm/serialization/instruction_serialization.ts +2 -0
- package/src/client/client_execution_context.ts +76 -60
- package/src/client/db_oracle.ts +8 -1
- package/src/client/execution_note_cache.ts +0 -28
- package/src/client/execution_result.ts +21 -7
- package/src/client/private_execution.ts +36 -21
- package/src/client/simulator.ts +25 -35
- package/src/client/unconstrained_execution.ts +9 -12
- package/src/client/view_data_oracle.ts +8 -0
- package/src/index.ts +3 -1
- package/src/mocks/fixtures.ts +30 -32
- package/src/{simulator → providers}/acvm_native.ts +21 -19
- package/src/{simulator → providers}/acvm_wasm.ts +2 -16
- package/src/public/abstract_phase_manager.ts +209 -258
- package/src/public/app_logic_phase_manager.ts +24 -40
- package/src/public/{db.ts → db_interfaces.ts} +4 -2
- package/src/public/execution.ts +15 -77
- package/src/public/executor.ts +61 -399
- package/src/public/fee_payment.ts +26 -0
- package/src/public/hints_builder.ts +6 -0
- package/src/public/index.ts +8 -12
- package/src/public/phase_manager_factory.ts +7 -7
- package/src/public/{public_executor.ts → public_db_sources.ts} +65 -9
- package/src/public/public_kernel.ts +24 -24
- package/src/public/public_processor.ts +81 -40
- package/src/public/setup_phase_manager.ts +21 -46
- package/src/public/tail_phase_manager.ts +19 -67
- package/src/public/teardown_phase_manager.ts +23 -42
- package/src/public/transitional_adaptors.ts +41 -5
- package/dest/public/db.d.ts.map +0 -1
- package/dest/public/db.js +0 -2
- package/dest/public/public_execution_context.d.ts +0 -121
- package/dest/public/public_execution_context.d.ts.map +0 -1
- package/dest/public/public_execution_context.js +0 -214
- package/dest/public/public_executor.d.ts.map +0 -1
- package/dest/public/public_executor.js +0 -197
- package/dest/public/state_actions.d.ts +0 -39
- package/dest/public/state_actions.d.ts.map +0 -1
- package/dest/public/state_actions.js +0 -80
- package/dest/public/utils.d.ts +0 -8
- package/dest/public/utils.d.ts.map +0 -1
- package/dest/public/utils.js +0 -31
- package/dest/simulator/acvm_wasm.d.ts.map +0 -1
- package/dest/simulator/acvm_wasm.js +0 -22
- package/dest/simulator/index.d.ts.map +0 -1
- package/src/public/public_execution_context.ts +0 -289
- package/src/public/state_actions.ts +0 -102
- package/src/public/utils.ts +0 -33
- /package/dest/{simulator → providers}/acvm_native.d.ts +0 -0
- /package/dest/{simulator → providers}/acvm_wasm.d.ts +0 -0
- /package/dest/{simulator → providers}/index.d.ts +0 -0
- /package/dest/{simulator → providers}/simulation_provider.d.ts +0 -0
- /package/src/{simulator → providers}/index.ts +0 -0
- /package/src/{simulator → providers}/simulation_provider.ts +0 -0
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
3
|
-
type GlobalVariables,
|
|
4
|
-
type Header,
|
|
5
|
-
type Proof,
|
|
6
|
-
type PublicKernelCircuitPublicInputs,
|
|
7
|
-
} from '@aztec/circuits.js';
|
|
1
|
+
import { PublicKernelType, type PublicProvingRequest, type Tx } from '@aztec/circuit-types';
|
|
2
|
+
import { type GlobalVariables, type Header, type PublicKernelCircuitPublicInputs } from '@aztec/circuits.js';
|
|
8
3
|
import { type PublicExecutor, type PublicStateDB } from '@aztec/simulator';
|
|
9
4
|
import { type MerkleTreeOperations } from '@aztec/world-state';
|
|
10
5
|
|
|
11
|
-
import { AbstractPhaseManager,
|
|
12
|
-
import { type ContractsDataSourcePublicDB } from './
|
|
6
|
+
import { AbstractPhaseManager, makeAvmProvingRequest } from './abstract_phase_manager.js';
|
|
7
|
+
import { type ContractsDataSourcePublicDB } from './public_db_sources.js';
|
|
13
8
|
import { type PublicKernelCircuitSimulator } from './public_kernel_circuit_simulator.js';
|
|
14
9
|
|
|
15
10
|
/**
|
|
@@ -24,54 +19,43 @@ export class AppLogicPhaseManager extends AbstractPhaseManager {
|
|
|
24
19
|
historicalHeader: Header,
|
|
25
20
|
protected publicContractsDB: ContractsDataSourcePublicDB,
|
|
26
21
|
protected publicStateDB: PublicStateDB,
|
|
27
|
-
phase:
|
|
22
|
+
phase: PublicKernelType = PublicKernelType.APP_LOGIC,
|
|
28
23
|
) {
|
|
29
24
|
super(db, publicExecutor, publicKernel, globalVariables, historicalHeader, phase);
|
|
30
25
|
}
|
|
31
26
|
|
|
32
|
-
override async handle(
|
|
33
|
-
tx
|
|
34
|
-
previousPublicKernelOutput: PublicKernelCircuitPublicInputs,
|
|
35
|
-
previousPublicKernelProof: Proof,
|
|
36
|
-
) {
|
|
27
|
+
override async handle(tx: Tx, previousPublicKernelOutput: PublicKernelCircuitPublicInputs) {
|
|
28
|
+
this.log.verbose(`Processing tx ${tx.getTxHash()}`);
|
|
37
29
|
// add new contracts to the contracts db so that their functions may be found and called
|
|
38
30
|
// TODO(#4073): This is catching only private deployments, when we add public ones, we'll
|
|
39
31
|
// have to capture contracts emitted in that phase as well.
|
|
40
32
|
// TODO(@spalladino): Should we allow emitting contracts in the fee preparation phase?
|
|
41
|
-
|
|
33
|
+
// TODO(#6464): Should we allow emitting contracts in the private setup phase?
|
|
34
|
+
// if so, this should only add contracts that were deployed during private app logic.
|
|
42
35
|
await this.publicContractsDB.addNewContracts(tx);
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
] = await this.processEnqueuedPublicCalls(tx, previousPublicKernelOutput, previousPublicKernelProof).catch(
|
|
52
|
-
// if we throw for any reason other than simulation, we need to rollback and drop the TX
|
|
53
|
-
async err => {
|
|
54
|
-
await this.publicStateDB.rollbackToCommit();
|
|
55
|
-
throw err;
|
|
56
|
-
},
|
|
57
|
-
);
|
|
36
|
+
const { publicProvingInformation, kernelOutput, newUnencryptedLogs, revertReason, returnValues, gasUsed } =
|
|
37
|
+
await this.processEnqueuedPublicCalls(tx, previousPublicKernelOutput).catch(
|
|
38
|
+
// if we throw for any reason other than simulation, we need to rollback and drop the TX
|
|
39
|
+
async err => {
|
|
40
|
+
await this.publicStateDB.rollbackToCommit();
|
|
41
|
+
throw err;
|
|
42
|
+
},
|
|
43
|
+
);
|
|
58
44
|
|
|
59
45
|
if (revertReason) {
|
|
46
|
+
// TODO(#6464): Should we allow emitting contracts in the private setup phase?
|
|
47
|
+
// if so, this is removing contracts deployed in private setup
|
|
60
48
|
await this.publicContractsDB.removeNewContracts(tx);
|
|
61
49
|
await this.publicStateDB.rollbackToCheckpoint();
|
|
62
50
|
} else {
|
|
63
|
-
tx.unencryptedLogs.addFunctionLogs(
|
|
64
|
-
|
|
51
|
+
tx.unencryptedLogs.addFunctionLogs(newUnencryptedLogs);
|
|
52
|
+
// TODO(#6470): we should be adding contracts deployed in those logs to the publicContractsDB
|
|
65
53
|
}
|
|
66
54
|
|
|
67
55
|
// Return a list of app logic proving requests
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
type: PublicKernelType.APP_LOGIC,
|
|
71
|
-
inputs: input,
|
|
72
|
-
};
|
|
73
|
-
return request;
|
|
56
|
+
const publicProvingRequests: PublicProvingRequest[] = publicProvingInformation.map(info => {
|
|
57
|
+
return makeAvmProvingRequest(info, PublicKernelType.APP_LOGIC);
|
|
74
58
|
});
|
|
75
|
-
return {
|
|
59
|
+
return { publicProvingRequests, publicKernelOutput: kernelOutput, revertReason, returnValues, gasUsed };
|
|
76
60
|
}
|
|
77
61
|
}
|
|
@@ -23,9 +23,9 @@ export interface PublicStateDB {
|
|
|
23
23
|
* @param contract - Owner of the storage.
|
|
24
24
|
* @param slot - Slot to read in the contract storage.
|
|
25
25
|
* @param newValue - The new value to store.
|
|
26
|
-
* @returns
|
|
26
|
+
* @returns The slot of the written leaf in the public data tree.
|
|
27
27
|
*/
|
|
28
|
-
storageWrite(contract: AztecAddress, slot: Fr, newValue: Fr): Promise<
|
|
28
|
+
storageWrite(contract: AztecAddress, slot: Fr, newValue: Fr): Promise<bigint>;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Mark the uncommitted changes in this TX as a checkpoint.
|
|
@@ -67,6 +67,8 @@ export interface PublicContractsDB {
|
|
|
67
67
|
* @returns The contract instance or undefined if not found.
|
|
68
68
|
*/
|
|
69
69
|
getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
70
|
+
|
|
71
|
+
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
/** Database interface for providing access to commitment tree, l1 to l2 message tree, and nullifier tree. */
|
package/src/public/execution.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type SimulationError, type UnencryptedFunctionL2Logs } from '@aztec/circuit-types';
|
|
2
2
|
import {
|
|
3
|
+
type AvmExecutionHints,
|
|
3
4
|
type ContractStorageRead,
|
|
4
5
|
type ContractStorageUpdateRequest,
|
|
5
6
|
type Fr,
|
|
@@ -8,11 +9,8 @@ import {
|
|
|
8
9
|
type NoteHash,
|
|
9
10
|
type Nullifier,
|
|
10
11
|
type PublicCallRequest,
|
|
11
|
-
PublicDataRead,
|
|
12
|
-
PublicDataUpdateRequest,
|
|
13
12
|
type ReadRequest,
|
|
14
13
|
} from '@aztec/circuits.js';
|
|
15
|
-
import { computePublicDataTreeLeafSlot, computePublicDataTreeValue } from '@aztec/circuits.js/hash';
|
|
16
14
|
|
|
17
15
|
import { type Gas } from '../avm/avm_gas.js';
|
|
18
16
|
|
|
@@ -34,10 +32,14 @@ export interface PublicExecutionResult {
|
|
|
34
32
|
endSideEffectCounter: Fr;
|
|
35
33
|
/** The new nullifiers to be inserted into the nullifier tree. */
|
|
36
34
|
newNullifiers: Nullifier[];
|
|
35
|
+
/** The note hash read requests emitted in this call. */
|
|
36
|
+
noteHashReadRequests: ReadRequest[];
|
|
37
37
|
/** The nullifier read requests emitted in this call. */
|
|
38
38
|
nullifierReadRequests: ReadRequest[];
|
|
39
39
|
/** The nullifier non existent read requests emitted in this call. */
|
|
40
40
|
nullifierNonExistentReadRequests: ReadRequest[];
|
|
41
|
+
/** L1 to L2 message read requests emitted in this call. */
|
|
42
|
+
l1ToL2MsgReadRequests: ReadRequest[];
|
|
41
43
|
/** The contract storage reads performed by the function. */
|
|
42
44
|
contractStorageReads: ContractStorageRead[];
|
|
43
45
|
/** The contract storage update requests performed by the function. */
|
|
@@ -59,26 +61,28 @@ export interface PublicExecutionResult {
|
|
|
59
61
|
* Useful for maintaining correct ordering in ts.
|
|
60
62
|
*/
|
|
61
63
|
allUnencryptedLogs: UnencryptedFunctionL2Logs;
|
|
62
|
-
/**
|
|
63
|
-
* Whether the execution reverted.
|
|
64
|
-
*/
|
|
64
|
+
/** Whether the execution reverted. */
|
|
65
65
|
reverted: boolean;
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
*/
|
|
69
|
-
revertReason: SimulationError | undefined;
|
|
66
|
+
/** The revert reason if the execution reverted. */
|
|
67
|
+
revertReason?: SimulationError;
|
|
70
68
|
/** How much gas was available for this public execution. */
|
|
71
69
|
startGasLeft: Gas;
|
|
72
70
|
/** How much gas was left after this public execution. */
|
|
73
71
|
endGasLeft: Gas;
|
|
74
72
|
/** Transaction fee set for this tx. */
|
|
75
73
|
transactionFee: Fr;
|
|
74
|
+
/** Bytecode used for this execution. */
|
|
75
|
+
bytecode?: Buffer;
|
|
76
|
+
/** Calldata used for this execution. */
|
|
77
|
+
calldata: Fr[];
|
|
78
|
+
/** Hints for proving AVM execution. */
|
|
79
|
+
avmHints: AvmExecutionHints;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
/**
|
|
79
83
|
* The execution of a public function.
|
|
80
84
|
*/
|
|
81
|
-
export type PublicExecution = Pick<PublicCallRequest, 'contractAddress' | '
|
|
85
|
+
export type PublicExecution = Pick<PublicCallRequest, 'contractAddress' | 'functionSelector' | 'callContext' | 'args'>;
|
|
82
86
|
|
|
83
87
|
/**
|
|
84
88
|
* Returns if the input is a public execution result and not just a public execution.
|
|
@@ -91,72 +95,6 @@ export function isPublicExecutionResult(
|
|
|
91
95
|
return 'execution' in input && input.execution !== undefined;
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
/**
|
|
95
|
-
* Collect all public storage reads across all nested executions
|
|
96
|
-
* and convert them to PublicDataReads (to match kernel output).
|
|
97
|
-
* @param execResult - The topmost execution result.
|
|
98
|
-
* @returns All public data reads (in execution order).
|
|
99
|
-
*/
|
|
100
|
-
export function collectPublicDataReads(execResult: PublicExecutionResult): PublicDataRead[] {
|
|
101
|
-
// HACK(#1622): part of temporary hack - may be able to remove this function after public state ordering is fixed
|
|
102
|
-
const thisExecPublicDataReads = execResult.contractStorageReads.map(read =>
|
|
103
|
-
contractStorageReadToPublicDataRead(read),
|
|
104
|
-
);
|
|
105
|
-
const unsorted = [
|
|
106
|
-
...thisExecPublicDataReads,
|
|
107
|
-
...[...execResult.nestedExecutions].flatMap(result => collectPublicDataReads(result)),
|
|
108
|
-
];
|
|
109
|
-
return unsorted.sort((a, b) => a.sideEffectCounter! - b.sideEffectCounter!);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Collect all public storage update requests across all nested executions
|
|
114
|
-
* and convert them to PublicDataUpdateRequests (to match kernel output).
|
|
115
|
-
* @param execResult - The topmost execution result.
|
|
116
|
-
* @returns All public data reads (in execution order).
|
|
117
|
-
*/
|
|
118
|
-
export function collectPublicDataUpdateRequests(execResult: PublicExecutionResult): PublicDataUpdateRequest[] {
|
|
119
|
-
// HACK(#1622): part of temporary hack - may be able to remove this function after public state ordering is fixed
|
|
120
|
-
const thisExecPublicDataUpdateRequests = execResult.contractStorageUpdateRequests.map(update =>
|
|
121
|
-
contractStorageUpdateRequestToPublicDataUpdateRequest(update),
|
|
122
|
-
);
|
|
123
|
-
const unsorted = [
|
|
124
|
-
...thisExecPublicDataUpdateRequests,
|
|
125
|
-
...[...execResult.nestedExecutions].flatMap(result => collectPublicDataUpdateRequests(result)),
|
|
126
|
-
];
|
|
127
|
-
return unsorted.sort((a, b) => a.sideEffectCounter! - b.sideEffectCounter!);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Convert a Contract Storage Read to a Public Data Read.
|
|
132
|
-
* @param read - the contract storage read to convert
|
|
133
|
-
* @param contractAddress - the contract address of the read
|
|
134
|
-
* @returns The public data read.
|
|
135
|
-
*/
|
|
136
|
-
function contractStorageReadToPublicDataRead(read: ContractStorageRead): PublicDataRead {
|
|
137
|
-
return new PublicDataRead(
|
|
138
|
-
computePublicDataTreeLeafSlot(read.contractAddress!, read.storageSlot),
|
|
139
|
-
computePublicDataTreeValue(read.currentValue),
|
|
140
|
-
read.sideEffectCounter!,
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Convert a Contract Storage Update Request to a Public Data Update Request.
|
|
146
|
-
* @param update - the contract storage update request to convert
|
|
147
|
-
* @param contractAddress - the contract address of the data update request.
|
|
148
|
-
* @returns The public data update request.
|
|
149
|
-
*/
|
|
150
|
-
function contractStorageUpdateRequestToPublicDataUpdateRequest(
|
|
151
|
-
update: ContractStorageUpdateRequest,
|
|
152
|
-
): PublicDataUpdateRequest {
|
|
153
|
-
return new PublicDataUpdateRequest(
|
|
154
|
-
computePublicDataTreeLeafSlot(update.contractAddress!, update.storageSlot),
|
|
155
|
-
computePublicDataTreeValue(update.newValue),
|
|
156
|
-
update.sideEffectCounter!,
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
98
|
/**
|
|
161
99
|
* Checks whether the child execution result is valid for a static call (no state modifications).
|
|
162
100
|
* @param executionResult - The execution result of a public function
|