@aztec/sequencer-client 0.0.1-commit.a072138 → 0.0.1-commit.a89ec08
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/sequencer-client.d.ts +16 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +56 -23
- package/dest/config.d.ts +25 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +46 -28
- package/dest/global_variable_builder/global_builder.d.ts +14 -10
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +22 -21
- package/dest/global_variable_builder/index.d.ts +2 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +31 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +101 -42
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +13 -2
- package/dest/publisher/sequencer-publisher.d.ts +29 -13
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +106 -57
- package/dest/sequencer/checkpoint_proposal_job.d.ts +10 -4
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +162 -107
- package/dest/sequencer/checkpoint_voter.d.ts +1 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +2 -5
- package/dest/sequencer/metrics.d.ts +17 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +86 -15
- package/dest/sequencer/sequencer.d.ts +29 -13
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +47 -43
- package/dest/sequencer/timetable.d.ts +4 -6
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +7 -11
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +3 -5
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +11 -11
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +47 -34
- package/dest/test/utils.d.ts +3 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +5 -4
- package/package.json +28 -28
- package/src/client/sequencer-client.ts +78 -21
- package/src/config.ts +61 -38
- package/src/global_variable_builder/global_builder.ts +23 -24
- package/src/global_variable_builder/index.ts +1 -1
- package/src/publisher/config.ts +112 -43
- package/src/publisher/sequencer-publisher-factory.ts +23 -6
- package/src/publisher/sequencer-publisher.ts +123 -71
- package/src/sequencer/checkpoint_proposal_job.ts +238 -136
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/metrics.ts +92 -18
- package/src/sequencer/sequencer.ts +60 -49
- package/src/sequencer/timetable.ts +13 -12
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +65 -49
- package/src/test/utils.ts +5 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { unfreeze } from '@aztec/foundation/types';
|
|
4
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
2
5
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
3
|
-
import { Gas } from '@aztec/stdlib/gas';
|
|
4
6
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
5
7
|
import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
6
8
|
/**
|
|
@@ -63,8 +65,10 @@ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
|
63
65
|
let block;
|
|
64
66
|
let usedTxs;
|
|
65
67
|
if (this.blockProvider) {
|
|
66
|
-
// Dynamic mode: get block from provider
|
|
67
|
-
block = this.blockProvider();
|
|
68
|
+
// Dynamic mode: get block from provider, cloning to avoid shared references across multiple buildBlock calls
|
|
69
|
+
block = L2Block.fromBuffer(this.blockProvider().toBuffer());
|
|
70
|
+
block.header.globalVariables.blockNumber = blockNumber;
|
|
71
|
+
await block.header.recomputeHash();
|
|
68
72
|
usedTxs = [];
|
|
69
73
|
this.builtBlocks.push(block);
|
|
70
74
|
} else {
|
|
@@ -87,61 +91,63 @@ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
|
87
91
|
}
|
|
88
92
|
return {
|
|
89
93
|
block,
|
|
90
|
-
publicGas: Gas.empty(),
|
|
91
94
|
publicProcessorDuration: 0,
|
|
92
95
|
numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
|
|
93
96
|
usedTxs,
|
|
94
|
-
failedTxs: []
|
|
95
|
-
usedTxBlobFields: block?.body?.txEffects?.reduce((sum, tx)=>sum + tx.getNumBlobFields(), 0) ?? 0
|
|
97
|
+
failedTxs: []
|
|
96
98
|
};
|
|
97
99
|
}
|
|
98
100
|
completeCheckpoint() {
|
|
99
101
|
this.completeCheckpointCalled = true;
|
|
100
102
|
const allBlocks = this.blockProvider ? this.builtBlocks : this.blocks;
|
|
101
|
-
|
|
102
|
-
// Create a CheckpointHeader from the last block's header for testing
|
|
103
|
-
const checkpointHeader = this.createCheckpointHeader(lastBlock);
|
|
104
|
-
return Promise.resolve(new Checkpoint(makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1), checkpointHeader, allBlocks, this.checkpointNumber));
|
|
103
|
+
return this.buildCheckpoint(allBlocks);
|
|
105
104
|
}
|
|
106
105
|
getCheckpoint() {
|
|
107
106
|
this.getCheckpointCalled = true;
|
|
108
107
|
const builtBlocks = this.blockProvider ? this.builtBlocks : this.blocks.slice(0, this.blockIndex);
|
|
109
|
-
|
|
110
|
-
if (!lastBlock) {
|
|
108
|
+
if (builtBlocks.length === 0) {
|
|
111
109
|
throw new Error('No blocks built yet');
|
|
112
110
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
111
|
+
return this.buildCheckpoint(builtBlocks);
|
|
112
|
+
}
|
|
113
|
+
/** Builds a structurally valid Checkpoint from a list of blocks, fixing up indexes and archive chaining. */ async buildCheckpoint(blocks) {
|
|
114
|
+
// Fix up indexWithinCheckpoint and archive chaining so the checkpoint passes structural validation.
|
|
115
|
+
for(let i = 0; i < blocks.length; i++){
|
|
116
|
+
blocks[i].indexWithinCheckpoint = IndexWithinCheckpoint(i);
|
|
117
|
+
if (i > 0) {
|
|
118
|
+
unfreeze(blocks[i].header).lastArchive = blocks[i - 1].archive;
|
|
119
|
+
await blocks[i].header.recomputeHash();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const firstBlock = blocks[0];
|
|
123
|
+
const lastBlock = blocks[blocks.length - 1];
|
|
124
|
+
const gv = firstBlock.header.globalVariables;
|
|
125
|
+
const checkpointHeader = CheckpointHeader.empty({
|
|
126
|
+
lastArchiveRoot: firstBlock.header.lastArchive.root,
|
|
125
127
|
blockHeadersHash: Fr.random(),
|
|
126
128
|
slotNumber: gv.slotNumber,
|
|
127
129
|
timestamp: gv.timestamp,
|
|
128
130
|
coinbase: gv.coinbase,
|
|
129
131
|
feeRecipient: gv.feeRecipient,
|
|
130
132
|
gasFees: gv.gasFees,
|
|
131
|
-
totalManaUsed: header.totalManaUsed
|
|
133
|
+
totalManaUsed: lastBlock.header.totalManaUsed
|
|
132
134
|
});
|
|
135
|
+
return new Checkpoint(makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1), checkpointHeader, blocks, this.checkpointNumber);
|
|
133
136
|
}
|
|
134
|
-
/**
|
|
135
|
-
this.blocks = [];
|
|
137
|
+
/** Resets per-checkpoint state (built blocks, consumed txs) while preserving config (blockProvider, seeded blocks). */ resetCheckpointState() {
|
|
136
138
|
this.builtBlocks = [];
|
|
137
|
-
this.usedTxsPerBlock = [];
|
|
138
139
|
this.blockIndex = 0;
|
|
139
|
-
this.buildBlockCalls = [];
|
|
140
140
|
this.consumedTxHashes.clear();
|
|
141
141
|
this.completeCheckpointCalled = false;
|
|
142
142
|
this.getCheckpointCalled = false;
|
|
143
|
+
}
|
|
144
|
+
/** Reset for reuse in another test */ reset() {
|
|
145
|
+
this.blocks = [];
|
|
146
|
+
this.usedTxsPerBlock = [];
|
|
147
|
+
this.buildBlockCalls = [];
|
|
143
148
|
this.errorOnBuild = undefined;
|
|
144
149
|
this.blockProvider = undefined;
|
|
150
|
+
this.resetCheckpointState();
|
|
145
151
|
}
|
|
146
152
|
}
|
|
147
153
|
/**
|
|
@@ -175,36 +181,43 @@ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
|
175
181
|
l1GenesisTime: 0n,
|
|
176
182
|
slotDuration: 24,
|
|
177
183
|
l1ChainId: 1,
|
|
178
|
-
rollupVersion: 1
|
|
184
|
+
rollupVersion: 1,
|
|
185
|
+
rollupManaLimit: 200_000_000
|
|
179
186
|
};
|
|
180
187
|
}
|
|
181
188
|
updateConfig(config) {
|
|
182
189
|
this.updateConfigCalls.push(config);
|
|
183
190
|
}
|
|
184
|
-
startCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, _fork) {
|
|
191
|
+
startCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, _fork) {
|
|
185
192
|
this.startCheckpointCalls.push({
|
|
186
193
|
checkpointNumber,
|
|
187
194
|
constants,
|
|
188
195
|
l1ToL2Messages,
|
|
189
|
-
previousCheckpointOutHashes
|
|
196
|
+
previousCheckpointOutHashes,
|
|
197
|
+
feeAssetPriceModifier
|
|
190
198
|
});
|
|
191
199
|
if (!this.checkpointBuilder) {
|
|
192
200
|
// Auto-create a builder if none was set
|
|
193
201
|
this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
|
|
202
|
+
} else {
|
|
203
|
+
this.checkpointBuilder.resetCheckpointState();
|
|
194
204
|
}
|
|
195
205
|
return Promise.resolve(this.checkpointBuilder);
|
|
196
206
|
}
|
|
197
|
-
openCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, _fork, existingBlocks = []) {
|
|
207
|
+
openCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, _fork, existingBlocks = []) {
|
|
198
208
|
this.openCheckpointCalls.push({
|
|
199
209
|
checkpointNumber,
|
|
200
210
|
constants,
|
|
201
211
|
l1ToL2Messages,
|
|
202
212
|
previousCheckpointOutHashes,
|
|
203
|
-
existingBlocks
|
|
213
|
+
existingBlocks,
|
|
214
|
+
feeAssetPriceModifier
|
|
204
215
|
});
|
|
205
216
|
if (!this.checkpointBuilder) {
|
|
206
217
|
// Auto-create a builder if none was set
|
|
207
218
|
this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
|
|
219
|
+
} else {
|
|
220
|
+
this.checkpointBuilder.resetCheckpointState();
|
|
208
221
|
}
|
|
209
222
|
return Promise.resolve(this.checkpointBuilder);
|
|
210
223
|
}
|
package/dest/test/utils.d.ts
CHANGED
|
@@ -35,13 +35,13 @@ export declare function createBlockProposal(block: L2Block, signature: Signature
|
|
|
35
35
|
/**
|
|
36
36
|
* Creates a checkpoint proposal from a block and signature
|
|
37
37
|
*/
|
|
38
|
-
export declare function createCheckpointProposal(block: L2Block, checkpointSignature: Signature, blockSignature?: Signature): CheckpointProposal;
|
|
38
|
+
export declare function createCheckpointProposal(block: L2Block, checkpointSignature: Signature, blockSignature?: Signature, feeAssetPriceModifier?: bigint): CheckpointProposal;
|
|
39
39
|
/**
|
|
40
40
|
* Creates a checkpoint attestation from a block and signature.
|
|
41
41
|
* Note: We manually set the sender since we use random signatures in tests.
|
|
42
42
|
* In production, the sender is recovered from the signature.
|
|
43
43
|
*/
|
|
44
|
-
export declare function createCheckpointAttestation(block: L2Block, signature: Signature, sender: EthAddress): CheckpointAttestation;
|
|
44
|
+
export declare function createCheckpointAttestation(block: L2Block, signature: Signature, sender: EthAddress, feeAssetPriceModifier?: bigint): CheckpointAttestation;
|
|
45
45
|
/**
|
|
46
46
|
* Creates transactions and a block, and mocks P2P to return them.
|
|
47
47
|
* Helper for tests that need to set up a block with transactions.
|
|
@@ -50,4 +50,4 @@ export declare function setupTxsAndBlock(p2p: MockProxy<P2P>, globalVariables: G
|
|
|
50
50
|
txs: Tx[];
|
|
51
51
|
block: L2Block;
|
|
52
52
|
}>;
|
|
53
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSwyQ0FBMkMsQ0FBQztBQUM1RSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDaEUsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzVELE9BQU8sS0FBSyxFQUFFLEdBQUcsRUFBRSxNQUFNLFlBQVksQ0FBQztBQUV0QyxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsT0FBTyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDcEUsT0FBTyxFQUFFLGFBQWEs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AAE,eAAe,EAChC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,EAAE,GACV,OAAO,CAAC;IAAE,GAAG,EAAE,EAAE,EAAE,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAKxC"}
|
package/dest/test/utils.js
CHANGED
|
@@ -36,6 +36,7 @@ export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint
|
|
|
36
36
|
*/ export function mockPendingTxs(p2p, txs) {
|
|
37
37
|
p2p.getPendingTxCount.mockResolvedValue(txs.length);
|
|
38
38
|
p2p.iteratePendingTxs.mockImplementation(()=>mockTxIterator(Promise.resolve(txs)));
|
|
39
|
+
p2p.iterateEligiblePendingTxs.mockImplementation(()=>mockTxIterator(Promise.resolve(txs)));
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* Creates an async iterator for transactions
|
|
@@ -67,10 +68,10 @@ export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint
|
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
69
70
|
* Creates a checkpoint proposal from a block and signature
|
|
70
|
-
*/ export function createCheckpointProposal(block, checkpointSignature, blockSignature) {
|
|
71
|
+
*/ export function createCheckpointProposal(block, checkpointSignature, blockSignature, feeAssetPriceModifier = 0n) {
|
|
71
72
|
const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
|
|
72
73
|
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
73
|
-
return new CheckpointProposal(checkpointHeader, block.archive.root, checkpointSignature, {
|
|
74
|
+
return new CheckpointProposal(checkpointHeader, block.archive.root, feeAssetPriceModifier, checkpointSignature, {
|
|
74
75
|
blockHeader: block.header,
|
|
75
76
|
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
76
77
|
txHashes,
|
|
@@ -81,9 +82,9 @@ export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint
|
|
|
81
82
|
* Creates a checkpoint attestation from a block and signature.
|
|
82
83
|
* Note: We manually set the sender since we use random signatures in tests.
|
|
83
84
|
* In production, the sender is recovered from the signature.
|
|
84
|
-
*/ export function createCheckpointAttestation(block, signature, sender) {
|
|
85
|
+
*/ export function createCheckpointAttestation(block, signature, sender, feeAssetPriceModifier = 0n) {
|
|
85
86
|
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
86
|
-
const payload = new ConsensusPayload(checkpointHeader, block.archive.root);
|
|
87
|
+
const payload = new ConsensusPayload(checkpointHeader, block.archive.root, feeAssetPriceModifier);
|
|
87
88
|
const attestation = new CheckpointAttestation(payload, signature, signature);
|
|
88
89
|
// Set sender directly for testing (bypasses signature recovery)
|
|
89
90
|
attestation.sender = sender;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/sequencer-client",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.a89ec08",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -26,38 +26,38 @@
|
|
|
26
26
|
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
30
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
31
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
32
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
33
|
-
"@aztec/constants": "0.0.1-commit.
|
|
34
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
35
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
36
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
37
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
38
|
-
"@aztec/merkle-tree": "0.0.1-commit.
|
|
39
|
-
"@aztec/node-keystore": "0.0.1-commit.
|
|
40
|
-
"@aztec/noir-acvm_js": "0.0.1-commit.
|
|
41
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
42
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
43
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
44
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
45
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
46
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
47
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
48
|
-
"@aztec/slasher": "0.0.1-commit.
|
|
49
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
50
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
51
|
-
"@aztec/validator-client": "0.0.1-commit.
|
|
52
|
-
"@aztec/validator-ha-signer": "0.0.1-commit.
|
|
53
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
29
|
+
"@aztec/aztec.js": "0.0.1-commit.a89ec08",
|
|
30
|
+
"@aztec/bb-prover": "0.0.1-commit.a89ec08",
|
|
31
|
+
"@aztec/blob-client": "0.0.1-commit.a89ec08",
|
|
32
|
+
"@aztec/blob-lib": "0.0.1-commit.a89ec08",
|
|
33
|
+
"@aztec/constants": "0.0.1-commit.a89ec08",
|
|
34
|
+
"@aztec/epoch-cache": "0.0.1-commit.a89ec08",
|
|
35
|
+
"@aztec/ethereum": "0.0.1-commit.a89ec08",
|
|
36
|
+
"@aztec/foundation": "0.0.1-commit.a89ec08",
|
|
37
|
+
"@aztec/l1-artifacts": "0.0.1-commit.a89ec08",
|
|
38
|
+
"@aztec/merkle-tree": "0.0.1-commit.a89ec08",
|
|
39
|
+
"@aztec/node-keystore": "0.0.1-commit.a89ec08",
|
|
40
|
+
"@aztec/noir-acvm_js": "0.0.1-commit.a89ec08",
|
|
41
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.a89ec08",
|
|
42
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.a89ec08",
|
|
43
|
+
"@aztec/noir-types": "0.0.1-commit.a89ec08",
|
|
44
|
+
"@aztec/p2p": "0.0.1-commit.a89ec08",
|
|
45
|
+
"@aztec/protocol-contracts": "0.0.1-commit.a89ec08",
|
|
46
|
+
"@aztec/prover-client": "0.0.1-commit.a89ec08",
|
|
47
|
+
"@aztec/simulator": "0.0.1-commit.a89ec08",
|
|
48
|
+
"@aztec/slasher": "0.0.1-commit.a89ec08",
|
|
49
|
+
"@aztec/stdlib": "0.0.1-commit.a89ec08",
|
|
50
|
+
"@aztec/telemetry-client": "0.0.1-commit.a89ec08",
|
|
51
|
+
"@aztec/validator-client": "0.0.1-commit.a89ec08",
|
|
52
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.a89ec08",
|
|
53
|
+
"@aztec/world-state": "0.0.1-commit.a89ec08",
|
|
54
54
|
"lodash.chunk": "^4.2.0",
|
|
55
55
|
"tslib": "^2.4.0",
|
|
56
56
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
60
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
59
|
+
"@aztec/archiver": "0.0.1-commit.a89ec08",
|
|
60
|
+
"@aztec/kv-store": "0.0.1-commit.a89ec08",
|
|
61
61
|
"@electric-sql/pglite": "^0.3.14",
|
|
62
62
|
"@jest/globals": "^30.0.0",
|
|
63
63
|
"@types/jest": "^30.0.0",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
|
+
import { MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
|
|
2
3
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
3
4
|
import { isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
4
5
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
5
6
|
import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
6
|
-
import {
|
|
7
|
+
import { type Delayer, L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
7
8
|
import { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
8
9
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -18,8 +19,8 @@ import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
|
18
19
|
import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
|
|
19
20
|
import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
20
21
|
|
|
21
|
-
import type
|
|
22
|
-
import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
22
|
+
import { type SequencerClientConfig, getPublisherConfigFromSequencerConfig } from '../config.js';
|
|
23
|
+
import type { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
23
24
|
import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
24
25
|
import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
25
26
|
|
|
@@ -28,11 +29,12 @@ import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
|
28
29
|
*/
|
|
29
30
|
export class SequencerClient {
|
|
30
31
|
constructor(
|
|
31
|
-
protected publisherManager: PublisherManager<
|
|
32
|
+
protected publisherManager: PublisherManager<L1TxUtils>,
|
|
32
33
|
protected sequencer: Sequencer,
|
|
33
34
|
protected checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
34
35
|
protected validatorClient?: ValidatorClient,
|
|
35
36
|
private l1Metrics?: L1Metrics,
|
|
37
|
+
private delayer_?: Delayer,
|
|
36
38
|
) {}
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -62,8 +64,9 @@ export class SequencerClient {
|
|
|
62
64
|
blobClient: BlobClientInterface;
|
|
63
65
|
dateProvider: DateProvider;
|
|
64
66
|
epochCache?: EpochCache;
|
|
65
|
-
l1TxUtils:
|
|
67
|
+
l1TxUtils: L1TxUtils[];
|
|
66
68
|
nodeKeyStore: KeystoreManager;
|
|
69
|
+
globalVariableBuilder: GlobalVariableBuilder;
|
|
67
70
|
},
|
|
68
71
|
) {
|
|
69
72
|
const {
|
|
@@ -85,12 +88,15 @@ export class SequencerClient {
|
|
|
85
88
|
publicClient,
|
|
86
89
|
l1TxUtils.map(x => x.getSenderAddress()),
|
|
87
90
|
);
|
|
88
|
-
const publisherManager = new PublisherManager(
|
|
91
|
+
const publisherManager = new PublisherManager(
|
|
92
|
+
l1TxUtils,
|
|
93
|
+
getPublisherConfigFromSequencerConfig(config),
|
|
94
|
+
log.getBindings(),
|
|
95
|
+
);
|
|
89
96
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
90
|
-
const [l1GenesisTime, slotDuration,
|
|
97
|
+
const [l1GenesisTime, slotDuration, rollupManaLimit] = await Promise.all([
|
|
91
98
|
rollupContract.getL1GenesisTime(),
|
|
92
99
|
rollupContract.getSlotDuration(),
|
|
93
|
-
rollupContract.getVersion(),
|
|
94
100
|
rollupContract.getManaLimit().then(Number),
|
|
95
101
|
] as const);
|
|
96
102
|
|
|
@@ -132,17 +138,8 @@ export class SequencerClient {
|
|
|
132
138
|
});
|
|
133
139
|
|
|
134
140
|
const ethereumSlotDuration = config.ethereumSlotDuration;
|
|
135
|
-
const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
|
|
136
|
-
|
|
137
|
-
const globalsBuilder = new GlobalVariableBuilder({ ...config, ...l1Constants, rollupVersion });
|
|
138
141
|
|
|
139
|
-
|
|
140
|
-
if (sequencerManaLimit > rollupManaLimit) {
|
|
141
|
-
log.warn(
|
|
142
|
-
`Provided maxL2BlockGas ${sequencerManaLimit} is greater than the max allowed by L1. Setting limit to ${rollupManaLimit}.`,
|
|
143
|
-
);
|
|
144
|
-
sequencerManaLimit = rollupManaLimit;
|
|
145
|
-
}
|
|
142
|
+
const globalsBuilder = deps.globalVariableBuilder;
|
|
146
143
|
|
|
147
144
|
// When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
|
|
148
145
|
// Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
|
|
@@ -152,6 +149,10 @@ export class SequencerClient {
|
|
|
152
149
|
const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
|
|
153
150
|
const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
|
|
154
151
|
|
|
152
|
+
const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = capPerBlockLimits(config, rollupManaLimit, log);
|
|
153
|
+
|
|
154
|
+
const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration, rollupManaLimit };
|
|
155
|
+
|
|
155
156
|
const sequencer = new Sequencer(
|
|
156
157
|
publisherFactory,
|
|
157
158
|
validatorClient,
|
|
@@ -166,14 +167,17 @@ export class SequencerClient {
|
|
|
166
167
|
deps.dateProvider,
|
|
167
168
|
epochCache,
|
|
168
169
|
rollupContract,
|
|
169
|
-
{ ...config, l1PublishingTime, maxL2BlockGas
|
|
170
|
+
{ ...config, l1PublishingTime, maxL2BlockGas, maxDABlockGas, maxTxsPerBlock },
|
|
170
171
|
telemetryClient,
|
|
171
172
|
log,
|
|
172
173
|
);
|
|
173
174
|
|
|
174
|
-
|
|
175
|
+
sequencer.init();
|
|
176
|
+
|
|
177
|
+
// Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
|
|
178
|
+
const delayer = l1TxUtils[0]?.delayer;
|
|
175
179
|
|
|
176
|
-
return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics);
|
|
180
|
+
return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics, delayer);
|
|
177
181
|
}
|
|
178
182
|
|
|
179
183
|
/**
|
|
@@ -204,10 +208,25 @@ export class SequencerClient {
|
|
|
204
208
|
this.l1Metrics?.stop();
|
|
205
209
|
}
|
|
206
210
|
|
|
211
|
+
/** Triggers an immediate run of the sequencer, bypassing the polling interval. */
|
|
212
|
+
public trigger() {
|
|
213
|
+
return this.sequencer.trigger();
|
|
214
|
+
}
|
|
215
|
+
|
|
207
216
|
public getSequencer(): Sequencer {
|
|
208
217
|
return this.sequencer;
|
|
209
218
|
}
|
|
210
219
|
|
|
220
|
+
/** Updates the publisher factory's node keystore adapter after a keystore reload. */
|
|
221
|
+
public updatePublisherNodeKeyStore(adapter: NodeKeystoreAdapter): void {
|
|
222
|
+
this.sequencer.updatePublisherNodeKeyStore(adapter);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Returns the shared tx delayer for sequencer L1 txs, if enabled. Test-only. */
|
|
226
|
+
getDelayer(): Delayer | undefined {
|
|
227
|
+
return this.delayer_;
|
|
228
|
+
}
|
|
229
|
+
|
|
211
230
|
get validatorAddresses(): EthAddress[] | undefined {
|
|
212
231
|
return this.sequencer.getValidatorAddresses();
|
|
213
232
|
}
|
|
@@ -216,3 +235,41 @@ export class SequencerClient {
|
|
|
216
235
|
return this.sequencer.maxL2BlockGas;
|
|
217
236
|
}
|
|
218
237
|
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Caps operator-provided per-block limits at checkpoint-level limits.
|
|
241
|
+
* Returns undefined for any limit the operator didn't set — the checkpoint builder handles redistribution.
|
|
242
|
+
*/
|
|
243
|
+
function capPerBlockLimits(
|
|
244
|
+
config: SequencerClientConfig,
|
|
245
|
+
rollupManaLimit: number,
|
|
246
|
+
log: ReturnType<typeof createLogger>,
|
|
247
|
+
): { maxL2BlockGas: number | undefined; maxDABlockGas: number | undefined; maxTxsPerBlock: number | undefined } {
|
|
248
|
+
let maxL2BlockGas = config.maxL2BlockGas;
|
|
249
|
+
if (maxL2BlockGas !== undefined && maxL2BlockGas > rollupManaLimit) {
|
|
250
|
+
log.warn(`Provided MAX_L2_BLOCK_GAS ${maxL2BlockGas} exceeds rollup mana limit ${rollupManaLimit} (capping)`);
|
|
251
|
+
maxL2BlockGas = rollupManaLimit;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
let maxDABlockGas = config.maxDABlockGas;
|
|
255
|
+
if (maxDABlockGas !== undefined && maxDABlockGas > MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT) {
|
|
256
|
+
log.warn(
|
|
257
|
+
`Provided MAX_DA_BLOCK_GAS ${maxDABlockGas} exceeds DA checkpoint limit ${MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT} (capping)`,
|
|
258
|
+
);
|
|
259
|
+
maxDABlockGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let maxTxsPerBlock = config.maxTxsPerBlock;
|
|
263
|
+
if (
|
|
264
|
+
maxTxsPerBlock !== undefined &&
|
|
265
|
+
config.maxTxsPerCheckpoint !== undefined &&
|
|
266
|
+
maxTxsPerBlock > config.maxTxsPerCheckpoint
|
|
267
|
+
) {
|
|
268
|
+
log.warn(
|
|
269
|
+
`Provided MAX_TX_PER_BLOCK ${maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`,
|
|
270
|
+
);
|
|
271
|
+
maxTxsPerBlock = config.maxTxsPerCheckpoint;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock };
|
|
275
|
+
}
|