@aztec/sequencer-client 0.0.1-commit.b2a5d0dd1 → 0.0.1-commit.b3d3157a
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/README.md +281 -21
- package/dest/client/sequencer-client.d.ts +3 -3
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +6 -6
- package/dest/config.d.ts +6 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +33 -10
- package/dest/global_variable_builder/fee_provider.js +1 -1
- package/dest/global_variable_builder/global_builder.d.ts +2 -3
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +1 -1
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/config.d.ts +3 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
- package/dest/publisher/sequencer-bundle-simulator.js +198 -0
- package/dest/publisher/sequencer-publisher.d.ts +36 -36
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +271 -500
- package/dest/sequencer/automine/automine_factory.d.ts +54 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +84 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +151 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +509 -0
- package/dest/sequencer/chain_state_overrides.d.ts +52 -16
- package/dest/sequencer/chain_state_overrides.d.ts.map +1 -1
- package/dest/sequencer/chain_state_overrides.js +86 -27
- package/dest/sequencer/checkpoint_proposal_job.d.ts +24 -6
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +373 -83
- package/dest/sequencer/events.d.ts +42 -2
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/index.d.ts +3 -1
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +2 -0
- package/dest/sequencer/metrics.d.ts +3 -1
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +7 -0
- package/dest/sequencer/sequencer.d.ts +44 -9
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +256 -79
- package/dest/sequencer/timetable.d.ts +3 -6
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +3 -7
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/utils.d.ts +1 -1
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +7 -6
- package/package.json +27 -27
- package/src/client/sequencer-client.ts +12 -7
- package/src/config.ts +38 -10
- package/src/global_variable_builder/fee_provider.ts +1 -1
- package/src/global_variable_builder/global_builder.ts +2 -3
- package/src/index.ts +10 -1
- package/src/publisher/config.ts +2 -2
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher.ts +286 -521
- package/src/sequencer/README.md +162 -520
- package/src/sequencer/automine/README.md +46 -0
- package/src/sequencer/automine/automine_factory.ts +145 -0
- package/src/sequencer/automine/automine_sequencer.ts +595 -0
- package/src/sequencer/chain_state_overrides.ts +133 -58
- package/src/sequencer/checkpoint_proposal_job.ts +420 -100
- package/src/sequencer/events.ts +46 -2
- package/src/sequencer/index.ts +2 -0
- package/src/sequencer/metrics.ts +9 -0
- package/src/sequencer/sequencer.ts +284 -95
- package/src/sequencer/timetable.ts +2 -9
- package/src/sequencer/types.ts +1 -1
- package/src/test/utils.ts +28 -10
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { getKzg } from '@aztec/blob-lib';
|
|
2
|
-
import {
|
|
3
|
-
import type
|
|
4
|
-
import { NoCommitteeError, type RollupContract, SimulationOverridesBuilder } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { type EpochCache, PROPOSER_PIPELINING_SLOT_OFFSET } from '@aztec/epoch-cache';
|
|
3
|
+
import { NoCommitteeError, type RollupContract } from '@aztec/ethereum/contracts';
|
|
5
4
|
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
6
5
|
import { merge, omit, pick } from '@aztec/foundation/collection';
|
|
7
6
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
7
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
8
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
10
9
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
11
10
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
12
11
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
13
12
|
import type { P2P } from '@aztec/p2p';
|
|
14
13
|
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
15
|
-
import type {
|
|
14
|
+
import type {
|
|
15
|
+
BlockData,
|
|
16
|
+
L2BlockSink,
|
|
17
|
+
L2BlockSource,
|
|
18
|
+
ProposedCheckpointSink,
|
|
19
|
+
ValidateCheckpointResult,
|
|
20
|
+
} from '@aztec/stdlib/block';
|
|
16
21
|
import type { Checkpoint, ProposedCheckpointData } from '@aztec/stdlib/checkpoint';
|
|
17
|
-
import {
|
|
22
|
+
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
23
|
+
import { getEpochAtSlot, getSlotStartBuildTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
18
24
|
import {
|
|
19
25
|
type ResolvedSequencerConfig,
|
|
20
26
|
type SequencerConfig,
|
|
@@ -22,8 +28,9 @@ import {
|
|
|
22
28
|
type WorldStateSynchronizer,
|
|
23
29
|
} from '@aztec/stdlib/interfaces/server';
|
|
24
30
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
31
|
+
import type { CoordinationSignatureContext } from '@aztec/stdlib/p2p';
|
|
25
32
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
26
|
-
import {
|
|
33
|
+
import { MIN_EXECUTION_TIME } from '@aztec/stdlib/timetable';
|
|
27
34
|
import { Attributes, type TelemetryClient, type Tracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
28
35
|
import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
29
36
|
|
|
@@ -33,6 +40,7 @@ import { DefaultSequencerConfig } from '../config.js';
|
|
|
33
40
|
import type { GlobalVariableBuilder } from '../global_variable_builder/global_builder.js';
|
|
34
41
|
import type { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
35
42
|
import type { InvalidateCheckpointRequest, SequencerPublisher } from '../publisher/sequencer-publisher.js';
|
|
43
|
+
import { buildCheckpointSimulationOverridesPlan } from './chain_state_overrides.js';
|
|
36
44
|
import { CheckpointProposalJob } from './checkpoint_proposal_job.js';
|
|
37
45
|
import { CheckpointProposalJobMetrics } from './checkpoint_proposal_job_metrics.js';
|
|
38
46
|
import { CheckpointVoter } from './checkpoint_voter.js';
|
|
@@ -45,6 +53,16 @@ import { SequencerState } from './utils.js';
|
|
|
45
53
|
|
|
46
54
|
export { SequencerState };
|
|
47
55
|
|
|
56
|
+
/** Slot snapshot used to prepare a checkpoint proposal. */
|
|
57
|
+
type SequencerSlotContext = {
|
|
58
|
+
slot: SlotNumber;
|
|
59
|
+
targetSlot: SlotNumber;
|
|
60
|
+
epoch: EpochNumber;
|
|
61
|
+
targetEpoch: EpochNumber;
|
|
62
|
+
ts: bigint;
|
|
63
|
+
nowSeconds: bigint;
|
|
64
|
+
};
|
|
65
|
+
|
|
48
66
|
/**
|
|
49
67
|
* Sequencer client
|
|
50
68
|
* - Checks whether it is elected as proposer for the next slot
|
|
@@ -56,8 +74,11 @@ export { SequencerState };
|
|
|
56
74
|
export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<SequencerEvents>) {
|
|
57
75
|
private runningPromise?: RunningPromise;
|
|
58
76
|
private state = SequencerState.STOPPED;
|
|
77
|
+
private stateSlotNumber: SlotNumber | undefined;
|
|
78
|
+
private stateEnteredAtMs = performance.now();
|
|
59
79
|
private metrics: SequencerMetrics;
|
|
60
80
|
private checkpointProposalJobMetrics: CheckpointProposalJobMetrics;
|
|
81
|
+
private readonly stateLog: Logger;
|
|
61
82
|
|
|
62
83
|
/** The last slot for which we attempted to perform our voting duties with degraded block production */
|
|
63
84
|
private lastSlotForFallbackVote: SlotNumber | undefined;
|
|
@@ -82,6 +103,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
82
103
|
|
|
83
104
|
/** Config for the sequencer */
|
|
84
105
|
protected config: ResolvedSequencerConfig = DefaultSequencerConfig;
|
|
106
|
+
private readonly signatureContext: CoordinationSignatureContext;
|
|
85
107
|
|
|
86
108
|
constructor(
|
|
87
109
|
protected publisherFactory: SequencerPublisherFactory,
|
|
@@ -90,24 +112,29 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
90
112
|
protected p2pClient: P2P,
|
|
91
113
|
protected worldState: WorldStateSynchronizer,
|
|
92
114
|
protected slasherClient: SlasherClientInterface | undefined,
|
|
93
|
-
protected l2BlockSource: L2BlockSource & L2BlockSink,
|
|
115
|
+
protected l2BlockSource: L2BlockSource & L2BlockSink & ProposedCheckpointSink,
|
|
94
116
|
protected l1ToL2MessageSource: L1ToL2MessageSource,
|
|
95
117
|
protected checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
96
118
|
protected l1Constants: SequencerRollupConstants,
|
|
97
119
|
protected dateProvider: DateProvider,
|
|
98
120
|
protected epochCache: EpochCache,
|
|
99
121
|
protected rollupContract: RollupContract,
|
|
100
|
-
config: SequencerConfig,
|
|
122
|
+
config: SequencerConfig & Pick<ChainConfig, 'l1ChainId' | 'rollupAddress'>,
|
|
101
123
|
protected telemetry: TelemetryClient = getTelemetryClient(),
|
|
102
124
|
protected log = createLogger('sequencer'),
|
|
103
125
|
) {
|
|
104
126
|
super();
|
|
127
|
+
this.stateLog = log.createChild('state');
|
|
105
128
|
|
|
106
129
|
// Add [FISHERMAN] prefix to logger if in fisherman mode
|
|
107
130
|
if (config.fishermanMode) {
|
|
108
131
|
this.log = log.createChild('[FISHERMAN]');
|
|
109
132
|
}
|
|
110
133
|
|
|
134
|
+
this.signatureContext = {
|
|
135
|
+
chainId: config.l1ChainId,
|
|
136
|
+
rollupAddress: config.rollupAddress,
|
|
137
|
+
};
|
|
111
138
|
this.metrics = new SequencerMetrics(telemetry, this.rollupContract, 'Sequencer');
|
|
112
139
|
this.checkpointProposalJobMetrics = new CheckpointProposalJobMetrics(telemetry);
|
|
113
140
|
this.updateConfig(config);
|
|
@@ -127,7 +154,6 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
127
154
|
p2pPropagationTime,
|
|
128
155
|
blockDurationMs: this.config.blockDurationMs,
|
|
129
156
|
enforce: this.config.enforceTimeTable,
|
|
130
|
-
pipelining: this.epochCache.isProposerPipeliningEnabled(),
|
|
131
157
|
},
|
|
132
158
|
this.metrics,
|
|
133
159
|
this.log,
|
|
@@ -160,6 +186,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
160
186
|
public async stop(): Promise<void> {
|
|
161
187
|
this.log.info(`Stopping sequencer`);
|
|
162
188
|
this.setState(SequencerState.STOPPING, undefined, { force: true });
|
|
189
|
+
this.lastCheckpointProposalJob?.interrupt();
|
|
163
190
|
await this.publisherFactory.stopAll();
|
|
164
191
|
await this.runningPromise?.stop();
|
|
165
192
|
await this.lastCheckpointProposalJob?.awaitPendingSubmission();
|
|
@@ -172,17 +199,15 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
172
199
|
try {
|
|
173
200
|
await this.work();
|
|
174
201
|
} catch (err) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
)
|
|
181
|
-
? ('debug' as const)
|
|
182
|
-
: ('warn' as const);
|
|
183
|
-
this.log[logLvl](err.message, { now: this.dateProvider.nowInSeconds() });
|
|
202
|
+
if (
|
|
203
|
+
err instanceof SequencerTooSlowError &&
|
|
204
|
+
[SequencerState.INITIALIZING_CHECKPOINT, SequencerState.PROPOSER_CHECK].includes(err.proposedState)
|
|
205
|
+
) {
|
|
206
|
+
// No need to alert if we just didn't get to start in time
|
|
207
|
+
this.log.debug(err.message, { now: this.dateProvider.nowInSeconds() });
|
|
184
208
|
} else {
|
|
185
209
|
// Re-throw other errors
|
|
210
|
+
this.emit('checkpoint-error', { error: err as Error });
|
|
186
211
|
throw err;
|
|
187
212
|
}
|
|
188
213
|
} finally {
|
|
@@ -206,8 +231,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
206
231
|
@trackSpan('Sequencer.work')
|
|
207
232
|
protected async work() {
|
|
208
233
|
this.setState(SequencerState.SYNCHRONIZING, undefined);
|
|
209
|
-
const { slot, ts, nowSeconds
|
|
210
|
-
const { slot: targetSlot, epoch: targetEpoch } = this.epochCache.getTargetEpochAndSlotInNextL1Slot();
|
|
234
|
+
const { slot, targetSlot, epoch, targetEpoch, ts, nowSeconds } = this.getSlotContextInNextL1Slot();
|
|
211
235
|
|
|
212
236
|
// Check if we are synced and it's our slot, grab a publisher, check previous block invalidation, etc
|
|
213
237
|
const checkpointProposalJob = await this.prepareCheckpointProposal(
|
|
@@ -245,6 +269,13 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
245
269
|
return checkpoint;
|
|
246
270
|
}
|
|
247
271
|
|
|
272
|
+
/** Returns slot and target slot from a single clock snapshot. */
|
|
273
|
+
protected getSlotContextInNextL1Slot(): SequencerSlotContext {
|
|
274
|
+
const { slot, ts, nowSeconds, epoch } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
275
|
+
const targetSlot = SlotNumber(slot + PROPOSER_PIPELINING_SLOT_OFFSET);
|
|
276
|
+
return { slot, targetSlot, epoch, targetEpoch: getEpochAtSlot(targetSlot, this.l1Constants), ts, nowSeconds };
|
|
277
|
+
}
|
|
278
|
+
|
|
248
279
|
/**
|
|
249
280
|
* Prepares the checkpoint proposal by performing all necessary checks and setup.
|
|
250
281
|
* This is the initial step in the main loop.
|
|
@@ -279,6 +310,15 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
279
310
|
return undefined;
|
|
280
311
|
}
|
|
281
312
|
|
|
313
|
+
// Test-only: skip proposing for explicitly paused slots. Attestation paths run in the validator
|
|
314
|
+
// client and are not gated by this hook, so paused proposers still attest to others' proposals.
|
|
315
|
+
if (this.config.pauseProposingForSlots?.some(s => s === targetSlot)) {
|
|
316
|
+
this.log.warn(`Skipping proposal for paused slot ${targetSlot} (test-only pauseProposingForSlots hook)`, {
|
|
317
|
+
targetSlot,
|
|
318
|
+
});
|
|
319
|
+
return undefined;
|
|
320
|
+
}
|
|
321
|
+
|
|
282
322
|
// Check all components are synced to latest as seen by the archiver (queries all subsystems)
|
|
283
323
|
const syncedTo = await this.checkSync({ ts, slot });
|
|
284
324
|
if (!syncedTo) {
|
|
@@ -295,7 +335,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
295
335
|
this.setState(SequencerState.PROPOSER_CHECK, slot);
|
|
296
336
|
const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
|
|
297
337
|
if (canPropose) {
|
|
298
|
-
await this.tryVoteWhenEscapeHatchOpen({ slot, proposer });
|
|
338
|
+
await this.tryVoteWhenEscapeHatchOpen({ slot, targetSlot, proposer });
|
|
299
339
|
} else {
|
|
300
340
|
this.log.trace(`Escape hatch open but we are not proposer, skipping vote-only actions`, {
|
|
301
341
|
slot,
|
|
@@ -357,54 +397,96 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
357
397
|
const { attestorAddress, publisher } = await this.publisherFactory.create(proposerForPublisher);
|
|
358
398
|
this.log.verbose(`Created publisher at address ${publisher.getSenderAddress()} for attestor ${attestorAddress}`);
|
|
359
399
|
|
|
360
|
-
//
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
let invalidateCheckpoint = await publisher.simulateInvalidateCheckpoint(syncedTo.pendingChainValidationStatus);
|
|
400
|
+
// Prepare invalidation request if the pending chain is invalid (returns undefined if no need).
|
|
401
|
+
// Only simulate invalidation when there's no proposed parent, since we assume the proposed parent
|
|
402
|
+
// will invalidate the currently invalid checkpoint on L1.
|
|
403
|
+
const invalidateCheckpoint =
|
|
404
|
+
syncedTo.hasProposedCheckpoint || syncedTo.pendingChainValidationStatus.valid
|
|
405
|
+
? undefined
|
|
406
|
+
: await publisher.simulateInvalidateCheckpoint(syncedTo.pendingChainValidationStatus);
|
|
368
407
|
|
|
369
408
|
// Determine the correct archive and L1 state overrides for the canProposeAt check.
|
|
370
409
|
// The L1 contract reads archives[proposedCheckpointNumber] and compares it with the provided archive.
|
|
371
410
|
// When invalidating or pipelining, the local archive may differ from L1's, so we adjust accordingly.
|
|
372
411
|
let archiveForCheck = syncedTo.archive;
|
|
373
|
-
const l1SimulationOverridesBuilder = new SimulationOverridesBuilder();
|
|
374
|
-
|
|
375
|
-
if (this.epochCache.isProposerPipeliningEnabled() && syncedTo.hasProposedCheckpoint) {
|
|
376
|
-
// Parent checkpoint hasn't landed on L1 yet. Override both the proposed checkpoint number
|
|
377
|
-
// and the archive at that checkpoint so L1 simulation sees the correct chain tip.
|
|
378
|
-
const parentCheckpointNumber = CheckpointNumber(checkpointNumber - 1);
|
|
379
|
-
l1SimulationOverridesBuilder.forPendingCheckpoint(parentCheckpointNumber).withPendingArchive(syncedTo.archive);
|
|
380
|
-
this.metrics.recordPipelineDepth(1);
|
|
381
412
|
|
|
413
|
+
if (syncedTo.hasProposedCheckpoint) {
|
|
414
|
+
this.metrics.recordPipelineDepth(syncedTo.checkpointNumber - syncedTo.checkpointedCheckpointNumber);
|
|
382
415
|
this.log.verbose(
|
|
383
|
-
`Building on top of proposed checkpoint (pending=${syncedTo.proposedCheckpointData?.checkpointNumber})`,
|
|
416
|
+
`Building on top of proposed checkpoint (pending=${syncedTo.proposedCheckpointData?.checkpointNumber}) for target slot ${targetSlot}`,
|
|
417
|
+
{ targetSlot, parentCheckpointNumber: CheckpointNumber(checkpointNumber - 1) },
|
|
384
418
|
);
|
|
385
|
-
//
|
|
386
|
-
|
|
419
|
+
// Match what L1 will see at archives[pending] once the proposed parent lands: the parent's
|
|
420
|
+
// own archive root from the gossiped proposal. `syncedTo.archive` is the world-state-local
|
|
421
|
+
// view and can transiently diverge from the proposed parent (e.g. before the proposed
|
|
422
|
+
// parent's blocks have been applied locally); diverging here would cause the canProposeAt
|
|
423
|
+
// override to set archives[pending] to one value while we present another for comparison.
|
|
424
|
+
archiveForCheck = syncedTo.proposedCheckpointData!.archive.root;
|
|
387
425
|
} else if (invalidateCheckpoint) {
|
|
388
426
|
// After invalidation, L1 will roll back to checkpoint N-1. The archive at N-1 already
|
|
389
427
|
// exists on L1, so we just pass the matching archive (the lastArchive of the invalid checkpoint).
|
|
390
428
|
archiveForCheck = invalidateCheckpoint.lastArchive;
|
|
391
|
-
l1SimulationOverridesBuilder.forPendingCheckpoint(invalidateCheckpoint.forcePendingCheckpointNumber);
|
|
392
429
|
this.metrics.recordPipelineDepth(0);
|
|
393
430
|
} else {
|
|
394
431
|
this.metrics.recordPipelineDepth(0);
|
|
395
432
|
}
|
|
396
433
|
|
|
397
|
-
|
|
434
|
+
// Build the simulation plan: pending/proven override from pipelining or invalidation (or the
|
|
435
|
+
// current snapshot when neither applies, to short-circuit any pending prune in simulation),
|
|
436
|
+
// plus the parent checkpoint cell and fee header when pipelining.
|
|
437
|
+
const simulationOverridesPlan = await buildCheckpointSimulationOverridesPlan({
|
|
438
|
+
checkpointNumber,
|
|
439
|
+
proposedCheckpointData: syncedTo.hasProposedCheckpoint ? syncedTo.proposedCheckpointData : undefined,
|
|
440
|
+
invalidateToPendingCheckpointNumber: invalidateCheckpoint?.forcePendingCheckpointNumber,
|
|
441
|
+
checkpointedCheckpointNumber: syncedTo.checkpointedCheckpointNumber,
|
|
442
|
+
rollup: this.rollupContract,
|
|
443
|
+
signatureContext: this.signatureContext,
|
|
444
|
+
log: this.log,
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
// The plan always pins both pending/proven (to short-circuit `canPruneAtTime` in simulation),
|
|
448
|
+
// so `provenOverride` always reflects the assumed proven checkpoint we are pinning the
|
|
449
|
+
// simulation to. We additionally warn when the pin is load-bearing — i.e. when a prune would
|
|
450
|
+
// actually fire at the target slot without it — so observers can spot "we are building
|
|
451
|
+
// optimistically across a pruning boundary" in the logs.
|
|
452
|
+
const provenOverride = simulationOverridesPlan?.chainTipsOverride?.proven;
|
|
453
|
+
if (provenOverride !== undefined && (await this.l2BlockSource.isPruneDueAtSlot(targetSlot))) {
|
|
454
|
+
this.log.warn(
|
|
455
|
+
`Assuming proof for epoch ending at checkpoint ${provenOverride} lands by target slot ${targetSlot}`,
|
|
456
|
+
{ checkpointNumber, slot, targetSlot, provenOverride },
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
this.emit('preparing-checkpoint', {
|
|
461
|
+
targetSlot,
|
|
462
|
+
checkpointNumber,
|
|
463
|
+
hadProposedParent: syncedTo.hasProposedCheckpoint,
|
|
464
|
+
provenOverride,
|
|
465
|
+
simulatedPending: simulationOverridesPlan?.chainTipsOverride?.pending,
|
|
466
|
+
});
|
|
467
|
+
|
|
398
468
|
const canProposeCheck = await publisher.canProposeAt(
|
|
399
469
|
archiveForCheck,
|
|
400
470
|
proposer ?? EthAddress.ZERO,
|
|
401
471
|
simulationOverridesPlan,
|
|
402
472
|
);
|
|
403
473
|
|
|
474
|
+
const proposeContext = {
|
|
475
|
+
hasProposedCheckpoint: syncedTo.hasProposedCheckpoint,
|
|
476
|
+
proposedCheckpointNumber: syncedTo.proposedCheckpointData?.checkpointNumber,
|
|
477
|
+
checkpointedCheckpointNumber: syncedTo.checkpointedCheckpointNumber,
|
|
478
|
+
isInvalidating: !!invalidateCheckpoint,
|
|
479
|
+
invalidatingCheckpointNumber: invalidateCheckpoint?.checkpointNumber,
|
|
480
|
+
archiveForCheck: archiveForCheck.toString(),
|
|
481
|
+
overridePendingCheckpointNumber: simulationOverridesPlan?.chainTipsOverride?.pending,
|
|
482
|
+
overrideArchive: simulationOverridesPlan?.pendingCheckpointState?.archive,
|
|
483
|
+
overrideFeeHeader: simulationOverridesPlan?.pendingCheckpointState?.feeHeader,
|
|
484
|
+
};
|
|
485
|
+
|
|
404
486
|
if (canProposeCheck === undefined) {
|
|
405
487
|
this.log.warn(
|
|
406
488
|
`Cannot propose checkpoint ${checkpointNumber} at slot ${slot} due to failed rollup contract check`,
|
|
407
|
-
logCtx,
|
|
489
|
+
{ ...logCtx, ...proposeContext },
|
|
408
490
|
);
|
|
409
491
|
this.emit('proposer-rollup-check-failed', { reason: 'Rollup contract check failed', slot });
|
|
410
492
|
this.metrics.recordCheckpointPrecheckFailed('rollup_contract_check_failed');
|
|
@@ -414,7 +496,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
414
496
|
if (canProposeCheck.slot !== targetSlot) {
|
|
415
497
|
this.log.warn(
|
|
416
498
|
`Cannot propose block due to slot mismatch with rollup contract (this can be caused by a clock out of sync). Expected slot ${targetSlot} but got ${canProposeCheck.slot}.`,
|
|
417
|
-
{ ...logCtx, rollup: canProposeCheck, expectedSlot: targetSlot },
|
|
499
|
+
{ ...logCtx, ...proposeContext, rollup: canProposeCheck, expectedSlot: targetSlot },
|
|
418
500
|
);
|
|
419
501
|
this.emit('proposer-rollup-check-failed', { reason: 'Slot mismatch', slot });
|
|
420
502
|
this.metrics.recordCheckpointPrecheckFailed('slot_mismatch');
|
|
@@ -424,7 +506,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
424
506
|
if (canProposeCheck.checkpointNumber !== checkpointNumber) {
|
|
425
507
|
this.log.warn(
|
|
426
508
|
`Cannot propose due to block mismatch with rollup contract (this can be caused by a pending archiver sync). Expected checkpoint ${checkpointNumber} but got ${canProposeCheck.checkpointNumber}.`,
|
|
427
|
-
{ ...logCtx, rollup: canProposeCheck, expectedSlot: slot },
|
|
509
|
+
{ ...logCtx, ...proposeContext, rollup: canProposeCheck, expectedSlot: slot },
|
|
428
510
|
);
|
|
429
511
|
this.emit('proposer-rollup-check-failed', { reason: 'Block mismatch', slot });
|
|
430
512
|
this.metrics.recordCheckpointPrecheckFailed('block_number_mismatch');
|
|
@@ -438,8 +520,8 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
438
520
|
`Preparing checkpoint proposal ${checkpointNumber} for target slot ${targetSlot} during wall-clock slot ${slot}`,
|
|
439
521
|
{
|
|
440
522
|
...logCtx,
|
|
523
|
+
...proposeContext,
|
|
441
524
|
proposer,
|
|
442
|
-
pipeliningEnabled: this.epochCache.isProposerPipeliningEnabled(),
|
|
443
525
|
},
|
|
444
526
|
);
|
|
445
527
|
|
|
@@ -450,6 +532,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
450
532
|
targetEpoch,
|
|
451
533
|
checkpointNumber,
|
|
452
534
|
syncedTo.blockNumber,
|
|
535
|
+
syncedTo.checkpointedCheckpointNumber,
|
|
453
536
|
proposer,
|
|
454
537
|
publisher,
|
|
455
538
|
attestorAddress,
|
|
@@ -464,6 +547,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
464
547
|
targetEpoch: EpochNumber,
|
|
465
548
|
checkpointNumber: CheckpointNumber,
|
|
466
549
|
syncedToBlockNumber: BlockNumber,
|
|
550
|
+
checkpointedCheckpointNumber: CheckpointNumber,
|
|
467
551
|
proposer: EthAddress | undefined,
|
|
468
552
|
publisher: SequencerPublisher,
|
|
469
553
|
attestorAddress: EthAddress,
|
|
@@ -476,6 +560,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
476
560
|
targetEpoch,
|
|
477
561
|
checkpointNumber,
|
|
478
562
|
syncedToBlockNumber,
|
|
563
|
+
checkpointedCheckpointNumber,
|
|
479
564
|
proposer,
|
|
480
565
|
publisher,
|
|
481
566
|
attestorAddress,
|
|
@@ -489,6 +574,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
489
574
|
this.checkpointsBuilder,
|
|
490
575
|
this.l2BlockSource,
|
|
491
576
|
this.l1Constants,
|
|
577
|
+
this.signatureContext,
|
|
492
578
|
this.config,
|
|
493
579
|
this.timetable,
|
|
494
580
|
this.slasherClient,
|
|
@@ -497,7 +583,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
497
583
|
this.metrics,
|
|
498
584
|
this.checkpointProposalJobMetrics.createRecorder(),
|
|
499
585
|
this,
|
|
500
|
-
this.setState
|
|
586
|
+
(state, slot, timeReferenceSlot) => this.setState(state, slot, { timeReferenceSlot }),
|
|
501
587
|
this.tracer,
|
|
502
588
|
this.log.getBindings(),
|
|
503
589
|
proposedCheckpointData,
|
|
@@ -514,13 +600,14 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
514
600
|
/**
|
|
515
601
|
* Internal helper for setting the sequencer state and checks if we have enough time left in the slot to transition to the new state.
|
|
516
602
|
* @param proposedState - The new state to transition to.
|
|
517
|
-
* @param slotNumber - The
|
|
603
|
+
* @param slotNumber - The logical slot associated with the new state.
|
|
518
604
|
* @param force - Whether to force the transition even if the sequencer is stopped.
|
|
605
|
+
* @param timeReferenceSlot - The slot to use for deadline checks when it differs from the logical slot.
|
|
519
606
|
*/
|
|
520
607
|
protected setState(
|
|
521
608
|
proposedState: SequencerState,
|
|
522
609
|
slotNumber: SlotNumber | undefined,
|
|
523
|
-
opts: { force?: boolean } = {},
|
|
610
|
+
opts: { force?: boolean; timeReferenceSlot?: SlotNumber } = {},
|
|
524
611
|
): void {
|
|
525
612
|
if (this.state === SequencerState.STOPPING && proposedState !== SequencerState.STOPPED && !opts.force) {
|
|
526
613
|
this.log.warn(`Cannot set sequencer to ${proposedState} as it is stopping.`);
|
|
@@ -531,24 +618,43 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
531
618
|
return;
|
|
532
619
|
}
|
|
533
620
|
let secondsIntoSlot = undefined;
|
|
534
|
-
|
|
535
|
-
|
|
621
|
+
const timeReferenceSlot = opts.timeReferenceSlot ?? slotNumber;
|
|
622
|
+
if (timeReferenceSlot !== undefined) {
|
|
623
|
+
secondsIntoSlot = this.getSecondsIntoSlot(timeReferenceSlot);
|
|
536
624
|
this.timetable.assertTimeLeft(proposedState, secondsIntoSlot);
|
|
537
625
|
}
|
|
538
626
|
|
|
627
|
+
const oldState = this.state;
|
|
628
|
+
const oldStateSlotNumber = this.stateSlotNumber;
|
|
629
|
+
const stateChanged = proposedState !== oldState;
|
|
630
|
+
const transitionAtMs = performance.now();
|
|
631
|
+
const stateDurationMs = transitionAtMs - this.stateEnteredAtMs;
|
|
632
|
+
|
|
539
633
|
const boringStates = [SequencerState.IDLE, SequencerState.SYNCHRONIZING];
|
|
540
634
|
const logLevel =
|
|
541
|
-
boringStates.includes(proposedState) && boringStates.includes(
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
635
|
+
boringStates.includes(proposedState) && boringStates.includes(oldState) ? ('trace' as const) : ('debug' as const);
|
|
636
|
+
this.stateLog[logLevel](`Transitioning from ${oldState} to ${proposedState}`, {
|
|
637
|
+
oldState,
|
|
638
|
+
newState: proposedState,
|
|
639
|
+
slotNumber,
|
|
640
|
+
timeReferenceSlot,
|
|
641
|
+
stateSlotNumber: oldStateSlotNumber,
|
|
642
|
+
secondsIntoSlot,
|
|
643
|
+
...(stateChanged && { stateDurationMs: Math.ceil(stateDurationMs) }),
|
|
644
|
+
});
|
|
545
645
|
|
|
546
646
|
this.emit('state-changed', {
|
|
547
|
-
oldState
|
|
647
|
+
oldState,
|
|
548
648
|
newState: proposedState,
|
|
549
649
|
secondsIntoSlot,
|
|
550
650
|
slot: slotNumber,
|
|
651
|
+
timeReferenceSlot,
|
|
551
652
|
});
|
|
653
|
+
if (stateChanged) {
|
|
654
|
+
this.metrics.recordStateDuration(stateDurationMs, oldState);
|
|
655
|
+
this.stateEnteredAtMs = transitionAtMs;
|
|
656
|
+
this.stateSlotNumber = slotNumber;
|
|
657
|
+
}
|
|
552
658
|
this.state = proposedState;
|
|
553
659
|
}
|
|
554
660
|
|
|
@@ -581,29 +687,18 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
581
687
|
this.p2pClient.getStatus().then(p2p => p2p.syncedToL2Block),
|
|
582
688
|
this.l1ToL2MessageSource.getL2Tips().then(t => ({ proposed: t.proposed, checkpointed: t.checkpointed })),
|
|
583
689
|
this.l2BlockSource.getPendingChainValidationStatus(),
|
|
584
|
-
this.l2BlockSource.
|
|
690
|
+
this.l2BlockSource.getProposedCheckpointData(),
|
|
585
691
|
] as const);
|
|
586
692
|
|
|
587
693
|
const [worldState, l2Tips, p2p, l1ToL2MessageSourceTips, pendingChainValidationStatus, proposedCheckpointData] =
|
|
588
694
|
syncedBlocks;
|
|
589
695
|
|
|
590
|
-
// Handle zero as a special case, since the block hash won't match across services if we're changing the prefilled data for the genesis block,
|
|
591
|
-
// as the world state can compute the new genesis block hash, but other components use the hardcoded constant.
|
|
592
|
-
// TODO(palla/mbps): Fix the above. All components should be able to handle dynamic genesis block hashes.
|
|
593
696
|
const result =
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
l1ToL2MessageSourceTips.proposed.number === 0 &&
|
|
600
|
-
l1ToL2MessageSourceTips.checkpointed.block.number === 0 &&
|
|
601
|
-
l1ToL2MessageSourceTips.checkpointed.checkpoint.number === 0) ||
|
|
602
|
-
(worldState.hash === l2Tips.proposed.hash &&
|
|
603
|
-
p2p.hash === l2Tips.proposed.hash &&
|
|
604
|
-
l1ToL2MessageSourceTips.proposed.hash === l2Tips.proposed.hash &&
|
|
605
|
-
l1ToL2MessageSourceTips.checkpointed.block.hash === l2Tips.checkpointed.block.hash &&
|
|
606
|
-
l1ToL2MessageSourceTips.checkpointed.checkpoint.hash === l2Tips.checkpointed.checkpoint.hash);
|
|
697
|
+
worldState.hash === l2Tips.proposed.hash &&
|
|
698
|
+
p2p.hash === l2Tips.proposed.hash &&
|
|
699
|
+
l1ToL2MessageSourceTips.proposed.hash === l2Tips.proposed.hash &&
|
|
700
|
+
l1ToL2MessageSourceTips.checkpointed.block.hash === l2Tips.checkpointed.block.hash &&
|
|
701
|
+
l1ToL2MessageSourceTips.checkpointed.checkpoint.hash === l2Tips.checkpointed.checkpoint.hash;
|
|
607
702
|
|
|
608
703
|
if (!result) {
|
|
609
704
|
this.log.debug(`Sequencer sync check failed`, {
|
|
@@ -615,30 +710,87 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
615
710
|
return undefined;
|
|
616
711
|
}
|
|
617
712
|
|
|
618
|
-
// Special case for genesis state
|
|
619
713
|
const blockNumber = worldState.number;
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
blockNumber: BlockNumber.ZERO,
|
|
626
|
-
archive,
|
|
627
|
-
hasProposedCheckpoint: false,
|
|
714
|
+
const blockData = await this.l2BlockSource.getBlockData({ number: blockNumber });
|
|
715
|
+
if (!blockData) {
|
|
716
|
+
this.log.warn(`Sequencer sync check failed: failed to get L2 block data ${blockNumber} from the archiver`, {
|
|
717
|
+
blockNumber,
|
|
718
|
+
l2Tips,
|
|
628
719
|
syncedL2Slot,
|
|
629
|
-
|
|
630
|
-
};
|
|
720
|
+
...args,
|
|
721
|
+
});
|
|
722
|
+
return undefined;
|
|
631
723
|
}
|
|
632
724
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
725
|
+
// Refuse to build a checkpoint on top of a proposed block whose enclosing checkpoint was never
|
|
726
|
+
// proposed. Under pipelining we may have received and reexecuted such a block locally — advancing
|
|
727
|
+
// our world-state tip past the checkpointed tip — while the proposing node never published the
|
|
728
|
+
// matching proposed checkpoint (e.g. it crashed before assembling it). Building on this orphan block
|
|
729
|
+
// would fork the chain off a tip no other node can follow. The archiver prunes these orphan blocks
|
|
730
|
+
// once their build slot ends; this guard is the correctness barrier during the grace window before.
|
|
731
|
+
if (
|
|
732
|
+
blockData.checkpointNumber > l2Tips.checkpointed.checkpoint.number &&
|
|
733
|
+
(l2Tips.proposedCheckpoint.checkpoint.number !== blockData.checkpointNumber ||
|
|
734
|
+
proposedCheckpointData?.checkpointNumber !== blockData.checkpointNumber)
|
|
735
|
+
) {
|
|
736
|
+
const logCtx = {
|
|
737
|
+
blockCheckpointNumber: blockData.checkpointNumber,
|
|
738
|
+
checkpointedCheckpointNumber: l2Tips.checkpointed.checkpoint.number,
|
|
739
|
+
proposedCheckpointTipNumber: l2Tips.proposedCheckpoint.checkpoint.number,
|
|
740
|
+
proposedCheckpointDataNumber: proposedCheckpointData?.checkpointNumber,
|
|
741
|
+
blockNumber: blockData.header.getBlockNumber(),
|
|
742
|
+
blockSlot: blockData.header.getSlot(),
|
|
743
|
+
syncedL2Slot,
|
|
744
|
+
...args,
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
// Under pipelining the block proposal for a checkpoint leads its checkpoint proposal by up to one
|
|
748
|
+
// slot, so a world-state tip sitting in an as-yet-unproposed checkpoint is the expected steady state
|
|
749
|
+
// until that checkpoint is due. Only treat it as abnormal — and warn — once the checkpoint is overdue
|
|
750
|
+
// by the same deadline the archiver uses to prune the orphan block (see pruneOrphanProposedBlocks).
|
|
751
|
+
// Before then this is normal pipelining and we wait it out quietly.
|
|
752
|
+
if (this.isProposedCheckpointOverdue(blockData.header.getSlot())) {
|
|
753
|
+
this.log.warn(`Sequencer sync check failed: proposed block has no matching proposed checkpoint`, logCtx);
|
|
754
|
+
} else {
|
|
755
|
+
this.log.debug(`Waiting for proposed checkpoint to catch up with reexecuted block`, logCtx);
|
|
756
|
+
}
|
|
637
757
|
return undefined;
|
|
638
758
|
}
|
|
639
759
|
|
|
640
760
|
const hasProposedCheckpoint = l2Tips.proposedCheckpoint.checkpoint.number > l2Tips.checkpointed.checkpoint.number;
|
|
641
761
|
|
|
762
|
+
// The l2Tips and proposedCheckpointData reads above come from independent archiver snapshots
|
|
763
|
+
// (a JS-side tips cache vs. a direct store read on `#proposedCheckpoints`). A concurrent archiver
|
|
764
|
+
// write that mutates both can be observed split, leaving us with `hasProposedCheckpoint=true` but
|
|
765
|
+
// no proposedCheckpointData (or one whose number doesn't match the tip). Refuse to proceed in that
|
|
766
|
+
// window — the next checkSync tick will see a coherent snapshot.
|
|
767
|
+
if (
|
|
768
|
+
hasProposedCheckpoint &&
|
|
769
|
+
(!proposedCheckpointData ||
|
|
770
|
+
proposedCheckpointData.checkpointNumber !== l2Tips.proposedCheckpoint.checkpoint.number)
|
|
771
|
+
) {
|
|
772
|
+
this.log.warn(`Sequencer sync check failed: inconsistent proposed-checkpoint state`, {
|
|
773
|
+
proposedCheckpointTipNumber: l2Tips.proposedCheckpoint.checkpoint.number,
|
|
774
|
+
checkpointedTipNumber: l2Tips.checkpointed.checkpoint.number,
|
|
775
|
+
proposedCheckpointDataNumber: proposedCheckpointData?.checkpointNumber,
|
|
776
|
+
syncedL2Slot,
|
|
777
|
+
...args,
|
|
778
|
+
});
|
|
779
|
+
return undefined;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// Check that the proposed checkpoint is indeed the parent of the checkpoint we'll be building
|
|
783
|
+
// The checkpoint number to build is derived as blockData.checkpointNumber + 1
|
|
784
|
+
if (proposedCheckpointData && proposedCheckpointData.checkpointNumber !== blockData.checkpointNumber) {
|
|
785
|
+
this.log.warn(`Sequencer sync check failed: proposed checkpoint number mismatch`, {
|
|
786
|
+
proposedCheckpointNumber: proposedCheckpointData.checkpointNumber,
|
|
787
|
+
blockCheckpointNumber: blockData.checkpointNumber,
|
|
788
|
+
syncedL2Slot,
|
|
789
|
+
...args,
|
|
790
|
+
});
|
|
791
|
+
return undefined;
|
|
792
|
+
}
|
|
793
|
+
|
|
642
794
|
return {
|
|
643
795
|
blockData,
|
|
644
796
|
blockNumber: blockData.header.getBlockNumber(),
|
|
@@ -652,6 +804,21 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
652
804
|
};
|
|
653
805
|
}
|
|
654
806
|
|
|
807
|
+
/**
|
|
808
|
+
* Whether the enclosing checkpoint of a reexecuted block is overdue: past the deadline by which a
|
|
809
|
+
* well-behaved proposer should have published it. Mirrors the archiver's orphan-prune deadline (the
|
|
810
|
+
* start of the slot after the block's build slot, plus a grace period) so the sequencer only warns
|
|
811
|
+
* about a missing proposed checkpoint once the archiver itself would prune the orphan block. The grace
|
|
812
|
+
* is derived from the block build duration the same way the archiver defaults it at node wiring.
|
|
813
|
+
*/
|
|
814
|
+
private isProposedCheckpointOverdue(blockSlot: SlotNumber): boolean {
|
|
815
|
+
const expectedBySlot = SlotNumber(Number(blockSlot) - PROPOSER_PIPELINING_SLOT_OFFSET + 1);
|
|
816
|
+
const graceSeconds =
|
|
817
|
+
this.config.blockDurationMs !== undefined ? Math.ceil(this.config.blockDurationMs / 1000) : MIN_EXECUTION_TIME;
|
|
818
|
+
const expectedByTime = getTimestampForSlot(expectedBySlot, this.l1Constants) + BigInt(graceSeconds);
|
|
819
|
+
return BigInt(this.dateProvider.nowInSeconds()) >= expectedByTime;
|
|
820
|
+
}
|
|
821
|
+
|
|
655
822
|
/**
|
|
656
823
|
* Checks if we are the proposer for the next slot.
|
|
657
824
|
* @returns True if we can propose, and the proposer address (undefined if anyone can propose)
|
|
@@ -773,7 +940,13 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
773
940
|
}
|
|
774
941
|
|
|
775
942
|
this.log.info(`Voting in slot ${slot} despite sync failure`, { slot });
|
|
776
|
-
|
|
943
|
+
// Votes are EIP-712-signed for `targetSlot` (the pipelined slot in which the multicall is
|
|
944
|
+
// expected to mine). Delay submission to the start of `targetSlot` so the tx mines in the
|
|
945
|
+
// slot the votes were signed for. We fire-and-forget so we don't block the sequencer's
|
|
946
|
+
// work loop while waiting for the target slot to start.
|
|
947
|
+
void publisher.sendRequestsAt(targetSlot).catch(err => {
|
|
948
|
+
this.log.error(`Failed to publish votes despite sync failure for slot ${slot}`, err, { slot });
|
|
949
|
+
});
|
|
777
950
|
}
|
|
778
951
|
|
|
779
952
|
/**
|
|
@@ -783,9 +956,10 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
783
956
|
@trackSpan('Sequencer.tryVoteWhenEscapeHatchOpen', ({ slot }) => ({ [Attributes.SLOT_NUMBER]: slot }))
|
|
784
957
|
protected async tryVoteWhenEscapeHatchOpen(args: {
|
|
785
958
|
slot: SlotNumber;
|
|
959
|
+
targetSlot: SlotNumber;
|
|
786
960
|
proposer: EthAddress | undefined;
|
|
787
961
|
}): Promise<void> {
|
|
788
|
-
const { slot, proposer } = args;
|
|
962
|
+
const { slot, targetSlot, proposer } = args;
|
|
789
963
|
|
|
790
964
|
// Prevent duplicate attempts in the same slot
|
|
791
965
|
if (this.lastSlotForFallbackVote === slot) {
|
|
@@ -798,10 +972,18 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
798
972
|
|
|
799
973
|
const { attestorAddress, publisher } = await this.publisherFactory.create(proposer);
|
|
800
974
|
|
|
801
|
-
this.log.debug(`Escape hatch open for slot ${slot}, attempting vote-only actions`, {
|
|
975
|
+
this.log.debug(`Escape hatch open for slot ${slot}, attempting vote-only actions`, {
|
|
976
|
+
slot,
|
|
977
|
+
targetSlot,
|
|
978
|
+
attestorAddress,
|
|
979
|
+
});
|
|
802
980
|
|
|
981
|
+
// Under proposer pipelining, the multicall is expected to mine in `targetSlot` (slot + 1).
|
|
982
|
+
// Governance and slashing votes are EIP-712-signed against the slot they will mine in, and the
|
|
983
|
+
// L1 contract checks `msg.sender == getCurrentProposer()` using the mining slot. So we must
|
|
984
|
+
// sign for `targetSlot` and delay submission to the start of `targetSlot`.
|
|
803
985
|
const voter = new CheckpointVoter(
|
|
804
|
-
|
|
986
|
+
targetSlot,
|
|
805
987
|
publisher,
|
|
806
988
|
attestorAddress,
|
|
807
989
|
this.validatorClient,
|
|
@@ -820,8 +1002,15 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
820
1002
|
return;
|
|
821
1003
|
}
|
|
822
1004
|
|
|
823
|
-
this.log.info(`Voting in slot ${slot} (escape hatch open)`, { slot });
|
|
824
|
-
|
|
1005
|
+
this.log.info(`Voting in slot ${slot} (escape hatch open)`, { slot, targetSlot });
|
|
1006
|
+
// Votes are EIP-712-signed for `targetSlot`. Delay submission to the start of `targetSlot` so
|
|
1007
|
+
// the multicall mines in the slot the votes were signed for; otherwise the L1 contract reads
|
|
1008
|
+
// `signaler = getCurrentProposer()` against the wrong slot and signature verification fails
|
|
1009
|
+
// silently inside Multicall3. Fire-and-forget so we don't block the sequencer's work loop while
|
|
1010
|
+
// waiting for the target slot to start, mirroring tryVoteWhenSyncFails.
|
|
1011
|
+
void publisher.sendRequestsAt(targetSlot).catch(err => {
|
|
1012
|
+
this.log.error(`Failed to publish escape-hatch votes for slot ${slot}`, err, { slot, targetSlot });
|
|
1013
|
+
});
|
|
825
1014
|
}
|
|
826
1015
|
|
|
827
1016
|
/**
|