@aztec/sequencer-client 0.0.1-commit.8f9871590 → 0.0.1-commit.9117c5f5a
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 +12 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +15 -4
- package/dest/config.d.ts +3 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +13 -4
- 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 +13 -2
- package/dest/publisher/sequencer-publisher.d.ts +15 -7
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +244 -24
- package/dest/sequencer/checkpoint_proposal_job.d.ts +1 -1
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +34 -8
- package/dest/sequencer/metrics.d.ts +13 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +32 -10
- package/dest/sequencer/sequencer.d.ts +15 -7
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +23 -25
- package/dest/sequencer/timetable.js +1 -1
- package/dest/test/index.d.ts +3 -5
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/client/sequencer-client.ts +25 -7
- package/src/config.ts +17 -8
- 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 +23 -6
- package/src/publisher/sequencer-publisher.ts +214 -31
- package/src/sequencer/checkpoint_proposal_job.ts +53 -9
- package/src/sequencer/metrics.ts +39 -13
- package/src/sequencer/sequencer.ts +31 -30
- package/src/sequencer/timetable.ts +1 -1
- package/src/test/index.ts +2 -4
|
@@ -12,7 +12,7 @@ import type { DateProvider } from '@aztec/foundation/timer';
|
|
|
12
12
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
13
13
|
import type { P2P } from '@aztec/p2p';
|
|
14
14
|
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
15
|
-
import type {
|
|
15
|
+
import type { BlockData, L2BlockSink, L2BlockSource, ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
16
16
|
import type { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
17
17
|
import { getSlotAtTimestamp, getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
18
18
|
import {
|
|
@@ -25,7 +25,7 @@ import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
|
25
25
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
26
26
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
27
27
|
import { Attributes, type TelemetryClient, type Tracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
28
|
-
import { FullNodeCheckpointsBuilder, type ValidatorClient } from '@aztec/validator-client';
|
|
28
|
+
import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
29
29
|
|
|
30
30
|
import EventEmitter from 'node:events';
|
|
31
31
|
|
|
@@ -75,14 +75,6 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
75
75
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */
|
|
76
76
|
protected timetable!: SequencerTimetable;
|
|
77
77
|
|
|
78
|
-
// This shouldn't be here as this gets re-created each time we build/propose a block.
|
|
79
|
-
// But we have a number of tests that abuse/rely on this class having a permanent publisher.
|
|
80
|
-
// As long as those tests only configure a single publisher they will continue to work.
|
|
81
|
-
// This will get re-assigned every time the sequencer goes to build a new block to a publisher that is valid
|
|
82
|
-
// for the block proposer.
|
|
83
|
-
// TODO(palla/mbps): Remove this field and fix tests
|
|
84
|
-
protected publisher: SequencerPublisher | undefined;
|
|
85
|
-
|
|
86
78
|
/** Config for the sequencer */
|
|
87
79
|
protected config: ResolvedSequencerConfig = DefaultSequencerConfig;
|
|
88
80
|
|
|
@@ -134,10 +126,9 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
134
126
|
);
|
|
135
127
|
}
|
|
136
128
|
|
|
137
|
-
/** Initializes the sequencer (precomputes tables
|
|
138
|
-
public
|
|
129
|
+
/** Initializes the sequencer (precomputes tables). Takes about 3s. */
|
|
130
|
+
public init() {
|
|
139
131
|
getKzg();
|
|
140
|
-
this.publisher = (await this.publisherFactory.create(undefined)).publisher;
|
|
141
132
|
}
|
|
142
133
|
|
|
143
134
|
/** Starts the sequencer and moves to IDLE state. */
|
|
@@ -156,7 +147,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
156
147
|
public async stop(): Promise<void> {
|
|
157
148
|
this.log.info(`Stopping sequencer`);
|
|
158
149
|
this.setState(SequencerState.STOPPING, undefined, { force: true });
|
|
159
|
-
this.
|
|
150
|
+
this.publisherFactory.interruptAll();
|
|
160
151
|
await this.runningPromise?.stop();
|
|
161
152
|
this.setState(SequencerState.STOPPED, undefined, { force: true });
|
|
162
153
|
this.log.info('Stopped sequencer');
|
|
@@ -169,7 +160,6 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
169
160
|
} catch (err) {
|
|
170
161
|
this.emit('checkpoint-error', { error: err as Error });
|
|
171
162
|
if (err instanceof SequencerTooSlowError) {
|
|
172
|
-
// TODO(palla/mbps): Add missing states
|
|
173
163
|
// Log as warn only if we had to abort halfway through the block proposal
|
|
174
164
|
const logLvl = [SequencerState.INITIALIZING_CHECKPOINT, SequencerState.PROPOSER_CHECK].includes(
|
|
175
165
|
err.proposedState,
|
|
@@ -310,12 +300,12 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
310
300
|
}
|
|
311
301
|
|
|
312
302
|
// Check that the slot is not taken by a block already (should never happen, since only us can propose for this slot)
|
|
313
|
-
if (syncedTo.
|
|
303
|
+
if (syncedTo.blockData && syncedTo.blockData.header.getSlot() >= slot) {
|
|
314
304
|
this.log.warn(
|
|
315
305
|
`Cannot propose block at next L2 slot ${slot} since that slot was taken by block ${syncedTo.blockNumber}`,
|
|
316
|
-
{ ...logCtx, block: syncedTo.
|
|
306
|
+
{ ...logCtx, block: syncedTo.blockData.header.toInspect() },
|
|
317
307
|
);
|
|
318
|
-
this.metrics.
|
|
308
|
+
this.metrics.recordCheckpointPrecheckFailed('slot_already_taken');
|
|
319
309
|
return undefined;
|
|
320
310
|
}
|
|
321
311
|
|
|
@@ -326,7 +316,6 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
326
316
|
const proposerForPublisher = this.config.fishermanMode ? undefined : proposer;
|
|
327
317
|
const { attestorAddress, publisher } = await this.publisherFactory.create(proposerForPublisher);
|
|
328
318
|
this.log.verbose(`Created publisher at address ${publisher.getSenderAddress()} for attestor ${attestorAddress}`);
|
|
329
|
-
this.publisher = publisher;
|
|
330
319
|
|
|
331
320
|
// In fisherman mode, set the actual proposer's address for simulations
|
|
332
321
|
if (this.config.fishermanMode && proposer) {
|
|
@@ -351,7 +340,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
351
340
|
logCtx,
|
|
352
341
|
);
|
|
353
342
|
this.emit('proposer-rollup-check-failed', { reason: 'Rollup contract check failed', slot });
|
|
354
|
-
this.metrics.
|
|
343
|
+
this.metrics.recordCheckpointPrecheckFailed('rollup_contract_check_failed');
|
|
355
344
|
return undefined;
|
|
356
345
|
}
|
|
357
346
|
|
|
@@ -361,7 +350,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
361
350
|
{ ...logCtx, rollup: canProposeCheck, expectedSlot: slot },
|
|
362
351
|
);
|
|
363
352
|
this.emit('proposer-rollup-check-failed', { reason: 'Slot mismatch', slot });
|
|
364
|
-
this.metrics.
|
|
353
|
+
this.metrics.recordCheckpointPrecheckFailed('slot_mismatch');
|
|
365
354
|
return undefined;
|
|
366
355
|
}
|
|
367
356
|
|
|
@@ -371,7 +360,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
371
360
|
{ ...logCtx, rollup: canProposeCheck, expectedSlot: slot },
|
|
372
361
|
);
|
|
373
362
|
this.emit('proposer-rollup-check-failed', { reason: 'Block mismatch', slot });
|
|
374
|
-
this.metrics.
|
|
363
|
+
this.metrics.recordCheckpointPrecheckFailed('block_number_mismatch');
|
|
375
364
|
return undefined;
|
|
376
365
|
}
|
|
377
366
|
|
|
@@ -433,6 +422,13 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
433
422
|
);
|
|
434
423
|
}
|
|
435
424
|
|
|
425
|
+
/**
|
|
426
|
+
* Returns the current sequencer state.
|
|
427
|
+
*/
|
|
428
|
+
public getState(): SequencerState {
|
|
429
|
+
return this.state;
|
|
430
|
+
}
|
|
431
|
+
|
|
436
432
|
/**
|
|
437
433
|
* Internal helper for setting the sequencer state and checks if we have enough time left in the slot to transition to the new state.
|
|
438
434
|
* @param proposedState - The new state to transition to.
|
|
@@ -533,18 +529,18 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
533
529
|
};
|
|
534
530
|
}
|
|
535
531
|
|
|
536
|
-
const
|
|
537
|
-
if (!
|
|
532
|
+
const blockData = await this.l2BlockSource.getBlockData(blockNumber);
|
|
533
|
+
if (!blockData) {
|
|
538
534
|
// this shouldn't really happen because a moment ago we checked that all components were in sync
|
|
539
|
-
this.log.error(`Failed to get L2 block ${blockNumber} from the archiver with all components in sync`);
|
|
535
|
+
this.log.error(`Failed to get L2 block data ${blockNumber} from the archiver with all components in sync`);
|
|
540
536
|
return undefined;
|
|
541
537
|
}
|
|
542
538
|
|
|
543
539
|
return {
|
|
544
|
-
|
|
545
|
-
blockNumber:
|
|
546
|
-
checkpointNumber:
|
|
547
|
-
archive:
|
|
540
|
+
blockData,
|
|
541
|
+
blockNumber: blockData.header.getBlockNumber(),
|
|
542
|
+
checkpointNumber: blockData.checkpointNumber,
|
|
543
|
+
archive: blockData.archive.root,
|
|
548
544
|
l1Timestamp,
|
|
549
545
|
pendingChainValidationStatus,
|
|
550
546
|
};
|
|
@@ -867,6 +863,11 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
867
863
|
return this.validatorClient?.getValidatorAddresses();
|
|
868
864
|
}
|
|
869
865
|
|
|
866
|
+
/** Updates the publisher factory's node keystore adapter after a keystore reload. */
|
|
867
|
+
public updatePublisherNodeKeyStore(adapter: NodeKeystoreAdapter): void {
|
|
868
|
+
this.publisherFactory.updateNodeKeyStore(adapter);
|
|
869
|
+
}
|
|
870
|
+
|
|
870
871
|
public getConfig() {
|
|
871
872
|
return this.config;
|
|
872
873
|
}
|
|
@@ -877,7 +878,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
877
878
|
}
|
|
878
879
|
|
|
879
880
|
type SequencerSyncCheckResult = {
|
|
880
|
-
|
|
881
|
+
blockData?: BlockData;
|
|
881
882
|
checkpointNumber: CheckpointNumber;
|
|
882
883
|
blockNumber: BlockNumber;
|
|
883
884
|
archive: Fr;
|
|
@@ -132,7 +132,7 @@ export class SequencerTimetable {
|
|
|
132
132
|
const initializeDeadline = this.aztecSlotDuration - minWorkToDo;
|
|
133
133
|
this.initializeDeadline = initializeDeadline;
|
|
134
134
|
|
|
135
|
-
this.log.
|
|
135
|
+
this.log.info(
|
|
136
136
|
`Sequencer timetable initialized with ${this.maxNumberOfBlocks} blocks per slot (${this.enforce ? 'enforced' : 'not enforced'})`,
|
|
137
137
|
{
|
|
138
138
|
ethereumSlotDuration: this.ethereumSlotDuration,
|
package/src/test/index.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
2
2
|
import type { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
3
3
|
import type { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
4
4
|
import type { FullNodeCheckpointsBuilder, ValidatorClient } from '@aztec/validator-client';
|
|
5
5
|
|
|
6
6
|
import { SequencerClient } from '../client/sequencer-client.js';
|
|
7
7
|
import type { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
8
|
-
import type { SequencerPublisher } from '../publisher/sequencer-publisher.js';
|
|
9
8
|
import { Sequencer } from '../sequencer/sequencer.js';
|
|
10
9
|
import type { SequencerTimetable } from '../sequencer/timetable.js';
|
|
11
10
|
|
|
12
11
|
class TestSequencer_ extends Sequencer {
|
|
13
12
|
declare public publicProcessorFactory: PublicProcessorFactory;
|
|
14
13
|
declare public timetable: SequencerTimetable;
|
|
15
|
-
declare public publisher: SequencerPublisher;
|
|
16
14
|
declare public publisherFactory: SequencerPublisherFactory;
|
|
17
15
|
declare public validatorClient: ValidatorClient;
|
|
18
16
|
declare public checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
@@ -22,7 +20,7 @@ export type TestSequencer = TestSequencer_;
|
|
|
22
20
|
|
|
23
21
|
class TestSequencerClient_ extends SequencerClient {
|
|
24
22
|
declare public sequencer: TestSequencer;
|
|
25
|
-
declare public publisherManager: PublisherManager<
|
|
23
|
+
declare public publisherManager: PublisherManager<L1TxUtils>;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
export type TestSequencerClient = TestSequencerClient_;
|