@aztec/sequencer-client 0.0.1-commit.993d52e → 0.0.1-commit.9a89641
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 +23 -5
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +63 -36
- package/dest/config.d.ts +32 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +76 -32
- package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_predictor.js +138 -0
- package/dest/global_variable_builder/fee_provider.d.ts +21 -0
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_provider.js +80 -0
- package/dest/global_variable_builder/global_builder.d.ts +13 -26
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +9 -66
- package/dest/global_variable_builder/index.d.ts +4 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/global_variable_builder/index.js +2 -0
- package/dest/publisher/config.d.ts +23 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +36 -6
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_to_l2_messaging.d.ts +21 -0
- package/dest/publisher/l1_to_l2_messaging.d.ts.map +1 -0
- package/dest/publisher/l1_to_l2_messaging.js +70 -0
- 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 +98 -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 +68 -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 +36 -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 +3 -0
- 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-factory.d.ts +3 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +16 -3
- package/dest/publisher/sequencer-publisher.d.ts +112 -65
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +758 -388
- package/dest/publisher/write_json.d.ts +11 -0
- package/dest/publisher/write_json.d.ts.map +1 -0
- package/dest/publisher/write_json.js +57 -0
- package/dest/sequencer/automine/automine_factory.d.ts +56 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +85 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +189 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +696 -0
- package/dest/sequencer/automine/index.d.ts +3 -0
- package/dest/sequencer/automine/index.d.ts.map +1 -0
- package/dest/sequencer/automine/index.js +2 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +75 -19
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +846 -264
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
- 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/events.d.ts +62 -5
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +13 -10
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +45 -20
- package/dest/sequencer/missing_committee.d.ts +72 -0
- package/dest/sequencer/missing_committee.d.ts.map +1 -0
- package/dest/sequencer/missing_committee.js +139 -0
- package/dest/sequencer/requests_tracker.d.ts +22 -0
- package/dest/sequencer/requests_tracker.d.ts.map +1 -0
- package/dest/sequencer/requests_tracker.js +33 -0
- package/dest/sequencer/sequencer.d.ts +167 -41
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +604 -200
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +3 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +7 -9
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +39 -30
- package/dest/test/utils.d.ts +15 -1
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +25 -7
- package/package.json +29 -29
- package/src/client/sequencer-client.ts +90 -45
- package/src/config.ts +92 -33
- package/src/global_variable_builder/README.md +44 -0
- package/src/global_variable_builder/fee_predictor.ts +182 -0
- package/src/global_variable_builder/fee_provider.ts +97 -0
- package/src/global_variable_builder/global_builder.ts +19 -88
- package/src/global_variable_builder/index.ts +3 -1
- package/src/publisher/config.ts +71 -7
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_to_l2_messaging.ts +85 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +164 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +47 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +18 -6
- package/src/publisher/sequencer-publisher.ts +847 -474
- package/src/publisher/write_json.ts +78 -0
- package/src/sequencer/README.md +162 -450
- package/src/sequencer/automine/README.md +60 -0
- package/src/sequencer/automine/automine_factory.ts +152 -0
- package/src/sequencer/automine/automine_sequencer.ts +800 -0
- package/src/sequencer/automine/index.ts +6 -0
- package/src/sequencer/checkpoint_proposal_job.ts +1002 -298
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/events.ts +66 -5
- package/src/sequencer/metrics.ts +57 -24
- package/src/sequencer/missing_committee.ts +192 -0
- package/src/sequencer/requests_tracker.ts +43 -0
- package/src/sequencer/sequencer.ts +711 -223
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -2
- package/src/test/mock_checkpoint_builder.ts +51 -48
- package/src/test/utils.ts +61 -10
- package/dest/sequencer/timetable.d.ts +0 -87
- package/dest/sequencer/timetable.d.ts.map +0 -1
- package/dest/sequencer/timetable.js +0 -223
- package/src/sequencer/timetable.ts +0 -283
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
import { getKzg } from '@aztec/blob-lib';
|
|
2
|
-
import {
|
|
3
|
-
import type { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
+
import { type EpochCache, PROPOSER_PIPELINING_SLOT_OFFSET } from '@aztec/epoch-cache';
|
|
4
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 {
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
import type {
|
|
15
|
+
BlockData,
|
|
16
|
+
L2BlockSink,
|
|
17
|
+
L2BlockSource,
|
|
18
|
+
ProposedCheckpointSink,
|
|
19
|
+
ValidateCheckpointResult,
|
|
20
|
+
} from '@aztec/stdlib/block';
|
|
21
|
+
import {
|
|
22
|
+
type Checkpoint,
|
|
23
|
+
type ProposedCheckpointData,
|
|
24
|
+
buildCheckpointSimulationOverridesPlan,
|
|
25
|
+
} from '@aztec/stdlib/checkpoint';
|
|
26
|
+
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
27
|
+
import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
28
|
+
import {
|
|
29
|
+
MIN_PER_BLOCK_ALLOCATION_MULTIPLIER,
|
|
30
|
+
MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER,
|
|
31
|
+
computeNetworkTxGasLimits,
|
|
32
|
+
} from '@aztec/stdlib/gas';
|
|
18
33
|
import {
|
|
19
34
|
type ResolvedSequencerConfig,
|
|
20
35
|
type SequencerConfig,
|
|
@@ -22,8 +37,9 @@ import {
|
|
|
22
37
|
type WorldStateSynchronizer,
|
|
23
38
|
} from '@aztec/stdlib/interfaces/server';
|
|
24
39
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
40
|
+
import type { CoordinationSignatureContext } from '@aztec/stdlib/p2p';
|
|
25
41
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
26
|
-
import {
|
|
42
|
+
import { ProposerTimetable, buildProposerTimetable } from '@aztec/stdlib/timetable';
|
|
27
43
|
import { Attributes, type TelemetryClient, type Tracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
28
44
|
import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
29
45
|
|
|
@@ -34,16 +50,28 @@ import type { GlobalVariableBuilder } from '../global_variable_builder/global_bu
|
|
|
34
50
|
import type { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
35
51
|
import type { InvalidateCheckpointRequest, SequencerPublisher } from '../publisher/sequencer-publisher.js';
|
|
36
52
|
import { CheckpointProposalJob } from './checkpoint_proposal_job.js';
|
|
53
|
+
import { CheckpointProposalJobMetrics } from './checkpoint_proposal_job_metrics.js';
|
|
37
54
|
import { CheckpointVoter } from './checkpoint_voter.js';
|
|
38
|
-
import { SequencerInterruptedError
|
|
55
|
+
import { SequencerInterruptedError } from './errors.js';
|
|
39
56
|
import type { SequencerEvents } from './events.js';
|
|
40
57
|
import { SequencerMetrics } from './metrics.js';
|
|
41
|
-
import {
|
|
58
|
+
import { logMissingCommittee } from './missing_committee.js';
|
|
59
|
+
import { RequestsTracker } from './requests_tracker.js';
|
|
42
60
|
import type { SequencerRollupConstants } from './types.js';
|
|
43
61
|
import { SequencerState } from './utils.js';
|
|
44
62
|
|
|
45
63
|
export { SequencerState };
|
|
46
64
|
|
|
65
|
+
/** Slot snapshot used to prepare a checkpoint proposal. */
|
|
66
|
+
type SequencerSlotContext = {
|
|
67
|
+
slot: SlotNumber;
|
|
68
|
+
targetSlot: SlotNumber;
|
|
69
|
+
epoch: EpochNumber;
|
|
70
|
+
targetEpoch: EpochNumber;
|
|
71
|
+
ts: bigint;
|
|
72
|
+
nowSeconds: bigint;
|
|
73
|
+
};
|
|
74
|
+
|
|
47
75
|
/**
|
|
48
76
|
* Sequencer client
|
|
49
77
|
* - Checks whether it is elected as proposer for the next slot
|
|
@@ -53,18 +81,27 @@ export { SequencerState };
|
|
|
53
81
|
* - Votes for proposals and slashes on L1
|
|
54
82
|
*/
|
|
55
83
|
export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<SequencerEvents>) {
|
|
56
|
-
|
|
84
|
+
protected runningPromise?: RunningPromise;
|
|
57
85
|
private state = SequencerState.STOPPED;
|
|
86
|
+
private stateSlotNumber: SlotNumber | undefined;
|
|
87
|
+
/** Wall-clock time (ms, via the date provider) at which the current state was entered. */
|
|
88
|
+
private stateEnteredAtMs: number;
|
|
58
89
|
private metrics: SequencerMetrics;
|
|
90
|
+
private checkpointProposalJobMetrics: CheckpointProposalJobMetrics;
|
|
91
|
+
private readonly stateLog: Logger;
|
|
92
|
+
|
|
93
|
+
/** The last slot for which we attempted to perform our fallback duties (votes and/or prune) with degraded block production */
|
|
94
|
+
private lastSlotForFallbackAction: SlotNumber | undefined;
|
|
59
95
|
|
|
60
|
-
/** The
|
|
61
|
-
|
|
96
|
+
/** The (checkpoint, slot) of the last invalidation request we successfully simulated, to prevent
|
|
97
|
+
* re-simulating and re-submitting the same invalidation across the many ticks within a single slot. */
|
|
98
|
+
private lastInvalidationAttempt: { slot: SlotNumber; checkpointNumber: CheckpointNumber } | undefined;
|
|
62
99
|
|
|
63
|
-
/** The last
|
|
64
|
-
private
|
|
100
|
+
/** The last epoch for which we logged a "no committee" diagnostic, to avoid per-slot log spam. */
|
|
101
|
+
private lastEpochForNoCommitteeLog: EpochNumber | undefined;
|
|
65
102
|
|
|
66
103
|
/** The last slot for which we triggered a checkpoint proposal job, to prevent duplicate attempts. */
|
|
67
|
-
|
|
104
|
+
protected lastSlotForCheckpointProposalJob: SlotNumber | undefined;
|
|
68
105
|
|
|
69
106
|
/** Last successful checkpoint proposed */
|
|
70
107
|
private lastCheckpointProposed: Checkpoint | undefined;
|
|
@@ -72,11 +109,26 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
72
109
|
/** The last epoch for which we logged strategy comparison in fisherman mode. */
|
|
73
110
|
private lastEpochForStrategyComparison: EpochNumber | undefined;
|
|
74
111
|
|
|
75
|
-
/** The
|
|
76
|
-
protected
|
|
112
|
+
/** The last checkpoint proposal job, tracked so we can await its pending L1 submission during shutdown. */
|
|
113
|
+
protected lastCheckpointProposalJob: CheckpointProposalJob | undefined;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* In-flight fire-and-forget requests that {@link stop} interrupts and drains, and {@link pause} awaits
|
|
117
|
+
* untouched: the checkpoint proposal jobs' backgrounded L1 submissions (each job is handed this shared
|
|
118
|
+
* tracker) plus the sequencer's own fallback submissions (votes/prune when we cannot build, or
|
|
119
|
+
* escape-hatch votes). Each fallback send is gated by its wrapper publisher's interruptible target-slot
|
|
120
|
+
* sleep; the tracked interrupt wakes that sleep so the send short-circuits without publishing. A wrapper
|
|
121
|
+
* is created for a single send and is never restarted, so once interrupted its sleeper can never publish
|
|
122
|
+
* a stale-slot tx, even after the pooled publishers are restarted by a later {@link start}.
|
|
123
|
+
*/
|
|
124
|
+
protected readonly pendingRequests = new RequestsTracker();
|
|
125
|
+
|
|
126
|
+
/** Proposer schedule and block sub-slot timetable for the sequencer, rebuilt on every config update. */
|
|
127
|
+
protected timetable!: ProposerTimetable;
|
|
77
128
|
|
|
78
129
|
/** Config for the sequencer */
|
|
79
130
|
protected config: ResolvedSequencerConfig = DefaultSequencerConfig;
|
|
131
|
+
private readonly signatureContext: CoordinationSignatureContext;
|
|
80
132
|
|
|
81
133
|
constructor(
|
|
82
134
|
protected publisherFactory: SequencerPublisherFactory,
|
|
@@ -85,45 +137,148 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
85
137
|
protected p2pClient: P2P,
|
|
86
138
|
protected worldState: WorldStateSynchronizer,
|
|
87
139
|
protected slasherClient: SlasherClientInterface | undefined,
|
|
88
|
-
protected l2BlockSource: L2BlockSource & L2BlockSink,
|
|
140
|
+
protected l2BlockSource: L2BlockSource & L2BlockSink & ProposedCheckpointSink,
|
|
89
141
|
protected l1ToL2MessageSource: L1ToL2MessageSource,
|
|
90
142
|
protected checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
91
143
|
protected l1Constants: SequencerRollupConstants,
|
|
92
144
|
protected dateProvider: DateProvider,
|
|
93
145
|
protected epochCache: EpochCache,
|
|
94
146
|
protected rollupContract: RollupContract,
|
|
95
|
-
config: SequencerConfig,
|
|
147
|
+
config: SequencerConfig & Pick<ChainConfig, 'l1ChainId' | 'rollupAddress'>,
|
|
96
148
|
protected telemetry: TelemetryClient = getTelemetryClient(),
|
|
97
149
|
protected log = createLogger('sequencer'),
|
|
98
150
|
) {
|
|
99
151
|
super();
|
|
152
|
+
this.stateLog = log.createChild('state');
|
|
153
|
+
this.stateEnteredAtMs = this.dateProvider.now();
|
|
100
154
|
|
|
101
155
|
// Add [FISHERMAN] prefix to logger if in fisherman mode
|
|
102
156
|
if (config.fishermanMode) {
|
|
103
157
|
this.log = log.createChild('[FISHERMAN]');
|
|
104
158
|
}
|
|
105
159
|
|
|
160
|
+
this.signatureContext = {
|
|
161
|
+
chainId: config.l1ChainId,
|
|
162
|
+
rollupAddress: config.rollupAddress,
|
|
163
|
+
};
|
|
106
164
|
this.metrics = new SequencerMetrics(telemetry, this.rollupContract, 'Sequencer');
|
|
165
|
+
this.checkpointProposalJobMetrics = new CheckpointProposalJobMetrics(telemetry);
|
|
107
166
|
this.updateConfig(config);
|
|
108
167
|
}
|
|
109
168
|
|
|
110
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* Updates sequencer config by the defined values and rebuilds the timetable.
|
|
171
|
+
*
|
|
172
|
+
* The merged config is validated against a candidate before being committed: {@link buildTimetable} may
|
|
173
|
+
* reject the candidate (invalid timing geometry, or per-block allocation multipliers below the network
|
|
174
|
+
* minimums). On rejection we leave `this.config` and `this.timetable` untouched and rethrow, so a bad update
|
|
175
|
+
* never leaves the sequencer running with a rejected config and a stale timetable.
|
|
176
|
+
*/
|
|
111
177
|
public updateConfig(config: Partial<SequencerConfig>) {
|
|
112
178
|
const filteredConfig = pickFromSchema(config, SequencerConfigSchema);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
179
|
+
const candidate = merge(this.config, filteredConfig);
|
|
180
|
+
let timetable: ProposerTimetable;
|
|
181
|
+
try {
|
|
182
|
+
timetable = this.buildTimetable(candidate);
|
|
183
|
+
} catch (err) {
|
|
184
|
+
this.log.warn(`Rejecting sequencer config update: ${(err as Error).message}`, {
|
|
185
|
+
rejectedConfig: omit(filteredConfig, 'txPublicSetupAllowListExtend'),
|
|
186
|
+
});
|
|
187
|
+
throw err;
|
|
188
|
+
}
|
|
189
|
+
this.config = candidate;
|
|
190
|
+
this.timetable = timetable;
|
|
191
|
+
this.log.info(`Updated sequencer config`, omit(filteredConfig, 'txPublicSetupAllowListExtend'));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Builds the proposer timetable from the given config and L1 constants via the shared
|
|
196
|
+
* {@link buildProposerTimetable} helper, so the sequencer derives the same blocks-per-checkpoint as the p2p
|
|
197
|
+
* layer and `getNodeInfo`. The fast local/e2e profile and budget clamping happen inside
|
|
198
|
+
* {@link ProposerTimetable}.
|
|
199
|
+
*
|
|
200
|
+
* Throws if the timing geometry is invalid or the per-block allocation multipliers are below the network
|
|
201
|
+
* minimums; callers must treat a throw as a rejected config and not commit it.
|
|
202
|
+
*/
|
|
203
|
+
private buildTimetable(config: ResolvedSequencerConfig): ProposerTimetable {
|
|
204
|
+
const timetable = buildProposerTimetable(config, this.l1Constants);
|
|
205
|
+
|
|
206
|
+
const maxNumberOfBlocks = timetable.getMaxBlocksPerCheckpoint();
|
|
207
|
+
this.log.info(`Sequencer timetable initialized with ${maxNumberOfBlocks} blocks per slot`, {
|
|
208
|
+
aztecSlotDuration: timetable.aztecSlotDuration,
|
|
209
|
+
ethereumSlotDuration: timetable.ethereumSlotDuration,
|
|
210
|
+
blockDuration: timetable.blockDuration,
|
|
211
|
+
minBlockDuration: timetable.minBlockDuration,
|
|
212
|
+
p2pPropagationTime: timetable.p2pPropagationTime,
|
|
213
|
+
checkpointProposalPrepareTime: timetable.checkpointProposalPrepareTime,
|
|
214
|
+
maxNumberOfBlocks,
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
this.assertConfigMeetsNetworkTxLimits(config, maxNumberOfBlocks);
|
|
218
|
+
|
|
219
|
+
return timetable;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Checks this node's configured per-block allocation against the network admission limit. A node
|
|
224
|
+
* advertises and admits txs up to the limit derived from the network-minimum multipliers (see
|
|
225
|
+
* {@link computeNetworkTxGasLimits}).
|
|
226
|
+
*
|
|
227
|
+
* Fails startup (and runtime config updates) only when the configured per-block allocation *multipliers*
|
|
228
|
+
* (`perBlockAllocationMultiplier` / `perBlockDAAllocationMultiplier`) are below the network minimums: such
|
|
229
|
+
* a node would accept txs over RPC/gossip that its builder can never pack into a block regardless of block
|
|
230
|
+
* size. Operators may configure a higher (more generous) multiplier, but not a lower one.
|
|
231
|
+
*
|
|
232
|
+
* When the multipliers meet the floor but an absolute per-block gas cap (`maxDABlockGas` / `maxL2BlockGas`)
|
|
233
|
+
* shrinks the builder's effective grant below the network limit, this is legitimate operator
|
|
234
|
+
* restrictiveness — the node simply builds smaller blocks and such txs stay in the pool for other
|
|
235
|
+
* proposers — so we only log a warning rather than failing startup. Restrictive tx-count caps
|
|
236
|
+
* (`maxTxsPerBlock` / `maxTxsPerCheckpoint`) can likewise make the builder skip admitted txs; they are
|
|
237
|
+
* intentionally not modeled here for the same reason.
|
|
238
|
+
*/
|
|
239
|
+
private assertConfigMeetsNetworkTxLimits(config: ResolvedSequencerConfig, maxBlocksPerCheckpoint: number) {
|
|
240
|
+
// Mirror CheckpointBuilder.capLimitsByCheckpointBudgets: DA falls back to the general multiplier.
|
|
241
|
+
const l2Multiplier = config.perBlockAllocationMultiplier;
|
|
242
|
+
const daMultiplier = config.perBlockDAAllocationMultiplier ?? l2Multiplier;
|
|
243
|
+
|
|
244
|
+
// The allocation is monotonic in the multiplier, so a multiplier at or above the network minimum
|
|
245
|
+
// guarantees the builder grants at least the network admission limit. Checking the multipliers directly
|
|
246
|
+
// is sufficient (and strictly more conservative than modeling the resulting gas grant).
|
|
247
|
+
if (daMultiplier < MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER) {
|
|
248
|
+
throw new Error(
|
|
249
|
+
`perBlockDAAllocationMultiplier (${daMultiplier}) is below the network minimum ` +
|
|
250
|
+
`${MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER}; the node would admit txs its own builder can never include.`,
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
if (l2Multiplier < MIN_PER_BLOCK_ALLOCATION_MULTIPLIER) {
|
|
254
|
+
throw new Error(
|
|
255
|
+
`perBlockAllocationMultiplier (${l2Multiplier}) is below the network minimum ` +
|
|
256
|
+
`${MIN_PER_BLOCK_ALLOCATION_MULTIPLIER}; the node would admit txs its own builder can never include.`,
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Absolute per-block gas caps below the network admission limit are legitimate operator restrictiveness:
|
|
261
|
+
// the node simply builds smaller blocks and such txs stay in the pool for other proposers. Warn only.
|
|
262
|
+
const networkLimit = computeNetworkTxGasLimits({
|
|
263
|
+
maxBlocksPerCheckpoint,
|
|
264
|
+
manaCheckpointBudget: this.l1Constants.rollupManaLimit,
|
|
265
|
+
});
|
|
266
|
+
if (config.maxDABlockGas !== undefined && config.maxDABlockGas < networkLimit.daGas) {
|
|
267
|
+
this.log.warn(
|
|
268
|
+
`Sequencer maxDABlockGas (${config.maxDABlockGas}) is below the network DA admission limit ` +
|
|
269
|
+
`(${networkLimit.daGas}): txs declaring more DA gas are admitted over RPC/gossip but will be skipped ` +
|
|
270
|
+
`by this proposer's own blocks and left in the pool for other proposers.`,
|
|
271
|
+
{ maxDABlockGas: config.maxDABlockGas, networkDaGas: networkLimit.daGas, maxBlocksPerCheckpoint },
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
if (config.maxL2BlockGas !== undefined && config.maxL2BlockGas < networkLimit.l2Gas) {
|
|
275
|
+
this.log.warn(
|
|
276
|
+
`Sequencer maxL2BlockGas (${config.maxL2BlockGas}) is below the network L2 admission limit ` +
|
|
277
|
+
`(${networkLimit.l2Gas}): txs declaring more L2 gas are admitted over RPC/gossip but will be skipped ` +
|
|
278
|
+
`by this proposer's own blocks and left in the pool for other proposers.`,
|
|
279
|
+
{ maxL2BlockGas: config.maxL2BlockGas, networkL2Gas: networkLimit.l2Gas, maxBlocksPerCheckpoint },
|
|
280
|
+
);
|
|
281
|
+
}
|
|
127
282
|
}
|
|
128
283
|
|
|
129
284
|
/** Initializes the sequencer (precomputes tables). Takes about 3s. */
|
|
@@ -131,8 +286,22 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
131
286
|
getKzg();
|
|
132
287
|
}
|
|
133
288
|
|
|
134
|
-
/**
|
|
289
|
+
/**
|
|
290
|
+
* Starts (or restarts) the sequencer and moves it to the IDLE state. Idempotent: a start while already
|
|
291
|
+
* running is a no-op, so it never orphans the previous poll loop. A start while STOPPING throws, since the
|
|
292
|
+
* in-flight stop would mark the fresh loop's state STOPPED and orphan it — silently doing nothing would
|
|
293
|
+
* leave the caller believing the sequencer is running when it is on its way to STOPPED. Safe to call after
|
|
294
|
+
* a previous {@link stop} has resolved; the caller must also restart the publishers (see
|
|
295
|
+
* {@link SequencerClient.start}) so L1 publishing is re-enabled.
|
|
296
|
+
*/
|
|
135
297
|
public start() {
|
|
298
|
+
if (this.state === SequencerState.STOPPING) {
|
|
299
|
+
throw new Error('Cannot start sequencer while it is stopping');
|
|
300
|
+
}
|
|
301
|
+
if (this.runningPromise?.isRunning()) {
|
|
302
|
+
this.log.warn('Attempted to start sequencer that is already running');
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
136
305
|
this.runningPromise = new RunningPromise(
|
|
137
306
|
this.safeWork.bind(this),
|
|
138
307
|
this.log,
|
|
@@ -143,34 +312,68 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
143
312
|
this.log.info('Started sequencer');
|
|
144
313
|
}
|
|
145
314
|
|
|
146
|
-
/**
|
|
315
|
+
/** Triggers an immediate run of the sequencer, bypassing the polling interval. */
|
|
316
|
+
public trigger() {
|
|
317
|
+
return this.runningPromise?.trigger();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Stops the sequencer from building blocks and moves it to STOPPED state, interrupting the in-flight
|
|
322
|
+
* work() iteration and its pending L1 submissions for a fast shutdown, then draining before returning.
|
|
323
|
+
* Idempotent: a second call while already stopped or stopping is a no-op. Lifecycle calls are expected
|
|
324
|
+
* to be serialized by the caller. For a restartable pause that lets in-flight work finish untouched
|
|
325
|
+
* (e.g. around a test clock warp), use {@link pause} instead.
|
|
326
|
+
*/
|
|
147
327
|
public async stop(): Promise<void> {
|
|
328
|
+
if (this.state === SequencerState.STOPPED || this.state === SequencerState.STOPPING) {
|
|
329
|
+
this.log.debug(`Sequencer already ${this.state.toLowerCase()}, ignoring stop`);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
148
332
|
this.log.info(`Stopping sequencer`);
|
|
149
333
|
this.setState(SequencerState.STOPPING, undefined, { force: true });
|
|
150
|
-
this.
|
|
334
|
+
this.lastCheckpointProposalJob?.interrupt();
|
|
335
|
+
await this.publisherFactory.stopAll();
|
|
336
|
+
// Stop the poll loop and await the in-flight work() iteration. work() registers its fire-and-forget
|
|
337
|
+
// requests synchronously before returning, so once the loop has stopped, pendingRequests holds every
|
|
338
|
+
// request that will ever exist. Interrupting any earlier could miss a request registered by the last
|
|
339
|
+
// in-flight iteration.
|
|
151
340
|
await this.runningPromise?.stop();
|
|
341
|
+
this.pendingRequests.interruptRequests();
|
|
342
|
+
await this.pendingRequests.awaitRequests();
|
|
152
343
|
this.setState(SequencerState.STOPPED, undefined, { force: true });
|
|
153
344
|
this.log.info('Stopped sequencer');
|
|
154
345
|
}
|
|
155
346
|
|
|
347
|
+
/**
|
|
348
|
+
* Gracefully pauses block production so the sequencer can later be resumed with {@link start}: halts the
|
|
349
|
+
* poll loop and waits for the in-flight work() iteration and every pending L1 submission / fallback send
|
|
350
|
+
* to finish, without interrupting them. No interrupt lands mid-build, so no spurious checkpoint-error is
|
|
351
|
+
* emitted and no enqueued checkpoint is dropped. Deliberately does not stop inner services (validator/HA
|
|
352
|
+
* signer, publishers), so the slashing-protection store stays open and the sequencer stays restartable.
|
|
353
|
+
* Used by tests that pause sequencers around an L1 clock warp. Idempotent.
|
|
354
|
+
*/
|
|
355
|
+
public async pause(): Promise<void> {
|
|
356
|
+
if (!this.runningPromise?.isRunning()) {
|
|
357
|
+
this.log.debug('Sequencer not running, ignoring pause');
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
this.log.info('Pausing sequencer');
|
|
361
|
+
// Halt the poll loop and let the in-flight iteration finish naturally — no interrupt, and no STOPPING
|
|
362
|
+
// state, since entering STOPPING would make the iteration's own setState calls throw and fail it.
|
|
363
|
+
// work() registers its fire-and-forget requests synchronously before returning, so once the loop has
|
|
364
|
+
// stopped pendingRequests holds every request that will ever exist; awaiting it lets them all finish.
|
|
365
|
+
await this.runningPromise.stop();
|
|
366
|
+
await this.pendingRequests.awaitRequests();
|
|
367
|
+
this.log.info('Paused sequencer');
|
|
368
|
+
}
|
|
369
|
+
|
|
156
370
|
/** Main sequencer loop with a try/catch */
|
|
157
371
|
protected async safeWork() {
|
|
158
372
|
try {
|
|
159
373
|
await this.work();
|
|
160
374
|
} catch (err) {
|
|
161
375
|
this.emit('checkpoint-error', { error: err as Error });
|
|
162
|
-
|
|
163
|
-
// Log as warn only if we had to abort halfway through the block proposal
|
|
164
|
-
const logLvl = [SequencerState.INITIALIZING_CHECKPOINT, SequencerState.PROPOSER_CHECK].includes(
|
|
165
|
-
err.proposedState,
|
|
166
|
-
)
|
|
167
|
-
? ('debug' as const)
|
|
168
|
-
: ('warn' as const);
|
|
169
|
-
this.log[logLvl](err.message, { now: this.dateProvider.nowInSeconds() });
|
|
170
|
-
} else {
|
|
171
|
-
// Re-throw other errors
|
|
172
|
-
throw err;
|
|
173
|
-
}
|
|
376
|
+
throw err;
|
|
174
377
|
} finally {
|
|
175
378
|
this.setState(SequencerState.IDLE, undefined);
|
|
176
379
|
}
|
|
@@ -192,14 +395,24 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
192
395
|
@trackSpan('Sequencer.work')
|
|
193
396
|
protected async work() {
|
|
194
397
|
this.setState(SequencerState.SYNCHRONIZING, undefined);
|
|
195
|
-
const { slot,
|
|
398
|
+
const { slot, targetSlot, epoch, targetEpoch, ts, nowSeconds } = this.getSlotContextInNextL1Slot();
|
|
196
399
|
|
|
197
400
|
// Check if we are synced and it's our slot, grab a publisher, check previous block invalidation, etc
|
|
198
|
-
const checkpointProposalJob = await this.prepareCheckpointProposal(
|
|
401
|
+
const checkpointProposalJob = await this.prepareCheckpointProposal(
|
|
402
|
+
slot,
|
|
403
|
+
targetSlot,
|
|
404
|
+
epoch,
|
|
405
|
+
targetEpoch,
|
|
406
|
+
ts,
|
|
407
|
+
nowSeconds,
|
|
408
|
+
);
|
|
199
409
|
if (!checkpointProposalJob) {
|
|
200
410
|
return;
|
|
201
411
|
}
|
|
202
412
|
|
|
413
|
+
// Track the job so we can await its pending L1 submission during shutdown
|
|
414
|
+
this.lastCheckpointProposalJob = checkpointProposalJob;
|
|
415
|
+
|
|
203
416
|
// Execute the checkpoint proposal job
|
|
204
417
|
const checkpoint = await checkpointProposalJob.execute();
|
|
205
418
|
|
|
@@ -208,64 +421,76 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
208
421
|
this.lastCheckpointProposed = checkpoint;
|
|
209
422
|
}
|
|
210
423
|
|
|
211
|
-
// Log fee strategy comparison if on fisherman
|
|
424
|
+
// Log fee strategy comparison if on fisherman (uses target epoch since we mirror the proposer's perspective)
|
|
212
425
|
if (
|
|
213
426
|
this.config.fishermanMode &&
|
|
214
|
-
(this.lastEpochForStrategyComparison === undefined ||
|
|
427
|
+
(this.lastEpochForStrategyComparison === undefined || targetEpoch > this.lastEpochForStrategyComparison)
|
|
215
428
|
) {
|
|
216
|
-
this.logStrategyComparison(
|
|
217
|
-
this.lastEpochForStrategyComparison =
|
|
429
|
+
this.logStrategyComparison(targetEpoch, checkpointProposalJob.getPublisher());
|
|
430
|
+
this.lastEpochForStrategyComparison = targetEpoch;
|
|
218
431
|
}
|
|
219
432
|
|
|
220
433
|
return checkpoint;
|
|
221
434
|
}
|
|
222
435
|
|
|
436
|
+
/** Returns slot and target slot from a single clock snapshot. */
|
|
437
|
+
protected getSlotContextInNextL1Slot(): SequencerSlotContext {
|
|
438
|
+
const { slot, ts, nowSeconds, epoch } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
439
|
+
const targetSlot = SlotNumber(slot + PROPOSER_PIPELINING_SLOT_OFFSET);
|
|
440
|
+
return { slot, targetSlot, epoch, targetEpoch: getEpochAtSlot(targetSlot, this.l1Constants), ts, nowSeconds };
|
|
441
|
+
}
|
|
442
|
+
|
|
223
443
|
/**
|
|
224
444
|
* Prepares the checkpoint proposal by performing all necessary checks and setup.
|
|
225
445
|
* This is the initial step in the main loop.
|
|
226
446
|
* @returns CheckpointProposalJob if successful, undefined if we are not yet synced or are not the proposer.
|
|
227
447
|
*/
|
|
228
448
|
@trackSpan('Sequencer.prepareCheckpointProposal')
|
|
229
|
-
|
|
230
|
-
epoch: EpochNumber,
|
|
449
|
+
protected async prepareCheckpointProposal(
|
|
231
450
|
slot: SlotNumber,
|
|
451
|
+
targetSlot: SlotNumber,
|
|
452
|
+
epoch: EpochNumber,
|
|
453
|
+
targetEpoch: EpochNumber,
|
|
232
454
|
ts: bigint,
|
|
233
|
-
|
|
455
|
+
nowSeconds: bigint,
|
|
234
456
|
): Promise<CheckpointProposalJob | undefined> {
|
|
235
|
-
// Check we have not already processed this slot (cheapest check)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (
|
|
239
|
-
this.lastSlotForCheckpointProposalJob &&
|
|
240
|
-
this.lastSlotForCheckpointProposalJob >= slot &&
|
|
241
|
-
this.config.enforceTimeTable
|
|
242
|
-
) {
|
|
243
|
-
this.log.trace(`Slot ${slot} has already been processed`);
|
|
457
|
+
// Check we have not already processed this target slot (cheapest check).
|
|
458
|
+
if (this.lastSlotForCheckpointProposalJob && this.lastSlotForCheckpointProposalJob >= targetSlot) {
|
|
459
|
+
this.log.trace(`Target slot ${targetSlot} has already been processed`);
|
|
244
460
|
return undefined;
|
|
245
461
|
}
|
|
246
462
|
|
|
247
|
-
// But if we have already proposed for this slot,
|
|
248
|
-
if (this.lastCheckpointProposed && this.lastCheckpointProposed.header.slotNumber >=
|
|
249
|
-
this.log.trace(
|
|
463
|
+
// But if we have already proposed for this slot, then we definitely have to skip it, automining or not
|
|
464
|
+
if (this.lastCheckpointProposed && this.lastCheckpointProposed.header.slotNumber >= targetSlot) {
|
|
465
|
+
this.log.trace(
|
|
466
|
+
`Slot ${targetSlot} has already been published as checkpoint ${this.lastCheckpointProposed.number}`,
|
|
467
|
+
);
|
|
250
468
|
return undefined;
|
|
251
469
|
}
|
|
252
470
|
|
|
253
|
-
//
|
|
254
|
-
|
|
255
|
-
if (
|
|
256
|
-
|
|
471
|
+
// Test-only: skip proposing for explicitly paused slots. Attestation paths run in the validator
|
|
472
|
+
// client and are not gated by this hook, so paused proposers still attest to others' proposals.
|
|
473
|
+
if (this.config.pauseProposingForSlots?.some(s => s === targetSlot)) {
|
|
474
|
+
this.log.warn(`Skipping proposal for paused slot ${targetSlot} (test-only pauseProposingForSlots hook)`, {
|
|
475
|
+
targetSlot,
|
|
476
|
+
});
|
|
257
477
|
return undefined;
|
|
258
478
|
}
|
|
259
479
|
|
|
260
|
-
//
|
|
480
|
+
// Cheap proposer check first: most nodes are not the proposer for most slots, so gate the
|
|
481
|
+
// expensive multi-subsystem checkSync (and the rest of the build path) behind it. Computed once
|
|
482
|
+
// here and reused for the escape-hatch voting path below. No setState/timing gate on this path:
|
|
483
|
+
// the build-start deadline gate runs only on the proposer build path after a successful checkSync.
|
|
484
|
+
const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
|
|
485
|
+
|
|
486
|
+
// If escape hatch is open for the target epoch, do not start checkpoint proposal work and do not attempt invalidations.
|
|
261
487
|
// Still perform governance/slashing voting (as proposer) once per slot.
|
|
262
|
-
|
|
488
|
+
// When pipelining, we check the target epoch (slot+1's epoch) since that's the epoch we're building for.
|
|
489
|
+
const isEscapeHatchOpen = await this.epochCache.isEscapeHatchOpen(targetEpoch);
|
|
263
490
|
|
|
264
491
|
if (isEscapeHatchOpen) {
|
|
265
|
-
this.setState(SequencerState.PROPOSER_CHECK, slot);
|
|
266
|
-
const [canPropose, proposer] = await this.checkCanPropose(slot);
|
|
267
492
|
if (canPropose) {
|
|
268
|
-
await this.tryVoteWhenEscapeHatchOpen({ slot, proposer });
|
|
493
|
+
await this.tryVoteWhenEscapeHatchOpen({ slot, targetSlot, proposer });
|
|
269
494
|
} else {
|
|
270
495
|
this.log.trace(`Escape hatch open but we are not proposer, skipping vote-only actions`, {
|
|
271
496
|
slot,
|
|
@@ -276,33 +501,80 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
276
501
|
return undefined;
|
|
277
502
|
}
|
|
278
503
|
|
|
504
|
+
// If we are not the proposer, check whether we should invalidate an invalid pending chain (a
|
|
505
|
+
// liveness backstop) and bail before any sync work or build-timing gate. This reads only the
|
|
506
|
+
// archiver's pending-chain validation status, which is authoritative on its own, instead of
|
|
507
|
+
// running the full sync check. Wrapped in try/catch because this leaner path skips the broader
|
|
508
|
+
// proposed-checkpoint/tip coherence screen that checkSync applied, so transient archiver
|
|
509
|
+
// incoherence surfaces as a quiet skip rather than a work-loop error.
|
|
510
|
+
if (!canPropose) {
|
|
511
|
+
try {
|
|
512
|
+
const pendingChainValidationStatus = await this.l2BlockSource.getPendingChainValidationStatus();
|
|
513
|
+
await this.considerInvalidatingCheckpoint(pendingChainValidationStatus, slot);
|
|
514
|
+
} catch (err) {
|
|
515
|
+
this.log.warn(`Failed to consider invalidating checkpoint`, { err, slot, targetSlot });
|
|
516
|
+
}
|
|
517
|
+
return undefined;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// Explicit build-loop entry gate: if we are past the latest useful block-building start for the
|
|
521
|
+
// target slot, abandon building for this slot. The proposer prioritizes the ideal L1-publish path
|
|
522
|
+
// and does not plan around the late consensus-handoff path. This is the proposer build path's
|
|
523
|
+
// timing gate; it runs only after we know we are the synced proposer, so non-proposer invalidation
|
|
524
|
+
// and escape-hatch voting (which returned above) are never gated by build timing. Vote-only paths
|
|
525
|
+
// still run when block building is abandoned.
|
|
526
|
+
const startDeadline = this.timetable.getBuildStartDeadline(targetSlot);
|
|
527
|
+
const nowForStartGate = this.dateProvider.now() / 1000;
|
|
528
|
+
if (nowForStartGate > startDeadline) {
|
|
529
|
+
this.log.debug(`Past start deadline for slot ${targetSlot}, abandoning block building`, {
|
|
530
|
+
targetSlot,
|
|
531
|
+
nowForStartGate,
|
|
532
|
+
startDeadline,
|
|
533
|
+
});
|
|
534
|
+
// Mark the slot as attempted so a deadline abort is not retried within the same slot. Vote-only actions
|
|
535
|
+
// still need to run because sync can succeed even when it is too late to start building a checkpoint.
|
|
536
|
+
await this.tryVoteAndPruneWhenCannotBuild({ slot, targetSlot });
|
|
537
|
+
this.lastSlotForCheckpointProposalJob = targetSlot;
|
|
538
|
+
return undefined;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// We are the proposer, the escape hatch is closed, and we have time before the build start deadline.
|
|
542
|
+
// Now run the full sync check before building.
|
|
543
|
+
const syncedTo = await this.checkSync({ ts, slot });
|
|
544
|
+
if (!syncedTo) {
|
|
545
|
+
return undefined;
|
|
546
|
+
}
|
|
547
|
+
|
|
279
548
|
// Next checkpoint follows from the last synced one
|
|
280
549
|
const checkpointNumber = CheckpointNumber(syncedTo.checkpointNumber + 1);
|
|
281
550
|
|
|
282
551
|
const logCtx = {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
syncedToL2Slot: getSlotAtTimestamp(syncedTo.l1Timestamp, this.l1Constants),
|
|
552
|
+
nowSeconds,
|
|
553
|
+
syncedToL2Slot: syncedTo.syncedL2Slot,
|
|
286
554
|
slot,
|
|
555
|
+
targetSlot,
|
|
287
556
|
slotTs: ts,
|
|
288
557
|
checkpointNumber,
|
|
289
558
|
isPendingChainValid: pick(syncedTo.pendingChainValidationStatus, 'valid', 'reason', 'invalidIndex'),
|
|
290
559
|
};
|
|
291
560
|
|
|
292
|
-
//
|
|
293
|
-
this.setState(SequencerState.PROPOSER_CHECK,
|
|
294
|
-
const [canPropose, proposer] = await this.checkCanPropose(slot);
|
|
561
|
+
// We are the synced proposer within the build window; enter the proposer-check state and build.
|
|
562
|
+
this.setState(SequencerState.PROPOSER_CHECK, targetSlot);
|
|
295
563
|
|
|
296
|
-
//
|
|
297
|
-
|
|
298
|
-
|
|
564
|
+
// Guard: don't exceed 1-deep pipeline. Without a proposed checkpoint, we can only build
|
|
565
|
+
// confirmed + 1. With a proposed checkpoint, we can build confirmed + 2.
|
|
566
|
+
const confirmedCkpt = syncedTo.checkpointedCheckpointNumber;
|
|
567
|
+
if (checkpointNumber > confirmedCkpt + 2) {
|
|
568
|
+
this.log.verbose(
|
|
569
|
+
`Skipping slot ${targetSlot}: checkpoint ${checkpointNumber} exceeds max pipeline depth (confirmed=${confirmedCkpt})`,
|
|
570
|
+
);
|
|
299
571
|
return undefined;
|
|
300
572
|
}
|
|
301
573
|
|
|
302
|
-
// Check that the slot is not taken by a block already (should never happen, since only us can propose for this slot)
|
|
303
|
-
if (syncedTo.blockData && syncedTo.blockData.header.getSlot() >=
|
|
574
|
+
// Check that the target slot is not taken by a block already (should never happen, since only us can propose for this slot)
|
|
575
|
+
if (syncedTo.blockData && syncedTo.blockData.header.getSlot() >= targetSlot) {
|
|
304
576
|
this.log.warn(
|
|
305
|
-
`Cannot propose block at
|
|
577
|
+
`Cannot propose block at target slot ${targetSlot} since that slot was taken by block ${syncedTo.blockNumber}`,
|
|
306
578
|
{ ...logCtx, block: syncedTo.blockData.header.toInspect() },
|
|
307
579
|
);
|
|
308
580
|
this.metrics.recordCheckpointPrecheckFailed('slot_already_taken');
|
|
@@ -317,37 +589,106 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
317
589
|
const { attestorAddress, publisher } = await this.publisherFactory.create(proposerForPublisher);
|
|
318
590
|
this.log.verbose(`Created publisher at address ${publisher.getSenderAddress()} for attestor ${attestorAddress}`);
|
|
319
591
|
|
|
320
|
-
//
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
592
|
+
// Prepare invalidation request if the pending chain is invalid (returns undefined if no need).
|
|
593
|
+
// Only simulate invalidation when there's no proposed parent, since we assume the proposed parent
|
|
594
|
+
// will invalidate the currently invalid checkpoint on L1.
|
|
595
|
+
const invalidateCheckpoint =
|
|
596
|
+
syncedTo.hasProposedCheckpoint || syncedTo.pendingChainValidationStatus.valid
|
|
597
|
+
? undefined
|
|
598
|
+
: await publisher.simulateInvalidateCheckpoint(syncedTo.pendingChainValidationStatus);
|
|
599
|
+
|
|
600
|
+
// Determine the correct archive and L1 state overrides for the canProposeAt check.
|
|
601
|
+
// The L1 contract reads archives[proposedCheckpointNumber] and compares it with the provided archive.
|
|
602
|
+
// When invalidating or pipelining, the local archive may differ from L1's, so we adjust accordingly.
|
|
603
|
+
let archiveForCheck = syncedTo.archive;
|
|
604
|
+
|
|
605
|
+
if (syncedTo.hasProposedCheckpoint) {
|
|
606
|
+
this.metrics.recordPipelineDepth(syncedTo.checkpointNumber - syncedTo.checkpointedCheckpointNumber);
|
|
607
|
+
this.log.verbose(
|
|
608
|
+
`Building on top of proposed checkpoint (pending=${syncedTo.proposedCheckpointData?.checkpointNumber}) for target slot ${targetSlot}`,
|
|
609
|
+
{ targetSlot, parentCheckpointNumber: CheckpointNumber(checkpointNumber - 1) },
|
|
610
|
+
);
|
|
611
|
+
// Match what L1 will see at archives[pending] once the proposed parent lands: the parent's
|
|
612
|
+
// own archive root from the gossiped proposal. `syncedTo.archive` is the world-state-local
|
|
613
|
+
// view and can transiently diverge from the proposed parent (e.g. before the proposed
|
|
614
|
+
// parent's blocks have been applied locally); diverging here would cause the canProposeAt
|
|
615
|
+
// override to set archives[pending] to one value while we present another for comparison.
|
|
616
|
+
archiveForCheck = syncedTo.proposedCheckpointData!.archive.root;
|
|
617
|
+
} else if (invalidateCheckpoint) {
|
|
618
|
+
// After invalidation, L1 will roll back to checkpoint N-1. The archive at N-1 already
|
|
619
|
+
// exists on L1, so we just pass the matching archive (the lastArchive of the invalid checkpoint).
|
|
620
|
+
archiveForCheck = invalidateCheckpoint.lastArchive;
|
|
621
|
+
this.metrics.recordPipelineDepth(0);
|
|
622
|
+
} else {
|
|
623
|
+
this.metrics.recordPipelineDepth(0);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// Build the simulation plan: pending/proven override from pipelining or invalidation (or the
|
|
627
|
+
// current snapshot when neither applies, to short-circuit any pending prune in simulation),
|
|
628
|
+
// plus the parent checkpoint cell and fee header when pipelining.
|
|
629
|
+
const simulationOverridesPlan = await buildCheckpointSimulationOverridesPlan({
|
|
630
|
+
checkpointNumber,
|
|
631
|
+
proposedCheckpointData: syncedTo.hasProposedCheckpoint ? syncedTo.proposedCheckpointData : undefined,
|
|
632
|
+
invalidateToPendingCheckpointNumber: invalidateCheckpoint?.forcePendingCheckpointNumber,
|
|
633
|
+
checkpointedCheckpointNumber: syncedTo.checkpointedCheckpointNumber,
|
|
634
|
+
rollup: this.rollupContract,
|
|
635
|
+
signatureContext: this.signatureContext,
|
|
636
|
+
log: this.log,
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
// The plan always pins both pending/proven (to short-circuit `canPruneAtTime` in simulation),
|
|
640
|
+
// so `provenOverride` always reflects the assumed proven checkpoint we are pinning the
|
|
641
|
+
// simulation to. We additionally warn when the pin is load-bearing — i.e. when a prune would
|
|
642
|
+
// actually fire at the target slot without it — so observers can spot "we are building
|
|
643
|
+
// optimistically across a pruning boundary" in the logs.
|
|
644
|
+
const provenOverride = simulationOverridesPlan?.chainTipsOverride?.proven;
|
|
645
|
+
if (provenOverride !== undefined && (await this.l2BlockSource.isPruneDueAtSlot(targetSlot))) {
|
|
646
|
+
this.log.warn(
|
|
647
|
+
`Assuming proof for epoch ending at checkpoint ${provenOverride} lands by target slot ${targetSlot}`,
|
|
648
|
+
{ checkpointNumber, slot, targetSlot, provenOverride },
|
|
649
|
+
);
|
|
324
650
|
}
|
|
325
651
|
|
|
326
|
-
|
|
327
|
-
|
|
652
|
+
this.emit('preparing-checkpoint', {
|
|
653
|
+
targetSlot,
|
|
654
|
+
checkpointNumber,
|
|
655
|
+
hadProposedParent: syncedTo.hasProposedCheckpoint,
|
|
656
|
+
provenOverride,
|
|
657
|
+
simulatedPending: simulationOverridesPlan?.chainTipsOverride?.pending,
|
|
658
|
+
});
|
|
328
659
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
const canProposeCheck = await publisher.canProposeAtNextEthBlock(
|
|
332
|
-
syncedTo.archive,
|
|
660
|
+
const canProposeCheck = await publisher.canProposeAt(
|
|
661
|
+
archiveForCheck,
|
|
333
662
|
proposer ?? EthAddress.ZERO,
|
|
334
|
-
|
|
663
|
+
simulationOverridesPlan,
|
|
335
664
|
);
|
|
336
665
|
|
|
666
|
+
const proposeContext = {
|
|
667
|
+
hasProposedCheckpoint: syncedTo.hasProposedCheckpoint,
|
|
668
|
+
proposedCheckpointNumber: syncedTo.proposedCheckpointData?.checkpointNumber,
|
|
669
|
+
checkpointedCheckpointNumber: syncedTo.checkpointedCheckpointNumber,
|
|
670
|
+
isInvalidating: !!invalidateCheckpoint,
|
|
671
|
+
invalidatingCheckpointNumber: invalidateCheckpoint?.checkpointNumber,
|
|
672
|
+
archiveForCheck: archiveForCheck.toString(),
|
|
673
|
+
overridePendingCheckpointNumber: simulationOverridesPlan?.chainTipsOverride?.pending,
|
|
674
|
+
overrideArchive: simulationOverridesPlan?.pendingCheckpointState?.archive,
|
|
675
|
+
overrideFeeHeader: simulationOverridesPlan?.pendingCheckpointState?.feeHeader,
|
|
676
|
+
};
|
|
677
|
+
|
|
337
678
|
if (canProposeCheck === undefined) {
|
|
338
679
|
this.log.warn(
|
|
339
680
|
`Cannot propose checkpoint ${checkpointNumber} at slot ${slot} due to failed rollup contract check`,
|
|
340
|
-
logCtx,
|
|
681
|
+
{ ...logCtx, ...proposeContext },
|
|
341
682
|
);
|
|
342
683
|
this.emit('proposer-rollup-check-failed', { reason: 'Rollup contract check failed', slot });
|
|
343
684
|
this.metrics.recordCheckpointPrecheckFailed('rollup_contract_check_failed');
|
|
344
685
|
return undefined;
|
|
345
686
|
}
|
|
346
687
|
|
|
347
|
-
if (canProposeCheck.slot !==
|
|
688
|
+
if (canProposeCheck.slot !== targetSlot) {
|
|
348
689
|
this.log.warn(
|
|
349
|
-
`Cannot propose block due to slot mismatch with rollup contract (this can be caused by a clock out of sync). Expected slot ${
|
|
350
|
-
{ ...logCtx, rollup: canProposeCheck, expectedSlot:
|
|
690
|
+
`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}.`,
|
|
691
|
+
{ ...logCtx, ...proposeContext, rollup: canProposeCheck, expectedSlot: targetSlot },
|
|
351
692
|
);
|
|
352
693
|
this.emit('proposer-rollup-check-failed', { reason: 'Slot mismatch', slot });
|
|
353
694
|
this.metrics.recordCheckpointPrecheckFailed('slot_mismatch');
|
|
@@ -357,45 +698,58 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
357
698
|
if (canProposeCheck.checkpointNumber !== checkpointNumber) {
|
|
358
699
|
this.log.warn(
|
|
359
700
|
`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}.`,
|
|
360
|
-
{ ...logCtx, rollup: canProposeCheck, expectedSlot: slot },
|
|
701
|
+
{ ...logCtx, ...proposeContext, rollup: canProposeCheck, expectedSlot: slot },
|
|
361
702
|
);
|
|
362
703
|
this.emit('proposer-rollup-check-failed', { reason: 'Block mismatch', slot });
|
|
363
704
|
this.metrics.recordCheckpointPrecheckFailed('block_number_mismatch');
|
|
364
705
|
return undefined;
|
|
365
706
|
}
|
|
366
707
|
|
|
367
|
-
this.lastSlotForCheckpointProposalJob =
|
|
368
|
-
|
|
369
|
-
this.
|
|
708
|
+
this.lastSlotForCheckpointProposalJob = targetSlot;
|
|
709
|
+
|
|
710
|
+
await this.p2pClient.prepareForSlot(targetSlot);
|
|
711
|
+
this.log.info(
|
|
712
|
+
`Preparing checkpoint proposal ${checkpointNumber} for target slot ${targetSlot} during wall-clock slot ${slot}`,
|
|
713
|
+
{
|
|
714
|
+
...logCtx,
|
|
715
|
+
...proposeContext,
|
|
716
|
+
proposer,
|
|
717
|
+
},
|
|
718
|
+
);
|
|
370
719
|
|
|
371
720
|
// Create and return the checkpoint proposal job
|
|
372
721
|
return this.createCheckpointProposalJob(
|
|
373
|
-
|
|
374
|
-
|
|
722
|
+
targetSlot,
|
|
723
|
+
targetEpoch,
|
|
375
724
|
checkpointNumber,
|
|
376
725
|
syncedTo.blockNumber,
|
|
726
|
+
syncedTo.checkpointedCheckpointNumber,
|
|
377
727
|
proposer,
|
|
378
728
|
publisher,
|
|
379
729
|
attestorAddress,
|
|
380
730
|
invalidateCheckpoint,
|
|
731
|
+
syncedTo.proposedCheckpointData,
|
|
381
732
|
);
|
|
382
733
|
}
|
|
383
734
|
|
|
384
735
|
protected createCheckpointProposalJob(
|
|
385
|
-
|
|
386
|
-
|
|
736
|
+
targetSlot: SlotNumber,
|
|
737
|
+
targetEpoch: EpochNumber,
|
|
387
738
|
checkpointNumber: CheckpointNumber,
|
|
388
739
|
syncedToBlockNumber: BlockNumber,
|
|
740
|
+
checkpointedCheckpointNumber: CheckpointNumber,
|
|
389
741
|
proposer: EthAddress | undefined,
|
|
390
742
|
publisher: SequencerPublisher,
|
|
391
743
|
attestorAddress: EthAddress,
|
|
392
744
|
invalidateCheckpoint: InvalidateCheckpointRequest | undefined,
|
|
745
|
+
proposedCheckpointData?: ProposedCheckpointData,
|
|
393
746
|
): CheckpointProposalJob {
|
|
394
747
|
return new CheckpointProposalJob(
|
|
395
|
-
|
|
396
|
-
|
|
748
|
+
targetSlot,
|
|
749
|
+
targetEpoch,
|
|
397
750
|
checkpointNumber,
|
|
398
751
|
syncedToBlockNumber,
|
|
752
|
+
checkpointedCheckpointNumber,
|
|
399
753
|
proposer,
|
|
400
754
|
publisher,
|
|
401
755
|
attestorAddress,
|
|
@@ -409,16 +763,20 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
409
763
|
this.checkpointsBuilder,
|
|
410
764
|
this.l2BlockSource,
|
|
411
765
|
this.l1Constants,
|
|
766
|
+
this.signatureContext,
|
|
412
767
|
this.config,
|
|
413
768
|
this.timetable,
|
|
414
769
|
this.slasherClient,
|
|
415
770
|
this.epochCache,
|
|
416
771
|
this.dateProvider,
|
|
417
772
|
this.metrics,
|
|
773
|
+
this.checkpointProposalJobMetrics.createRecorder(),
|
|
418
774
|
this,
|
|
775
|
+
this.pendingRequests,
|
|
419
776
|
this.setState.bind(this),
|
|
420
777
|
this.tracer,
|
|
421
778
|
this.log.getBindings(),
|
|
779
|
+
proposedCheckpointData,
|
|
422
780
|
);
|
|
423
781
|
}
|
|
424
782
|
|
|
@@ -430,9 +788,11 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
430
788
|
}
|
|
431
789
|
|
|
432
790
|
/**
|
|
433
|
-
* Internal helper for setting the sequencer state
|
|
791
|
+
* Internal helper for setting the sequencer state. Pure: sets the state, emits `state-changed`, and
|
|
792
|
+
* records metrics. Timing deadlines are queried explicitly at the relevant call sites, not gated here.
|
|
434
793
|
* @param proposedState - The new state to transition to.
|
|
435
|
-
* @param slotNumber - The
|
|
794
|
+
* @param slotNumber - The target slot being proposed for, emitted as `targetSlot` on the event payload
|
|
795
|
+
* and used to anchor `secondsIntoBuildFrame`. Undefined for lifecycle states with no associated slot.
|
|
436
796
|
* @param force - Whether to force the transition even if the sequencer is stopped.
|
|
437
797
|
*/
|
|
438
798
|
protected setState(
|
|
@@ -448,25 +808,39 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
448
808
|
this.log.warn(`Cannot set sequencer from ${this.state} to ${proposedState} as it is stopped.`);
|
|
449
809
|
return;
|
|
450
810
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
811
|
+
const secondsIntoBuildFrame = slotNumber !== undefined ? this.getSecondsIntoBuildFrame(slotNumber) : undefined;
|
|
812
|
+
|
|
813
|
+
const oldState = this.state;
|
|
814
|
+
const oldStateSlotNumber = this.stateSlotNumber;
|
|
815
|
+
const stateChanged = proposedState !== oldState;
|
|
816
|
+
// Wall-clock time spent in the previous state: the delta between consecutive state-changing setState
|
|
817
|
+
// calls, read from the date provider so it tracks simulated time under a test/manual clock.
|
|
818
|
+
const transitionAtMs = this.dateProvider.now();
|
|
819
|
+
const stateDurationMs = transitionAtMs - this.stateEnteredAtMs;
|
|
456
820
|
|
|
457
821
|
const boringStates = [SequencerState.IDLE, SequencerState.SYNCHRONIZING];
|
|
458
822
|
const logLevel =
|
|
459
|
-
boringStates.includes(proposedState) && boringStates.includes(
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
823
|
+
boringStates.includes(proposedState) && boringStates.includes(oldState) ? ('trace' as const) : ('debug' as const);
|
|
824
|
+
this.stateLog[logLevel](`Transitioning from ${oldState} to ${proposedState}`, {
|
|
825
|
+
oldState,
|
|
826
|
+
newState: proposedState,
|
|
827
|
+
slotNumber,
|
|
828
|
+
stateSlotNumber: oldStateSlotNumber,
|
|
829
|
+
secondsIntoBuildFrame,
|
|
830
|
+
...(stateChanged && { stateDurationMs: Math.ceil(stateDurationMs) }),
|
|
831
|
+
});
|
|
463
832
|
|
|
464
833
|
this.emit('state-changed', {
|
|
465
|
-
oldState
|
|
834
|
+
oldState,
|
|
466
835
|
newState: proposedState,
|
|
467
|
-
|
|
468
|
-
|
|
836
|
+
secondsIntoBuildFrame,
|
|
837
|
+
targetSlot: slotNumber,
|
|
469
838
|
});
|
|
839
|
+
if (stateChanged) {
|
|
840
|
+
this.metrics.recordStateDuration(stateDurationMs, oldState);
|
|
841
|
+
this.stateEnteredAtMs = transitionAtMs;
|
|
842
|
+
this.stateSlotNumber = slotNumber;
|
|
843
|
+
}
|
|
470
844
|
this.state = proposedState;
|
|
471
845
|
}
|
|
472
846
|
|
|
@@ -475,16 +849,15 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
475
849
|
* We don't check against the previous block submitted since it may have been reorg'd out.
|
|
476
850
|
*/
|
|
477
851
|
protected async checkSync(args: { ts: bigint; slot: SlotNumber }): Promise<SequencerSyncCheckResult | undefined> {
|
|
478
|
-
// Check that the archiver
|
|
479
|
-
//
|
|
480
|
-
//
|
|
481
|
-
const
|
|
482
|
-
const { slot
|
|
483
|
-
if (
|
|
852
|
+
// Check that the archiver has fully synced the L2 slot before the one we want to propose in.
|
|
853
|
+
// The archiver reports sync progress via L1 block timestamps and synced checkpoint slots.
|
|
854
|
+
// See getSyncedL2SlotNumber for how missed L1 blocks are handled.
|
|
855
|
+
const syncedL2Slot = await this.l2BlockSource.getSyncedL2SlotNumber();
|
|
856
|
+
const { slot } = args;
|
|
857
|
+
if (syncedL2Slot === undefined || syncedL2Slot + 1 < slot) {
|
|
484
858
|
this.log.debug(`Cannot propose block at next L2 slot ${slot} due to pending sync from L1`, {
|
|
485
859
|
slot,
|
|
486
|
-
|
|
487
|
-
l1Timestamp,
|
|
860
|
+
syncedL2Slot,
|
|
488
861
|
});
|
|
489
862
|
return undefined;
|
|
490
863
|
}
|
|
@@ -494,45 +867,83 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
494
867
|
number: syncSummary.latestBlockNumber,
|
|
495
868
|
hash: syncSummary.latestBlockHash,
|
|
496
869
|
})),
|
|
497
|
-
this.l2BlockSource.getL2Tips().then(t => t.proposed),
|
|
870
|
+
this.l2BlockSource.getL2Tips().then(t => ({ proposed: t.proposed, checkpointed: t.checkpointed })),
|
|
498
871
|
this.p2pClient.getStatus().then(p2p => p2p.syncedToL2Block),
|
|
499
|
-
this.l1ToL2MessageSource.getL2Tips().then(t => t.proposed),
|
|
872
|
+
this.l1ToL2MessageSource.getL2Tips().then(t => ({ proposed: t.proposed, checkpointed: t.checkpointed })),
|
|
500
873
|
this.l2BlockSource.getPendingChainValidationStatus(),
|
|
874
|
+
this.l2BlockSource.getProposedCheckpointData(),
|
|
501
875
|
] as const);
|
|
502
876
|
|
|
503
|
-
const [worldState,
|
|
877
|
+
const [worldState, l2Tips, p2p, l1ToL2MessageSourceTips, pendingChainValidationStatus, proposedCheckpointData] =
|
|
878
|
+
syncedBlocks;
|
|
504
879
|
|
|
505
|
-
// 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,
|
|
506
|
-
// as the world state can compute the new genesis block hash, but other components use the hardcoded constant.
|
|
507
|
-
// TODO(palla/mbps): Fix the above. All components should be able to handle dynamic genesis block hashes.
|
|
508
880
|
const result =
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
881
|
+
worldState.hash === l2Tips.proposed.hash &&
|
|
882
|
+
p2p.hash === l2Tips.proposed.hash &&
|
|
883
|
+
l1ToL2MessageSourceTips.proposed.hash === l2Tips.proposed.hash &&
|
|
884
|
+
l1ToL2MessageSourceTips.checkpointed.block.hash === l2Tips.checkpointed.block.hash &&
|
|
885
|
+
l1ToL2MessageSourceTips.checkpointed.checkpoint.hash === l2Tips.checkpointed.checkpoint.hash;
|
|
513
886
|
|
|
514
887
|
if (!result) {
|
|
515
|
-
this.log.debug(`Sequencer sync check failed`, {
|
|
888
|
+
this.log.debug(`Sequencer sync check failed`, {
|
|
889
|
+
worldState,
|
|
890
|
+
l2BlockSource: l2Tips.proposed,
|
|
891
|
+
p2p,
|
|
892
|
+
l1ToL2MessageSourceTips,
|
|
893
|
+
});
|
|
516
894
|
return undefined;
|
|
517
895
|
}
|
|
518
896
|
|
|
519
|
-
// Special case for genesis state
|
|
520
897
|
const blockNumber = worldState.number;
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
898
|
+
const blockData = await this.l2BlockSource.getBlockData({ number: blockNumber });
|
|
899
|
+
if (!blockData) {
|
|
900
|
+
this.log.warn(`Sequencer sync check failed: failed to get L2 block data ${blockNumber} from the archiver`, {
|
|
901
|
+
blockNumber,
|
|
902
|
+
l2Tips,
|
|
903
|
+
syncedL2Slot,
|
|
904
|
+
...args,
|
|
905
|
+
});
|
|
906
|
+
return undefined;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
// Refuse to build a checkpoint on top of a proposed block whose enclosing checkpoint was never
|
|
910
|
+
// proposed. Under pipelining we may have received and reexecuted such a block locally — advancing
|
|
911
|
+
// our world-state tip past the checkpointed tip — while the proposing node never published the
|
|
912
|
+
// matching proposed checkpoint (e.g. it crashed before assembling it). Building on this orphan block
|
|
913
|
+
// would fork the chain off a tip no other node can follow. The archiver prunes these orphan blocks
|
|
914
|
+
// once their build slot ends; this guard is the correctness barrier during the grace window before.
|
|
915
|
+
// `getProposedCheckpointData()` returns the latest proposed checkpoint payload, which is always
|
|
916
|
+
// the leading one (a proposed entry is only stored beyond the confirmed frontier and is deleted
|
|
917
|
+
// on confirmation). It carries no tip, so there is no tip-vs-payload split read to reconcile.
|
|
918
|
+
if (
|
|
919
|
+
blockData.checkpointNumber > l2Tips.checkpointed.checkpoint.number &&
|
|
920
|
+
proposedCheckpointData?.checkpointNumber !== blockData.checkpointNumber
|
|
921
|
+
) {
|
|
922
|
+
const logCtx = {
|
|
923
|
+
blockCheckpointNumber: blockData.checkpointNumber,
|
|
924
|
+
checkpointedCheckpointNumber: l2Tips.checkpointed.checkpoint.number,
|
|
925
|
+
proposedCheckpointTipNumber: proposedCheckpointData?.checkpointNumber,
|
|
926
|
+
blockNumber: blockData.header.getBlockNumber(),
|
|
927
|
+
blockSlot: blockData.header.getSlot(),
|
|
928
|
+
syncedL2Slot,
|
|
929
|
+
...args,
|
|
529
930
|
};
|
|
931
|
+
|
|
932
|
+
this.log.debug(`Waiting for proposed checkpoint to catch up with reexecuted block`, logCtx);
|
|
933
|
+
return undefined;
|
|
530
934
|
}
|
|
531
935
|
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
936
|
+
const hasProposedCheckpoint = proposedCheckpointData !== undefined;
|
|
937
|
+
|
|
938
|
+
// Check that the proposed checkpoint is indeed the parent of the checkpoint we'll be building
|
|
939
|
+
// The checkpoint number to build is derived as blockData.checkpointNumber + 1
|
|
940
|
+
if (proposedCheckpointData && proposedCheckpointData.checkpointNumber !== blockData.checkpointNumber) {
|
|
941
|
+
this.log.warn(`Sequencer sync check failed: proposed checkpoint number mismatch`, {
|
|
942
|
+
proposedCheckpointNumber: proposedCheckpointData.checkpointNumber,
|
|
943
|
+
blockCheckpointNumber: blockData.checkpointNumber,
|
|
944
|
+
syncedL2Slot,
|
|
945
|
+
...args,
|
|
946
|
+
});
|
|
536
947
|
return undefined;
|
|
537
948
|
}
|
|
538
949
|
|
|
@@ -540,8 +951,11 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
540
951
|
blockData,
|
|
541
952
|
blockNumber: blockData.header.getBlockNumber(),
|
|
542
953
|
checkpointNumber: blockData.checkpointNumber,
|
|
954
|
+
checkpointedCheckpointNumber: l2Tips.checkpointed.checkpoint.number,
|
|
543
955
|
archive: blockData.archive.root,
|
|
544
|
-
|
|
956
|
+
hasProposedCheckpoint,
|
|
957
|
+
proposedCheckpointData,
|
|
958
|
+
syncedL2Slot,
|
|
545
959
|
pendingChainValidationStatus,
|
|
546
960
|
};
|
|
547
961
|
}
|
|
@@ -550,20 +964,28 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
550
964
|
* Checks if we are the proposer for the next slot.
|
|
551
965
|
* @returns True if we can propose, and the proposer address (undefined if anyone can propose)
|
|
552
966
|
*/
|
|
553
|
-
protected async checkCanPropose(
|
|
967
|
+
protected async checkCanPropose(targetSlot: SlotNumber): Promise<[boolean, EthAddress | undefined]> {
|
|
554
968
|
let proposer: EthAddress | undefined;
|
|
555
969
|
|
|
556
970
|
try {
|
|
557
|
-
proposer = await this.epochCache.getProposerAttesterAddressInSlot(
|
|
971
|
+
proposer = await this.epochCache.getProposerAttesterAddressInSlot(targetSlot);
|
|
558
972
|
} catch (e) {
|
|
559
973
|
if (e instanceof NoCommitteeError) {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
this.
|
|
974
|
+
const targetEpoch = getEpochAtSlot(targetSlot, this.l1Constants);
|
|
975
|
+
if (this.lastEpochForNoCommitteeLog !== targetEpoch) {
|
|
976
|
+
this.lastEpochForNoCommitteeLog = targetEpoch;
|
|
977
|
+
await logMissingCommittee(targetSlot, targetEpoch, {
|
|
978
|
+
epochCache: this.epochCache,
|
|
979
|
+
rollupContract: this.rollupContract,
|
|
980
|
+
l2BlockSource: this.l2BlockSource,
|
|
981
|
+
l1Constants: this.l1Constants,
|
|
982
|
+
dateProvider: this.dateProvider,
|
|
983
|
+
logger: this.log,
|
|
984
|
+
});
|
|
563
985
|
}
|
|
564
986
|
return [false, undefined];
|
|
565
987
|
}
|
|
566
|
-
this.log.error(`Error getting proposer for slot ${
|
|
988
|
+
this.log.error(`Error getting proposer for target slot ${targetSlot}`, e);
|
|
567
989
|
return [false, undefined];
|
|
568
990
|
}
|
|
569
991
|
|
|
@@ -580,55 +1002,56 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
580
1002
|
const weAreProposer = validatorAddresses.some(addr => addr.equals(proposer));
|
|
581
1003
|
|
|
582
1004
|
if (!weAreProposer) {
|
|
583
|
-
this.log.debug(`Cannot propose at slot ${
|
|
1005
|
+
this.log.debug(`Cannot propose at target slot ${targetSlot} since we are not a proposer`, {
|
|
1006
|
+
targetSlot,
|
|
1007
|
+
validatorAddresses,
|
|
1008
|
+
proposer,
|
|
1009
|
+
});
|
|
584
1010
|
return [false, proposer];
|
|
585
1011
|
}
|
|
586
1012
|
|
|
1013
|
+
this.log.info(`We are the proposer for pipeline slot ${targetSlot}`, {
|
|
1014
|
+
targetSlot,
|
|
1015
|
+
proposer,
|
|
1016
|
+
});
|
|
587
1017
|
return [true, proposer];
|
|
588
1018
|
}
|
|
589
1019
|
|
|
590
1020
|
/**
|
|
591
|
-
* Tries to vote on slashing actions and governance
|
|
592
|
-
* This allows the sequencer to participate in governance/slashing votes even when it
|
|
1021
|
+
* Tries to vote on slashing actions and governance and to prune when we cannot build and are past the
|
|
1022
|
+
* block-building window. This allows the sequencer to participate in governance/slashing votes even when it
|
|
1023
|
+
* cannot build blocks, and to prune the pending chain so it can recover from bad data that is blocking sync.
|
|
593
1024
|
*/
|
|
594
|
-
@trackSpan('
|
|
595
|
-
protected async
|
|
596
|
-
const { slot } = args;
|
|
1025
|
+
@trackSpan('Sequencer.tryVoteAndPruneWhenCannotBuild', ({ slot }) => ({ [Attributes.SLOT_NUMBER]: slot }))
|
|
1026
|
+
protected async tryVoteAndPruneWhenCannotBuild(args: { slot: SlotNumber; targetSlot: SlotNumber }): Promise<void> {
|
|
1027
|
+
const { slot, targetSlot } = args;
|
|
597
1028
|
|
|
598
1029
|
// Prevent duplicate attempts in the same slot
|
|
599
|
-
if (this.
|
|
600
|
-
this.log.trace(`Already attempted
|
|
1030
|
+
if (this.lastSlotForFallbackAction === slot) {
|
|
1031
|
+
this.log.trace(`Already attempted fallback actions in slot ${slot} (skipping)`);
|
|
601
1032
|
return;
|
|
602
1033
|
}
|
|
603
1034
|
|
|
604
|
-
//
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
// We use INITIALIZING_PROPOSAL time limit because if we're past that, we can't build a block anyway
|
|
610
|
-
if (maxAllowedTime === undefined || secondsIntoSlot <= maxAllowedTime) {
|
|
611
|
-
this.log.trace(`Not attempting to vote since there is still time for block building`, {
|
|
612
|
-
secondsIntoSlot,
|
|
613
|
-
maxAllowedTime,
|
|
614
|
-
});
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
1035
|
+
// Vote-only actions do not give up the slot: if sync recovers, a later work-loop iteration can still build.
|
|
1036
|
+
// Under proposer pipelining the work loop reasons about the next L1 slot, so waiting for the target slot's
|
|
1037
|
+
// build-start deadline can miss the whole fallback window when the target advances with the clock.
|
|
1038
|
+
const nowSeconds = this.dateProvider.now() / 1000;
|
|
1039
|
+
const startDeadline = this.timetable.getBuildStartDeadline(targetSlot);
|
|
617
1040
|
|
|
618
|
-
this.log.trace(`
|
|
619
|
-
|
|
620
|
-
|
|
1041
|
+
this.log.trace(`Cannot build for slot ${slot}, checking for voting opportunities`, {
|
|
1042
|
+
nowSeconds,
|
|
1043
|
+
startDeadline,
|
|
621
1044
|
});
|
|
622
1045
|
|
|
623
1046
|
// Check if we're a proposer or proposal is open
|
|
624
|
-
const [canPropose, proposer] = await this.checkCanPropose(
|
|
1047
|
+
const [canPropose, proposer] = await this.checkCanPropose(targetSlot);
|
|
625
1048
|
if (!canPropose) {
|
|
626
1049
|
this.log.trace(`Cannot vote in slot ${slot} since we are not a proposer`, { slot, proposer });
|
|
627
1050
|
return;
|
|
628
1051
|
}
|
|
629
1052
|
|
|
630
1053
|
// Mark this slot as attempted
|
|
631
|
-
this.
|
|
1054
|
+
this.lastSlotForFallbackAction = slot;
|
|
632
1055
|
|
|
633
1056
|
// Get a publisher for voting
|
|
634
1057
|
const { attestorAddress, publisher } = await this.publisherFactory.create(proposer);
|
|
@@ -638,9 +1061,9 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
638
1061
|
slot,
|
|
639
1062
|
});
|
|
640
1063
|
|
|
641
|
-
// Enqueue governance and slashing votes
|
|
1064
|
+
// Enqueue governance and slashing votes (voter uses the target slot for L1 submission)
|
|
642
1065
|
const voter = new CheckpointVoter(
|
|
643
|
-
|
|
1066
|
+
targetSlot,
|
|
644
1067
|
publisher,
|
|
645
1068
|
attestorAddress,
|
|
646
1069
|
this.validatorClient,
|
|
@@ -653,13 +1076,41 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
653
1076
|
const votesPromises = voter.enqueueVotes();
|
|
654
1077
|
const votes = await Promise.all(votesPromises);
|
|
655
1078
|
|
|
656
|
-
if (
|
|
657
|
-
|
|
1079
|
+
// Even if we cannot build, try to prune so a stuck pending chain (e.g. bad data blocking sync) can
|
|
1080
|
+
// recover. prune() is permissionless, so it rides the same fallback multicall as the votes.
|
|
1081
|
+
const pruneEnqueued = await this.tryEnqueuePruneIfPrunable(targetSlot, publisher);
|
|
1082
|
+
|
|
1083
|
+
// Bail if nothing to do
|
|
1084
|
+
if (votes.every(p => !p) && !pruneEnqueued) {
|
|
1085
|
+
this.log.debug(`Nothing to enqueue for slot ${slot} (no votes, not prunable)`);
|
|
658
1086
|
return;
|
|
659
1087
|
}
|
|
660
1088
|
|
|
661
|
-
|
|
662
|
-
|
|
1089
|
+
const [governanceVoteEnqueued, slashingVoteEnqueued] = votes;
|
|
1090
|
+
this.log.info(`Submitting fallback requests in slot ${slot} despite sync failure`, {
|
|
1091
|
+
slot,
|
|
1092
|
+
pruneEnqueued,
|
|
1093
|
+
governanceVoteEnqueued: !!governanceVoteEnqueued,
|
|
1094
|
+
slashingVoteEnqueued: !!slashingVoteEnqueued,
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
// Votes are EIP-712-signed for `targetSlot` (the pipelined slot in which the multicall is
|
|
1098
|
+
// expected to mine). Delay submission to the start of `targetSlot` so the tx mines in the
|
|
1099
|
+
// slot the votes were signed for. We fire-and-forget so we don't block the sequencer's
|
|
1100
|
+
// work loop while waiting for the target slot to start, but track it so stop() can drain it.
|
|
1101
|
+
const send = publisher.sendRequestsAt(targetSlot).catch(err => {
|
|
1102
|
+
this.log.error(`Failed to publish fallback requests despite sync failure for slot ${slot}`, err, { slot });
|
|
1103
|
+
});
|
|
1104
|
+
this.pendingRequests.trackRequest(send, () => publisher.interrupt());
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
private async tryEnqueuePruneIfPrunable(targetSlot: SlotNumber, publisher: SequencerPublisher): Promise<boolean> {
|
|
1108
|
+
try {
|
|
1109
|
+
return await publisher.enqueuePruneIfPrunable(targetSlot);
|
|
1110
|
+
} catch (err) {
|
|
1111
|
+
this.log.error(`Failed to enqueue rollup prune for slot ${targetSlot}`, err, { targetSlot });
|
|
1112
|
+
return false;
|
|
1113
|
+
}
|
|
663
1114
|
}
|
|
664
1115
|
|
|
665
1116
|
/**
|
|
@@ -669,25 +1120,34 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
669
1120
|
@trackSpan('Sequencer.tryVoteWhenEscapeHatchOpen', ({ slot }) => ({ [Attributes.SLOT_NUMBER]: slot }))
|
|
670
1121
|
protected async tryVoteWhenEscapeHatchOpen(args: {
|
|
671
1122
|
slot: SlotNumber;
|
|
1123
|
+
targetSlot: SlotNumber;
|
|
672
1124
|
proposer: EthAddress | undefined;
|
|
673
1125
|
}): Promise<void> {
|
|
674
|
-
const { slot, proposer } = args;
|
|
1126
|
+
const { slot, targetSlot, proposer } = args;
|
|
675
1127
|
|
|
676
1128
|
// Prevent duplicate attempts in the same slot
|
|
677
|
-
if (this.
|
|
1129
|
+
if (this.lastSlotForFallbackAction === slot) {
|
|
678
1130
|
this.log.trace(`Already attempted to vote in slot ${slot} (escape hatch open, skipping)`);
|
|
679
1131
|
return;
|
|
680
1132
|
}
|
|
681
1133
|
|
|
682
1134
|
// Mark this slot as attempted
|
|
683
|
-
this.
|
|
1135
|
+
this.lastSlotForFallbackAction = slot;
|
|
684
1136
|
|
|
685
1137
|
const { attestorAddress, publisher } = await this.publisherFactory.create(proposer);
|
|
686
1138
|
|
|
687
|
-
this.log.debug(`Escape hatch open for slot ${slot}, attempting vote-only actions`, {
|
|
1139
|
+
this.log.debug(`Escape hatch open for slot ${slot}, attempting vote-only actions`, {
|
|
1140
|
+
slot,
|
|
1141
|
+
targetSlot,
|
|
1142
|
+
attestorAddress,
|
|
1143
|
+
});
|
|
688
1144
|
|
|
1145
|
+
// Under proposer pipelining, the multicall is expected to mine in `targetSlot` (slot + 1).
|
|
1146
|
+
// Governance and slashing votes are EIP-712-signed against the slot they will mine in, and the
|
|
1147
|
+
// L1 contract checks `msg.sender == getCurrentProposer()` using the mining slot. So we must
|
|
1148
|
+
// sign for `targetSlot` and delay submission to the start of `targetSlot`.
|
|
689
1149
|
const voter = new CheckpointVoter(
|
|
690
|
-
|
|
1150
|
+
targetSlot,
|
|
691
1151
|
publisher,
|
|
692
1152
|
attestorAddress,
|
|
693
1153
|
this.validatorClient,
|
|
@@ -706,8 +1166,17 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
706
1166
|
return;
|
|
707
1167
|
}
|
|
708
1168
|
|
|
709
|
-
this.log.info(`Voting in slot ${slot} (escape hatch open)`, { slot });
|
|
710
|
-
|
|
1169
|
+
this.log.info(`Voting in slot ${slot} (escape hatch open)`, { slot, targetSlot });
|
|
1170
|
+
// Votes are EIP-712-signed for `targetSlot`. Delay submission to the start of `targetSlot` so
|
|
1171
|
+
// the multicall mines in the slot the votes were signed for; otherwise the L1 contract reads
|
|
1172
|
+
// `signaler = getCurrentProposer()` against the wrong slot and signature verification fails
|
|
1173
|
+
// silently inside Multicall3. Fire-and-forget so we don't block the sequencer's work loop while
|
|
1174
|
+
// waiting for the target slot to start, mirroring tryVoteAndPruneWhenCannotBuild, but tracked so
|
|
1175
|
+
// stop() can drain it.
|
|
1176
|
+
const send = publisher.sendRequestsAt(targetSlot).catch(err => {
|
|
1177
|
+
this.log.error(`Failed to publish escape-hatch votes for slot ${slot}`, err, { slot, targetSlot });
|
|
1178
|
+
});
|
|
1179
|
+
this.pendingRequests.trackRequest(send, () => publisher.interrupt());
|
|
711
1180
|
}
|
|
712
1181
|
|
|
713
1182
|
/**
|
|
@@ -715,17 +1184,34 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
715
1184
|
* has been there without being invalidated and whether the sequencer is in the committee or not. We always
|
|
716
1185
|
* have the proposer try to invalidate, but if they fail, the sequencers in the committee are expected to try,
|
|
717
1186
|
* and if they fail, any sequencer will try as well.
|
|
1187
|
+
* @param pendingChainValidationStatus - The archiver's pending-chain validation status, authoritative on its own.
|
|
1188
|
+
* @param currentSlot - The wall-clock slot, used for committee lookup, the per-(checkpoint, slot) dedup guard, and logging.
|
|
718
1189
|
*/
|
|
719
1190
|
protected async considerInvalidatingCheckpoint(
|
|
720
|
-
|
|
1191
|
+
pendingChainValidationStatus: ValidateCheckpointResult,
|
|
721
1192
|
currentSlot: SlotNumber,
|
|
722
1193
|
): Promise<void> {
|
|
723
|
-
const { pendingChainValidationStatus, l1Timestamp } = syncedTo;
|
|
724
1194
|
if (pendingChainValidationStatus.valid) {
|
|
725
1195
|
return;
|
|
726
1196
|
}
|
|
727
1197
|
|
|
728
1198
|
const invalidCheckpointNumber = pendingChainValidationStatus.checkpoint.checkpointNumber;
|
|
1199
|
+
|
|
1200
|
+
// Avoid re-running the committee lookup, simulation, and submission on every tick within a slot.
|
|
1201
|
+
// The guard is keyed by (checkpoint, slot) — so a different invalid checkpoint surfacing later in
|
|
1202
|
+
// the same slot is not suppressed — and is set only after a request is successfully simulated below,
|
|
1203
|
+
// so a transient simulation failure (or thresholds not yet met) still retries on the next tick.
|
|
1204
|
+
if (
|
|
1205
|
+
this.lastInvalidationAttempt?.slot === currentSlot &&
|
|
1206
|
+
this.lastInvalidationAttempt.checkpointNumber === invalidCheckpointNumber
|
|
1207
|
+
) {
|
|
1208
|
+
this.log.trace(`Already attempted to invalidate checkpoint ${invalidCheckpointNumber} in slot ${currentSlot}`, {
|
|
1209
|
+
currentSlot,
|
|
1210
|
+
invalidCheckpointNumber,
|
|
1211
|
+
});
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
729
1215
|
const invalidCheckpointTimestamp = pendingChainValidationStatus.checkpoint.timestamp;
|
|
730
1216
|
const timeSinceChainInvalid = this.dateProvider.nowInSeconds() - Number(invalidCheckpointTimestamp);
|
|
731
1217
|
const ourValidatorAddresses = this.validatorClient.getValidatorAddresses();
|
|
@@ -735,7 +1221,6 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
735
1221
|
|
|
736
1222
|
const logData = {
|
|
737
1223
|
invalidL1Timestamp: invalidCheckpointTimestamp,
|
|
738
|
-
l1Timestamp,
|
|
739
1224
|
invalidCheckpoint: pendingChainValidationStatus.checkpoint,
|
|
740
1225
|
secondsBeforeInvalidatingBlockAsCommitteeMember,
|
|
741
1226
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember,
|
|
@@ -788,6 +1273,10 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
788
1273
|
return;
|
|
789
1274
|
}
|
|
790
1275
|
|
|
1276
|
+
// We produced a valid invalidation request; record it so further ticks within this slot skip the
|
|
1277
|
+
// committee lookup, simulation, and submission above for this same invalid checkpoint.
|
|
1278
|
+
this.lastInvalidationAttempt = { slot: currentSlot, checkpointNumber: invalidCheckpointNumber };
|
|
1279
|
+
|
|
791
1280
|
this.log.info(
|
|
792
1281
|
invalidateAsCommitteeMember
|
|
793
1282
|
? `Invalidating checkpoint ${invalidCheckpointNumber} as committee member`
|
|
@@ -834,13 +1323,13 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
834
1323
|
});
|
|
835
1324
|
}
|
|
836
1325
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
private
|
|
842
|
-
const
|
|
843
|
-
return Number((this.dateProvider.now() / 1000 -
|
|
1326
|
+
/**
|
|
1327
|
+
* Wall-clock seconds elapsed since the build-frame start of the given target slot
|
|
1328
|
+
* (`now − getBuildFrameStart(targetSlot)`). May be negative if called before the build frame opens.
|
|
1329
|
+
*/
|
|
1330
|
+
private getSecondsIntoBuildFrame(targetSlot: SlotNumber): number {
|
|
1331
|
+
const buildFrameStart = this.timetable.getBuildFrameStart(targetSlot);
|
|
1332
|
+
return Number((this.dateProvider.now() / 1000 - buildFrameStart).toFixed(3));
|
|
844
1333
|
}
|
|
845
1334
|
|
|
846
1335
|
public get aztecSlotDuration() {
|
|
@@ -871,17 +1360,16 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
871
1360
|
public getConfig() {
|
|
872
1361
|
return this.config;
|
|
873
1362
|
}
|
|
874
|
-
|
|
875
|
-
private get l1PublishingTime(): number {
|
|
876
|
-
return this.config.l1PublishingTime ?? this.l1Constants.ethereumSlotDuration;
|
|
877
|
-
}
|
|
878
1363
|
}
|
|
879
1364
|
|
|
880
1365
|
type SequencerSyncCheckResult = {
|
|
881
1366
|
blockData?: BlockData;
|
|
882
1367
|
checkpointNumber: CheckpointNumber;
|
|
1368
|
+
checkpointedCheckpointNumber: CheckpointNumber;
|
|
883
1369
|
blockNumber: BlockNumber;
|
|
884
1370
|
archive: Fr;
|
|
885
|
-
|
|
1371
|
+
hasProposedCheckpoint: boolean;
|
|
1372
|
+
proposedCheckpointData?: ProposedCheckpointData;
|
|
1373
|
+
syncedL2Slot: SlotNumber;
|
|
886
1374
|
pendingChainValidationStatus: ValidateCheckpointResult;
|
|
887
1375
|
};
|