@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
|
@@ -15,4 +15,4 @@ export declare function getPublicFunctionSelectorAndName(db: PublicContractsDBIn
|
|
|
15
15
|
functionSelector?: FunctionSelector;
|
|
16
16
|
functionName?: string;
|
|
17
17
|
}>;
|
|
18
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVidWdfZm5fbmFtZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3B1YmxpYy9kZWJ1Z19mbl9uYW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3pELE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3JELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRWhFLE9BQU8sS0FBSyxFQUFFLDBCQUEwQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFckUsd0JBQXNCLDBCQUEwQixDQUM5QyxFQUFFLEVBQUUsMEJBQTBCLEVBQzlCLGVBQWUsRUFBRSxZQUFZLEVBQzdCLFFBQVEsRUFBRSxFQUFFLEVBQUUsR0FDYixPQUFPLENBQUMsTUFBTSxDQUFDLENBV2pCO0FBRUQ7Ozs7Ozs7R0FPRztBQUNILHdCQUFzQixnQ0FBZ0MsQ0FDcEQsRUFBRSxFQUFFLDBCQUEwQixFQUM5QixlQUFlLEVBQUUsWUFBWSxFQUM3QixRQUFRLEVBQUUsRUFBRSxFQUFFLEdBQ2IsT0FBTyxDQUFDO0lBQUUsZ0JBQWdCLENBQUMsRUFBRSxnQkFBZ0IsQ0FBQztJQUFDLFlBQVksQ0FBQyxFQUFFLE1BQU0sQ0FBQTtDQUFFLENBQUMsQ0FjekUifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug_fn_name.d.ts","sourceRoot":"","sources":["../../src/public/debug_fn_name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAErE,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,0BAA0B,EAC9B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,EAAE,EAAE,GACb,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"debug_fn_name.d.ts","sourceRoot":"","sources":["../../src/public/debug_fn_name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAErE,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,0BAA0B,EAC9B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,EAAE,EAAE,GACb,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED;;;;;;;GAOG;AACH,wBAAsB,gCAAgC,CACpD,EAAE,EAAE,0BAA0B,EAC9B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,EAAE,EAAE,GACb,OAAO,CAAC;IAAE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAczE"}
|
|
@@ -4,8 +4,12 @@ export async function getPublicFunctionDebugName(db, contractAddress, calldata)
|
|
|
4
4
|
if (!calldata[0]) {
|
|
5
5
|
return `<calldata[0] undefined> (Contract Address: ${contractAddress})`;
|
|
6
6
|
}
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const fallbackName = `<calldata[0]:${calldata[0].toString()}> (Contract Address: ${contractAddress})`;
|
|
8
|
+
const selector = FunctionSelector.fromFieldOrUndefined(calldata[0]);
|
|
9
|
+
if (!selector) {
|
|
10
|
+
return fallbackName;
|
|
11
|
+
}
|
|
12
|
+
return await db.getDebugFunctionName(contractAddress, selector) ?? fallbackName;
|
|
9
13
|
}
|
|
10
14
|
/**
|
|
11
15
|
* Get the function selector and optional debug name for a public function.
|
|
@@ -19,7 +23,10 @@ export async function getPublicFunctionDebugName(db, contractAddress, calldata)
|
|
|
19
23
|
if (!calldata[0]) {
|
|
20
24
|
return {};
|
|
21
25
|
}
|
|
22
|
-
const selector = FunctionSelector.
|
|
26
|
+
const selector = FunctionSelector.fromFieldOrUndefined(calldata[0]);
|
|
27
|
+
if (!selector) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
23
30
|
const debugName = await db.getDebugFunctionName(contractAddress, selector);
|
|
24
31
|
return {
|
|
25
32
|
functionSelector: selector,
|
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
import type { PublicTxResult } from '@aztec/stdlib/avm';
|
|
2
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
2
4
|
import { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
* Test custom bytecode (simulation or proving) with the provided bytecode.
|
|
6
|
+
* Deploy a contract with the provided bytecode.
|
|
6
7
|
* @param bytecode - The bytecode buffer to use
|
|
7
|
-
* @param tester - The tester to use
|
|
8
|
+
* @param tester - The tester to use
|
|
9
|
+
* @param contractName - The name of the contract
|
|
10
|
+
* @param deployer - The deployer address
|
|
11
|
+
* @returns The deployed contract instance
|
|
12
|
+
*/
|
|
13
|
+
export declare function deployCustomBytecode(bytecode: Buffer, tester: PublicTxSimulationTester, contractName?: string, deployer?: AztecAddress): Promise<ContractInstanceWithAddress>;
|
|
14
|
+
/**
|
|
15
|
+
* Execute a custom bytecode contract.
|
|
16
|
+
* @param contract - The contract instance to execute
|
|
17
|
+
* @param tester - The tester to use
|
|
18
|
+
* @param txLabel - The label of the transaction
|
|
19
|
+
* @param calldata - The calldata to use
|
|
20
|
+
* @returns The execution result
|
|
21
|
+
*/
|
|
22
|
+
export declare function executeCustomBytecode(contract: ContractInstanceWithAddress, tester: PublicTxSimulationTester, txLabel?: string, calldata?: any[]): Promise<PublicTxResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Deploy and execute a custom bytecode contract.
|
|
25
|
+
* @param bytecode - The bytecode buffer to use
|
|
26
|
+
* @param tester - The tester to use
|
|
8
27
|
* @param txLabel - The label of the transaction
|
|
9
|
-
* @param contractName - The name of the contract
|
|
28
|
+
* @param contractName - The name of the contract
|
|
29
|
+
* @param deployer - The deployer address
|
|
30
|
+
* @param calldata - The calldata to use
|
|
31
|
+
* @returns The execution result
|
|
10
32
|
*/
|
|
11
|
-
export declare function
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
33
|
+
export declare function deployAndExecuteCustomBytecode(bytecode: Buffer, tester: PublicTxSimulationTester, txLabel?: string, contractName?: string, deployer?: AztecAddress, calldata?: any[]): Promise<PublicTxResult>;
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3VzdG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EdBQUUsWUFBMEMsRUFDcEQsUUFBUSxHQUFFLEdBQUcsRUFBTyxHQUNuQixPQUFPLENBQUMsY0FBYyxDQUFDLENBR3pCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom_bytecode_tester.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/custom_bytecode_tester.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"custom_bytecode_tester.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/custom_bytecode_tester.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,wBAAwB,EAChC,YAAY,GAAE,MAAiC,EAC/C,QAAQ,GAAE,YAA0C,GACnD,OAAO,CAAC,2BAA2B,CAAC,CAiBtC;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,2BAA2B,EACrC,MAAM,EAAE,wBAAwB,EAChC,OAAO,GAAE,MAA6B,EACtC,QAAQ,GAAE,GAAG,EAAO,GACnB,OAAO,CAAC,cAAc,CAAC,CAQzB;AAED;;;;;;;;;GASG;AACH,wBAAsB,8BAA8B,CAClD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,wBAAwB,EAChC,OAAO,GAAE,MAA6B,EACtC,YAAY,GAAE,MAAiC,EAC/C,QAAQ,GAAE,YAA0C,EACpD,QAAQ,GAAE,GAAG,EAAO,GACnB,OAAO,CAAC,cAAc,CAAC,CAGzB"}
|
|
@@ -1,29 +1,53 @@
|
|
|
1
1
|
import { FunctionType, emptyContractArtifact, emptyFunctionArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* Test custom bytecode (simulation or proving) with the provided bytecode.
|
|
4
|
+
* Deploy a contract with the provided bytecode.
|
|
6
5
|
* @param bytecode - The bytecode buffer to use
|
|
7
|
-
* @param tester - The tester to use
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
* @param tester - The tester to use
|
|
7
|
+
* @param contractName - The name of the contract
|
|
8
|
+
* @param deployer - The deployer address
|
|
9
|
+
* @returns The deployed contract instance
|
|
10
|
+
*/ export async function deployCustomBytecode(bytecode, tester, contractName = 'CustomBytecodeContract', deployer = AztecAddress.fromNumber(42)) {
|
|
12
11
|
const contractArtifact = emptyContractArtifact();
|
|
13
12
|
contractArtifact.name = contractName;
|
|
14
13
|
contractArtifact.functions = [
|
|
15
14
|
emptyFunctionArtifact()
|
|
16
15
|
];
|
|
16
|
+
// We use name 'public_dispatch' since that is what is expected
|
|
17
|
+
// in a ContractArtifact. But function selectors are not required
|
|
18
|
+
// when executing since the custom bytecode likely has no dispatch.
|
|
17
19
|
contractArtifact.functions[0].name = 'public_dispatch';
|
|
18
20
|
contractArtifact.functions[0].functionType = FunctionType.PUBLIC;
|
|
19
21
|
contractArtifact.functions[0].bytecode = bytecode;
|
|
20
|
-
|
|
22
|
+
// return the contract instance
|
|
23
|
+
return await tester.registerAndDeployContract(/*constructorArgs=*/ [], deployer, /*contractArtifact=*/ contractArtifact);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Execute a custom bytecode contract.
|
|
27
|
+
* @param contract - The contract instance to execute
|
|
28
|
+
* @param tester - The tester to use
|
|
29
|
+
* @param txLabel - The label of the transaction
|
|
30
|
+
* @param calldata - The calldata to use
|
|
31
|
+
* @returns The execution result
|
|
32
|
+
*/ export async function executeCustomBytecode(contract, tester, txLabel = 'CustomBytecodeTest', calldata = []) {
|
|
21
33
|
// EXECUTE! This means that if using AvmProvingTester subclass, it will PROVE the transaction!
|
|
22
|
-
return await tester.executeTxWithLabel(/*txLabel=*/ txLabel, /*sender=*/ deployer, /*setupCalls=*/ [], /*appCalls=*/ [
|
|
34
|
+
return await tester.executeTxWithLabel(/*txLabel=*/ txLabel, /*sender=*/ contract.deployer, /*setupCalls=*/ [], /*appCalls=*/ [
|
|
23
35
|
{
|
|
24
|
-
address:
|
|
25
|
-
|
|
26
|
-
args: []
|
|
36
|
+
address: contract.address,
|
|
37
|
+
args: calldata
|
|
27
38
|
}
|
|
28
39
|
]);
|
|
29
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Deploy and execute a custom bytecode contract.
|
|
43
|
+
* @param bytecode - The bytecode buffer to use
|
|
44
|
+
* @param tester - The tester to use
|
|
45
|
+
* @param txLabel - The label of the transaction
|
|
46
|
+
* @param contractName - The name of the contract
|
|
47
|
+
* @param deployer - The deployer address
|
|
48
|
+
* @param calldata - The calldata to use
|
|
49
|
+
* @returns The execution result
|
|
50
|
+
*/ export async function deployAndExecuteCustomBytecode(bytecode, tester, txLabel = 'CustomBytecodeTest', contractName = 'CustomBytecodeContract', deployer = AztecAddress.fromNumber(42), calldata = []) {
|
|
51
|
+
const testContract = await deployCustomBytecode(bytecode, tester, contractName, deployer);
|
|
52
|
+
return await executeCustomBytecode(testContract, tester, txLabel, calldata);
|
|
53
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
|
|
2
2
|
export declare function addressingWithBaseTagIssueTest(isIndirect: boolean, tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
3
3
|
export declare function addressingWithIndirectTagIssueTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
4
|
+
export declare function addressingWithIndirectThenRelativeTagIssueTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
5
|
+
export declare function addressingWithRelativeOverflowAndIndirectTagIssueTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
4
6
|
export declare function pcOutOfRangeTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
5
7
|
export declare function invalidOpcodeTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
6
8
|
export declare function invalidByteTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
7
9
|
export declare function instructionTruncatedTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
8
10
|
export declare function invalidTagValueTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
9
11
|
export declare function invalidTagValueAndInstructionTruncatedTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3VzdG9tX2J5dGVjb2RlX3Rlc3RzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcHVibGljL2ZpeHR1cmVzL2N1c3RvbV9ieXRlY29kZV90ZXN0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFhQSxPQUFPLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxrQ0FBa0MsQ0FBQztBQUk1RSx3QkFBc0IsOEJBQThCLENBQUMsVUFBVSxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUUsd0JBQXdCLGlEQWN6RztBQUtELHdCQUFzQixrQ0FBa0MsQ0FBQyxNQUFNLEVBQUUsd0JBQXdCLGlEQW1CeEY7QUFPRCx3QkFBc0IsOENBQThDLENBQUMsTUFBTSxFQUF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
|
+
{"version":3,"file":"custom_bytecode_tests.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/custom_bytecode_tests.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAI5E,wBAAsB,8BAA8B,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,wBAAwB,iDAczG;AAKD,wBAAsB,kCAAkC,CAAC,MAAM,EAAE,wBAAwB,iDAmBxF;AAOD,wBAAsB,8CAA8C,CAAC,MAAM,EAAE,wBAAwB,iDAqBpG;AAOD,wBAAsB,qDAAqD,CAAC,MAAM,EAAE,wBAAwB,iDAyB3G;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,wBAAwB,iDAQtE;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,wBAAwB,iDAiBvE;AAGD,wBAAsB,eAAe,CAAC,MAAM,EAAE,wBAAwB,iDAOrE;AAGD,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,wBAAwB,iDAU9E;AAGD,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,wBAAwB,iDAYzE;AAGD,wBAAsB,0CAA0C,CAAC,MAAM,EAAE,wBAAwB,iDAchG"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { strict as assert } from 'assert';
|
|
2
2
|
import { TypeTag } from '../avm/avm_memory_types.js';
|
|
3
3
|
import { Addressing, AddressingMode } from '../avm/opcodes/addressing_mode.js';
|
|
4
|
-
import { CalldataCopy, Jump, Return, Set } from '../avm/opcodes/index.js';
|
|
4
|
+
import { Add, CalldataCopy, Jump, Return, Set } from '../avm/opcodes/index.js';
|
|
5
5
|
import { encodeToBytecode } from '../avm/serialization/bytecode_serialization.js';
|
|
6
6
|
import { MAX_OPCODE_VALUE, Opcode, OperandType, getOperandSize } from '../avm/serialization/instruction_serialization.js';
|
|
7
|
-
import {
|
|
7
|
+
import { deployAndExecuteCustomBytecode } from './custom_bytecode_tester.js';
|
|
8
8
|
// First instruction resolved a base address (offset 0) which is uninitialized and therefore
|
|
9
9
|
// of invalid tag (FF). This will trigger an exceptional halt.
|
|
10
10
|
export async function addressingWithBaseTagIssueTest(isIndirect, tester) {
|
|
@@ -18,7 +18,7 @@ export async function addressingWithBaseTagIssueTest(isIndirect, tester) {
|
|
|
18
18
|
new Return(/*indirect=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
|
|
19
19
|
]);
|
|
20
20
|
const txLabel = isIndirect ? 'AddressingWithBaseTagInvalidIndirect' : 'AddressingWithBaseTagInvalidDirect';
|
|
21
|
-
return await
|
|
21
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
22
22
|
}
|
|
23
23
|
// First instruction sets a value with tag U64 at offset 0. Then a CalldataCopy instruction
|
|
24
24
|
// uses INDIRECT addressing to read from offset 0, which should fail because the value at
|
|
@@ -39,7 +39,51 @@ export async function addressingWithIndirectTagIssueTest(tester) {
|
|
|
39
39
|
new Return(/*indirect=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
|
|
40
40
|
]);
|
|
41
41
|
const txLabel = 'AddressingWithIndirectTagInvalid';
|
|
42
|
-
return await
|
|
42
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
43
|
+
}
|
|
44
|
+
// First instruction sets a value 10 with tag U32 at offset 1 (direct, no relative).
|
|
45
|
+
// Then an ADD_16 instruction uses INDIRECT addressing for the first operand (offset 1)
|
|
46
|
+
// and RELATIVE addressing for the second operand (offset 2). The indirect addressing
|
|
47
|
+
// succeeds (reads U32 value 10 from offset 1, uses it as address), but the relative
|
|
48
|
+
// addressing fails because the base address at offset 0 has the wrong tag (uninitialized/invalid).
|
|
49
|
+
export async function addressingWithIndirectThenRelativeTagIssueTest(tester) {
|
|
50
|
+
const addressingMode = Addressing.fromModes([
|
|
51
|
+
AddressingMode.INDIRECT,
|
|
52
|
+
AddressingMode.RELATIVE,
|
|
53
|
+
AddressingMode.DIRECT
|
|
54
|
+
]);
|
|
55
|
+
const bytecode = encodeToBytecode([
|
|
56
|
+
// Set a U32 value 10 at offset 1 - this will be used as an indirect address
|
|
57
|
+
new Set(/*indirect=*/ 0, /*dstOffset=*/ 1, TypeTag.UINT32, /*value=*/ 10).as(Opcode.SET_32, Set.wireFormat32),
|
|
58
|
+
// ADD_16: first operand uses indirect addressing (reads from offset 1, gets value 10, uses as address - succeeds)
|
|
59
|
+
// second operand uses relative addressing (tries to read base from offset 0, but offset 0 has wrong tag - fails)
|
|
60
|
+
new Add(/*indirect=*/ addressingMode.toWire(), /*aOffset=*/ 1, /*bOffset=*/ 2, /*dstOffset=*/ 3).as(Opcode.ADD_16, Add.wireFormat16),
|
|
61
|
+
new Return(/*indirect=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
|
|
62
|
+
]);
|
|
63
|
+
const txLabel = 'AddressingWithIndirectThenRelativeTagInvalid';
|
|
64
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
65
|
+
}
|
|
66
|
+
// First instruction sets UINT32_MAX at offset 0 (base address) with tag U32.
|
|
67
|
+
// Then an ADD_8 instruction uses INDIRECT_RELATIVE addressing for the first operand (offset 1)
|
|
68
|
+
// and INDIRECT addressing for the second operand (offset 2). The relative addressing
|
|
69
|
+
// for the first operand will overflow (UINT32_MAX + 1 >= MAX_MEMORY_SIZE), causing the instruction to fail.
|
|
70
|
+
// The second operand will also fail (indirect addressing from offset 2 which is uninitialized with tag FF).
|
|
71
|
+
export async function addressingWithRelativeOverflowAndIndirectTagIssueTest(tester) {
|
|
72
|
+
const addressingMode = Addressing.fromModes([
|
|
73
|
+
AddressingMode.INDIRECT_RELATIVE,
|
|
74
|
+
AddressingMode.INDIRECT,
|
|
75
|
+
AddressingMode.DIRECT
|
|
76
|
+
]);
|
|
77
|
+
// UINT32_MAX = 2^32 - 1 = 4294967295
|
|
78
|
+
const UINT32_MAX = 0xffffffff;
|
|
79
|
+
const bytecode = encodeToBytecode([
|
|
80
|
+
// Set UINT32_MAX at offset 0 as base address - this will cause overflow when adding relative offset 1
|
|
81
|
+
new Set(/*indirect=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ UINT32_MAX).as(Opcode.SET_32, Set.wireFormat32),
|
|
82
|
+
new Add(/*indirect=*/ addressingMode.toWire(), /*aOffset=*/ 1, /*bOffset=*/ 2, /*dstOffset=*/ 3).as(Opcode.ADD_8, Add.wireFormat8),
|
|
83
|
+
new Return(/*indirect=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
|
|
84
|
+
]);
|
|
85
|
+
const txLabel = 'AddressingWithRelativeOverflowAndIndirectTagInvalid';
|
|
86
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
43
87
|
}
|
|
44
88
|
export async function pcOutOfRangeTest(tester) {
|
|
45
89
|
const bytecode = encodeToBytecode([
|
|
@@ -47,7 +91,7 @@ export async function pcOutOfRangeTest(tester) {
|
|
|
47
91
|
new Return(/*indirect=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0)
|
|
48
92
|
]);
|
|
49
93
|
const txLabel = 'PcOutOfRange';
|
|
50
|
-
return await
|
|
94
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
51
95
|
}
|
|
52
96
|
export async function invalidOpcodeTest(tester) {
|
|
53
97
|
let bytecode = encodeToBytecode([
|
|
@@ -63,7 +107,7 @@ export async function invalidOpcodeTest(tester) {
|
|
|
63
107
|
// Manipulate the Return opcode to make the opcode invalid (out of range).
|
|
64
108
|
bytecode[offsetReturnOpcodeByte] = MAX_OPCODE_VALUE + 1; // opcode is invalid.
|
|
65
109
|
const txLabel = 'InvalidOpcode';
|
|
66
|
-
return await
|
|
110
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
67
111
|
}
|
|
68
112
|
// Single invalid byte in the bytecode.
|
|
69
113
|
export async function invalidByteTest(tester) {
|
|
@@ -73,7 +117,7 @@ export async function invalidByteTest(tester) {
|
|
|
73
117
|
invalidOpcode
|
|
74
118
|
]);
|
|
75
119
|
const txLabel = 'InvalidByte';
|
|
76
|
-
return await
|
|
120
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
77
121
|
}
|
|
78
122
|
// Truncate the last instruction in the bytecode.
|
|
79
123
|
export async function instructionTruncatedTest(tester) {
|
|
@@ -83,7 +127,7 @@ export async function instructionTruncatedTest(tester) {
|
|
|
83
127
|
// Truncate the bytecode.
|
|
84
128
|
bytecode = bytecode.subarray(0, -1);
|
|
85
129
|
const txLabel = 'InstructionTruncated';
|
|
86
|
-
return await
|
|
130
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
87
131
|
}
|
|
88
132
|
// Invalid tag value byte in an instruction.
|
|
89
133
|
export async function invalidTagValueTest(tester) {
|
|
@@ -95,7 +139,7 @@ export async function invalidTagValueTest(tester) {
|
|
|
95
139
|
assert(bytecode[tagOffset].valueOf() == TypeTag.UINT32.valueOf(), 'Set instruction tag should be UINT32 in test');
|
|
96
140
|
bytecode[tagOffset] = TypeTag.INVALID;
|
|
97
141
|
const txLabel = 'InvalidTagValue';
|
|
98
|
-
return await
|
|
142
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
99
143
|
}
|
|
100
144
|
// Combine an invalid tag in the last instruction that is truncated.
|
|
101
145
|
export async function invalidTagValueAndInstructionTruncatedTest(tester) {
|
|
@@ -109,7 +153,7 @@ export async function invalidTagValueAndInstructionTruncatedTest(tester) {
|
|
|
109
153
|
assert(bytecode[tagOffset].valueOf() == TypeTag.UINT128.valueOf(), 'Set instruction tag should be UINT128 in test');
|
|
110
154
|
bytecode[tagOffset] = 0x6f; // Invalid tag value.
|
|
111
155
|
const txLabel = 'InvalidTagValueAndInstructionTruncated';
|
|
112
|
-
return await
|
|
156
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
113
157
|
}
|
|
114
158
|
/**
|
|
115
159
|
* Returns the offset of the tag in an instruction.
|
|
@@ -7,4 +7,6 @@ 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
|
-
|
|
10
|
+
export { deployCustomBytecode, executeCustomBytecode, deployAndExecuteCustomBytecode, } from './custom_bytecode_tester.js';
|
|
11
|
+
export { getSpamConfigsPerOpcode, testOpcodeSpamCase } from './opcode_spammer.js';
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvZml4dHVyZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxrQ0FBa0MsQ0FBQztBQUNqRCxjQUFjLFlBQVksQ0FBQztBQUMzQixjQUFjLGtDQUFrQyxDQUFDO0FBQ2pELE9BQU8sRUFBRSxvQ0FBb0MsRUFBRSx5QkFBeUIsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ3pHLE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2xFLE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDeEMsT0FBTyxFQUFFLFFBQVEsRUFBRSxZQUFZLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUN4RCxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDNUMsY0FBYyw0QkFBNEIsQ0FBQztBQUMzQyxPQUFPLEVBQ0wsb0JBQW9CLEVBQ3BCLHFCQUFxQixFQUNyQiw4QkFBOEIsR0FDL0IsTUFBTSw2QkFBNkIsQ0FBQztBQUNyQyxPQUFPLEVBQUUsdUJBQXVCLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,YAAY,CAAC;AAC3B,cAAc,kCAAkC,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,YAAY,CAAC;AAC3B,cAAc,kCAAkC,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,8BAA8B,GAC/B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -7,3 +7,5 @@ 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 { deployCustomBytecode, executeCustomBytecode, deployAndExecuteCustomBytecode } from './custom_bytecode_tester.js';
|
|
11
|
+
export { getSpamConfigsPerOpcode, testOpcodeSpamCase } from './opcode_spammer.js';
|
|
@@ -7,7 +7,7 @@ import { TypeTag } from '../avm/avm_memory_types.js';
|
|
|
7
7
|
import { Add, Return, Set } from '../avm/opcodes/index.js';
|
|
8
8
|
import { encodeToBytecode } from '../avm/serialization/bytecode_serialization.js';
|
|
9
9
|
import { Opcode } from '../avm/serialization/instruction_serialization.js';
|
|
10
|
-
import {
|
|
10
|
+
import { deployAndExecuteCustomBytecode } from './custom_bytecode_tester.js';
|
|
11
11
|
export async function executeAvmMinimalPublicTx(tester) {
|
|
12
12
|
const minimalBytecode = encodeToBytecode([
|
|
13
13
|
new Set(/*indirect*/ 0, /*dstOffset*/ 0, TypeTag.UINT32, /*value*/ 1).as(Opcode.SET_8, Set.wireFormat8),
|
|
@@ -15,7 +15,7 @@ export async function executeAvmMinimalPublicTx(tester) {
|
|
|
15
15
|
new Add(/*indirect=*/ 0, /*aOffset=*/ 0, /*bOffset=*/ 1, /*dstOffset=*/ 2).as(Opcode.ADD_8, Add.wireFormat8),
|
|
16
16
|
new Return(/*indirect=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 2)
|
|
17
17
|
]);
|
|
18
|
-
const result = await
|
|
18
|
+
const result = await deployAndExecuteCustomBytecode(minimalBytecode, tester, 'MinimalTx', 'AvmMinimalContract');
|
|
19
19
|
// Modify the protocol contracts to be all zeros
|
|
20
20
|
result.hints.protocolContracts = ProtocolContracts.empty();
|
|
21
21
|
result.publicInputs.protocolContracts = ProtocolContracts.empty();
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Bufferable } from '@aztec/foundation/serialize';
|
|
2
|
+
import type { PublicTxResult } from '@aztec/stdlib/avm';
|
|
3
|
+
import { type MemoryValue } from '../avm/avm_memory_types.js';
|
|
4
|
+
import { Opcode } from '../avm/serialization/instruction_serialization.js';
|
|
5
|
+
import type { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
|
|
6
|
+
/**
|
|
7
|
+
* Memory cell to initialize before spamming.
|
|
8
|
+
*/
|
|
9
|
+
interface MemSetup {
|
|
10
|
+
offset: number;
|
|
11
|
+
value: MemoryValue;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Some setup action to take before spamming.
|
|
15
|
+
* Either a memory cell to initialize, or some instruction generator.
|
|
16
|
+
*/
|
|
17
|
+
type SetupItem = MemSetup | (() => Bufferable[]);
|
|
18
|
+
/**
|
|
19
|
+
* Everything needed to spam an opcode.
|
|
20
|
+
*/
|
|
21
|
+
export interface SpamConfig {
|
|
22
|
+
/** Memory cells to initialize */
|
|
23
|
+
setup: SetupItem[];
|
|
24
|
+
/** Factory to create target instruction(s) to spam */
|
|
25
|
+
targetInstructions: () => Bufferable[];
|
|
26
|
+
/** Instructions to run after target spam (e.g., REVERT) */
|
|
27
|
+
cleanupInstructions?: () => Bufferable[];
|
|
28
|
+
/**
|
|
29
|
+
* Per-TX limit for the target opcode (for side-effect-limited opcodes)
|
|
30
|
+
* If set:
|
|
31
|
+
* 1. makes nested CALL
|
|
32
|
+
* 2. executes target opcode #limit times in a nested call
|
|
33
|
+
* 3. REVERT
|
|
34
|
+
* 4. CALL again to repeat
|
|
35
|
+
*/
|
|
36
|
+
limit?: number;
|
|
37
|
+
/** Optional label for this config variant (e.g., UINT8 or MAXSIZE) */
|
|
38
|
+
label?: string;
|
|
39
|
+
/** Whether to pass the contract address as calldata[0] */
|
|
40
|
+
addressAsCalldata?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* An object containing opcode name and its SpamConfigs
|
|
44
|
+
* Useful when ready to iterate over all opcodes and test them.
|
|
45
|
+
*/
|
|
46
|
+
export interface SpamConfigsForOpcode {
|
|
47
|
+
/** Opcode name (e.g., "ADD_8") */
|
|
48
|
+
opcode: string;
|
|
49
|
+
/** All spam configs for this opcode (one or more) */
|
|
50
|
+
configs: SpamConfig[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Opcode spammer configs for ~all opcodes.
|
|
54
|
+
* Each opcode maps to an array of configs (usually one, but can be multiple for type variants, etc.)
|
|
55
|
+
* Uses smallest wire format (_8) for maximum instruction density.
|
|
56
|
+
*/
|
|
57
|
+
export declare const SPAM_CONFIGS: Partial<Record<Opcode, SpamConfig[]>>;
|
|
58
|
+
/**
|
|
59
|
+
* Get all spam test cases grouped by opcode.
|
|
60
|
+
* This is the main entry point for tests - it handles all the complexity of
|
|
61
|
+
* type variants, multiple configs, etc.
|
|
62
|
+
*
|
|
63
|
+
* Returns hierarchical structure for nested describe blocks in tests.
|
|
64
|
+
*
|
|
65
|
+
* @param maxConfigsPerOpcode - Maximum number of configs to include per opcode.
|
|
66
|
+
* Defaults to Infinity (no limit). Useful for quick
|
|
67
|
+
* smoke tests where testing all type variants is too slow,
|
|
68
|
+
* or for proving tests that are inherently slower.
|
|
69
|
+
*/
|
|
70
|
+
export declare function getSpamConfigsPerOpcode(maxConfigsPerOpcode?: number): SpamConfigsForOpcode[];
|
|
71
|
+
/**
|
|
72
|
+
* Generate basic opcode spam bytecode from a SpamConfig.
|
|
73
|
+
* Spams the target instruction(s) in an infinite loop until out-of-gas.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createOpcodeSpamBytecode(config: SpamConfig): Buffer;
|
|
76
|
+
/**
|
|
77
|
+
* Generate a bytecode that spams a side-effect limited opcode #limit times
|
|
78
|
+
* NOT in a loop, but inline/unrolled. Then revert.
|
|
79
|
+
*
|
|
80
|
+
* @param config - the side-effect limited spam config to use
|
|
81
|
+
* @returns the bytecode for the side-effect limited spam
|
|
82
|
+
*/
|
|
83
|
+
export declare function createSideEffectSpamBytecode(config: SpamConfig): Buffer;
|
|
84
|
+
export declare function testOpcodeSpamCase(tester: PublicTxSimulationTester, config: SpamConfig, expectToBeTrue?: (x: boolean) => void): Promise<PublicTxResult>;
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3Bjb2RlX3NwYW1tZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvZml4dHVyZXMvb3Bjb2RlX3NwYW1tZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBbUtBLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQzlELE9BQU8sS0FBSyxFQUFxQixjQUFjLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUkzRSxPQUFPLEVBQVMsS0FBSyxXQUFXLEVBQXdDLE1BQU0sNEJBQTRCLENBQUM7QUFrRDNHLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxtREFBbUQsQ0FBQztBQUUzRSxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBTWpGOztHQUVHO0FBQ0gsVUFBVSxRQUFRO0lBQ2hCLE1BQU0sRUFBRSxNQUFNLENBQUM7SUFDZixLQUFLLEVBQUUsV0FBVyxDQUFDO0NBQ3BCO0FBRUQ7OztHQUdHO0FBQ0gsS0FBSyxTQUFTLEdBQUcsUUFBUSxHQUFHLENBQUMsTUFBTSxVQUFVLEVBQUUsQ0FBQyxDQUFDO0FBRWpEOztHQUVHO0FBQ0gsTUFBTSxXQUFXLFVBQVU7SUFDekIsaUNBQWlDO0lBQ2pDLEtBQUssRUFBRSxTQUFTLEVBQUUsQ0FBQztJQUVuQixzREFBc0Q7SUFDdEQsa0JBQWtCLEVBQUUsTUFBTSxVQUFVLEVBQUUsQ0FBQ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