@aztec/simulator 0.41.0 → 0.42.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 +6 -4
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +20 -11
- package/dest/acvm/oracle/typed_oracle.d.ts +5 -3
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +10 -4
- 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 +67 -73
- 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 +3 -0
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +13 -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 +2 -0
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +6 -2
- package/dest/avm/journal/trace.d.ts +2 -0
- package/dest/avm/journal/trace.d.ts.map +1 -1
- package/dest/avm/journal/trace.js +7 -1
- package/dest/avm/journal/trace_types.d.ts +1 -0
- package/dest/avm/journal/trace_types.d.ts.map +1 -1
- package/dest/avm/journal/trace_types.js +1 -1
- 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 +1 -12
- package/dest/avm/opcodes/conversion.js +2 -2
- package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/avm/opcodes/external_calls.js +4 -3
- 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/memory.d.ts +0 -4
- package/dest/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/avm/opcodes/memory.js +1 -7
- package/dest/avm/opcodes/storage.d.ts +0 -5
- package/dest/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/avm/opcodes/storage.js +1 -7
- package/dest/avm/serialization/bytecode_serialization.js +2 -2
- package/dest/client/client_execution_context.d.ts +11 -19
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +26 -43
- 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 +0 -16
- package/dest/client/simulator.d.ts.map +1 -1
- package/dest/client/simulator.js +8 -25
- 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 +43 -42
- package/dest/public/abstract_phase_manager.d.ts.map +1 -1
- package/dest/public/abstract_phase_manager.js +77 -106
- package/dest/public/app_logic_phase_manager.d.ts +6 -7
- package/dest/public/app_logic_phase_manager.d.ts.map +1 -1
- package/dest/public/app_logic_phase_manager.js +14 -14
- package/dest/public/{db.d.ts → db_interfaces.d.ts} +3 -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 -9
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +1 -1
- package/dest/public/executor.d.ts +3 -30
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +32 -282
- 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 +1 -0
- package/dest/public/hints_builder.d.ts.map +1 -1
- package/dest/public/hints_builder.js +6 -2
- package/dest/public/index.d.ts +4 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +5 -3
- package/dest/public/phase_manager_factory.d.ts +1 -1
- package/dest/public/phase_manager_factory.d.ts.map +1 -1
- package/dest/public/{public_executor.d.ts → public_db_sources.d.ts} +3 -2
- package/dest/public/public_db_sources.d.ts.map +1 -0
- package/dest/public/public_db_sources.js +198 -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 +46 -27
- package/dest/public/setup_phase_manager.d.ts +6 -8
- package/dest/public/setup_phase_manager.d.ts.map +1 -1
- package/dest/public/setup_phase_manager.js +11 -20
- package/dest/public/tail_phase_manager.d.ts +4 -10
- package/dest/public/tail_phase_manager.d.ts.map +1 -1
- package/dest/public/tail_phase_manager.js +15 -35
- package/dest/public/teardown_phase_manager.d.ts +6 -8
- package/dest/public/teardown_phase_manager.d.ts.map +1 -1
- package/dest/public/teardown_phase_manager.js +15 -21
- package/dest/public/transitional_adaptors.d.ts +1 -1
- package/dest/public/transitional_adaptors.d.ts.map +1 -1
- package/dest/public/transitional_adaptors.js +8 -6
- package/dest/public/utils.d.ts +2 -2
- package/dest/public/utils.d.ts.map +1 -1
- package/dest/public/utils.js +21 -14
- package/package.json +12 -9
- package/src/acvm/acvm.ts +0 -3
- package/src/acvm/oracle/oracle.ts +36 -13
- package/src/acvm/oracle/typed_oracle.ts +12 -3
- package/src/acvm/serialize.ts +1 -1
- package/src/avm/avm_gas.ts +66 -73
- package/src/avm/avm_simulator.ts +9 -0
- package/src/avm/fixtures/index.ts +20 -0
- package/src/avm/index.ts +1 -0
- package/src/avm/journal/host_storage.ts +1 -1
- package/src/avm/journal/journal.ts +6 -1
- package/src/avm/journal/trace.ts +12 -0
- package/src/avm/journal/trace_types.ts +1 -0
- package/src/avm/opcodes/arithmetic.ts +1 -14
- package/src/avm/opcodes/conversion.ts +1 -1
- package/src/avm/opcodes/external_calls.ts +3 -1
- package/src/avm/opcodes/instruction.ts +5 -3
- package/src/avm/opcodes/memory.ts +1 -8
- package/src/avm/opcodes/storage.ts +1 -8
- package/src/avm/serialization/bytecode_serialization.ts +1 -1
- package/src/client/client_execution_context.ts +33 -45
- 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 +7 -27
- 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 +138 -205
- package/src/public/app_logic_phase_manager.ts +23 -39
- package/src/public/{db.ts → db_interfaces.ts} +2 -2
- package/src/public/execution.ts +15 -8
- package/src/public/executor.ts +51 -398
- package/src/public/fee_payment.ts +26 -0
- package/src/public/hints_builder.ts +6 -0
- package/src/public/index.ts +4 -2
- package/src/public/phase_manager_factory.ts +1 -1
- package/src/public/{public_executor.ts → public_db_sources.ts} +3 -2
- package/src/public/public_kernel.ts +24 -24
- package/src/public/public_processor.ts +77 -33
- package/src/public/setup_phase_manager.ts +20 -45
- package/src/public/tail_phase_manager.ts +17 -65
- package/src/public/teardown_phase_manager.ts +22 -41
- package/src/public/transitional_adaptors.ts +7 -11
- package/src/public/utils.ts +20 -14
- 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/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/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,65 +1,66 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AVM_REQUEST,
|
|
3
|
+
type AvmProvingRequest,
|
|
2
4
|
MerkleTreeId,
|
|
3
5
|
type NestedProcessReturnValues,
|
|
4
|
-
type
|
|
6
|
+
type PublicKernelNonTailRequest,
|
|
5
7
|
PublicKernelType,
|
|
8
|
+
type PublicProvingRequest,
|
|
6
9
|
type SimulationError,
|
|
7
10
|
type Tx,
|
|
8
11
|
type UnencryptedFunctionL2Logs,
|
|
9
12
|
} from '@aztec/circuit-types';
|
|
10
13
|
import {
|
|
14
|
+
type AvmExecutionHints,
|
|
11
15
|
AztecAddress,
|
|
12
16
|
CallRequest,
|
|
13
17
|
ContractStorageRead,
|
|
14
18
|
ContractStorageUpdateRequest,
|
|
15
19
|
Fr,
|
|
20
|
+
FunctionData,
|
|
16
21
|
Gas,
|
|
17
22
|
type GlobalVariables,
|
|
18
23
|
type Header,
|
|
19
24
|
type KernelCircuitPublicInputs,
|
|
20
25
|
L2ToL1Message,
|
|
21
26
|
LogHash,
|
|
27
|
+
MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL,
|
|
22
28
|
MAX_NEW_L2_TO_L1_MSGS_PER_CALL,
|
|
23
29
|
MAX_NEW_NOTE_HASHES_PER_CALL,
|
|
24
30
|
MAX_NEW_NULLIFIERS_PER_CALL,
|
|
31
|
+
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
|
|
25
32
|
MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL,
|
|
26
33
|
MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
|
|
27
34
|
MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL,
|
|
28
35
|
MAX_PUBLIC_DATA_READS_PER_CALL,
|
|
29
|
-
MAX_PUBLIC_DATA_READS_PER_TX,
|
|
30
36
|
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
|
|
31
|
-
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
32
37
|
MAX_UNENCRYPTED_LOGS_PER_CALL,
|
|
33
38
|
MembershipWitness,
|
|
39
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
34
40
|
NoteHash,
|
|
35
41
|
Nullifier,
|
|
36
|
-
type Proof,
|
|
37
42
|
PublicCallData,
|
|
38
43
|
type PublicCallRequest,
|
|
39
44
|
PublicCallStackItem,
|
|
40
45
|
PublicCircuitPublicInputs,
|
|
41
|
-
PublicDataRead,
|
|
42
|
-
PublicDataUpdateRequest,
|
|
43
46
|
PublicKernelCircuitPrivateInputs,
|
|
44
47
|
type PublicKernelCircuitPublicInputs,
|
|
45
48
|
PublicKernelData,
|
|
46
49
|
ReadRequest,
|
|
47
50
|
RevertCode,
|
|
48
51
|
VK_TREE_HEIGHT,
|
|
49
|
-
|
|
52
|
+
VerificationKeyData,
|
|
50
53
|
makeEmptyProof,
|
|
54
|
+
makeEmptyRecursiveProof,
|
|
51
55
|
} from '@aztec/circuits.js';
|
|
52
56
|
import { computeVarArgsHash } from '@aztec/circuits.js/hash';
|
|
53
|
-
import {
|
|
57
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
54
58
|
import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
|
|
55
|
-
import { type Tuple } from '@aztec/foundation/serialize';
|
|
56
59
|
import {
|
|
57
60
|
type PublicExecution,
|
|
58
61
|
type PublicExecutionResult,
|
|
59
62
|
type PublicExecutor,
|
|
60
63
|
accumulateReturnValues,
|
|
61
|
-
collectPublicDataReads,
|
|
62
|
-
collectPublicDataUpdateRequests,
|
|
63
64
|
isPublicExecutionResult,
|
|
64
65
|
} from '@aztec/simulator';
|
|
65
66
|
import { type MerkleTreeOperations } from '@aztec/world-state';
|
|
@@ -78,7 +79,7 @@ export enum PublicKernelPhase {
|
|
|
78
79
|
export const PhaseIsRevertible: Record<PublicKernelPhase, boolean> = {
|
|
79
80
|
[PublicKernelPhase.SETUP]: false,
|
|
80
81
|
[PublicKernelPhase.APP_LOGIC]: true,
|
|
81
|
-
[PublicKernelPhase.TEARDOWN]:
|
|
82
|
+
[PublicKernelPhase.TEARDOWN]: true,
|
|
82
83
|
[PublicKernelPhase.TAIL]: false,
|
|
83
84
|
};
|
|
84
85
|
|
|
@@ -96,6 +97,59 @@ export function publicKernelPhaseToKernelType(phase: PublicKernelPhase): PublicK
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
100
|
+
export type PublicProvingInformation = {
|
|
101
|
+
calldata: Fr[];
|
|
102
|
+
bytecode: Buffer;
|
|
103
|
+
inputs: PublicKernelCircuitPrivateInputs;
|
|
104
|
+
avmHints: AvmExecutionHints;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export function makeAvmProvingRequest(
|
|
108
|
+
info: PublicProvingInformation,
|
|
109
|
+
kernelType: PublicKernelNonTailRequest['type'],
|
|
110
|
+
): AvmProvingRequest {
|
|
111
|
+
return {
|
|
112
|
+
type: AVM_REQUEST,
|
|
113
|
+
bytecode: info.bytecode,
|
|
114
|
+
calldata: info.calldata,
|
|
115
|
+
avmHints: info.avmHints,
|
|
116
|
+
kernelRequest: {
|
|
117
|
+
type: kernelType,
|
|
118
|
+
inputs: info.inputs,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export type TxPublicCallsResult = {
|
|
124
|
+
/** Inputs to be used for proving */
|
|
125
|
+
publicProvingInformation: PublicProvingInformation[];
|
|
126
|
+
/** The public kernel output at the end of the Tx */
|
|
127
|
+
kernelOutput: PublicKernelCircuitPublicInputs;
|
|
128
|
+
/** Unencrypted logs generated during the execution of this Tx */
|
|
129
|
+
newUnencryptedLogs: UnencryptedFunctionL2Logs[];
|
|
130
|
+
/** Revert reason, if any */
|
|
131
|
+
revertReason?: SimulationError;
|
|
132
|
+
/** Return values of simulating complete callstack */
|
|
133
|
+
returnValues: NestedProcessReturnValues[];
|
|
134
|
+
/** Gas used during the execution this Tx */
|
|
135
|
+
gasUsed?: Gas;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export type PhaseResult = {
|
|
139
|
+
/** The collection of public proving requests */
|
|
140
|
+
publicProvingRequests: PublicProvingRequest[];
|
|
141
|
+
/** The output of the public kernel circuit simulation for this phase */
|
|
142
|
+
publicKernelOutput: PublicKernelCircuitPublicInputs;
|
|
143
|
+
/** The final output of the public kernel circuit for this phase */
|
|
144
|
+
finalKernelOutput?: KernelCircuitPublicInputs;
|
|
145
|
+
/** Revert reason, if any */
|
|
146
|
+
revertReason?: SimulationError;
|
|
147
|
+
/** Return values of simulating complete callstack */
|
|
148
|
+
returnValues: NestedProcessReturnValues[];
|
|
149
|
+
/** Gas used during the execution this phase */
|
|
150
|
+
gasUsed?: Gas;
|
|
151
|
+
};
|
|
152
|
+
|
|
99
153
|
export abstract class AbstractPhaseManager {
|
|
100
154
|
protected hintsBuilder: HintsBuilder;
|
|
101
155
|
protected log: DebugLogger;
|
|
@@ -110,41 +164,12 @@ export abstract class AbstractPhaseManager {
|
|
|
110
164
|
this.hintsBuilder = new HintsBuilder(db);
|
|
111
165
|
this.log = createDebugLogger(`aztec:sequencer:${phase}`);
|
|
112
166
|
}
|
|
167
|
+
|
|
113
168
|
/**
|
|
114
|
-
*
|
|
115
169
|
* @param tx - the tx to be processed
|
|
116
170
|
* @param publicKernelPublicInputs - the output of the public kernel circuit for the previous phase
|
|
117
|
-
* @param previousPublicKernelProof - the proof of the public kernel circuit for the previous phase
|
|
118
171
|
*/
|
|
119
|
-
abstract handle(
|
|
120
|
-
tx: Tx,
|
|
121
|
-
publicKernelPublicInputs: PublicKernelCircuitPublicInputs,
|
|
122
|
-
previousPublicKernelProof: Proof,
|
|
123
|
-
): Promise<{
|
|
124
|
-
/**
|
|
125
|
-
* The collection of public kernel requests
|
|
126
|
-
*/
|
|
127
|
-
kernelRequests: PublicKernelRequest[];
|
|
128
|
-
/**
|
|
129
|
-
* the output of the public kernel circuit for this phase
|
|
130
|
-
*/
|
|
131
|
-
publicKernelOutput: PublicKernelCircuitPublicInputs;
|
|
132
|
-
/**
|
|
133
|
-
* the final output of the public kernel circuit for this phase
|
|
134
|
-
*/
|
|
135
|
-
finalKernelOutput?: KernelCircuitPublicInputs;
|
|
136
|
-
/**
|
|
137
|
-
* the proof of the public kernel circuit for this phase
|
|
138
|
-
*/
|
|
139
|
-
publicKernelProof: Proof;
|
|
140
|
-
/**
|
|
141
|
-
* revert reason, if any
|
|
142
|
-
*/
|
|
143
|
-
revertReason: SimulationError | undefined;
|
|
144
|
-
returnValues: NestedProcessReturnValues[];
|
|
145
|
-
/** Gas used during the execution this particular phase. */
|
|
146
|
-
gasUsed: Gas | undefined;
|
|
147
|
-
}>;
|
|
172
|
+
abstract handle(tx: Tx, publicKernelPublicInputs: PublicKernelCircuitPublicInputs): Promise<PhaseResult>;
|
|
148
173
|
|
|
149
174
|
public static extractEnqueuedPublicCallsByPhase(tx: Tx): Record<PublicKernelPhase, PublicCallRequest[]> {
|
|
150
175
|
const data = tx.data.forPublic;
|
|
@@ -216,43 +241,32 @@ export abstract class AbstractPhaseManager {
|
|
|
216
241
|
return calls;
|
|
217
242
|
}
|
|
218
243
|
|
|
219
|
-
// REFACTOR: Do not return an array and instead return a struct with similar shape to that returned by `handle`
|
|
220
244
|
protected async processEnqueuedPublicCalls(
|
|
221
245
|
tx: Tx,
|
|
222
246
|
previousPublicKernelOutput: PublicKernelCircuitPublicInputs,
|
|
223
|
-
|
|
224
|
-
): Promise<
|
|
225
|
-
[
|
|
226
|
-
PublicKernelCircuitPrivateInputs[],
|
|
227
|
-
PublicKernelCircuitPublicInputs,
|
|
228
|
-
Proof,
|
|
229
|
-
UnencryptedFunctionL2Logs[],
|
|
230
|
-
SimulationError | undefined,
|
|
231
|
-
NestedProcessReturnValues[],
|
|
232
|
-
Gas,
|
|
233
|
-
]
|
|
234
|
-
> {
|
|
235
|
-
let kernelOutput = previousPublicKernelOutput;
|
|
236
|
-
const kernelProof = previousPublicKernelProof;
|
|
237
|
-
const publicKernelInputs: PublicKernelCircuitPrivateInputs[] = [];
|
|
238
|
-
|
|
247
|
+
): Promise<TxPublicCallsResult> {
|
|
239
248
|
const enqueuedCalls = this.extractEnqueuedPublicCalls(tx);
|
|
240
249
|
|
|
241
250
|
if (!enqueuedCalls || !enqueuedCalls.length) {
|
|
242
|
-
return
|
|
251
|
+
return {
|
|
252
|
+
publicProvingInformation: [],
|
|
253
|
+
kernelOutput: previousPublicKernelOutput,
|
|
254
|
+
newUnencryptedLogs: [],
|
|
255
|
+
returnValues: [],
|
|
256
|
+
gasUsed: Gas.empty(),
|
|
257
|
+
};
|
|
243
258
|
}
|
|
244
259
|
|
|
245
|
-
const newUnencryptedFunctionLogs: UnencryptedFunctionL2Logs[] = [];
|
|
246
|
-
|
|
247
|
-
// Transaction fee is zero for all phases except teardown
|
|
248
|
-
const transactionFee = this.getTransactionFee(tx, previousPublicKernelOutput);
|
|
249
|
-
|
|
250
260
|
// TODO(#1684): Should multiple separately enqueued public calls be treated as
|
|
251
261
|
// separate public callstacks to be proven by separate public kernel sequences
|
|
252
262
|
// and submitted separately to the base rollup?
|
|
253
263
|
|
|
264
|
+
const provingInformationList: PublicProvingInformation[] = [];
|
|
265
|
+
const newUnencryptedFunctionLogs: UnencryptedFunctionL2Logs[] = [];
|
|
266
|
+
// Transaction fee is zero for all phases except teardown
|
|
267
|
+
const transactionFee = this.getTransactionFee(tx, previousPublicKernelOutput);
|
|
254
268
|
let gasUsed = Gas.empty();
|
|
255
|
-
|
|
269
|
+
let kernelPublicOutput: PublicKernelCircuitPublicInputs = previousPublicKernelOutput;
|
|
256
270
|
const enqueuedCallResults = [];
|
|
257
271
|
|
|
258
272
|
for (const enqueuedCall of enqueuedCalls) {
|
|
@@ -264,10 +278,9 @@ export abstract class AbstractPhaseManager {
|
|
|
264
278
|
while (executionStack.length) {
|
|
265
279
|
const current = executionStack.pop()!;
|
|
266
280
|
const isExecutionRequest = !isPublicExecutionResult(current);
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
const pendingNullifiers = this.getSiloedPendingNullifiers(kernelOutput);
|
|
281
|
+
const sideEffectCounter = lastSideEffectCounter(kernelPublicOutput) + 1;
|
|
282
|
+
const availableGas = this.getAvailableGas(tx, kernelPublicOutput);
|
|
283
|
+
const pendingNullifiers = this.getSiloedPendingNullifiers(kernelPublicOutput);
|
|
271
284
|
|
|
272
285
|
const result = isExecutionRequest
|
|
273
286
|
? await this.publicExecutor.simulate(
|
|
@@ -281,18 +294,18 @@ export abstract class AbstractPhaseManager {
|
|
|
281
294
|
)
|
|
282
295
|
: current;
|
|
283
296
|
|
|
297
|
+
// Accumulate gas used in this execution
|
|
298
|
+
gasUsed = gasUsed.add(Gas.from(result.startGasLeft).sub(Gas.from(result.endGasLeft)));
|
|
299
|
+
|
|
284
300
|
// Sanity check for a current upstream assumption.
|
|
285
301
|
// Consumers of the result seem to expect "reverted <=> revertReason !== undefined".
|
|
286
|
-
const functionSelector = result.execution.
|
|
302
|
+
const functionSelector = result.execution.functionSelector.toString();
|
|
287
303
|
if (result.reverted && !result.revertReason) {
|
|
288
304
|
throw new Error(
|
|
289
305
|
`Simulation of ${result.execution.contractAddress.toString()}:${functionSelector} reverted with no reason.`,
|
|
290
306
|
);
|
|
291
307
|
}
|
|
292
308
|
|
|
293
|
-
// Accumulate gas used in this execution
|
|
294
|
-
gasUsed = gasUsed.add(Gas.from(result.startGasLeft).sub(Gas.from(result.endGasLeft)));
|
|
295
|
-
|
|
296
309
|
if (result.reverted && !PhaseIsRevertible[this.phase]) {
|
|
297
310
|
this.log.debug(
|
|
298
311
|
`Simulation error on ${result.execution.contractAddress.toString()}:${functionSelector} with reason: ${
|
|
@@ -305,23 +318,29 @@ export abstract class AbstractPhaseManager {
|
|
|
305
318
|
if (isExecutionRequest) {
|
|
306
319
|
newUnencryptedFunctionLogs.push(result.allUnencryptedLogs);
|
|
307
320
|
}
|
|
321
|
+
executionStack.push(...result.nestedExecutions);
|
|
308
322
|
|
|
323
|
+
// Simulate the public kernel circuit.
|
|
309
324
|
this.log.debug(
|
|
310
325
|
`Running public kernel circuit for ${result.execution.contractAddress.toString()}:${functionSelector}`,
|
|
311
326
|
);
|
|
312
|
-
executionStack.push(...result.nestedExecutions);
|
|
313
327
|
const callData = await this.getPublicCallData(result, isExecutionRequest);
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
328
|
+
const [privateInputs, publicInputs] = await this.runKernelCircuit(kernelPublicOutput, callData);
|
|
329
|
+
kernelPublicOutput = publicInputs;
|
|
330
|
+
|
|
331
|
+
// Capture the inputs for later proving in the AVM and kernel.
|
|
332
|
+
const publicProvingInformation: PublicProvingInformation = {
|
|
333
|
+
calldata: result.calldata,
|
|
334
|
+
bytecode: result.bytecode!,
|
|
335
|
+
inputs: privateInputs,
|
|
336
|
+
avmHints: result.avmHints,
|
|
337
|
+
};
|
|
338
|
+
provingInformationList.push(publicProvingInformation);
|
|
339
|
+
|
|
340
|
+
// Sanity check: Note we can't expect them to just be equal, because e.g.
|
|
322
341
|
// if the simulator reverts in app logic, it "resets" and result.reverted will be false when we run teardown,
|
|
323
342
|
// but the kernel carries the reverted flag forward. But if the simulator reverts, so should the kernel.
|
|
324
|
-
if (result.reverted &&
|
|
343
|
+
if (result.reverted && kernelPublicOutput.revertCode.isOK()) {
|
|
325
344
|
throw new Error(
|
|
326
345
|
`Public kernel circuit did not revert on ${result.execution.contractAddress.toString()}:${functionSelector}, but simulator did.`,
|
|
327
346
|
);
|
|
@@ -336,7 +355,14 @@ export abstract class AbstractPhaseManager {
|
|
|
336
355
|
}`,
|
|
337
356
|
);
|
|
338
357
|
// TODO(@spalladino): Check gasUsed is correct. The AVM should take care of setting gasLeft to zero upon a revert.
|
|
339
|
-
return
|
|
358
|
+
return {
|
|
359
|
+
publicProvingInformation: [],
|
|
360
|
+
kernelOutput: kernelPublicOutput,
|
|
361
|
+
newUnencryptedLogs: [],
|
|
362
|
+
revertReason: result.revertReason,
|
|
363
|
+
returnValues: [],
|
|
364
|
+
gasUsed,
|
|
365
|
+
};
|
|
340
366
|
}
|
|
341
367
|
|
|
342
368
|
if (!enqueuedExecutionResult) {
|
|
@@ -345,26 +371,18 @@ export abstract class AbstractPhaseManager {
|
|
|
345
371
|
|
|
346
372
|
enqueuedCallResults.push(accumulateReturnValues(enqueuedExecutionResult));
|
|
347
373
|
}
|
|
348
|
-
// HACK(#1622): Manually patches the ordering of public state actions
|
|
349
|
-
// TODO(#757): Enforce proper ordering of public state actions
|
|
350
|
-
patchPublicStorageActionOrdering(kernelOutput, enqueuedExecutionResult!, this.phase);
|
|
351
374
|
}
|
|
352
375
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
kernelOutput,
|
|
359
|
-
kernelProof,
|
|
360
|
-
newUnencryptedFunctionLogs,
|
|
361
|
-
undefined,
|
|
362
|
-
enqueuedCallResults,
|
|
376
|
+
return {
|
|
377
|
+
publicProvingInformation: provingInformationList,
|
|
378
|
+
kernelOutput: kernelPublicOutput,
|
|
379
|
+
newUnencryptedLogs: newUnencryptedFunctionLogs,
|
|
380
|
+
returnValues: enqueuedCallResults,
|
|
363
381
|
gasUsed,
|
|
364
|
-
|
|
382
|
+
};
|
|
365
383
|
}
|
|
366
384
|
|
|
367
|
-
/** Returns all pending private and public nullifiers.
|
|
385
|
+
/** Returns all pending private and public nullifiers. */
|
|
368
386
|
private getSiloedPendingNullifiers(ko: PublicKernelCircuitPublicInputs) {
|
|
369
387
|
return [...ko.end.newNullifiers, ...ko.endNonRevertibleData.newNullifiers].filter(n => !n.isEmpty());
|
|
370
388
|
}
|
|
@@ -380,20 +398,11 @@ export abstract class AbstractPhaseManager {
|
|
|
380
398
|
return Fr.ZERO;
|
|
381
399
|
}
|
|
382
400
|
|
|
383
|
-
|
|
401
|
+
private async runKernelCircuit(
|
|
384
402
|
previousOutput: PublicKernelCircuitPublicInputs,
|
|
385
|
-
previousProof: Proof,
|
|
386
403
|
callData: PublicCallData,
|
|
387
404
|
): Promise<[PublicKernelCircuitPrivateInputs, PublicKernelCircuitPublicInputs]> {
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
protected async getKernelCircuitOutput(
|
|
392
|
-
previousOutput: PublicKernelCircuitPublicInputs,
|
|
393
|
-
previousProof: Proof,
|
|
394
|
-
callData: PublicCallData,
|
|
395
|
-
): Promise<[PublicKernelCircuitPrivateInputs, PublicKernelCircuitPublicInputs]> {
|
|
396
|
-
const previousKernel = this.getPreviousKernelData(previousOutput, previousProof);
|
|
405
|
+
const previousKernel = this.getPreviousKernelData(previousOutput);
|
|
397
406
|
|
|
398
407
|
// We take a deep copy (clone) of these inputs to be passed to the prover
|
|
399
408
|
const inputs = new PublicKernelCircuitPrivateInputs(previousKernel, callData);
|
|
@@ -409,15 +418,13 @@ export abstract class AbstractPhaseManager {
|
|
|
409
418
|
}
|
|
410
419
|
}
|
|
411
420
|
|
|
412
|
-
protected getPreviousKernelData(
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
// TODO(@PhilWindle) Fix once we move this to prover-client
|
|
417
|
-
const vk = VerificationKey.makeFake();
|
|
421
|
+
protected getPreviousKernelData(previousOutput: PublicKernelCircuitPublicInputs): PublicKernelData {
|
|
422
|
+
// The proof and verification key are not used in simulation
|
|
423
|
+
const vk = VerificationKeyData.makeFake();
|
|
424
|
+
const proof = makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH);
|
|
418
425
|
const vkIndex = 0;
|
|
419
426
|
const vkSiblingPath = MembershipWitness.random(VK_TREE_HEIGHT).siblingPath;
|
|
420
|
-
return new PublicKernelData(previousOutput,
|
|
427
|
+
return new PublicKernelData(previousOutput, proof, vk, vkIndex, vkSiblingPath);
|
|
421
428
|
}
|
|
422
429
|
|
|
423
430
|
protected async getPublicCallStackItem(result: PublicExecutionResult, isExecutionRequest = false) {
|
|
@@ -441,6 +448,11 @@ export abstract class AbstractPhaseManager {
|
|
|
441
448
|
startSideEffectCounter: result.startSideEffectCounter,
|
|
442
449
|
endSideEffectCounter: result.endSideEffectCounter,
|
|
443
450
|
returnsHash: computeVarArgsHash(result.returnValues),
|
|
451
|
+
noteHashReadRequests: padArrayEnd(
|
|
452
|
+
result.noteHashReadRequests,
|
|
453
|
+
ReadRequest.empty(),
|
|
454
|
+
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
|
|
455
|
+
),
|
|
444
456
|
nullifierReadRequests: padArrayEnd(
|
|
445
457
|
result.nullifierReadRequests,
|
|
446
458
|
ReadRequest.empty(),
|
|
@@ -451,6 +463,11 @@ export abstract class AbstractPhaseManager {
|
|
|
451
463
|
ReadRequest.empty(),
|
|
452
464
|
MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL,
|
|
453
465
|
),
|
|
466
|
+
l1ToL2MsgReadRequests: padArrayEnd(
|
|
467
|
+
result.l1ToL2MsgReadRequests,
|
|
468
|
+
ReadRequest.empty(),
|
|
469
|
+
MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL,
|
|
470
|
+
),
|
|
454
471
|
contractStorageReads: padArrayEnd(
|
|
455
472
|
result.contractStorageReads,
|
|
456
473
|
ContractStorageRead.empty(),
|
|
@@ -469,12 +486,12 @@ export abstract class AbstractPhaseManager {
|
|
|
469
486
|
endGasLeft: Gas.from(result.endGasLeft),
|
|
470
487
|
transactionFee: result.transactionFee,
|
|
471
488
|
// TODO(@just-mitch): need better mapping from simulator to revert code.
|
|
472
|
-
revertCode: result.reverted ? RevertCode.
|
|
489
|
+
revertCode: result.reverted ? RevertCode.APP_LOGIC_REVERTED : RevertCode.OK,
|
|
473
490
|
});
|
|
474
491
|
|
|
475
492
|
return new PublicCallStackItem(
|
|
476
493
|
result.execution.contractAddress,
|
|
477
|
-
result.execution.
|
|
494
|
+
new FunctionData(result.execution.functionSelector, false),
|
|
478
495
|
publicCircuitPublicInputs,
|
|
479
496
|
isExecutionRequest,
|
|
480
497
|
);
|
|
@@ -516,87 +533,3 @@ export abstract class AbstractPhaseManager {
|
|
|
516
533
|
return new PublicCallData(callStackItem, publicCallStack, makeEmptyProof(), bytecodeHash);
|
|
517
534
|
}
|
|
518
535
|
}
|
|
519
|
-
|
|
520
|
-
function removeRedundantPublicDataWrites(publicInputs: PublicKernelCircuitPublicInputs, phase: PublicKernelPhase) {
|
|
521
|
-
const lastWritesMap = new Map<string, boolean>();
|
|
522
|
-
const patch = <N extends number>(requests: Tuple<PublicDataUpdateRequest, N>) =>
|
|
523
|
-
requests.filter(write => {
|
|
524
|
-
const leafSlot = write.leafSlot.toString();
|
|
525
|
-
const exists = lastWritesMap.get(leafSlot);
|
|
526
|
-
lastWritesMap.set(leafSlot, true);
|
|
527
|
-
return !exists;
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
const [prev, curr] = PhaseIsRevertible[phase]
|
|
531
|
-
? [publicInputs.endNonRevertibleData, publicInputs.end]
|
|
532
|
-
: [publicInputs.end, publicInputs.endNonRevertibleData];
|
|
533
|
-
|
|
534
|
-
curr.publicDataUpdateRequests = padArrayEnd(
|
|
535
|
-
patch(curr.publicDataUpdateRequests.reverse()).reverse(),
|
|
536
|
-
PublicDataUpdateRequest.empty(),
|
|
537
|
-
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
538
|
-
);
|
|
539
|
-
|
|
540
|
-
prev.publicDataUpdateRequests = padArrayEnd(
|
|
541
|
-
patch(prev.publicDataUpdateRequests.reverse()),
|
|
542
|
-
PublicDataUpdateRequest.empty(),
|
|
543
|
-
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
544
|
-
);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// HACK(#1622): this is a hack to fix ordering of public state in the call stack. Since the private kernel
|
|
548
|
-
// cannot keep track of side effects that happen after or before a nested call, we override the public
|
|
549
|
-
// state actions it emits with whatever we got from the simulator. As a sanity check, we at least verify
|
|
550
|
-
// that the elements are the same, so we are only tweaking their ordering.
|
|
551
|
-
// See yarn-project/end-to-end/src/e2e_ordering.test.ts
|
|
552
|
-
// See https://github.com/AztecProtocol/aztec-packages/issues/1616
|
|
553
|
-
// TODO(#757): Enforce proper ordering of public state actions
|
|
554
|
-
/**
|
|
555
|
-
* Patch the ordering of storage actions output from the public kernel.
|
|
556
|
-
* @param publicInputs - to be patched here: public inputs to the kernel iteration up to this point
|
|
557
|
-
* @param execResult - result of the top/first execution for this enqueued public call
|
|
558
|
-
*/
|
|
559
|
-
function patchPublicStorageActionOrdering(
|
|
560
|
-
publicInputs: PublicKernelCircuitPublicInputs,
|
|
561
|
-
execResult: PublicExecutionResult,
|
|
562
|
-
phase: PublicKernelPhase,
|
|
563
|
-
) {
|
|
564
|
-
const { publicDataUpdateRequests } = PhaseIsRevertible[phase] ? publicInputs.end : publicInputs.endNonRevertibleData;
|
|
565
|
-
const { publicDataReads } = publicInputs.validationRequests;
|
|
566
|
-
|
|
567
|
-
// Convert ContractStorage* objects to PublicData* objects and sort them in execution order.
|
|
568
|
-
// Note, this only pulls simulated reads/writes from the current phase,
|
|
569
|
-
// so the returned result will be a subset of the public kernel output.
|
|
570
|
-
|
|
571
|
-
const simPublicDataReads = collectPublicDataReads(execResult);
|
|
572
|
-
|
|
573
|
-
const simPublicDataUpdateRequests = collectPublicDataUpdateRequests(execResult);
|
|
574
|
-
|
|
575
|
-
// We only want to reorder the items from the public inputs of the
|
|
576
|
-
// most recently processed top/enqueued call.
|
|
577
|
-
|
|
578
|
-
const effectSet = PhaseIsRevertible[phase] ? 'end' : 'endNonRevertibleData';
|
|
579
|
-
|
|
580
|
-
const numReadsInKernel = arrayNonEmptyLength(publicDataReads, f => f.isEmpty());
|
|
581
|
-
const numReadsBeforeThisEnqueuedCall = numReadsInKernel - simPublicDataReads.length;
|
|
582
|
-
publicInputs.validationRequests.publicDataReads = padArrayEnd(
|
|
583
|
-
[
|
|
584
|
-
// do not mess with items from previous top/enqueued calls in kernel output
|
|
585
|
-
...publicInputs.validationRequests.publicDataReads.slice(0, numReadsBeforeThisEnqueuedCall),
|
|
586
|
-
...simPublicDataReads,
|
|
587
|
-
],
|
|
588
|
-
PublicDataRead.empty(),
|
|
589
|
-
MAX_PUBLIC_DATA_READS_PER_TX,
|
|
590
|
-
);
|
|
591
|
-
|
|
592
|
-
const numUpdatesInKernel = arrayNonEmptyLength(publicDataUpdateRequests, f => f.isEmpty());
|
|
593
|
-
const numUpdatesBeforeThisEnqueuedCall = numUpdatesInKernel - simPublicDataUpdateRequests.length;
|
|
594
|
-
publicInputs[effectSet].publicDataUpdateRequests = padArrayEnd(
|
|
595
|
-
[
|
|
596
|
-
...publicInputs[effectSet].publicDataUpdateRequests.slice(0, numUpdatesBeforeThisEnqueuedCall),
|
|
597
|
-
...simPublicDataUpdateRequests,
|
|
598
|
-
],
|
|
599
|
-
PublicDataUpdateRequest.empty(),
|
|
600
|
-
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
601
|
-
);
|
|
602
|
-
}
|
|
@@ -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, PublicKernelPhase } from './abstract_phase_manager.js';
|
|
12
|
-
import { type ContractsDataSourcePublicDB } from './
|
|
6
|
+
import { AbstractPhaseManager, PublicKernelPhase, 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
|
/**
|
|
@@ -29,49 +24,38 @@ export class AppLogicPhaseManager extends AbstractPhaseManager {
|
|
|
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.
|