@aztec/simulator 0.87.2 → 0.87.3-nightly.20250529
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/client.d.ts +2 -0
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +2 -0
- package/dest/private/acvm/acvm.d.ts +4 -0
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/oracle/oracle.d.ts +2 -2
- package/dest/private/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/oracle.js +6 -6
- package/dest/private/acvm/oracle/typed_oracle.d.ts +3 -3
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/typed_oracle.js +4 -4
- package/dest/private/execution_data_provider.d.ts +9 -6
- package/dest/private/execution_data_provider.d.ts.map +1 -1
- package/dest/private/private_execution.d.ts.map +1 -1
- package/dest/private/private_execution.js +2 -1
- package/dest/private/private_execution_oracle.d.ts +1 -1
- package/dest/private/private_execution_oracle.d.ts.map +1 -1
- package/dest/private/private_execution_oracle.js +1 -1
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts +39 -19
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/providers/circuit_recording/circuit_recorder.js +90 -126
- package/dest/private/providers/circuit_recording/file_circuit_recorder.d.ts +31 -0
- package/dest/private/providers/circuit_recording/file_circuit_recorder.d.ts.map +1 -0
- package/dest/private/providers/circuit_recording/file_circuit_recorder.js +135 -0
- package/dest/private/providers/circuit_recording/memory_circuit_recorder.d.ts +5 -0
- package/dest/private/providers/circuit_recording/memory_circuit_recorder.d.ts.map +1 -0
- package/dest/private/providers/circuit_recording/memory_circuit_recorder.js +9 -0
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts +3 -1
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts.map +1 -1
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.js +16 -11
- package/dest/private/utility_execution_oracle.d.ts +3 -3
- package/dest/private/utility_execution_oracle.d.ts.map +1 -1
- package/dest/private/utility_execution_oracle.js +3 -3
- package/dest/public/avm/avm_gas.d.ts +4 -5
- package/dest/public/avm/avm_gas.d.ts.map +1 -1
- package/dest/public/avm/avm_gas.js +29 -19
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +1 -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 +6 -0
- package/dest/public/avm/fixtures/utils.js +1 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +8 -7
- package/dest/public/avm/opcodes/addressing_mode.d.ts +2 -0
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -1
- package/dest/public/avm/opcodes/addressing_mode.js +6 -0
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/public/avm/opcodes/arithmetic.js +1 -1
- package/dest/public/avm/opcodes/bitwise.d.ts +5 -1
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/public/avm/opcodes/bitwise.js +17 -2
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.js +1 -1
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +1 -1
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.js +4 -4
- package/dest/public/avm/opcodes/conversion.d.ts +1 -0
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +263 -2
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +1 -1
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +1 -1
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +6 -8
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +3 -3
- package/dest/public/avm/opcodes/instruction.d.ts +9 -3
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction.js +12 -7
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +8 -6
- package/dest/public/avm/opcodes/misc.js +1 -3
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/public/avm/opcodes/storage.js +5 -3
- package/dest/public/fixtures/index.d.ts +1 -0
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +1 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts +9 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -0
- package/dest/public/fixtures/minimal_public_tx.js +43 -0
- package/dest/public/fixtures/utils.js +3 -3
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +2 -2
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +3 -4
- package/dest/public/public_tx_simulator/apps_tests/amm_test.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/apps_tests/amm_test.js +27 -55
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +5 -4
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +0 -3
- package/dest/public/side_effect_trace.d.ts +4 -1
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +13 -2
- package/dest/public/side_effect_trace_interface.d.ts +1 -0
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.d.ts +1 -0
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +3 -0
- package/dest/server.d.ts +2 -0
- package/dest/server.d.ts.map +1 -1
- package/dest/server.js +2 -0
- package/dest/testing.d.ts +1 -1
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +1 -1
- package/package.json +15 -15
- package/src/client.ts +2 -0
- package/src/private/acvm/acvm.ts +3 -0
- package/src/private/acvm/oracle/oracle.ts +6 -6
- package/src/private/acvm/oracle/typed_oracle.ts +5 -5
- package/src/private/execution_data_provider.ts +9 -6
- package/src/private/private_execution.ts +1 -0
- package/src/private/private_execution_oracle.ts +1 -1
- package/src/private/providers/circuit_recording/circuit_recorder.ts +114 -136
- package/src/private/providers/circuit_recording/file_circuit_recorder.ts +158 -0
- package/src/private/providers/circuit_recording/memory_circuit_recorder.ts +11 -0
- package/src/private/providers/circuit_recording/simulation_provider_recorder_wrapper.ts +22 -14
- package/src/private/utility_execution_oracle.ts +4 -4
- package/src/public/avm/avm_gas.ts +21 -15
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +5 -0
- package/src/public/avm/fixtures/utils.ts +1 -1
- package/src/public/avm/opcodes/accrued_substate.ts +23 -7
- package/src/public/avm/opcodes/addressing_mode.ts +8 -0
- package/src/public/avm/opcodes/arithmetic.ts +3 -1
- package/src/public/avm/opcodes/bitwise.ts +26 -2
- package/src/public/avm/opcodes/comparators.ts +3 -1
- package/src/public/avm/opcodes/contract.ts +3 -1
- package/src/public/avm/opcodes/control_flow.ts +6 -4
- package/src/public/avm/opcodes/conversion.ts +21 -2
- package/src/public/avm/opcodes/ec_add.ts +3 -1
- package/src/public/avm/opcodes/environment_getters.ts +3 -1
- package/src/public/avm/opcodes/external_calls.ts +16 -8
- package/src/public/avm/opcodes/hashing.ts +11 -3
- package/src/public/avm/opcodes/instruction.ts +14 -7
- package/src/public/avm/opcodes/memory.ts +23 -6
- package/src/public/avm/opcodes/misc.ts +4 -4
- package/src/public/avm/opcodes/storage.ts +13 -3
- package/src/public/fixtures/index.ts +1 -0
- package/src/public/fixtures/minimal_public_tx.ts +57 -0
- package/src/public/fixtures/utils.ts +3 -3
- package/src/public/public_db_sources.ts +3 -13
- package/src/public/public_processor/public_processor.ts +6 -12
- package/src/public/public_tx_simulator/apps_tests/amm_test.ts +49 -44
- package/src/public/public_tx_simulator/public_tx_context.ts +26 -5
- package/src/public/public_tx_simulator/public_tx_simulator.ts +0 -3
- package/src/public/side_effect_trace.ts +13 -0
- package/src/public/side_effect_trace_interface.ts +1 -0
- package/src/public/state_manager/state_manager.ts +4 -0
- package/src/server.ts +2 -0
- package/src/testing.ts +1 -1
|
@@ -1,22 +1,38 @@
|
|
|
1
|
+
import { sha512 } from '@aztec/foundation/crypto';
|
|
1
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import {
|
|
3
|
-
import fs from 'fs/promises';
|
|
4
|
-
import path from 'path';
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
5
4
|
import { Oracle } from '../../acvm/oracle/oracle.js';
|
|
5
|
+
export class CircuitRecording {
|
|
6
|
+
circuitName;
|
|
7
|
+
functionName;
|
|
8
|
+
bytecodeSHA512Hash;
|
|
9
|
+
timestamp;
|
|
10
|
+
inputs;
|
|
11
|
+
oracleCalls;
|
|
12
|
+
error;
|
|
13
|
+
parent;
|
|
14
|
+
constructor(circuitName, functionName, bytecodeSHA512Hash, inputs){
|
|
15
|
+
this.circuitName = circuitName;
|
|
16
|
+
this.functionName = functionName;
|
|
17
|
+
this.bytecodeSHA512Hash = bytecodeSHA512Hash;
|
|
18
|
+
this.timestamp = Date.now();
|
|
19
|
+
this.inputs = inputs;
|
|
20
|
+
this.oracleCalls = [];
|
|
21
|
+
}
|
|
22
|
+
setParent(recording) {
|
|
23
|
+
this.parent = recording;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
6
26
|
/**
|
|
7
27
|
* Class responsible for recording circuit inputs necessary to replay the circuit. These inputs are the initial witness
|
|
8
28
|
* map and the oracle calls made during the circuit execution/witness generation.
|
|
9
29
|
*
|
|
10
|
-
*
|
|
11
|
-
* a counter to ensure unique filenames. The file is stored in the `recordDir` directory provided as a parameter to
|
|
12
|
-
* CircuitRecorder.start().
|
|
13
|
-
*
|
|
14
|
-
* Example recording file:
|
|
30
|
+
* Example recording object:
|
|
15
31
|
* ```json
|
|
16
32
|
* {
|
|
17
33
|
* "circuitName": "AMM",
|
|
18
34
|
* "functionName": "add_liquidity",
|
|
19
|
-
* "
|
|
35
|
+
* "bytecodeSHA512Hash": "b46c640ed38f20eac5f61a5e41d8dd1e",
|
|
20
36
|
* "timestamp": 1740691464360,
|
|
21
37
|
* "inputs": {
|
|
22
38
|
* "0": "0x1e89de1f0ad5204263733b7ddf65bec45b8f44714a4da85a46474dad677679ef",
|
|
@@ -45,21 +61,18 @@ import { Oracle } from '../../acvm/oracle/oracle.js';
|
|
|
45
61
|
* ]
|
|
46
62
|
* },
|
|
47
63
|
* {
|
|
48
|
-
* "name": "
|
|
64
|
+
* "name": "fetchTaggedLogs",
|
|
49
65
|
* "inputs": []
|
|
50
66
|
* }
|
|
51
67
|
* ]
|
|
52
68
|
* }
|
|
53
69
|
* ```
|
|
54
70
|
*/ export class CircuitRecorder {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.logger = createLogger('simulator:acvm:recording');
|
|
61
|
-
this.isFirstCall = true;
|
|
62
|
-
}
|
|
71
|
+
logger = createLogger('simulator:acvm:recording');
|
|
72
|
+
recording;
|
|
73
|
+
stackDepth = 0;
|
|
74
|
+
newCircuit = true;
|
|
75
|
+
constructor(){}
|
|
63
76
|
/**
|
|
64
77
|
* Initializes a new circuit recording session.
|
|
65
78
|
* @param recordDir - Directory to store the recording
|
|
@@ -68,62 +81,13 @@ import { Oracle } from '../../acvm/oracle/oracle.js';
|
|
|
68
81
|
* @param circuitName - Name of the circuit
|
|
69
82
|
* @param functionName - Name of the circuit function (defaults to 'main'). This is meaningful only for
|
|
70
83
|
* contracts as protocol circuits artifacts always contain a single entrypoint function called 'main'.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
functionName: functionName,
|
|
76
|
-
bytecodeMd5Hash: createHash('md5').update(circuitBytecode).digest('hex'),
|
|
77
|
-
timestamp: Date.now(),
|
|
78
|
-
inputs: Object.fromEntries(input)
|
|
79
|
-
};
|
|
80
|
-
const recordingStringWithoutClosingBracket = JSON.stringify(recording, null, 2).slice(0, -2);
|
|
81
|
-
try {
|
|
82
|
-
// Check if the recording directory exists and is a directory
|
|
83
|
-
const stats = await fs.stat(recordDir);
|
|
84
|
-
if (!stats.isDirectory()) {
|
|
85
|
-
throw new Error(`Recording path ${recordDir} exists but is not a directory`);
|
|
86
|
-
}
|
|
87
|
-
} catch (err) {
|
|
88
|
-
if (err.code === 'ENOENT') {
|
|
89
|
-
// The directory does not exist so we create it
|
|
90
|
-
await fs.mkdir(recordDir, {
|
|
91
|
-
recursive: true
|
|
92
|
-
});
|
|
93
|
-
} else {
|
|
94
|
-
throw err;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const filePath = await CircuitRecorder.#computeFilePathAndStoreInitialRecording(recordDir, circuitName, functionName, recordingStringWithoutClosingBracket);
|
|
98
|
-
return new CircuitRecorder(filePath);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Computes a unique file path for the recording by trying different counter values.
|
|
102
|
-
* This is needed because multiple recordings of the same circuit could be happening simultaneously or an older
|
|
103
|
-
* recording might be present.
|
|
104
|
-
* @param recordDir - Directory to store the recording
|
|
105
|
-
* @param circuitName - Name of the circuit
|
|
106
|
-
* @param functionName - Name of the circuit function
|
|
107
|
-
* @param recordingContent - Initial recording content
|
|
108
|
-
* @returns A unique file path for the recording
|
|
109
|
-
*/ static async #computeFilePathAndStoreInitialRecording(recordDir, circuitName, functionName, recordingContent) {
|
|
110
|
-
let counter = 0;
|
|
111
|
-
while(true){
|
|
112
|
-
try {
|
|
113
|
-
const filePath = getFilePath(recordDir, circuitName, functionName, counter);
|
|
114
|
-
// Write the initial recording content to the file
|
|
115
|
-
await fs.writeFile(filePath, recordingContent + ',\n "oracleCalls": [\n', {
|
|
116
|
-
flag: 'wx'
|
|
117
|
-
});
|
|
118
|
-
return filePath;
|
|
119
|
-
} catch (err) {
|
|
120
|
-
if (err.code === 'EEXIST') {
|
|
121
|
-
counter++;
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
throw err;
|
|
125
|
-
}
|
|
84
|
+
*/ start(input, circuitBytecode, circuitName, functionName) {
|
|
85
|
+
const parentRef = this.recording;
|
|
86
|
+
if (this.newCircuit) {
|
|
87
|
+
this.recording = new CircuitRecording(circuitName, functionName, sha512(circuitBytecode).toString('hex'), Object.fromEntries(input));
|
|
126
88
|
}
|
|
89
|
+
this.recording.setParent(parentRef);
|
|
90
|
+
return Promise.resolve();
|
|
127
91
|
}
|
|
128
92
|
/**
|
|
129
93
|
* Wraps a callback to record all oracle/foreign calls.
|
|
@@ -155,15 +119,37 @@ import { Oracle } from '../../acvm/oracle/oracle.js';
|
|
|
155
119
|
if (!fn) {
|
|
156
120
|
throw new Error(`Oracle method ${name} not found when setting up recording callback`);
|
|
157
121
|
}
|
|
122
|
+
const isExternalCall = name === 'callPrivateFunction';
|
|
158
123
|
recordingCallback[name] = (...args)=>{
|
|
124
|
+
const timer = new Timer();
|
|
125
|
+
// If we're entering another circuit via `callPrivateFunction`, we increase the stack depth and set the
|
|
126
|
+
// newCircuit variable to ensure we are creating a new recording object.
|
|
127
|
+
if (isExternalCall) {
|
|
128
|
+
this.stackDepth++;
|
|
129
|
+
this.newCircuit = true;
|
|
130
|
+
}
|
|
159
131
|
const result = fn.call(callback, ...args);
|
|
160
132
|
if (result instanceof Promise) {
|
|
161
133
|
return result.then(async (r)=>{
|
|
162
|
-
|
|
134
|
+
// Once we leave the nested circuit, we decrease the stack depth and set newCircuit to false
|
|
135
|
+
// since we are going back to the "parent" circuit which can never be new
|
|
136
|
+
if (isExternalCall) {
|
|
137
|
+
this.stackDepth--;
|
|
138
|
+
this.newCircuit = false;
|
|
139
|
+
this.recording = this.recording.parent;
|
|
140
|
+
}
|
|
141
|
+
await this.recordCall(name, args, r, timer.ms(), this.stackDepth);
|
|
163
142
|
return r;
|
|
164
143
|
});
|
|
165
144
|
}
|
|
166
|
-
|
|
145
|
+
// Once we leave the nested circuit, we decrease the stack depth and set newCircuit to false
|
|
146
|
+
// since we are going back to the "parent" circuit which can never be new
|
|
147
|
+
if (isExternalCall) {
|
|
148
|
+
this.stackDepth--;
|
|
149
|
+
this.newCircuit = false;
|
|
150
|
+
this.recording = this.recording.parent;
|
|
151
|
+
}
|
|
152
|
+
void this.recordCall(name, args, result, timer.ms(), this.stackDepth);
|
|
167
153
|
return result;
|
|
168
154
|
};
|
|
169
155
|
}
|
|
@@ -175,8 +161,9 @@ import { Oracle } from '../../acvm/oracle/oracle.js';
|
|
|
175
161
|
* @returns A wrapped handler that records all oracle interactions which is to be provided to the ACVM.
|
|
176
162
|
*/ #wrapProtocolCircuitCallback(callback) {
|
|
177
163
|
return async (name, inputs)=>{
|
|
164
|
+
const timer = new Timer();
|
|
178
165
|
const result = await callback(name, inputs);
|
|
179
|
-
await this
|
|
166
|
+
await this.recordCall(name, inputs, result, timer.ms(), 0);
|
|
180
167
|
return result;
|
|
181
168
|
};
|
|
182
169
|
}
|
|
@@ -185,62 +172,39 @@ import { Oracle } from '../../acvm/oracle/oracle.js';
|
|
|
185
172
|
* @param name - Name of the call
|
|
186
173
|
* @param inputs - Input arguments
|
|
187
174
|
* @param outputs - Output results
|
|
188
|
-
*/
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
} catch (err) {
|
|
199
|
-
this.logger.error('Failed to log circuit call', {
|
|
200
|
-
error: err
|
|
201
|
-
});
|
|
202
|
-
}
|
|
175
|
+
*/ recordCall(name, inputs, outputs, time, stackDepth) {
|
|
176
|
+
const entry = {
|
|
177
|
+
name,
|
|
178
|
+
inputs,
|
|
179
|
+
outputs,
|
|
180
|
+
time,
|
|
181
|
+
stackDepth
|
|
182
|
+
};
|
|
183
|
+
this.recording.oracleCalls.push(entry);
|
|
184
|
+
return Promise.resolve(entry);
|
|
203
185
|
}
|
|
204
186
|
/**
|
|
205
|
-
* Finalizes the recording
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
this.
|
|
212
|
-
error: err
|
|
213
|
-
});
|
|
187
|
+
* Finalizes the recording by resetting the state and returning the recording object.
|
|
188
|
+
*/ finish() {
|
|
189
|
+
const result = this.recording;
|
|
190
|
+
// If this is the top-level circuit recording, we reset the state for the next simulator call
|
|
191
|
+
if (!result.parent) {
|
|
192
|
+
this.newCircuit = true;
|
|
193
|
+
this.recording = undefined;
|
|
214
194
|
}
|
|
195
|
+
return Promise.resolve(result);
|
|
215
196
|
}
|
|
216
197
|
/**
|
|
217
|
-
* Finalizes the recording
|
|
218
|
-
* the recording file is incomplete and it fails to parse.
|
|
198
|
+
* Finalizes the recording by resetting the state and returning the recording object with an attached error.
|
|
219
199
|
* @param error - The error that occurred during circuit execution
|
|
220
|
-
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
this.logger.error('Failed to finalize recording file with error', {
|
|
227
|
-
error: err
|
|
228
|
-
});
|
|
200
|
+
*/ finishWithError(error) {
|
|
201
|
+
const result = this.recording;
|
|
202
|
+
// If this is the top-level circuit recording, we reset the state for the next simulator call
|
|
203
|
+
if (!result.parent) {
|
|
204
|
+
this.newCircuit = true;
|
|
205
|
+
this.recording = undefined;
|
|
229
206
|
}
|
|
207
|
+
result.error = JSON.stringify(error);
|
|
208
|
+
return Promise.resolve(result);
|
|
230
209
|
}
|
|
231
210
|
}
|
|
232
|
-
/**
|
|
233
|
-
* Generates a file path for storing circuit recordings. The format of the filename is:
|
|
234
|
-
* `circuit_name_circuit_function_name_YYYY-MM-DD_N.json` where N is a counter to ensure unique filenames.
|
|
235
|
-
* @param recordDir - Base directory for recordings
|
|
236
|
-
* @param circuitName - Name of the circuit
|
|
237
|
-
* @param functionName - Name of the circuit function
|
|
238
|
-
* @param counter - Counter to ensure unique filenames. This is expected to be incremented in a loop until there is no
|
|
239
|
-
* existing file with the same name.
|
|
240
|
-
* @returns A file path for the recording.
|
|
241
|
-
*/ function getFilePath(recordDir, circuitName, functionName, counter) {
|
|
242
|
-
const date = new Date();
|
|
243
|
-
const formattedDate = date.toISOString().split('T')[0];
|
|
244
|
-
const filename = `${circuitName}_${functionName}_${formattedDate}_${counter}.json`;
|
|
245
|
-
return path.join(recordDir, filename);
|
|
246
|
-
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ACVMWitness } from '../../acvm/acvm_types.js';
|
|
2
|
+
import { CircuitRecorder, type CircuitRecording } from './circuit_recorder.js';
|
|
3
|
+
export declare class FileCircuitRecorder extends CircuitRecorder {
|
|
4
|
+
#private;
|
|
5
|
+
private readonly recordDir;
|
|
6
|
+
recording?: CircuitRecording & {
|
|
7
|
+
filePath: string;
|
|
8
|
+
isFirstCall: boolean;
|
|
9
|
+
};
|
|
10
|
+
constructor(recordDir: string);
|
|
11
|
+
start(input: ACVMWitness, circuitBytecode: Buffer, circuitName: string, functionName?: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Records a single oracle/foreign call with its inputs and outputs.
|
|
14
|
+
* @param name - Name of the call
|
|
15
|
+
* @param inputs - Input arguments
|
|
16
|
+
* @param outputs - Output results
|
|
17
|
+
*/
|
|
18
|
+
recordCall(name: string, inputs: unknown[], outputs: unknown, time: number, stackDepth: number): Promise<import("./circuit_recorder.js").OracleCall>;
|
|
19
|
+
/**
|
|
20
|
+
* Finalizes the recording file by adding closing brackets. Without calling this method, the recording file is
|
|
21
|
+
* incomplete and it fails to parse.
|
|
22
|
+
*/
|
|
23
|
+
finish(): Promise<CircuitRecording>;
|
|
24
|
+
/**
|
|
25
|
+
* Finalizes the recording file by adding the error and closing brackets. Without calling this method or `finish`,
|
|
26
|
+
* the recording file is incomplete and it fails to parse.
|
|
27
|
+
* @param error - The error that occurred during circuit execution
|
|
28
|
+
*/
|
|
29
|
+
finishWithError(error: unknown): Promise<CircuitRecording>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=file_circuit_recorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file_circuit_recorder.d.ts","sourceRoot":"","sources":["../../../../src/private/providers/circuit_recording/file_circuit_recorder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,qBAAa,mBAAoB,SAAQ,eAAe;;IAG1C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAF9B,SAAS,CAAC,EAAE,gBAAgB,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,CAAC;gBAErD,SAAS,EAAE,MAAM;IAI/B,KAAK,CAClB,KAAK,EAAE,WAAW,EAClB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,YAAY,GAAE,MAAe;IAqE/B;;;;;OAKG;IACY,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAY7G;;;OAGG;IACY,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAalD;;;;OAIG;IACY,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAc1E"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { CircuitRecorder } from './circuit_recorder.js';
|
|
4
|
+
export class FileCircuitRecorder extends CircuitRecorder {
|
|
5
|
+
recordDir;
|
|
6
|
+
constructor(recordDir){
|
|
7
|
+
super(), this.recordDir = recordDir;
|
|
8
|
+
}
|
|
9
|
+
async start(input, circuitBytecode, circuitName, functionName = 'main') {
|
|
10
|
+
await super.start(input, circuitBytecode, circuitName, functionName);
|
|
11
|
+
const recordingStringWithoutClosingBracket = JSON.stringify({
|
|
12
|
+
...this.recording,
|
|
13
|
+
isFirstCall: undefined,
|
|
14
|
+
parent: undefined,
|
|
15
|
+
oracleCalls: undefined,
|
|
16
|
+
filePath: undefined
|
|
17
|
+
}, null, 2).slice(0, -2);
|
|
18
|
+
try {
|
|
19
|
+
// Check if the recording directory exists and is a directory
|
|
20
|
+
const stats = await fs.stat(this.recordDir);
|
|
21
|
+
if (!stats.isDirectory()) {
|
|
22
|
+
throw new Error(`Recording path ${this.recordDir} exists but is not a directory`);
|
|
23
|
+
}
|
|
24
|
+
} catch (err) {
|
|
25
|
+
if (err.code === 'ENOENT') {
|
|
26
|
+
// The directory does not exist so we create it
|
|
27
|
+
await fs.mkdir(this.recordDir, {
|
|
28
|
+
recursive: true
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
this.recording.isFirstCall = true;
|
|
35
|
+
this.recording.filePath = await FileCircuitRecorder.#computeFilePathAndStoreInitialRecording(this.recordDir, this.recording.circuitName, this.recording.functionName, recordingStringWithoutClosingBracket);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Computes a unique file path for the recording by trying different counter values.
|
|
39
|
+
* This is needed because multiple recordings of the same circuit could be happening simultaneously or an older
|
|
40
|
+
* recording might be present.
|
|
41
|
+
* @param recordDir - Directory to store the recording
|
|
42
|
+
* @param circuitName - Name of the circuit
|
|
43
|
+
* @param functionName - Name of the circuit function
|
|
44
|
+
* @param recordingContent - Initial recording content
|
|
45
|
+
* @returns A unique file path for the recording
|
|
46
|
+
*/ static async #computeFilePathAndStoreInitialRecording(recordDir, circuitName, functionName, recordingContent) {
|
|
47
|
+
let counter = 0;
|
|
48
|
+
while(true){
|
|
49
|
+
try {
|
|
50
|
+
const filePath = getFilePath(recordDir, circuitName, functionName, counter);
|
|
51
|
+
// Write the initial recording content to the file
|
|
52
|
+
await fs.writeFile(filePath, recordingContent + ',\n "oracleCalls": [\n', {
|
|
53
|
+
flag: 'wx'
|
|
54
|
+
});
|
|
55
|
+
return filePath;
|
|
56
|
+
} catch (err) {
|
|
57
|
+
if (err.code === 'EEXIST') {
|
|
58
|
+
counter++;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Records a single oracle/foreign call with its inputs and outputs.
|
|
67
|
+
* @param name - Name of the call
|
|
68
|
+
* @param inputs - Input arguments
|
|
69
|
+
* @param outputs - Output results
|
|
70
|
+
*/ async recordCall(name, inputs, outputs, time, stackDepth) {
|
|
71
|
+
const entry = await super.recordCall(name, inputs, outputs, time, stackDepth);
|
|
72
|
+
try {
|
|
73
|
+
const prefix = this.recording.isFirstCall ? ' ' : ' ,';
|
|
74
|
+
this.recording.isFirstCall = false;
|
|
75
|
+
await fs.appendFile(this.recording.filePath, prefix + JSON.stringify(entry) + '\n');
|
|
76
|
+
} catch (err) {
|
|
77
|
+
this.logger.error('Failed to log circuit call', {
|
|
78
|
+
error: err
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return entry;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Finalizes the recording file by adding closing brackets. Without calling this method, the recording file is
|
|
85
|
+
* incomplete and it fails to parse.
|
|
86
|
+
*/ async finish() {
|
|
87
|
+
// Finish sets the recording to undefined if we are at the topmost circuit,
|
|
88
|
+
// so we save the current file path before that
|
|
89
|
+
const filePath = this.recording.filePath;
|
|
90
|
+
const result = await super.finish();
|
|
91
|
+
try {
|
|
92
|
+
await fs.appendFile(filePath, ' ]\n}\n');
|
|
93
|
+
} catch (err) {
|
|
94
|
+
this.logger.error('Failed to finalize recording file', {
|
|
95
|
+
error: err
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Finalizes the recording file by adding the error and closing brackets. Without calling this method or `finish`,
|
|
102
|
+
* the recording file is incomplete and it fails to parse.
|
|
103
|
+
* @param error - The error that occurred during circuit execution
|
|
104
|
+
*/ async finishWithError(error) {
|
|
105
|
+
// Finish sets the recording to undefined if we are at the topmost circuit,
|
|
106
|
+
// so we save the current file path before that
|
|
107
|
+
const filePath = this.recording.filePath;
|
|
108
|
+
const result = await super.finishWithError(error);
|
|
109
|
+
try {
|
|
110
|
+
await fs.appendFile(filePath, ' ],\n');
|
|
111
|
+
await fs.appendFile(filePath, ` "error": ${JSON.stringify(error)}\n`);
|
|
112
|
+
await fs.appendFile(filePath, '}\n');
|
|
113
|
+
} catch (err) {
|
|
114
|
+
this.logger.error('Failed to finalize recording file with error', {
|
|
115
|
+
error: err
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Generates a file path for storing circuit recordings. The format of the filename is:
|
|
123
|
+
* `circuit_name_circuit_function_name_YYYY-MM-DD_N.json` where N is a counter to ensure unique filenames.
|
|
124
|
+
* @param recordDir - Base directory for recordings
|
|
125
|
+
* @param circuitName - Name of the circuit
|
|
126
|
+
* @param functionName - Name of the circuit function
|
|
127
|
+
* @param counter - Counter to ensure unique filenames. This is expected to be incremented in a loop until there is no
|
|
128
|
+
* existing file with the same name.
|
|
129
|
+
* @returns A file path for the recording.
|
|
130
|
+
*/ function getFilePath(recordDir, circuitName, functionName, counter) {
|
|
131
|
+
const date = new Date();
|
|
132
|
+
const formattedDate = date.toISOString().split('T')[0];
|
|
133
|
+
const filename = `${circuitName}_${functionName}_${formattedDate}_${counter}.json`;
|
|
134
|
+
return path.join(recordDir, filename);
|
|
135
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory_circuit_recorder.d.ts","sourceRoot":"","sources":["../../../../src/private/providers/circuit_recording/memory_circuit_recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAMxD,qBAAa,qBAAsB,SAAQ,eAAe;;CAIzD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CircuitRecorder } from './circuit_recorder.js';
|
|
2
|
+
/*
|
|
3
|
+
* In memory circuit recorder uses the default implementation. This is kept
|
|
4
|
+
* while we decide the fate of the FileCircuitRecorder
|
|
5
|
+
*/ export class MemoryCircuitRecorder extends CircuitRecorder {
|
|
6
|
+
constructor(){
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -5,6 +5,7 @@ import type { ACIRCallback, ACIRExecutionResult } from '../../acvm/acvm.js';
|
|
|
5
5
|
import type { ACVMWitness } from '../../acvm/acvm_types.js';
|
|
6
6
|
import type { ACVMSuccess } from '../acvm_native.js';
|
|
7
7
|
import type { SimulationProvider } from '../simulation_provider.js';
|
|
8
|
+
import type { CircuitRecorder } from './circuit_recorder.js';
|
|
8
9
|
/**
|
|
9
10
|
* Takes a simulation provider and wraps it in a circuit recorder. See CircuitRecorder for more details on how circuit
|
|
10
11
|
* recording works.
|
|
@@ -12,7 +13,8 @@ import type { SimulationProvider } from '../simulation_provider.js';
|
|
|
12
13
|
export declare class SimulationProviderRecorderWrapper implements SimulationProvider {
|
|
13
14
|
#private;
|
|
14
15
|
private simulator;
|
|
15
|
-
|
|
16
|
+
private recorder;
|
|
17
|
+
constructor(simulator: SimulationProvider, recorder: CircuitRecorder);
|
|
16
18
|
executeProtocolCircuit(input: ACVMWitness, artifact: NoirCompiledCircuitWithName, callback: ForeignCallHandler | undefined): Promise<ACVMSuccess>;
|
|
17
19
|
executeUserCircuit(input: ACVMWitness, artifact: FunctionArtifactWithContractName, callback: ACIRCallback): Promise<ACIRExecutionResult>;
|
|
18
20
|
}
|
package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simulation_provider_recorder_wrapper.d.ts","sourceRoot":"","sources":["../../../../src/private/providers/circuit_recording/simulation_provider_recorder_wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"simulation_provider_recorder_wrapper.d.ts","sourceRoot":"","sources":["../../../../src/private/providers/circuit_recording/simulation_provider_recorder_wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAqB,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;GAGG;AACH,qBAAa,iCAAkC,YAAW,kBAAkB;;IAExE,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,QAAQ;gBADR,SAAS,EAAE,kBAAkB,EAC7B,QAAQ,EAAE,eAAe;IAGnC,sBAAsB,CACpB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,2BAA2B,EACrC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,GACvC,OAAO,CAAC,WAAW,CAAC;IAavB,kBAAkB,CAChB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,gCAAgC,EAC1C,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,mBAAmB,CAAC;CAiDhC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { CircuitRecorder } from './circuit_recorder.js';
|
|
2
1
|
/**
|
|
3
2
|
* Takes a simulation provider and wraps it in a circuit recorder. See CircuitRecorder for more details on how circuit
|
|
4
3
|
* recording works.
|
|
5
4
|
*/ export class SimulationProviderRecorderWrapper {
|
|
6
5
|
simulator;
|
|
7
|
-
|
|
6
|
+
recorder;
|
|
7
|
+
constructor(simulator, recorder){
|
|
8
8
|
this.simulator = simulator;
|
|
9
|
+
this.recorder = recorder;
|
|
9
10
|
}
|
|
10
11
|
executeProtocolCircuit(input, artifact, callback) {
|
|
11
12
|
const bytecode = Buffer.from(artifact.bytecode, 'base64');
|
|
@@ -15,25 +16,29 @@ import { CircuitRecorder } from './circuit_recorder.js';
|
|
|
15
16
|
return this.#simulate((wrappedCallback)=>this.simulator.executeUserCircuit(input, artifact, wrappedCallback), input, artifact.bytecode, artifact.contractName, artifact.name, callback);
|
|
16
17
|
}
|
|
17
18
|
async #simulate(simulateFn, input, bytecode, contractName, functionName, callback) {
|
|
18
|
-
const recordDir = process.env.CIRCUIT_RECORD_DIR;
|
|
19
|
-
if (!recordDir) {
|
|
20
|
-
// Recording is not enabled so we just execute the circuit
|
|
21
|
-
return simulateFn(callback);
|
|
22
|
-
}
|
|
23
19
|
// Start recording circuit execution
|
|
24
|
-
|
|
20
|
+
await this.recorder.start(input, bytecode, contractName, functionName);
|
|
25
21
|
// If callback was provided, we wrap it in a circuit recorder callback wrapper
|
|
26
|
-
const wrappedCallback = recorder.wrapCallback(callback);
|
|
22
|
+
const wrappedCallback = this.recorder.wrapCallback(callback);
|
|
27
23
|
let result;
|
|
28
24
|
try {
|
|
29
25
|
result = await simulateFn(wrappedCallback);
|
|
30
26
|
} catch (error) {
|
|
31
27
|
// If an error occurs, we finalize the recording file with the error
|
|
32
|
-
await recorder.finishWithError(error);
|
|
28
|
+
await this.recorder.finishWithError(error);
|
|
33
29
|
throw error;
|
|
34
30
|
}
|
|
35
31
|
// Witness generation is complete so we finish the circuit recorder
|
|
36
|
-
await recorder.finish();
|
|
32
|
+
const recording = await this.recorder.finish();
|
|
33
|
+
result.oracles = recording.oracleCalls?.reduce((acc, { time, name })=>{
|
|
34
|
+
if (!acc[name]) {
|
|
35
|
+
acc[name] = {
|
|
36
|
+
times: []
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
acc[name].times.push(time);
|
|
40
|
+
return acc;
|
|
41
|
+
}, {});
|
|
37
42
|
return result;
|
|
38
43
|
}
|
|
39
44
|
}
|
|
@@ -4,7 +4,7 @@ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
6
6
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
7
|
-
import { IndexedTaggingSecret,
|
|
7
|
+
import { IndexedTaggingSecret, PublicLogWithTxData } from '@aztec/stdlib/logs';
|
|
8
8
|
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
9
9
|
import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
10
10
|
import type { BlockHeader, Capsule, TxHash } from '@aztec/stdlib/tx';
|
|
@@ -149,9 +149,9 @@ export declare class UtilityExecutionOracle extends TypedOracle {
|
|
|
149
149
|
* @returns A tagging secret that can be used to tag notes.
|
|
150
150
|
*/
|
|
151
151
|
getIndexedTaggingSecretAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<IndexedTaggingSecret>;
|
|
152
|
-
|
|
152
|
+
fetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
|
|
153
153
|
deliverNote(contractAddress: AztecAddress, storageSlot: Fr, nonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: TxHash, recipient: AztecAddress): Promise<void>;
|
|
154
|
-
|
|
154
|
+
getPublicLogByTag(tag: Fr, contractAddress: AztecAddress): Promise<PublicLogWithTxData | null>;
|
|
155
155
|
storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void>;
|
|
156
156
|
loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null>;
|
|
157
157
|
deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility_execution_oracle.d.ts","sourceRoot":"","sources":["../../src/private/utility_execution_oracle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEhF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,
|
|
1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|
201
201
|
return await this.executionDataProvider.getIndexedTaggingSecretAsSender(this.contractAddress, sender, recipient);
|
|
202
202
|
}
|
|
203
|
-
async
|
|
203
|
+
async fetchTaggedLogs(pendingTaggedLogArrayBaseSlot) {
|
|
204
204
|
await this.executionDataProvider.syncTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes);
|
|
205
205
|
await this.executionDataProvider.removeNullifiedNotes(this.contractAddress);
|
|
206
206
|
}
|
|
@@ -211,8 +211,8 @@ import { pickNotes } from './pick_notes.js';
|
|
|
211
211
|
}
|
|
212
212
|
await this.executionDataProvider.deliverNote(contractAddress, storageSlot, nonce, content, noteHash, nullifier, txHash, recipient);
|
|
213
213
|
}
|
|
214
|
-
|
|
215
|
-
return this.executionDataProvider.
|
|
214
|
+
getPublicLogByTag(tag, contractAddress) {
|
|
215
|
+
return this.executionDataProvider.getPublicLogByTag(tag, contractAddress);
|
|
216
216
|
}
|
|
217
217
|
storeCapsule(contractAddress, slot, capsule) {
|
|
218
218
|
if (!contractAddress.equals(this.contractAddress)) {
|
|
@@ -36,10 +36,9 @@ export declare const EmptyGas: Gas;
|
|
|
36
36
|
export declare const GAS_DIMENSIONS: readonly ["l2Gas", "daGas"];
|
|
37
37
|
/** Returns the fixed base gas cost for a given opcode. */
|
|
38
38
|
export declare function getBaseGasCost(opcode: Opcode): Gas;
|
|
39
|
+
export declare function computeAddressingCost(indirectOperandsCount: number, relativeOperandsCount: number): Gas;
|
|
39
40
|
export declare function getDynamicGasCost(opcode: Opcode): Gas;
|
|
40
|
-
/** Returns
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
daGas: number;
|
|
44
|
-
};
|
|
41
|
+
/** Returns a multiplier based on the byte size of the type represented by the integer tag.
|
|
42
|
+
* Used to account for necessary rows in the bitwise trace. Throws on invalid. */
|
|
43
|
+
export declare function getBitwiseDynamicGasMultiplier(tag: TypeTag): 0 | 1 | 2 | 8 | 4 | 16;
|
|
45
44
|
//# sourceMappingURL=avm_gas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avm_gas.d.ts","sourceRoot":"","sources":["../../../src/public/avm/avm_gas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,8CAA8C,CAAC;AAEtE,sCAAsC;AACtC,MAAM,MAAM,GAAG,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG;;;EAEpC;AAED,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;;;EAE7E;AAED,8EAA8E;AAC9E,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;WAfpC,MAAM;WACN,MAAM;EAgBd;AAED,+CAA+C;AAC/C,wBAAgB,MAAM,CAAC,GAAG,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,OAQ9C;AAED,6CAA6C;AAC7C,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM;;;EAEvD;AAED,0CAA0C;AAC1C,eAAO,MAAM,QAAQ,EAAE,GAGtB,CAAC;AAMF,+CAA+C;AAC/C,eAAO,MAAM,cAAc,6BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"avm_gas.d.ts","sourceRoot":"","sources":["../../../src/public/avm/avm_gas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,8CAA8C,CAAC;AAEtE,sCAAsC;AACtC,MAAM,MAAM,GAAG,GAAG;IAChB,KAAK,EAAE,MAAM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