@aztec/sequencer-client 0.0.1-commit.f146247c → 0.0.1-commit.f224bb98b
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 +23 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +99 -16
- package/dest/config.d.ts +24 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +40 -28
- package/dest/global_variable_builder/global_builder.d.ts +2 -4
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +35 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +106 -42
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- 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 +27 -2
- package/dest/publisher/sequencer-publisher.d.ts +26 -7
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +299 -30
- package/dest/sequencer/checkpoint_proposal_job.d.ts +8 -4
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +132 -79
- 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 +26 -13
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +41 -40
- 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 +8 -8
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +45 -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 +135 -18
- package/src/config.ts +54 -38
- package/src/global_variable_builder/global_builder.ts +1 -1
- package/src/publisher/config.ts +121 -43
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-publisher-factory.ts +38 -6
- package/src/publisher/sequencer-publisher.ts +300 -43
- package/src/sequencer/checkpoint_proposal_job.ts +171 -86
- package/src/sequencer/metrics.ts +92 -18
- package/src/sequencer/sequencer.ts +52 -46
- 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 +60 -46
- package/src/test/utils.ts +5 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { type BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { unfreeze } from '@aztec/foundation/types';
|
|
3
4
|
import { L2Block } from '@aztec/stdlib/block';
|
|
4
5
|
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
5
|
-
import { Gas } from '@aztec/stdlib/gas';
|
|
6
6
|
import type {
|
|
7
7
|
FullNodeBlockBuilderConfig,
|
|
8
8
|
ICheckpointBlockBuilder,
|
|
@@ -86,8 +86,10 @@ export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
86
86
|
let usedTxs: Tx[];
|
|
87
87
|
|
|
88
88
|
if (this.blockProvider) {
|
|
89
|
-
// Dynamic mode: get block from provider
|
|
90
|
-
block = this.blockProvider();
|
|
89
|
+
// Dynamic mode: get block from provider, cloning to avoid shared references across multiple buildBlock calls
|
|
90
|
+
block = L2Block.fromBuffer(this.blockProvider().toBuffer());
|
|
91
|
+
block.header.globalVariables.blockNumber = blockNumber;
|
|
92
|
+
await block.header.recomputeHash();
|
|
91
93
|
usedTxs = [];
|
|
92
94
|
this.builtBlocks.push(block);
|
|
93
95
|
} else {
|
|
@@ -113,81 +115,79 @@ export class MockCheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
113
115
|
|
|
114
116
|
return {
|
|
115
117
|
block,
|
|
116
|
-
publicGas: Gas.empty(),
|
|
117
118
|
publicProcessorDuration: 0,
|
|
118
119
|
numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
|
|
119
120
|
usedTxs,
|
|
120
121
|
failedTxs: [],
|
|
121
|
-
usedTxBlobFields: block?.body?.txEffects?.reduce((sum, tx) => sum + tx.getNumBlobFields(), 0) ?? 0,
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
completeCheckpoint(): Promise<Checkpoint> {
|
|
126
126
|
this.completeCheckpointCalled = true;
|
|
127
127
|
const allBlocks = this.blockProvider ? this.builtBlocks : this.blocks;
|
|
128
|
-
|
|
129
|
-
// Create a CheckpointHeader from the last block's header for testing
|
|
130
|
-
const checkpointHeader = this.createCheckpointHeader(lastBlock);
|
|
131
|
-
return Promise.resolve(
|
|
132
|
-
new Checkpoint(
|
|
133
|
-
makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
|
|
134
|
-
checkpointHeader,
|
|
135
|
-
allBlocks,
|
|
136
|
-
this.checkpointNumber,
|
|
137
|
-
),
|
|
138
|
-
);
|
|
128
|
+
return this.buildCheckpoint(allBlocks);
|
|
139
129
|
}
|
|
140
130
|
|
|
141
131
|
getCheckpoint(): Promise<Checkpoint> {
|
|
142
132
|
this.getCheckpointCalled = true;
|
|
143
133
|
const builtBlocks = this.blockProvider ? this.builtBlocks : this.blocks.slice(0, this.blockIndex);
|
|
144
|
-
|
|
145
|
-
if (!lastBlock) {
|
|
134
|
+
if (builtBlocks.length === 0) {
|
|
146
135
|
throw new Error('No blocks built yet');
|
|
147
136
|
}
|
|
148
|
-
|
|
149
|
-
const checkpointHeader = this.createCheckpointHeader(lastBlock);
|
|
150
|
-
return Promise.resolve(
|
|
151
|
-
new Checkpoint(
|
|
152
|
-
makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
|
|
153
|
-
checkpointHeader,
|
|
154
|
-
builtBlocks,
|
|
155
|
-
this.checkpointNumber,
|
|
156
|
-
),
|
|
157
|
-
);
|
|
137
|
+
return this.buildCheckpoint(builtBlocks);
|
|
158
138
|
}
|
|
159
139
|
|
|
160
|
-
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
140
|
+
/** Builds a structurally valid Checkpoint from a list of blocks, fixing up indexes and archive chaining. */
|
|
141
|
+
private async buildCheckpoint(blocks: L2Block[]): Promise<Checkpoint> {
|
|
142
|
+
// Fix up indexWithinCheckpoint and archive chaining so the checkpoint passes structural validation.
|
|
143
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
144
|
+
blocks[i].indexWithinCheckpoint = IndexWithinCheckpoint(i);
|
|
145
|
+
if (i > 0) {
|
|
146
|
+
unfreeze(blocks[i].header).lastArchive = blocks[i - 1].archive;
|
|
147
|
+
await blocks[i].header.recomputeHash();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const firstBlock = blocks[0];
|
|
152
|
+
const lastBlock = blocks[blocks.length - 1];
|
|
153
|
+
const gv = firstBlock.header.globalVariables;
|
|
154
|
+
|
|
155
|
+
const checkpointHeader = CheckpointHeader.empty({
|
|
156
|
+
lastArchiveRoot: firstBlock.header.lastArchive.root,
|
|
157
|
+
blockHeadersHash: Fr.random(),
|
|
170
158
|
slotNumber: gv.slotNumber,
|
|
171
159
|
timestamp: gv.timestamp,
|
|
172
160
|
coinbase: gv.coinbase,
|
|
173
161
|
feeRecipient: gv.feeRecipient,
|
|
174
162
|
gasFees: gv.gasFees,
|
|
175
|
-
totalManaUsed: header.totalManaUsed,
|
|
163
|
+
totalManaUsed: lastBlock.header.totalManaUsed,
|
|
176
164
|
});
|
|
165
|
+
|
|
166
|
+
return new Checkpoint(
|
|
167
|
+
makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
|
|
168
|
+
checkpointHeader,
|
|
169
|
+
blocks,
|
|
170
|
+
this.checkpointNumber,
|
|
171
|
+
);
|
|
177
172
|
}
|
|
178
173
|
|
|
179
|
-
/**
|
|
180
|
-
|
|
181
|
-
this.blocks = [];
|
|
174
|
+
/** Resets per-checkpoint state (built blocks, consumed txs) while preserving config (blockProvider, seeded blocks). */
|
|
175
|
+
resetCheckpointState(): void {
|
|
182
176
|
this.builtBlocks = [];
|
|
183
|
-
this.usedTxsPerBlock = [];
|
|
184
177
|
this.blockIndex = 0;
|
|
185
|
-
this.buildBlockCalls = [];
|
|
186
178
|
this.consumedTxHashes.clear();
|
|
187
179
|
this.completeCheckpointCalled = false;
|
|
188
180
|
this.getCheckpointCalled = false;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Reset for reuse in another test */
|
|
184
|
+
reset(): void {
|
|
185
|
+
this.blocks = [];
|
|
186
|
+
this.usedTxsPerBlock = [];
|
|
187
|
+
this.buildBlockCalls = [];
|
|
189
188
|
this.errorOnBuild = undefined;
|
|
190
189
|
this.blockProvider = undefined;
|
|
190
|
+
this.resetCheckpointState();
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
|
|
@@ -205,6 +205,7 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
205
205
|
constants: CheckpointGlobalVariables;
|
|
206
206
|
l1ToL2Messages: Fr[];
|
|
207
207
|
previousCheckpointOutHashes: Fr[];
|
|
208
|
+
feeAssetPriceModifier: bigint;
|
|
208
209
|
}> = [];
|
|
209
210
|
public openCheckpointCalls: Array<{
|
|
210
211
|
checkpointNumber: CheckpointNumber;
|
|
@@ -212,6 +213,7 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
212
213
|
l1ToL2Messages: Fr[];
|
|
213
214
|
previousCheckpointOutHashes: Fr[];
|
|
214
215
|
existingBlocks: L2Block[];
|
|
216
|
+
feeAssetPriceModifier: bigint;
|
|
215
217
|
}> = [];
|
|
216
218
|
public updateConfigCalls: Array<Partial<FullNodeBlockBuilderConfig>> = [];
|
|
217
219
|
|
|
@@ -247,6 +249,7 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
247
249
|
slotDuration: 24,
|
|
248
250
|
l1ChainId: 1,
|
|
249
251
|
rollupVersion: 1,
|
|
252
|
+
rollupManaLimit: 200_000_000,
|
|
250
253
|
};
|
|
251
254
|
}
|
|
252
255
|
|
|
@@ -257,15 +260,24 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
257
260
|
startCheckpoint(
|
|
258
261
|
checkpointNumber: CheckpointNumber,
|
|
259
262
|
constants: CheckpointGlobalVariables,
|
|
263
|
+
feeAssetPriceModifier: bigint,
|
|
260
264
|
l1ToL2Messages: Fr[],
|
|
261
265
|
previousCheckpointOutHashes: Fr[],
|
|
262
266
|
_fork: MerkleTreeWriteOperations,
|
|
263
267
|
): Promise<ICheckpointBlockBuilder> {
|
|
264
|
-
this.startCheckpointCalls.push({
|
|
268
|
+
this.startCheckpointCalls.push({
|
|
269
|
+
checkpointNumber,
|
|
270
|
+
constants,
|
|
271
|
+
l1ToL2Messages,
|
|
272
|
+
previousCheckpointOutHashes,
|
|
273
|
+
feeAssetPriceModifier,
|
|
274
|
+
});
|
|
265
275
|
|
|
266
276
|
if (!this.checkpointBuilder) {
|
|
267
277
|
// Auto-create a builder if none was set
|
|
268
278
|
this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
|
|
279
|
+
} else {
|
|
280
|
+
this.checkpointBuilder.resetCheckpointState();
|
|
269
281
|
}
|
|
270
282
|
|
|
271
283
|
return Promise.resolve(this.checkpointBuilder);
|
|
@@ -274,6 +286,7 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
274
286
|
openCheckpoint(
|
|
275
287
|
checkpointNumber: CheckpointNumber,
|
|
276
288
|
constants: CheckpointGlobalVariables,
|
|
289
|
+
feeAssetPriceModifier: bigint,
|
|
277
290
|
l1ToL2Messages: Fr[],
|
|
278
291
|
previousCheckpointOutHashes: Fr[],
|
|
279
292
|
_fork: MerkleTreeWriteOperations,
|
|
@@ -285,6 +298,7 @@ export class MockCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
285
298
|
l1ToL2Messages,
|
|
286
299
|
previousCheckpointOutHashes,
|
|
287
300
|
existingBlocks,
|
|
301
|
+
feeAssetPriceModifier,
|
|
288
302
|
});
|
|
289
303
|
|
|
290
304
|
if (!this.checkpointBuilder) {
|
package/src/test/utils.ts
CHANGED
|
@@ -56,6 +56,7 @@ export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Pr
|
|
|
56
56
|
export function mockPendingTxs(p2p: MockProxy<P2P>, txs: Tx[]): void {
|
|
57
57
|
p2p.getPendingTxCount.mockResolvedValue(txs.length);
|
|
58
58
|
p2p.iteratePendingTxs.mockImplementation(() => mockTxIterator(Promise.resolve(txs)));
|
|
59
|
+
p2p.iterateEligiblePendingTxs.mockImplementation(() => mockTxIterator(Promise.resolve(txs)));
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
/**
|
|
@@ -118,10 +119,11 @@ export function createCheckpointProposal(
|
|
|
118
119
|
block: L2Block,
|
|
119
120
|
checkpointSignature: Signature,
|
|
120
121
|
blockSignature?: Signature,
|
|
122
|
+
feeAssetPriceModifier: bigint = 0n,
|
|
121
123
|
): CheckpointProposal {
|
|
122
124
|
const txHashes = block.body.txEffects.map(tx => tx.txHash);
|
|
123
125
|
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
124
|
-
return new CheckpointProposal(checkpointHeader, block.archive.root, checkpointSignature, {
|
|
126
|
+
return new CheckpointProposal(checkpointHeader, block.archive.root, feeAssetPriceModifier, checkpointSignature, {
|
|
125
127
|
blockHeader: block.header,
|
|
126
128
|
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
127
129
|
txHashes,
|
|
@@ -138,9 +140,10 @@ export function createCheckpointAttestation(
|
|
|
138
140
|
block: L2Block,
|
|
139
141
|
signature: Signature,
|
|
140
142
|
sender: EthAddress,
|
|
143
|
+
feeAssetPriceModifier: bigint = 0n,
|
|
141
144
|
): CheckpointAttestation {
|
|
142
145
|
const checkpointHeader = createCheckpointHeaderFromBlock(block);
|
|
143
|
-
const payload = new ConsensusPayload(checkpointHeader, block.archive.root);
|
|
146
|
+
const payload = new ConsensusPayload(checkpointHeader, block.archive.root, feeAssetPriceModifier);
|
|
144
147
|
const attestation = new CheckpointAttestation(payload, signature, signature);
|
|
145
148
|
// Set sender directly for testing (bypasses signature recovery)
|
|
146
149
|
(attestation as any).sender = sender;
|