@aztec/sequencer-client 0.0.1-commit.d3ec352c → 0.0.1-commit.e310a4c8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client/sequencer-client.d.ts +12 -12
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +33 -26
- package/dest/config.d.ts +12 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +73 -30
- package/dest/global_variable_builder/global_builder.d.ts +21 -12
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +51 -41
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/publisher/config.d.ts +7 -4
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +9 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts +5 -4
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +23 -86
- package/dest/publisher/sequencer-publisher.d.ts +48 -41
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +600 -129
- package/dest/sequencer/checkpoint_proposal_job.d.ts +96 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1192 -0
- package/dest/sequencer/checkpoint_voter.d.ts +35 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +109 -0
- package/dest/sequencer/config.d.ts +3 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/events.d.ts +46 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +4 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +3 -1
- package/dest/sequencer/metrics.d.ts +23 -3
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +143 -70
- package/dest/sequencer/sequencer.d.ts +107 -131
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +690 -602
- package/dest/sequencer/timetable.d.ts +54 -14
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +148 -59
- package/dest/sequencer/types.d.ts +3 -0
- package/dest/sequencer/types.d.ts.map +1 -0
- package/dest/sequencer/types.js +1 -0
- package/dest/sequencer/utils.d.ts +14 -8
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +7 -4
- package/dest/test/index.d.ts +4 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +95 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +220 -0
- package/dest/test/utils.d.ts +53 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +103 -0
- package/package.json +30 -28
- package/src/client/sequencer-client.ts +31 -42
- package/src/config.ts +78 -34
- package/src/global_variable_builder/global_builder.ts +63 -59
- package/src/index.ts +1 -7
- package/src/publisher/config.ts +12 -9
- package/src/publisher/sequencer-publisher-factory.ts +5 -4
- package/src/publisher/sequencer-publisher-metrics.ts +19 -71
- package/src/publisher/sequencer-publisher.ts +293 -170
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/checkpoint_proposal_job.ts +874 -0
- package/src/sequencer/checkpoint_voter.ts +130 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +3 -1
- package/src/sequencer/metrics.ts +190 -78
- package/src/sequencer/sequencer.ts +430 -804
- package/src/sequencer/timetable.ts +173 -79
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +3 -2
- package/src/test/mock_checkpoint_builder.ts +309 -0
- package/src/test/utils.ts +164 -0
- package/dest/sequencer/block_builder.d.ts +0 -28
- package/dest/sequencer/block_builder.d.ts.map +0 -1
- package/dest/sequencer/block_builder.js +0 -134
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -53
- package/src/sequencer/block_builder.ts +0 -222
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -133
|
@@ -1,241 +1,155 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getKzg } from '@aztec/blob-lib';
|
|
2
|
+
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
3
3
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
4
|
-
import {
|
|
4
|
+
import { NoCommitteeError, type RollupContract } from '@aztec/ethereum/contracts';
|
|
5
5
|
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
6
|
-
import { omit, pick } from '@aztec/foundation/collection';
|
|
7
|
-
import {
|
|
6
|
+
import { merge, omit, pick } from '@aztec/foundation/collection';
|
|
7
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
8
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
|
-
import { Signature } from '@aztec/foundation/eth-signature';
|
|
10
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
11
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
10
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
12
|
+
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
15
13
|
import type { P2P } from '@aztec/p2p';
|
|
16
14
|
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
15
|
+
import type { L2Block, L2BlockSink, L2BlockSource, ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
16
|
+
import type { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
17
|
+
import { getSlotAtTimestamp, getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
17
18
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
type L2BlockSource,
|
|
21
|
-
MaliciousCommitteeAttestationsAndSigners,
|
|
22
|
-
type ValidateBlockResult,
|
|
23
|
-
} from '@aztec/stdlib/block';
|
|
24
|
-
import { type L1RollupConstants, getSlotAtTimestamp, getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
25
|
-
import { Gas } from '@aztec/stdlib/gas';
|
|
26
|
-
import {
|
|
27
|
-
type IFullNodeBlockBuilder,
|
|
28
|
-
type PublicProcessorLimits,
|
|
19
|
+
type ResolvedSequencerConfig,
|
|
20
|
+
type SequencerConfig,
|
|
29
21
|
SequencerConfigSchema,
|
|
30
22
|
type WorldStateSynchronizer,
|
|
31
23
|
} from '@aztec/stdlib/interfaces/server';
|
|
32
24
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
33
|
-
import type { BlockProposalOptions } from '@aztec/stdlib/p2p';
|
|
34
|
-
import { orderAttestations } from '@aztec/stdlib/p2p';
|
|
35
|
-
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
36
25
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
37
|
-
import type { L2BlockBuiltStats } from '@aztec/stdlib/stats';
|
|
38
26
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
39
|
-
import { ContentCommitment, type FailedTx, GlobalVariables, Tx } from '@aztec/stdlib/tx';
|
|
40
|
-
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
41
27
|
import { Attributes, type TelemetryClient, type Tracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
42
|
-
import type
|
|
28
|
+
import { FullNodeCheckpointsBuilder, type ValidatorClient } from '@aztec/validator-client';
|
|
43
29
|
|
|
44
30
|
import EventEmitter from 'node:events';
|
|
45
|
-
import type { TypedDataDefinition } from 'viem';
|
|
46
31
|
|
|
32
|
+
import { DefaultSequencerConfig } from '../config.js';
|
|
47
33
|
import type { GlobalVariableBuilder } from '../global_variable_builder/global_builder.js';
|
|
48
34
|
import type { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
49
|
-
import type {
|
|
50
|
-
import
|
|
35
|
+
import type { InvalidateCheckpointRequest, SequencerPublisher } from '../publisher/sequencer-publisher.js';
|
|
36
|
+
import { CheckpointProposalJob } from './checkpoint_proposal_job.js';
|
|
37
|
+
import { CheckpointVoter } from './checkpoint_voter.js';
|
|
51
38
|
import { SequencerInterruptedError, SequencerTooSlowError } from './errors.js';
|
|
39
|
+
import type { SequencerEvents } from './events.js';
|
|
52
40
|
import { SequencerMetrics } from './metrics.js';
|
|
53
41
|
import { SequencerTimetable } from './timetable.js';
|
|
54
|
-
import {
|
|
42
|
+
import type { SequencerRollupConstants } from './types.js';
|
|
43
|
+
import { SequencerState } from './utils.js';
|
|
55
44
|
|
|
56
45
|
export { SequencerState };
|
|
57
46
|
|
|
58
|
-
type SequencerRollupConstants = Pick<L1RollupConstants, 'ethereumSlotDuration' | 'l1GenesisTime' | 'slotDuration'>;
|
|
59
|
-
|
|
60
|
-
export type SequencerEvents = {
|
|
61
|
-
['state-changed']: (args: {
|
|
62
|
-
oldState: SequencerState;
|
|
63
|
-
newState: SequencerState;
|
|
64
|
-
secondsIntoSlot?: number;
|
|
65
|
-
slotNumber?: SlotNumber;
|
|
66
|
-
}) => void;
|
|
67
|
-
['proposer-rollup-check-failed']: (args: { reason: string }) => void;
|
|
68
|
-
['tx-count-check-failed']: (args: { minTxs: number; availableTxs: number }) => void;
|
|
69
|
-
['block-build-failed']: (args: { reason: string }) => void;
|
|
70
|
-
['block-publish-failed']: (args: {
|
|
71
|
-
successfulActions?: Action[];
|
|
72
|
-
failedActions?: Action[];
|
|
73
|
-
sentActions?: Action[];
|
|
74
|
-
expiredActions?: Action[];
|
|
75
|
-
}) => void;
|
|
76
|
-
['block-published']: (args: { blockNumber: BlockNumber; slot: number }) => void;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
47
|
/**
|
|
80
48
|
* Sequencer client
|
|
81
|
-
* -
|
|
82
|
-
* -
|
|
83
|
-
* -
|
|
84
|
-
* -
|
|
85
|
-
* -
|
|
86
|
-
* - Publishes L1 tx(s) to the rollup contract via RollupPublisher.
|
|
49
|
+
* - Checks whether it is elected as proposer for the next slot
|
|
50
|
+
* - Builds multiple blocks and broadcasts them
|
|
51
|
+
* - Collects attestations for the checkpoint
|
|
52
|
+
* - Publishes the checkpoint to L1
|
|
53
|
+
* - Votes for proposals and slashes on L1
|
|
87
54
|
*/
|
|
88
55
|
export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<SequencerEvents>) {
|
|
89
56
|
private runningPromise?: RunningPromise;
|
|
90
|
-
private pollingIntervalMs: number = 1000;
|
|
91
|
-
private maxTxsPerBlock = 32;
|
|
92
|
-
private minTxsPerBlock = 1;
|
|
93
|
-
private maxL1TxInclusionTimeIntoSlot = 0;
|
|
94
57
|
private state = SequencerState.STOPPED;
|
|
95
|
-
private maxBlockSizeInBytes: number = 1024 * 1024;
|
|
96
|
-
private maxBlockGas: Gas = new Gas(100e9, 100e9);
|
|
97
58
|
private metrics: SequencerMetrics;
|
|
98
59
|
|
|
99
|
-
|
|
60
|
+
/** The last slot for which we attempted to perform our voting duties with degraded block production */
|
|
61
|
+
private lastSlotForFallbackVote: SlotNumber | undefined;
|
|
100
62
|
|
|
101
|
-
|
|
63
|
+
/** The last slot for which we triggered a checkpoint proposal job, to prevent duplicate attempts. */
|
|
64
|
+
private lastSlotForCheckpointProposalJob: SlotNumber | undefined;
|
|
102
65
|
|
|
103
|
-
/**
|
|
104
|
-
private
|
|
66
|
+
/** Last successful checkpoint proposed */
|
|
67
|
+
private lastCheckpointProposed: Checkpoint | undefined;
|
|
105
68
|
|
|
106
|
-
/** The last
|
|
107
|
-
private
|
|
69
|
+
/** The last epoch for which we logged strategy comparison in fisherman mode. */
|
|
70
|
+
private lastEpochForStrategyComparison: EpochNumber | undefined;
|
|
108
71
|
|
|
109
72
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */
|
|
110
73
|
protected timetable!: SequencerTimetable;
|
|
111
|
-
protected enforceTimeTable: boolean = false;
|
|
112
74
|
|
|
113
75
|
// This shouldn't be here as this gets re-created each time we build/propose a block.
|
|
114
76
|
// But we have a number of tests that abuse/rely on this class having a permanent publisher.
|
|
115
77
|
// As long as those tests only configure a single publisher they will continue to work.
|
|
116
78
|
// This will get re-assigned every time the sequencer goes to build a new block to a publisher that is valid
|
|
117
79
|
// for the block proposer.
|
|
80
|
+
// TODO(palla/mbps): Remove this field and fix tests
|
|
118
81
|
protected publisher: SequencerPublisher | undefined;
|
|
119
82
|
|
|
83
|
+
/** Config for the sequencer */
|
|
84
|
+
protected config: ResolvedSequencerConfig = DefaultSequencerConfig;
|
|
85
|
+
|
|
120
86
|
constructor(
|
|
121
87
|
protected publisherFactory: SequencerPublisherFactory,
|
|
122
|
-
protected validatorClient: ValidatorClient
|
|
88
|
+
protected validatorClient: ValidatorClient,
|
|
123
89
|
protected globalsBuilder: GlobalVariableBuilder,
|
|
124
90
|
protected p2pClient: P2P,
|
|
125
91
|
protected worldState: WorldStateSynchronizer,
|
|
126
92
|
protected slasherClient: SlasherClientInterface | undefined,
|
|
127
|
-
protected l2BlockSource: L2BlockSource,
|
|
93
|
+
protected l2BlockSource: L2BlockSource & L2BlockSink,
|
|
128
94
|
protected l1ToL2MessageSource: L1ToL2MessageSource,
|
|
129
|
-
protected
|
|
95
|
+
protected checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
130
96
|
protected l1Constants: SequencerRollupConstants,
|
|
131
97
|
protected dateProvider: DateProvider,
|
|
132
98
|
protected epochCache: EpochCache,
|
|
133
99
|
protected rollupContract: RollupContract,
|
|
134
|
-
|
|
100
|
+
config: SequencerConfig,
|
|
135
101
|
protected telemetry: TelemetryClient = getTelemetryClient(),
|
|
136
102
|
protected log = createLogger('sequencer'),
|
|
137
103
|
) {
|
|
138
104
|
super();
|
|
139
105
|
|
|
140
106
|
// Add [FISHERMAN] prefix to logger if in fisherman mode
|
|
141
|
-
if (
|
|
107
|
+
if (config.fishermanMode) {
|
|
142
108
|
this.log = log.createChild('[FISHERMAN]');
|
|
143
109
|
}
|
|
144
110
|
|
|
145
111
|
this.metrics = new SequencerMetrics(telemetry, this.rollupContract, 'Sequencer');
|
|
146
|
-
|
|
147
|
-
this.updateConfig(this.config);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
get tracer(): Tracer {
|
|
151
|
-
return this.metrics.tracer;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
public getValidatorAddresses() {
|
|
155
|
-
return this.validatorClient?.getValidatorAddresses();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
public getConfig() {
|
|
159
|
-
return this.config;
|
|
112
|
+
this.updateConfig(config);
|
|
160
113
|
}
|
|
161
114
|
|
|
162
|
-
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
this.log.info(
|
|
168
|
-
`Sequencer config set`,
|
|
169
|
-
omit(pickFromSchema(config, SequencerConfigSchema), 'txPublicSetupAllowList'),
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
if (config.transactionPollingIntervalMS !== undefined) {
|
|
173
|
-
this.pollingIntervalMs = config.transactionPollingIntervalMS;
|
|
174
|
-
}
|
|
175
|
-
if (config.maxTxsPerBlock !== undefined) {
|
|
176
|
-
this.maxTxsPerBlock = config.maxTxsPerBlock;
|
|
177
|
-
}
|
|
178
|
-
if (config.minTxsPerBlock !== undefined) {
|
|
179
|
-
this.minTxsPerBlock = config.minTxsPerBlock;
|
|
180
|
-
}
|
|
181
|
-
if (config.maxDABlockGas !== undefined) {
|
|
182
|
-
this.maxBlockGas = new Gas(config.maxDABlockGas, this.maxBlockGas.l2Gas);
|
|
183
|
-
}
|
|
184
|
-
if (config.maxL2BlockGas !== undefined) {
|
|
185
|
-
this.maxBlockGas = new Gas(this.maxBlockGas.daGas, config.maxL2BlockGas);
|
|
186
|
-
}
|
|
187
|
-
if (config.maxBlockSizeInBytes !== undefined) {
|
|
188
|
-
this.maxBlockSizeInBytes = config.maxBlockSizeInBytes;
|
|
189
|
-
}
|
|
190
|
-
if (config.governanceProposerPayload) {
|
|
191
|
-
this.governanceProposerPayload = config.governanceProposerPayload;
|
|
192
|
-
}
|
|
193
|
-
if (config.maxL1TxInclusionTimeIntoSlot !== undefined) {
|
|
194
|
-
this.maxL1TxInclusionTimeIntoSlot = config.maxL1TxInclusionTimeIntoSlot;
|
|
195
|
-
}
|
|
196
|
-
if (config.enforceTimeTable !== undefined) {
|
|
197
|
-
this.enforceTimeTable = config.enforceTimeTable;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
this.setTimeTable();
|
|
201
|
-
|
|
202
|
-
// TODO: Just read everything from the config object as needed instead of copying everything into local vars.
|
|
203
|
-
|
|
204
|
-
// Update all values on this.config that are populated in the config object.
|
|
205
|
-
Object.assign(this.config, config);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
private setTimeTable() {
|
|
115
|
+
/** Updates sequencer config by the defined values and updates the timetable */
|
|
116
|
+
public updateConfig(config: Partial<SequencerConfig>) {
|
|
117
|
+
const filteredConfig = pickFromSchema(config, SequencerConfigSchema);
|
|
118
|
+
this.log.info(`Updated sequencer config`, omit(filteredConfig, 'txPublicSetupAllowList'));
|
|
119
|
+
this.config = merge(this.config, filteredConfig);
|
|
209
120
|
this.timetable = new SequencerTimetable(
|
|
210
121
|
{
|
|
211
122
|
ethereumSlotDuration: this.l1Constants.ethereumSlotDuration,
|
|
212
123
|
aztecSlotDuration: this.aztecSlotDuration,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
124
|
+
l1PublishingTime: this.l1PublishingTime,
|
|
125
|
+
p2pPropagationTime: this.config.attestationPropagationTime,
|
|
126
|
+
blockDurationMs: this.config.blockDurationMs,
|
|
127
|
+
enforce: this.config.enforceTimeTable,
|
|
216
128
|
},
|
|
217
129
|
this.metrics,
|
|
218
130
|
this.log,
|
|
219
131
|
);
|
|
220
132
|
}
|
|
221
133
|
|
|
134
|
+
/** Initializes the sequencer (precomputes tables and creates a publisher). Takes about 3s. */
|
|
222
135
|
public async init() {
|
|
136
|
+
getKzg();
|
|
223
137
|
this.publisher = (await this.publisherFactory.create(undefined)).publisher;
|
|
224
138
|
}
|
|
225
139
|
|
|
226
|
-
/**
|
|
227
|
-
* Starts the sequencer and moves to IDLE state.
|
|
228
|
-
*/
|
|
140
|
+
/** Starts the sequencer and moves to IDLE state. */
|
|
229
141
|
public start() {
|
|
230
|
-
this.runningPromise = new RunningPromise(
|
|
142
|
+
this.runningPromise = new RunningPromise(
|
|
143
|
+
this.safeWork.bind(this),
|
|
144
|
+
this.log,
|
|
145
|
+
this.config.sequencerPollingIntervalMS,
|
|
146
|
+
);
|
|
231
147
|
this.setState(SequencerState.IDLE, undefined, { force: true });
|
|
232
148
|
this.runningPromise.start();
|
|
233
149
|
this.log.info('Started sequencer');
|
|
234
150
|
}
|
|
235
151
|
|
|
236
|
-
/**
|
|
237
|
-
* Stops the sequencer from processing txs and moves to STOPPED state.
|
|
238
|
-
*/
|
|
152
|
+
/** Stops the sequencer from building blocks and moves to STOPPED state. */
|
|
239
153
|
public async stop(): Promise<void> {
|
|
240
154
|
this.log.info(`Stopping sequencer`);
|
|
241
155
|
this.setState(SequencerState.STOPPING, undefined, { force: true });
|
|
@@ -245,52 +159,140 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
245
159
|
this.log.info('Stopped sequencer');
|
|
246
160
|
}
|
|
247
161
|
|
|
248
|
-
/**
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
162
|
+
/** Main sequencer loop with a try/catch */
|
|
163
|
+
protected async safeWork() {
|
|
164
|
+
try {
|
|
165
|
+
await this.work();
|
|
166
|
+
} catch (err) {
|
|
167
|
+
this.emit('checkpoint-error', { error: err as Error });
|
|
168
|
+
if (err instanceof SequencerTooSlowError) {
|
|
169
|
+
// TODO(palla/mbps): Add missing states
|
|
170
|
+
// Log as warn only if we had to abort halfway through the block proposal
|
|
171
|
+
const logLvl = [SequencerState.INITIALIZING_CHECKPOINT, SequencerState.PROPOSER_CHECK].includes(
|
|
172
|
+
err.proposedState,
|
|
173
|
+
)
|
|
174
|
+
? ('debug' as const)
|
|
175
|
+
: ('warn' as const);
|
|
176
|
+
this.log[logLvl](err.message, { now: this.dateProvider.nowInSeconds() });
|
|
177
|
+
} else {
|
|
178
|
+
// Re-throw other errors
|
|
179
|
+
throw err;
|
|
180
|
+
}
|
|
181
|
+
} finally {
|
|
182
|
+
this.setState(SequencerState.IDLE, undefined);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Returns the current state of the sequencer. */
|
|
252
187
|
public status() {
|
|
253
188
|
return { state: this.state };
|
|
254
189
|
}
|
|
255
190
|
|
|
256
191
|
/**
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
192
|
+
* Main sequencer loop:
|
|
193
|
+
* - Checks if we are up to date
|
|
194
|
+
* - If we are and we are the sequencer, collect txs and build blocks
|
|
195
|
+
* - Build multiple blocks per slot when configured
|
|
196
|
+
* - Collect attestations for the final block
|
|
197
|
+
* - Submit checkpoint
|
|
263
198
|
*/
|
|
199
|
+
@trackSpan('Sequencer.work')
|
|
264
200
|
protected async work() {
|
|
265
201
|
this.setState(SequencerState.SYNCHRONIZING, undefined);
|
|
266
|
-
const { slot, ts, now } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
202
|
+
const { slot, ts, now, epoch } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
267
203
|
|
|
268
|
-
// Check we
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
`Cannot propose block at next L2 slot ${slot} since that slot was taken by our own block ${this.lastBlockPublished.number}`,
|
|
272
|
-
);
|
|
204
|
+
// Check if we are synced and it's our slot, grab a publisher, check previous block invalidation, etc
|
|
205
|
+
const checkpointProposalJob = await this.prepareCheckpointProposal(epoch, slot, ts, now);
|
|
206
|
+
if (!checkpointProposalJob) {
|
|
273
207
|
return;
|
|
274
208
|
}
|
|
275
209
|
|
|
210
|
+
// Execute the checkpoint proposal job
|
|
211
|
+
const checkpoint = await checkpointProposalJob.execute();
|
|
212
|
+
|
|
213
|
+
// Update last checkpoint proposed (currently unused)
|
|
214
|
+
if (checkpoint) {
|
|
215
|
+
this.lastCheckpointProposed = checkpoint;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Log fee strategy comparison if on fisherman
|
|
219
|
+
if (
|
|
220
|
+
this.config.fishermanMode &&
|
|
221
|
+
(this.lastEpochForStrategyComparison === undefined || epoch > this.lastEpochForStrategyComparison)
|
|
222
|
+
) {
|
|
223
|
+
this.logStrategyComparison(epoch, checkpointProposalJob.getPublisher());
|
|
224
|
+
this.lastEpochForStrategyComparison = epoch;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return checkpoint;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Prepares the checkpoint proposal by performing all necessary checks and setup.
|
|
232
|
+
* This is the initial step in the main loop.
|
|
233
|
+
* @returns CheckpointProposalJob if successful, undefined if we are not yet synced or are not the proposer.
|
|
234
|
+
*/
|
|
235
|
+
@trackSpan('Sequencer.prepareCheckpointProposal')
|
|
236
|
+
private async prepareCheckpointProposal(
|
|
237
|
+
epoch: EpochNumber,
|
|
238
|
+
slot: SlotNumber,
|
|
239
|
+
ts: bigint,
|
|
240
|
+
now: bigint,
|
|
241
|
+
): Promise<CheckpointProposalJob | undefined> {
|
|
242
|
+
// Check we have not already processed this slot (cheapest check)
|
|
243
|
+
// We only check this if enforce timetable is set, since we want to keep processing the same slot if we are not
|
|
244
|
+
// running against actual time (eg when we use sandbox-style automining)
|
|
245
|
+
if (
|
|
246
|
+
this.lastSlotForCheckpointProposalJob &&
|
|
247
|
+
this.lastSlotForCheckpointProposalJob >= slot &&
|
|
248
|
+
this.config.enforceTimeTable
|
|
249
|
+
) {
|
|
250
|
+
this.log.trace(`Slot ${slot} has already been processed`);
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// But if we have already proposed for this slot, the we definitely have to skip it, automining or not
|
|
255
|
+
if (this.lastCheckpointProposed && this.lastCheckpointProposed.header.slotNumber >= slot) {
|
|
256
|
+
this.log.trace(`Slot ${slot} has already been published as checkpoint ${this.lastCheckpointProposed.number}`);
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
|
|
276
260
|
// Check all components are synced to latest as seen by the archiver (queries all subsystems)
|
|
277
261
|
const syncedTo = await this.checkSync({ ts, slot });
|
|
278
262
|
if (!syncedTo) {
|
|
279
263
|
await this.tryVoteWhenSyncFails({ slot, ts });
|
|
280
|
-
return;
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// If escape hatch is open for this epoch, do not start checkpoint proposal work and do not attempt invalidations.
|
|
268
|
+
// Still perform governance/slashing voting (as proposer) once per slot.
|
|
269
|
+
const isEscapeHatchOpen = await this.epochCache.isEscapeHatchOpen(epoch);
|
|
270
|
+
|
|
271
|
+
if (isEscapeHatchOpen) {
|
|
272
|
+
this.setState(SequencerState.PROPOSER_CHECK, slot);
|
|
273
|
+
const [canPropose, proposer] = await this.checkCanPropose(slot);
|
|
274
|
+
if (canPropose) {
|
|
275
|
+
await this.tryVoteWhenEscapeHatchOpen({ slot, proposer });
|
|
276
|
+
} else {
|
|
277
|
+
this.log.trace(`Escape hatch open but we are not proposer, skipping vote-only actions`, {
|
|
278
|
+
slot,
|
|
279
|
+
epoch,
|
|
280
|
+
proposer,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return undefined;
|
|
281
284
|
}
|
|
282
285
|
|
|
283
|
-
|
|
284
|
-
const
|
|
286
|
+
// Next checkpoint follows from the last synced one
|
|
287
|
+
const checkpointNumber = CheckpointNumber(syncedTo.checkpointNumber + 1);
|
|
285
288
|
|
|
286
|
-
const
|
|
289
|
+
const logCtx = {
|
|
287
290
|
now,
|
|
288
291
|
syncedToL1Ts: syncedTo.l1Timestamp,
|
|
289
292
|
syncedToL2Slot: getSlotAtTimestamp(syncedTo.l1Timestamp, this.l1Constants),
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
newBlockNumber,
|
|
293
|
+
slot,
|
|
294
|
+
slotTs: ts,
|
|
295
|
+
checkpointNumber,
|
|
294
296
|
isPendingChainValid: pick(syncedTo.pendingChainValidationStatus, 'valid', 'reason', 'invalidIndex'),
|
|
295
297
|
};
|
|
296
298
|
|
|
@@ -298,269 +300,146 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
298
300
|
this.setState(SequencerState.PROPOSER_CHECK, slot);
|
|
299
301
|
const [canPropose, proposer] = await this.checkCanPropose(slot);
|
|
300
302
|
|
|
301
|
-
// If we are not a proposer check if we should invalidate
|
|
303
|
+
// If we are not a proposer check if we should invalidate an invalid checkpoint, and bail
|
|
302
304
|
if (!canPropose) {
|
|
303
|
-
await this.
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// In fisherman mode, check if we've already validated this slot to prevent duplicate attempts
|
|
308
|
-
if (this.config.fishermanMode) {
|
|
309
|
-
if (this.lastSlotForValidationBlock === slot) {
|
|
310
|
-
this.log.trace(`Already validated block building for slot ${slot} (skipping)`, { slot });
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
this.log.debug(
|
|
314
|
-
`Building validation block for slot ${slot} (actual proposer: ${proposer?.toString() ?? 'none'})`,
|
|
315
|
-
{ slot, proposer: proposer?.toString() },
|
|
316
|
-
);
|
|
317
|
-
// Mark this slot as being validated
|
|
318
|
-
this.lastSlotForValidationBlock = slot;
|
|
305
|
+
await this.considerInvalidatingCheckpoint(syncedTo, slot);
|
|
306
|
+
return undefined;
|
|
319
307
|
}
|
|
320
308
|
|
|
321
309
|
// Check that the slot is not taken by a block already (should never happen, since only us can propose for this slot)
|
|
322
310
|
if (syncedTo.block && syncedTo.block.header.getSlot() >= slot) {
|
|
323
311
|
this.log.warn(
|
|
324
312
|
`Cannot propose block at next L2 slot ${slot} since that slot was taken by block ${syncedTo.blockNumber}`,
|
|
325
|
-
{ ...
|
|
313
|
+
{ ...logCtx, block: syncedTo.block.header.toInspect() },
|
|
326
314
|
);
|
|
327
315
|
this.metrics.recordBlockProposalPrecheckFailed('slot_already_taken');
|
|
328
|
-
return;
|
|
316
|
+
return undefined;
|
|
329
317
|
}
|
|
330
318
|
|
|
331
319
|
// We now need to get ourselves a publisher.
|
|
332
320
|
// The returned attestor will be the one we provided if we provided one.
|
|
333
321
|
// Otherwise it will be a valid attestor for the returned publisher.
|
|
334
322
|
// In fisherman mode, pass undefined to use the fisherman's own keystore instead of the actual proposer's
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
);
|
|
323
|
+
const proposerForPublisher = this.config.fishermanMode ? undefined : proposer;
|
|
324
|
+
const { attestorAddress, publisher } = await this.publisherFactory.create(proposerForPublisher);
|
|
338
325
|
this.log.verbose(`Created publisher at address ${publisher.getSenderAddress()} for attestor ${attestorAddress}`);
|
|
339
326
|
this.publisher = publisher;
|
|
340
327
|
|
|
341
328
|
// In fisherman mode, set the actual proposer's address for simulations
|
|
342
|
-
if (this.config.fishermanMode) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
this.log.debug(`Set proposer address ${proposer} for simulation in fisherman mode`);
|
|
346
|
-
}
|
|
329
|
+
if (this.config.fishermanMode && proposer) {
|
|
330
|
+
publisher.setProposerAddressForSimulation(proposer);
|
|
331
|
+
this.log.debug(`Set proposer address ${proposer} for simulation in fisherman mode`);
|
|
347
332
|
}
|
|
348
333
|
|
|
349
|
-
// Get proposer credentials
|
|
350
|
-
const coinbase = this.validatorClient!.getCoinbaseForAttestor(attestorAddress);
|
|
351
|
-
const feeRecipient = this.validatorClient!.getFeeRecipientForAttestor(attestorAddress);
|
|
352
|
-
|
|
353
334
|
// Prepare invalidation request if the pending chain is invalid (returns undefined if no need)
|
|
354
|
-
const
|
|
335
|
+
const invalidateCheckpoint = await publisher.simulateInvalidateCheckpoint(syncedTo.pendingChainValidationStatus);
|
|
355
336
|
|
|
356
|
-
// Check with the rollup if we can indeed propose at the next L2 slot. This check should not fail
|
|
337
|
+
// Check with the rollup contract if we can indeed propose at the next L2 slot. This check should not fail
|
|
357
338
|
// if all the previous checks are good, but we do it just in case.
|
|
358
339
|
const canProposeCheck = await publisher.canProposeAtNextEthBlock(
|
|
359
|
-
|
|
340
|
+
syncedTo.archive,
|
|
360
341
|
proposer ?? EthAddress.ZERO,
|
|
361
|
-
|
|
342
|
+
invalidateCheckpoint,
|
|
362
343
|
);
|
|
363
344
|
|
|
364
345
|
if (canProposeCheck === undefined) {
|
|
365
346
|
this.log.warn(
|
|
366
|
-
`Cannot propose
|
|
367
|
-
|
|
347
|
+
`Cannot propose checkpoint ${checkpointNumber} at slot ${slot} due to failed rollup contract check`,
|
|
348
|
+
logCtx,
|
|
368
349
|
);
|
|
369
|
-
this.emit('proposer-rollup-check-failed', { reason: 'Rollup contract check failed' });
|
|
350
|
+
this.emit('proposer-rollup-check-failed', { reason: 'Rollup contract check failed', slot });
|
|
370
351
|
this.metrics.recordBlockProposalPrecheckFailed('rollup_contract_check_failed');
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (canProposeCheck.slot !== slot) {
|
|
373
356
|
this.log.warn(
|
|
374
357
|
`Cannot propose block due to slot mismatch with rollup contract (this can be caused by a clock out of sync). Expected slot ${slot} but got ${canProposeCheck.slot}.`,
|
|
375
|
-
{ ...
|
|
358
|
+
{ ...logCtx, rollup: canProposeCheck, expectedSlot: slot },
|
|
376
359
|
);
|
|
377
|
-
this.emit('proposer-rollup-check-failed', { reason: 'Slot mismatch' });
|
|
360
|
+
this.emit('proposer-rollup-check-failed', { reason: 'Slot mismatch', slot });
|
|
378
361
|
this.metrics.recordBlockProposalPrecheckFailed('slot_mismatch');
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
362
|
+
return undefined;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (canProposeCheck.checkpointNumber !== checkpointNumber) {
|
|
381
366
|
this.log.warn(
|
|
382
|
-
`Cannot propose
|
|
383
|
-
{ ...
|
|
367
|
+
`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}.`,
|
|
368
|
+
{ ...logCtx, rollup: canProposeCheck, expectedSlot: slot },
|
|
384
369
|
);
|
|
385
|
-
this.emit('proposer-rollup-check-failed', { reason: 'Block mismatch' });
|
|
370
|
+
this.emit('proposer-rollup-check-failed', { reason: 'Block mismatch', slot });
|
|
386
371
|
this.metrics.recordBlockProposalPrecheckFailed('block_number_mismatch');
|
|
387
|
-
return;
|
|
372
|
+
return undefined;
|
|
388
373
|
}
|
|
389
374
|
|
|
390
|
-
this.
|
|
375
|
+
this.lastSlotForCheckpointProposalJob = slot;
|
|
376
|
+
this.log.info(`Preparing checkpoint proposal ${checkpointNumber} at slot ${slot}`, { ...logCtx, proposer });
|
|
391
377
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
feeRecipient,
|
|
396
|
-
slot,
|
|
397
|
-
);
|
|
398
|
-
|
|
399
|
-
// Enqueue governance and slashing votes (returns promises that will be awaited later)
|
|
400
|
-
// In fisherman mode, we simulate slashing but don't actually publish to L1
|
|
401
|
-
const votesPromises = this.enqueueGovernanceAndSlashingVotes(
|
|
402
|
-
publisher,
|
|
403
|
-
attestorAddress,
|
|
404
|
-
slot,
|
|
405
|
-
newGlobalVariables.timestamp,
|
|
406
|
-
);
|
|
407
|
-
|
|
408
|
-
// Enqueues block invalidation
|
|
409
|
-
if (invalidateBlock && !this.config.skipInvalidateBlockAsProposer) {
|
|
410
|
-
publisher.enqueueInvalidateBlock(invalidateBlock);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// Actual block building
|
|
414
|
-
this.setState(SequencerState.INITIALIZING_PROPOSAL, slot);
|
|
415
|
-
this.metrics.incOpenSlot(slot, proposer?.toString() ?? 'unknown');
|
|
416
|
-
const block: L2Block | undefined = await this.tryBuildBlockAndEnqueuePublish(
|
|
378
|
+
// Create and return the checkpoint proposal job
|
|
379
|
+
return this.createCheckpointProposalJob(
|
|
380
|
+
epoch,
|
|
417
381
|
slot,
|
|
382
|
+
checkpointNumber,
|
|
383
|
+
syncedTo.blockNumber,
|
|
418
384
|
proposer,
|
|
419
|
-
newBlockNumber,
|
|
420
385
|
publisher,
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
invalidateBlock,
|
|
386
|
+
attestorAddress,
|
|
387
|
+
invalidateCheckpoint,
|
|
424
388
|
);
|
|
425
|
-
|
|
426
|
-
// Wait until the voting promises have resolved, so all requests are enqueued
|
|
427
|
-
await Promise.all(votesPromises);
|
|
428
|
-
|
|
429
|
-
// In fisherman mode, we don't publish to L1
|
|
430
|
-
if (this.config.fishermanMode) {
|
|
431
|
-
// Clear pending requests
|
|
432
|
-
publisher.clearPendingRequests();
|
|
433
|
-
|
|
434
|
-
if (block) {
|
|
435
|
-
this.log.info(`Validation block building SUCCEEDED for slot ${slot}`, {
|
|
436
|
-
blockNumber: newBlockNumber,
|
|
437
|
-
slot: Number(slot),
|
|
438
|
-
archive: block.archive.toString(),
|
|
439
|
-
txCount: block.body.txEffects.length,
|
|
440
|
-
});
|
|
441
|
-
this.lastBlockPublished = block;
|
|
442
|
-
this.metrics.recordBlockProposalSuccess();
|
|
443
|
-
} else {
|
|
444
|
-
// Block building failed in fisherman mode
|
|
445
|
-
this.log.warn(`Validation block building FAILED for slot ${slot}`, {
|
|
446
|
-
blockNumber: newBlockNumber,
|
|
447
|
-
slot: Number(slot),
|
|
448
|
-
});
|
|
449
|
-
this.metrics.recordBlockProposalFailed('block_build_failed');
|
|
450
|
-
}
|
|
451
|
-
} else {
|
|
452
|
-
// Normal mode: send the tx to L1
|
|
453
|
-
const l1Response = await publisher.sendRequests();
|
|
454
|
-
const proposedBlock = l1Response?.successfulActions.find(a => a === 'propose');
|
|
455
|
-
if (proposedBlock) {
|
|
456
|
-
this.lastBlockPublished = block;
|
|
457
|
-
this.emit('block-published', { blockNumber: newBlockNumber, slot: Number(slot) });
|
|
458
|
-
await this.metrics.incFilledSlot(publisher.getSenderAddress().toString(), coinbase);
|
|
459
|
-
} else if (block) {
|
|
460
|
-
this.emit('block-publish-failed', l1Response ?? {});
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
this.setState(SequencerState.IDLE, undefined);
|
|
465
389
|
}
|
|
466
390
|
|
|
467
|
-
|
|
468
|
-
|
|
391
|
+
protected createCheckpointProposalJob(
|
|
392
|
+
epoch: EpochNumber,
|
|
469
393
|
slot: SlotNumber,
|
|
394
|
+
checkpointNumber: CheckpointNumber,
|
|
395
|
+
syncedToBlockNumber: BlockNumber,
|
|
470
396
|
proposer: EthAddress | undefined,
|
|
471
|
-
newBlockNumber: BlockNumber,
|
|
472
397
|
publisher: SequencerPublisher,
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
proposer,
|
|
479
|
-
publisher: publisher.getSenderAddress(),
|
|
480
|
-
globalVariables: newGlobalVariables.toInspect(),
|
|
481
|
-
chainTipArchive,
|
|
482
|
-
blockNumber: newBlockNumber,
|
|
398
|
+
attestorAddress: EthAddress,
|
|
399
|
+
invalidateCheckpoint: InvalidateCheckpointRequest | undefined,
|
|
400
|
+
): CheckpointProposalJob {
|
|
401
|
+
return new CheckpointProposalJob(
|
|
402
|
+
epoch,
|
|
483
403
|
slot,
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
);
|
|
511
|
-
} catch (err: any) {
|
|
512
|
-
this.emit('block-build-failed', { reason: err.message });
|
|
513
|
-
if (err instanceof FormattedViemError) {
|
|
514
|
-
this.log.verbose(`Unable to build/enqueue block ${err.message}`);
|
|
515
|
-
} else {
|
|
516
|
-
this.log.error(`Error building/enqueuing block`, err, { blockNumber: newBlockNumber, slot });
|
|
517
|
-
}
|
|
518
|
-
this.metrics.recordBlockProposalFailed(err.name || 'unknown_error');
|
|
519
|
-
}
|
|
520
|
-
} else {
|
|
521
|
-
this.log.verbose(
|
|
522
|
-
`Not enough txs to build block ${newBlockNumber} at slot ${slot} (got ${pendingTxCount} txs, need ${this.minTxsPerBlock})`,
|
|
523
|
-
{ chainTipArchive, blockNumber: newBlockNumber, slot },
|
|
524
|
-
);
|
|
525
|
-
this.emit('tx-count-check-failed', { minTxs: this.minTxsPerBlock, availableTxs: pendingTxCount });
|
|
526
|
-
this.metrics.recordBlockProposalFailed('insufficient_txs');
|
|
527
|
-
}
|
|
528
|
-
return block;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
@trackSpan('Sequencer.work')
|
|
532
|
-
protected async safeWork() {
|
|
533
|
-
try {
|
|
534
|
-
await this.work();
|
|
535
|
-
} catch (err) {
|
|
536
|
-
if (err instanceof SequencerTooSlowError) {
|
|
537
|
-
// Log as warn only if we had to abort halfway through the block proposal
|
|
538
|
-
const logLvl = [SequencerState.INITIALIZING_PROPOSAL, SequencerState.PROPOSER_CHECK].includes(err.proposedState)
|
|
539
|
-
? ('debug' as const)
|
|
540
|
-
: ('warn' as const);
|
|
541
|
-
this.log[logLvl](err.message, { now: this.dateProvider.nowInSeconds() });
|
|
542
|
-
} else {
|
|
543
|
-
// Re-throw other errors
|
|
544
|
-
throw err;
|
|
545
|
-
}
|
|
546
|
-
} finally {
|
|
547
|
-
this.setState(SequencerState.IDLE, undefined);
|
|
548
|
-
}
|
|
404
|
+
checkpointNumber,
|
|
405
|
+
syncedToBlockNumber,
|
|
406
|
+
proposer,
|
|
407
|
+
publisher,
|
|
408
|
+
attestorAddress,
|
|
409
|
+
invalidateCheckpoint,
|
|
410
|
+
this.validatorClient,
|
|
411
|
+
this.globalsBuilder,
|
|
412
|
+
this.p2pClient,
|
|
413
|
+
this.worldState,
|
|
414
|
+
this.l1ToL2MessageSource,
|
|
415
|
+
this.l2BlockSource,
|
|
416
|
+
this.checkpointsBuilder,
|
|
417
|
+
this.l2BlockSource,
|
|
418
|
+
this.l1Constants,
|
|
419
|
+
this.config,
|
|
420
|
+
this.timetable,
|
|
421
|
+
this.slasherClient,
|
|
422
|
+
this.epochCache,
|
|
423
|
+
this.dateProvider,
|
|
424
|
+
this.metrics,
|
|
425
|
+
this,
|
|
426
|
+
this.setState.bind(this),
|
|
427
|
+
this.tracer,
|
|
428
|
+
this.log.getBindings(),
|
|
429
|
+
);
|
|
549
430
|
}
|
|
550
431
|
|
|
551
432
|
/**
|
|
552
|
-
*
|
|
433
|
+
* Internal helper for setting the sequencer state and checks if we have enough time left in the slot to transition to the new state.
|
|
553
434
|
* @param proposedState - The new state to transition to.
|
|
554
435
|
* @param slotNumber - The current slot number.
|
|
555
436
|
* @param force - Whether to force the transition even if the sequencer is stopped.
|
|
556
437
|
*/
|
|
557
|
-
setState(
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
): void;
|
|
563
|
-
setState(proposedState: SequencerState, slotNumber: SlotNumber | undefined, opts: { force?: boolean } = {}): void {
|
|
438
|
+
protected setState(
|
|
439
|
+
proposedState: SequencerState,
|
|
440
|
+
slotNumber: SlotNumber | undefined,
|
|
441
|
+
opts: { force?: boolean } = {},
|
|
442
|
+
): void {
|
|
564
443
|
if (this.state === SequencerState.STOPPING && proposedState !== SequencerState.STOPPED && !opts.force) {
|
|
565
444
|
this.log.warn(`Cannot set sequencer to ${proposedState} as it is stopping.`);
|
|
566
445
|
throw new SequencerInterruptedError();
|
|
@@ -586,351 +465,16 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
586
465
|
oldState: this.state,
|
|
587
466
|
newState: proposedState,
|
|
588
467
|
secondsIntoSlot,
|
|
589
|
-
slotNumber,
|
|
468
|
+
slot: slotNumber,
|
|
590
469
|
});
|
|
591
470
|
this.state = proposedState;
|
|
592
471
|
}
|
|
593
472
|
|
|
594
|
-
private async dropFailedTxsFromP2P(failedTxs: FailedTx[]) {
|
|
595
|
-
if (failedTxs.length === 0) {
|
|
596
|
-
return;
|
|
597
|
-
}
|
|
598
|
-
const failedTxData = failedTxs.map(fail => fail.tx);
|
|
599
|
-
const failedTxHashes = failedTxData.map(tx => tx.getTxHash());
|
|
600
|
-
this.log.verbose(`Dropping failed txs ${failedTxHashes.join(', ')}`);
|
|
601
|
-
await this.p2pClient.deleteTxs(failedTxHashes);
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
protected getBlockBuilderOptions(slot: SlotNumber): PublicProcessorLimits {
|
|
605
|
-
// Deadline for processing depends on whether we're proposing a block
|
|
606
|
-
const secondsIntoSlot = this.getSecondsIntoSlot(slot);
|
|
607
|
-
const processingEndTimeWithinSlot = this.timetable.getBlockProposalExecTimeEnd(secondsIntoSlot);
|
|
608
|
-
|
|
609
|
-
// Deadline is only set if enforceTimeTable is enabled.
|
|
610
|
-
const deadline = this.enforceTimeTable
|
|
611
|
-
? new Date((this.getSlotStartBuildTimestamp(slot) + processingEndTimeWithinSlot) * 1000)
|
|
612
|
-
: undefined;
|
|
613
|
-
return {
|
|
614
|
-
maxTransactions: this.maxTxsPerBlock,
|
|
615
|
-
maxBlockSize: this.maxBlockSizeInBytes,
|
|
616
|
-
maxBlockGas: this.maxBlockGas,
|
|
617
|
-
maxBlobFields: BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB,
|
|
618
|
-
deadline,
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* @notice Build and propose a block to the chain
|
|
624
|
-
*
|
|
625
|
-
* @dev MUST throw instead of exiting early to ensure that world-state
|
|
626
|
-
* is being rolled back if the block is dropped.
|
|
627
|
-
*
|
|
628
|
-
* @param pendingTxs - Iterable of pending transactions to construct the block from
|
|
629
|
-
* @param proposalHeader - The partial header constructed for the proposal
|
|
630
|
-
* @param newGlobalVariables - The global variables for the new block
|
|
631
|
-
* @param proposerAddress - The address of the proposer
|
|
632
|
-
*/
|
|
633
|
-
@trackSpan('Sequencer.buildBlockAndEnqueuePublish', (_validTxs, _proposalHeader, newGlobalVariables) => ({
|
|
634
|
-
[Attributes.BLOCK_NUMBER]: newGlobalVariables.blockNumber,
|
|
635
|
-
}))
|
|
636
|
-
private async buildBlockAndEnqueuePublish(
|
|
637
|
-
pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
638
|
-
proposalHeader: CheckpointHeader,
|
|
639
|
-
newGlobalVariables: GlobalVariables,
|
|
640
|
-
proposerAddress: EthAddress | undefined,
|
|
641
|
-
invalidateBlock: InvalidateBlockRequest | undefined,
|
|
642
|
-
publisher: SequencerPublisher,
|
|
643
|
-
): Promise<L2Block> {
|
|
644
|
-
await publisher.validateBlockHeader(proposalHeader, invalidateBlock);
|
|
645
|
-
|
|
646
|
-
const blockNumber = newGlobalVariables.blockNumber;
|
|
647
|
-
const slot = proposalHeader.slotNumber;
|
|
648
|
-
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(blockNumber);
|
|
649
|
-
|
|
650
|
-
const workTimer = new Timer();
|
|
651
|
-
this.setState(SequencerState.CREATING_BLOCK, slot);
|
|
652
|
-
|
|
653
|
-
try {
|
|
654
|
-
const blockBuilderOptions = this.getBlockBuilderOptions(slot);
|
|
655
|
-
const buildBlockRes = await this.blockBuilder.buildBlock(
|
|
656
|
-
pendingTxs,
|
|
657
|
-
l1ToL2Messages,
|
|
658
|
-
newGlobalVariables,
|
|
659
|
-
blockBuilderOptions,
|
|
660
|
-
);
|
|
661
|
-
const { publicGas, block, publicProcessorDuration, numTxs, numMsgs, blockBuildingTimer, usedTxs, failedTxs } =
|
|
662
|
-
buildBlockRes;
|
|
663
|
-
const blockBuildDuration = workTimer.ms();
|
|
664
|
-
await this.dropFailedTxsFromP2P(failedTxs);
|
|
665
|
-
|
|
666
|
-
const minTxsPerBlock = this.minTxsPerBlock;
|
|
667
|
-
if (numTxs < minTxsPerBlock) {
|
|
668
|
-
this.log.warn(
|
|
669
|
-
`Block ${blockNumber} has too few txs to be proposed (got ${numTxs} but required ${minTxsPerBlock})`,
|
|
670
|
-
{ slot, blockNumber, numTxs },
|
|
671
|
-
);
|
|
672
|
-
throw new Error(`Block has too few successful txs to be proposed`);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
// TODO(@PhilWindle) We should probably periodically check for things like another
|
|
676
|
-
// block being published before ours instead of just waiting on our block
|
|
677
|
-
await publisher.validateBlockHeader(block.getCheckpointHeader(), invalidateBlock);
|
|
678
|
-
|
|
679
|
-
const blockStats: L2BlockBuiltStats = {
|
|
680
|
-
eventName: 'l2-block-built',
|
|
681
|
-
creator: proposerAddress?.toString() ?? publisher.getSenderAddress().toString(),
|
|
682
|
-
duration: workTimer.ms(),
|
|
683
|
-
publicProcessDuration: publicProcessorDuration,
|
|
684
|
-
rollupCircuitsDuration: blockBuildingTimer.ms(),
|
|
685
|
-
...block.getStats(),
|
|
686
|
-
};
|
|
687
|
-
|
|
688
|
-
const blockHash = await block.hash();
|
|
689
|
-
const txHashes = block.body.txEffects.map(tx => tx.txHash);
|
|
690
|
-
this.log.info(
|
|
691
|
-
`Built block ${block.number} for slot ${slot} with ${numTxs} txs and ${numMsgs} messages. ${
|
|
692
|
-
publicGas.l2Gas / workTimer.s()
|
|
693
|
-
} mana/s`,
|
|
694
|
-
{
|
|
695
|
-
blockHash,
|
|
696
|
-
globalVariables: block.header.globalVariables.toInspect(),
|
|
697
|
-
txHashes,
|
|
698
|
-
...blockStats,
|
|
699
|
-
},
|
|
700
|
-
);
|
|
701
|
-
|
|
702
|
-
// In fisherman mode, skip attestation collection
|
|
703
|
-
let attestationsAndSigners: CommitteeAttestationsAndSigners;
|
|
704
|
-
if (this.config.fishermanMode) {
|
|
705
|
-
this.log.debug('Skipping attestation collection');
|
|
706
|
-
attestationsAndSigners = CommitteeAttestationsAndSigners.empty();
|
|
707
|
-
} else {
|
|
708
|
-
this.log.debug('Collecting attestations');
|
|
709
|
-
attestationsAndSigners = await this.collectAttestations(block, usedTxs, proposerAddress);
|
|
710
|
-
this.log.verbose(
|
|
711
|
-
`Collected ${attestationsAndSigners.attestations.length} attestations for block ${blockNumber} at slot ${slot}`,
|
|
712
|
-
{ blockHash, blockNumber, slot },
|
|
713
|
-
);
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
// In fisherman mode, skip attestation signing
|
|
717
|
-
const attestationsAndSignersSignature =
|
|
718
|
-
this.config.fishermanMode || !this.validatorClient
|
|
719
|
-
? Signature.empty()
|
|
720
|
-
: await this.validatorClient.signAttestationsAndSigners(
|
|
721
|
-
attestationsAndSigners,
|
|
722
|
-
proposerAddress ?? publisher.getSenderAddress(),
|
|
723
|
-
);
|
|
724
|
-
|
|
725
|
-
await this.enqueuePublishL2Block(
|
|
726
|
-
block,
|
|
727
|
-
attestationsAndSigners,
|
|
728
|
-
attestationsAndSignersSignature,
|
|
729
|
-
invalidateBlock,
|
|
730
|
-
publisher,
|
|
731
|
-
);
|
|
732
|
-
this.metrics.recordBuiltBlock(blockBuildDuration, publicGas.l2Gas);
|
|
733
|
-
return block;
|
|
734
|
-
} catch (err) {
|
|
735
|
-
this.metrics.recordFailedBlock();
|
|
736
|
-
throw err;
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
@trackSpan('Sequencer.collectAttestations', (block, txHashes) => ({
|
|
741
|
-
[Attributes.BLOCK_NUMBER]: block.number,
|
|
742
|
-
[Attributes.BLOCK_ARCHIVE]: block.archive.toString(),
|
|
743
|
-
[Attributes.BLOCK_TXS_COUNT]: txHashes.length,
|
|
744
|
-
}))
|
|
745
|
-
protected async collectAttestations(
|
|
746
|
-
block: L2Block,
|
|
747
|
-
txs: Tx[],
|
|
748
|
-
proposerAddress: EthAddress | undefined,
|
|
749
|
-
): Promise<CommitteeAttestationsAndSigners> {
|
|
750
|
-
const { committee, seed, epoch } = await this.epochCache.getCommittee(block.slot);
|
|
751
|
-
|
|
752
|
-
// We checked above that the committee is defined, so this should never happen.
|
|
753
|
-
if (!committee) {
|
|
754
|
-
throw new Error('No committee when collecting attestations');
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
if (committee.length === 0) {
|
|
758
|
-
this.log.verbose(`Attesting committee is empty`);
|
|
759
|
-
return CommitteeAttestationsAndSigners.empty();
|
|
760
|
-
} else {
|
|
761
|
-
this.log.debug(`Attesting committee length is ${committee.length}`);
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
if (!this.validatorClient) {
|
|
765
|
-
throw new Error('Missing validator client: Cannot collect attestations');
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
const numberOfRequiredAttestations = Math.floor((committee.length * 2) / 3) + 1;
|
|
769
|
-
|
|
770
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
771
|
-
this.setState(SequencerState.COLLECTING_ATTESTATIONS, slotNumber);
|
|
772
|
-
|
|
773
|
-
this.log.debug('Creating block proposal for validators');
|
|
774
|
-
const blockProposalOptions: BlockProposalOptions = {
|
|
775
|
-
publishFullTxs: !!this.config.publishTxsWithProposals,
|
|
776
|
-
broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal,
|
|
777
|
-
};
|
|
778
|
-
const proposal = await this.validatorClient.createBlockProposal(
|
|
779
|
-
block.header.globalVariables.blockNumber,
|
|
780
|
-
block.getCheckpointHeader(),
|
|
781
|
-
block.archive.root,
|
|
782
|
-
txs,
|
|
783
|
-
proposerAddress,
|
|
784
|
-
blockProposalOptions,
|
|
785
|
-
);
|
|
786
|
-
|
|
787
|
-
if (!proposal) {
|
|
788
|
-
throw new Error(`Failed to create block proposal`);
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
if (this.config.skipCollectingAttestations) {
|
|
792
|
-
this.log.warn('Skipping attestation collection as per config (attesting with own keys only)');
|
|
793
|
-
const attestations = await this.validatorClient?.collectOwnAttestations(proposal);
|
|
794
|
-
return new CommitteeAttestationsAndSigners(orderAttestations(attestations ?? [], committee));
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
this.log.debug('Broadcasting block proposal to validators');
|
|
798
|
-
await this.validatorClient.broadcastBlockProposal(proposal);
|
|
799
|
-
|
|
800
|
-
const attestationTimeAllowed = this.enforceTimeTable
|
|
801
|
-
? this.timetable.getMaxAllowedTime(SequencerState.PUBLISHING_BLOCK)!
|
|
802
|
-
: this.aztecSlotDuration;
|
|
803
|
-
|
|
804
|
-
this.metrics.recordRequiredAttestations(numberOfRequiredAttestations, attestationTimeAllowed);
|
|
805
|
-
|
|
806
|
-
const timer = new Timer();
|
|
807
|
-
let collectedAttestationsCount: number = 0;
|
|
808
|
-
try {
|
|
809
|
-
const attestationDeadline = new Date(this.dateProvider.now() + attestationTimeAllowed * 1000);
|
|
810
|
-
const attestations = await this.validatorClient.collectAttestations(
|
|
811
|
-
proposal,
|
|
812
|
-
numberOfRequiredAttestations,
|
|
813
|
-
attestationDeadline,
|
|
814
|
-
);
|
|
815
|
-
|
|
816
|
-
collectedAttestationsCount = attestations.length;
|
|
817
|
-
|
|
818
|
-
// note: the smart contract requires that the signatures are provided in the order of the committee
|
|
819
|
-
const sorted = orderAttestations(attestations, committee);
|
|
820
|
-
|
|
821
|
-
// manipulate the attestations if we've been configured to do so
|
|
822
|
-
if (this.config.injectFakeAttestation || this.config.shuffleAttestationOrdering) {
|
|
823
|
-
return this.manipulateAttestations(block, epoch, seed, committee, sorted);
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
return new CommitteeAttestationsAndSigners(sorted);
|
|
827
|
-
} catch (err) {
|
|
828
|
-
if (err && err instanceof AttestationTimeoutError) {
|
|
829
|
-
collectedAttestationsCount = err.collectedCount;
|
|
830
|
-
}
|
|
831
|
-
throw err;
|
|
832
|
-
} finally {
|
|
833
|
-
this.metrics.recordCollectedAttestations(collectedAttestationsCount, timer.ms());
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
/** Breaks the attestations before publishing based on attack configs */
|
|
838
|
-
private manipulateAttestations(
|
|
839
|
-
block: L2Block,
|
|
840
|
-
epoch: EpochNumber,
|
|
841
|
-
seed: bigint,
|
|
842
|
-
committee: EthAddress[],
|
|
843
|
-
attestations: CommitteeAttestation[],
|
|
844
|
-
) {
|
|
845
|
-
// Compute the proposer index in the committee, since we dont want to tweak it.
|
|
846
|
-
// Otherwise, the L1 rollup contract will reject the block outright.
|
|
847
|
-
const proposerIndex = Number(
|
|
848
|
-
this.epochCache.computeProposerIndex(block.slot, epoch, seed, BigInt(committee.length)),
|
|
849
|
-
);
|
|
850
|
-
|
|
851
|
-
if (this.config.injectFakeAttestation) {
|
|
852
|
-
// Find non-empty attestations that are not from the proposer
|
|
853
|
-
const nonProposerIndices: number[] = [];
|
|
854
|
-
for (let i = 0; i < attestations.length; i++) {
|
|
855
|
-
if (!attestations[i].signature.isEmpty() && i !== proposerIndex) {
|
|
856
|
-
nonProposerIndices.push(i);
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
if (nonProposerIndices.length > 0) {
|
|
860
|
-
const targetIndex = nonProposerIndices[randomInt(nonProposerIndices.length)];
|
|
861
|
-
this.log.warn(`Injecting fake attestation in block ${block.number} at index ${targetIndex}`);
|
|
862
|
-
unfreeze(attestations[targetIndex]).signature = Signature.random();
|
|
863
|
-
}
|
|
864
|
-
return new CommitteeAttestationsAndSigners(attestations);
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
if (this.config.shuffleAttestationOrdering) {
|
|
868
|
-
this.log.warn(`Shuffling attestation ordering in block ${block.number} (proposer index ${proposerIndex})`);
|
|
869
|
-
|
|
870
|
-
const shuffled = [...attestations];
|
|
871
|
-
const [i, j] = [(proposerIndex + 1) % shuffled.length, (proposerIndex + 2) % shuffled.length];
|
|
872
|
-
const valueI = shuffled[i];
|
|
873
|
-
const valueJ = shuffled[j];
|
|
874
|
-
shuffled[i] = valueJ;
|
|
875
|
-
shuffled[j] = valueI;
|
|
876
|
-
|
|
877
|
-
const signers = new CommitteeAttestationsAndSigners(attestations).getSigners();
|
|
878
|
-
return new MaliciousCommitteeAttestationsAndSigners(shuffled, signers);
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
return new CommitteeAttestationsAndSigners(attestations);
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
/**
|
|
885
|
-
* Publishes the L2Block to the rollup contract.
|
|
886
|
-
* @param block - The L2Block to be published.
|
|
887
|
-
*/
|
|
888
|
-
@trackSpan('Sequencer.enqueuePublishL2Block', block => ({
|
|
889
|
-
[Attributes.BLOCK_NUMBER]: block.number,
|
|
890
|
-
}))
|
|
891
|
-
protected async enqueuePublishL2Block(
|
|
892
|
-
block: L2Block,
|
|
893
|
-
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
894
|
-
attestationsAndSignersSignature: Signature,
|
|
895
|
-
invalidateBlock: InvalidateBlockRequest | undefined,
|
|
896
|
-
publisher: SequencerPublisher,
|
|
897
|
-
): Promise<void> {
|
|
898
|
-
// Publishes new block to the network and awaits the tx to be mined
|
|
899
|
-
this.setState(SequencerState.PUBLISHING_BLOCK, block.header.globalVariables.slotNumber);
|
|
900
|
-
|
|
901
|
-
// Time out tx at the end of the slot
|
|
902
|
-
const slot = block.header.globalVariables.slotNumber;
|
|
903
|
-
const txTimeoutAt = new Date((this.getSlotStartBuildTimestamp(slot) + this.aztecSlotDuration) * 1000);
|
|
904
|
-
|
|
905
|
-
const enqueued = await publisher.enqueueProposeL2Block(
|
|
906
|
-
block,
|
|
907
|
-
attestationsAndSigners,
|
|
908
|
-
attestationsAndSignersSignature,
|
|
909
|
-
{
|
|
910
|
-
txTimeoutAt,
|
|
911
|
-
forcePendingBlockNumber: invalidateBlock?.forcePendingBlockNumber,
|
|
912
|
-
},
|
|
913
|
-
);
|
|
914
|
-
|
|
915
|
-
if (!enqueued) {
|
|
916
|
-
throw new Error(`Failed to enqueue publish of block ${block.number}`);
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
|
|
920
473
|
/**
|
|
921
474
|
* Returns whether all dependencies have caught up.
|
|
922
475
|
* We don't check against the previous block submitted since it may have been reorg'd out.
|
|
923
476
|
*/
|
|
924
|
-
protected async checkSync(args: { ts: bigint; slot: SlotNumber }): Promise<
|
|
925
|
-
| {
|
|
926
|
-
block?: L2Block;
|
|
927
|
-
blockNumber: BlockNumber;
|
|
928
|
-
archive: Fr;
|
|
929
|
-
l1Timestamp: bigint;
|
|
930
|
-
pendingChainValidationStatus: ValidateBlockResult;
|
|
931
|
-
}
|
|
932
|
-
| undefined
|
|
933
|
-
> {
|
|
477
|
+
protected async checkSync(args: { ts: bigint; slot: SlotNumber }): Promise<SequencerSyncCheckResult | undefined> {
|
|
934
478
|
// Check that the archiver and dependencies have synced to the previous L1 slot at least
|
|
935
479
|
// TODO(#14766): Archiver reports L1 timestamp based on L1 blocks seen, which means that a missed L1 block will
|
|
936
480
|
// cause the archiver L1 timestamp to fall behind, and cause this sequencer to start processing one L1 slot later.
|
|
@@ -950,9 +494,9 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
950
494
|
number: syncSummary.latestBlockNumber,
|
|
951
495
|
hash: syncSummary.latestBlockHash,
|
|
952
496
|
})),
|
|
953
|
-
this.l2BlockSource.getL2Tips().then(t => t.
|
|
497
|
+
this.l2BlockSource.getL2Tips().then(t => t.proposed),
|
|
954
498
|
this.p2pClient.getStatus().then(p2p => p2p.syncedToL2Block),
|
|
955
|
-
this.l1ToL2MessageSource.getL2Tips().then(t => t.
|
|
499
|
+
this.l1ToL2MessageSource.getL2Tips().then(t => t.proposed),
|
|
956
500
|
this.l2BlockSource.getPendingChainValidationStatus(),
|
|
957
501
|
] as const);
|
|
958
502
|
|
|
@@ -960,6 +504,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
960
504
|
|
|
961
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,
|
|
962
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.
|
|
963
508
|
const result =
|
|
964
509
|
(l2BlockSource.number === 0 && worldState.number === 0 && p2p.number === 0 && l1ToL2MessageSource.number === 0) ||
|
|
965
510
|
(worldState.hash === l2BlockSource.hash &&
|
|
@@ -975,10 +520,16 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
975
520
|
const blockNumber = worldState.number;
|
|
976
521
|
if (blockNumber < INITIAL_L2_BLOCK_NUM) {
|
|
977
522
|
const archive = new Fr((await this.worldState.getCommitted().getTreeInfo(MerkleTreeId.ARCHIVE)).root);
|
|
978
|
-
return {
|
|
523
|
+
return {
|
|
524
|
+
checkpointNumber: CheckpointNumber.ZERO,
|
|
525
|
+
blockNumber: BlockNumber.ZERO,
|
|
526
|
+
archive,
|
|
527
|
+
l1Timestamp,
|
|
528
|
+
pendingChainValidationStatus,
|
|
529
|
+
};
|
|
979
530
|
}
|
|
980
531
|
|
|
981
|
-
const block = await this.l2BlockSource.
|
|
532
|
+
const block = await this.l2BlockSource.getL2Block(blockNumber);
|
|
982
533
|
if (!block) {
|
|
983
534
|
// this shouldn't really happen because a moment ago we checked that all components were in sync
|
|
984
535
|
this.log.error(`Failed to get L2 block ${blockNumber} from the archiver with all components in sync`);
|
|
@@ -988,69 +539,13 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
988
539
|
return {
|
|
989
540
|
block,
|
|
990
541
|
blockNumber: block.number,
|
|
542
|
+
checkpointNumber: block.checkpointNumber,
|
|
991
543
|
archive: block.archive.root,
|
|
992
544
|
l1Timestamp,
|
|
993
545
|
pendingChainValidationStatus,
|
|
994
546
|
};
|
|
995
547
|
}
|
|
996
548
|
|
|
997
|
-
/**
|
|
998
|
-
* Enqueues governance and slashing votes with the publisher. Does not block.
|
|
999
|
-
* @param publisher - The publisher to enqueue votes with
|
|
1000
|
-
* @param attestorAddress - The attestor address to use for signing
|
|
1001
|
-
* @param slot - The slot number
|
|
1002
|
-
* @param timestamp - The timestamp for the votes
|
|
1003
|
-
* @param context - Optional context for logging (e.g., block number)
|
|
1004
|
-
* @returns A tuple of [governanceEnqueued, slashingEnqueued]
|
|
1005
|
-
*/
|
|
1006
|
-
protected enqueueGovernanceAndSlashingVotes(
|
|
1007
|
-
publisher: SequencerPublisher,
|
|
1008
|
-
attestorAddress: EthAddress,
|
|
1009
|
-
slot: SlotNumber,
|
|
1010
|
-
timestamp: bigint,
|
|
1011
|
-
): [Promise<boolean> | undefined, Promise<boolean> | undefined] {
|
|
1012
|
-
try {
|
|
1013
|
-
const signerFn = (msg: TypedDataDefinition) =>
|
|
1014
|
-
this.validatorClient!.signWithAddress(attestorAddress, msg).then(s => s.toString());
|
|
1015
|
-
|
|
1016
|
-
const enqueueGovernancePromise =
|
|
1017
|
-
this.governanceProposerPayload && !this.governanceProposerPayload.isZero()
|
|
1018
|
-
? publisher
|
|
1019
|
-
.enqueueGovernanceCastSignal(this.governanceProposerPayload, slot, timestamp, attestorAddress, signerFn)
|
|
1020
|
-
.catch(err => {
|
|
1021
|
-
this.log.error(`Error enqueuing governance vote`, err, { slot });
|
|
1022
|
-
return false;
|
|
1023
|
-
})
|
|
1024
|
-
: undefined;
|
|
1025
|
-
|
|
1026
|
-
const enqueueSlashingPromise = this.slasherClient
|
|
1027
|
-
? this.slasherClient
|
|
1028
|
-
.getProposerActions(slot)
|
|
1029
|
-
.then(actions => {
|
|
1030
|
-
// Record metrics for fisherman mode
|
|
1031
|
-
if (this.config.fishermanMode && actions.length > 0) {
|
|
1032
|
-
this.log.debug(`Fisherman mode: simulating ${actions.length} slashing action(s) for slot ${slot}`, {
|
|
1033
|
-
slot,
|
|
1034
|
-
actionCount: actions.length,
|
|
1035
|
-
});
|
|
1036
|
-
this.metrics.recordSlashingAttempt(actions.length);
|
|
1037
|
-
}
|
|
1038
|
-
// Enqueue the actions to fully simulate L1 tx building (they won't be sent in fisherman mode)
|
|
1039
|
-
return publisher.enqueueSlashingActions(actions, slot, timestamp, attestorAddress, signerFn);
|
|
1040
|
-
})
|
|
1041
|
-
.catch(err => {
|
|
1042
|
-
this.log.error(`Error enqueuing slashing actions`, err, { slot });
|
|
1043
|
-
return false;
|
|
1044
|
-
})
|
|
1045
|
-
: undefined;
|
|
1046
|
-
|
|
1047
|
-
return [enqueueGovernancePromise, enqueueSlashingPromise];
|
|
1048
|
-
} catch (err) {
|
|
1049
|
-
this.log.error(`Error enqueueing governance and slashing votes`, err);
|
|
1050
|
-
return [undefined, undefined];
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
549
|
/**
|
|
1055
550
|
* Checks if we are the proposer for the next slot.
|
|
1056
551
|
* @returns True if we can propose, and the proposer address (undefined if anyone can propose)
|
|
@@ -1078,7 +573,7 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1078
573
|
return [true, proposer];
|
|
1079
574
|
}
|
|
1080
575
|
|
|
1081
|
-
const validatorAddresses = this.validatorClient
|
|
576
|
+
const validatorAddresses = this.validatorClient.getValidatorAddresses();
|
|
1082
577
|
const weAreProposer = validatorAddresses.some(addr => addr.equals(proposer));
|
|
1083
578
|
|
|
1084
579
|
if (!weAreProposer) {
|
|
@@ -1093,30 +588,31 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1093
588
|
* Tries to vote on slashing actions and governance when the sync check fails but we're past the max time for initializing a proposal.
|
|
1094
589
|
* This allows the sequencer to participate in governance/slashing votes even when it cannot build blocks.
|
|
1095
590
|
*/
|
|
591
|
+
@trackSpan('Seqeuencer.tryVoteWhenSyncFails', ({ slot }) => ({ [Attributes.SLOT_NUMBER]: slot }))
|
|
1096
592
|
protected async tryVoteWhenSyncFails(args: { slot: SlotNumber; ts: bigint }): Promise<void> {
|
|
1097
|
-
const { slot
|
|
593
|
+
const { slot } = args;
|
|
1098
594
|
|
|
1099
595
|
// Prevent duplicate attempts in the same slot
|
|
1100
|
-
if (this.
|
|
1101
|
-
this.log.
|
|
596
|
+
if (this.lastSlotForFallbackVote === slot) {
|
|
597
|
+
this.log.trace(`Already attempted to vote in slot ${slot} (skipping)`);
|
|
1102
598
|
return;
|
|
1103
599
|
}
|
|
1104
600
|
|
|
1105
601
|
// Check if we're past the max time for initializing a proposal
|
|
1106
602
|
const secondsIntoSlot = this.getSecondsIntoSlot(slot);
|
|
1107
|
-
const maxAllowedTime = this.timetable.getMaxAllowedTime(SequencerState.
|
|
603
|
+
const maxAllowedTime = this.timetable.getMaxAllowedTime(SequencerState.INITIALIZING_CHECKPOINT);
|
|
1108
604
|
|
|
1109
605
|
// If we haven't exceeded the time limit for initializing a proposal, don't proceed with voting
|
|
1110
606
|
// We use INITIALIZING_PROPOSAL time limit because if we're past that, we can't build a block anyway
|
|
1111
607
|
if (maxAllowedTime === undefined || secondsIntoSlot <= maxAllowedTime) {
|
|
1112
|
-
this.log.trace(`Not attempting to vote since there is still for block building`, {
|
|
608
|
+
this.log.trace(`Not attempting to vote since there is still time for block building`, {
|
|
1113
609
|
secondsIntoSlot,
|
|
1114
610
|
maxAllowedTime,
|
|
1115
611
|
});
|
|
1116
612
|
return;
|
|
1117
613
|
}
|
|
1118
614
|
|
|
1119
|
-
this.log.
|
|
615
|
+
this.log.trace(`Sync for slot ${slot} failed, checking for voting opportunities`, {
|
|
1120
616
|
secondsIntoSlot,
|
|
1121
617
|
maxAllowedTime,
|
|
1122
618
|
});
|
|
@@ -1124,12 +620,12 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1124
620
|
// Check if we're a proposer or proposal is open
|
|
1125
621
|
const [canPropose, proposer] = await this.checkCanPropose(slot);
|
|
1126
622
|
if (!canPropose) {
|
|
1127
|
-
this.log.
|
|
623
|
+
this.log.trace(`Cannot vote in slot ${slot} since we are not a proposer`, { slot, proposer });
|
|
1128
624
|
return;
|
|
1129
625
|
}
|
|
1130
626
|
|
|
1131
627
|
// Mark this slot as attempted
|
|
1132
|
-
this.
|
|
628
|
+
this.lastSlotForFallbackVote = slot;
|
|
1133
629
|
|
|
1134
630
|
// Get a publisher for voting
|
|
1135
631
|
const { attestorAddress, publisher } = await this.publisherFactory.create(proposer);
|
|
@@ -1139,11 +635,22 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1139
635
|
slot,
|
|
1140
636
|
});
|
|
1141
637
|
|
|
1142
|
-
// Enqueue governance and slashing votes
|
|
1143
|
-
const
|
|
1144
|
-
|
|
638
|
+
// Enqueue governance and slashing votes
|
|
639
|
+
const voter = new CheckpointVoter(
|
|
640
|
+
slot,
|
|
641
|
+
publisher,
|
|
642
|
+
attestorAddress,
|
|
643
|
+
this.validatorClient,
|
|
644
|
+
this.slasherClient,
|
|
645
|
+
this.l1Constants,
|
|
646
|
+
this.config,
|
|
647
|
+
this.metrics,
|
|
648
|
+
this.log,
|
|
649
|
+
);
|
|
650
|
+
const votesPromises = voter.enqueueVotes();
|
|
651
|
+
const votes = await Promise.all(votesPromises);
|
|
1145
652
|
|
|
1146
|
-
if (
|
|
653
|
+
if (votes.every(p => !p)) {
|
|
1147
654
|
this.log.debug(`No votes to enqueue for slot ${slot}`);
|
|
1148
655
|
return;
|
|
1149
656
|
}
|
|
@@ -1152,14 +659,62 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1152
659
|
await publisher.sendRequests();
|
|
1153
660
|
}
|
|
1154
661
|
|
|
662
|
+
/**
|
|
663
|
+
* Tries to vote on slashing actions and governance proposals when escape hatch is open.
|
|
664
|
+
* This allows the sequencer to participate in voting without performing checkpoint proposal work.
|
|
665
|
+
*/
|
|
666
|
+
@trackSpan('Sequencer.tryVoteWhenEscapeHatchOpen', ({ slot }) => ({ [Attributes.SLOT_NUMBER]: slot }))
|
|
667
|
+
protected async tryVoteWhenEscapeHatchOpen(args: {
|
|
668
|
+
slot: SlotNumber;
|
|
669
|
+
proposer: EthAddress | undefined;
|
|
670
|
+
}): Promise<void> {
|
|
671
|
+
const { slot, proposer } = args;
|
|
672
|
+
|
|
673
|
+
// Prevent duplicate attempts in the same slot
|
|
674
|
+
if (this.lastSlotForFallbackVote === slot) {
|
|
675
|
+
this.log.trace(`Already attempted to vote in slot ${slot} (escape hatch open, skipping)`);
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Mark this slot as attempted
|
|
680
|
+
this.lastSlotForFallbackVote = slot;
|
|
681
|
+
|
|
682
|
+
const { attestorAddress, publisher } = await this.publisherFactory.create(proposer);
|
|
683
|
+
|
|
684
|
+
this.log.debug(`Escape hatch open for slot ${slot}, attempting vote-only actions`, { slot, attestorAddress });
|
|
685
|
+
|
|
686
|
+
const voter = new CheckpointVoter(
|
|
687
|
+
slot,
|
|
688
|
+
publisher,
|
|
689
|
+
attestorAddress,
|
|
690
|
+
this.validatorClient,
|
|
691
|
+
this.slasherClient,
|
|
692
|
+
this.l1Constants,
|
|
693
|
+
this.config,
|
|
694
|
+
this.metrics,
|
|
695
|
+
this.log,
|
|
696
|
+
);
|
|
697
|
+
|
|
698
|
+
const votesPromises = voter.enqueueVotes();
|
|
699
|
+
const votes = await Promise.all(votesPromises);
|
|
700
|
+
|
|
701
|
+
if (votes.every(p => !p)) {
|
|
702
|
+
this.log.debug(`No votes to enqueue for slot ${slot} (escape hatch open)`);
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
this.log.info(`Voting in slot ${slot} (escape hatch open)`, { slot });
|
|
707
|
+
await publisher.sendRequests();
|
|
708
|
+
}
|
|
709
|
+
|
|
1155
710
|
/**
|
|
1156
711
|
* Considers invalidating a block if the pending chain is invalid. Depends on how long the invalid block
|
|
1157
712
|
* has been there without being invalidated and whether the sequencer is in the committee or not. We always
|
|
1158
713
|
* have the proposer try to invalidate, but if they fail, the sequencers in the committee are expected to try,
|
|
1159
714
|
* and if they fail, any sequencer will try as well.
|
|
1160
715
|
*/
|
|
1161
|
-
protected async
|
|
1162
|
-
syncedTo:
|
|
716
|
+
protected async considerInvalidatingCheckpoint(
|
|
717
|
+
syncedTo: SequencerSyncCheckResult,
|
|
1163
718
|
currentSlot: SlotNumber,
|
|
1164
719
|
): Promise<void> {
|
|
1165
720
|
const { pendingChainValidationStatus, l1Timestamp } = syncedTo;
|
|
@@ -1167,19 +722,18 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1167
722
|
return;
|
|
1168
723
|
}
|
|
1169
724
|
|
|
1170
|
-
const
|
|
1171
|
-
const
|
|
1172
|
-
const
|
|
1173
|
-
const
|
|
1174
|
-
const ourValidatorAddresses = this.validatorClient!.getValidatorAddresses();
|
|
725
|
+
const invalidCheckpointNumber = pendingChainValidationStatus.checkpoint.checkpointNumber;
|
|
726
|
+
const invalidCheckpointTimestamp = pendingChainValidationStatus.checkpoint.timestamp;
|
|
727
|
+
const timeSinceChainInvalid = this.dateProvider.nowInSeconds() - Number(invalidCheckpointTimestamp);
|
|
728
|
+
const ourValidatorAddresses = this.validatorClient.getValidatorAddresses();
|
|
1175
729
|
|
|
1176
730
|
const { secondsBeforeInvalidatingBlockAsCommitteeMember, secondsBeforeInvalidatingBlockAsNonCommitteeMember } =
|
|
1177
731
|
this.config;
|
|
1178
732
|
|
|
1179
733
|
const logData = {
|
|
1180
|
-
invalidL1Timestamp:
|
|
734
|
+
invalidL1Timestamp: invalidCheckpointTimestamp,
|
|
1181
735
|
l1Timestamp,
|
|
1182
|
-
|
|
736
|
+
invalidCheckpoint: pendingChainValidationStatus.checkpoint,
|
|
1183
737
|
secondsBeforeInvalidatingBlockAsCommitteeMember,
|
|
1184
738
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember,
|
|
1185
739
|
ourValidatorAddresses,
|
|
@@ -1207,29 +761,76 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1207
761
|
return;
|
|
1208
762
|
}
|
|
1209
763
|
|
|
1210
|
-
|
|
1211
|
-
if (
|
|
1212
|
-
|
|
764
|
+
let validatorToUse: EthAddress;
|
|
765
|
+
if (invalidateAsCommitteeMember) {
|
|
766
|
+
// When invalidating as a committee member, use first validator that's actually in the committee
|
|
767
|
+
const { committee } = await this.epochCache.getCommittee(currentSlot);
|
|
768
|
+
if (committee) {
|
|
769
|
+
const committeeSet = new Set(committee.map(addr => addr.toString()));
|
|
770
|
+
validatorToUse =
|
|
771
|
+
ourValidatorAddresses.find(addr => committeeSet.has(addr.toString())) ?? ourValidatorAddresses[0];
|
|
772
|
+
} else {
|
|
773
|
+
validatorToUse = ourValidatorAddresses[0];
|
|
774
|
+
}
|
|
775
|
+
} else {
|
|
776
|
+
// When invalidating as a non-committee member, use the first validator
|
|
777
|
+
validatorToUse = ourValidatorAddresses[0];
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
const { publisher } = await this.publisherFactory.create(validatorToUse);
|
|
781
|
+
|
|
782
|
+
const invalidateCheckpoint = await publisher.simulateInvalidateCheckpoint(pendingChainValidationStatus);
|
|
783
|
+
if (!invalidateCheckpoint) {
|
|
784
|
+
this.log.warn(`Failed to simulate invalidate checkpoint`, logData);
|
|
1213
785
|
return;
|
|
1214
786
|
}
|
|
1215
787
|
|
|
1216
788
|
this.log.info(
|
|
1217
789
|
invalidateAsCommitteeMember
|
|
1218
|
-
? `Invalidating
|
|
1219
|
-
: `Invalidating
|
|
790
|
+
? `Invalidating checkpoint ${invalidCheckpointNumber} as committee member`
|
|
791
|
+
: `Invalidating checkpoint ${invalidCheckpointNumber} as non-committee member`,
|
|
1220
792
|
logData,
|
|
1221
793
|
);
|
|
1222
794
|
|
|
1223
|
-
publisher.
|
|
795
|
+
publisher.enqueueInvalidateCheckpoint(invalidateCheckpoint);
|
|
1224
796
|
|
|
1225
797
|
if (!this.config.fishermanMode) {
|
|
1226
798
|
await publisher.sendRequests();
|
|
1227
799
|
} else {
|
|
1228
|
-
this.log.info('Invalidating
|
|
800
|
+
this.log.info('Invalidating checkpoint in fisherman mode, clearing pending requests');
|
|
1229
801
|
publisher.clearPendingRequests();
|
|
1230
802
|
}
|
|
1231
803
|
}
|
|
1232
804
|
|
|
805
|
+
private logStrategyComparison(epoch: EpochNumber, publisher: SequencerPublisher): void {
|
|
806
|
+
const feeAnalyzer = publisher.getL1FeeAnalyzer();
|
|
807
|
+
if (!feeAnalyzer) {
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
const comparison = feeAnalyzer.getStrategyComparison();
|
|
812
|
+
if (comparison.length === 0) {
|
|
813
|
+
this.log.debug(`No strategy data available yet for epoch ${epoch}`);
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
this.log.info(`L1 Fee Strategy Performance Report - End of Epoch ${epoch}`, {
|
|
818
|
+
epoch: Number(epoch),
|
|
819
|
+
totalAnalyses: comparison[0]?.totalAnalyses,
|
|
820
|
+
strategies: comparison.map(s => ({
|
|
821
|
+
id: s.strategyId,
|
|
822
|
+
name: s.strategyName,
|
|
823
|
+
inclusionRate: `${(s.inclusionRate * 100).toFixed(1)}%`,
|
|
824
|
+
inclusionCount: `${s.inclusionCount}/${s.totalAnalyses}`,
|
|
825
|
+
avgCostEth: s.avgEstimatedCostEth.toFixed(6),
|
|
826
|
+
totalCostEth: s.totalEstimatedCostEth.toFixed(6),
|
|
827
|
+
avgOverpaymentEth: s.avgOverpaymentEth.toFixed(6),
|
|
828
|
+
totalOverpaymentEth: s.totalOverpaymentEth.toFixed(6),
|
|
829
|
+
avgPriorityFeeDeltaGwei: s.avgPriorityFeeDeltaGwei.toFixed(2),
|
|
830
|
+
})),
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
|
|
1233
834
|
private getSlotStartBuildTimestamp(slotNumber: SlotNumber): number {
|
|
1234
835
|
return getSlotStartBuildTimestamp(slotNumber, this.l1Constants);
|
|
1235
836
|
}
|
|
@@ -1239,15 +840,40 @@ export class Sequencer extends (EventEmitter as new () => TypedEventEmitter<Sequ
|
|
|
1239
840
|
return Number((this.dateProvider.now() / 1000 - slotStartTimestamp).toFixed(3));
|
|
1240
841
|
}
|
|
1241
842
|
|
|
1242
|
-
get aztecSlotDuration() {
|
|
843
|
+
public get aztecSlotDuration() {
|
|
1243
844
|
return this.l1Constants.slotDuration;
|
|
1244
845
|
}
|
|
1245
846
|
|
|
1246
|
-
get maxL2BlockGas(): number | undefined {
|
|
847
|
+
public get maxL2BlockGas(): number | undefined {
|
|
1247
848
|
return this.config.maxL2BlockGas;
|
|
1248
849
|
}
|
|
1249
850
|
|
|
1250
851
|
public getSlasherClient(): SlasherClientInterface | undefined {
|
|
1251
852
|
return this.slasherClient;
|
|
1252
853
|
}
|
|
854
|
+
|
|
855
|
+
public get tracer(): Tracer {
|
|
856
|
+
return this.metrics.tracer;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
public getValidatorAddresses() {
|
|
860
|
+
return this.validatorClient?.getValidatorAddresses();
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
public getConfig() {
|
|
864
|
+
return this.config;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
private get l1PublishingTime(): number {
|
|
868
|
+
return this.config.l1PublishingTime ?? this.l1Constants.ethereumSlotDuration;
|
|
869
|
+
}
|
|
1253
870
|
}
|
|
871
|
+
|
|
872
|
+
type SequencerSyncCheckResult = {
|
|
873
|
+
block?: L2Block;
|
|
874
|
+
checkpointNumber: CheckpointNumber;
|
|
875
|
+
blockNumber: BlockNumber;
|
|
876
|
+
archive: Fr;
|
|
877
|
+
l1Timestamp: bigint;
|
|
878
|
+
pendingChainValidationStatus: ValidateCheckpointResult;
|
|
879
|
+
};
|