@aztec/simulator 0.27.2 → 0.28.1
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 -3
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +7 -7
- package/dest/acvm/oracle/typed_oracle.d.ts +3 -3
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +4 -4
- package/dest/avm/avm_memory_types.d.ts +1 -0
- package/dest/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/avm/avm_memory_types.js +6 -1
- package/dest/avm/opcodes/arithmetic.d.ts +13 -1
- package/dest/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/avm/opcodes/arithmetic.js +31 -2
- package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/bytecode_serialization.js +3 -2
- package/dest/avm/serialization/instruction_serialization.d.ts +58 -57
- package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/instruction_serialization.js +59 -58
- package/dest/avm/temporary_executor_migration.d.ts.map +1 -1
- package/dest/avm/temporary_executor_migration.js +6 -1
- package/dest/client/client_execution_context.d.ts +2 -1
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +5 -3
- package/dest/client/execution_result.js +2 -2
- package/dest/client/simulator.d.ts.map +1 -1
- package/dest/client/simulator.js +5 -6
- package/dest/common/side_effect_counter.d.ts +1 -0
- package/dest/common/side_effect_counter.d.ts.map +1 -1
- package/dest/common/side_effect_counter.js +5 -1
- package/dest/public/db.d.ts +12 -5
- package/dest/public/db.d.ts.map +1 -1
- package/dest/public/execution.d.ts +4 -0
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +1 -1
- package/dest/public/executor.d.ts +2 -2
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +12 -12
- package/dest/public/public_execution_context.d.ts +1 -1
- package/dest/public/public_execution_context.d.ts.map +1 -1
- package/dest/public/public_execution_context.js +10 -4
- package/package.json +5 -5
- package/src/acvm/oracle/oracle.ts +6 -4
- package/src/acvm/oracle/typed_oracle.ts +3 -2
- package/src/avm/avm_memory_types.ts +6 -0
- package/src/avm/opcodes/arithmetic.ts +33 -1
- package/src/avm/serialization/bytecode_serialization.ts +2 -0
- package/src/avm/serialization/instruction_serialization.ts +1 -0
- package/src/avm/temporary_executor_migration.ts +5 -0
- package/src/client/client_execution_context.ts +4 -0
- package/src/client/execution_result.ts +1 -1
- package/src/client/simulator.ts +6 -3
- package/src/common/side_effect_counter.ts +5 -0
- package/src/public/db.ts +14 -5
- package/src/public/execution.ts +4 -0
- package/src/public/executor.ts +16 -10
- package/src/public/public_execution_context.ts +9 -2
package/src/public/executor.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FunctionL2Logs } from '@aztec/circuit-types';
|
|
2
|
-
import { GlobalVariables, Header, PublicCircuitPublicInputs } from '@aztec/circuits.js';
|
|
2
|
+
import { Fr, GlobalVariables, Header, PublicCircuitPublicInputs } from '@aztec/circuits.js';
|
|
3
3
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
4
4
|
|
|
5
5
|
import { spawn } from 'child_process';
|
|
@@ -83,6 +83,9 @@ export async function executePublicFunction(
|
|
|
83
83
|
returnValues: [],
|
|
84
84
|
newNoteHashes: [],
|
|
85
85
|
newL2ToL1Messages: [],
|
|
86
|
+
// TODO (side effects) get these values in the revert case from the vm
|
|
87
|
+
startSideEffectCounter: Fr.ZERO,
|
|
88
|
+
endSideEffectCounter: Fr.ZERO,
|
|
86
89
|
newNullifiers: [],
|
|
87
90
|
nullifierReadRequests: [],
|
|
88
91
|
nullifierNonExistentReadRequests: [],
|
|
@@ -107,6 +110,8 @@ export async function executePublicFunction(
|
|
|
107
110
|
newL2ToL1Msgs,
|
|
108
111
|
newNoteHashes: newNoteHashesPadded,
|
|
109
112
|
newNullifiers: newNullifiersPadded,
|
|
113
|
+
startSideEffectCounter,
|
|
114
|
+
endSideEffectCounter,
|
|
110
115
|
} = PublicCircuitPublicInputs.fromFields(returnWitness);
|
|
111
116
|
|
|
112
117
|
const nullifierReadRequests = nullifierReadRequestsPadded.filter(v => !v.isEmpty());
|
|
@@ -136,6 +141,8 @@ export async function executePublicFunction(
|
|
|
136
141
|
newNoteHashes,
|
|
137
142
|
newL2ToL1Messages,
|
|
138
143
|
newNullifiers,
|
|
144
|
+
startSideEffectCounter,
|
|
145
|
+
endSideEffectCounter,
|
|
139
146
|
nullifierReadRequests,
|
|
140
147
|
nullifierNonExistentReadRequests,
|
|
141
148
|
contractStorageReads,
|
|
@@ -165,7 +172,11 @@ export class PublicExecutor {
|
|
|
165
172
|
* @param globalVariables - The global variables to use.
|
|
166
173
|
* @returns The result of the run plus all nested runs.
|
|
167
174
|
*/
|
|
168
|
-
public async simulate(
|
|
175
|
+
public async simulate(
|
|
176
|
+
execution: PublicExecution,
|
|
177
|
+
globalVariables: GlobalVariables,
|
|
178
|
+
sideEffectCounter: number = 0,
|
|
179
|
+
): Promise<PublicExecutionResult> {
|
|
169
180
|
const selector = execution.functionData.selector;
|
|
170
181
|
const acir = await this.contractsDb.getBytecode(execution.contractAddress, selector);
|
|
171
182
|
if (!acir) {
|
|
@@ -176,14 +187,12 @@ export class PublicExecutor {
|
|
|
176
187
|
// We use this cache to hold the packed arguments.
|
|
177
188
|
const packedArgs = PackedArgsCache.create([]);
|
|
178
189
|
|
|
179
|
-
const sideEffectCounter = new SideEffectCounter();
|
|
180
|
-
|
|
181
190
|
const context = new PublicExecutionContext(
|
|
182
191
|
execution,
|
|
183
192
|
this.header,
|
|
184
193
|
globalVariables,
|
|
185
194
|
packedArgs,
|
|
186
|
-
sideEffectCounter,
|
|
195
|
+
new SideEffectCounter(sideEffectCounter),
|
|
187
196
|
this.stateDb,
|
|
188
197
|
this.contractsDb,
|
|
189
198
|
this.commitmentsDb,
|
|
@@ -213,9 +222,10 @@ export class PublicExecutor {
|
|
|
213
222
|
public async simulateAvm(
|
|
214
223
|
execution: PublicExecution,
|
|
215
224
|
globalVariables: GlobalVariables,
|
|
225
|
+
_sideEffectCounter = 0,
|
|
216
226
|
): Promise<PublicExecutionResult> {
|
|
217
227
|
// Temporary code to construct the AVM context
|
|
218
|
-
// These data structures will
|
|
228
|
+
// These data structures will permeate across the simulator when the public executor is phased out
|
|
219
229
|
const hostStorage = new HostStorage(this.stateDb, this.contractsDb, this.commitmentsDb);
|
|
220
230
|
const worldStateJournal = new AvmPersistableStateManager(hostStorage);
|
|
221
231
|
const executionEnv = temporaryCreateAvmExecutionEnvironment(execution, globalVariables);
|
|
@@ -244,8 +254,6 @@ export class PublicExecutor {
|
|
|
244
254
|
*/
|
|
245
255
|
public async getAvmProof(avmExecution: PublicExecution): Promise<Buffer[]> {
|
|
246
256
|
// The paths for the barretenberg binary and the write path are hardcoded for now.
|
|
247
|
-
// We additionally need the path to a valid crs for proof generation.
|
|
248
|
-
// const bbPath = '../../barretenberg/cpp';
|
|
249
257
|
const bbPath = path.resolve('../../barretenberg/cpp');
|
|
250
258
|
const artifactsPath = path.resolve('target');
|
|
251
259
|
|
|
@@ -273,8 +281,6 @@ export class PublicExecutor {
|
|
|
273
281
|
bytecodePath,
|
|
274
282
|
'-d',
|
|
275
283
|
calldataPath,
|
|
276
|
-
'-c',
|
|
277
|
-
path.join(bbPath, 'srs_db', 'ignition'),
|
|
278
284
|
'-o',
|
|
279
285
|
proofPath,
|
|
280
286
|
]);
|
|
@@ -50,7 +50,13 @@ export class PublicExecutionContext extends TypedOracle {
|
|
|
50
50
|
*/
|
|
51
51
|
public getInitialWitness(witnessStartIndex = 0) {
|
|
52
52
|
const { callContext, args } = this.execution;
|
|
53
|
-
const fields = [
|
|
53
|
+
const fields = [
|
|
54
|
+
...callContext.toFields(),
|
|
55
|
+
...this.header.toFields(),
|
|
56
|
+
...this.globalVariables.toFields(),
|
|
57
|
+
new Fr(this.sideEffectCounter.current()),
|
|
58
|
+
...args,
|
|
59
|
+
];
|
|
54
60
|
|
|
55
61
|
return toACVMWitness(witnessStartIndex, fields);
|
|
56
62
|
}
|
|
@@ -161,6 +167,7 @@ export class PublicExecutionContext extends TypedOracle {
|
|
|
161
167
|
targetContractAddress: AztecAddress,
|
|
162
168
|
functionSelector: FunctionSelector,
|
|
163
169
|
argsHash: Fr,
|
|
170
|
+
sideEffectCounter: number,
|
|
164
171
|
isStaticCall: boolean,
|
|
165
172
|
isDelegateCall: boolean,
|
|
166
173
|
) {
|
|
@@ -189,7 +196,7 @@ export class PublicExecutionContext extends TypedOracle {
|
|
|
189
196
|
functionSelector,
|
|
190
197
|
isDelegateCall,
|
|
191
198
|
isStaticCall,
|
|
192
|
-
|
|
199
|
+
sideEffectCounter,
|
|
193
200
|
});
|
|
194
201
|
|
|
195
202
|
const nestedExecution: PublicExecution = {
|