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