@aztec/simulator 3.0.0-nightly.20251002 → 3.0.0-nightly.20251004
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_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +8 -18
- package/dest/public/avm/errors.d.ts +5 -14
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +7 -20
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +2 -0
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +22 -0
- package/dest/public/avm/opcodes/accrued_substate.js +1 -1
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -1
- package/dest/public/avm/opcodes/addressing_mode.js +2 -3
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +3 -2
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +5 -7
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction.js +3 -6
- package/dest/public/avm/serialization/instruction_serialization.d.ts +8 -0
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +10 -0
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +48 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +12 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tester.js +29 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +9 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tests.js +109 -0
- package/dest/public/fixtures/index.d.ts +2 -1
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +2 -1
- package/dest/public/fixtures/minimal_public_tx.d.ts +1 -1
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
- package/dest/public/fixtures/minimal_public_tx.js +4 -20
- package/dest/public/public_errors.d.ts +12 -0
- package/dest/public/public_errors.d.ts.map +1 -0
- package/dest/public/public_errors.js +13 -0
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +2 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +1 -2
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +7 -2
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +95 -31
- package/dest/public/side_effect_errors.d.ts +24 -1
- package/dest/public/side_effect_errors.d.ts.map +1 -1
- package/dest/public/side_effect_errors.js +42 -1
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +5 -5
- package/dest/public/state_manager/nullifiers.d.ts +0 -3
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -1
- package/dest/public/state_manager/nullifiers.js +1 -6
- package/dest/public/state_manager/state_manager.d.ts +1 -2
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +16 -7
- package/package.json +15 -15
- package/src/public/avm/avm_simulator.ts +8 -26
- package/src/public/avm/errors.ts +7 -24
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +32 -0
- package/src/public/avm/opcodes/accrued_substate.ts +1 -1
- package/src/public/avm/opcodes/addressing_mode.ts +3 -3
- package/src/public/avm/opcodes/ec_add.ts +3 -2
- package/src/public/avm/opcodes/environment_getters.ts +6 -8
- package/src/public/avm/opcodes/instruction.ts +6 -6
- package/src/public/avm/serialization/instruction_serialization.ts +12 -0
- package/src/public/fixtures/bulk_test.ts +23 -0
- package/src/public/fixtures/custom_bytecode_tester.ts +49 -0
- package/src/public/fixtures/custom_bytecode_tests.ts +135 -0
- package/src/public/fixtures/index.ts +2 -1
- package/src/public/fixtures/minimal_public_tx.ts +4 -31
- package/src/public/public_errors.ts +14 -0
- package/src/public/public_processor/public_processor.ts +3 -1
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +2 -3
- package/src/public/public_tx_simulator/public_tx_simulator.ts +140 -47
- package/src/public/side_effect_errors.ts +56 -1
- package/src/public/side_effect_trace.ts +11 -8
- package/src/public/state_manager/nullifiers.ts +1 -7
- package/src/public/state_manager/state_manager.ts +20 -12
- package/dest/public/bytecode_errors.d.ts +0 -4
- package/dest/public/bytecode_errors.d.ts.map +0 -1
- package/dest/public/bytecode_errors.js +0 -6
- package/src/public/bytecode_errors.ts +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avm_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/avm/avm_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKxD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAI1E,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,2CAA2C,CAAC;AAOnD,qBAAa,YAAa,YAAW,qBAAqB;IAatD,OAAO,CAAC,OAAO;I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I1E,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,2CAA2C,CAAC;AAOnD,qBAAa,YAAa,YAAW,qBAAqB;IAatD,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,cAAc;IAbxB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,aAAa,CAAuC;IAE5D,OAAO,CAAC,6BAA6B,CAAiD;IAEtF,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,wBAAwB,CAA+B;gBAKrD,OAAO,EAAE,UAAU,EACnB,cAAc,GAAE,cAAgC,EACxD,cAAc,UAAQ;WAeJ,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;WAQjD,MAAM,CACxB,YAAY,EAAE,6BAA6B,EAC3C,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,EAAE,EAClB,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,OAAO,EACrB,QAAQ,EAAE,EAAE,EAAE,EACd,YAAY,EAAE,GAAG,EACjB,yBAAyB,GAAE,OAAe,EAC1C,sBAAsB,CAAC,EAAE,MAAM;IAmBjC;;OAEG;IACU,OAAO,IAAI,OAAO,CAAC,qBAAqB,CAAC;IActD;;OAEG;IACI,WAAW,IAAI,MAAM,GAAG,SAAS;IAIxC;;;OAGG;IACU,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;YA0GhE,+BAA+B;IAoB7C,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,kBAAkB;CAS3B"}
|
|
@@ -2,12 +2,12 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import { strict as assert } from 'assert';
|
|
5
|
-
import {
|
|
5
|
+
import { CheckedPublicExecutionError } from '../public_errors.js';
|
|
6
6
|
import { AvmContext } from './avm_context.js';
|
|
7
7
|
import { AvmContractCallResult } from './avm_contract_call_result.js';
|
|
8
8
|
import { AvmExecutionEnvironment } from './avm_execution_environment.js';
|
|
9
9
|
import { AvmMachineState } from './avm_machine_state.js';
|
|
10
|
-
import {
|
|
10
|
+
import { AvmRevertReason, InvalidProgramCounterError } from './errors.js';
|
|
11
11
|
import { revertReasonFromExceptionalHalt, revertReasonFromExplicitRevert } from './revert_reason.js';
|
|
12
12
|
import { INSTRUCTION_SET, decodeInstructionFromBytecode } from './serialization/bytecode_serialization.js';
|
|
13
13
|
export class AvmSimulator {
|
|
@@ -56,18 +56,11 @@ export class AvmSimulator {
|
|
|
56
56
|
/**
|
|
57
57
|
* Fetch the bytecode and execute it in the current context.
|
|
58
58
|
*/ async execute() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
} catch (err) {
|
|
63
|
-
if (!(err instanceof AvmExecutionError || err instanceof SideEffectLimitReachedError)) {
|
|
64
|
-
this.log.error(`Unknown error thrown by AVM during bytecode retrieval: ${err}`);
|
|
65
|
-
throw err;
|
|
66
|
-
}
|
|
67
|
-
return await this.handleFailureToRetrieveBytecode(`Bytecode retrieval for contract '${this.context.environment.address}' failed with ${err.message}. Reverting...`);
|
|
68
|
-
}
|
|
59
|
+
const bytecode = await this.context.persistableState.getBytecode(this.context.environment.address);
|
|
60
|
+
// getBytecode returns undefined if bytecode is not found or if the limit of contract calls to unique class IDs is reached.
|
|
61
|
+
// If it throws an error that reaches this point, it is a bug.
|
|
69
62
|
if (!bytecode) {
|
|
70
|
-
return await this.handleFailureToRetrieveBytecode(`No bytecode found
|
|
63
|
+
return await this.handleFailureToRetrieveBytecode(`No bytecode found, or limit encountered for max calls to unique contract class IDs. Contract address: ${this.context.environment.address}. Reverting...`);
|
|
71
64
|
}
|
|
72
65
|
return await this.executeBytecode(bytecode);
|
|
73
66
|
}
|
|
@@ -138,11 +131,8 @@ export class AvmSimulator {
|
|
|
138
131
|
return results;
|
|
139
132
|
} catch (err) {
|
|
140
133
|
this.log.verbose('Exceptional halt (revert by something other than REVERT opcode)');
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// 2. We should at least be able to do instanceof OutOfGasError instead of checking the constructor name
|
|
144
|
-
if (!(err.constructor.name == 'OutOfGasError' || err instanceof AvmExecutionError || err instanceof SideEffectLimitReachedError)) {
|
|
145
|
-
this.log.error(`Unknown error thrown by AVM: ${err}`);
|
|
134
|
+
if (!(err instanceof CheckedPublicExecutionError)) {
|
|
135
|
+
this.log.error(`Unchecked/unknown error thrown by AVM. This is a bug. Error: ${err}`);
|
|
146
136
|
throw err;
|
|
147
137
|
}
|
|
148
138
|
const revertReason = await revertReasonFromExceptionalHalt(err, this.context);
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import type { Point } from '@aztec/foundation/fields';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
2
|
import type { FailingFunction, NoirCallStack } from '@aztec/stdlib/errors';
|
|
4
3
|
import { ExecutionError } from '../../common/errors.js';
|
|
4
|
+
import { CheckedPublicExecutionError } from '../public_errors.js';
|
|
5
5
|
/**
|
|
6
6
|
* Avm-specific errors should derive from this
|
|
7
7
|
*/
|
|
8
|
-
export declare abstract class AvmExecutionError extends
|
|
8
|
+
export declare abstract class AvmExecutionError extends CheckedPublicExecutionError {
|
|
9
9
|
constructor(message: string);
|
|
10
10
|
}
|
|
11
|
-
export declare class NoBytecodeForContractError extends AvmExecutionError {
|
|
12
|
-
constructor(contractAddress: AztecAddress);
|
|
13
|
-
}
|
|
14
11
|
export declare class ArithmeticError extends AvmExecutionError {
|
|
15
12
|
constructor(message: string);
|
|
16
13
|
}
|
|
@@ -73,16 +70,10 @@ export declare class OutOfGasError extends AvmExecutionError {
|
|
|
73
70
|
constructor(dimensions: string[]);
|
|
74
71
|
}
|
|
75
72
|
/**
|
|
76
|
-
* Error is thrown when the supplied points
|
|
77
|
-
*/
|
|
78
|
-
export declare class MSMPointsLengthError extends AvmExecutionError {
|
|
79
|
-
constructor(pointsReadLength: number);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Error is thrown when one of the supplied points does not lie on the Grumpkin curve. Specific for MSM opcode.
|
|
73
|
+
* Error is thrown when one of the supplied points does not lie on the Grumpkin curve. Specific for ECADD opcode.
|
|
83
74
|
*/
|
|
84
|
-
export declare class
|
|
85
|
-
constructor(point: Point);
|
|
75
|
+
export declare class EcAddPointNotOnCurveError extends AvmExecutionError {
|
|
76
|
+
constructor(pointIndex: number, point: Point);
|
|
86
77
|
}
|
|
87
78
|
/**
|
|
88
79
|
* Error is thrown when some inputs of ToRadixBE are not valid.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/public/avm/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/public/avm/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAElE;;GAEG;AACH,8BAAsB,iBAAkB,SAAQ,2BAA2B;gBAC7D,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,eAAgB,SAAQ,iBAAiB;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,iBAAiB;gBACnD,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAIpC;AAED;;;GAGG;AACH,qBAAa,kBAAmB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AY;CAGpH"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { ExecutionError } from '../../common/errors.js';
|
|
2
|
+
import { CheckedPublicExecutionError } from '../public_errors.js';
|
|
2
3
|
/**
|
|
3
4
|
* Avm-specific errors should derive from this
|
|
4
|
-
*/ export class AvmExecutionError extends
|
|
5
|
+
*/ export class AvmExecutionError extends CheckedPublicExecutionError {
|
|
5
6
|
constructor(message){
|
|
6
7
|
super(message);
|
|
7
8
|
this.name = 'AvmExecutionError';
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
export class NoBytecodeForContractError extends AvmExecutionError {
|
|
11
|
-
constructor(contractAddress){
|
|
12
|
-
super(`No bytecode found at: ${contractAddress}`);
|
|
13
|
-
this.name = 'NoBytecodeFoundInterpreterError';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
11
|
export class ArithmeticError extends AvmExecutionError {
|
|
17
12
|
constructor(message){
|
|
18
13
|
super(message);
|
|
@@ -100,19 +95,11 @@ export class ArithmeticError extends AvmExecutionError {
|
|
|
100
95
|
}
|
|
101
96
|
}
|
|
102
97
|
/**
|
|
103
|
-
* Error is thrown when the supplied points
|
|
104
|
-
*/ export class
|
|
105
|
-
constructor(
|
|
106
|
-
super(`
|
|
107
|
-
this.name = '
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Error is thrown when one of the supplied points does not lie on the Grumpkin curve. Specific for MSM opcode.
|
|
112
|
-
*/ export class MSMPointNotOnCurveError extends AvmExecutionError {
|
|
113
|
-
constructor(point){
|
|
114
|
-
super(`Point ${point.toString()} is not on the curve.`);
|
|
115
|
-
this.name = 'MSMPointNotOnCurveError';
|
|
98
|
+
* Error is thrown when one of the supplied points does not lie on the Grumpkin curve. Specific for ECADD opcode.
|
|
99
|
+
*/ export class EcAddPointNotOnCurveError extends AvmExecutionError {
|
|
100
|
+
constructor(pointIndex, point){
|
|
101
|
+
super(`EcAdd point${pointIndex} (${point.toString()}) is not on the curve.`);
|
|
102
|
+
this.name = 'EcAddPointNotOnCurveError';
|
|
116
103
|
}
|
|
117
104
|
}
|
|
118
105
|
/**
|
|
@@ -29,6 +29,8 @@ export declare abstract class BaseAvmSimulationTester {
|
|
|
29
29
|
*/
|
|
30
30
|
registerAndDeployContract(constructorArgs: any[], deployer: AztecAddress, contractArtifact: ContractArtifact, skipNullifierInsertion?: boolean, seed?: number, contractClassSeed?: number, originalContractClassId?: Fr): Promise<ContractInstanceWithAddress>;
|
|
31
31
|
registerFeeJuiceContract(): Promise<ContractInstanceWithAddress>;
|
|
32
|
+
registerAuthContract(): Promise<ContractInstanceWithAddress>;
|
|
33
|
+
registerInstanceRegistryContract(): Promise<ContractInstanceWithAddress>;
|
|
32
34
|
addContractInstance(contractInstance: ContractInstanceWithAddress, skipNullifierInsertion?: boolean): Promise<void>;
|
|
33
35
|
private insertContractAddressNullifier;
|
|
34
36
|
insertNullifier(contractThatEmitted: AztecAddress, nullifier: Fr): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_avm_simulation_tester.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/base_avm_simulation_tester.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"base_avm_simulation_tester.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/base_avm_simulation_tester.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAM9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAGjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAG9F;;;;;;;;;;GAUG;AACH,8BAAsB,uBAAuB;IAIlC,kBAAkB,EAAE,wBAAwB;IAC5C,WAAW,EAAE,yBAAyB;IAC7C,OAAO,CAAC,sBAAsB;IALzB,MAAM,yCAAyC;gBAG7C,kBAAkB,EAAE,wBAAwB,EAC5C,WAAW,EAAE,yBAAyB,EACrC,sBAAsB,KAAmB;IAG7C,kBAAkB,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,KAA8B;IAMhF,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE;IAOjE;;;OAGG;IACG,yBAAyB,CAC7B,eAAe,EAAE,GAAG,EAAE,EACtB,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,sBAAsB,UAAQ,EAC9B,IAAI,SAAI,EACR,iBAAiB,SAAO,EACxB,uBAAuB,CAAC,EAAE,EAAE,GAC3B,OAAO,CAAC,2BAA2B,CAAC;IAkBjC,wBAAwB,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAWhE,oBAAoB,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAe5D,gCAAgC,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAexE,mBAAmB,CAAC,gBAAgB,EAAE,2BAA2B,EAAE,sBAAsB,UAAQ;YAOzF,8BAA8B;IAQtC,eAAe,CAAC,mBAAmB,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE;CAIvE"}
|
|
@@ -2,7 +2,9 @@ import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
|
+
import { getCanonicalAuthRegistry } from '@aztec/protocol-contracts/auth-registry';
|
|
5
6
|
import { computeFeePayerBalanceStorageSlot, getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
|
|
7
|
+
import { getCanonicalInstanceRegistry } from '@aztec/protocol-contracts/instance-registry';
|
|
6
8
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
7
9
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
10
|
import { computePublicDataTreeLeafSlot, siloNullifier } from '@aztec/stdlib/hash';
|
|
@@ -63,6 +65,26 @@ import { createContractClassAndInstance } from './utils.js';
|
|
|
63
65
|
await this.contractDataSource.addNewContract(feeJuice.artifact, feeJuiceContractClassPublic, feeJuice.instance);
|
|
64
66
|
return feeJuice.instance;
|
|
65
67
|
}
|
|
68
|
+
async registerAuthContract() {
|
|
69
|
+
const authRegistry = await getCanonicalAuthRegistry();
|
|
70
|
+
const authRegistryContractClassPublic = {
|
|
71
|
+
...authRegistry.contractClass,
|
|
72
|
+
privateFunctions: [],
|
|
73
|
+
utilityFunctions: []
|
|
74
|
+
};
|
|
75
|
+
await this.contractDataSource.addNewContract(authRegistry.artifact, authRegistryContractClassPublic, authRegistry.instance);
|
|
76
|
+
return authRegistry.instance;
|
|
77
|
+
}
|
|
78
|
+
async registerInstanceRegistryContract() {
|
|
79
|
+
const instanceRegistry = await getCanonicalInstanceRegistry();
|
|
80
|
+
const instanceRegistryContractClassPublic = {
|
|
81
|
+
...instanceRegistry.contractClass,
|
|
82
|
+
privateFunctions: [],
|
|
83
|
+
utilityFunctions: []
|
|
84
|
+
};
|
|
85
|
+
await this.contractDataSource.addNewContract(instanceRegistry.artifact, instanceRegistryContractClassPublic, instanceRegistry.instance);
|
|
86
|
+
return instanceRegistry.instance;
|
|
87
|
+
}
|
|
66
88
|
async addContractInstance(contractInstance, skipNullifierInsertion = false) {
|
|
67
89
|
if (!skipNullifierInsertion) {
|
|
68
90
|
await this.insertContractAddressNullifier(contractInstance.address);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NullifierCollisionError } from '../../
|
|
1
|
+
import { NullifierCollisionError } from '../../side_effect_errors.js';
|
|
2
2
|
import { TypeTag, Uint1 } from '../avm_memory_types.js';
|
|
3
3
|
import { InstructionExecutionError, StaticCallAlterationError } from '../errors.js';
|
|
4
4
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addressing_mode.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/addressing_mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"addressing_mode.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/addressing_mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAIzD,OAAO,EAA6B,KAAK,qBAAqB,EAAW,MAAM,wBAAwB,CAAC;AAGxG,oBAAY,cAAc;IACxB,MAAM,IAAI;IACV,QAAQ,IAAI;IACZ,QAAQ,IAAI;IACZ,iBAAiB,IAAI;CACtB;AAED,kEAAkE;AAClE,qBAAa,UAAU;IAEnB,qDAAqD;IACrD,OAAO,CAAC,QAAQ,CAAC,cAAc;;IAD/B,qDAAqD;IACpC,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,OAAO,gBAAgB,CAAC;WAGnE,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,UAAU;WAK9C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU;IAa9C,MAAM,IAAI,MAAM;IAehB,qBAAqB,IAAI,MAAM;IAI/B,qBAAqB,IAAI,MAAM;IAItC;;;;;;OAMG;IACI,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,qBAAqB,GAAG,MAAM,EAAE;CAuCxE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AVM_MAX_OPERANDS } from '@aztec/constants';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
+
import { strict as assert } from 'assert';
|
|
3
4
|
import { TaggedMemory, TypeTag } from '../avm_memory_types.js';
|
|
4
5
|
import { RelativeAddressOutOfRangeError, TagCheckError } from '../errors.js';
|
|
5
6
|
export var AddressingMode = /*#__PURE__*/ function(AddressingMode) {
|
|
@@ -15,9 +16,7 @@ export var AddressingMode = /*#__PURE__*/ function(AddressingMode) {
|
|
|
15
16
|
this.modePerOperand = modePerOperand;
|
|
16
17
|
}
|
|
17
18
|
static fromModes(modes) {
|
|
18
|
-
|
|
19
|
-
throw new Error('Too many operands for addressing mode');
|
|
20
|
-
}
|
|
19
|
+
assert(modes.length <= AVM_MAX_OPERANDS, 'Too many operands for addressing mode');
|
|
21
20
|
return new Addressing(padArrayEnd(modes, 0, AVM_MAX_OPERANDS));
|
|
22
21
|
}
|
|
23
22
|
static fromWire(wireModes) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ec_add.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/ec_add.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ec_add.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/ec_add.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAEpF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBAAa,KAAM,SAAQ,WAAW;IAkBlC,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,SAAS;IAxBnB,MAAM,CAAC,IAAI,EAAE,MAAM,CAAW;IAC9B,MAAM,CAAC,QAAQ,CAAC,MAAM,gBAAgB;IAGtC,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,EAAE,CAUvC;gBAGQ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,MAAM;IAKd,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAwDzD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Grumpkin } from '@aztec/foundation/crypto';
|
|
2
2
|
import { Point } from '@aztec/foundation/fields';
|
|
3
3
|
import { Field, TypeTag, Uint1 } from '../avm_memory_types.js';
|
|
4
|
+
import { EcAddPointNotOnCurveError } from '../errors.js';
|
|
4
5
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
5
6
|
import { Addressing } from './addressing_mode.js';
|
|
6
7
|
import { Instruction } from './instruction.js';
|
|
@@ -51,7 +52,7 @@ export class EcAdd extends Instruction {
|
|
|
51
52
|
const p1IsInfinite = memory.get(p1IsInfiniteOffset).toNumber() === 1;
|
|
52
53
|
const p1 = new Point(p1X.toFr(), p1Y.toFr(), p1IsInfinite);
|
|
53
54
|
if (!p1.isOnGrumpkin()) {
|
|
54
|
-
throw new
|
|
55
|
+
throw new EcAddPointNotOnCurveError(/*pointIndex=*/ 1, p1);
|
|
55
56
|
}
|
|
56
57
|
const p2X = memory.get(p2XOffset);
|
|
57
58
|
const p2Y = memory.get(p2YOffset);
|
|
@@ -59,7 +60,7 @@ export class EcAdd extends Instruction {
|
|
|
59
60
|
const p2IsInfinite = memory.get(p2IsInfiniteOffset).toNumber() === 1;
|
|
60
61
|
const p2 = new Point(p2X.toFr(), p2Y.toFr(), p2IsInfinite);
|
|
61
62
|
if (!p2.isOnGrumpkin()) {
|
|
62
|
-
throw new
|
|
63
|
+
throw new EcAddPointNotOnCurveError(/*pointIndex=*/ 2, p2);
|
|
63
64
|
}
|
|
64
65
|
const grumpkin = new Grumpkin();
|
|
65
66
|
let dest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment_getters.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/environment_getters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAEpF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,oBAAY,mBAAmB;IAC7B,OAAO,IAAA;IACP,MAAM,IAAA;IACN,cAAc,IAAA;IACd,OAAO,IAAA;IACP,OAAO,IAAA;IACP,WAAW,IAAA;IACX,SAAS,IAAA;IACT,eAAe,IAAA;IACf,eAAe,IAAA;IACf,YAAY,IAAA;IACZ,SAAS,KAAA;IACT,SAAS,KAAA;CACV;AAiCD,qBAAa,SAAU,SAAQ,WAAW;IAWtC,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,OAAO;IAZjB,gBAAuB,IAAI,EAAE,MAAM,CAAe;IAClD,gBAAuB,MAAM,EAAE,MAAM,CAAuB;IAC5D,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,WAAW,EAAE,CAKzC;gBAGQ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM;IAKZ,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"environment_getters.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/environment_getters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAEpF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,oBAAY,mBAAmB;IAC7B,OAAO,IAAA;IACP,MAAM,IAAA;IACN,cAAc,IAAA;IACd,OAAO,IAAA;IACP,OAAO,IAAA;IACP,WAAW,IAAA;IACX,SAAS,IAAA;IACT,eAAe,IAAA;IACf,eAAe,IAAA;IACf,YAAY,IAAA;IACZ,SAAS,KAAA;IACT,SAAS,KAAA;CACV;AAiCD,qBAAa,SAAU,SAAQ,WAAW;IAWtC,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,OAAO;IAZjB,gBAAuB,IAAI,EAAE,MAAM,CAAe;IAClD,gBAAuB,MAAM,EAAE,MAAM,CAAuB;IAC5D,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,WAAW,EAAE,CAKzC;gBAGQ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM;IAKZ,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAezD"}
|
|
@@ -18,8 +18,8 @@ export var EnvironmentVariable = /*#__PURE__*/ function(EnvironmentVariable) {
|
|
|
18
18
|
EnvironmentVariable[EnvironmentVariable["DAGASLEFT"] = 11] = "DAGASLEFT";
|
|
19
19
|
return EnvironmentVariable;
|
|
20
20
|
}({});
|
|
21
|
-
function getValue(
|
|
22
|
-
switch(
|
|
21
|
+
function getValue(varEnum, ctx) {
|
|
22
|
+
switch(varEnum){
|
|
23
23
|
case 0:
|
|
24
24
|
return new Field(ctx.environment.address.toField());
|
|
25
25
|
case 1:
|
|
@@ -45,7 +45,7 @@ function getValue(e, ctx) {
|
|
|
45
45
|
case 11:
|
|
46
46
|
return new Uint32(ctx.machineState.daGasLeft);
|
|
47
47
|
default:
|
|
48
|
-
throw new
|
|
48
|
+
throw new InstructionExecutionError(`Invalid GETENVVAR var enum ${varEnum}`);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
export class GetEnvVar extends Instruction {
|
|
@@ -67,13 +67,11 @@ export class GetEnvVar extends Instruction {
|
|
|
67
67
|
const memory = context.machineState.memory;
|
|
68
68
|
const addressing = Addressing.fromWire(this.indirect);
|
|
69
69
|
context.machineState.consumeGas(this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()));
|
|
70
|
-
if (!(this.varEnum in EnvironmentVariable)) {
|
|
71
|
-
throw new InstructionExecutionError(`Invalid GETENVVAR var enum ${this.varEnum}`);
|
|
72
|
-
}
|
|
73
70
|
const operands = [
|
|
74
71
|
this.dstOffset
|
|
75
72
|
];
|
|
76
73
|
const [dstOffset] = addressing.resolve(operands, memory);
|
|
77
|
-
|
|
74
|
+
const value = getValue(this.varEnum, context);
|
|
75
|
+
memory.set(dstOffset, value);
|
|
78
76
|
}
|
|
79
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/instruction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAI9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,GAAG,EAA4E,MAAM,eAAe,CAAC;AACnH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAA4B,MAAM,+CAA+C,CAAC;AAEnH,KAAK,sBAAsB,GAAG;IAC5B,KAAK,GAAG,IAAI,E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AE,KAAK,WAAW,EAA4B,MAAM,+CAA+C,CAAC;AAEnH,KAAK,sBAAsB,GAAG;IAC5B,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,8BAAsB,WAAW;IAC/B;;;;OAIG;aACa,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3D;;OAEG;IACI,SAAS,IAAI,OAAO;IAI3B;;;;OAIG;IACI,QAAQ,IAAI,MAAM;WAUX,UAAU,CACtB,IAAI,EAAE,sBAAsB,GAAG;QAAE,UAAU,EAAE,WAAW,EAAE,CAAC;QAAC,EAAE,EAAE,GAAG,CAAA;KAAE,EACrE,GAAG,EAAE,YAAY,GAAG,MAAM,GACzB,WAAW;IAKP,QAAQ,IAAI,MAAM;IAOzB;;;;;OAKG;IACI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,WAAW,GAAG,UAAU;IAS9E;;;;;OAKG;WACW,EAAE,CAAC,IAAI,EAAE,sBAAsB,EAAE,UAAU,EAAE,WAAW,EAAE;0BAElD,YAAY,GAAG,MAAM,KAAG,WAAW;;IAQzD;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,qBAAqB,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,GAAG,GAAG;IAIxF;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,aAAa,GAAE,MAAU,GAAG,GAAG;IAIxD;;;OAGG;IACH,IAAW,IAAI,IAAI,MAAM,CAIxB;IAED;;;OAGG;IACH,IAAW,MAAM,IAAI,MAAM,CAQ1B;CACF"}
|
|
@@ -78,9 +78,7 @@ import { Opcode, deserialize, serializeAs } from '../serialization/instruction_s
|
|
|
78
78
|
* Instruction sub-classes should have a static `type` property.
|
|
79
79
|
*/ get type() {
|
|
80
80
|
const type = 'type' in this.constructor && this.constructor.type;
|
|
81
|
-
|
|
82
|
-
throw new Error(`Instruction class ${this.constructor.name} does not have a static 'type' property defined.`);
|
|
83
|
-
}
|
|
81
|
+
assert(!!type, `Instruction class ${this.constructor.name} does not have a static 'type' property defined.`);
|
|
84
82
|
return type;
|
|
85
83
|
}
|
|
86
84
|
/**
|
|
@@ -88,9 +86,8 @@ import { Opcode, deserialize, serializeAs } from '../serialization/instruction_s
|
|
|
88
86
|
* Instruction sub-classes should have a static `opcode` property.
|
|
89
87
|
*/ get opcode() {
|
|
90
88
|
const opcode = 'opcode' in this.constructor ? this.constructor.opcode : undefined;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
89
|
+
assert(opcode !== undefined, `Instruction class ${this.constructor.name} does not have a static 'opcode' property defined.`);
|
|
90
|
+
assert(Opcode[opcode] !== undefined, `Invalid opcode ${opcode} for instruction class ${this.constructor.name}.`);
|
|
94
91
|
return opcode;
|
|
95
92
|
}
|
|
96
93
|
}
|
|
@@ -84,6 +84,14 @@ export declare enum OperandType {
|
|
|
84
84
|
TAG = 6
|
|
85
85
|
}
|
|
86
86
|
type DeserializedValue = number | bigint;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the size of an operand in bytes.
|
|
89
|
+
* Should not be called with unknown operand types.
|
|
90
|
+
* @param operandType
|
|
91
|
+
* @returns number size in bytes
|
|
92
|
+
* @throws AssertionError if the operand type is unknown
|
|
93
|
+
*/
|
|
94
|
+
export declare function getOperandSize(operandType: OperandType): number;
|
|
87
95
|
/**
|
|
88
96
|
* Reads an array of operands from a buffer.
|
|
89
97
|
* @param cursor Buffer to read from. Might be longer than needed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction_serialization.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/serialization/instruction_serialization.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;GAGG;AACH,oBAAY,MAAM;IAEhB,KAAK,IAAA;IACL,MAAM,IAAA;IACN,KAAK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ACN,MAAM,IAAA;IACN,MAAM,IAAA;IACN,OAAO,IAAA;IACP,EAAE,IAAA;IACF,GAAG,IAAA;CACJ;AAGD,KAAK,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"instruction_serialization.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/serialization/instruction_serialization.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;GAGG;AACH,oBAAY,MAAM;IAEhB,KAAK,IAAA;IACL,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,MAAM,IAAA;IACN,OAAO,IAAA;IACP,IAAI,KAAA;IACJ,KAAK,KAAA;IACL,IAAI,KAAA;IACJ,KAAK,KAAA;IACL,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,IAAI,KAAA;IACJ,KAAK,KAAA;IACL,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,MAAM,KAAA;IACN,OAAO,KAAA;IAEP,YAAY,KAAA;IACZ,YAAY,KAAA;IACZ,WAAW,KAAA;IACX,cAAc,KAAA;IACd,cAAc,KAAA;IAEd,OAAO,KAAA;IACP,QAAQ,KAAA;IACR,YAAY,KAAA;IACZ,cAAc,KAAA;IAEd,KAAK,KAAA;IACL,MAAM,KAAA;IACN,MAAM,KAAA;IACN,MAAM,KAAA;IACN,OAAO,KAAA;IACP,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IAEN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,cAAc,KAAA;IACd,YAAY,KAAA;IACZ,eAAe,KAAA;IACf,aAAa,KAAA;IACb,eAAe,KAAA;IACf,mBAAmB,KAAA;IACnB,kBAAkB,KAAA;IAClB,aAAa,KAAA;IAEb,IAAI,KAAA;IACJ,UAAU,KAAA;IACV,MAAM,KAAA;IACN,QAAQ,KAAA;IACR,SAAS,KAAA;IAET,QAAQ,KAAA;IAER,SAAS,KAAA;IACT,iBAAiB,KAAA;IACjB,WAAW,KAAA;IACX,KAAK,KAAA;IAEL,SAAS,KAAA;CACV;AAED,eAAO,MAAM,gBAAgB,QAI5B,CAAC;AAIF,oBAAY,WAAW;IACrB,KAAK,IAAA;IACL,MAAM,IAAA;IACN,MAAM,IAAA;IACN,MAAM,IAAA;IACN,OAAO,IAAA;IACP,EAAE,IAAA;IACF,GAAG,IAAA;CACJ;AAGD,KAAK,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;AAgBzC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAG/D;AAkDD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,iBAAiB,EAAE,CAyBvG;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,CAmBrF"}
|
|
@@ -157,6 +157,16 @@ const OPERAND_SPEC = new Map([
|
|
|
157
157
|
]
|
|
158
158
|
]
|
|
159
159
|
]);
|
|
160
|
+
/**
|
|
161
|
+
* Returns the size of an operand in bytes.
|
|
162
|
+
* Should not be called with unknown operand types.
|
|
163
|
+
* @param operandType
|
|
164
|
+
* @returns number size in bytes
|
|
165
|
+
* @throws AssertionError if the operand type is unknown
|
|
166
|
+
*/ export function getOperandSize(operandType) {
|
|
167
|
+
assert(OPERAND_SPEC.has(operandType), `Unknown operand type: ${operandType}`);
|
|
168
|
+
return OPERAND_SPEC.get(operandType)[0];
|
|
169
|
+
}
|
|
160
170
|
function readUintBE(buf, offset, totalBytes) {
|
|
161
171
|
let value = 0n;
|
|
162
172
|
for(let i = 0; i < totalBytes; ++i){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk_test.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/bulk_test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,wBAAwB,EAChC,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"bulk_test.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/bulk_test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,wBAAwB,EAChC,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,gBAAgB,iDAkF1C;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,wBAAwB,EAChC,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,gBAAgB,iDAsE1C"}
|
|
@@ -7,6 +7,9 @@ export async function bulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
7
7
|
const avmTestContract = await tester.registerAndDeployContract(/*constructorArgs=*/ [], deployer, avmTestContractArtifact);
|
|
8
8
|
// Needed since we invoke the Fee Juice Contract in the bulk test.registerFeeJuiceContract
|
|
9
9
|
await tester.registerFeeJuiceContract();
|
|
10
|
+
// Register multiple different protocol contracts (to ensure we don't dedup bytecode hashing events):
|
|
11
|
+
await tester.registerAuthContract();
|
|
12
|
+
await tester.registerInstanceRegistryContract();
|
|
10
13
|
// Get a deployed contract instance to pass to the contract
|
|
11
14
|
// for it to use as "expected" values when testing contract instance retrieval.
|
|
12
15
|
const expectContractInstance = avmTestContract;
|
|
@@ -48,6 +51,51 @@ export async function bulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
48
51
|
address: avmTestContract.address,
|
|
49
52
|
fnName: 'bulk_testing',
|
|
50
53
|
args
|
|
54
|
+
},
|
|
55
|
+
// 3 calls creating calldata + asserting calldata copy:
|
|
56
|
+
{
|
|
57
|
+
address: avmTestContract.address,
|
|
58
|
+
fnName: 'assert_calldata_copy_large',
|
|
59
|
+
args: [
|
|
60
|
+
Array.from({
|
|
61
|
+
length: 300
|
|
62
|
+
}, ()=>Fr.random()),
|
|
63
|
+
/* with_selector: */ true
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
address: avmTestContract.address,
|
|
68
|
+
fnName: 'assert_calldata_copy',
|
|
69
|
+
args: [
|
|
70
|
+
argsField.slice(3),
|
|
71
|
+
/* with_selector: */ true
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
address: avmTestContract.address,
|
|
76
|
+
fnName: 'assert_calldata_copy_large',
|
|
77
|
+
args: [
|
|
78
|
+
Array.from({
|
|
79
|
+
length: 300
|
|
80
|
+
}, ()=>Fr.random()),
|
|
81
|
+
/* with_selector: */ true
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
// 3 calls to external contracts
|
|
85
|
+
{
|
|
86
|
+
address: avmTestContract.address,
|
|
87
|
+
fnName: 'call_fee_juice',
|
|
88
|
+
args: []
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
address: avmTestContract.address,
|
|
92
|
+
fnName: 'call_auth_registry',
|
|
93
|
+
args: []
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
address: avmTestContract.address,
|
|
97
|
+
fnName: 'call_instance_registry',
|
|
98
|
+
args: []
|
|
51
99
|
}
|
|
52
100
|
], /*teardownCall=*/ undefined, /*feePayer*/ undefined, /*privateInsertions=*/ {
|
|
53
101
|
nonRevertible: {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PublicTxResult } from '../public_tx_simulator/public_tx_simulator.js';
|
|
2
|
+
import { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Test custom bytecode (simulation or proving) with the provided bytecode.
|
|
6
|
+
* @param bytecode - The bytecode buffer to use
|
|
7
|
+
* @param tester - The tester to use (simulation or proving)
|
|
8
|
+
* @param txLabel - The label of the transaction
|
|
9
|
+
* @param contractName - The name of the contract (default: 'CustomBytecodeContract')
|
|
10
|
+
*/
|
|
11
|
+
export declare function testCustomBytecode(bytecode: Buffer, tester: PublicTxSimulationTester, txLabel: string, contractName?: string): Promise<PublicTxResult>;
|
|
12
|
+
//# sourceMappingURL=custom_bytecode_tester.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom_bytecode_tester.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/custom_bytecode_tester.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AACpF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,wBAAwB,EAChC,OAAO,EAAE,MAAM,EACf,YAAY,GAAE,MAAiC,GAC9C,OAAO,CAAC,cAAc,CAAC,CA6BzB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FunctionType, emptyContractArtifact, emptyFunctionArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Test custom bytecode (simulation or proving) with the provided bytecode.
|
|
6
|
+
* @param bytecode - The bytecode buffer to use
|
|
7
|
+
* @param tester - The tester to use (simulation or proving)
|
|
8
|
+
* @param txLabel - The label of the transaction
|
|
9
|
+
* @param contractName - The name of the contract (default: 'CustomBytecodeContract')
|
|
10
|
+
*/ export async function testCustomBytecode(bytecode, tester, txLabel, contractName = 'CustomBytecodeContract') {
|
|
11
|
+
const deployer = AztecAddress.fromNumber(42);
|
|
12
|
+
const contractArtifact = emptyContractArtifact();
|
|
13
|
+
contractArtifact.name = contractName;
|
|
14
|
+
contractArtifact.functions = [
|
|
15
|
+
emptyFunctionArtifact()
|
|
16
|
+
];
|
|
17
|
+
contractArtifact.functions[0].name = 'public_dispatch';
|
|
18
|
+
contractArtifact.functions[0].functionType = FunctionType.PUBLIC;
|
|
19
|
+
contractArtifact.functions[0].bytecode = bytecode;
|
|
20
|
+
const testContract = await tester.registerAndDeployContract(/*constructorArgs=*/ [], deployer, /*contractArtifact=*/ contractArtifact);
|
|
21
|
+
// EXECUTE! This means that if using AvmProvingTester subclass, it will PROVE the transaction!
|
|
22
|
+
return await tester.executeTxWithLabel(/*txLabel=*/ txLabel, /*sender=*/ deployer, /*setupCalls=*/ [], /*appCalls=*/ [
|
|
23
|
+
{
|
|
24
|
+
address: testContract.address,
|
|
25
|
+
fnName: 'public_dispatch',
|
|
26
|
+
args: []
|
|
27
|
+
}
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
|
|
2
|
+
export declare function addressingWithBaseTagIssueTest(isIndirect: boolean, tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
3
|
+
export declare function pcOutOfRangeTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
4
|
+
export declare function invalidOpcodeTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
5
|
+
export declare function invalidByteTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
6
|
+
export declare function instructionTruncatedTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
7
|
+
export declare function invalidTagValueTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
8
|
+
export declare function invalidTagValueAndInstructionTruncatedTest(tester: PublicTxSimulationTester): Promise<import("../index.js").PublicTxResult>;
|
|
9
|
+
//# sourceMappingURL=custom_bytecode_tests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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;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"}
|