@aztec/simulator 3.0.0-nightly.20251216 → 3.0.0-nightly.20251217
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/public/avm/avm_memory_types.d.ts +3 -1
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +2 -2
- package/dest/public/debug_fn_name.d.ts +1 -1
- package/dest/public/debug_fn_name.d.ts.map +1 -1
- package/dest/public/debug_fn_name.js +10 -3
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +28 -6
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.js +36 -12
- package/dest/public/fixtures/custom_bytecode_tests.js +9 -9
- package/dest/public/fixtures/index.d.ts +3 -1
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +2 -0
- package/dest/public/fixtures/minimal_public_tx.js +2 -2
- package/dest/public/fixtures/opcode_spammer.d.ts +90 -0
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -0
- package/dest/public/fixtures/opcode_spammer.js +1262 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +2 -2
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +19 -7
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +5 -1
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +1 -1
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +2 -1
- package/package.json +16 -16
- package/src/public/avm/avm_memory_types.ts +2 -2
- package/src/public/debug_fn_name.ts +10 -3
- package/src/public/fixtures/custom_bytecode_tester.ts +53 -19
- package/src/public/fixtures/custom_bytecode_tests.ts +9 -9
- package/src/public/fixtures/index.ts +6 -0
- package/src/public/fixtures/minimal_public_tx.ts +2 -2
- package/src/public/fixtures/opcode_spammer.ts +1235 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +19 -5
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +6 -1
- package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +2 -1
|
@@ -31,7 +31,7 @@ const DEFAULT_GAS_FEES = new GasFees(2, 3);
|
|
|
31
31
|
export type TestEnqueuedCall = {
|
|
32
32
|
sender?: AztecAddress;
|
|
33
33
|
address: AztecAddress;
|
|
34
|
-
fnName
|
|
34
|
+
fnName?: string;
|
|
35
35
|
args: any[];
|
|
36
36
|
isStaticCall?: boolean;
|
|
37
37
|
contractArtifact?: ContractArtifact;
|
|
@@ -235,10 +235,24 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
235
235
|
throw new Error(`Contract artifact not found for address: ${address}`);
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
238
|
+
let calldata: Fr[] = [];
|
|
239
|
+
if (!call.fnName) {
|
|
240
|
+
this.logger.debug(
|
|
241
|
+
`No function name specified for call to contract ${call.address.toString()}. Assuming this is a custom bytecode with no public_dispatch function.`,
|
|
242
|
+
);
|
|
243
|
+
this.logger.debug(`Not using ABI to encode arguments. Not prepending fn selector to calldata.`);
|
|
244
|
+
try {
|
|
245
|
+
calldata = call.args.map(arg => new Fr(arg));
|
|
246
|
+
} catch (error) {
|
|
247
|
+
this.logger.warn(`Tried assuming that all arguments are Field-like. Failed. Error: ${error}`);
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
const fnSelector = await getFunctionSelector(call.fnName, contractArtifact);
|
|
252
|
+
const fnAbi = getContractFunctionAbi(call.fnName, contractArtifact)!;
|
|
253
|
+
const encodedArgs = encodeArguments(fnAbi, call.args);
|
|
254
|
+
calldata = [fnSelector.toField(), ...encodedArgs];
|
|
255
|
+
}
|
|
242
256
|
const isStaticCall = call.isStaticCall ?? false;
|
|
243
257
|
const request = await PublicCallRequest.fromCalldata(sender, address, isStaticCall, calldata);
|
|
244
258
|
|
|
@@ -86,7 +86,12 @@ export class ContractProviderForCpp implements ContractProvider {
|
|
|
86
86
|
// Parse address and selector strings
|
|
87
87
|
const aztecAddr = AztecAddress.fromString(address);
|
|
88
88
|
const selectorFr = Fr.fromString(selector);
|
|
89
|
-
const functionSelector = FunctionSelector.
|
|
89
|
+
const functionSelector = FunctionSelector.fromFieldOrUndefined(selectorFr);
|
|
90
|
+
|
|
91
|
+
if (!functionSelector) {
|
|
92
|
+
this.log.debug(`calldata[0] is not a function selector: ${selector}`);
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
90
95
|
|
|
91
96
|
// Fetch debug function name from the contracts DB
|
|
92
97
|
const name = await this.contractsDB.getDebugFunctionName(aztecAddr, functionSelector);
|
|
@@ -205,7 +205,8 @@ export class CppVsTsPublicTxSimulator extends PublicTxSimulator implements Publi
|
|
|
205
205
|
cppGasUsed: cppResult.gasUsed.totalGas.l2Gas,
|
|
206
206
|
});
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
// Return cpp result as it has more detailed metadata / revert reasons
|
|
209
|
+
return cppResult;
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
|