@aztec/sequencer-client 0.15.0 → 0.16.0
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/block_builder/solo_block_builder.d.ts.map +1 -1
- package/dest/block_builder/solo_block_builder.js +5 -3
- package/dest/client/sequencer-client.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +11 -6
- package/dest/publisher/viem-tx-sender.d.ts.map +1 -1
- package/dest/publisher/viem-tx-sender.js +6 -5
- package/dest/sequencer/config.d.ts +1 -17
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/public_processor.d.ts +6 -6
- package/dest/sequencer/public_processor.d.ts.map +1 -1
- package/dest/sequencer/public_processor.js +32 -24
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +19 -10
- package/dest/simulator/public_executor.d.ts +35 -9
- package/dest/simulator/public_executor.d.ts.map +1 -1
- package/dest/simulator/public_executor.js +31 -17
- package/dest/simulator/public_kernel.d.ts +2 -2
- package/dest/simulator/public_kernel.d.ts.map +1 -1
- package/dest/simulator/public_kernel.js +7 -5
- package/dest/simulator/rollup.d.ts +2 -2
- package/dest/simulator/rollup.d.ts.map +1 -1
- package/dest/simulator/rollup.js +5 -10
- package/package.json +12 -13
- package/src/block_builder/solo_block_builder.ts +6 -2
- package/src/client/sequencer-client.ts +2 -2
- package/src/index.ts +1 -1
- package/src/publisher/l1-publisher.ts +15 -5
- package/src/publisher/viem-tx-sender.ts +6 -4
- package/src/sequencer/config.ts +1 -17
- package/src/sequencer/public_processor.ts +38 -29
- package/src/sequencer/sequencer.ts +27 -9
- package/src/simulator/public_executor.ts +34 -33
- package/src/simulator/public_kernel.ts +8 -4
- package/src/simulator/rollup.ts +4 -11
|
@@ -2,9 +2,9 @@ import { createDebugLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
import { elapsed } from '@aztec/foundation/timer';
|
|
3
3
|
import { executePublicKernelPrivatePrevious, executePublicKernelPublicPrevious } from '@aztec/noir-protocol-circuits';
|
|
4
4
|
/**
|
|
5
|
-
* Implements the PublicKernelCircuitSimulator
|
|
5
|
+
* Implements the PublicKernelCircuitSimulator.
|
|
6
6
|
*/
|
|
7
|
-
export class
|
|
7
|
+
export class RealPublicKernelCircuitSimulator {
|
|
8
8
|
constructor() {
|
|
9
9
|
this.log = createDebugLogger('aztec:public-kernel-simulator');
|
|
10
10
|
}
|
|
@@ -14,8 +14,9 @@ export class WasmPublicKernelCircuitSimulator {
|
|
|
14
14
|
* @returns The public inputs as outputs of the simulation.
|
|
15
15
|
*/
|
|
16
16
|
async publicKernelCircuitPrivateInput(input) {
|
|
17
|
-
if (!input.previousKernel.publicInputs.isPrivate)
|
|
17
|
+
if (!input.previousKernel.publicInputs.isPrivate) {
|
|
18
18
|
throw new Error(`Expected private kernel previous inputs`);
|
|
19
|
+
}
|
|
19
20
|
const [duration, result] = await elapsed(() => executePublicKernelPrivatePrevious(input));
|
|
20
21
|
this.log(`Simulated public kernel circuit with private input`, {
|
|
21
22
|
eventName: 'circuit-simulation',
|
|
@@ -32,8 +33,9 @@ export class WasmPublicKernelCircuitSimulator {
|
|
|
32
33
|
* @returns The public inputs as outputs of the simulation.
|
|
33
34
|
*/
|
|
34
35
|
async publicKernelCircuitNonFirstIteration(input) {
|
|
35
|
-
if (input.previousKernel.publicInputs.isPrivate)
|
|
36
|
+
if (input.previousKernel.publicInputs.isPrivate) {
|
|
36
37
|
throw new Error(`Expected public kernel previous inputs`);
|
|
38
|
+
}
|
|
37
39
|
const [duration, result] = await elapsed(() => executePublicKernelPublicPrevious(input));
|
|
38
40
|
this.log(`Simulated public kernel circuit non-first iteration`, {
|
|
39
41
|
eventName: 'circuit-simulation',
|
|
@@ -45,4 +47,4 @@ export class WasmPublicKernelCircuitSimulator {
|
|
|
45
47
|
return result;
|
|
46
48
|
}
|
|
47
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UssQ0FBQyxRQUFRLEVBQUUsQ0FBQyxNQUFNO1lBQ2xDLFVBQVUsRUFBRSxNQUFNLENBQUMsUUFBUSxFQUFFLENBQUMsTUFBTTtTQUNKLENBQUMsQ0FBQztRQUNwQyxPQUFPLE1BQU0sQ0FBQztJQUNoQixDQUFDO0lBRUQ7Ozs7T0FJRztJQUNJLEtBQUssQ0FBQyxvQ0FBb0MsQ0FBQyxLQUF5QjtRQUN6RSxJQUFJLEtBQUssQ0FBQyxjQUFjLENBQUMsWUFBWSxDQUFDLFNBQVMsRUFBRTtZQUMvQyxNQUFNLElBQUksS0FBSyxDQUFDLHdDQUF3QyxDQUFDLENBQUM7U0FDM0Q7UUFDRCxNQUFNLENBQUMsUUFBUSxFQUFFLE1BQU0sQ0FBQyxHQUFHLE1BQU0sT0FBTyxDQUFDLEdBQUcsRUFBRSxDQUFDLGlDQUFpQyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUM7UUFDekYsSUFBSSxDQUFDLEdBQUcsQ0FBQyxxREFBcUQsRUFBRTtZQUM5RCxTQUFTLEVBQUUsb0JBQW9CO1lBQy9CLFdBQVcsRUFBRSxtQ0FBbUM7WUFDaEQsUUFBUTtZQUNSLFNBQVMsRUFBRSxLQUFLLENBQUMsUUFBUSxFQUFFLENBQUMsTUFBTTtZQUNsQyxVQUFVLEVBQUUsTUFBTSxDQUFDLFFBQVEsRUFBRSxDQUFDLE1BQU07U0FDSixDQUFDLENBQUM7UUFDcEMsT0FBTyxNQUFNLENBQUM7SUFDaEIsQ0FBQztDQUNGIn0=
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseOrMergeRollupPublicInputs, BaseRollupInputs, MergeRollupInputs, RootRollupInputs, RootRollupPublicInputs } from '@aztec/circuits.js';
|
|
2
2
|
import { RollupSimulator } from './index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Implements the rollup circuit simulator
|
|
4
|
+
* Implements the rollup circuit simulator.
|
|
5
5
|
*/
|
|
6
|
-
export declare class
|
|
6
|
+
export declare class RealRollupCircuitSimulator implements RollupSimulator {
|
|
7
7
|
private log;
|
|
8
8
|
/**
|
|
9
9
|
* Simulates the base rollup circuit from its inputs.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/simulator/rollup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,
|
|
1
|
+
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/simulator/rollup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;GAEG;AACH,qBAAa,0BAA2B,YAAW,eAAe;IAChE,OAAO,CAAC,GAAG,CAA+C;IAE1D;;;;OAIG;IACU,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAa/F;;;;OAIG;IACU,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAcjG;;;;OAIG;IACU,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAazF"}
|
package/dest/simulator/rollup.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { CircuitError, CircuitsWasm, baseRollupSim, } from '@aztec/circuits.js';
|
|
2
1
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
3
2
|
import { elapsed } from '@aztec/foundation/timer';
|
|
4
|
-
import { executeMergeRollup, executeRootRollup } from '@aztec/noir-protocol-circuits';
|
|
3
|
+
import { executeBaseRollup, executeMergeRollup, executeRootRollup } from '@aztec/noir-protocol-circuits';
|
|
5
4
|
/**
|
|
6
|
-
* Implements the rollup circuit simulator
|
|
5
|
+
* Implements the rollup circuit simulator.
|
|
7
6
|
*/
|
|
8
|
-
export class
|
|
7
|
+
export class RealRollupCircuitSimulator {
|
|
9
8
|
constructor() {
|
|
10
9
|
this.log = createDebugLogger('aztec:rollup-simulator');
|
|
11
10
|
}
|
|
@@ -15,11 +14,7 @@ export class WasmRollupCircuitSimulator {
|
|
|
15
14
|
* @returns The public inputs as outputs of the simulation.
|
|
16
15
|
*/
|
|
17
16
|
async baseRollupCircuit(input) {
|
|
18
|
-
const
|
|
19
|
-
const [duration, result] = await elapsed(() => baseRollupSim(wasm, input));
|
|
20
|
-
if (result instanceof CircuitError) {
|
|
21
|
-
throw new CircuitError(result.code, result.message);
|
|
22
|
-
}
|
|
17
|
+
const [duration, result] = await elapsed(() => executeBaseRollup(input));
|
|
23
18
|
this.log(`Simulated base rollup circuit`, {
|
|
24
19
|
eventName: 'circuit-simulation',
|
|
25
20
|
circuitName: 'base-rollup',
|
|
@@ -62,4 +57,4 @@ export class WasmRollupCircuitSimulator {
|
|
|
62
57
|
return result;
|
|
63
58
|
}
|
|
64
59
|
}
|
|
65
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
60
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sbHVwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NpbXVsYXRvci9yb2xsdXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBT0EsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDMUQsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ2xELE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxrQkFBa0IsRUFBRSxpQkFBaUIsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBS3pHOztHQUVHO0FBQ0gsTUFBTSxPQUFPLDBCQUEwQjtJQUF2QztRQU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BUSxFQUFFLENBQUMsTUFBTTtTQUNKLENBQUMsQ0FBQztRQUVwQyxPQUFPLE1BQU0sQ0FBQztJQUNoQixDQUFDO0lBRUQ7Ozs7T0FJRztJQUNJLEtBQUssQ0FBQyxpQkFBaUIsQ0FBQyxLQUF1QjtRQUNwRCxNQUFNLENBQUMsUUFBUSxFQUFFLE1BQU0sQ0FBQyxHQUFHLE1BQU0sT0FBTyxDQUFDLEdBQUcsRUFBRSxDQUFDLGlCQUFpQixDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUM7UUFFekUsSUFBSSxDQUFDLEdBQUcsQ0FBQywrQkFBK0IsRUFBRTtZQUN4QyxTQUFTLEVBQUUsb0JBQW9CO1lBQy9CLFdBQVcsRUFBRSxhQUFhO1lBQzFCLFFBQVE7WUFDUixTQUFTLEVBQUUsS0FBSyxDQUFDLFFBQVEsRUFBRSxDQUFDLE1BQU07WUFDbEMsVUFBVSxFQUFFLE1BQU0sQ0FBQyxRQUFRLEVBQUUsQ0FBQyxNQUFNO1NBQ0osQ0FBQyxDQUFDO1FBRXBDLE9BQU8sTUFBTSxDQUFDO0lBQ2hCLENBQUM7Q0FDRiJ9
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/sequencer-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"typedocOptions": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"build:dev": "tsc -b --watch",
|
|
16
16
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
17
17
|
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
18
|
-
"formatting:fix": "run -T prettier -w ./src",
|
|
18
|
+
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
19
19
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests",
|
|
20
20
|
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
|
|
21
21
|
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
"rootDir": "./src"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@aztec/acir-simulator": "0.
|
|
36
|
-
"@aztec/circuits.js": "0.
|
|
37
|
-
"@aztec/ethereum": "0.
|
|
38
|
-
"@aztec/foundation": "0.
|
|
39
|
-
"@aztec/l1-artifacts": "0.
|
|
40
|
-
"@aztec/merkle-tree": "0.
|
|
41
|
-
"@aztec/noir-protocol-circuits": "0.
|
|
42
|
-
"@aztec/p2p": "0.
|
|
43
|
-
"@aztec/types": "0.
|
|
44
|
-
"@aztec/world-state": "0.
|
|
35
|
+
"@aztec/acir-simulator": "0.16.0",
|
|
36
|
+
"@aztec/circuits.js": "0.16.0",
|
|
37
|
+
"@aztec/ethereum": "0.16.0",
|
|
38
|
+
"@aztec/foundation": "0.16.0",
|
|
39
|
+
"@aztec/l1-artifacts": "0.16.0",
|
|
40
|
+
"@aztec/merkle-tree": "0.16.0",
|
|
41
|
+
"@aztec/noir-protocol-circuits": "0.16.0",
|
|
42
|
+
"@aztec/p2p": "0.16.0",
|
|
43
|
+
"@aztec/types": "0.16.0",
|
|
44
|
+
"@aztec/world-state": "0.16.0",
|
|
45
45
|
"lodash.chunk": "^4.2.0",
|
|
46
46
|
"lodash.flatmap": "^4.5.0",
|
|
47
47
|
"lodash.pick": "^4.4.0",
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@jest/globals": "^29.5.0",
|
|
54
|
-
"@rushstack/eslint-patch": "^1.1.4",
|
|
55
54
|
"@types/jest": "^29.5.0",
|
|
56
55
|
"@types/levelup": "^5.1.2",
|
|
57
56
|
"@types/lodash.chunk": "^4.2.7",
|
|
@@ -527,7 +527,9 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
527
527
|
height: N,
|
|
528
528
|
): Promise<MembershipWitness<N>> {
|
|
529
529
|
// If this is an empty tx, then just return zeroes
|
|
530
|
-
if (value.isZero())
|
|
530
|
+
if (value.isZero()) {
|
|
531
|
+
return this.makeEmptyMembershipWitness(height);
|
|
532
|
+
}
|
|
531
533
|
|
|
532
534
|
const index = await this.db.findLeafIndex(treeId, value.toBuffer());
|
|
533
535
|
if (index === undefined) {
|
|
@@ -576,7 +578,9 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
576
578
|
const tree = MerkleTreeId.NULLIFIER_TREE;
|
|
577
579
|
const prevValueIndex = await this.db.getPreviousValueIndex(tree, frToBigInt(nullifier));
|
|
578
580
|
const prevValueInfo = await this.db.getLeafData(tree, prevValueIndex.index);
|
|
579
|
-
if (!prevValueInfo)
|
|
581
|
+
if (!prevValueInfo) {
|
|
582
|
+
throw new Error(`Nullifier tree should have one initial leaf`);
|
|
583
|
+
}
|
|
580
584
|
const prevValueSiblingPath = await this.db.getSiblingPath(tree, BigInt(prevValueIndex.index));
|
|
581
585
|
|
|
582
586
|
return {
|
|
@@ -8,7 +8,7 @@ import { getGlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
|
8
8
|
import { Sequencer, SequencerConfig, getL1Publisher, getVerificationKeys } from '../index.js';
|
|
9
9
|
import { EmptyRollupProver } from '../prover/empty.js';
|
|
10
10
|
import { PublicProcessorFactory } from '../sequencer/public_processor.js';
|
|
11
|
-
import {
|
|
11
|
+
import { RealRollupCircuitSimulator } from '../simulator/rollup.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Encapsulates the full sequencer and publisher.
|
|
@@ -41,7 +41,7 @@ export class SequencerClient {
|
|
|
41
41
|
const blockBuilder = new SoloBlockBuilder(
|
|
42
42
|
merkleTreeDb,
|
|
43
43
|
getVerificationKeys(),
|
|
44
|
-
new
|
|
44
|
+
new RealRollupCircuitSimulator(),
|
|
45
45
|
new EmptyRollupProver(),
|
|
46
46
|
);
|
|
47
47
|
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from './sequencer/public_processor.js';
|
|
|
9
9
|
export * from './global_variable_builder/index.js';
|
|
10
10
|
|
|
11
11
|
// Used by publisher test in e2e
|
|
12
|
-
export {
|
|
12
|
+
export { RealRollupCircuitSimulator } from './simulator/rollup.js';
|
|
13
13
|
export { EmptyRollupProver } from './prover/empty.js';
|
|
14
14
|
export { SoloBlockBuilder } from './block_builder/solo_block_builder.js';
|
|
15
15
|
export { makeProcessedTx, makeEmptyProcessedTx } from './sequencer/processed_tx.js';
|
|
@@ -134,10 +134,14 @@ export class L1Publisher implements L2BlockReceiver {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
const txHash = await this.sendProcessTx(txData);
|
|
137
|
-
if (!txHash)
|
|
137
|
+
if (!txHash) {
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
138
140
|
|
|
139
141
|
const receipt = await this.getTransactionReceipt(txHash);
|
|
140
|
-
if (!receipt)
|
|
142
|
+
if (!receipt) {
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
141
145
|
|
|
142
146
|
// Tx was mined successfully
|
|
143
147
|
if (receipt.status) {
|
|
@@ -184,17 +188,23 @@ export class L1Publisher implements L2BlockReceiver {
|
|
|
184
188
|
|
|
185
189
|
const arr = _contractData.length ? _contractData : contractData;
|
|
186
190
|
const txHashes = await this.sendEmitNewContractDataTx(l2BlockNum, l2BlockHash, arr);
|
|
187
|
-
if (!txHashes)
|
|
191
|
+
if (!txHashes) {
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
188
194
|
// filter successful txs
|
|
189
195
|
_contractData = arr.filter((_, i) => !!txHashes[i]);
|
|
190
196
|
|
|
191
197
|
const receipts = await Promise.all(
|
|
192
198
|
txHashes.filter(isNotUndefined).map(txHash => this.getTransactionReceipt(txHash)),
|
|
193
199
|
);
|
|
194
|
-
if (!receipts?.length)
|
|
200
|
+
if (!receipts?.length) {
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
195
203
|
|
|
196
204
|
// ALL Txs were mined successfully
|
|
197
|
-
if (receipts.length === contractData.length && receipts.every(r => r?.status))
|
|
205
|
+
if (receipts.length === contractData.length && receipts.every(r => r?.status)) {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
198
208
|
|
|
199
209
|
this.log(
|
|
200
210
|
`Transaction status failed: ${receipts
|
|
@@ -77,7 +77,9 @@ export class ViemTxSender implements L1PublisherTxSender {
|
|
|
77
77
|
|
|
78
78
|
async getTransactionStats(txHash: string): Promise<TransactionStats | undefined> {
|
|
79
79
|
const tx = await this.publicClient.getTransaction({ hash: txHash as Hex });
|
|
80
|
-
if (!tx)
|
|
80
|
+
if (!tx) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
81
83
|
const calldata = hexToBytes(tx.input);
|
|
82
84
|
return {
|
|
83
85
|
transactionHash: tx.hash,
|
|
@@ -146,9 +148,9 @@ export class ViemTxSender implements L1PublisherTxSender {
|
|
|
146
148
|
extendedContractData.contractData.contractAddress.toString() as Hex,
|
|
147
149
|
extendedContractData.contractData.portalContractAddress.toString() as Hex,
|
|
148
150
|
`0x${l2BlockHash.toString('hex')}`,
|
|
149
|
-
extendedContractData.partialAddress.toString(
|
|
150
|
-
extendedContractData.publicKey.x.toString(
|
|
151
|
-
extendedContractData.publicKey.y.toString(
|
|
151
|
+
extendedContractData.partialAddress.toString(),
|
|
152
|
+
extendedContractData.publicKey.x.toString(),
|
|
153
|
+
extendedContractData.publicKey.y.toString(),
|
|
152
154
|
`0x${extendedContractData.bytecode.toString('hex')}`,
|
|
153
155
|
] as const;
|
|
154
156
|
|
package/src/sequencer/config.ts
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* The sequencer configuration.
|
|
3
|
-
*/
|
|
4
|
-
export interface SequencerConfig {
|
|
5
|
-
/**
|
|
6
|
-
* The number of ms to wait between polling for pending txs.
|
|
7
|
-
*/
|
|
8
|
-
transactionPollingIntervalMS?: number;
|
|
9
|
-
/**
|
|
10
|
-
* The maximum number of txs to include in a block.
|
|
11
|
-
*/
|
|
12
|
-
maxTxsPerBlock?: number;
|
|
13
|
-
/**
|
|
14
|
-
* The minimum number of txs to include in a block.
|
|
15
|
-
*/
|
|
16
|
-
minTxsPerBlock?: number;
|
|
17
|
-
}
|
|
1
|
+
export { SequencerConfig } from '@aztec/types';
|
|
@@ -2,13 +2,14 @@ import {
|
|
|
2
2
|
PublicExecution,
|
|
3
3
|
PublicExecutionResult,
|
|
4
4
|
PublicExecutor,
|
|
5
|
+
PublicStateDB,
|
|
5
6
|
collectPublicDataReads,
|
|
6
7
|
collectPublicDataUpdateRequests,
|
|
7
8
|
isPublicExecutionResult,
|
|
8
9
|
} from '@aztec/acir-simulator';
|
|
9
10
|
import {
|
|
10
11
|
AztecAddress,
|
|
11
|
-
|
|
12
|
+
CallRequest,
|
|
12
13
|
CombinedAccumulatedData,
|
|
13
14
|
ContractStorageRead,
|
|
14
15
|
ContractStorageUpdateRequest,
|
|
@@ -37,10 +38,10 @@ import {
|
|
|
37
38
|
RETURN_VALUES_LENGTH,
|
|
38
39
|
VK_TREE_HEIGHT,
|
|
39
40
|
} from '@aztec/circuits.js';
|
|
40
|
-
import {
|
|
41
|
+
import { computeVarArgsHash } from '@aztec/circuits.js/abis';
|
|
41
42
|
import { arrayNonEmptyLength, isArrayEmpty, padArrayEnd } from '@aztec/foundation/collection';
|
|
42
43
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
43
|
-
import {
|
|
44
|
+
import { to2Fields } from '@aztec/foundation/serialize';
|
|
44
45
|
import { ContractDataSource, FunctionL2Logs, L1ToL2MessageSource, MerkleTreeId, Tx } from '@aztec/types';
|
|
45
46
|
import { MerkleTreeOperations } from '@aztec/world-state';
|
|
46
47
|
|
|
@@ -48,8 +49,8 @@ import { getVerificationKeys } from '../index.js';
|
|
|
48
49
|
import { EmptyPublicProver } from '../prover/empty.js';
|
|
49
50
|
import { PublicProver } from '../prover/index.js';
|
|
50
51
|
import { PublicKernelCircuitSimulator } from '../simulator/index.js';
|
|
51
|
-
import { ContractsDataSourcePublicDB,
|
|
52
|
-
import {
|
|
52
|
+
import { ContractsDataSourcePublicDB, WorldStateDB, WorldStatePublicDB } from '../simulator/public_executor.js';
|
|
53
|
+
import { RealPublicKernelCircuitSimulator } from '../simulator/public_kernel.js';
|
|
53
54
|
import { FailedTx, ProcessedTx, makeEmptyProcessedTx, makeProcessedTx } from './processed_tx.js';
|
|
54
55
|
import { getHistoricBlockData } from './utils.js';
|
|
55
56
|
|
|
@@ -76,14 +77,18 @@ export class PublicProcessorFactory {
|
|
|
76
77
|
): Promise<PublicProcessor> {
|
|
77
78
|
const blockData = await getHistoricBlockData(this.merkleTree, prevGlobalVariables);
|
|
78
79
|
const publicContractsDB = new ContractsDataSourcePublicDB(this.contractDataSource);
|
|
80
|
+
const worldStatePublicDB = new WorldStatePublicDB(this.merkleTree);
|
|
81
|
+
const worldStateDB = new WorldStateDB(this.merkleTree, this.l1Tol2MessagesDataSource);
|
|
82
|
+
const publicExecutor = new PublicExecutor(worldStatePublicDB, publicContractsDB, worldStateDB, blockData);
|
|
79
83
|
return new PublicProcessor(
|
|
80
84
|
this.merkleTree,
|
|
81
|
-
|
|
82
|
-
new
|
|
85
|
+
publicExecutor,
|
|
86
|
+
new RealPublicKernelCircuitSimulator(),
|
|
83
87
|
new EmptyPublicProver(),
|
|
84
88
|
globalVariables,
|
|
85
89
|
blockData,
|
|
86
90
|
publicContractsDB,
|
|
91
|
+
worldStatePublicDB,
|
|
87
92
|
);
|
|
88
93
|
}
|
|
89
94
|
}
|
|
@@ -101,6 +106,7 @@ export class PublicProcessor {
|
|
|
101
106
|
protected globalVariables: GlobalVariables,
|
|
102
107
|
protected blockData: HistoricBlockData,
|
|
103
108
|
protected publicContractsDB: ContractsDataSourcePublicDB,
|
|
109
|
+
protected publicStateDB: PublicStateDB,
|
|
104
110
|
|
|
105
111
|
private log = createDebugLogger('aztec:sequencer:public-processor'),
|
|
106
112
|
) {}
|
|
@@ -122,6 +128,8 @@ export class PublicProcessor {
|
|
|
122
128
|
// add new contracts to the contracts db so that their functions may be found and called
|
|
123
129
|
await this.publicContractsDB.addNewContracts(tx);
|
|
124
130
|
result.push(await this.processTx(tx));
|
|
131
|
+
// commit the state updates from this transaction
|
|
132
|
+
await this.publicStateDB.commit();
|
|
125
133
|
} catch (err) {
|
|
126
134
|
this.log.warn(`Error processing tx ${await tx.getTxHash()}: ${err}`);
|
|
127
135
|
failed.push({
|
|
@@ -130,6 +138,8 @@ export class PublicProcessor {
|
|
|
130
138
|
});
|
|
131
139
|
// remove contracts on failure
|
|
132
140
|
await this.publicContractsDB.removeNewContracts(tx);
|
|
141
|
+
// rollback any state updates from this failed transaction
|
|
142
|
+
await this.publicStateDB.rollback();
|
|
133
143
|
}
|
|
134
144
|
}
|
|
135
145
|
|
|
@@ -146,7 +156,7 @@ export class PublicProcessor {
|
|
|
146
156
|
}
|
|
147
157
|
|
|
148
158
|
protected async processTx(tx: Tx): Promise<ProcessedTx> {
|
|
149
|
-
if (!isArrayEmpty(tx.data.end.publicCallStack, item => item.
|
|
159
|
+
if (!isArrayEmpty(tx.data.end.publicCallStack, item => item.isEmpty())) {
|
|
150
160
|
const [publicKernelOutput, publicKernelProof, newUnencryptedFunctionLogs] = await this.processEnqueuedPublicCalls(
|
|
151
161
|
tx,
|
|
152
162
|
);
|
|
@@ -160,7 +170,9 @@ export class PublicProcessor {
|
|
|
160
170
|
|
|
161
171
|
protected async processEnqueuedPublicCalls(tx: Tx): Promise<[PublicKernelPublicInputs, Proof, FunctionL2Logs[]]> {
|
|
162
172
|
this.log(`Executing enqueued public calls for tx ${await tx.getTxHash()}`);
|
|
163
|
-
if (!tx.enqueuedPublicFunctionCalls)
|
|
173
|
+
if (!tx.enqueuedPublicFunctionCalls) {
|
|
174
|
+
throw new Error(`Missing preimages for enqueued public calls`);
|
|
175
|
+
}
|
|
164
176
|
|
|
165
177
|
let kernelOutput = new KernelCircuitPublicInputs(
|
|
166
178
|
CombinedAccumulatedData.fromFinalAccumulatedData(tx.data.end),
|
|
@@ -192,12 +204,13 @@ export class PublicProcessor {
|
|
|
192
204
|
`Running public kernel circuit for ${functionSelector}@${result.execution.contractAddress.toString()}`,
|
|
193
205
|
);
|
|
194
206
|
executionStack.push(...result.nestedExecutions);
|
|
195
|
-
const
|
|
196
|
-
const callData = await this.getPublicCallData(result, preimages, isExecutionRequest);
|
|
207
|
+
const callData = await this.getPublicCallData(result, isExecutionRequest);
|
|
197
208
|
|
|
198
209
|
[kernelOutput, kernelProof] = await this.runKernelCircuit(callData, kernelOutput, kernelProof);
|
|
199
210
|
|
|
200
|
-
if (!enqueuedExecutionResult)
|
|
211
|
+
if (!enqueuedExecutionResult) {
|
|
212
|
+
enqueuedExecutionResult = result;
|
|
213
|
+
}
|
|
201
214
|
}
|
|
202
215
|
// HACK(#1622): Manually patches the ordering of public state actions
|
|
203
216
|
// TODO(#757): Enforce proper ordering of public state actions
|
|
@@ -249,10 +262,10 @@ export class PublicProcessor {
|
|
|
249
262
|
this.blockData.publicDataTreeRoot = Fr.fromBuffer(publicDataTreeInfo.root);
|
|
250
263
|
|
|
251
264
|
const callStackPreimages = await this.getPublicCallStackPreimages(result);
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
265
|
+
const publicCallStackHashes = padArrayEnd(
|
|
266
|
+
callStackPreimages.map(c => c.hash()),
|
|
267
|
+
Fr.ZERO,
|
|
268
|
+
MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL,
|
|
256
269
|
);
|
|
257
270
|
|
|
258
271
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165) --> set this in Noir
|
|
@@ -277,7 +290,7 @@ export class PublicProcessor {
|
|
|
277
290
|
ContractStorageUpdateRequest.empty(),
|
|
278
291
|
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
|
|
279
292
|
),
|
|
280
|
-
|
|
293
|
+
publicCallStackHashes,
|
|
281
294
|
unencryptedLogsHash,
|
|
282
295
|
unencryptedLogPreimagesLength,
|
|
283
296
|
historicBlockData: this.blockData,
|
|
@@ -293,17 +306,15 @@ export class PublicProcessor {
|
|
|
293
306
|
);
|
|
294
307
|
}
|
|
295
308
|
|
|
296
|
-
protected async getPublicCallStackPreimages(result: PublicExecutionResult) {
|
|
309
|
+
protected async getPublicCallStackPreimages(result: PublicExecutionResult): Promise<PublicCallStackItem[]> {
|
|
297
310
|
const nested = result.nestedExecutions;
|
|
298
|
-
|
|
299
|
-
if (preimages.length > MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL) {
|
|
311
|
+
if (nested.length > MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL) {
|
|
300
312
|
throw new Error(
|
|
301
|
-
`Public call stack size exceeded (max ${MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL}, got ${
|
|
313
|
+
`Public call stack size exceeded (max ${MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL}, got ${nested.length})`,
|
|
302
314
|
);
|
|
303
315
|
}
|
|
304
316
|
|
|
305
|
-
|
|
306
|
-
return padArrayEnd(preimages, PublicCallStackItem.empty(), MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL);
|
|
317
|
+
return await Promise.all(nested.map(n => this.getPublicCallStackItem(n)));
|
|
307
318
|
}
|
|
308
319
|
|
|
309
320
|
protected getBytecodeHash(_result: PublicExecutionResult) {
|
|
@@ -321,16 +332,14 @@ export class PublicProcessor {
|
|
|
321
332
|
* @param isExecutionRequest - Whether the current callstack item should be considered a public fn execution request.
|
|
322
333
|
* @returns A corresponding PublicCallData object.
|
|
323
334
|
*/
|
|
324
|
-
protected async getPublicCallData(
|
|
325
|
-
result: PublicExecutionResult,
|
|
326
|
-
preimages: Tuple<PublicCallStackItem, typeof MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL>,
|
|
327
|
-
isExecutionRequest = false,
|
|
328
|
-
) {
|
|
335
|
+
protected async getPublicCallData(result: PublicExecutionResult, isExecutionRequest = false) {
|
|
329
336
|
const bytecodeHash = await this.getBytecodeHash(result);
|
|
330
337
|
const callStackItem = await this.getPublicCallStackItem(result, isExecutionRequest);
|
|
338
|
+
const publicCallRequests = (await this.getPublicCallStackPreimages(result)).map(c => c.toCallRequest());
|
|
339
|
+
const publicCallStack = padArrayEnd(publicCallRequests, CallRequest.empty(), MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL);
|
|
331
340
|
const portalContractAddress = result.execution.callContext.portalContractAddress.toField();
|
|
332
341
|
const proof = await this.publicProver.getPublicCircuitProof(callStackItem.publicInputs);
|
|
333
|
-
return new PublicCallData(callStackItem,
|
|
342
|
+
return new PublicCallData(callStackItem, publicCallStack, proof, portalContractAddress, bytecodeHash);
|
|
334
343
|
}
|
|
335
344
|
|
|
336
345
|
// HACK(#1622): this is a hack to fix ordering of public state in the call stack. Since the private kernel
|
|
@@ -56,9 +56,15 @@ export class Sequencer {
|
|
|
56
56
|
* @param config - New parameters.
|
|
57
57
|
*/
|
|
58
58
|
public updateConfig(config: SequencerConfig) {
|
|
59
|
-
if (config.transactionPollingIntervalMS)
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
if (config.transactionPollingIntervalMS) {
|
|
60
|
+
this.pollingIntervalMs = config.transactionPollingIntervalMS;
|
|
61
|
+
}
|
|
62
|
+
if (config.maxTxsPerBlock) {
|
|
63
|
+
this.maxTxsPerBlock = config.maxTxsPerBlock;
|
|
64
|
+
}
|
|
65
|
+
if (config.minTxsPerBlock) {
|
|
66
|
+
this.minTxsPerBLock = config.minTxsPerBlock;
|
|
67
|
+
}
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
/**
|
|
@@ -119,14 +125,18 @@ export class Sequencer {
|
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
// Do not go forward with new block if the previous one has not been mined and processed
|
|
122
|
-
if (!prevBlockSynced)
|
|
128
|
+
if (!prevBlockSynced) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
123
131
|
|
|
124
132
|
const workTimer = new Timer();
|
|
125
133
|
this.state = SequencerState.WAITING_FOR_TXS;
|
|
126
134
|
|
|
127
135
|
// Get txs to build the new block
|
|
128
136
|
const pendingTxs = await this.p2pClient.getTxs();
|
|
129
|
-
if (pendingTxs.length < this.minTxsPerBLock)
|
|
137
|
+
if (pendingTxs.length < this.minTxsPerBLock) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
130
140
|
this.log.info(`Retrieved ${pendingTxs.length} txs from P2P pool`);
|
|
131
141
|
|
|
132
142
|
const blockNumber = (await this.l2BlockSource.getBlockNumber()) + 1;
|
|
@@ -146,7 +156,9 @@ export class Sequencer {
|
|
|
146
156
|
// Filter out invalid txs
|
|
147
157
|
// TODO: It should be responsibility of the P2P layer to validate txs before passing them on here
|
|
148
158
|
const validTxs = await this.takeValidTxs(pendingTxs, newGlobalVariables);
|
|
149
|
-
if (validTxs.length < this.minTxsPerBLock)
|
|
159
|
+
if (validTxs.length < this.minTxsPerBLock) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
150
162
|
|
|
151
163
|
this.log.info(`Building block ${blockNumber} with ${validTxs.length} transactions`);
|
|
152
164
|
this.state = SequencerState.CREATING_BLOCK;
|
|
@@ -284,7 +296,9 @@ export class Sequencer {
|
|
|
284
296
|
|
|
285
297
|
tx.data.end.newNullifiers.forEach(n => thisBlockNullifiers.add(n.toBigInt()));
|
|
286
298
|
validTxs.push(tx);
|
|
287
|
-
if (validTxs.length >= this.maxTxsPerBlock)
|
|
299
|
+
if (validTxs.length >= this.maxTxsPerBlock) {
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
288
302
|
}
|
|
289
303
|
|
|
290
304
|
// Make sure we remove these from the tx pool so we do not consider it again
|
|
@@ -373,13 +387,17 @@ export class Sequencer {
|
|
|
373
387
|
|
|
374
388
|
// Ditch this tx if it has a repeated nullifiers
|
|
375
389
|
const uniqNullifiers = new Set(newNullifiers.map(n => n.toBigInt()));
|
|
376
|
-
if (uniqNullifiers.size !== newNullifiers.length)
|
|
390
|
+
if (uniqNullifiers.size !== newNullifiers.length) {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
377
393
|
|
|
378
394
|
for (const nullifier of newNullifiers) {
|
|
379
395
|
// TODO(AD): this is an exhaustive search currently
|
|
380
396
|
const db = this.worldState.getLatest();
|
|
381
397
|
const indexInDb = await db.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer());
|
|
382
|
-
if (indexInDb !== undefined)
|
|
398
|
+
if (indexInDb !== undefined) {
|
|
399
|
+
return true;
|
|
400
|
+
}
|
|
383
401
|
}
|
|
384
402
|
return false;
|
|
385
403
|
}
|