@aztec/simulator 0.0.1-commit.6c91f13 → 0.0.1-commit.96bb3f7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/public/avm/opcodes/accrued_substate.js +1 -1
- package/dest/public/avm/opcodes/environment_getters.d.ts +3 -3
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +2 -2
- 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 +1 -0
- 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 +8 -34
- package/dest/public/fixtures/bulk_test.js +1 -17
- package/dest/public/fuzzing/avm_simulator_bin.js +14 -3
- package/dest/public/hinting_db_sources.js +3 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +3 -1
- package/dest/public/public_processor/public_processor.js +399 -20
- package/dest/public/public_processor/public_processor_metrics.d.ts +1 -1
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +12 -45
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +1 -1
- 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 +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +395 -19
- package/package.json +16 -16
- package/src/public/avm/opcodes/accrued_substate.ts +1 -1
- package/src/public/avm/opcodes/environment_getters.ts +4 -4
- package/src/public/avm/opcodes/external_calls.ts +1 -0
- package/src/public/executor_metrics.ts +7 -34
- package/src/public/fixtures/bulk_test.ts +2 -2
- package/src/public/fuzzing/avm_simulator_bin.ts +17 -4
- package/src/public/public_processor/public_processor_metrics.ts +11 -45
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +8 -1
|
@@ -1,20 +1,409 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function applyDecs2203RFactory() {
|
|
2
|
+
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
|
3
|
+
return function addInitializer(initializer) {
|
|
4
|
+
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
|
5
|
+
assertCallable(initializer, "An initializer");
|
|
6
|
+
initializers.push(initializer);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
|
|
10
|
+
var kindStr;
|
|
11
|
+
switch(kind){
|
|
12
|
+
case 1:
|
|
13
|
+
kindStr = "accessor";
|
|
14
|
+
break;
|
|
15
|
+
case 2:
|
|
16
|
+
kindStr = "method";
|
|
17
|
+
break;
|
|
18
|
+
case 3:
|
|
19
|
+
kindStr = "getter";
|
|
20
|
+
break;
|
|
21
|
+
case 4:
|
|
22
|
+
kindStr = "setter";
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
kindStr = "field";
|
|
26
|
+
}
|
|
27
|
+
var ctx = {
|
|
28
|
+
kind: kindStr,
|
|
29
|
+
name: isPrivate ? "#" + name : name,
|
|
30
|
+
static: isStatic,
|
|
31
|
+
private: isPrivate,
|
|
32
|
+
metadata: metadata
|
|
33
|
+
};
|
|
34
|
+
var decoratorFinishedRef = {
|
|
35
|
+
v: false
|
|
36
|
+
};
|
|
37
|
+
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
|
38
|
+
var get, set;
|
|
39
|
+
if (kind === 0) {
|
|
40
|
+
if (isPrivate) {
|
|
41
|
+
get = desc.get;
|
|
42
|
+
set = desc.set;
|
|
43
|
+
} else {
|
|
44
|
+
get = function() {
|
|
45
|
+
return this[name];
|
|
46
|
+
};
|
|
47
|
+
set = function(v) {
|
|
48
|
+
this[name] = v;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
} else if (kind === 2) {
|
|
52
|
+
get = function() {
|
|
53
|
+
return desc.value;
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
if (kind === 1 || kind === 3) {
|
|
57
|
+
get = function() {
|
|
58
|
+
return desc.get.call(this);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (kind === 1 || kind === 4) {
|
|
62
|
+
set = function(v) {
|
|
63
|
+
desc.set.call(this, v);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
ctx.access = get && set ? {
|
|
68
|
+
get: get,
|
|
69
|
+
set: set
|
|
70
|
+
} : get ? {
|
|
71
|
+
get: get
|
|
72
|
+
} : {
|
|
73
|
+
set: set
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
return dec(value, ctx);
|
|
77
|
+
} finally{
|
|
78
|
+
decoratorFinishedRef.v = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function assertNotFinished(decoratorFinishedRef, fnName) {
|
|
82
|
+
if (decoratorFinishedRef.v) {
|
|
83
|
+
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function assertCallable(fn, hint) {
|
|
87
|
+
if (typeof fn !== "function") {
|
|
88
|
+
throw new TypeError(hint + " must be a function");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function assertValidReturnValue(kind, value) {
|
|
92
|
+
var type = typeof value;
|
|
93
|
+
if (kind === 1) {
|
|
94
|
+
if (type !== "object" || value === null) {
|
|
95
|
+
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
|
96
|
+
}
|
|
97
|
+
if (value.get !== undefined) {
|
|
98
|
+
assertCallable(value.get, "accessor.get");
|
|
99
|
+
}
|
|
100
|
+
if (value.set !== undefined) {
|
|
101
|
+
assertCallable(value.set, "accessor.set");
|
|
102
|
+
}
|
|
103
|
+
if (value.init !== undefined) {
|
|
104
|
+
assertCallable(value.init, "accessor.init");
|
|
105
|
+
}
|
|
106
|
+
} else if (type !== "function") {
|
|
107
|
+
var hint;
|
|
108
|
+
if (kind === 0) {
|
|
109
|
+
hint = "field";
|
|
110
|
+
} else if (kind === 10) {
|
|
111
|
+
hint = "class";
|
|
112
|
+
} else {
|
|
113
|
+
hint = "method";
|
|
114
|
+
}
|
|
115
|
+
throw new TypeError(hint + " decorators must return a function or void 0");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
|
|
119
|
+
var decs = decInfo[0];
|
|
120
|
+
var desc, init, value;
|
|
121
|
+
if (isPrivate) {
|
|
122
|
+
if (kind === 0 || kind === 1) {
|
|
123
|
+
desc = {
|
|
124
|
+
get: decInfo[3],
|
|
125
|
+
set: decInfo[4]
|
|
126
|
+
};
|
|
127
|
+
} else if (kind === 3) {
|
|
128
|
+
desc = {
|
|
129
|
+
get: decInfo[3]
|
|
130
|
+
};
|
|
131
|
+
} else if (kind === 4) {
|
|
132
|
+
desc = {
|
|
133
|
+
set: decInfo[3]
|
|
134
|
+
};
|
|
135
|
+
} else {
|
|
136
|
+
desc = {
|
|
137
|
+
value: decInfo[3]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
} else if (kind !== 0) {
|
|
141
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
142
|
+
}
|
|
143
|
+
if (kind === 1) {
|
|
144
|
+
value = {
|
|
145
|
+
get: desc.get,
|
|
146
|
+
set: desc.set
|
|
147
|
+
};
|
|
148
|
+
} else if (kind === 2) {
|
|
149
|
+
value = desc.value;
|
|
150
|
+
} else if (kind === 3) {
|
|
151
|
+
value = desc.get;
|
|
152
|
+
} else if (kind === 4) {
|
|
153
|
+
value = desc.set;
|
|
154
|
+
}
|
|
155
|
+
var newValue, get, set;
|
|
156
|
+
if (typeof decs === "function") {
|
|
157
|
+
newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
158
|
+
if (newValue !== void 0) {
|
|
159
|
+
assertValidReturnValue(kind, newValue);
|
|
160
|
+
if (kind === 0) {
|
|
161
|
+
init = newValue;
|
|
162
|
+
} else if (kind === 1) {
|
|
163
|
+
init = newValue.init;
|
|
164
|
+
get = newValue.get || value.get;
|
|
165
|
+
set = newValue.set || value.set;
|
|
166
|
+
value = {
|
|
167
|
+
get: get,
|
|
168
|
+
set: set
|
|
169
|
+
};
|
|
170
|
+
} else {
|
|
171
|
+
value = newValue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
for(var i = decs.length - 1; i >= 0; i--){
|
|
176
|
+
var dec = decs[i];
|
|
177
|
+
newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
|
|
178
|
+
if (newValue !== void 0) {
|
|
179
|
+
assertValidReturnValue(kind, newValue);
|
|
180
|
+
var newInit;
|
|
181
|
+
if (kind === 0) {
|
|
182
|
+
newInit = newValue;
|
|
183
|
+
} else if (kind === 1) {
|
|
184
|
+
newInit = newValue.init;
|
|
185
|
+
get = newValue.get || value.get;
|
|
186
|
+
set = newValue.set || value.set;
|
|
187
|
+
value = {
|
|
188
|
+
get: get,
|
|
189
|
+
set: set
|
|
190
|
+
};
|
|
191
|
+
} else {
|
|
192
|
+
value = newValue;
|
|
193
|
+
}
|
|
194
|
+
if (newInit !== void 0) {
|
|
195
|
+
if (init === void 0) {
|
|
196
|
+
init = newInit;
|
|
197
|
+
} else if (typeof init === "function") {
|
|
198
|
+
init = [
|
|
199
|
+
init,
|
|
200
|
+
newInit
|
|
201
|
+
];
|
|
202
|
+
} else {
|
|
203
|
+
init.push(newInit);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (kind === 0 || kind === 1) {
|
|
210
|
+
if (init === void 0) {
|
|
211
|
+
init = function(instance, init) {
|
|
212
|
+
return init;
|
|
213
|
+
};
|
|
214
|
+
} else if (typeof init !== "function") {
|
|
215
|
+
var ownInitializers = init;
|
|
216
|
+
init = function(instance, init) {
|
|
217
|
+
var value = init;
|
|
218
|
+
for(var i = 0; i < ownInitializers.length; i++){
|
|
219
|
+
value = ownInitializers[i].call(instance, value);
|
|
220
|
+
}
|
|
221
|
+
return value;
|
|
222
|
+
};
|
|
223
|
+
} else {
|
|
224
|
+
var originalInitializer = init;
|
|
225
|
+
init = function(instance, init) {
|
|
226
|
+
return originalInitializer.call(instance, init);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
ret.push(init);
|
|
230
|
+
}
|
|
231
|
+
if (kind !== 0) {
|
|
232
|
+
if (kind === 1) {
|
|
233
|
+
desc.get = value.get;
|
|
234
|
+
desc.set = value.set;
|
|
235
|
+
} else if (kind === 2) {
|
|
236
|
+
desc.value = value;
|
|
237
|
+
} else if (kind === 3) {
|
|
238
|
+
desc.get = value;
|
|
239
|
+
} else if (kind === 4) {
|
|
240
|
+
desc.set = value;
|
|
241
|
+
}
|
|
242
|
+
if (isPrivate) {
|
|
243
|
+
if (kind === 1) {
|
|
244
|
+
ret.push(function(instance, args) {
|
|
245
|
+
return value.get.call(instance, args);
|
|
246
|
+
});
|
|
247
|
+
ret.push(function(instance, args) {
|
|
248
|
+
return value.set.call(instance, args);
|
|
249
|
+
});
|
|
250
|
+
} else if (kind === 2) {
|
|
251
|
+
ret.push(value);
|
|
252
|
+
} else {
|
|
253
|
+
ret.push(function(instance, args) {
|
|
254
|
+
return value.call(instance, args);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
Object.defineProperty(base, name, desc);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function applyMemberDecs(Class, decInfos, metadata) {
|
|
263
|
+
var ret = [];
|
|
264
|
+
var protoInitializers;
|
|
265
|
+
var staticInitializers;
|
|
266
|
+
var existingProtoNonFields = new Map();
|
|
267
|
+
var existingStaticNonFields = new Map();
|
|
268
|
+
for(var i = 0; i < decInfos.length; i++){
|
|
269
|
+
var decInfo = decInfos[i];
|
|
270
|
+
if (!Array.isArray(decInfo)) continue;
|
|
271
|
+
var kind = decInfo[1];
|
|
272
|
+
var name = decInfo[2];
|
|
273
|
+
var isPrivate = decInfo.length > 3;
|
|
274
|
+
var isStatic = kind >= 5;
|
|
275
|
+
var base;
|
|
276
|
+
var initializers;
|
|
277
|
+
if (isStatic) {
|
|
278
|
+
base = Class;
|
|
279
|
+
kind = kind - 5;
|
|
280
|
+
staticInitializers = staticInitializers || [];
|
|
281
|
+
initializers = staticInitializers;
|
|
282
|
+
} else {
|
|
283
|
+
base = Class.prototype;
|
|
284
|
+
protoInitializers = protoInitializers || [];
|
|
285
|
+
initializers = protoInitializers;
|
|
286
|
+
}
|
|
287
|
+
if (kind !== 0 && !isPrivate) {
|
|
288
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
289
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
290
|
+
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
|
291
|
+
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
|
292
|
+
} else if (!existingKind && kind > 2) {
|
|
293
|
+
existingNonFields.set(name, kind);
|
|
294
|
+
} else {
|
|
295
|
+
existingNonFields.set(name, true);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
|
|
299
|
+
}
|
|
300
|
+
pushInitializers(ret, protoInitializers);
|
|
301
|
+
pushInitializers(ret, staticInitializers);
|
|
302
|
+
return ret;
|
|
303
|
+
}
|
|
304
|
+
function pushInitializers(ret, initializers) {
|
|
305
|
+
if (initializers) {
|
|
306
|
+
ret.push(function(instance) {
|
|
307
|
+
for(var i = 0; i < initializers.length; i++){
|
|
308
|
+
initializers[i].call(instance);
|
|
309
|
+
}
|
|
310
|
+
return instance;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function applyClassDecs(targetClass, classDecs, metadata) {
|
|
315
|
+
if (classDecs.length > 0) {
|
|
316
|
+
var initializers = [];
|
|
317
|
+
var newClass = targetClass;
|
|
318
|
+
var name = targetClass.name;
|
|
319
|
+
for(var i = classDecs.length - 1; i >= 0; i--){
|
|
320
|
+
var decoratorFinishedRef = {
|
|
321
|
+
v: false
|
|
322
|
+
};
|
|
323
|
+
try {
|
|
324
|
+
var nextNewClass = classDecs[i](newClass, {
|
|
325
|
+
kind: "class",
|
|
326
|
+
name: name,
|
|
327
|
+
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
|
|
328
|
+
metadata
|
|
329
|
+
});
|
|
330
|
+
} finally{
|
|
331
|
+
decoratorFinishedRef.v = true;
|
|
332
|
+
}
|
|
333
|
+
if (nextNewClass !== undefined) {
|
|
334
|
+
assertValidReturnValue(10, nextNewClass);
|
|
335
|
+
newClass = nextNewClass;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return [
|
|
339
|
+
defineMetadata(newClass, metadata),
|
|
340
|
+
function() {
|
|
341
|
+
for(var i = 0; i < initializers.length; i++){
|
|
342
|
+
initializers[i].call(newClass);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function defineMetadata(Class, metadata) {
|
|
349
|
+
return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
|
|
350
|
+
configurable: true,
|
|
351
|
+
enumerable: true,
|
|
352
|
+
value: metadata
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
|
|
356
|
+
if (parentClass !== void 0) {
|
|
357
|
+
var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
358
|
+
}
|
|
359
|
+
var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
|
|
360
|
+
var e = applyMemberDecs(targetClass, memberDecs, metadata);
|
|
361
|
+
if (!classDecs.length) defineMetadata(targetClass, metadata);
|
|
362
|
+
return {
|
|
363
|
+
e: e,
|
|
364
|
+
get c () {
|
|
365
|
+
return applyClassDecs(targetClass, classDecs, metadata);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
371
|
+
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
6
372
|
}
|
|
373
|
+
var _dec, _dec1, _initProto;
|
|
7
374
|
import { TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
8
375
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
9
376
|
import { ExecutorMetrics } from '../executor_metrics.js';
|
|
10
377
|
import { MeasuredPublicTxSimulator } from './measured_public_tx_simulator.js';
|
|
378
|
+
_dec = trackSpan('PublicTxSimulator.simulateEnqueuedCall', (phase, context, callRequest)=>({
|
|
379
|
+
[Attributes.TX_HASH]: context.txHash.toString(),
|
|
380
|
+
[Attributes.TARGET_ADDRESS]: callRequest.request.contractAddress.toString(),
|
|
381
|
+
[Attributes.SENDER_ADDRESS]: callRequest.request.msgSender.toString(),
|
|
382
|
+
[Attributes.SIMULATOR_PHASE]: TxExecutionPhase[phase].toString()
|
|
383
|
+
})), _dec1 = trackSpan('PublicTxSimulator.simulateEnqueuedCallInternal', (_stateManager, _callRequest, _allocatedGas, _transactionFee, fnName)=>({
|
|
384
|
+
[Attributes.APP_CIRCUIT_NAME]: fnName
|
|
385
|
+
}));
|
|
11
386
|
/**
|
|
12
387
|
* A public tx simulator that tracks runtime/production metrics with telemetry.
|
|
13
388
|
*/ export class TelemetryPublicTxSimulator extends MeasuredPublicTxSimulator {
|
|
389
|
+
static{
|
|
390
|
+
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
391
|
+
[
|
|
392
|
+
_dec,
|
|
393
|
+
2,
|
|
394
|
+
"simulateEnqueuedCall"
|
|
395
|
+
],
|
|
396
|
+
[
|
|
397
|
+
_dec1,
|
|
398
|
+
2,
|
|
399
|
+
"simulateEnqueuedCallInternal"
|
|
400
|
+
]
|
|
401
|
+
], []));
|
|
402
|
+
}
|
|
14
403
|
/* tracer needed by trackSpans */ tracer;
|
|
15
404
|
constructor(merkleTree, contractsDB, globalVariables, telemetryClient = getTelemetryClient(), config){
|
|
16
405
|
const metrics = new ExecutorMetrics(telemetryClient, 'PublicTxSimulator');
|
|
17
|
-
super(merkleTree, contractsDB, globalVariables, metrics, config);
|
|
406
|
+
super(merkleTree, contractsDB, globalVariables, metrics, config), _initProto(this);
|
|
18
407
|
this.tracer = metrics.tracer;
|
|
19
408
|
}
|
|
20
409
|
async simulateEnqueuedCall(phase, context, callRequest) {
|
|
@@ -24,16 +413,3 @@ import { MeasuredPublicTxSimulator } from './measured_public_tx_simulator.js';
|
|
|
24
413
|
return await super.simulateEnqueuedCallInternal(stateManager, callRequest, allocatedGas, transactionFee, fnName);
|
|
25
414
|
}
|
|
26
415
|
}
|
|
27
|
-
_ts_decorate([
|
|
28
|
-
trackSpan('PublicTxSimulator.simulateEnqueuedCall', (phase, context, callRequest)=>({
|
|
29
|
-
[Attributes.TX_HASH]: context.txHash.toString(),
|
|
30
|
-
[Attributes.TARGET_ADDRESS]: callRequest.request.contractAddress.toString(),
|
|
31
|
-
[Attributes.SENDER_ADDRESS]: callRequest.request.msgSender.toString(),
|
|
32
|
-
[Attributes.SIMULATOR_PHASE]: TxExecutionPhase[phase].toString()
|
|
33
|
-
}))
|
|
34
|
-
], TelemetryPublicTxSimulator.prototype, "simulateEnqueuedCall", null);
|
|
35
|
-
_ts_decorate([
|
|
36
|
-
trackSpan('PublicTxSimulator.simulateEnqueuedCallInternal', (_stateManager, _callRequest, _allocatedGas, _transactionFee, fnName)=>({
|
|
37
|
-
[Attributes.APP_CIRCUIT_NAME]: fnName
|
|
38
|
-
}))
|
|
39
|
-
], TelemetryPublicTxSimulator.prototype, "simulateEnqueuedCallInternal", null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.96bb3f7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -64,26 +64,26 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/constants": "0.0.1-commit.
|
|
68
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
69
|
-
"@aztec/native": "0.0.1-commit.
|
|
70
|
-
"@aztec/noir-acvm_js": "0.0.1-commit.
|
|
71
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
73
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
74
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
75
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
76
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
77
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
67
|
+
"@aztec/constants": "0.0.1-commit.96bb3f7",
|
|
68
|
+
"@aztec/foundation": "0.0.1-commit.96bb3f7",
|
|
69
|
+
"@aztec/native": "0.0.1-commit.96bb3f7",
|
|
70
|
+
"@aztec/noir-acvm_js": "0.0.1-commit.96bb3f7",
|
|
71
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.96bb3f7",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.96bb3f7",
|
|
73
|
+
"@aztec/noir-types": "0.0.1-commit.96bb3f7",
|
|
74
|
+
"@aztec/protocol-contracts": "0.0.1-commit.96bb3f7",
|
|
75
|
+
"@aztec/stdlib": "0.0.1-commit.96bb3f7",
|
|
76
|
+
"@aztec/telemetry-client": "0.0.1-commit.96bb3f7",
|
|
77
|
+
"@aztec/world-state": "0.0.1-commit.96bb3f7",
|
|
78
78
|
"lodash.clonedeep": "^4.5.0",
|
|
79
79
|
"lodash.merge": "^4.6.2",
|
|
80
80
|
"tslib": "^2.4.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
84
|
-
"@aztec/merkle-tree": "0.0.1-commit.
|
|
85
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
86
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
83
|
+
"@aztec/kv-store": "0.0.1-commit.96bb3f7",
|
|
84
|
+
"@aztec/merkle-tree": "0.0.1-commit.96bb3f7",
|
|
85
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.96bb3f7",
|
|
86
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.96bb3f7",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
88
|
"@types/jest": "^30.0.0",
|
|
89
89
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
@@ -241,11 +241,11 @@ export class EmitUnencryptedLog extends Instruction {
|
|
|
241
241
|
const [logSizeOffset, logOffset] = addressing.resolve(operands, memory);
|
|
242
242
|
memory.checkTag(TypeTag.UINT32, logSizeOffset);
|
|
243
243
|
const logSize = memory.get(logSizeOffset).toNumber();
|
|
244
|
-
memory.checkTagsRange(TypeTag.FIELD, logOffset, logSize);
|
|
245
244
|
|
|
246
245
|
const contractAddress = context.environment.address;
|
|
247
246
|
|
|
248
247
|
context.machineState.consumeGas(this.dynamicGasCost(logSize));
|
|
248
|
+
memory.checkTagsRange(TypeTag.FIELD, logOffset, logSize);
|
|
249
249
|
const log = memory.getSlice(logOffset, logSize).map(f => f.toFr());
|
|
250
250
|
context.persistableState.writePublicLog(contractAddress, log);
|
|
251
251
|
}
|
|
@@ -13,8 +13,8 @@ export enum EnvironmentVariable {
|
|
|
13
13
|
VERSION,
|
|
14
14
|
BLOCKNUMBER,
|
|
15
15
|
TIMESTAMP,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
MINFEEPERL2GAS,
|
|
17
|
+
MINFEEPERDAGAS,
|
|
18
18
|
ISSTATICCALL,
|
|
19
19
|
L2GASLEFT,
|
|
20
20
|
DAGASLEFT,
|
|
@@ -36,9 +36,9 @@ function getValue(varEnum: EnvironmentVariable, ctx: AvmContext) {
|
|
|
36
36
|
return new Uint32(ctx.environment.globals.blockNumber);
|
|
37
37
|
case EnvironmentVariable.TIMESTAMP:
|
|
38
38
|
return new Uint64(ctx.environment.globals.timestamp);
|
|
39
|
-
case EnvironmentVariable.
|
|
39
|
+
case EnvironmentVariable.MINFEEPERL2GAS:
|
|
40
40
|
return new Uint128(ctx.environment.globals.gasFees.feePerL2Gas);
|
|
41
|
-
case EnvironmentVariable.
|
|
41
|
+
case EnvironmentVariable.MINFEEPERDAGAS:
|
|
42
42
|
return new Uint128(ctx.environment.globals.gasFees.feePerDaGas);
|
|
43
43
|
case EnvironmentVariable.ISSTATICCALL:
|
|
44
44
|
return new Uint1(ctx.environment.isStaticCall ? 1 : 0);
|
|
@@ -45,6 +45,7 @@ abstract class ExternalCall extends Instruction {
|
|
|
45
45
|
memory.checkTag(TypeTag.UINT32, argsSizeOffset);
|
|
46
46
|
|
|
47
47
|
const calldataSize = memory.get(argsSizeOffset).toNumber();
|
|
48
|
+
// This is a DOS vector. CalldataSize is chosen by the bytecode, and can be arbitrarily large leading to a OOM here.
|
|
48
49
|
const calldata = memory.getSlice(argsOffset, calldataSize).map(f => f.toFr());
|
|
49
50
|
|
|
50
51
|
const callAddress = memory.getAs<Field>(addrOffset);
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
type TelemetryClient,
|
|
8
8
|
type Tracer,
|
|
9
9
|
type UpDownCounter,
|
|
10
|
-
ValueType,
|
|
11
10
|
} from '@aztec/telemetry-client';
|
|
12
11
|
|
|
13
12
|
import type { ExecutorMetricsInterface } from './executor_metrics_interface.js';
|
|
@@ -26,45 +25,19 @@ export class ExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
26
25
|
this.tracer = client.getTracer(name);
|
|
27
26
|
const meter = client.getMeter(name);
|
|
28
27
|
|
|
29
|
-
this.fnCount = meter.createUpDownCounter(Metrics.PUBLIC_EXECUTOR_SIMULATION_COUNT
|
|
30
|
-
description: 'Number of functions executed',
|
|
31
|
-
});
|
|
28
|
+
this.fnCount = meter.createUpDownCounter(Metrics.PUBLIC_EXECUTOR_SIMULATION_COUNT);
|
|
32
29
|
|
|
33
|
-
this.fnDuration = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_SIMULATION_DURATION
|
|
34
|
-
description: 'How long it takes to execute a function',
|
|
35
|
-
unit: 'ms',
|
|
36
|
-
valueType: ValueType.INT,
|
|
37
|
-
});
|
|
30
|
+
this.fnDuration = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_SIMULATION_DURATION);
|
|
38
31
|
|
|
39
|
-
this.manaPerSecond = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_SIMULATION_MANA_PER_SECOND
|
|
40
|
-
description: 'Mana used per second',
|
|
41
|
-
unit: 'mana/s',
|
|
42
|
-
valueType: ValueType.INT,
|
|
43
|
-
});
|
|
32
|
+
this.manaPerSecond = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_SIMULATION_MANA_PER_SECOND);
|
|
44
33
|
|
|
45
|
-
this.manaUsed = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_SIMULATION_MANA_USED
|
|
46
|
-
description: 'Total mana used',
|
|
47
|
-
unit: 'mana',
|
|
48
|
-
valueType: ValueType.INT,
|
|
49
|
-
});
|
|
34
|
+
this.manaUsed = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_SIMULATION_MANA_USED);
|
|
50
35
|
|
|
51
|
-
this.totalInstructionsExecuted = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_SIMULATION_TOTAL_INSTRUCTIONS
|
|
52
|
-
description: 'Total number of instructions executed',
|
|
53
|
-
unit: '#instructions',
|
|
54
|
-
valueType: ValueType.INT,
|
|
55
|
-
});
|
|
36
|
+
this.totalInstructionsExecuted = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_SIMULATION_TOTAL_INSTRUCTIONS);
|
|
56
37
|
|
|
57
|
-
this.txHashing = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_TX_HASHING
|
|
58
|
-
description: 'Tx hashing time',
|
|
59
|
-
unit: 'ms',
|
|
60
|
-
valueType: ValueType.INT,
|
|
61
|
-
});
|
|
38
|
+
this.txHashing = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_TX_HASHING);
|
|
62
39
|
|
|
63
|
-
this.privateEffectsInsertions = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_PRIVATE_EFFECTS_INSERTION
|
|
64
|
-
description: 'Private effects insertion time',
|
|
65
|
-
unit: 'us',
|
|
66
|
-
valueType: ValueType.INT,
|
|
67
|
-
});
|
|
40
|
+
this.privateEffectsInsertions = meter.createHistogram(Metrics.PUBLIC_EXECUTOR_PRIVATE_EFFECTS_INSERTION);
|
|
68
41
|
}
|
|
69
42
|
|
|
70
43
|
startRecordingTxSimulation(_txLabel: string) {
|
|
@@ -118,7 +118,7 @@ export async function megaBulkTest(
|
|
|
118
118
|
const argsField2 = [5, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
119
119
|
const argsField3 = [7, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
120
120
|
const argsField4 = [9, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
121
|
-
const argsField5 = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
121
|
+
//const argsField5 = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
122
122
|
//const argsField6 = [13, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
123
123
|
//const argsField7 = [15, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
124
124
|
//const argsField8 = [17, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
|
|
@@ -144,7 +144,7 @@ export async function megaBulkTest(
|
|
|
144
144
|
{ address: avmTestContract.address, fnName: 'bulk_testing', args: genArgs(argsField2) },
|
|
145
145
|
{ address: avmTestContract.address, fnName: 'bulk_testing', args: genArgs(argsField3) },
|
|
146
146
|
{ address: avmTestContract.address, fnName: 'bulk_testing', args: genArgs(argsField4) },
|
|
147
|
-
{ address: avmTestContract.address, fnName: 'bulk_testing', args: genArgs(argsField5) },
|
|
147
|
+
//{ address: avmTestContract.address, fnName: 'bulk_testing', args: genArgs(argsField5) },
|
|
148
148
|
//{ address: avmTestContract.address, fnName: 'bulk_testing', args: genArgs(argsField6) },
|
|
149
149
|
//{ address: avmTestContract.address, fnName: 'bulk_testing', args: genArgs(argsField7) },
|
|
150
150
|
//{ address: avmTestContract.address, fnName: 'bulk_testing', args: genArgs(argsField8) },
|
|
@@ -9,11 +9,23 @@ import {
|
|
|
9
9
|
import { GlobalVariables, TreeSnapshots } from '@aztec/stdlib/tx';
|
|
10
10
|
import { NativeWorldStateService } from '@aztec/world-state';
|
|
11
11
|
|
|
12
|
-
import { writeSync } from 'fs';
|
|
13
12
|
import { createInterface } from 'readline';
|
|
14
13
|
|
|
15
14
|
import { AvmFuzzerSimulator, FuzzerSimulationRequest } from './avm_fuzzer_simulator.js';
|
|
16
15
|
|
|
16
|
+
/** Write data to stdout, letting Node handle buffering. */
|
|
17
|
+
function writeOutput(data: string): Promise<void> {
|
|
18
|
+
return new Promise<void>((resolve, reject) => {
|
|
19
|
+
process.stdout.write(data, err => {
|
|
20
|
+
if (err) {
|
|
21
|
+
reject(err);
|
|
22
|
+
} else {
|
|
23
|
+
resolve();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
17
29
|
// This cache holds opened world states to avoid reopening them for each invocation.
|
|
18
30
|
// It's a map so that in the future we could support multiple world states (if we had multiple fuzzers).
|
|
19
31
|
const worldStateCache = new Map<string, NativeWorldStateService>();
|
|
@@ -96,16 +108,17 @@ async function execute(base64Line: string): Promise<void> {
|
|
|
96
108
|
revertReason: result.revertReason ?? '',
|
|
97
109
|
endTreeSnapshots: result.publicInputs.endTreeSnapshots,
|
|
98
110
|
});
|
|
99
|
-
|
|
111
|
+
const base64Response = resultBuffer.toString('base64') + '\n';
|
|
112
|
+
await writeOutput(base64Response);
|
|
100
113
|
} catch (error: any) {
|
|
101
114
|
// If we error, treat as reverted
|
|
102
115
|
const errorResult = serializeWithMessagePack({
|
|
103
116
|
reverted: true,
|
|
104
|
-
output: [] as
|
|
117
|
+
output: [] as Fr[],
|
|
105
118
|
revertReason: `Unexpected Error ${error.message}`,
|
|
106
119
|
endTreeSnapshots: TreeSnapshots.empty(),
|
|
107
120
|
});
|
|
108
|
-
|
|
121
|
+
await writeOutput(errorResult.toString('base64') + '\n');
|
|
109
122
|
}
|
|
110
123
|
}
|
|
111
124
|
|