@aztec/simulator 3.0.0-nightly.20251216 → 3.0.0-nightly.20251218
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/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.d.ts +3 -1
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +54 -10
- 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 +86 -0
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -0
- package/dest/public/fixtures/opcode_spammer.js +1539 -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 +15 -11
- 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/debug_fn_name.ts +10 -3
- package/src/public/fixtures/custom_bytecode_tester.ts +53 -19
- package/src/public/fixtures/custom_bytecode_tests.ts +70 -10
- 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 +1516 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +19 -5
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +16 -11
- package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +2 -1
|
@@ -13,7 +13,7 @@ import { type TestPrivateInsertions } from './utils.js';
|
|
|
13
13
|
export type TestEnqueuedCall = {
|
|
14
14
|
sender?: AztecAddress;
|
|
15
15
|
address: AztecAddress;
|
|
16
|
-
fnName
|
|
16
|
+
fnName?: string;
|
|
17
17
|
args: any[];
|
|
18
18
|
isStaticCall?: boolean;
|
|
19
19
|
contractArtifact?: ContractArtifact;
|
|
@@ -56,4 +56,4 @@ export declare class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
56
56
|
prettyPrintMetrics(): void;
|
|
57
57
|
}
|
|
58
58
|
export declare function defaultGlobals(): GlobalVariables;
|
|
59
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
59
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3R4X3NpbXVsYXRpb25fdGVzdGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcHVibGljL2ZpeHR1cmVzL3B1YmxpY190eF9zaW11bGF0aW9uX3Rlc3Rlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFJQSxPQUFPLEVBQUUsS0FBSyxnQkFBZ0IsRUFBbUIsTUFBTSxtQkFBbUIsQ0FBQztBQUMzRSxPQUFPLEVBQUUscUJBQXFCLEVBQUUsS0FBSyxjQUFjLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUMvRSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVoRSxPQ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_simulation_tester.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/public_tx_simulation_tester.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,eAAe,EAAiC,KAAK,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AAOxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,yDAAyD,CAAC;AAClH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,KAAK,qBAAqB,EAA0B,MAAM,YAAY,CAAC;AAIhF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"public_tx_simulation_tester.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/public_tx_simulation_tester.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KA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AgB,EAAE,EAC/B,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAC7B,YAAY,CAAC,EAAE,gBAAgB,EAC/B,QAAQ,CAAC,EAAE,YAAY,EACvB,iBAAiB,CAAC,EAAE,qBAAqB,GACxC,OAAO,CAAC,cAAc,CAAC,CAUzB;IAEM,kBAAkB,SAExB;CAmCF;AAED,wBAAgB,cAAc,oBAM7B"}
|
|
@@ -111,13 +111,25 @@ const defaultConfig = PublicSimulatorConfig.from({
|
|
|
111
111
|
if (!contractArtifact) {
|
|
112
112
|
throw new Error(`Contract artifact not found for address: ${address}`);
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
let calldata = [];
|
|
115
|
+
if (!call.fnName) {
|
|
116
|
+
this.logger.debug(`No function name specified for call to contract ${call.address.toString()}. Assuming this is a custom bytecode with no public_dispatch function.`);
|
|
117
|
+
this.logger.debug(`Not using ABI to encode arguments. Not prepending fn selector to calldata.`);
|
|
118
|
+
try {
|
|
119
|
+
calldata = call.args.map((arg)=>new Fr(arg));
|
|
120
|
+
} catch (error) {
|
|
121
|
+
this.logger.warn(`Tried assuming that all arguments are Field-like. Failed. Error: ${error}`);
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
const fnSelector = await getFunctionSelector(call.fnName, contractArtifact);
|
|
126
|
+
const fnAbi = getContractFunctionAbi(call.fnName, contractArtifact);
|
|
127
|
+
const encodedArgs = encodeArguments(fnAbi, call.args);
|
|
128
|
+
calldata = [
|
|
129
|
+
fnSelector.toField(),
|
|
130
|
+
...encodedArgs
|
|
131
|
+
];
|
|
132
|
+
}
|
|
121
133
|
const isStaticCall = call.isStaticCall ?? false;
|
|
122
134
|
const request = await PublicCallRequest.fromCalldata(sender, address, isStaticCall, calldata);
|
|
123
135
|
return new PublicCallRequestWithCalldata(request, calldata);
|
|
@@ -15,4 +15,4 @@ export declare class ContractProviderForCpp implements ContractProvider {
|
|
|
15
15
|
commitCheckpoint: () => Promise<void>;
|
|
16
16
|
revertCheckpoint: () => Promise<void>;
|
|
17
17
|
}
|
|
18
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfcHJvdmlkZXJfZm9yX2NwcC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3B1YmxpYy9wdWJsaWNfdHhfc2ltdWxhdG9yL2NvbnRyYWN0X3Byb3ZpZGVyX2Zvcl9jcHAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFLdEQsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFeEQsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUVqRSxxQkFBYSxzQkFBdUIsWUFBVyxnQkFBZ0I7SUFJM0QsT0FBTyxDQUFDLFdBQVc7SUFDbkIsT0FBTyxDQUFDLGVBQWU7SUFKekIsT0FBTyxDQUFDLEdBQUcsQ0FBK0Q7SUFFMUUsWUFDVSxXQUFXLEVBQUUsaUJBQWlCLEVBQzlCLGVBQWUsRUFBRSxlQUFlLEVBQ3RDO0lBRUcsbUJBQW1CLG9FQWF4QjtJQUVLLGdCQUFnQixvRUFlckI7SUFFSyxZQUFZLDJFQVdqQjtJQUVLLHFCQUFxQixvRUFnQjFCO0lBRUssb0JBQW9CLHFFQXNCekI7SUFFSyxnQkFBZ0Isc0JBR3JCO0lBRUssZ0JBQWdCLHNCQUdyQjtJQUVLLGdCQUFnQixzQkFHckI7Q0FDSCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_provider_for_cpp.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/contract_provider_for_cpp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,qBAAa,sBAAuB,YAAW,gBAAgB;IAI3D,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,eAAe;IAJzB,OAAO,CAAC,GAAG,CAA+D;IAE1E,YACU,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EACtC;IAEG,mBAAmB,oEAaxB;IAEK,gBAAgB,oEAerB;IAEK,YAAY,2EAWjB;IAEK,qBAAqB,oEAgB1B;IAEK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"contract_provider_for_cpp.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/contract_provider_for_cpp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,qBAAa,sBAAuB,YAAW,gBAAgB;IAI3D,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,eAAe;IAJzB,OAAO,CAAC,GAAG,CAA+D;IAE1E,YACU,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EACtC;IAEG,mBAAmB,oEAaxB;IAEK,gBAAgB,oEAerB;IAEK,YAAY,2EAWjB;IAEK,qBAAqB,oEAgB1B;IAEK,oBAAoB,qEAsBzB;IAEK,gBAAgB,sBAGrB;IAEK,gBAAgB,sBAGrB;IAEK,gBAAgB,sBAGrB;CACH"}
|
|
@@ -13,7 +13,7 @@ export class ContractProviderForCpp {
|
|
|
13
13
|
this.globalVariables = globalVariables;
|
|
14
14
|
this.log = createLogger('simulator:contract_provider_for_cpp');
|
|
15
15
|
this.getContractInstance = async (address)=>{
|
|
16
|
-
this.log.
|
|
16
|
+
this.log.trace(`Contract provider callback: getContractInstance(${address})`);
|
|
17
17
|
const aztecAddr = AztecAddress.fromString(address);
|
|
18
18
|
const instance = await this.contractsDB.getContractInstance(aztecAddr, this.globalVariables.timestamp);
|
|
19
19
|
if (!instance) {
|
|
@@ -23,7 +23,7 @@ export class ContractProviderForCpp {
|
|
|
23
23
|
return serializeWithMessagePack(instance);
|
|
24
24
|
};
|
|
25
25
|
this.getContractClass = async (classId)=>{
|
|
26
|
-
this.log.
|
|
26
|
+
this.log.trace(`Contract provider callback: getContractClass(${classId})`);
|
|
27
27
|
// Parse classId string to Fr
|
|
28
28
|
const classIdFr = Fr.fromString(classId);
|
|
29
29
|
// Fetch contract class from the contracts DB
|
|
@@ -35,16 +35,16 @@ export class ContractProviderForCpp {
|
|
|
35
35
|
return serializeWithMessagePack(contractClass);
|
|
36
36
|
};
|
|
37
37
|
this.addContracts = async (contractDeploymentDataBuffer)=>{
|
|
38
|
-
this.log.
|
|
38
|
+
this.log.trace(`Contract provider callback: addContracts`);
|
|
39
39
|
const rawData = deserializeFromMessagePack(contractDeploymentDataBuffer);
|
|
40
40
|
// Construct ContractDeploymentData from plain object.
|
|
41
41
|
const contractDeploymentData = ContractDeploymentData.fromPlainObject(rawData);
|
|
42
42
|
// Add contracts to the contracts DB
|
|
43
|
-
this.log.
|
|
43
|
+
this.log.trace(`Calling contractsDB.addContracts`);
|
|
44
44
|
await this.contractsDB.addContracts(contractDeploymentData);
|
|
45
45
|
};
|
|
46
46
|
this.getBytecodeCommitment = async (classId)=>{
|
|
47
|
-
this.log.
|
|
47
|
+
this.log.trace(`Contract provider callback: getBytecodeCommitment(${classId})`);
|
|
48
48
|
// Parse classId string to Fr
|
|
49
49
|
const classIdFr = Fr.fromString(classId);
|
|
50
50
|
// Fetch bytecode commitment from the contracts DB
|
|
@@ -57,29 +57,33 @@ export class ContractProviderForCpp {
|
|
|
57
57
|
return serializeWithMessagePack(commitment);
|
|
58
58
|
};
|
|
59
59
|
this.getDebugFunctionName = async (address, selector)=>{
|
|
60
|
-
this.log.
|
|
60
|
+
this.log.trace(`Contract provider callback: getDebugFunctionName(${address}, ${selector})`);
|
|
61
61
|
// Parse address and selector strings
|
|
62
62
|
const aztecAddr = AztecAddress.fromString(address);
|
|
63
63
|
const selectorFr = Fr.fromString(selector);
|
|
64
|
-
const functionSelector = FunctionSelector.
|
|
64
|
+
const functionSelector = FunctionSelector.fromFieldOrUndefined(selectorFr);
|
|
65
|
+
if (!functionSelector) {
|
|
66
|
+
this.log.trace(`calldata[0] is not a function selector: ${selector}`);
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
65
69
|
// Fetch debug function name from the contracts DB
|
|
66
70
|
const name = await this.contractsDB.getDebugFunctionName(aztecAddr, functionSelector);
|
|
67
71
|
if (!name) {
|
|
68
|
-
this.log.
|
|
72
|
+
this.log.trace(`Debug function name not found for ${address}:${selector}`);
|
|
69
73
|
return undefined;
|
|
70
74
|
}
|
|
71
75
|
return name;
|
|
72
76
|
};
|
|
73
77
|
this.createCheckpoint = ()=>{
|
|
74
|
-
this.log.
|
|
78
|
+
this.log.trace(`Contract provider callback: createCheckpoint`);
|
|
75
79
|
return Promise.resolve(this.contractsDB.createCheckpoint());
|
|
76
80
|
};
|
|
77
81
|
this.commitCheckpoint = ()=>{
|
|
78
|
-
this.log.
|
|
82
|
+
this.log.trace(`Contract provider callback: commitCheckpoint`);
|
|
79
83
|
return Promise.resolve(this.contractsDB.commitCheckpoint());
|
|
80
84
|
};
|
|
81
85
|
this.revertCheckpoint = ()=>{
|
|
82
|
-
this.log.
|
|
86
|
+
this.log.trace(`Contract provider callback: revertCheckpoint`);
|
|
83
87
|
return Promise.resolve(this.contractsDB.revertCheckpoint());
|
|
84
88
|
};
|
|
85
89
|
}
|
|
@@ -27,4 +27,4 @@ export declare class MeasuredCppVsTsPublicTxSimulator extends CppVsTsPublicTxSim
|
|
|
27
27
|
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, metrics: ExecutorMetricsInterface, config?: Partial<PublicSimulatorConfig>);
|
|
28
28
|
simulate(tx: Tx, txLabel?: string): Promise<PublicTxResult>;
|
|
29
29
|
}
|
|
30
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
30
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3BwX3ZzX3RzX3B1YmxpY190eF9zaW11bGF0b3IuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvcHVibGljX3R4X3NpbXVsYXRvci9jcHBfdnNfdHNfcHVibGljX3R4X3NpbXVsYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQTBCLE1BQU0sdUJBQXVCLENBQUM7QUFHNUUsT0FBTyxFQUdMLEtBQUsscUJBQXFCLEVBQzFCLGNBQWMsRUFFZixNQUFNLG1CQUFtQixDQUFDO0FBRTNCLE9BQU8sS0FBSyxFQUFFLHlCQUF5QixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDckUsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFrQixFQUFFLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUs1RSxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBQ2pGLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFakUsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFDN0QsT0FBTyxLQUFLLEVBQ1Ysa0NBQWtDLEVBQ2xDLDBCQUEwQixFQUMzQixNQUFNLG9DQUFvQyxDQUFDO0FBRTVDOzs7O0dBSUc7QUFDSCxxQkFBYSx3QkFBeUIsU0FBUSxpQkFBa0IsWUFBVywwQkFBMEI7SUFDbkcsVUFBbUIsR0FBRyxFQUFFLE1BQU0sQ0FBQztJQUUvQixZQUNFLFVBQVUsRUFBRSx5QkFBeUIsRUFDckMsV0FBVyxFQUFFLGlCQUFpQixFQUM5QixlQUFlLEVBQUUsZUFBZSxFQUNoQyxNQUFNLENBQUMsRUFBRSxPQUFPLENBQUMscUJBQXFCLENBQUMsRUFJeEM7SUFFRDs7Ozs7T0FLRztJQUNtQixRQUFRLENBQUMsRUFBRSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLENBK0o5RDtDQUNGO0FBRUQscUJBQWEsZ0NBQ1gsU0FBUSx3QkFDUixZQUFXLGtDQUFrQztJQU0zQyxTQUFTLENBQUMsUUFBUSxDQUFDLE9BQU8sRUFBRSx3QkFBd0I7SUFKdEQsWUFDRSxVQUFVLEVBQUUseUJBQXlCLEVBQ3JDLFdBQVcsRUFBRSxpQkFBaUIsRUFDOUIsZUFBZSxFQUFFLGVBQWUsRUFDYixPQUFPLEVBQUUsd0JBQXdCLEVBQ3BELE1BQU0sQ0FBQyxFQUFFLE9BQU8sQ0FBQyxxQkFBcUIsQ0FBQyxFQUd4QztJQUVxQixRQUFRLENBQUMsRUFBRSxFQUFFLEVBQUUsRUFBRSxPQUFPLEdBQUUsTUFBc0IsR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLENBUy9GO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpp_vs_ts_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAA0B,MAAM,uBA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AkC,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACV,kCAAkC,EAClC,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAE5C;;;;GAIG;AACH,qBAAa,wBAAyB,SAAQ,iBAAkB,YAAW,0BAA0B;IACnG,UAAmB,GAAG,EAAE,MAAM,CAAC;IAE/B,YACE,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAChC,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAIxC;IAED;;;;;OAKG;IACmB,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CA+J9D;CACF;AAED,qBAAa,gCACX,SAAQ,wBACR,YAAW,kCAAkC;IAM3C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,wBAAwB;IAJtD,YACE,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EACb,OAAO,EAAE,wBAAwB,EACpD,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAGxC;IAEqB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,GAAE,MAAsB,GAAG,OAAO,CAAC,cAAc,CAAC,CAS/F;CACF"}
|
|
@@ -149,7 +149,8 @@ import { PublicTxSimulator } from './public_tx_simulator.js';
|
|
|
149
149
|
reverted: !cppResult.revertCode.isOK(),
|
|
150
150
|
cppGasUsed: cppResult.gasUsed.totalGas.l2Gas
|
|
151
151
|
});
|
|
152
|
-
|
|
152
|
+
// Return cpp result as it has more detailed metadata / revert reasons
|
|
153
|
+
return cppResult;
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
export class MeasuredCppVsTsPublicTxSimulator extends CppVsTsPublicTxSimulator {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251218",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -64,26 +64,26 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
68
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
69
|
-
"@aztec/native": "3.0.0-nightly.
|
|
70
|
-
"@aztec/noir-acvm_js": "3.0.0-nightly.
|
|
71
|
-
"@aztec/noir-noirc_abi": "3.0.0-nightly.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.
|
|
73
|
-
"@aztec/noir-types": "3.0.0-nightly.
|
|
74
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
75
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
76
|
-
"@aztec/telemetry-client": "3.0.0-nightly.
|
|
77
|
-
"@aztec/world-state": "3.0.0-nightly.
|
|
67
|
+
"@aztec/constants": "3.0.0-nightly.20251218",
|
|
68
|
+
"@aztec/foundation": "3.0.0-nightly.20251218",
|
|
69
|
+
"@aztec/native": "3.0.0-nightly.20251218",
|
|
70
|
+
"@aztec/noir-acvm_js": "3.0.0-nightly.20251218",
|
|
71
|
+
"@aztec/noir-noirc_abi": "3.0.0-nightly.20251218",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251218",
|
|
73
|
+
"@aztec/noir-types": "3.0.0-nightly.20251218",
|
|
74
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251218",
|
|
75
|
+
"@aztec/stdlib": "3.0.0-nightly.20251218",
|
|
76
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20251218",
|
|
77
|
+
"@aztec/world-state": "3.0.0-nightly.20251218",
|
|
78
78
|
"lodash.clonedeep": "^4.5.0",
|
|
79
79
|
"lodash.merge": "^4.6.2",
|
|
80
80
|
"tslib": "^2.4.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
84
|
-
"@aztec/merkle-tree": "3.0.0-nightly.
|
|
85
|
-
"@aztec/noir-contracts.js": "3.0.0-nightly.
|
|
86
|
-
"@aztec/noir-test-contracts.js": "3.0.0-nightly.
|
|
83
|
+
"@aztec/kv-store": "3.0.0-nightly.20251218",
|
|
84
|
+
"@aztec/merkle-tree": "3.0.0-nightly.20251218",
|
|
85
|
+
"@aztec/noir-contracts.js": "3.0.0-nightly.20251218",
|
|
86
|
+
"@aztec/noir-test-contracts.js": "3.0.0-nightly.20251218",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
88
|
"@types/jest": "^30.0.0",
|
|
89
89
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
@@ -13,8 +13,12 @@ export async function getPublicFunctionDebugName(
|
|
|
13
13
|
if (!calldata[0]) {
|
|
14
14
|
return `<calldata[0] undefined> (Contract Address: ${contractAddress})`;
|
|
15
15
|
}
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const fallbackName = `<calldata[0]:${calldata[0].toString()}> (Contract Address: ${contractAddress})`;
|
|
17
|
+
const selector = FunctionSelector.fromFieldOrUndefined(calldata[0]);
|
|
18
|
+
if (!selector) {
|
|
19
|
+
return fallbackName;
|
|
20
|
+
}
|
|
21
|
+
return (await db.getDebugFunctionName(contractAddress, selector)) ?? fallbackName;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
/**
|
|
@@ -34,7 +38,10 @@ export async function getPublicFunctionSelectorAndName(
|
|
|
34
38
|
if (!calldata[0]) {
|
|
35
39
|
return {};
|
|
36
40
|
}
|
|
37
|
-
const selector = FunctionSelector.
|
|
41
|
+
const selector = FunctionSelector.fromFieldOrUndefined(calldata[0]);
|
|
42
|
+
if (!selector) {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
38
45
|
const debugName = await db.getDebugFunctionName(contractAddress, selector);
|
|
39
46
|
return {
|
|
40
47
|
functionSelector: selector,
|
|
@@ -1,49 +1,83 @@
|
|
|
1
1
|
import { FunctionType, emptyContractArtifact, emptyFunctionArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { PublicTxResult } from '@aztec/stdlib/avm';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
4
5
|
|
|
5
6
|
import { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
* Test custom bytecode (simulation or proving) with the provided bytecode.
|
|
9
|
+
* Deploy a contract with the provided bytecode.
|
|
10
10
|
* @param bytecode - The bytecode buffer to use
|
|
11
|
-
* @param tester - The tester to use
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
11
|
+
* @param tester - The tester to use
|
|
12
|
+
* @param contractName - The name of the contract
|
|
13
|
+
* @param deployer - The deployer address
|
|
14
|
+
* @returns The deployed contract instance
|
|
14
15
|
*/
|
|
15
|
-
export async function
|
|
16
|
+
export async function deployCustomBytecode(
|
|
16
17
|
bytecode: Buffer,
|
|
17
18
|
tester: PublicTxSimulationTester,
|
|
18
|
-
txLabel: string,
|
|
19
19
|
contractName: string = 'CustomBytecodeContract',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
deployer: AztecAddress = AztecAddress.fromNumber(42),
|
|
21
|
+
): Promise<ContractInstanceWithAddress> {
|
|
23
22
|
const contractArtifact = emptyContractArtifact();
|
|
24
23
|
contractArtifact.name = contractName;
|
|
25
24
|
contractArtifact.functions = [emptyFunctionArtifact()];
|
|
25
|
+
// We use name 'public_dispatch' since that is what is expected
|
|
26
|
+
// in a ContractArtifact. But function selectors are not required
|
|
27
|
+
// when executing since the custom bytecode likely has no dispatch.
|
|
26
28
|
contractArtifact.functions[0].name = 'public_dispatch';
|
|
27
29
|
contractArtifact.functions[0].functionType = FunctionType.PUBLIC;
|
|
28
30
|
contractArtifact.functions[0].bytecode = bytecode;
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
// return the contract instance
|
|
33
|
+
return await tester.registerAndDeployContract(
|
|
31
34
|
/*constructorArgs=*/ [],
|
|
32
35
|
deployer,
|
|
33
36
|
/*contractArtifact=*/ contractArtifact,
|
|
34
37
|
);
|
|
38
|
+
}
|
|
35
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Execute a custom bytecode contract.
|
|
42
|
+
* @param contract - The contract instance to execute
|
|
43
|
+
* @param tester - The tester to use
|
|
44
|
+
* @param txLabel - The label of the transaction
|
|
45
|
+
* @param calldata - The calldata to use
|
|
46
|
+
* @returns The execution result
|
|
47
|
+
*/
|
|
48
|
+
export async function executeCustomBytecode(
|
|
49
|
+
contract: ContractInstanceWithAddress,
|
|
50
|
+
tester: PublicTxSimulationTester,
|
|
51
|
+
txLabel: string = 'CustomBytecodeTest',
|
|
52
|
+
calldata: any[] = [],
|
|
53
|
+
): Promise<PublicTxResult> {
|
|
36
54
|
// EXECUTE! This means that if using AvmProvingTester subclass, it will PROVE the transaction!
|
|
37
55
|
return await tester.executeTxWithLabel(
|
|
38
56
|
/*txLabel=*/ txLabel,
|
|
39
|
-
/*sender=*/ deployer,
|
|
57
|
+
/*sender=*/ contract.deployer,
|
|
40
58
|
/*setupCalls=*/ [],
|
|
41
|
-
/*appCalls=*/ [
|
|
42
|
-
{
|
|
43
|
-
address: testContract.address,
|
|
44
|
-
fnName: 'public_dispatch',
|
|
45
|
-
args: [],
|
|
46
|
-
},
|
|
47
|
-
],
|
|
59
|
+
/*appCalls=*/ [{ address: contract.address, args: calldata }],
|
|
48
60
|
);
|
|
49
61
|
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Deploy and execute a custom bytecode contract.
|
|
65
|
+
* @param bytecode - The bytecode buffer to use
|
|
66
|
+
* @param tester - The tester to use
|
|
67
|
+
* @param txLabel - The label of the transaction
|
|
68
|
+
* @param contractName - The name of the contract
|
|
69
|
+
* @param deployer - The deployer address
|
|
70
|
+
* @param calldata - The calldata to use
|
|
71
|
+
* @returns The execution result
|
|
72
|
+
*/
|
|
73
|
+
export async function deployAndExecuteCustomBytecode(
|
|
74
|
+
bytecode: Buffer,
|
|
75
|
+
tester: PublicTxSimulationTester,
|
|
76
|
+
txLabel: string = 'CustomBytecodeTest',
|
|
77
|
+
contractName: string = 'CustomBytecodeContract',
|
|
78
|
+
deployer: AztecAddress = AztecAddress.fromNumber(42),
|
|
79
|
+
calldata: any[] = [],
|
|
80
|
+
): Promise<PublicTxResult> {
|
|
81
|
+
const testContract = await deployCustomBytecode(bytecode, tester, contractName, deployer);
|
|
82
|
+
return await executeCustomBytecode(testContract, tester, txLabel, calldata);
|
|
83
|
+
}
|
|
@@ -2,7 +2,7 @@ import { strict as assert } from 'assert';
|
|
|
2
2
|
|
|
3
3
|
import { TypeTag } from '../avm/avm_memory_types.js';
|
|
4
4
|
import { Addressing, AddressingMode } from '../avm/opcodes/addressing_mode.js';
|
|
5
|
-
import { CalldataCopy, Jump, Return, Set } from '../avm/opcodes/index.js';
|
|
5
|
+
import { Add, CalldataCopy, Jump, Return, Set } from '../avm/opcodes/index.js';
|
|
6
6
|
import { encodeToBytecode } from '../avm/serialization/bytecode_serialization.js';
|
|
7
7
|
import {
|
|
8
8
|
MAX_OPCODE_VALUE,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
OperandType,
|
|
11
11
|
getOperandSize,
|
|
12
12
|
} from '../avm/serialization/instruction_serialization.js';
|
|
13
|
-
import {
|
|
13
|
+
import { deployAndExecuteCustomBytecode } from './custom_bytecode_tester.js';
|
|
14
14
|
import { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
|
|
15
15
|
|
|
16
16
|
// First instruction resolved a base address (offset 0) which is uninitialized and therefore
|
|
@@ -28,7 +28,7 @@ export async function addressingWithBaseTagIssueTest(isIndirect: boolean, tester
|
|
|
28
28
|
]);
|
|
29
29
|
|
|
30
30
|
const txLabel = isIndirect ? 'AddressingWithBaseTagInvalidIndirect' : 'AddressingWithBaseTagInvalidDirect';
|
|
31
|
-
return await
|
|
31
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// First instruction sets a value with tag U64 at offset 0. Then a CalldataCopy instruction
|
|
@@ -52,7 +52,67 @@ export async function addressingWithIndirectTagIssueTest(tester: PublicTxSimulat
|
|
|
52
52
|
]);
|
|
53
53
|
|
|
54
54
|
const txLabel = 'AddressingWithIndirectTagInvalid';
|
|
55
|
-
return await
|
|
55
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// First instruction sets a value 10 with tag U32 at offset 1 (direct, no relative).
|
|
59
|
+
// Then an ADD_16 instruction uses INDIRECT addressing for the first operand (offset 1)
|
|
60
|
+
// and RELATIVE addressing for the second operand (offset 2). The indirect addressing
|
|
61
|
+
// succeeds (reads U32 value 10 from offset 1, uses it as address), but the relative
|
|
62
|
+
// addressing fails because the base address at offset 0 has the wrong tag (uninitialized/invalid).
|
|
63
|
+
export async function addressingWithIndirectThenRelativeTagIssueTest(tester: PublicTxSimulationTester) {
|
|
64
|
+
const addressingMode = Addressing.fromModes([
|
|
65
|
+
AddressingMode.INDIRECT, // First operand (aOffset) uses indirect addressing, no relative
|
|
66
|
+
AddressingMode.RELATIVE, // Second operand (bOffset) uses relative addressing
|
|
67
|
+
AddressingMode.DIRECT, // Third operand (dstOffset) uses direct addressing
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
const bytecode = encodeToBytecode([
|
|
71
|
+
// Set a U32 value 10 at offset 1 - this will be used as an indirect address
|
|
72
|
+
new Set(/*indirect=*/ 0, /*dstOffset=*/ 1, TypeTag.UINT32, /*value=*/ 10).as(Opcode.SET_32, Set.wireFormat32),
|
|
73
|
+
// ADD_16: first operand uses indirect addressing (reads from offset 1, gets value 10, uses as address - succeeds)
|
|
74
|
+
// second operand uses relative addressing (tries to read base from offset 0, but offset 0 has wrong tag - fails)
|
|
75
|
+
new Add(/*indirect=*/ addressingMode.toWire(), /*aOffset=*/ 1, /*bOffset=*/ 2, /*dstOffset=*/ 3).as(
|
|
76
|
+
Opcode.ADD_16,
|
|
77
|
+
Add.wireFormat16,
|
|
78
|
+
),
|
|
79
|
+
new Return(/*indirect=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
const txLabel = 'AddressingWithIndirectThenRelativeTagInvalid';
|
|
83
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// First instruction sets UINT32_MAX at offset 0 (base address) with tag U32.
|
|
87
|
+
// Then an ADD_8 instruction uses INDIRECT_RELATIVE addressing for the first operand (offset 1)
|
|
88
|
+
// and INDIRECT addressing for the second operand (offset 2). The relative addressing
|
|
89
|
+
// for the first operand will overflow (UINT32_MAX + 1 >= MAX_MEMORY_SIZE), causing the instruction to fail.
|
|
90
|
+
// The second operand will also fail (indirect addressing from offset 2 which is uninitialized with tag FF).
|
|
91
|
+
export async function addressingWithRelativeOverflowAndIndirectTagIssueTest(tester: PublicTxSimulationTester) {
|
|
92
|
+
const addressingMode = Addressing.fromModes([
|
|
93
|
+
AddressingMode.INDIRECT_RELATIVE, // First operand (aOffset) uses both indirect and relative addressing
|
|
94
|
+
AddressingMode.INDIRECT, // Second operand (bOffset) uses indirect addressing only
|
|
95
|
+
AddressingMode.DIRECT, // Third operand (dstOffset) uses direct addressing
|
|
96
|
+
]);
|
|
97
|
+
|
|
98
|
+
// UINT32_MAX = 2^32 - 1 = 4294967295
|
|
99
|
+
const UINT32_MAX = 0xffffffff;
|
|
100
|
+
|
|
101
|
+
const bytecode = encodeToBytecode([
|
|
102
|
+
// Set UINT32_MAX at offset 0 as base address - this will cause overflow when adding relative offset 1
|
|
103
|
+
new Set(/*indirect=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ UINT32_MAX).as(
|
|
104
|
+
Opcode.SET_32,
|
|
105
|
+
Set.wireFormat32,
|
|
106
|
+
),
|
|
107
|
+
new Add(/*indirect=*/ addressingMode.toWire(), /*aOffset=*/ 1, /*bOffset=*/ 2, /*dstOffset=*/ 3).as(
|
|
108
|
+
Opcode.ADD_8,
|
|
109
|
+
Add.wireFormat8,
|
|
110
|
+
),
|
|
111
|
+
new Return(/*indirect=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
|
|
112
|
+
]);
|
|
113
|
+
|
|
114
|
+
const txLabel = 'AddressingWithRelativeOverflowAndIndirectTagInvalid';
|
|
115
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
56
116
|
}
|
|
57
117
|
|
|
58
118
|
export async function pcOutOfRangeTest(tester: PublicTxSimulationTester) {
|
|
@@ -62,7 +122,7 @@ export async function pcOutOfRangeTest(tester: PublicTxSimulationTester) {
|
|
|
62
122
|
]);
|
|
63
123
|
|
|
64
124
|
const txLabel = 'PcOutOfRange';
|
|
65
|
-
return await
|
|
125
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
66
126
|
}
|
|
67
127
|
|
|
68
128
|
export async function invalidOpcodeTest(tester: PublicTxSimulationTester) {
|
|
@@ -81,7 +141,7 @@ export async function invalidOpcodeTest(tester: PublicTxSimulationTester) {
|
|
|
81
141
|
bytecode[offsetReturnOpcodeByte] = MAX_OPCODE_VALUE + 1; // opcode is invalid.
|
|
82
142
|
|
|
83
143
|
const txLabel = 'InvalidOpcode';
|
|
84
|
-
return await
|
|
144
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
85
145
|
}
|
|
86
146
|
|
|
87
147
|
// Single invalid byte in the bytecode.
|
|
@@ -91,7 +151,7 @@ export async function invalidByteTest(tester: PublicTxSimulationTester) {
|
|
|
91
151
|
const bytecode = Buffer.from([invalidOpcode]);
|
|
92
152
|
|
|
93
153
|
const txLabel = 'InvalidByte';
|
|
94
|
-
return await
|
|
154
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
95
155
|
}
|
|
96
156
|
|
|
97
157
|
// Truncate the last instruction in the bytecode.
|
|
@@ -104,7 +164,7 @@ export async function instructionTruncatedTest(tester: PublicTxSimulationTester)
|
|
|
104
164
|
bytecode = bytecode.subarray(0, -1);
|
|
105
165
|
|
|
106
166
|
const txLabel = 'InstructionTruncated';
|
|
107
|
-
return await
|
|
167
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
108
168
|
}
|
|
109
169
|
|
|
110
170
|
// Invalid tag value byte in an instruction.
|
|
@@ -119,7 +179,7 @@ export async function invalidTagValueTest(tester: PublicTxSimulationTester) {
|
|
|
119
179
|
bytecode[tagOffset] = TypeTag.INVALID;
|
|
120
180
|
|
|
121
181
|
const txLabel = 'InvalidTagValue';
|
|
122
|
-
return await
|
|
182
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
123
183
|
}
|
|
124
184
|
|
|
125
185
|
// Combine an invalid tag in the last instruction that is truncated.
|
|
@@ -136,7 +196,7 @@ export async function invalidTagValueAndInstructionTruncatedTest(tester: PublicT
|
|
|
136
196
|
bytecode[tagOffset] = 0x6f; // Invalid tag value.
|
|
137
197
|
|
|
138
198
|
const txLabel = 'InvalidTagValueAndInstructionTruncated';
|
|
139
|
-
return await
|
|
199
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
140
200
|
}
|
|
141
201
|
|
|
142
202
|
/**
|
|
@@ -7,3 +7,9 @@ export { ammTest } from './amm_test.js';
|
|
|
7
7
|
export { bulkTest, megaBulkTest } from './bulk_test.js';
|
|
8
8
|
export { tokenTest } from './token_test.js';
|
|
9
9
|
export * from './custom_bytecode_tests.js';
|
|
10
|
+
export {
|
|
11
|
+
deployCustomBytecode,
|
|
12
|
+
executeCustomBytecode,
|
|
13
|
+
deployAndExecuteCustomBytecode,
|
|
14
|
+
} from './custom_bytecode_tester.js';
|
|
15
|
+
export { getSpamConfigsPerOpcode, testOpcodeSpamCase } from './opcode_spammer.js';
|
|
@@ -6,7 +6,7 @@ import { TypeTag } from '../avm/avm_memory_types.js';
|
|
|
6
6
|
import { Add, Return, Set } from '../avm/opcodes/index.js';
|
|
7
7
|
import { encodeToBytecode } from '../avm/serialization/bytecode_serialization.js';
|
|
8
8
|
import { Opcode } from '../avm/serialization/instruction_serialization.js';
|
|
9
|
-
import {
|
|
9
|
+
import { deployAndExecuteCustomBytecode } from './custom_bytecode_tester.js';
|
|
10
10
|
import { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
|
|
11
11
|
|
|
12
12
|
export async function executeAvmMinimalPublicTx(tester: PublicTxSimulationTester): Promise<PublicTxResult> {
|
|
@@ -17,7 +17,7 @@ export async function executeAvmMinimalPublicTx(tester: PublicTxSimulationTester
|
|
|
17
17
|
new Return(/*indirect=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 2),
|
|
18
18
|
]);
|
|
19
19
|
|
|
20
|
-
const result = await
|
|
20
|
+
const result = await deployAndExecuteCustomBytecode(minimalBytecode, tester, 'MinimalTx', 'AvmMinimalContract');
|
|
21
21
|
|
|
22
22
|
// Modify the protocol contracts to be all zeros
|
|
23
23
|
result.hints!.protocolContracts = ProtocolContracts.empty();
|