@aztec/simulator 2.0.3-rc.17 → 2.0.3-rc.18
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAMvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,KAAK,QAAQ,EACb,eAAe,EACf,yBAAyB,EACzB,KAAK,WAAW,EAEhB,EAAE,
|
|
1
|
+
{"version":3,"file":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAMvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,KAAK,QAAQ,EACb,eAAe,EACf,yBAAyB,EACzB,KAAK,WAAW,EAEhB,EAAE,EAIH,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,iBAAiB,EAAiB,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,KAAK,iBAAiB,EAA8B,MAAM,iCAAiC,CAAC;AACrG,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAGvE;;GAEG;AACH,qB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E,qBAA0B,EAClC,SAAS,GAAE,wBAA6B,GACvC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,yBAAyB,EAAE,CAAC,CAAC;YA4L5D,wBAAwB;YAiBxB,SAAS;YA2BT,gCAAgC;IA2B9C,kFAAkF;YACpE,uBAAuB;IA2CrC;;;;OAIG;YACW,gCAAgC;YA0BhC,oBAAoB;YAkCpB,wBAAwB;CAsCvC"}
|
|
@@ -89,7 +89,7 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
89
89
|
* @param validator - Pre-process validator and nullifier cache to use for processing the txs.
|
|
90
90
|
* @returns The list of processed txs with their circuit simulation outputs.
|
|
91
91
|
*/ async process(txs, limits = {}, validator = {}) {
|
|
92
|
-
const { maxTransactions, maxBlockSize, deadline, maxBlockGas } = limits;
|
|
92
|
+
const { maxTransactions, maxBlockSize, deadline, maxBlockGas, maxBlobFields } = limits;
|
|
93
93
|
const { preprocessValidator, nullifierCache } = validator;
|
|
94
94
|
const result = [];
|
|
95
95
|
const usedTxs = [];
|
|
@@ -99,6 +99,7 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
99
99
|
let returns = [];
|
|
100
100
|
let totalPublicGas = new Gas(0, 0);
|
|
101
101
|
let totalBlockGas = new Gas(0, 0);
|
|
102
|
+
let totalBlobFields = 0;
|
|
102
103
|
for await (const origTx of txs){
|
|
103
104
|
// Only process up to the max tx limit
|
|
104
105
|
if (maxTransactions !== undefined && result.length >= maxTransactions) {
|
|
@@ -179,6 +180,19 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
179
180
|
await checkpoint.revert();
|
|
180
181
|
continue;
|
|
181
182
|
}
|
|
183
|
+
// If the actual blob fields of this tx would exceed the limit, skip it
|
|
184
|
+
const txBlobFields = processedTx.txEffect.toBlobFields().length;
|
|
185
|
+
if (maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
186
|
+
this.log.debug(`Skipping processed tx ${txHash} with ${txBlobFields} blob fields due to max blob fields limit.`, {
|
|
187
|
+
txHash,
|
|
188
|
+
txBlobFields,
|
|
189
|
+
totalBlobFields,
|
|
190
|
+
maxBlobFields
|
|
191
|
+
});
|
|
192
|
+
// Need to revert the checkpoint here and don't go any further
|
|
193
|
+
await checkpoint.revert();
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
182
196
|
// FIXME(fcarreiro): it's ugly to have to notify the validator of nullifiers.
|
|
183
197
|
// I'd rather pass the validators the processedTx as well and let them deal with it.
|
|
184
198
|
nullifierCache?.addNullifiers(processedTx.txEffect.nullifiers.map((n)=>n.toBuffer()));
|
|
@@ -188,6 +202,7 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
188
202
|
totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
|
|
189
203
|
totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
|
|
190
204
|
totalSizeInBytes += txSize;
|
|
205
|
+
totalBlobFields += txBlobFields;
|
|
191
206
|
} catch (err) {
|
|
192
207
|
if (err?.name === 'PublicProcessorTimeoutError') {
|
|
193
208
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
@@ -279,7 +294,7 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
279
294
|
returnValues ?? []
|
|
280
295
|
];
|
|
281
296
|
}
|
|
282
|
-
async doTreeInsertionsForPrivateOnlyTx(processedTx
|
|
297
|
+
async doTreeInsertionsForPrivateOnlyTx(processedTx) {
|
|
283
298
|
const treeInsertionStart = process.hrtime.bigint();
|
|
284
299
|
// Update the state so that the next tx in the loop has the correct .startState
|
|
285
300
|
// NB: before this change, all .startStates were actually incorrect, but the issue was never caught because we either:
|
|
@@ -290,14 +305,10 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
290
305
|
await this.guardedMerkleTree.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, padArrayEnd(processedTx.txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX));
|
|
291
306
|
try {
|
|
292
307
|
await this.guardedMerkleTree.batchInsert(MerkleTreeId.NULLIFIER_TREE, padArrayEnd(processedTx.txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map((n)=>n.toBuffer()), NULLIFIER_SUBTREE_HEIGHT);
|
|
293
|
-
} catch
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
} else {
|
|
298
|
-
// We have no validator and assume this call should blindly process txs with duplicates being caught later
|
|
299
|
-
this.log.warn(`Detected duplicate nullifier after public processing for: ${processedTx.hash}.`);
|
|
300
|
-
}
|
|
308
|
+
} catch (cause) {
|
|
309
|
+
throw new Error(`Transaction ${processedTx.hash} failed with duplicate nullifiers`, {
|
|
310
|
+
cause
|
|
311
|
+
});
|
|
301
312
|
}
|
|
302
313
|
const treeInsertionEnd = process.hrtime.bigint();
|
|
303
314
|
this.metrics.recordTreeInsertions(Number(treeInsertionEnd - treeInsertionStart) / 1_000);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "2.0.3-rc.
|
|
3
|
+
"version": "2.0.3-rc.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -63,25 +63,25 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@aztec/constants": "2.0.3-rc.
|
|
67
|
-
"@aztec/foundation": "2.0.3-rc.
|
|
68
|
-
"@aztec/noir-acvm_js": "2.0.3-rc.
|
|
69
|
-
"@aztec/noir-noirc_abi": "2.0.3-rc.
|
|
70
|
-
"@aztec/noir-protocol-circuits-types": "2.0.3-rc.
|
|
71
|
-
"@aztec/noir-types": "2.0.3-rc.
|
|
72
|
-
"@aztec/protocol-contracts": "2.0.3-rc.
|
|
73
|
-
"@aztec/stdlib": "2.0.3-rc.
|
|
74
|
-
"@aztec/telemetry-client": "2.0.3-rc.
|
|
75
|
-
"@aztec/world-state": "2.0.3-rc.
|
|
66
|
+
"@aztec/constants": "2.0.3-rc.18",
|
|
67
|
+
"@aztec/foundation": "2.0.3-rc.18",
|
|
68
|
+
"@aztec/noir-acvm_js": "2.0.3-rc.18",
|
|
69
|
+
"@aztec/noir-noirc_abi": "2.0.3-rc.18",
|
|
70
|
+
"@aztec/noir-protocol-circuits-types": "2.0.3-rc.18",
|
|
71
|
+
"@aztec/noir-types": "2.0.3-rc.18",
|
|
72
|
+
"@aztec/protocol-contracts": "2.0.3-rc.18",
|
|
73
|
+
"@aztec/stdlib": "2.0.3-rc.18",
|
|
74
|
+
"@aztec/telemetry-client": "2.0.3-rc.18",
|
|
75
|
+
"@aztec/world-state": "2.0.3-rc.18",
|
|
76
76
|
"lodash.clonedeep": "^4.5.0",
|
|
77
77
|
"lodash.merge": "^4.6.2",
|
|
78
78
|
"tslib": "^2.4.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@aztec/kv-store": "2.0.3-rc.
|
|
82
|
-
"@aztec/merkle-tree": "2.0.3-rc.
|
|
83
|
-
"@aztec/noir-contracts.js": "2.0.3-rc.
|
|
84
|
-
"@aztec/noir-test-contracts.js": "2.0.3-rc.
|
|
81
|
+
"@aztec/kv-store": "2.0.3-rc.18",
|
|
82
|
+
"@aztec/merkle-tree": "2.0.3-rc.18",
|
|
83
|
+
"@aztec/noir-contracts.js": "2.0.3-rc.18",
|
|
84
|
+
"@aztec/noir-test-contracts.js": "2.0.3-rc.18",
|
|
85
85
|
"@jest/globals": "^30.0.0",
|
|
86
86
|
"@types/jest": "^30.0.0",
|
|
87
87
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
StateReference,
|
|
28
28
|
Tx,
|
|
29
29
|
TxExecutionPhase,
|
|
30
|
-
type TxValidator,
|
|
31
30
|
makeProcessedTxFromPrivateOnlyTx,
|
|
32
31
|
makeProcessedTxFromTxWithPublicCalls,
|
|
33
32
|
} from '@aztec/stdlib/tx';
|
|
@@ -154,7 +153,7 @@ export class PublicProcessor implements Traceable {
|
|
|
154
153
|
limits: PublicProcessorLimits = {},
|
|
155
154
|
validator: PublicProcessorValidator = {},
|
|
156
155
|
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[]]> {
|
|
157
|
-
const { maxTransactions, maxBlockSize, deadline, maxBlockGas } = limits;
|
|
156
|
+
const { maxTransactions, maxBlockSize, deadline, maxBlockGas, maxBlobFields } = limits;
|
|
158
157
|
const { preprocessValidator, nullifierCache } = validator;
|
|
159
158
|
const result: ProcessedTx[] = [];
|
|
160
159
|
const usedTxs: Tx[] = [];
|
|
@@ -165,6 +164,7 @@ export class PublicProcessor implements Traceable {
|
|
|
165
164
|
let returns: NestedProcessReturnValues[] = [];
|
|
166
165
|
let totalPublicGas = new Gas(0, 0);
|
|
167
166
|
let totalBlockGas = new Gas(0, 0);
|
|
167
|
+
let totalBlobFields = 0;
|
|
168
168
|
|
|
169
169
|
for await (const origTx of txs) {
|
|
170
170
|
// Only process up to the max tx limit
|
|
@@ -252,6 +252,23 @@ export class PublicProcessor implements Traceable {
|
|
|
252
252
|
continue;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
// If the actual blob fields of this tx would exceed the limit, skip it
|
|
256
|
+
const txBlobFields = processedTx.txEffect.toBlobFields().length;
|
|
257
|
+
if (maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
258
|
+
this.log.debug(
|
|
259
|
+
`Skipping processed tx ${txHash} with ${txBlobFields} blob fields due to max blob fields limit.`,
|
|
260
|
+
{
|
|
261
|
+
txHash,
|
|
262
|
+
txBlobFields,
|
|
263
|
+
totalBlobFields,
|
|
264
|
+
maxBlobFields,
|
|
265
|
+
},
|
|
266
|
+
);
|
|
267
|
+
// Need to revert the checkpoint here and don't go any further
|
|
268
|
+
await checkpoint.revert();
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
|
|
255
272
|
// FIXME(fcarreiro): it's ugly to have to notify the validator of nullifiers.
|
|
256
273
|
// I'd rather pass the validators the processedTx as well and let them deal with it.
|
|
257
274
|
nullifierCache?.addNullifiers(processedTx.txEffect.nullifiers.map(n => n.toBuffer()));
|
|
@@ -262,6 +279,7 @@ export class PublicProcessor implements Traceable {
|
|
|
262
279
|
totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
|
|
263
280
|
totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
|
|
264
281
|
totalSizeInBytes += txSize;
|
|
282
|
+
totalBlobFields += txBlobFields;
|
|
265
283
|
} catch (err: any) {
|
|
266
284
|
if (err?.name === 'PublicProcessorTimeoutError') {
|
|
267
285
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
@@ -366,10 +384,7 @@ export class PublicProcessor implements Traceable {
|
|
|
366
384
|
return [processedTx, returnValues ?? []];
|
|
367
385
|
}
|
|
368
386
|
|
|
369
|
-
private async doTreeInsertionsForPrivateOnlyTx(
|
|
370
|
-
processedTx: ProcessedTx,
|
|
371
|
-
txValidator?: TxValidator<ProcessedTx>,
|
|
372
|
-
): Promise<void> {
|
|
387
|
+
private async doTreeInsertionsForPrivateOnlyTx(processedTx: ProcessedTx): Promise<void> {
|
|
373
388
|
const treeInsertionStart = process.hrtime.bigint();
|
|
374
389
|
|
|
375
390
|
// Update the state so that the next tx in the loop has the correct .startState
|
|
@@ -388,14 +403,8 @@ export class PublicProcessor implements Traceable {
|
|
|
388
403
|
padArrayEnd(processedTx.txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map(n => n.toBuffer()),
|
|
389
404
|
NULLIFIER_SUBTREE_HEIGHT,
|
|
390
405
|
);
|
|
391
|
-
} catch {
|
|
392
|
-
|
|
393
|
-
// Ideally the validator has already caught this above, but just in case:
|
|
394
|
-
throw new Error(`Transaction ${processedTx.hash} invalid after processing public functions`);
|
|
395
|
-
} else {
|
|
396
|
-
// We have no validator and assume this call should blindly process txs with duplicates being caught later
|
|
397
|
-
this.log.warn(`Detected duplicate nullifier after public processing for: ${processedTx.hash}.`);
|
|
398
|
-
}
|
|
406
|
+
} catch (cause) {
|
|
407
|
+
throw new Error(`Transaction ${processedTx.hash} failed with duplicate nullifiers`, { cause });
|
|
399
408
|
}
|
|
400
409
|
|
|
401
410
|
const treeInsertionEnd = process.hrtime.bigint();
|