@aztec/simulator 2.0.3 → 2.1.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/public/avm/avm_memory_types.d.ts +6 -0
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +9 -2
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +21 -10
- package/package.json +15 -15
- package/src/public/avm/avm_memory_types.ts +11 -2
- package/src/public/public_processor/public_processor.ts +23 -14
|
@@ -52,6 +52,7 @@ declare const Uint1_base: {
|
|
|
52
52
|
toNumber(): number;
|
|
53
53
|
toString(): string;
|
|
54
54
|
};
|
|
55
|
+
readonly bits: number;
|
|
55
56
|
readonly mod: bigint;
|
|
56
57
|
readonly bitmask: bigint;
|
|
57
58
|
};
|
|
@@ -81,6 +82,7 @@ declare const Uint8_base: {
|
|
|
81
82
|
toNumber(): number;
|
|
82
83
|
toString(): string;
|
|
83
84
|
};
|
|
85
|
+
readonly bits: number;
|
|
84
86
|
readonly mod: bigint;
|
|
85
87
|
readonly bitmask: bigint;
|
|
86
88
|
};
|
|
@@ -110,6 +112,7 @@ declare const Uint16_base: {
|
|
|
110
112
|
toNumber(): number;
|
|
111
113
|
toString(): string;
|
|
112
114
|
};
|
|
115
|
+
readonly bits: number;
|
|
113
116
|
readonly mod: bigint;
|
|
114
117
|
readonly bitmask: bigint;
|
|
115
118
|
};
|
|
@@ -139,6 +142,7 @@ declare const Uint32_base: {
|
|
|
139
142
|
toNumber(): number;
|
|
140
143
|
toString(): string;
|
|
141
144
|
};
|
|
145
|
+
readonly bits: number;
|
|
142
146
|
readonly mod: bigint;
|
|
143
147
|
readonly bitmask: bigint;
|
|
144
148
|
};
|
|
@@ -168,6 +172,7 @@ declare const Uint64_base: {
|
|
|
168
172
|
toNumber(): number;
|
|
169
173
|
toString(): string;
|
|
170
174
|
};
|
|
175
|
+
readonly bits: number;
|
|
171
176
|
readonly mod: bigint;
|
|
172
177
|
readonly bitmask: bigint;
|
|
173
178
|
};
|
|
@@ -197,6 +202,7 @@ declare const Uint128_base: {
|
|
|
197
202
|
toNumber(): number;
|
|
198
203
|
toString(): string;
|
|
199
204
|
};
|
|
205
|
+
readonly bits: number;
|
|
200
206
|
readonly mod: bigint;
|
|
201
207
|
readonly bitmask: bigint;
|
|
202
208
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avm_memory_types.d.ts","sourceRoot":"","sources":["../../../src/public/avm/avm_memory_types.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAM3D,sEAAsE;AACtE,8BAAsB,WAAW;aACf,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW;aAClC,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW;aAClC,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW;aAClC,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW;aAElC,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO;aACjC,EAAE,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO;aAG7B,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW;aAG7B,QAAQ,IAAI,MAAM;IAC3B,MAAM,IAAI,OAAO;aAKR,QAAQ,IAAI,MAAM;IAG3B,IAAI,IAAI,EAAE;IAIV,cAAc,IAAI,YAAY;IAK9B,QAAQ,IAAI,MAAM;IAIlB,QAAQ,IAAI,MAAM;CAG1B;AAED,iFAAiF;AACjF,8BAAsB,aAAc,SAAQ,WAAW;aACrC,GAAG,CAAC,GAAG,EAAE,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OAEG;IACI,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE;IAMnD;;OAEG;IACI,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAKxD;;OAEG;IACI,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;WAMvD,MAAM,CAAC,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO;WAS3C,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,WAAW;CAqBpF"}
|
|
@@ -31,6 +31,7 @@ import { InvalidTagValueError, MemorySliceOutOfRangeError, TagCheckError } from
|
|
|
31
31
|
* In TypeScript terms, it's a class mixin.
|
|
32
32
|
**/ function UnsignedIntegerClassFactory(bits) {
|
|
33
33
|
return class NewUintClass extends IntegralValue {
|
|
34
|
+
static bits = bits;
|
|
34
35
|
static mod = 1n << BigInt(bits);
|
|
35
36
|
static bitmask = this.mod - 1n;
|
|
36
37
|
n;
|
|
@@ -58,11 +59,17 @@ import { InvalidTagValueError, MemorySliceOutOfRangeError, TagCheckError } from
|
|
|
58
59
|
}
|
|
59
60
|
// No sign extension.
|
|
60
61
|
shr(rhs) {
|
|
61
|
-
// Note that this.n is
|
|
62
|
+
// Note that this.n is >= 0 by class invariant.
|
|
62
63
|
return this.build(this.n >> rhs.n);
|
|
63
64
|
}
|
|
64
65
|
shl(rhs) {
|
|
65
|
-
|
|
66
|
+
const shiftAmount = rhs.n;
|
|
67
|
+
const bitSize = BigInt(NewUintClass.bits);
|
|
68
|
+
// Shifting by more than the bit size always results in 0
|
|
69
|
+
if (shiftAmount >= bitSize) {
|
|
70
|
+
return this.build(0n);
|
|
71
|
+
}
|
|
72
|
+
return this.build(this.n << shiftAmount & NewUintClass.bitmask);
|
|
66
73
|
}
|
|
67
74
|
and(rhs) {
|
|
68
75
|
return this.build(this.n & rhs.n);
|
|
@@ -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,qBAAa,sBAAsB;IAE/B,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,YAAY;IACpB,SAAS,CAAC,eAAe,EAAE,eAAe;gBA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AAE,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
|
+
"version": "2.1.0-rc.2",
|
|
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.
|
|
67
|
-
"@aztec/foundation": "2.0.
|
|
68
|
-
"@aztec/noir-acvm_js": "2.0.
|
|
69
|
-
"@aztec/noir-noirc_abi": "2.0.
|
|
70
|
-
"@aztec/noir-protocol-circuits-types": "2.0.
|
|
71
|
-
"@aztec/noir-types": "2.0.
|
|
72
|
-
"@aztec/protocol-contracts": "2.0.
|
|
73
|
-
"@aztec/stdlib": "2.0.
|
|
74
|
-
"@aztec/telemetry-client": "2.0.
|
|
75
|
-
"@aztec/world-state": "2.0.
|
|
66
|
+
"@aztec/constants": "2.1.0-rc.2",
|
|
67
|
+
"@aztec/foundation": "2.1.0-rc.2",
|
|
68
|
+
"@aztec/noir-acvm_js": "2.1.0-rc.2",
|
|
69
|
+
"@aztec/noir-noirc_abi": "2.1.0-rc.2",
|
|
70
|
+
"@aztec/noir-protocol-circuits-types": "2.1.0-rc.2",
|
|
71
|
+
"@aztec/noir-types": "2.1.0-rc.2",
|
|
72
|
+
"@aztec/protocol-contracts": "2.1.0-rc.2",
|
|
73
|
+
"@aztec/stdlib": "2.1.0-rc.2",
|
|
74
|
+
"@aztec/telemetry-client": "2.1.0-rc.2",
|
|
75
|
+
"@aztec/world-state": "2.1.0-rc.2",
|
|
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.
|
|
82
|
-
"@aztec/merkle-tree": "2.0.
|
|
83
|
-
"@aztec/noir-contracts.js": "2.0.
|
|
84
|
-
"@aztec/noir-test-contracts.js": "2.0.
|
|
81
|
+
"@aztec/kv-store": "2.1.0-rc.2",
|
|
82
|
+
"@aztec/merkle-tree": "2.1.0-rc.2",
|
|
83
|
+
"@aztec/noir-contracts.js": "2.1.0-rc.2",
|
|
84
|
+
"@aztec/noir-test-contracts.js": "2.1.0-rc.2",
|
|
85
85
|
"@jest/globals": "^30.0.0",
|
|
86
86
|
"@types/jest": "^30.0.0",
|
|
87
87
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
@@ -74,6 +74,7 @@ export abstract class IntegralValue extends MemoryValue {
|
|
|
74
74
|
**/
|
|
75
75
|
function UnsignedIntegerClassFactory(bits: number) {
|
|
76
76
|
return class NewUintClass extends IntegralValue {
|
|
77
|
+
static readonly bits: number = bits;
|
|
77
78
|
static readonly mod: bigint = 1n << BigInt(bits);
|
|
78
79
|
static readonly bitmask: bigint = this.mod - 1n;
|
|
79
80
|
public readonly n: bigint; // Cannot be private due to TS limitations.
|
|
@@ -108,12 +109,20 @@ function UnsignedIntegerClassFactory(bits: number) {
|
|
|
108
109
|
|
|
109
110
|
// No sign extension.
|
|
110
111
|
public shr(rhs: NewUintClass): NewUintClass {
|
|
111
|
-
// Note that this.n is
|
|
112
|
+
// Note that this.n is >= 0 by class invariant.
|
|
112
113
|
return this.build(this.n >> rhs.n);
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
public shl(rhs: NewUintClass): NewUintClass {
|
|
116
|
-
|
|
117
|
+
const shiftAmount = rhs.n;
|
|
118
|
+
const bitSize = BigInt(NewUintClass.bits);
|
|
119
|
+
|
|
120
|
+
// Shifting by more than the bit size always results in 0
|
|
121
|
+
if (shiftAmount >= bitSize) {
|
|
122
|
+
return this.build(0n);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return this.build((this.n << shiftAmount) & NewUintClass.bitmask);
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
public and(rhs: NewUintClass): NewUintClass {
|
|
@@ -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();
|