@aztec/simulator 2.1.0-rc.9 → 3.0.0-devnet.2
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/private/acvm_native.d.ts +1 -2
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.d.ts +2 -1
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +5 -2
- package/dest/public/avm/avm_gas.js +2 -2
- package/dest/public/avm/avm_simulator.d.ts +1 -1
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +14 -21
- 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/avm_simulation_tester.d.ts +2 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +2 -3
- 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/fixtures/initializers.d.ts.map +1 -1
- package/dest/public/avm/fixtures/initializers.js +2 -2
- package/dest/public/avm/opcodes/accrued_substate.d.ts +2 -2
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +7 -7
- 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/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +3 -0
- 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 +5 -6
- package/dest/public/avm/opcodes/misc.d.ts +2 -1
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +28 -8
- 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/avm/test_utils.d.ts +2 -2
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +6 -9
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +63 -130
- 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 +2 -1
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
- package/dest/public/fixtures/minimal_public_tx.js +8 -22
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +4 -2
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +11 -6
- package/dest/public/fixtures/utils.js +1 -1
- package/dest/public/hinting_db_sources.d.ts +2 -0
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +3 -0
- package/dest/public/index.d.ts +1 -1
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/public_db_sources.d.ts +2 -2
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +11 -1
- 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/guarded_merkle_tree.d.ts +2 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +3 -0
- package/dest/public/public_processor/public_processor.d.ts +9 -4
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +12 -6
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +41 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +89 -0
- package/dest/public/public_tx_simulator/index.d.ts +1 -0
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +5 -4
- 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 +3 -4
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +4 -2
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +12 -8
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +24 -11
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +112 -44
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +9 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.js +1 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +2 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +2 -2
- package/dest/public/side_effect_errors.d.ts +41 -1
- package/dest/public/side_effect_errors.d.ts.map +1 -1
- package/dest/public/side_effect_errors.js +70 -1
- package/dest/public/side_effect_trace.d.ts +11 -4
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +35 -20
- package/dest/public/side_effect_trace_interface.d.ts +6 -0
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- 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 +7 -2
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +54 -15
- package/package.json +21 -17
- package/src/private/acvm_native.ts +1 -2
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +1 -1
- package/src/public/avm/avm_execution_environment.ts +4 -1
- package/src/public/avm/avm_gas.ts +2 -2
- package/src/public/avm/avm_simulator.ts +16 -27
- package/src/public/avm/errors.ts +7 -24
- package/src/public/avm/fixtures/avm_simulation_tester.ts +4 -2
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +32 -0
- package/src/public/avm/fixtures/initializers.ts +2 -1
- package/src/public/avm/opcodes/accrued_substate.ts +4 -4
- package/src/public/avm/opcodes/addressing_mode.ts +3 -3
- package/src/public/avm/opcodes/conversion.ts +4 -0
- 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 +8 -6
- package/src/public/avm/opcodes/misc.ts +41 -7
- package/src/public/avm/serialization/instruction_serialization.ts +12 -0
- package/src/public/avm/test_utils.ts +6 -14
- package/src/public/fixtures/bulk_test.ts +41 -23
- 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 +8 -31
- package/src/public/fixtures/public_tx_simulation_tester.ts +16 -12
- package/src/public/fixtures/utils.ts +1 -1
- package/src/public/hinting_db_sources.ts +5 -0
- package/src/public/index.ts +6 -1
- package/src/public/public_db_sources.ts +19 -3
- package/src/public/public_errors.ts +14 -0
- package/src/public/public_processor/guarded_merkle_tree.ts +4 -0
- package/src/public/public_processor/public_processor.ts +23 -25
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +128 -0
- package/src/public/public_tx_simulator/index.ts +1 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +12 -9
- package/src/public/public_tx_simulator/public_tx_context.ts +11 -4
- package/src/public/public_tx_simulator/public_tx_simulator.ts +178 -60
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +11 -0
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +3 -12
- package/src/public/side_effect_errors.ts +91 -1
- package/src/public/side_effect_trace.ts +48 -23
- package/src/public/side_effect_trace_interface.ts +6 -0
- package/src/public/state_manager/nullifiers.ts +1 -7
- package/src/public/state_manager/state_manager.ts +73 -25
- 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
|
@@ -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,GAA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,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"}
|
|
@@ -15,6 +15,8 @@ import { Opcode, deserialize, serializeAs } from '../serialization/instruction_s
|
|
|
15
15
|
* the instruction sub-class name all of its flags and operands.
|
|
16
16
|
* @returns Thee string representation.
|
|
17
17
|
*/ toString() {
|
|
18
|
+
// Note: we could have this be the actual wire opcode if `bytecode_serialization.ts` were to
|
|
19
|
+
// pass it into the class' static `Instruction.as(this, wireFormat)` method.
|
|
18
20
|
let instructionStr = this.constructor.name + ': ';
|
|
19
21
|
// assumes that all properties are flags or operands
|
|
20
22
|
for (const prop of Object.getOwnPropertyNames(this)){
|
|
@@ -78,9 +80,7 @@ import { Opcode, deserialize, serializeAs } from '../serialization/instruction_s
|
|
|
78
80
|
* Instruction sub-classes should have a static `type` property.
|
|
79
81
|
*/ get type() {
|
|
80
82
|
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
|
-
}
|
|
83
|
+
assert(!!type, `Instruction class ${this.constructor.name} does not have a static 'type' property defined.`);
|
|
84
84
|
return type;
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
@@ -88,9 +88,8 @@ import { Opcode, deserialize, serializeAs } from '../serialization/instruction_s
|
|
|
88
88
|
* Instruction sub-classes should have a static `opcode` property.
|
|
89
89
|
*/ get opcode() {
|
|
90
90
|
const opcode = 'opcode' in this.constructor ? this.constructor.opcode : undefined;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
91
|
+
assert(opcode !== undefined, `Instruction class ${this.constructor.name} does not have a static 'opcode' property defined.`);
|
|
92
|
+
assert(Opcode[opcode] !== undefined, `Invalid opcode ${opcode} for instruction class ${this.constructor.name}.`);
|
|
94
93
|
return opcode;
|
|
95
94
|
}
|
|
96
95
|
}
|
|
@@ -3,6 +3,7 @@ import { Opcode, OperandType } from '../serialization/instruction_serialization.
|
|
|
3
3
|
import { Instruction } from './instruction.js';
|
|
4
4
|
export declare class DebugLog extends Instruction {
|
|
5
5
|
private indirect;
|
|
6
|
+
private levelOffset;
|
|
6
7
|
private messageOffset;
|
|
7
8
|
private fieldsOffset;
|
|
8
9
|
private fieldsSizeOffset;
|
|
@@ -11,7 +12,7 @@ export declare class DebugLog extends Instruction {
|
|
|
11
12
|
static readonly opcode: Opcode;
|
|
12
13
|
static readonly logger: import("@aztec/foundation/log").Logger;
|
|
13
14
|
static readonly wireFormat: OperandType[];
|
|
14
|
-
constructor(indirect: number, messageOffset: number, fieldsOffset: number, fieldsSizeOffset: number, messageSize: number);
|
|
15
|
+
constructor(indirect: number, levelOffset: number, messageOffset: number, fieldsOffset: number, fieldsSizeOffset: number, messageSize: number);
|
|
15
16
|
execute(context: AvmContext): Promise<void>;
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=misc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/misc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAEpF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBAAa,QAAS,SAAQ,WAAW;
|
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/misc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAEpF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBAAa,QAAS,SAAQ,WAAW;IAiBrC,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,WAAW;IArBrB,MAAM,CAAC,IAAI,EAAE,MAAM,CAAc;IACjC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAmB;IACjD,MAAM,CAAC,QAAQ,CAAC,MAAM,yCAA2C;IAGjE,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,EAAE,CAQvC;gBAGQ,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM;IAKhB,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAkEzD"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
1
|
+
import { LogLevels, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { TypeTag } from '../avm_memory_types.js';
|
|
3
3
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
4
4
|
import { Addressing } from './addressing_mode.js';
|
|
5
5
|
import { Instruction } from './instruction.js';
|
|
6
6
|
export class DebugLog extends Instruction {
|
|
7
7
|
indirect;
|
|
8
|
+
levelOffset;
|
|
8
9
|
messageOffset;
|
|
9
10
|
fieldsOffset;
|
|
10
11
|
fieldsSizeOffset;
|
|
@@ -19,35 +20,54 @@ export class DebugLog extends Instruction {
|
|
|
19
20
|
OperandType.UINT16,
|
|
20
21
|
OperandType.UINT16,
|
|
21
22
|
OperandType.UINT16,
|
|
23
|
+
OperandType.UINT16,
|
|
22
24
|
OperandType.UINT16
|
|
23
25
|
];
|
|
24
|
-
constructor(indirect, messageOffset, fieldsOffset, fieldsSizeOffset, messageSize){
|
|
25
|
-
super(), this.indirect = indirect, this.messageOffset = messageOffset, this.fieldsOffset = fieldsOffset, this.fieldsSizeOffset = fieldsSizeOffset, this.messageSize = messageSize;
|
|
26
|
+
constructor(indirect, levelOffset, messageOffset, fieldsOffset, fieldsSizeOffset, messageSize){
|
|
27
|
+
super(), this.indirect = indirect, this.levelOffset = levelOffset, this.messageOffset = messageOffset, this.fieldsOffset = fieldsOffset, this.fieldsSizeOffset = fieldsSizeOffset, this.messageSize = messageSize;
|
|
26
28
|
}
|
|
27
29
|
async execute(context) {
|
|
28
30
|
const memory = context.machineState.memory;
|
|
29
31
|
const addressing = Addressing.fromWire(this.indirect);
|
|
30
32
|
context.machineState.consumeGas(this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()));
|
|
31
33
|
const operands = [
|
|
34
|
+
this.levelOffset,
|
|
32
35
|
this.messageOffset,
|
|
33
36
|
this.fieldsOffset,
|
|
34
37
|
this.fieldsSizeOffset
|
|
35
38
|
];
|
|
36
|
-
const [messageOffset, fieldsOffset, fieldsSizeOffset] = addressing.resolve(operands, memory);
|
|
37
|
-
// DebugLog is a no-op except when doing client-initiated simulation
|
|
39
|
+
const [levelOffset, messageOffset, fieldsOffset, fieldsSizeOffset] = addressing.resolve(operands, memory);
|
|
40
|
+
// DebugLog is a no-op except when doing client-initiated simulation.
|
|
38
41
|
// Note that we still do address resolution and basic tag-checking (above)
|
|
39
42
|
// To avoid a special-case in the witness generator and circuit.
|
|
40
|
-
if (context.environment.clientInitiatedSimulation
|
|
43
|
+
if (context.environment.clientInitiatedSimulation) {
|
|
44
|
+
memory.checkTag(TypeTag.UINT8, levelOffset);
|
|
45
|
+
const levelNumber = memory.get(levelOffset).toNumber();
|
|
41
46
|
memory.checkTag(TypeTag.UINT32, fieldsSizeOffset);
|
|
42
47
|
const fieldsSize = memory.get(fieldsSizeOffset).toNumber();
|
|
48
|
+
const memoryReads = 1 /* level */ + 1 /* fieldsSize */ + this.messageSize /* message */ + fieldsSize; /* fields */
|
|
49
|
+
if (context.persistableState.getDebugLogMemoryReads() + memoryReads > context.environment.maxDebugLogMemoryReads) {
|
|
50
|
+
// Regular error on purpose: this is not a recoverable error.
|
|
51
|
+
throw new Error(`Max debug log memory reads exceeded: ${context.persistableState.getDebugLogMemoryReads() + memoryReads} > ${context.environment.maxDebugLogMemoryReads}`);
|
|
52
|
+
}
|
|
53
|
+
context.persistableState.writeDebugLogMemoryReads(memoryReads);
|
|
43
54
|
const rawMessage = memory.getSlice(messageOffset, this.messageSize);
|
|
44
55
|
const fields = memory.getSlice(fieldsOffset, fieldsSize);
|
|
45
56
|
memory.checkTagsRange(TypeTag.UINT8, messageOffset, this.messageSize);
|
|
46
57
|
memory.checkTagsRange(TypeTag.FIELD, fieldsOffset, fieldsSize);
|
|
47
58
|
// Interpret str<N> = [u8; N] to string.
|
|
48
59
|
const messageAsStr = rawMessage.map((field)=>String.fromCharCode(field.toNumber())).join('');
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
if (!LogLevels[levelNumber]) {
|
|
61
|
+
// Regular error on purpose: this is not a recoverable error.
|
|
62
|
+
throw new Error(`Invalid debug log level: ${levelNumber}`);
|
|
63
|
+
}
|
|
64
|
+
const level = LogLevels[levelNumber];
|
|
65
|
+
context.persistableState.writeDebugLog(context.environment.address, level, messageAsStr, fields.map((field)=>field.toFr()));
|
|
66
|
+
// Skips string formatting if the level is disabled.
|
|
67
|
+
if (DebugLog.logger.isLevelEnabled(level)) {
|
|
68
|
+
const formattedStr = applyStringFormatting(messageAsStr, fields.map((field)=>field.toFr()));
|
|
69
|
+
DebugLog.logger[level](formattedStr);
|
|
70
|
+
}
|
|
51
71
|
}
|
|
52
72
|
}
|
|
53
73
|
}
|
|
@@ -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,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;
|
|
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;IAC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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){
|
|
@@ -6,9 +6,9 @@ export declare function mockTraceFork(trace: PublicSideEffectTraceInterface, nes
|
|
|
6
6
|
export declare function mockStorageRead(worldStateDB: PublicTreesDB, value: Fr): void;
|
|
7
7
|
export declare function mockNoteHashCount(mockedTrace: PublicSideEffectTraceInterface, count: number): void;
|
|
8
8
|
export declare function mockStorageReadWithMap(worldStateDB: PublicTreesDB, mockedStorage: Map<bigint, Fr>): void;
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function mockGetNoteHash(worldStateDB: PublicTreesDB, _leafIndex: bigint, value?: Fr): void;
|
|
10
10
|
export declare function mockCheckNullifierExists(worldStateDB: PublicTreesDB, exists: boolean, _ignoredValue?: Fr): void;
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function mockGetL1ToL2LeafValue(worldStateDB: PublicTreesDB, leafIndex: bigint, value?: Fr): void;
|
|
12
12
|
export declare function mockGetContractInstance(contractsDB: PublicContractsDB, contractInstance: ContractInstanceWithAddress): void;
|
|
13
13
|
export declare function mockGetContractClass(contractsDB: PublicContractsDB, contractClass: ContractClassPublic): void;
|
|
14
14
|
export declare function mockGetBytecodeCommitment(contractsDB: PublicContractsDB, commitment: Fr): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_utils.d.ts","sourceRoot":"","sources":["../../../src/public/avm/test_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAK/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAExF,wBAAgB,aAAa,CAAC,KAAK,EAAE,8BAA8B,EAAE,WAAW,CAAC,EAAE,8BAA8B,QAIhH;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,QAErE;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,8BAA8B,EAAE,KAAK,EAAE,MAAM,QAE3F;AAED,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,QAIjG;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"test_utils.d.ts","sourceRo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,24 @@ export function mockNoteHashCount(mockedTrace, count) {
|
|
|
12
12
|
export function mockStorageReadWithMap(worldStateDB, mockedStorage) {
|
|
13
13
|
worldStateDB.storageRead.mockImplementation((_address, slot)=>Promise.resolve(mockedStorage.get(slot.toBigInt()) ?? Fr.ZERO));
|
|
14
14
|
}
|
|
15
|
-
export function
|
|
15
|
+
export function mockGetNoteHash(worldStateDB, _leafIndex, value) {
|
|
16
16
|
worldStateDB.getNoteHash.mockImplementation((index)=>{
|
|
17
|
-
if (index == _leafIndex) {
|
|
17
|
+
if (index == _leafIndex && value) {
|
|
18
18
|
return Promise.resolve(value);
|
|
19
19
|
} else {
|
|
20
|
-
|
|
21
|
-
return Promise.resolve(undefined);
|
|
20
|
+
return Promise.resolve(Fr.ZERO);
|
|
22
21
|
}
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
24
|
export function mockCheckNullifierExists(worldStateDB, exists, _ignoredValue) {
|
|
26
25
|
worldStateDB.checkNullifierExists.mockResolvedValue(exists);
|
|
27
26
|
}
|
|
28
|
-
export function
|
|
27
|
+
export function mockGetL1ToL2LeafValue(worldStateDB, leafIndex, value) {
|
|
29
28
|
worldStateDB.getL1ToL2LeafValue.mockImplementation((index)=>{
|
|
30
|
-
if (index == leafIndex) {
|
|
29
|
+
if (index == leafIndex && value) {
|
|
31
30
|
return Promise.resolve(value);
|
|
32
31
|
} else {
|
|
33
|
-
|
|
34
|
-
// (or undefined if no value is specified for other indices)
|
|
35
|
-
return Promise.resolve(valueAtOtherIndices);
|
|
32
|
+
return Promise.resolve(Fr.ZERO);
|
|
36
33
|
}
|
|
37
34
|
});
|
|
38
35
|
}
|
|
@@ -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"}
|
|
@@ -5,6 +5,11 @@ export async function bulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
5
5
|
const timer = new Timer();
|
|
6
6
|
const deployer = AztecAddress.fromNumber(42);
|
|
7
7
|
const avmTestContract = await tester.registerAndDeployContract(/*constructorArgs=*/ [], deployer, avmTestContractArtifact);
|
|
8
|
+
// Needed since we invoke the Fee Juice Contract in the bulk test.registerFeeJuiceContract
|
|
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();
|
|
8
13
|
// Get a deployed contract instance to pass to the contract
|
|
9
14
|
// for it to use as "expected" values when testing contract instance retrieval.
|
|
10
15
|
const expectContractInstance = avmTestContract;
|
|
@@ -28,10 +33,10 @@ export async function bulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
28
33
|
5,
|
|
29
34
|
6,
|
|
30
35
|
7,
|
|
31
|
-
8
|
|
32
|
-
9,
|
|
33
|
-
10
|
|
36
|
+
8
|
|
34
37
|
].map((x)=>new Fr(x));
|
|
38
|
+
argsU8.push(new Fr(2n ** 128n + 9n)); // Trigger truncation from large (> 128 bits) value (canonical decomposition event)
|
|
39
|
+
argsU8.push(new Fr(2n ** 125n + 10n)); // Trigger truncation from small (< 128 bits) value (no canonical decomposition event)
|
|
35
40
|
const args = [
|
|
36
41
|
argsField,
|
|
37
42
|
argsU8,
|
|
@@ -46,6 +51,51 @@ export async function bulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
46
51
|
address: avmTestContract.address,
|
|
47
52
|
fnName: 'bulk_testing',
|
|
48
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: []
|
|
49
99
|
}
|
|
50
100
|
], /*teardownCall=*/ undefined, /*feePayer*/ undefined, /*privateInsertions=*/ {
|
|
51
101
|
nonRevertible: {
|
|
@@ -72,6 +122,8 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
72
122
|
const timer = new Timer();
|
|
73
123
|
const deployer = AztecAddress.fromNumber(42);
|
|
74
124
|
const avmTestContract = await tester.registerAndDeployContract(/*constructorArgs=*/ [], deployer, avmTestContractArtifact);
|
|
125
|
+
// Needed since we invoke the Fee Juice Contract in the bulk test.registerFeeJuiceContract
|
|
126
|
+
await tester.registerFeeJuiceContract();
|
|
75
127
|
// Get a deployed contract instance to pass to the contract
|
|
76
128
|
// for it to use as "expected" values when testing contract instance retrieval.
|
|
77
129
|
const expectContractInstance = avmTestContract;
|
|
@@ -88,31 +140,7 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
88
140
|
10
|
|
89
141
|
].map((x)=>new Fr(x));
|
|
90
142
|
const argsField1 = [
|
|
91
|
-
2,
|
|
92
|
-
2,
|
|
93
|
-
3,
|
|
94
|
-
4,
|
|
95
|
-
5,
|
|
96
|
-
6,
|
|
97
|
-
7,
|
|
98
|
-
8,
|
|
99
|
-
9,
|
|
100
|
-
10
|
|
101
|
-
].map((x)=>new Fr(x));
|
|
102
|
-
const argsField2 = [
|
|
103
|
-
3,
|
|
104
|
-
2,
|
|
105
143
|
3,
|
|
106
|
-
4,
|
|
107
|
-
5,
|
|
108
|
-
6,
|
|
109
|
-
7,
|
|
110
|
-
8,
|
|
111
|
-
9,
|
|
112
|
-
10
|
|
113
|
-
].map((x)=>new Fr(x));
|
|
114
|
-
const argsField3 = [
|
|
115
|
-
4,
|
|
116
144
|
2,
|
|
117
145
|
3,
|
|
118
146
|
4,
|
|
@@ -123,20 +151,8 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
123
151
|
9,
|
|
124
152
|
10
|
|
125
153
|
].map((x)=>new Fr(x));
|
|
126
|
-
const
|
|
127
|
-
5,
|
|
128
|
-
2,
|
|
129
|
-
3,
|
|
130
|
-
4,
|
|
154
|
+
const argsField2 = [
|
|
131
155
|
5,
|
|
132
|
-
6,
|
|
133
|
-
7,
|
|
134
|
-
8,
|
|
135
|
-
9,
|
|
136
|
-
10
|
|
137
|
-
].map((x)=>new Fr(x));
|
|
138
|
-
const argsField5 = [
|
|
139
|
-
6,
|
|
140
156
|
2,
|
|
141
157
|
3,
|
|
142
158
|
4,
|
|
@@ -147,20 +163,8 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
147
163
|
9,
|
|
148
164
|
10
|
|
149
165
|
].map((x)=>new Fr(x));
|
|
150
|
-
const
|
|
151
|
-
7,
|
|
152
|
-
2,
|
|
153
|
-
3,
|
|
154
|
-
4,
|
|
155
|
-
5,
|
|
156
|
-
6,
|
|
166
|
+
const argsField3 = [
|
|
157
167
|
7,
|
|
158
|
-
8,
|
|
159
|
-
9,
|
|
160
|
-
10
|
|
161
|
-
].map((x)=>new Fr(x));
|
|
162
|
-
const argsField7 = [
|
|
163
|
-
8,
|
|
164
168
|
2,
|
|
165
169
|
3,
|
|
166
170
|
4,
|
|
@@ -171,20 +175,8 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
171
175
|
9,
|
|
172
176
|
10
|
|
173
177
|
].map((x)=>new Fr(x));
|
|
174
|
-
const
|
|
175
|
-
9,
|
|
176
|
-
2,
|
|
177
|
-
3,
|
|
178
|
-
4,
|
|
179
|
-
5,
|
|
180
|
-
6,
|
|
181
|
-
7,
|
|
182
|
-
8,
|
|
178
|
+
const argsField4 = [
|
|
183
179
|
9,
|
|
184
|
-
10
|
|
185
|
-
].map((x)=>new Fr(x));
|
|
186
|
-
const argsField9 = [
|
|
187
|
-
10,
|
|
188
180
|
2,
|
|
189
181
|
3,
|
|
190
182
|
4,
|
|
@@ -195,7 +187,7 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
195
187
|
9,
|
|
196
188
|
10
|
|
197
189
|
].map((x)=>new Fr(x));
|
|
198
|
-
const
|
|
190
|
+
const argsField5 = [
|
|
199
191
|
11,
|
|
200
192
|
2,
|
|
201
193
|
3,
|
|
@@ -207,19 +199,7 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
207
199
|
9,
|
|
208
200
|
10
|
|
209
201
|
].map((x)=>new Fr(x));
|
|
210
|
-
const
|
|
211
|
-
12,
|
|
212
|
-
2,
|
|
213
|
-
3,
|
|
214
|
-
4,
|
|
215
|
-
5,
|
|
216
|
-
6,
|
|
217
|
-
7,
|
|
218
|
-
8,
|
|
219
|
-
9,
|
|
220
|
-
10
|
|
221
|
-
].map((x)=>new Fr(x));
|
|
222
|
-
const argsField12 = [
|
|
202
|
+
const argsField6 = [
|
|
223
203
|
13,
|
|
224
204
|
2,
|
|
225
205
|
3,
|
|
@@ -231,19 +211,7 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
231
211
|
9,
|
|
232
212
|
10
|
|
233
213
|
].map((x)=>new Fr(x));
|
|
234
|
-
const
|
|
235
|
-
14,
|
|
236
|
-
2,
|
|
237
|
-
3,
|
|
238
|
-
4,
|
|
239
|
-
5,
|
|
240
|
-
6,
|
|
241
|
-
7,
|
|
242
|
-
8,
|
|
243
|
-
9,
|
|
244
|
-
10
|
|
245
|
-
].map((x)=>new Fr(x));
|
|
246
|
-
const argsField14 = [
|
|
214
|
+
const argsField7 = [
|
|
247
215
|
15,
|
|
248
216
|
2,
|
|
249
217
|
3,
|
|
@@ -255,8 +223,8 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
255
223
|
9,
|
|
256
224
|
10
|
|
257
225
|
].map((x)=>new Fr(x));
|
|
258
|
-
const
|
|
259
|
-
|
|
226
|
+
const argsField8 = [
|
|
227
|
+
17,
|
|
260
228
|
2,
|
|
261
229
|
3,
|
|
262
230
|
4,
|
|
@@ -334,41 +302,6 @@ export async function megaBulkTest(tester, logger, avmTestContractArtifact) {
|
|
|
334
302
|
address: avmTestContract.address,
|
|
335
303
|
fnName: 'bulk_testing',
|
|
336
304
|
args: genArgs(argsField8)
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
address: avmTestContract.address,
|
|
340
|
-
fnName: 'bulk_testing',
|
|
341
|
-
args: genArgs(argsField9)
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
address: avmTestContract.address,
|
|
345
|
-
fnName: 'bulk_testing',
|
|
346
|
-
args: genArgs(argsField10)
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
address: avmTestContract.address,
|
|
350
|
-
fnName: 'bulk_testing',
|
|
351
|
-
args: genArgs(argsField11)
|
|
352
|
-
},
|
|
353
|
-
{
|
|
354
|
-
address: avmTestContract.address,
|
|
355
|
-
fnName: 'bulk_testing',
|
|
356
|
-
args: genArgs(argsField12)
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
address: avmTestContract.address,
|
|
360
|
-
fnName: 'bulk_testing',
|
|
361
|
-
args: genArgs(argsField13)
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
address: avmTestContract.address,
|
|
365
|
-
fnName: 'bulk_testing',
|
|
366
|
-
args: genArgs(argsField14)
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
address: avmTestContract.address,
|
|
370
|
-
fnName: 'bulk_testing',
|
|
371
|
-
args: genArgs(argsField15)
|
|
372
305
|
}
|
|
373
306
|
], /*teardownCall=*/ undefined, /*feePayer*/ undefined, /*privateInsertions=*/ {
|
|
374
307
|
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"}
|