@aztec/simulator 0.0.1-commit.d431d1c → 0.0.1-commit.e3c1de76
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/acvm.d.ts +4 -2
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +4 -3
- package/dest/private/acvm_native.d.ts +5 -3
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/acvm_native.js +8 -6
- package/dest/private/acvm_wasm.d.ts +4 -3
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm.js +4 -4
- package/dest/private/circuit_recording/circuit_recorder.d.ts +4 -3
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +5 -3
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
- package/dest/private/factory.d.ts +3 -3
- package/dest/private/factory.d.ts.map +1 -1
- package/dest/private/factory.js +7 -4
- package/dest/public/avm/avm_context.d.ts +3 -3
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +6 -6
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.js +3 -3
- package/dest/public/avm/avm_execution_environment.d.ts +6 -5
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.d.ts +6 -5
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.js +3 -2
- package/dest/public/avm/avm_memory_types.d.ts +1 -1
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +3 -0
- package/dest/public/avm/avm_simulator.d.ts +3 -2
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +5 -4
- package/dest/public/avm/calldata.d.ts +51 -0
- package/dest/public/avm/calldata.d.ts.map +1 -0
- package/dest/public/avm/calldata.js +63 -0
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +3 -2
- package/dest/public/avm/fixtures/initializers.d.ts +1 -1
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -1
- package/dest/public/avm/fixtures/initializers.js +2 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts +3 -4
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +12 -12
- package/dest/public/avm/opcodes/contract.d.ts +1 -1
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +4 -4
- package/dest/public/avm/opcodes/external_calls.d.ts +1 -1
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +7 -7
- package/dest/public/avm/opcodes/memory.js +1 -1
- package/dest/public/avm/opcodes/storage.d.ts +13 -12
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/public/avm/opcodes/storage.js +30 -20
- package/dest/public/debug_fn_name.d.ts +4 -4
- package/dest/public/debug_fn_name.d.ts.map +1 -1
- package/dest/public/debug_fn_name.js +7 -5
- package/dest/public/executor_metrics.d.ts +1 -1
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +7 -2
- package/dest/public/fixtures/opcode_spammer.d.ts +3 -4
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -1
- package/dest/public/fixtures/opcode_spammer.js +30 -58
- package/dest/public/fuzzing/avm_simulator_bin.js +7 -4
- package/dest/public/public_db_sources.d.ts +4 -3
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +4 -4
- package/dest/public/public_processor/public_processor.d.ts +5 -3
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +8 -5
- package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +20 -4
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +3 -2
- 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 +2 -2
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +5 -5
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +8 -8
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +4 -4
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +5 -5
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +4 -4
- 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 +6 -6
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +3 -2
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.js +2 -2
- package/dest/public/public_tx_simulator/factories.d.ts +3 -2
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/factories.js +3 -3
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +4 -3
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +8 -8
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +4 -3
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +9 -6
- package/dest/public/side_effect_trace.d.ts +4 -4
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +3 -3
- package/dest/public/state_manager/state_manager.d.ts +10 -4
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +12 -5
- package/dest/public/test_executor_metrics.d.ts +3 -2
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +2 -2
- package/package.json +16 -16
- package/src/private/acvm/acvm.ts +4 -3
- package/src/private/acvm_native.ts +11 -5
- package/src/private/acvm_wasm.ts +7 -3
- package/src/private/circuit_recording/circuit_recorder.ts +5 -3
- package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
- package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
- package/src/private/factory.ts +7 -4
- package/src/public/avm/avm_context.ts +2 -2
- package/src/public/avm/avm_contract_call_result.ts +8 -6
- package/src/public/avm/avm_execution_environment.ts +9 -4
- package/src/public/avm/avm_machine_state.ts +6 -5
- package/src/public/avm/avm_memory_types.ts +4 -0
- package/src/public/avm/avm_simulator.ts +8 -5
- package/src/public/avm/calldata.ts +100 -0
- package/src/public/avm/fixtures/avm_simulation_tester.ts +8 -2
- package/src/public/avm/fixtures/initializers.ts +2 -1
- package/src/public/avm/opcodes/accrued_substate.ts +13 -15
- package/src/public/avm/opcodes/contract.ts +1 -4
- package/src/public/avm/opcodes/external_calls.ts +8 -7
- package/src/public/avm/opcodes/memory.ts +1 -1
- package/src/public/avm/opcodes/storage.ts +28 -20
- package/src/public/debug_fn_name.ts +10 -8
- package/src/public/executor_metrics.ts +4 -1
- package/src/public/fixtures/opcode_spammer.ts +49 -53
- package/src/public/fuzzing/avm_simulator_bin.ts +11 -1
- package/src/public/public_db_sources.ts +15 -5
- package/src/public/public_processor/public_processor.ts +18 -5
- package/src/public/public_processor/public_processor_metrics.ts +10 -4
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +6 -3
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +9 -6
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +6 -4
- package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +7 -5
- package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +3 -1
- package/src/public/public_tx_simulator/factories.ts +4 -2
- package/src/public/public_tx_simulator/public_tx_context.ts +13 -6
- package/src/public/public_tx_simulator/public_tx_simulator.ts +14 -5
- package/src/public/side_effect_trace.ts +5 -2
- package/src/public/state_manager/state_manager.ts +27 -4
- package/src/public/test_executor_metrics.ts +3 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AvmContext } from '../avm_context.js';
|
|
2
2
|
import type { AvmContractCallResult } from '../avm_contract_call_result.js';
|
|
3
3
|
import { type Field, TypeTag, Uint1 } from '../avm_memory_types.js';
|
|
4
|
+
import { CallDataMemory, ReturnDataMemory } from '../calldata.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';
|
|
@@ -45,8 +46,8 @@ abstract class ExternalCall extends Instruction {
|
|
|
45
46
|
memory.checkTag(TypeTag.UINT32, argsSizeOffset);
|
|
46
47
|
|
|
47
48
|
const calldataSize = memory.get(argsSizeOffset).toNumber();
|
|
48
|
-
|
|
49
|
-
const calldata = memory
|
|
49
|
+
|
|
50
|
+
const calldata = new CallDataMemory(memory, argsOffset, calldataSize);
|
|
50
51
|
|
|
51
52
|
const callAddress = memory.getAs<Field>(addrOffset);
|
|
52
53
|
// If we are already in a static call, we propagate the environment.
|
|
@@ -73,8 +74,8 @@ abstract class ExternalCall extends Instruction {
|
|
|
73
74
|
const success = !nestedCallResults.reverted;
|
|
74
75
|
|
|
75
76
|
// Save return/revert data for later.
|
|
76
|
-
const
|
|
77
|
-
context.machineState.nestedReturndata =
|
|
77
|
+
const returnData = nestedCallResults.output;
|
|
78
|
+
context.machineState.nestedReturndata = returnData;
|
|
78
79
|
|
|
79
80
|
// Track the success status directly
|
|
80
81
|
context.machineState.nestedCallSuccess = success;
|
|
@@ -89,7 +90,7 @@ abstract class ExternalCall extends Instruction {
|
|
|
89
90
|
// (in Noir code).
|
|
90
91
|
if (!success) {
|
|
91
92
|
context.machineState.collectedRevertInfo = {
|
|
92
|
-
revertDataRepresentative:
|
|
93
|
+
revertDataRepresentative: returnData.bestEffortReadAll(),
|
|
93
94
|
recursiveRevertReason: nestedCallResults.revertReason!,
|
|
94
95
|
};
|
|
95
96
|
}
|
|
@@ -195,7 +196,7 @@ export class Return extends Instruction {
|
|
|
195
196
|
memory.checkTag(TypeTag.UINT32, returnSizeOffset);
|
|
196
197
|
const returnSize = memory.get(returnSizeOffset).toNumber();
|
|
197
198
|
|
|
198
|
-
const output = memory
|
|
199
|
+
const output = new ReturnDataMemory(memory, returnOffset, returnSize);
|
|
199
200
|
|
|
200
201
|
context.machineState.return(output);
|
|
201
202
|
}
|
|
@@ -243,7 +244,7 @@ export class Revert extends Instruction {
|
|
|
243
244
|
|
|
244
245
|
memory.checkTag(TypeTag.UINT32, retSizeOffset);
|
|
245
246
|
const retSize = memory.get(retSizeOffset).toNumber();
|
|
246
|
-
const output = memory
|
|
247
|
+
const output = new ReturnDataMemory(memory, returnOffset, retSize);
|
|
247
248
|
|
|
248
249
|
context.machineState.revert(output);
|
|
249
250
|
}
|
|
@@ -242,7 +242,7 @@ export class ReturndataSize extends Instruction {
|
|
|
242
242
|
const operands = [this.dstOffset];
|
|
243
243
|
const [dstOffset] = addressing.resolve(operands, memory);
|
|
244
244
|
|
|
245
|
-
memory.set(dstOffset, new Uint32(context.machineState.nestedReturndata.length));
|
|
245
|
+
memory.set(dstOffset, new Uint32(context.machineState.nestedReturndata.length()));
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
|
|
@@ -5,7 +5,9 @@ import { Opcode, OperandType } from '../serialization/instruction_serialization.
|
|
|
5
5
|
import { Addressing } from './addressing_mode.js';
|
|
6
6
|
import { Instruction } from './instruction.js';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export class SStore extends Instruction {
|
|
9
|
+
static readonly type: string = 'SSTORE';
|
|
10
|
+
static readonly opcode = Opcode.SSTORE;
|
|
9
11
|
// Informs (de)serialization. See Instruction.deserialize.
|
|
10
12
|
public static readonly wireFormat: OperandType[] = [
|
|
11
13
|
OperandType.UINT8,
|
|
@@ -15,21 +17,12 @@ abstract class BaseStorageInstruction extends Instruction {
|
|
|
15
17
|
];
|
|
16
18
|
|
|
17
19
|
constructor(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
private addressingMode: number,
|
|
21
|
+
private srcOffset: number,
|
|
22
|
+
private slotOffset: number,
|
|
21
23
|
) {
|
|
22
24
|
super();
|
|
23
25
|
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class SStore extends BaseStorageInstruction {
|
|
27
|
-
static readonly type: string = 'SSTORE';
|
|
28
|
-
static readonly opcode = Opcode.SSTORE;
|
|
29
|
-
|
|
30
|
-
constructor(addressingMode: number, srcOffset: number, slotOffset: number) {
|
|
31
|
-
super(addressingMode, srcOffset, slotOffset);
|
|
32
|
-
}
|
|
33
26
|
|
|
34
27
|
public async execute(context: AvmContext): Promise<void> {
|
|
35
28
|
if (context.environment.isStaticCall) {
|
|
@@ -43,7 +36,7 @@ export class SStore extends BaseStorageInstruction {
|
|
|
43
36
|
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
44
37
|
);
|
|
45
38
|
|
|
46
|
-
const operands = [this.
|
|
39
|
+
const operands = [this.srcOffset, this.slotOffset];
|
|
47
40
|
const [srcOffset, slotOffset] = addressing.resolve(operands, memory);
|
|
48
41
|
// We read before tag checking since it's needed for gas cost calculation
|
|
49
42
|
const slot = memory.get(slotOffset).toFr();
|
|
@@ -60,12 +53,25 @@ export class SStore extends BaseStorageInstruction {
|
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
55
|
|
|
63
|
-
export class SLoad extends
|
|
56
|
+
export class SLoad extends Instruction {
|
|
64
57
|
static readonly type: string = 'SLOAD';
|
|
65
58
|
static readonly opcode = Opcode.SLOAD;
|
|
59
|
+
// Informs (de)serialization. See Instruction.deserialize.
|
|
60
|
+
public static readonly wireFormat: OperandType[] = [
|
|
61
|
+
OperandType.UINT8,
|
|
62
|
+
OperandType.UINT8,
|
|
63
|
+
OperandType.UINT16,
|
|
64
|
+
OperandType.UINT16,
|
|
65
|
+
OperandType.UINT16,
|
|
66
|
+
];
|
|
66
67
|
|
|
67
|
-
constructor(
|
|
68
|
-
|
|
68
|
+
constructor(
|
|
69
|
+
private addressingMode: number,
|
|
70
|
+
private slotOffset: number,
|
|
71
|
+
private contractAddressOffset: number,
|
|
72
|
+
private dstOffset: number,
|
|
73
|
+
) {
|
|
74
|
+
super();
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
public async execute(context: AvmContext): Promise<void> {
|
|
@@ -76,12 +82,14 @@ export class SLoad extends BaseStorageInstruction {
|
|
|
76
82
|
this.baseGasCost(addressing.indirectOperandsCount(), addressing.relativeOperandsCount()),
|
|
77
83
|
);
|
|
78
84
|
|
|
79
|
-
const operands = [this.
|
|
80
|
-
const [slotOffset, dstOffset] = addressing.resolve(operands, memory);
|
|
85
|
+
const operands = [this.slotOffset, this.contractAddressOffset, this.dstOffset];
|
|
86
|
+
const [slotOffset, contractAddressOffset, dstOffset] = addressing.resolve(operands, memory);
|
|
81
87
|
memory.checkTag(TypeTag.FIELD, slotOffset);
|
|
88
|
+
memory.checkTag(TypeTag.FIELD, contractAddressOffset);
|
|
82
89
|
|
|
83
90
|
const slot = memory.get(slotOffset).toFr();
|
|
84
|
-
const
|
|
91
|
+
const contractAddress = memory.get(contractAddressOffset).toAztecAddress();
|
|
92
|
+
const value = await context.persistableState.readStorage(contractAddress, slot);
|
|
85
93
|
memory.set(dstOffset, new Field(value));
|
|
86
94
|
}
|
|
87
95
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
1
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
3
|
|
|
4
|
+
import type { CallData } from './avm/calldata.js';
|
|
5
5
|
import type { PublicContractsDBInterface } from './db_interfaces.js';
|
|
6
6
|
|
|
7
7
|
export async function getPublicFunctionDebugName(
|
|
8
8
|
db: PublicContractsDBInterface,
|
|
9
9
|
contractAddress: AztecAddress,
|
|
10
|
-
calldata:
|
|
10
|
+
calldata: CallData,
|
|
11
11
|
): Promise<string> {
|
|
12
12
|
// Public function is dispatched and therefore the target function is passed in the first argument.
|
|
13
|
-
|
|
13
|
+
const selectorField = calldata.read(0);
|
|
14
|
+
if (!selectorField) {
|
|
14
15
|
return `<calldata[0] undefined> (Contract Address: ${contractAddress})`;
|
|
15
16
|
}
|
|
16
|
-
const fallbackName = `<calldata[0]:${
|
|
17
|
-
const selector = FunctionSelector.fromFieldOrUndefined(
|
|
17
|
+
const fallbackName = `<calldata[0]:${selectorField.toString()}> (Contract Address: ${contractAddress})`;
|
|
18
|
+
const selector = FunctionSelector.fromFieldOrUndefined(selectorField);
|
|
18
19
|
if (!selector) {
|
|
19
20
|
return fallbackName;
|
|
20
21
|
}
|
|
@@ -32,13 +33,14 @@ export async function getPublicFunctionDebugName(
|
|
|
32
33
|
export async function getPublicFunctionSelectorAndName(
|
|
33
34
|
db: PublicContractsDBInterface,
|
|
34
35
|
contractAddress: AztecAddress,
|
|
35
|
-
calldata:
|
|
36
|
+
calldata: CallData,
|
|
36
37
|
): Promise<{ functionSelector?: FunctionSelector; functionName?: string }> {
|
|
37
38
|
// Public function is dispatched and therefore the target function is passed in the first argument.
|
|
38
|
-
|
|
39
|
+
const selectorField = calldata.read(0);
|
|
40
|
+
if (!selectorField) {
|
|
39
41
|
return {};
|
|
40
42
|
}
|
|
41
|
-
const selector = FunctionSelector.fromFieldOrUndefined(
|
|
43
|
+
const selector = FunctionSelector.fromFieldOrUndefined(selectorField);
|
|
42
44
|
if (!selector) {
|
|
43
45
|
return {};
|
|
44
46
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type TelemetryClient,
|
|
8
8
|
type Tracer,
|
|
9
9
|
type UpDownCounter,
|
|
10
|
+
createUpDownCounterWithDefault,
|
|
10
11
|
} from '@aztec/telemetry-client';
|
|
11
12
|
|
|
12
13
|
import type { ExecutorMetricsInterface } from './executor_metrics_interface.js';
|
|
@@ -25,7 +26,9 @@ export class ExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
25
26
|
this.tracer = client.getTracer(name);
|
|
26
27
|
const meter = client.getMeter(name);
|
|
27
28
|
|
|
28
|
-
this.fnCount = meter
|
|
29
|
+
this.fnCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_EXECUTOR_SIMULATION_COUNT, {
|
|
30
|
+
[Attributes.OK]: [true, false],
|
|
31
|
+
});
|
|
29
32
|
|
|
30
33
|
this.fnDuration = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_SIMULATION_DURATION);
|
|
31
34
|
|
|
@@ -164,7 +164,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
164
164
|
import type { Bufferable } from '@aztec/foundation/serialize';
|
|
165
165
|
import { type CallStackMetadata, PublicDataWrite, type PublicTxResult } from '@aztec/stdlib/avm';
|
|
166
166
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
167
|
-
import { computePublicDataTreeLeafSlot
|
|
167
|
+
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
168
168
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
169
169
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
170
170
|
|
|
@@ -295,9 +295,8 @@ export interface SpamConfigsForOpcode {
|
|
|
295
295
|
export const WARM_NOTE_HASH = new Fr(0xdeadbeefn);
|
|
296
296
|
export const WARM_L1_TO_L2_MSG = new Fr(0xcafebabedeadbeefn);
|
|
297
297
|
|
|
298
|
-
/** Warm nullifier
|
|
299
|
-
export const
|
|
300
|
-
export const WARM_NULLIFIER_ADDRESS = AztecAddress.fromNumber(0xbeef);
|
|
298
|
+
/** Warm nullifier constant - a pre-siloed nullifier value inserted directly into the tree */
|
|
299
|
+
export const WARM_SILOED_NULLIFIER = new Fr(0xdeadbeef0001n);
|
|
301
300
|
|
|
302
301
|
/** Warm storage constants - storage is inserted for the deployed contract's address */
|
|
303
302
|
export const WARM_STORAGE_SLOT = new Fr(0xdeadbeef0002n);
|
|
@@ -331,9 +330,8 @@ export async function insertWarmTreeEntries(
|
|
|
331
330
|
// Insert into L1 to L2 message tree
|
|
332
331
|
await merkleTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [WARM_L1_TO_L2_MSG]);
|
|
333
332
|
|
|
334
|
-
// Insert siloed nullifier into nullifier tree
|
|
335
|
-
|
|
336
|
-
await merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()]);
|
|
333
|
+
// Insert siloed nullifier into nullifier tree (already siloed - used directly by NULLIFIEREXISTS)
|
|
334
|
+
await merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [WARM_SILOED_NULLIFIER.toBuffer()]);
|
|
337
335
|
|
|
338
336
|
// Insert storage value into public data tree
|
|
339
337
|
const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, WARM_STORAGE_SLOT);
|
|
@@ -966,34 +964,63 @@ export const SPAM_CONFIGS: Partial<Record<Opcode, SpamConfig[]>> = {
|
|
|
966
964
|
[Opcode.SLOAD]: [
|
|
967
965
|
{
|
|
968
966
|
label: 'Cold read (slot not written)',
|
|
969
|
-
setup: [
|
|
970
|
-
|
|
967
|
+
setup: [
|
|
968
|
+
{ offset: 0, value: new Field(Fr.random()) }, // random slot
|
|
969
|
+
() => [
|
|
970
|
+
// Get current contract address into offset 1
|
|
971
|
+
new GetEnvVar(/*addressing_mode=*/ 0, /*dstOffset=*/ 1, /*varEnum=*/ 0).as(
|
|
972
|
+
Opcode.GETENVVAR_16,
|
|
973
|
+
GetEnvVar.wireFormat16,
|
|
974
|
+
),
|
|
975
|
+
],
|
|
976
|
+
],
|
|
977
|
+
targetInstructions: () => [
|
|
978
|
+
new SLoad(/*addressing_mode=*/ 0, /*slotOffset=*/ 0, /*contractAddressOffset=*/ 1, /*dstOffset=*/ 2),
|
|
979
|
+
],
|
|
971
980
|
},
|
|
972
981
|
{
|
|
973
982
|
label: 'Warm read (from tree)',
|
|
974
983
|
// Uses pre-inserted storage from insertWarmTreeEntries() which is called after contract deployment
|
|
975
|
-
setup: [
|
|
976
|
-
|
|
984
|
+
setup: [
|
|
985
|
+
{ offset: 0, value: new Field(WARM_STORAGE_SLOT) }, // pre-inserted slot
|
|
986
|
+
() => [
|
|
987
|
+
// Get current contract address into offset 1
|
|
988
|
+
new GetEnvVar(/*addressing_mode=*/ 0, /*dstOffset=*/ 1, /*varEnum=*/ 0).as(
|
|
989
|
+
Opcode.GETENVVAR_16,
|
|
990
|
+
GetEnvVar.wireFormat16,
|
|
991
|
+
),
|
|
992
|
+
],
|
|
993
|
+
],
|
|
994
|
+
targetInstructions: () => [
|
|
995
|
+
new SLoad(/*addressing_mode=*/ 0, /*slotOffset=*/ 0, /*contractAddressOffset=*/ 1, /*dstOffset=*/ 2),
|
|
996
|
+
],
|
|
977
997
|
},
|
|
978
998
|
{
|
|
979
999
|
label: 'Warm read (SSTORE first, unique slot per SLOAD)',
|
|
980
|
-
// Memory layout: slot (incremented), value, constant 1, revertSize, loaded value
|
|
1000
|
+
// Memory layout: slot (incremented), value, constant 1, contract address (from GETENVVAR), revertSize, loaded value
|
|
981
1001
|
setup: [
|
|
982
1002
|
{ offset: 0, value: new Field(Fr.random()) }, // slot (will be incremented)
|
|
983
1003
|
{ offset: 1, value: new Field(Fr.random()) }, // value to store
|
|
984
1004
|
{ offset: 2, value: new Field(1n) }, // constant 1 for ADD
|
|
985
|
-
|
|
1005
|
+
() => [
|
|
1006
|
+
// Get current contract address into offset 3
|
|
1007
|
+
new GetEnvVar(/*addressing_mode=*/ 0, /*dstOffset=*/ 3, /*varEnum=*/ 0).as(
|
|
1008
|
+
Opcode.GETENVVAR_16,
|
|
1009
|
+
GetEnvVar.wireFormat16,
|
|
1010
|
+
),
|
|
1011
|
+
],
|
|
1012
|
+
{ offset: 4, value: new Uint32(0n) }, // revertSize
|
|
986
1013
|
],
|
|
987
1014
|
targetInstructions: () => [
|
|
988
1015
|
new SStore(/*addressing_mode=*/ 0, /*srcOffset=*/ 1, /*slotOffset=*/ 0),
|
|
989
|
-
new SLoad(/*addressing_mode=*/ 0, /*slotOffset=*/ 0, /*dstOffset=*/
|
|
1016
|
+
new SLoad(/*addressing_mode=*/ 0, /*slotOffset=*/ 0, /*contractAddressOffset=*/ 3, /*dstOffset=*/ 5),
|
|
990
1017
|
new Add(/*addressing_mode=*/ 0, /*aOffset=*/ 0, /*bOffset=*/ 2, /*dstOffset=*/ 0).as(
|
|
991
1018
|
Opcode.ADD_8,
|
|
992
1019
|
Add.wireFormat8,
|
|
993
1020
|
), // slot++
|
|
994
1021
|
],
|
|
995
1022
|
cleanupInstructions: () => [
|
|
996
|
-
new Revert(/*addressing_mode=*/ 0, /*retSizeOffset=*/
|
|
1023
|
+
new Revert(/*addressing_mode=*/ 0, /*retSizeOffset=*/ 4, /*returnOffset=*/ 0).as(
|
|
997
1024
|
Opcode.REVERT_8,
|
|
998
1025
|
Revert.wireFormat8,
|
|
999
1026
|
),
|
|
@@ -1031,55 +1058,24 @@ export const SPAM_CONFIGS: Partial<Record<Opcode, SpamConfig[]>> = {
|
|
|
1031
1058
|
[Opcode.NULLIFIEREXISTS]: [
|
|
1032
1059
|
{
|
|
1033
1060
|
label: 'Non-existent nullifier',
|
|
1061
|
+
// NULLIFIEREXISTS now takes a siloed nullifier directly (no address parameter)
|
|
1034
1062
|
setup: [
|
|
1035
|
-
{ offset: 0, value: new Field(Fr.random()) }, // random nullifier
|
|
1036
|
-
{ offset: 1, value: new Field(Fr.random()) }, // random address
|
|
1063
|
+
{ offset: 0, value: new Field(Fr.random()) }, // random siloed nullifier (won't exist)
|
|
1037
1064
|
],
|
|
1038
1065
|
targetInstructions: () => [
|
|
1039
|
-
new NullifierExists(/*addressing_mode=*/ 0, /*
|
|
1066
|
+
new NullifierExists(/*addressing_mode=*/ 0, /*siloedNullifierOffset=*/ 0, /*existsOffset=*/ 1),
|
|
1040
1067
|
],
|
|
1041
1068
|
},
|
|
1042
1069
|
{
|
|
1043
1070
|
label: 'Existing nullifier (warm - from tree)',
|
|
1044
|
-
// Uses pre-inserted nullifier from insertWarmTreeEntries()
|
|
1071
|
+
// Uses pre-inserted siloed nullifier from insertWarmTreeEntries()
|
|
1072
|
+
// NULLIFIEREXISTS now takes a siloed nullifier directly
|
|
1045
1073
|
setup: [
|
|
1046
|
-
{ offset: 0, value: new Field(
|
|
1047
|
-
{ offset: 1, value: new Field(WARM_NULLIFIER_ADDRESS.toField()) }, // address it was siloed with
|
|
1074
|
+
{ offset: 0, value: new Field(WARM_SILOED_NULLIFIER) }, // pre-inserted siloed nullifier
|
|
1048
1075
|
],
|
|
1049
1076
|
targetInstructions: () => [
|
|
1050
|
-
new NullifierExists(/*addressing_mode=*/ 0, /*
|
|
1051
|
-
],
|
|
1052
|
-
},
|
|
1053
|
-
{
|
|
1054
|
-
label: 'Existing nullifier (warm - EMITNULLIFIER first)',
|
|
1055
|
-
// Memory layout: nullifier (incremented), constant 1, current address (from GETENVVAR), revertSize, exists result
|
|
1056
|
-
setup: [
|
|
1057
|
-
{ offset: 0, value: new Field(Fr.random()) }, // nullifier (will be incremented)
|
|
1058
|
-
{ offset: 1, value: new Field(1n) }, // constant 1 for ADD
|
|
1059
|
-
() => [
|
|
1060
|
-
// Get current contract address into offset 2
|
|
1061
|
-
new GetEnvVar(/*addressing_mode=*/ 0, /*dstOffset=*/ 2, /*varEnum=*/ 0).as(
|
|
1062
|
-
Opcode.GETENVVAR_16,
|
|
1063
|
-
GetEnvVar.wireFormat16,
|
|
1064
|
-
),
|
|
1065
|
-
],
|
|
1066
|
-
{ offset: 3, value: new Uint32(0n) }, // revertSize
|
|
1067
|
-
],
|
|
1068
|
-
targetInstructions: () => [
|
|
1069
|
-
new EmitNullifier(/*addressing_mode=*/ 0, /*nullifierOffset=*/ 0),
|
|
1070
|
-
new NullifierExists(/*addressing_mode=*/ 0, /*nullifierOffset=*/ 0, /*addressOffset=*/ 2, /*existsOffset=*/ 4),
|
|
1071
|
-
new Add(/*addressing_mode=*/ 0, /*aOffset=*/ 0, /*bOffset=*/ 1, /*dstOffset=*/ 0).as(
|
|
1072
|
-
Opcode.ADD_8,
|
|
1073
|
-
Add.wireFormat8,
|
|
1074
|
-
), // nullifier++
|
|
1075
|
-
],
|
|
1076
|
-
cleanupInstructions: () => [
|
|
1077
|
-
new Revert(/*addressing_mode=*/ 0, /*retSizeOffset=*/ 3, /*returnOffset=*/ 0).as(
|
|
1078
|
-
Opcode.REVERT_8,
|
|
1079
|
-
Revert.wireFormat8,
|
|
1080
|
-
),
|
|
1077
|
+
new NullifierExists(/*addressing_mode=*/ 0, /*siloedNullifierOffset=*/ 0, /*existsOffset=*/ 1),
|
|
1081
1078
|
],
|
|
1082
|
-
limit: MAX_NULLIFIERS_PER_TX - 1,
|
|
1083
1079
|
},
|
|
1084
1080
|
],
|
|
1085
1081
|
|
|
@@ -3,6 +3,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
3
3
|
import {
|
|
4
4
|
AvmCircuitPublicInputs,
|
|
5
5
|
type AvmTxHint,
|
|
6
|
+
PublicTxEffect,
|
|
6
7
|
deserializeFromMessagePack,
|
|
7
8
|
serializeWithMessagePack,
|
|
8
9
|
} from '@aztec/stdlib/avm';
|
|
@@ -58,7 +59,13 @@ async function simulateWithFuzzer(
|
|
|
58
59
|
rawPublicDataWrites: any[], // Public data tree writes to apply before simulation
|
|
59
60
|
rawNoteHashes: any[], // Note hashes to apply before simulation
|
|
60
61
|
protocolContracts: ProtocolContracts, // Protocol contracts mapping from C++
|
|
61
|
-
): Promise<{
|
|
62
|
+
): Promise<{
|
|
63
|
+
reverted: boolean;
|
|
64
|
+
output: Fr[];
|
|
65
|
+
revertReason?: string;
|
|
66
|
+
publicInputs: AvmCircuitPublicInputs;
|
|
67
|
+
publicTxEffect: PublicTxEffect;
|
|
68
|
+
}> {
|
|
62
69
|
const worldStateService = await openExistingWorldState(dataDir, mapSizeKb);
|
|
63
70
|
|
|
64
71
|
const simulator = await AvmFuzzerSimulator.create(worldStateService, globals, protocolContracts);
|
|
@@ -90,6 +97,7 @@ async function simulateWithFuzzer(
|
|
|
90
97
|
output,
|
|
91
98
|
revertReason: result.findRevertReason()?.message,
|
|
92
99
|
publicInputs: result.publicInputs!,
|
|
100
|
+
publicTxEffect: result.publicTxEffect,
|
|
93
101
|
};
|
|
94
102
|
}
|
|
95
103
|
|
|
@@ -119,6 +127,7 @@ async function execute(base64Line: string): Promise<void> {
|
|
|
119
127
|
output: result.output,
|
|
120
128
|
revertReason: result.revertReason ?? '',
|
|
121
129
|
endTreeSnapshots: result.publicInputs.endTreeSnapshots,
|
|
130
|
+
publicTxEffect: result.publicTxEffect,
|
|
122
131
|
});
|
|
123
132
|
const base64Response = resultBuffer.toString('base64') + '\n';
|
|
124
133
|
await writeOutput(base64Response);
|
|
@@ -129,6 +138,7 @@ async function execute(base64Line: string): Promise<void> {
|
|
|
129
138
|
output: [] as Fr[],
|
|
130
139
|
revertReason: `Unexpected Error ${error.message}`,
|
|
131
140
|
endTreeSnapshots: TreeSnapshots.empty(),
|
|
141
|
+
publicTxEffect: PublicTxEffect.empty(),
|
|
132
142
|
});
|
|
133
143
|
await writeOutput(errorResult.toString('base64') + '\n');
|
|
134
144
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
PUBLIC_DATA_SUBTREE_HEIGHT,
|
|
6
6
|
} from '@aztec/constants';
|
|
7
7
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
8
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
9
9
|
import { Timer } from '@aztec/foundation/timer';
|
|
10
10
|
import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
11
11
|
import { ContractInstancePublishedEvent } from '@aztec/protocol-contracts/instance-registry';
|
|
@@ -46,9 +46,14 @@ import { L1ToL2MessageIndexOutOfRangeError, NoteHashIndexOutOfRangeError } from
|
|
|
46
46
|
export class PublicContractsDB implements PublicContractsDBInterface {
|
|
47
47
|
private contractStateStack: ContractsDbCheckpoint[] = [new ContractsDbCheckpoint()];
|
|
48
48
|
|
|
49
|
-
private log
|
|
49
|
+
private log: Logger;
|
|
50
50
|
|
|
51
|
-
constructor(
|
|
51
|
+
constructor(
|
|
52
|
+
private dataSource: ContractDataSource,
|
|
53
|
+
bindings?: LoggerBindings,
|
|
54
|
+
) {
|
|
55
|
+
this.log = createLogger('simulator:contracts-data-source', bindings);
|
|
56
|
+
}
|
|
52
57
|
|
|
53
58
|
public async addContracts(contractDeploymentData: ContractDeploymentData): Promise<void> {
|
|
54
59
|
const currentState = this.getCurrentState();
|
|
@@ -208,9 +213,14 @@ export class PublicContractsDB implements PublicContractsDBInterface {
|
|
|
208
213
|
* to decide whether to use hints or not (same with tracing, etc).
|
|
209
214
|
*/
|
|
210
215
|
export class PublicTreesDB implements PublicStateDBInterface {
|
|
211
|
-
private logger
|
|
216
|
+
private logger: Logger;
|
|
212
217
|
|
|
213
|
-
constructor(
|
|
218
|
+
constructor(
|
|
219
|
+
private readonly db: MerkleTreeWriteOperations,
|
|
220
|
+
bindings?: LoggerBindings,
|
|
221
|
+
) {
|
|
222
|
+
this.logger = createLogger('simulator:public-trees-db', bindings);
|
|
223
|
+
}
|
|
214
224
|
|
|
215
225
|
public async storageRead(contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
216
226
|
const timer = new Timer();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { sleep } from '@aztec/foundation/sleep';
|
|
6
6
|
import { DateProvider, Timer, elapsed, executeTimeout } from '@aztec/foundation/timer';
|
|
7
7
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
@@ -62,11 +62,15 @@ import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
|
62
62
|
* Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
|
|
63
63
|
*/
|
|
64
64
|
export class PublicProcessorFactory {
|
|
65
|
+
private log: Logger;
|
|
65
66
|
constructor(
|
|
66
67
|
private contractDataSource: ContractDataSource,
|
|
67
68
|
private dateProvider: DateProvider = new DateProvider(),
|
|
68
69
|
protected telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
69
|
-
|
|
70
|
+
bindings?: LoggerBindings,
|
|
71
|
+
) {
|
|
72
|
+
this.log = createLogger('simulator:public-processor-factory', bindings);
|
|
73
|
+
}
|
|
70
74
|
|
|
71
75
|
/**
|
|
72
76
|
* Creates a new instance of a PublicProcessor.
|
|
@@ -79,7 +83,8 @@ export class PublicProcessorFactory {
|
|
|
79
83
|
globalVariables: GlobalVariables,
|
|
80
84
|
config: PublicSimulatorConfig,
|
|
81
85
|
): PublicProcessor {
|
|
82
|
-
const
|
|
86
|
+
const bindings = this.log.getBindings();
|
|
87
|
+
const contractsDB = new PublicContractsDB(this.contractDataSource, bindings);
|
|
83
88
|
|
|
84
89
|
const guardedFork = new GuardedMerkleTreeOperations(merkleTree);
|
|
85
90
|
const publicTxSimulator = this.createPublicTxSimulator(guardedFork, contractsDB, globalVariables, config);
|
|
@@ -91,6 +96,7 @@ export class PublicProcessorFactory {
|
|
|
91
96
|
publicTxSimulator,
|
|
92
97
|
this.dateProvider,
|
|
93
98
|
this.telemetryClient,
|
|
99
|
+
createLogger('simulator:public-processor', bindings),
|
|
94
100
|
);
|
|
95
101
|
}
|
|
96
102
|
|
|
@@ -100,7 +106,14 @@ export class PublicProcessorFactory {
|
|
|
100
106
|
globalVariables: GlobalVariables,
|
|
101
107
|
config?: Partial<PublicTxSimulatorConfig>,
|
|
102
108
|
): PublicTxSimulatorInterface {
|
|
103
|
-
return new TelemetryCppPublicTxSimulator(
|
|
109
|
+
return new TelemetryCppPublicTxSimulator(
|
|
110
|
+
merkleTree,
|
|
111
|
+
contractsDB,
|
|
112
|
+
globalVariables,
|
|
113
|
+
this.telemetryClient,
|
|
114
|
+
config,
|
|
115
|
+
this.log.getBindings(),
|
|
116
|
+
);
|
|
104
117
|
}
|
|
105
118
|
}
|
|
106
119
|
|
|
@@ -125,7 +138,7 @@ export class PublicProcessor implements Traceable {
|
|
|
125
138
|
protected publicTxSimulator: PublicTxSimulatorInterface,
|
|
126
139
|
private dateProvider: DateProvider,
|
|
127
140
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
128
|
-
private log
|
|
141
|
+
private log: Logger,
|
|
129
142
|
private opts: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs' | 'fakeThrowAfterProcessingTxCount'> = {},
|
|
130
143
|
) {
|
|
131
144
|
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
2
2
|
import type { Gas } from '@aztec/stdlib/gas';
|
|
3
|
-
import
|
|
3
|
+
import { TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
4
4
|
import {
|
|
5
5
|
Attributes,
|
|
6
6
|
type Gauge,
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type TelemetryClient,
|
|
10
10
|
type Tracer,
|
|
11
11
|
type UpDownCounter,
|
|
12
|
+
createUpDownCounterWithDefault,
|
|
12
13
|
} from '@aztec/telemetry-client';
|
|
13
14
|
|
|
14
15
|
export class PublicProcessorMetrics {
|
|
@@ -35,13 +36,18 @@ export class PublicProcessorMetrics {
|
|
|
35
36
|
|
|
36
37
|
this.txDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_DURATION);
|
|
37
38
|
|
|
38
|
-
this.txCount = meter
|
|
39
|
+
this.txCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_COUNT, {
|
|
40
|
+
[Attributes.OK]: [true, false],
|
|
41
|
+
});
|
|
39
42
|
|
|
40
|
-
this.txPhaseCount = meter
|
|
43
|
+
this.txPhaseCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_PHASE_COUNT);
|
|
41
44
|
|
|
42
45
|
this.phaseDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_PHASE_DURATION);
|
|
43
46
|
|
|
44
|
-
this.phaseCount = meter
|
|
47
|
+
this.phaseCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_PHASE_COUNT, {
|
|
48
|
+
[Attributes.TX_PHASE_NAME]: [TxExecutionPhase.SETUP, TxExecutionPhase.APP_LOGIC, TxExecutionPhase.TEARDOWN],
|
|
49
|
+
[Attributes.OK]: [true, false],
|
|
50
|
+
});
|
|
45
51
|
|
|
46
52
|
this.bytecodeDeployed = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_DEPLOY_BYTECODE_SIZE);
|
|
47
53
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { ContractProvider } from '@aztec/native';
|
|
4
4
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
5
|
import { deserializeFromMessagePack, serializeWithMessagePack } from '@aztec/stdlib/avm';
|
|
@@ -10,12 +10,15 @@ import type { GlobalVariables } from '@aztec/stdlib/tx';
|
|
|
10
10
|
import type { PublicContractsDB } from '../public_db_sources.js';
|
|
11
11
|
|
|
12
12
|
export class ContractProviderForCpp implements ContractProvider {
|
|
13
|
-
private log: Logger
|
|
13
|
+
private log: Logger;
|
|
14
14
|
|
|
15
15
|
constructor(
|
|
16
16
|
private contractsDB: PublicContractsDB,
|
|
17
17
|
private globalVariables: GlobalVariables,
|
|
18
|
-
|
|
18
|
+
bindings?: LoggerBindings,
|
|
19
|
+
) {
|
|
20
|
+
this.log = createLogger('simulator:contract_provider_for_cpp', bindings);
|
|
21
|
+
}
|
|
19
22
|
|
|
20
23
|
public getContractInstance = async (address: string): Promise<Buffer | undefined> => {
|
|
21
24
|
this.log.trace(`Contract provider callback: getContractInstance(${address})`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Logger, createLogger, logLevel } from '@aztec/foundation/log';
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger, logLevel } from '@aztec/foundation/log';
|
|
2
2
|
import { sleep } from '@aztec/foundation/sleep';
|
|
3
3
|
import { type CancellationToken, avmSimulate, cancelSimulation, createCancellationToken } from '@aztec/native';
|
|
4
4
|
import { ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
@@ -44,9 +44,10 @@ export class CppPublicTxSimulator extends PublicTxSimulator implements PublicTxS
|
|
|
44
44
|
contractsDB: PublicContractsDB,
|
|
45
45
|
globalVariables: GlobalVariables,
|
|
46
46
|
config?: Partial<PublicSimulatorConfig>,
|
|
47
|
+
bindings?: LoggerBindings,
|
|
47
48
|
) {
|
|
48
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
49
|
-
this.log = createLogger(`simulator:cpp_public_tx_simulator
|
|
49
|
+
super(merkleTree, contractsDB, globalVariables, config, undefined, bindings);
|
|
50
|
+
this.log = createLogger(`simulator:cpp_public_tx_simulator`, bindings);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
/**
|
|
@@ -84,7 +85,7 @@ export class CppPublicTxSimulator extends PublicTxSimulator implements PublicTxS
|
|
|
84
85
|
);
|
|
85
86
|
|
|
86
87
|
// Create contract provider for callbacks to TypeScript PublicContractsDB from C++
|
|
87
|
-
const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables);
|
|
88
|
+
const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables, this.bindings);
|
|
88
89
|
|
|
89
90
|
// Serialize to msgpack and call the C++ simulator
|
|
90
91
|
this.log.trace(`Serializing fast simulation inputs to msgpack...`);
|
|
@@ -171,8 +172,9 @@ export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator implement
|
|
|
171
172
|
globalVariables: GlobalVariables,
|
|
172
173
|
protected readonly metrics: ExecutorMetricsInterface,
|
|
173
174
|
config?: Partial<PublicSimulatorConfig>,
|
|
175
|
+
bindings?: LoggerBindings,
|
|
174
176
|
) {
|
|
175
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
177
|
+
super(merkleTree, contractsDB, globalVariables, config, bindings);
|
|
176
178
|
}
|
|
177
179
|
|
|
178
180
|
public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
|
|
@@ -200,9 +202,10 @@ export class TelemetryCppPublicTxSimulator extends MeasuredCppPublicTxSimulator
|
|
|
200
202
|
globalVariables: GlobalVariables,
|
|
201
203
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
202
204
|
config?: Partial<PublicSimulatorConfig>,
|
|
205
|
+
bindings?: LoggerBindings,
|
|
203
206
|
) {
|
|
204
207
|
const metrics = new ExecutorMetrics(telemetryClient, 'CppPublicTxSimulator');
|
|
205
|
-
super(merkleTree, contractsDB, globalVariables, metrics, config);
|
|
208
|
+
super(merkleTree, contractsDB, globalVariables, metrics, config, bindings);
|
|
206
209
|
this.tracer = metrics.tracer;
|
|
207
210
|
}
|
|
208
211
|
}
|