@aztec/sequencer-client 0.0.0-test.1 → 0.0.1-commit.03f7ef2
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 +30 -29
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +82 -60
- package/dest/config.d.ts +15 -16
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +113 -70
- package/dest/global_variable_builder/global_builder.d.ts +25 -14
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +60 -42
- 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 +15 -12
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +32 -19
- package/dest/publisher/index.d.ts +3 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +3 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +44 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -0
- package/dest/publisher/sequencer-publisher-factory.js +51 -0
- package/dest/publisher/sequencer-publisher-metrics.d.ts +5 -4
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +37 -2
- package/dest/publisher/sequencer-publisher.d.ts +132 -86
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +755 -248
- package/dest/sequencer/block_builder.d.ts +26 -0
- package/dest/sequencer/block_builder.d.ts.map +1 -0
- package/dest/sequencer/block_builder.js +129 -0
- package/dest/sequencer/checkpoint_builder.d.ts +63 -0
- package/dest/sequencer/checkpoint_builder.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_builder.js +131 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +74 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +640 -0
- package/dest/sequencer/checkpoint_voter.d.ts +34 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +85 -0
- package/dest/sequencer/config.d.ts +7 -1
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/errors.d.ts +11 -0
- package/dest/sequencer/errors.d.ts.map +1 -0
- package/dest/sequencer/errors.js +15 -0
- 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 +6 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +5 -1
- package/dest/sequencer/metrics.d.ts +48 -12
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +274 -48
- package/dest/sequencer/sequencer.d.ts +132 -135
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +519 -521
- package/dest/sequencer/timetable.d.ts +76 -24
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +177 -61
- 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 +20 -38
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +12 -47
- package/dest/test/index.d.ts +10 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -4
- package/dest/test/mock_checkpoint_builder.d.ts +83 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +179 -0
- package/dest/test/utils.d.ts +49 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +94 -0
- package/dest/tx_validator/nullifier_cache.d.ts +1 -3
- package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.d.ts +11 -11
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +28 -25
- package/package.json +45 -45
- package/src/client/sequencer-client.ts +105 -105
- package/src/config.ts +126 -81
- package/src/global_variable_builder/global_builder.ts +82 -53
- package/src/index.ts +8 -2
- package/src/publisher/config.ts +45 -32
- package/src/publisher/index.ts +4 -0
- package/src/publisher/sequencer-publisher-factory.ts +92 -0
- package/src/publisher/sequencer-publisher-metrics.ts +26 -4
- package/src/publisher/sequencer-publisher.ts +955 -293
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/block_builder.ts +217 -0
- package/src/sequencer/checkpoint_builder.ts +217 -0
- package/src/sequencer/checkpoint_proposal_job.ts +703 -0
- package/src/sequencer/checkpoint_voter.ts +105 -0
- package/src/sequencer/config.ts +8 -0
- package/src/sequencer/errors.ts +21 -0
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +5 -1
- package/src/sequencer/metrics.ts +355 -50
- package/src/sequencer/sequencer.ts +631 -594
- package/src/sequencer/timetable.ts +221 -62
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +28 -60
- package/src/test/index.ts +13 -4
- package/src/test/mock_checkpoint_builder.ts +247 -0
- package/src/test/utils.ts +137 -0
- package/src/tx_validator/tx_validator_factory.ts +46 -33
- package/dest/sequencer/allowed.d.ts +0 -3
- package/dest/sequencer/allowed.d.ts.map +0 -1
- package/dest/sequencer/allowed.js +0 -27
- package/dest/slasher/factory.d.ts +0 -7
- package/dest/slasher/factory.d.ts.map +0 -1
- package/dest/slasher/factory.js +0 -8
- package/dest/slasher/index.d.ts +0 -3
- package/dest/slasher/index.d.ts.map +0 -1
- package/dest/slasher/index.js +0 -2
- package/dest/slasher/slasher_client.d.ts +0 -75
- package/dest/slasher/slasher_client.d.ts.map +0 -1
- package/dest/slasher/slasher_client.js +0 -132
- package/dest/tx_validator/archive_cache.d.ts +0 -14
- package/dest/tx_validator/archive_cache.d.ts.map +0 -1
- package/dest/tx_validator/archive_cache.js +0 -22
- package/dest/tx_validator/gas_validator.d.ts +0 -14
- package/dest/tx_validator/gas_validator.d.ts.map +0 -1
- package/dest/tx_validator/gas_validator.js +0 -78
- package/dest/tx_validator/phases_validator.d.ts +0 -12
- package/dest/tx_validator/phases_validator.d.ts.map +0 -1
- package/dest/tx_validator/phases_validator.js +0 -80
- package/dest/tx_validator/test_utils.d.ts +0 -23
- package/dest/tx_validator/test_utils.d.ts.map +0 -1
- package/dest/tx_validator/test_utils.js +0 -26
- package/src/sequencer/allowed.ts +0 -36
- package/src/slasher/factory.ts +0 -15
- package/src/slasher/index.ts +0 -2
- package/src/slasher/slasher_client.ts +0 -193
- package/src/tx_validator/archive_cache.ts +0 -28
- package/src/tx_validator/gas_validator.ts +0 -101
- package/src/tx_validator/phases_validator.ts +0 -98
- package/src/tx_validator/test_utils.ts +0 -48
|
@@ -4,620 +4,618 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
4
4
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
}
|
|
7
|
+
import { getKzg } from '@aztec/blob-lib';
|
|
7
8
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
8
|
-
import {
|
|
9
|
+
import { NoCommitteeError } from '@aztec/ethereum/contracts';
|
|
10
|
+
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
11
|
+
import { merge, omit, pick } from '@aztec/foundation/collection';
|
|
12
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
13
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
10
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
11
14
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
15
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
13
|
-
import {
|
|
14
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
-
import { Gas } from '@aztec/stdlib/gas';
|
|
16
|
+
import { getSlotAtTimestamp, getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
16
17
|
import { SequencerConfigSchema } from '@aztec/stdlib/interfaces/server';
|
|
17
18
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
19
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
20
|
+
import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
21
|
+
import EventEmitter from 'node:events';
|
|
22
|
+
import { DefaultSequencerConfig } from '../config.js';
|
|
23
|
+
import { CheckpointProposalJob } from './checkpoint_proposal_job.js';
|
|
24
|
+
import { CheckpointVoter } from './checkpoint_voter.js';
|
|
25
|
+
import { SequencerInterruptedError, SequencerTooSlowError } from './errors.js';
|
|
24
26
|
import { SequencerMetrics } from './metrics.js';
|
|
25
|
-
import { SequencerTimetable
|
|
26
|
-
import { SequencerState
|
|
27
|
+
import { SequencerTimetable } from './timetable.js';
|
|
28
|
+
import { SequencerState } from './utils.js';
|
|
27
29
|
export { SequencerState };
|
|
28
30
|
/**
|
|
29
31
|
* Sequencer client
|
|
30
|
-
* -
|
|
31
|
-
* -
|
|
32
|
-
* -
|
|
33
|
-
* -
|
|
34
|
-
* -
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
publisher;
|
|
32
|
+
* - Checks whether it is elected as proposer for the next slot
|
|
33
|
+
* - Builds multiple blocks and broadcasts them
|
|
34
|
+
* - Collects attestations for the checkpoint
|
|
35
|
+
* - Publishes the checkpoint to L1
|
|
36
|
+
* - Votes for proposals and slashes on L1
|
|
37
|
+
*/ export class Sequencer extends EventEmitter {
|
|
38
|
+
publisherFactory;
|
|
38
39
|
validatorClient;
|
|
39
40
|
globalsBuilder;
|
|
40
41
|
p2pClient;
|
|
41
42
|
worldState;
|
|
42
43
|
slasherClient;
|
|
43
|
-
blockBuilderFactory;
|
|
44
44
|
l2BlockSource;
|
|
45
45
|
l1ToL2MessageSource;
|
|
46
|
-
|
|
47
|
-
contractDataSource;
|
|
46
|
+
checkpointsBuilder;
|
|
48
47
|
l1Constants;
|
|
49
48
|
dateProvider;
|
|
50
|
-
|
|
49
|
+
epochCache;
|
|
50
|
+
rollupContract;
|
|
51
|
+
telemetry;
|
|
51
52
|
log;
|
|
52
53
|
runningPromise;
|
|
53
|
-
pollingIntervalMs;
|
|
54
|
-
maxTxsPerBlock;
|
|
55
|
-
minTxsPerBlock;
|
|
56
|
-
maxL1TxInclusionTimeIntoSlot;
|
|
57
|
-
// TODO: zero values should not be allowed for the following 2 values in PROD
|
|
58
|
-
_coinbase;
|
|
59
|
-
_feeRecipient;
|
|
60
54
|
state;
|
|
61
|
-
allowedInSetup;
|
|
62
|
-
maxBlockSizeInBytes;
|
|
63
|
-
maxBlockGas;
|
|
64
55
|
metrics;
|
|
65
|
-
|
|
56
|
+
/** The last slot for which we attempted to vote when sync failed, to prevent duplicate attempts. */ lastSlotForVoteWhenSyncFailed;
|
|
57
|
+
/** The last slot for which we triggered a checkpoint proposal job, to prevent duplicate attempts. */ lastSlotForCheckpointProposalJob;
|
|
58
|
+
/** Last successful checkpoint proposed */ lastCheckpointProposed;
|
|
59
|
+
/** The last epoch for which we logged strategy comparison in fisherman mode. */ lastEpochForStrategyComparison;
|
|
66
60
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */ timetable;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.l2BlockSource = l2BlockSource;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.
|
|
82
|
-
this.config
|
|
83
|
-
this.log = log;
|
|
84
|
-
this.pollingIntervalMs = 1000;
|
|
85
|
-
this.maxTxsPerBlock = 32;
|
|
86
|
-
this.minTxsPerBlock = 1;
|
|
87
|
-
this.maxL1TxInclusionTimeIntoSlot = 0;
|
|
88
|
-
this._coinbase = EthAddress.ZERO;
|
|
89
|
-
this._feeRecipient = AztecAddress.ZERO;
|
|
90
|
-
this.state = SequencerState.STOPPED;
|
|
91
|
-
this.allowedInSetup = [];
|
|
92
|
-
this.maxBlockSizeInBytes = 1024 * 1024;
|
|
93
|
-
this.maxBlockGas = new Gas(100e9, 100e9);
|
|
94
|
-
this.isFlushing = false;
|
|
95
|
-
this.enforceTimeTable = false;
|
|
96
|
-
this.metrics = new SequencerMetrics(telemetry, ()=>this.state, 'Sequencer');
|
|
97
|
-
// Register the block builder with the validator client for re-execution
|
|
98
|
-
this.validatorClient?.registerBlockBuilder(this.buildBlock.bind(this));
|
|
99
|
-
// Register the slasher on the publisher to fetch slashing payloads
|
|
100
|
-
this.publisher.registerSlashPayloadGetter(this.slasherClient.getSlashPayload.bind(this.slasherClient));
|
|
61
|
+
// This shouldn't be here as this gets re-created each time we build/propose a block.
|
|
62
|
+
// But we have a number of tests that abuse/rely on this class having a permanent publisher.
|
|
63
|
+
// As long as those tests only configure a single publisher they will continue to work.
|
|
64
|
+
// This will get re-assigned every time the sequencer goes to build a new block to a publisher that is valid
|
|
65
|
+
// for the block proposer.
|
|
66
|
+
// TODO(palla/mbps): Remove this field and fix tests
|
|
67
|
+
publisher;
|
|
68
|
+
/** Config for the sequencer */ config;
|
|
69
|
+
constructor(publisherFactory, validatorClient, globalsBuilder, p2pClient, worldState, slasherClient, l2BlockSource, l1ToL2MessageSource, checkpointsBuilder, l1Constants, dateProvider, epochCache, rollupContract, config, telemetry = getTelemetryClient(), log = createLogger('sequencer')){
|
|
70
|
+
super(), this.publisherFactory = publisherFactory, this.validatorClient = validatorClient, this.globalsBuilder = globalsBuilder, this.p2pClient = p2pClient, this.worldState = worldState, this.slasherClient = slasherClient, this.l2BlockSource = l2BlockSource, this.l1ToL2MessageSource = l1ToL2MessageSource, this.checkpointsBuilder = checkpointsBuilder, this.l1Constants = l1Constants, this.dateProvider = dateProvider, this.epochCache = epochCache, this.rollupContract = rollupContract, this.telemetry = telemetry, this.log = log, this.state = SequencerState.STOPPED, this.config = DefaultSequencerConfig;
|
|
71
|
+
// Add [FISHERMAN] prefix to logger if in fisherman mode
|
|
72
|
+
if (config.fishermanMode) {
|
|
73
|
+
this.log = log.createChild('[FISHERMAN]');
|
|
74
|
+
}
|
|
75
|
+
this.metrics = new SequencerMetrics(telemetry, this.rollupContract, 'Sequencer');
|
|
76
|
+
this.updateConfig(config);
|
|
101
77
|
}
|
|
102
|
-
|
|
103
|
-
|
|
78
|
+
/** Updates sequencer config by the defined values and updates the timetable */ updateConfig(config) {
|
|
79
|
+
const filteredConfig = pickFromSchema(config, SequencerConfigSchema);
|
|
80
|
+
this.log.info(`Updated sequencer config`, omit(filteredConfig, 'txPublicSetupAllowList'));
|
|
81
|
+
this.config = merge(this.config, filteredConfig);
|
|
82
|
+
this.timetable = new SequencerTimetable({
|
|
83
|
+
ethereumSlotDuration: this.l1Constants.ethereumSlotDuration,
|
|
84
|
+
aztecSlotDuration: this.aztecSlotDuration,
|
|
85
|
+
l1PublishingTime: this.l1PublishingTime,
|
|
86
|
+
p2pPropagationTime: this.config.attestationPropagationTime,
|
|
87
|
+
blockDurationMs: this.config.blockDurationMs,
|
|
88
|
+
enforce: this.config.enforceTimeTable
|
|
89
|
+
}, this.metrics, this.log);
|
|
104
90
|
}
|
|
105
|
-
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*/ async updateConfig(config) {
|
|
109
|
-
this.log.info(`Sequencer config set`, omit(pickFromSchema(config, SequencerConfigSchema), 'allowedInSetup'));
|
|
110
|
-
if (config.transactionPollingIntervalMS !== undefined) {
|
|
111
|
-
this.pollingIntervalMs = config.transactionPollingIntervalMS;
|
|
112
|
-
}
|
|
113
|
-
if (config.maxTxsPerBlock !== undefined) {
|
|
114
|
-
this.maxTxsPerBlock = config.maxTxsPerBlock;
|
|
115
|
-
}
|
|
116
|
-
if (config.minTxsPerBlock !== undefined) {
|
|
117
|
-
this.minTxsPerBlock = config.minTxsPerBlock;
|
|
118
|
-
}
|
|
119
|
-
if (config.maxDABlockGas !== undefined) {
|
|
120
|
-
this.maxBlockGas = new Gas(config.maxDABlockGas, this.maxBlockGas.l2Gas);
|
|
121
|
-
}
|
|
122
|
-
if (config.maxL2BlockGas !== undefined) {
|
|
123
|
-
this.maxBlockGas = new Gas(this.maxBlockGas.daGas, config.maxL2BlockGas);
|
|
124
|
-
}
|
|
125
|
-
if (config.coinbase) {
|
|
126
|
-
this._coinbase = config.coinbase;
|
|
127
|
-
}
|
|
128
|
-
if (config.feeRecipient) {
|
|
129
|
-
this._feeRecipient = config.feeRecipient;
|
|
130
|
-
}
|
|
131
|
-
if (config.allowedInSetup) {
|
|
132
|
-
this.allowedInSetup = config.allowedInSetup;
|
|
133
|
-
} else {
|
|
134
|
-
this.allowedInSetup = await getDefaultAllowedSetupFunctions();
|
|
135
|
-
}
|
|
136
|
-
if (config.maxBlockSizeInBytes !== undefined) {
|
|
137
|
-
this.maxBlockSizeInBytes = config.maxBlockSizeInBytes;
|
|
138
|
-
}
|
|
139
|
-
if (config.governanceProposerPayload) {
|
|
140
|
-
this.publisher.setGovernancePayload(config.governanceProposerPayload);
|
|
141
|
-
}
|
|
142
|
-
if (config.maxL1TxInclusionTimeIntoSlot !== undefined) {
|
|
143
|
-
this.maxL1TxInclusionTimeIntoSlot = config.maxL1TxInclusionTimeIntoSlot;
|
|
144
|
-
}
|
|
145
|
-
if (config.enforceTimeTable !== undefined) {
|
|
146
|
-
this.enforceTimeTable = config.enforceTimeTable;
|
|
147
|
-
}
|
|
148
|
-
this.setTimeTable();
|
|
149
|
-
// TODO: Just read everything from the config object as needed instead of copying everything into local vars.
|
|
150
|
-
this.config = config;
|
|
91
|
+
/** Initializes the sequencer (precomputes tables and creates a publisher). Takes about 3s. */ async init() {
|
|
92
|
+
getKzg();
|
|
93
|
+
this.publisher = (await this.publisherFactory.create(undefined)).publisher;
|
|
151
94
|
}
|
|
152
|
-
|
|
153
|
-
this.
|
|
154
|
-
this.
|
|
155
|
-
|
|
95
|
+
/** Starts the sequencer and moves to IDLE state. */ start() {
|
|
96
|
+
this.runningPromise = new RunningPromise(this.safeWork.bind(this), this.log, this.config.sequencerPollingIntervalMS);
|
|
97
|
+
this.setState(SequencerState.IDLE, undefined, {
|
|
98
|
+
force: true
|
|
156
99
|
});
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Starts the sequencer and moves to IDLE state.
|
|
160
|
-
*/ async start() {
|
|
161
|
-
await this.updateConfig(this.config);
|
|
162
|
-
this.runningPromise = new RunningPromise(this.work.bind(this), this.log, this.pollingIntervalMs);
|
|
163
|
-
this.setState(SequencerState.IDLE, 0n, true);
|
|
164
100
|
this.runningPromise.start();
|
|
165
|
-
this.log.info(
|
|
101
|
+
this.log.info('Started sequencer');
|
|
166
102
|
}
|
|
167
|
-
/**
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
103
|
+
/** Stops the sequencer from building blocks and moves to STOPPED state. */ async stop() {
|
|
104
|
+
this.log.info(`Stopping sequencer`);
|
|
105
|
+
this.setState(SequencerState.STOPPING, undefined, {
|
|
106
|
+
force: true
|
|
107
|
+
});
|
|
108
|
+
this.publisher?.interrupt();
|
|
172
109
|
await this.runningPromise?.stop();
|
|
173
|
-
this.
|
|
174
|
-
|
|
175
|
-
|
|
110
|
+
this.setState(SequencerState.STOPPED, undefined, {
|
|
111
|
+
force: true
|
|
112
|
+
});
|
|
176
113
|
this.log.info('Stopped sequencer');
|
|
177
114
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
115
|
+
async safeWork() {
|
|
116
|
+
try {
|
|
117
|
+
await this.work();
|
|
118
|
+
} catch (err) {
|
|
119
|
+
this.emit('checkpoint-error', {
|
|
120
|
+
error: err
|
|
121
|
+
});
|
|
122
|
+
if (err instanceof SequencerTooSlowError) {
|
|
123
|
+
// TODO(palla/mbps): Add missing states
|
|
124
|
+
// Log as warn only if we had to abort halfway through the block proposal
|
|
125
|
+
const logLvl = [
|
|
126
|
+
SequencerState.INITIALIZING_CHECKPOINT,
|
|
127
|
+
SequencerState.PROPOSER_CHECK
|
|
128
|
+
].includes(err.proposedState) ? 'debug' : 'warn';
|
|
129
|
+
this.log[logLvl](err.message, {
|
|
130
|
+
now: this.dateProvider.nowInSeconds()
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
133
|
+
// Re-throw other errors
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
} finally{
|
|
137
|
+
this.setState(SequencerState.IDLE, undefined);
|
|
138
|
+
}
|
|
185
139
|
}
|
|
186
|
-
/**
|
|
187
|
-
* Returns the current state of the sequencer.
|
|
188
|
-
* @returns An object with a state entry with one of SequencerState.
|
|
189
|
-
*/ status() {
|
|
140
|
+
/** Returns the current state of the sequencer. */ status() {
|
|
190
141
|
return {
|
|
191
142
|
state: this.state
|
|
192
143
|
};
|
|
193
144
|
}
|
|
194
|
-
/** Forces the sequencer to bypass all time and tx count checks for the next block and build anyway. */ flush() {
|
|
195
|
-
this.isFlushing = true;
|
|
196
|
-
}
|
|
197
145
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*/ async
|
|
205
|
-
this.setState(SequencerState.SYNCHRONIZING,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (!
|
|
146
|
+
* Main sequencer loop:
|
|
147
|
+
* - Checks if we are up to date
|
|
148
|
+
* - If we are and we are the sequencer, collect txs and build blocks
|
|
149
|
+
* - Build multiple blocks per slot when configured
|
|
150
|
+
* - Collect attestations for the final block
|
|
151
|
+
* - Submit checkpoint
|
|
152
|
+
*/ async work() {
|
|
153
|
+
this.setState(SequencerState.SYNCHRONIZING, undefined);
|
|
154
|
+
const { slot, ts, now, epoch } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
155
|
+
// Check if we are synced and it's our slot, grab a publisher, check previous block invalidation, etc
|
|
156
|
+
const checkpointProposalJob = await this.prepareCheckpointProposal(slot, ts, now);
|
|
157
|
+
if (!checkpointProposalJob) {
|
|
210
158
|
return;
|
|
211
159
|
}
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
160
|
+
// Execute the checkpoint proposal job
|
|
161
|
+
const checkpoint = await checkpointProposalJob.execute();
|
|
162
|
+
// Update last checkpoint proposed (currently unused)
|
|
163
|
+
if (checkpoint) {
|
|
164
|
+
this.lastCheckpointProposed = checkpoint;
|
|
165
|
+
}
|
|
166
|
+
// Log fee strategy comparison if on fisherman
|
|
167
|
+
if (this.config.fishermanMode && (this.lastEpochForStrategyComparison === undefined || epoch > this.lastEpochForStrategyComparison)) {
|
|
168
|
+
this.logStrategyComparison(epoch, checkpointProposalJob.getPublisher());
|
|
169
|
+
this.lastEpochForStrategyComparison = epoch;
|
|
170
|
+
}
|
|
171
|
+
return checkpoint;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Prepares the checkpoint proposal by performing all necessary checks and setup.
|
|
175
|
+
* This is the initial step in the main loop.
|
|
176
|
+
* @returns CheckpointProposalJob if successful, undefined if we are not yet synced or are not the proposer.
|
|
177
|
+
*/ async prepareCheckpointProposal(slot, ts, now) {
|
|
178
|
+
// Check we have not already processed this slot (cheapest check)
|
|
179
|
+
// We only check this if enforce timetable is set, since we want to keep processing the same slot if we are not
|
|
180
|
+
// running against actual time (eg when we use sandbox-style automining)
|
|
181
|
+
if (this.lastSlotForCheckpointProposalJob && this.lastSlotForCheckpointProposalJob >= slot && this.config.enforceTimeTable) {
|
|
182
|
+
this.log.trace(`Slot ${slot} has already been processed`);
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
// But if we have already proposed for this slot, the we definitely have to skip it, automining or not
|
|
186
|
+
if (this.lastCheckpointProposed && this.lastCheckpointProposed.header.slotNumber >= slot) {
|
|
187
|
+
this.log.trace(`Slot ${slot} has already been published as checkpoint ${this.lastCheckpointProposed.number}`);
|
|
188
|
+
return undefined;
|
|
220
189
|
}
|
|
221
|
-
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
const enqueueSlashingVotePromise = this.publisher.enqueueCastVote(slot, newGlobalVariables.timestamp.toBigInt(), VoteType.SLASHING);
|
|
225
|
-
this.setState(SequencerState.INITIALIZING_PROPOSAL, slot);
|
|
226
|
-
this.log.verbose(`Preparing proposal for block ${newBlockNumber} at slot ${slot}`, {
|
|
227
|
-
chainTipArchive,
|
|
228
|
-
blockNumber: newBlockNumber,
|
|
190
|
+
// Check all components are synced to latest as seen by the archiver (queries all subsystems)
|
|
191
|
+
const syncedTo = await this.checkSync({
|
|
192
|
+
ts,
|
|
229
193
|
slot
|
|
230
194
|
});
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (pendingTxCount >= this.minTxsPerBlock || this.isFlushing) {
|
|
236
|
-
// We don't fetch exactly maxTxsPerBlock txs here because we may not need all of them if we hit a limit before,
|
|
237
|
-
// and also we may need to fetch more if we don't have enough valid txs.
|
|
238
|
-
const pendingTxs = this.p2pClient.iteratePendingTxs();
|
|
239
|
-
await this.buildBlockAndEnqueuePublish(pendingTxs, proposalHeader).catch((err)=>{
|
|
240
|
-
this.log.error(`Error building/enqueuing block`, err, {
|
|
241
|
-
blockNumber: newBlockNumber,
|
|
242
|
-
slot
|
|
243
|
-
});
|
|
195
|
+
if (!syncedTo) {
|
|
196
|
+
await this.tryVoteWhenSyncFails({
|
|
197
|
+
slot,
|
|
198
|
+
ts
|
|
244
199
|
});
|
|
245
|
-
|
|
246
|
-
} else {
|
|
247
|
-
this.log.debug(`Not enough txs to build block ${newBlockNumber} at slot ${slot}: got ${pendingTxCount} txs, need ${this.minTxsPerBlock}`);
|
|
200
|
+
return undefined;
|
|
248
201
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
202
|
+
// TODO(palla/mbps): Compute proper checkpoint number
|
|
203
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(BlockNumber(syncedTo.blockNumber + 1));
|
|
204
|
+
const logCtx = {
|
|
205
|
+
now,
|
|
206
|
+
syncedToL1Ts: syncedTo.l1Timestamp,
|
|
207
|
+
syncedToL2Slot: getSlotAtTimestamp(syncedTo.l1Timestamp, this.l1Constants),
|
|
208
|
+
slot,
|
|
209
|
+
slotTs: ts,
|
|
210
|
+
checkpointNumber,
|
|
211
|
+
isPendingChainValid: pick(syncedTo.pendingChainValidationStatus, 'valid', 'reason', 'invalidIndex')
|
|
212
|
+
};
|
|
213
|
+
// Check that we are a proposer for the next slot
|
|
214
|
+
this.setState(SequencerState.PROPOSER_CHECK, slot);
|
|
215
|
+
const [canPropose, proposer] = await this.checkCanPropose(slot);
|
|
216
|
+
// If we are not a proposer check if we should invalidate a invalid block, and bail
|
|
217
|
+
if (!canPropose) {
|
|
218
|
+
await this.considerInvalidatingBlock(syncedTo, slot);
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
// Check that the slot is not taken by a block already (should never happen, since only us can propose for this slot)
|
|
222
|
+
if (syncedTo.block && syncedTo.block.header.getSlot() >= slot) {
|
|
223
|
+
this.log.warn(`Cannot propose block at next L2 slot ${slot} since that slot was taken by block ${syncedTo.blockNumber}`, {
|
|
224
|
+
...logCtx,
|
|
225
|
+
block: syncedTo.block.header.toInspect()
|
|
253
226
|
});
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
227
|
+
this.metrics.recordBlockProposalPrecheckFailed('slot_already_taken');
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
// We now need to get ourselves a publisher.
|
|
231
|
+
// The returned attestor will be the one we provided if we provided one.
|
|
232
|
+
// Otherwise it will be a valid attestor for the returned publisher.
|
|
233
|
+
// In fisherman mode, pass undefined to use the fisherman's own keystore instead of the actual proposer's
|
|
234
|
+
const proposerForPublisher = this.config.fishermanMode ? undefined : proposer;
|
|
235
|
+
const { attestorAddress, publisher } = await this.publisherFactory.create(proposerForPublisher);
|
|
236
|
+
this.log.verbose(`Created publisher at address ${publisher.getSenderAddress()} for attestor ${attestorAddress}`);
|
|
237
|
+
this.publisher = publisher;
|
|
238
|
+
// In fisherman mode, set the actual proposer's address for simulations
|
|
239
|
+
if (this.config.fishermanMode && proposer) {
|
|
240
|
+
publisher.setProposerAddressForSimulation(proposer);
|
|
241
|
+
this.log.debug(`Set proposer address ${proposer} for simulation in fisherman mode`);
|
|
242
|
+
}
|
|
243
|
+
// Prepare invalidation request if the pending chain is invalid (returns undefined if no need)
|
|
244
|
+
// TODO(palla/mbps): We need to invalidate checkpoints, not blocks
|
|
245
|
+
const invalidateBlock = await publisher.simulateInvalidateBlock(syncedTo.pendingChainValidationStatus);
|
|
246
|
+
// Check with the rollup contract if we can indeed propose at the next L2 slot. This check should not fail
|
|
247
|
+
// if all the previous checks are good, but we do it just in case.
|
|
248
|
+
const canProposeCheck = await publisher.canProposeAtNextEthBlock(syncedTo.archive, proposer ?? EthAddress.ZERO, invalidateBlock);
|
|
249
|
+
if (canProposeCheck === undefined) {
|
|
250
|
+
this.log.warn(`Cannot propose checkpoint ${checkpointNumber} at slot ${slot} due to failed rollup contract check`, logCtx);
|
|
251
|
+
this.emit('proposer-rollup-check-failed', {
|
|
252
|
+
reason: 'Rollup contract check failed',
|
|
258
253
|
slot
|
|
259
254
|
});
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (finishedFlushing) {
|
|
263
|
-
this.isFlushing = false;
|
|
264
|
-
}
|
|
265
|
-
this.setState(SequencerState.IDLE, 0n);
|
|
266
|
-
}
|
|
267
|
-
async work() {
|
|
268
|
-
try {
|
|
269
|
-
await this.doRealWork();
|
|
270
|
-
} catch (err) {
|
|
271
|
-
if (err instanceof SequencerTooSlowError) {
|
|
272
|
-
this.log.warn(err.message);
|
|
273
|
-
} else {
|
|
274
|
-
// Re-throw other errors
|
|
275
|
-
throw err;
|
|
276
|
-
}
|
|
277
|
-
} finally{
|
|
278
|
-
this.setState(SequencerState.IDLE, 0n);
|
|
255
|
+
this.metrics.recordBlockProposalPrecheckFailed('rollup_contract_check_failed');
|
|
256
|
+
return undefined;
|
|
279
257
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (!result) {
|
|
258
|
+
if (canProposeCheck.slot !== slot) {
|
|
259
|
+
this.log.warn(`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}.`, {
|
|
260
|
+
...logCtx,
|
|
261
|
+
rollup: canProposeCheck,
|
|
262
|
+
expectedSlot: slot
|
|
263
|
+
});
|
|
264
|
+
this.emit('proposer-rollup-check-failed', {
|
|
265
|
+
reason: 'Slot mismatch',
|
|
266
|
+
slot
|
|
267
|
+
});
|
|
268
|
+
this.metrics.recordBlockProposalPrecheckFailed('slot_mismatch');
|
|
292
269
|
return undefined;
|
|
293
270
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
271
|
+
if (canProposeCheck.checkpointNumber !== checkpointNumber) {
|
|
272
|
+
this.log.warn(`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}.`, {
|
|
273
|
+
...logCtx,
|
|
274
|
+
rollup: canProposeCheck,
|
|
275
|
+
expectedSlot: slot
|
|
276
|
+
});
|
|
277
|
+
this.emit('proposer-rollup-check-failed', {
|
|
278
|
+
reason: 'Block mismatch',
|
|
279
|
+
slot
|
|
280
|
+
});
|
|
281
|
+
this.metrics.recordBlockProposalPrecheckFailed('block_number_mismatch');
|
|
282
|
+
return undefined;
|
|
299
283
|
}
|
|
300
|
-
|
|
284
|
+
this.lastSlotForCheckpointProposalJob = slot;
|
|
285
|
+
this.log.info(`Preparing checkpoint proposal ${checkpointNumber} at slot ${slot}`, {
|
|
286
|
+
...logCtx,
|
|
287
|
+
proposer
|
|
288
|
+
});
|
|
289
|
+
// Create and return the checkpoint proposal job
|
|
290
|
+
return this.createCheckpointProposalJob(slot, checkpointNumber, syncedTo.blockNumber, proposer, publisher, attestorAddress, invalidateBlock);
|
|
291
|
+
}
|
|
292
|
+
createCheckpointProposalJob(slot, checkpointNumber, syncedToBlockNumber, proposer, publisher, attestorAddress, invalidateBlock) {
|
|
293
|
+
return new CheckpointProposalJob(slot, checkpointNumber, syncedToBlockNumber, proposer, publisher, attestorAddress, invalidateBlock, this.validatorClient, this.globalsBuilder, this.p2pClient, this.worldState, this.l1ToL2MessageSource, this.checkpointsBuilder, this.l1Constants, this.config, this.timetable, this.slasherClient, this.epochCache, this.dateProvider, this.metrics, this, this.setState.bind(this), this.log);
|
|
301
294
|
}
|
|
302
295
|
/**
|
|
303
|
-
*
|
|
296
|
+
* Internal helper for setting the sequencer state and checks if we have enough time left in the slot to transition to the new state.
|
|
304
297
|
* @param proposedState - The new state to transition to.
|
|
305
|
-
* @param
|
|
298
|
+
* @param slotNumber - The current slot number.
|
|
306
299
|
* @param force - Whether to force the transition even if the sequencer is stopped.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
300
|
+
*/ setState(proposedState, slotNumber, opts = {}) {
|
|
301
|
+
if (this.state === SequencerState.STOPPING && proposedState !== SequencerState.STOPPED && !opts.force) {
|
|
302
|
+
this.log.warn(`Cannot set sequencer to ${proposedState} as it is stopping.`);
|
|
303
|
+
throw new SequencerInterruptedError();
|
|
304
|
+
}
|
|
305
|
+
if (this.state === SequencerState.STOPPED && !opts.force) {
|
|
312
306
|
this.log.warn(`Cannot set sequencer from ${this.state} to ${proposedState} as it is stopped.`);
|
|
313
307
|
return;
|
|
314
308
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
309
|
+
let secondsIntoSlot = undefined;
|
|
310
|
+
if (slotNumber !== undefined) {
|
|
311
|
+
secondsIntoSlot = this.getSecondsIntoSlot(slotNumber);
|
|
312
|
+
this.timetable.assertTimeLeft(proposedState, secondsIntoSlot);
|
|
313
|
+
}
|
|
314
|
+
const boringStates = [
|
|
315
|
+
SequencerState.IDLE,
|
|
316
|
+
SequencerState.SYNCHRONIZING
|
|
317
|
+
];
|
|
318
|
+
const logLevel = boringStates.includes(proposedState) && boringStates.includes(this.state) ? 'trace' : 'debug';
|
|
319
|
+
this.log[logLevel](`Transitioning from ${this.state} to ${proposedState}`, {
|
|
320
|
+
slotNumber,
|
|
321
|
+
secondsIntoSlot
|
|
322
|
+
});
|
|
323
|
+
this.emit('state-changed', {
|
|
324
|
+
oldState: this.state,
|
|
325
|
+
newState: proposedState,
|
|
326
|
+
secondsIntoSlot,
|
|
327
|
+
slot: slotNumber
|
|
328
|
+
});
|
|
318
329
|
this.state = proposedState;
|
|
319
330
|
}
|
|
320
331
|
/**
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
const slot = newGlobalVariables.slotNumber.toBigInt();
|
|
332
|
-
this.log.debug(`Requesting L1 to L2 messages from contract for block ${blockNumber}`);
|
|
333
|
-
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(BigInt(blockNumber));
|
|
334
|
-
const msgCount = l1ToL2Messages.length;
|
|
335
|
-
this.log.verbose(`Building block ${blockNumber} for slot ${slot}`, {
|
|
336
|
-
slot,
|
|
337
|
-
blockNumber,
|
|
338
|
-
msgCount,
|
|
339
|
-
validator: opts.validateOnly
|
|
340
|
-
});
|
|
341
|
-
// Sync to the previous block at least
|
|
342
|
-
await this.worldState.syncImmediate(blockNumber - 1);
|
|
343
|
-
this.log.debug(`Synced to previous block ${blockNumber - 1}`);
|
|
344
|
-
// NB: separating the dbs because both should update the state
|
|
345
|
-
const publicProcessorFork = await this.worldState.fork();
|
|
346
|
-
const orchestratorFork = await this.worldState.fork();
|
|
347
|
-
const previousBlockHeader = (await this.l2BlockSource.getBlock(blockNumber - 1))?.header ?? orchestratorFork.getInitialHeader();
|
|
348
|
-
try {
|
|
349
|
-
const processor = this.publicProcessorFactory.create(publicProcessorFork, newGlobalVariables, true);
|
|
350
|
-
const blockBuildingTimer = new Timer();
|
|
351
|
-
const blockBuilder = this.blockBuilderFactory.create(orchestratorFork);
|
|
352
|
-
await blockBuilder.startNewBlock(newGlobalVariables, l1ToL2Messages, previousBlockHeader);
|
|
353
|
-
// Deadline for processing depends on whether we're proposing a block
|
|
354
|
-
const secondsIntoSlot = this.getSecondsIntoSlot(slot);
|
|
355
|
-
const processingEndTimeWithinSlot = opts.validateOnly ? this.timetable.getValidatorReexecTimeEnd(secondsIntoSlot) : this.timetable.getBlockProposalExecTimeEnd(secondsIntoSlot);
|
|
356
|
-
// Deadline is only set if enforceTimeTable is enabled.
|
|
357
|
-
const deadline = this.enforceTimeTable ? new Date((this.getSlotStartTimestamp(slot) + processingEndTimeWithinSlot) * 1000) : undefined;
|
|
358
|
-
this.log.verbose(`Processing pending txs`, {
|
|
332
|
+
* Returns whether all dependencies have caught up.
|
|
333
|
+
* We don't check against the previous block submitted since it may have been reorg'd out.
|
|
334
|
+
*/ async checkSync(args) {
|
|
335
|
+
// Check that the archiver and dependencies have synced to the previous L1 slot at least
|
|
336
|
+
// TODO(#14766): Archiver reports L1 timestamp based on L1 blocks seen, which means that a missed L1 block will
|
|
337
|
+
// cause the archiver L1 timestamp to fall behind, and cause this sequencer to start processing one L1 slot later.
|
|
338
|
+
const l1Timestamp = await this.l2BlockSource.getL1Timestamp();
|
|
339
|
+
const { slot, ts } = args;
|
|
340
|
+
if (l1Timestamp === undefined || l1Timestamp + BigInt(this.l1Constants.ethereumSlotDuration) < ts) {
|
|
341
|
+
this.log.debug(`Cannot propose block at next L2 slot ${slot} due to pending sync from L1`, {
|
|
359
342
|
slot,
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
deadline
|
|
343
|
+
ts,
|
|
344
|
+
l1Timestamp
|
|
363
345
|
});
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
});
|
|
394
|
-
throw new Error(`Block has too few successful txs to be proposed`);
|
|
395
|
-
}
|
|
396
|
-
const start = process.hrtime.bigint();
|
|
397
|
-
await blockBuilder.addTxs(processedTxs);
|
|
398
|
-
const end = process.hrtime.bigint();
|
|
399
|
-
const duration = Number(end - start) / 1_000;
|
|
400
|
-
this.metrics.recordBlockBuilderTreeInsertions(duration);
|
|
401
|
-
// All real transactions have been added, set the block as full and pad if needed
|
|
402
|
-
const block = await blockBuilder.setBlockCompleted();
|
|
403
|
-
// How much public gas was processed
|
|
404
|
-
const publicGas = processedTxs.reduce((acc, tx)=>acc.add(tx.gasUsed.publicGas), Gas.empty());
|
|
346
|
+
return undefined;
|
|
347
|
+
}
|
|
348
|
+
const syncedBlocks = await Promise.all([
|
|
349
|
+
this.worldState.status().then(({ syncSummary })=>({
|
|
350
|
+
number: syncSummary.latestBlockNumber,
|
|
351
|
+
hash: syncSummary.latestBlockHash
|
|
352
|
+
})),
|
|
353
|
+
this.l2BlockSource.getL2Tips().then((t)=>t.latest),
|
|
354
|
+
this.p2pClient.getStatus().then((p2p)=>p2p.syncedToL2Block),
|
|
355
|
+
this.l1ToL2MessageSource.getL2Tips().then((t)=>t.latest),
|
|
356
|
+
this.l2BlockSource.getPendingChainValidationStatus()
|
|
357
|
+
]);
|
|
358
|
+
const [worldState, l2BlockSource, p2p, l1ToL2MessageSource, pendingChainValidationStatus] = syncedBlocks;
|
|
359
|
+
// 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,
|
|
360
|
+
// as the world state can compute the new genesis block hash, but other components use the hardcoded constant.
|
|
361
|
+
const result = l2BlockSource.number === 0 && worldState.number === 0 && p2p.number === 0 && l1ToL2MessageSource.number === 0 || worldState.hash === l2BlockSource.hash && p2p.hash === l2BlockSource.hash && l1ToL2MessageSource.hash === l2BlockSource.hash;
|
|
362
|
+
if (!result) {
|
|
363
|
+
this.log.debug(`Sequencer sync check failed`, {
|
|
364
|
+
worldState,
|
|
365
|
+
l2BlockSource,
|
|
366
|
+
p2p,
|
|
367
|
+
l1ToL2MessageSource
|
|
368
|
+
});
|
|
369
|
+
return undefined;
|
|
370
|
+
}
|
|
371
|
+
// Special case for genesis state
|
|
372
|
+
const blockNumber = worldState.number;
|
|
373
|
+
if (blockNumber < INITIAL_L2_BLOCK_NUM) {
|
|
374
|
+
const archive = new Fr((await this.worldState.getCommitted().getTreeInfo(MerkleTreeId.ARCHIVE)).root);
|
|
405
375
|
return {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
numTxs: processedTxs.length,
|
|
411
|
-
numFailedTxs: failedTxs.length,
|
|
412
|
-
blockBuildingTimer
|
|
376
|
+
blockNumber: BlockNumber(INITIAL_L2_BLOCK_NUM - 1),
|
|
377
|
+
archive,
|
|
378
|
+
l1Timestamp,
|
|
379
|
+
pendingChainValidationStatus
|
|
413
380
|
};
|
|
414
|
-
} finally{
|
|
415
|
-
// We create a fresh processor each time to reset any cached state (eg storage writes)
|
|
416
|
-
// We wait a bit to close the forks since the processor may still be working on a dangling tx
|
|
417
|
-
// which was interrupted due to the processingDeadline being hit.
|
|
418
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
419
|
-
setTimeout(async ()=>{
|
|
420
|
-
try {
|
|
421
|
-
await publicProcessorFork.close();
|
|
422
|
-
await orchestratorFork.close();
|
|
423
|
-
} catch (err) {
|
|
424
|
-
// This can happen if the sequencer is stopped before we hit this timeout.
|
|
425
|
-
this.log.warn(`Error closing forks for block processing`, err);
|
|
426
|
-
}
|
|
427
|
-
}, 5000);
|
|
428
381
|
}
|
|
382
|
+
const block = await this.l2BlockSource.getL2BlockNew(blockNumber);
|
|
383
|
+
if (!block) {
|
|
384
|
+
// this shouldn't really happen because a moment ago we checked that all components were in sync
|
|
385
|
+
this.log.error(`Failed to get L2 block ${blockNumber} from the archiver with all components in sync`);
|
|
386
|
+
return undefined;
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
block,
|
|
390
|
+
blockNumber: block.number,
|
|
391
|
+
archive: block.archive.root,
|
|
392
|
+
l1Timestamp,
|
|
393
|
+
pendingChainValidationStatus
|
|
394
|
+
};
|
|
429
395
|
}
|
|
430
396
|
/**
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
*
|
|
436
|
-
* @param pendingTxs - Iterable of pending transactions to construct the block from
|
|
437
|
-
* @param proposalHeader - The partial header constructed for the proposal
|
|
438
|
-
*/ async buildBlockAndEnqueuePublish(pendingTxs, proposalHeader) {
|
|
439
|
-
await this.publisher.validateBlockForSubmission(proposalHeader);
|
|
440
|
-
const newGlobalVariables = proposalHeader.globalVariables;
|
|
441
|
-
const blockNumber = newGlobalVariables.blockNumber.toNumber();
|
|
442
|
-
const slot = newGlobalVariables.slotNumber.toBigInt();
|
|
443
|
-
// this.metrics.recordNewBlock(blockNumber, validTxs.length);
|
|
444
|
-
const workTimer = new Timer();
|
|
445
|
-
this.setState(SequencerState.CREATING_BLOCK, slot);
|
|
397
|
+
* Checks if we are the proposer for the next slot.
|
|
398
|
+
* @returns True if we can propose, and the proposer address (undefined if anyone can propose)
|
|
399
|
+
*/ async checkCanPropose(slot) {
|
|
400
|
+
let proposer;
|
|
446
401
|
try {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
creator: this.publisher.getSenderAddress().toString(),
|
|
456
|
-
duration: workTimer.ms(),
|
|
457
|
-
publicProcessDuration: publicProcessorDuration,
|
|
458
|
-
rollupCircuitsDuration: blockBuildingTimer.ms(),
|
|
459
|
-
...block.getStats()
|
|
460
|
-
};
|
|
461
|
-
const blockHash = await block.hash();
|
|
462
|
-
const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
|
|
463
|
-
this.log.info(`Built block ${block.number} for slot ${slot} with ${numTxs} txs and ${numMsgs} messages. ${publicGas.l2Gas / workTimer.s()} mana/s`, {
|
|
464
|
-
blockHash,
|
|
465
|
-
globalVariables: block.header.globalVariables.toInspect(),
|
|
466
|
-
txHashes,
|
|
467
|
-
...blockStats
|
|
468
|
-
});
|
|
469
|
-
this.log.debug('Collecting attestations');
|
|
470
|
-
const stopCollectingAttestationsTimer = this.metrics.startCollectingAttestationsTimer();
|
|
471
|
-
const attestations = await this.collectAttestations(block, txHashes);
|
|
472
|
-
if (attestations !== undefined) {
|
|
473
|
-
this.log.verbose(`Collected ${attestations.length} attestations`, {
|
|
474
|
-
blockHash,
|
|
475
|
-
blockNumber
|
|
476
|
-
});
|
|
402
|
+
proposer = await this.epochCache.getProposerAttesterAddressInSlot(slot);
|
|
403
|
+
} catch (e) {
|
|
404
|
+
if (e instanceof NoCommitteeError) {
|
|
405
|
+
this.log.warn(`Cannot propose at next L2 slot ${slot} since the committee does not exist on L1`);
|
|
406
|
+
return [
|
|
407
|
+
false,
|
|
408
|
+
undefined
|
|
409
|
+
];
|
|
477
410
|
}
|
|
478
|
-
|
|
479
|
-
return
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
411
|
+
this.log.error(`Error getting proposer for slot ${slot}`, e);
|
|
412
|
+
return [
|
|
413
|
+
false,
|
|
414
|
+
undefined
|
|
415
|
+
];
|
|
483
416
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
return orderAttestations(attestations, committee);
|
|
417
|
+
// If proposer is undefined, then the committee is empty and anyone may propose
|
|
418
|
+
if (proposer === undefined) {
|
|
419
|
+
return [
|
|
420
|
+
true,
|
|
421
|
+
undefined
|
|
422
|
+
];
|
|
423
|
+
}
|
|
424
|
+
// In fisherman mode, just return the current proposer
|
|
425
|
+
if (this.config.fishermanMode) {
|
|
426
|
+
return [
|
|
427
|
+
true,
|
|
428
|
+
proposer
|
|
429
|
+
];
|
|
430
|
+
}
|
|
431
|
+
const validatorAddresses = this.validatorClient.getValidatorAddresses();
|
|
432
|
+
const weAreProposer = validatorAddresses.some((addr)=>addr.equals(proposer));
|
|
433
|
+
if (!weAreProposer) {
|
|
434
|
+
this.log.debug(`Cannot propose at slot ${slot} since we are not a proposer`, {
|
|
435
|
+
validatorAddresses,
|
|
436
|
+
proposer
|
|
437
|
+
});
|
|
438
|
+
return [
|
|
439
|
+
false,
|
|
440
|
+
proposer
|
|
441
|
+
];
|
|
442
|
+
}
|
|
443
|
+
return [
|
|
444
|
+
true,
|
|
445
|
+
proposer
|
|
446
|
+
];
|
|
515
447
|
}
|
|
516
448
|
/**
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*/ async
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
449
|
+
* Tries to vote on slashing actions and governance when the sync check fails but we're past the max time for initializing a proposal.
|
|
450
|
+
* This allows the sequencer to participate in governance/slashing votes even when it cannot build blocks.
|
|
451
|
+
*/ async tryVoteWhenSyncFails(args) {
|
|
452
|
+
const { slot } = args;
|
|
453
|
+
// Prevent duplicate attempts in the same slot
|
|
454
|
+
if (this.lastSlotForVoteWhenSyncFailed === slot) {
|
|
455
|
+
this.log.trace(`Already attempted to vote in slot ${slot} (skipping)`);
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
// Check if we're past the max time for initializing a proposal
|
|
459
|
+
const secondsIntoSlot = this.getSecondsIntoSlot(slot);
|
|
460
|
+
const maxAllowedTime = this.timetable.getMaxAllowedTime(SequencerState.INITIALIZING_CHECKPOINT);
|
|
461
|
+
// If we haven't exceeded the time limit for initializing a proposal, don't proceed with voting
|
|
462
|
+
// We use INITIALIZING_PROPOSAL time limit because if we're past that, we can't build a block anyway
|
|
463
|
+
if (maxAllowedTime === undefined || secondsIntoSlot <= maxAllowedTime) {
|
|
464
|
+
this.log.trace(`Not attempting to vote since there is still time for block building`, {
|
|
465
|
+
secondsIntoSlot,
|
|
466
|
+
maxAllowedTime
|
|
467
|
+
});
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
this.log.trace(`Sync for slot ${slot} failed, checking for voting opportunities`, {
|
|
471
|
+
secondsIntoSlot,
|
|
472
|
+
maxAllowedTime
|
|
473
|
+
});
|
|
474
|
+
// Check if we're a proposer or proposal is open
|
|
475
|
+
const [canPropose, proposer] = await this.checkCanPropose(slot);
|
|
476
|
+
if (!canPropose) {
|
|
477
|
+
this.log.trace(`Cannot vote in slot ${slot} since we are not a proposer`, {
|
|
478
|
+
slot,
|
|
479
|
+
proposer
|
|
480
|
+
});
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
// Mark this slot as attempted
|
|
484
|
+
this.lastSlotForVoteWhenSyncFailed = slot;
|
|
485
|
+
// Get a publisher for voting
|
|
486
|
+
const { attestorAddress, publisher } = await this.publisherFactory.create(proposer);
|
|
487
|
+
this.log.debug(`Attempting to vote despite sync failure at slot ${slot}`, {
|
|
488
|
+
attestorAddress,
|
|
489
|
+
slot
|
|
527
490
|
});
|
|
528
|
-
|
|
529
|
-
|
|
491
|
+
// Enqueue governance and slashing votes
|
|
492
|
+
const voter = new CheckpointVoter(slot, publisher, attestorAddress, this.validatorClient, this.slasherClient, this.l1Constants, this.config, this.metrics, this.log);
|
|
493
|
+
const votesPromises = voter.enqueueVotes();
|
|
494
|
+
const votes = await Promise.all(votesPromises);
|
|
495
|
+
if (votes.every((p)=>!p)) {
|
|
496
|
+
this.log.debug(`No votes to enqueue for slot ${slot}`);
|
|
497
|
+
return;
|
|
530
498
|
}
|
|
499
|
+
this.log.info(`Voting in slot ${slot} despite sync failure`, {
|
|
500
|
+
slot
|
|
501
|
+
});
|
|
502
|
+
await publisher.sendRequests();
|
|
531
503
|
}
|
|
532
504
|
/**
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
hash: s.syncSummary.latestBlockHash
|
|
542
|
-
};
|
|
543
|
-
}),
|
|
544
|
-
this.l2BlockSource.getL2Tips().then((t)=>t.latest),
|
|
545
|
-
this.p2pClient.getStatus().then((p2p)=>p2p.syncedToL2Block),
|
|
546
|
-
this.l1ToL2MessageSource.getBlockNumber()
|
|
547
|
-
]);
|
|
548
|
-
const [worldState, l2BlockSource, p2p, l1ToL2MessageSource] = syncedBlocks;
|
|
549
|
-
const result = // check that world state has caught up with archiver
|
|
550
|
-
// note that the archiver reports undefined hash for the genesis block
|
|
551
|
-
// because it doesn't have access to world state to compute it (facepalm)
|
|
552
|
-
(l2BlockSource.hash === undefined || worldState.hash === l2BlockSource.hash) && // and p2p client and message source are at least at the same block
|
|
553
|
-
// this should change to hashes once p2p client handles reorgs
|
|
554
|
-
// and once we stop pretending that the l1tol2message source is not
|
|
555
|
-
// just the archiver under a different name
|
|
556
|
-
(!l2BlockSource.hash || p2p.hash === l2BlockSource.hash) && l1ToL2MessageSource === l2BlockSource.number;
|
|
557
|
-
this.log.debug(`Sequencer sync check ${result ? 'succeeded' : 'failed'}`, {
|
|
558
|
-
worldStateNumber: worldState.number,
|
|
559
|
-
worldStateHash: worldState.hash,
|
|
560
|
-
l2BlockSourceNumber: l2BlockSource.number,
|
|
561
|
-
l2BlockSourceHash: l2BlockSource.hash,
|
|
562
|
-
p2pNumber: p2p.number,
|
|
563
|
-
p2pHash: p2p.hash,
|
|
564
|
-
l1ToL2MessageSourceNumber: l1ToL2MessageSource
|
|
565
|
-
});
|
|
566
|
-
if (!result) {
|
|
567
|
-
return undefined;
|
|
505
|
+
* Considers invalidating a block if the pending chain is invalid. Depends on how long the invalid block
|
|
506
|
+
* has been there without being invalidated and whether the sequencer is in the committee or not. We always
|
|
507
|
+
* have the proposer try to invalidate, but if they fail, the sequencers in the committee are expected to try,
|
|
508
|
+
* and if they fail, any sequencer will try as well.
|
|
509
|
+
*/ async considerInvalidatingBlock(syncedTo, currentSlot) {
|
|
510
|
+
const { pendingChainValidationStatus, l1Timestamp } = syncedTo;
|
|
511
|
+
if (pendingChainValidationStatus.valid) {
|
|
512
|
+
return;
|
|
568
513
|
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
514
|
+
const invalidBlockNumber = pendingChainValidationStatus.block.blockNumber;
|
|
515
|
+
const invalidBlockTimestamp = pendingChainValidationStatus.block.timestamp;
|
|
516
|
+
const timeSinceChainInvalid = this.dateProvider.nowInSeconds() - Number(invalidBlockTimestamp);
|
|
517
|
+
const ourValidatorAddresses = this.validatorClient.getValidatorAddresses();
|
|
518
|
+
const { secondsBeforeInvalidatingBlockAsCommitteeMember, secondsBeforeInvalidatingBlockAsNonCommitteeMember } = this.config;
|
|
519
|
+
const logData = {
|
|
520
|
+
invalidL1Timestamp: invalidBlockTimestamp,
|
|
521
|
+
l1Timestamp,
|
|
522
|
+
invalidBlock: pendingChainValidationStatus.block,
|
|
523
|
+
secondsBeforeInvalidatingBlockAsCommitteeMember,
|
|
524
|
+
secondsBeforeInvalidatingBlockAsNonCommitteeMember,
|
|
525
|
+
ourValidatorAddresses,
|
|
526
|
+
currentSlot
|
|
527
|
+
};
|
|
528
|
+
const inCurrentCommittee = ()=>this.epochCache.getCommittee(currentSlot).then((c)=>c?.committee?.some((member)=>ourValidatorAddresses.some((addr)=>addr.equals(member))));
|
|
529
|
+
const invalidateAsCommitteeMember = secondsBeforeInvalidatingBlockAsCommitteeMember !== undefined && secondsBeforeInvalidatingBlockAsCommitteeMember > 0 && timeSinceChainInvalid > secondsBeforeInvalidatingBlockAsCommitteeMember && await inCurrentCommittee();
|
|
530
|
+
const invalidateAsNonCommitteeMember = secondsBeforeInvalidatingBlockAsNonCommitteeMember !== undefined && secondsBeforeInvalidatingBlockAsNonCommitteeMember > 0 && timeSinceChainInvalid > secondsBeforeInvalidatingBlockAsNonCommitteeMember;
|
|
531
|
+
if (!invalidateAsCommitteeMember && !invalidateAsNonCommitteeMember) {
|
|
532
|
+
this.log.debug(`Not invalidating pending chain`, logData);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
let validatorToUse;
|
|
536
|
+
if (invalidateAsCommitteeMember) {
|
|
537
|
+
// When invalidating as a committee member, use first validator that's actually in the committee
|
|
538
|
+
const { committee } = await this.epochCache.getCommittee(currentSlot);
|
|
539
|
+
if (committee) {
|
|
540
|
+
const committeeSet = new Set(committee.map((addr)=>addr.toString()));
|
|
541
|
+
validatorToUse = ourValidatorAddresses.find((addr)=>committeeSet.has(addr.toString())) ?? ourValidatorAddresses[0];
|
|
542
|
+
} else {
|
|
543
|
+
validatorToUse = ourValidatorAddresses[0];
|
|
574
544
|
}
|
|
575
|
-
return {
|
|
576
|
-
blockNumber: block.number,
|
|
577
|
-
archive: block.archive.root
|
|
578
|
-
};
|
|
579
545
|
} else {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
546
|
+
// When invalidating as a non-committee member, use the first validator
|
|
547
|
+
validatorToUse = ourValidatorAddresses[0];
|
|
548
|
+
}
|
|
549
|
+
const { publisher } = await this.publisherFactory.create(validatorToUse);
|
|
550
|
+
const invalidateBlock = await publisher.simulateInvalidateBlock(pendingChainValidationStatus);
|
|
551
|
+
if (!invalidateBlock) {
|
|
552
|
+
this.log.warn(`Failed to simulate invalidate block`, logData);
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
this.log.info(invalidateAsCommitteeMember ? `Invalidating block ${invalidBlockNumber} as committee member` : `Invalidating block ${invalidBlockNumber} as non-committee member`, logData);
|
|
556
|
+
publisher.enqueueInvalidateBlock(invalidateBlock);
|
|
557
|
+
if (!this.config.fishermanMode) {
|
|
558
|
+
await publisher.sendRequests();
|
|
559
|
+
} else {
|
|
560
|
+
this.log.info('Invalidating block in fisherman mode, clearing pending requests');
|
|
561
|
+
publisher.clearPendingRequests();
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
logStrategyComparison(epoch, publisher) {
|
|
565
|
+
const feeAnalyzer = publisher.getL1FeeAnalyzer();
|
|
566
|
+
if (!feeAnalyzer) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const comparison = feeAnalyzer.getStrategyComparison();
|
|
570
|
+
if (comparison.length === 0) {
|
|
571
|
+
this.log.debug(`No strategy data available yet for epoch ${epoch}`);
|
|
572
|
+
return;
|
|
585
573
|
}
|
|
574
|
+
this.log.info(`L1 Fee Strategy Performance Report - End of Epoch ${epoch}`, {
|
|
575
|
+
epoch: Number(epoch),
|
|
576
|
+
totalAnalyses: comparison[0]?.totalAnalyses,
|
|
577
|
+
strategies: comparison.map((s)=>({
|
|
578
|
+
id: s.strategyId,
|
|
579
|
+
name: s.strategyName,
|
|
580
|
+
inclusionRate: `${(s.inclusionRate * 100).toFixed(1)}%`,
|
|
581
|
+
inclusionCount: `${s.inclusionCount}/${s.totalAnalyses}`,
|
|
582
|
+
avgCostEth: s.avgEstimatedCostEth.toFixed(6),
|
|
583
|
+
totalCostEth: s.totalEstimatedCostEth.toFixed(6),
|
|
584
|
+
avgOverpaymentEth: s.avgOverpaymentEth.toFixed(6),
|
|
585
|
+
totalOverpaymentEth: s.totalOverpaymentEth.toFixed(6),
|
|
586
|
+
avgPriorityFeeDeltaGwei: s.avgPriorityFeeDeltaGwei.toFixed(2)
|
|
587
|
+
}))
|
|
588
|
+
});
|
|
586
589
|
}
|
|
587
|
-
|
|
588
|
-
return
|
|
590
|
+
getSlotStartBuildTimestamp(slotNumber) {
|
|
591
|
+
return getSlotStartBuildTimestamp(slotNumber, this.l1Constants);
|
|
589
592
|
}
|
|
590
593
|
getSecondsIntoSlot(slotNumber) {
|
|
591
|
-
const slotStartTimestamp = this.
|
|
594
|
+
const slotStartTimestamp = this.getSlotStartBuildTimestamp(slotNumber);
|
|
592
595
|
return Number((this.dateProvider.now() / 1000 - slotStartTimestamp).toFixed(3));
|
|
593
596
|
}
|
|
594
597
|
get aztecSlotDuration() {
|
|
595
598
|
return this.l1Constants.slotDuration;
|
|
596
599
|
}
|
|
597
|
-
get
|
|
598
|
-
return this.
|
|
600
|
+
get maxL2BlockGas() {
|
|
601
|
+
return this.config.maxL2BlockGas;
|
|
602
|
+
}
|
|
603
|
+
getSlasherClient() {
|
|
604
|
+
return this.slasherClient;
|
|
605
|
+
}
|
|
606
|
+
get tracer() {
|
|
607
|
+
return this.metrics.tracer;
|
|
599
608
|
}
|
|
600
|
-
|
|
601
|
-
return this.
|
|
609
|
+
getValidatorAddresses() {
|
|
610
|
+
return this.validatorClient?.getValidatorAddresses();
|
|
611
|
+
}
|
|
612
|
+
getConfig() {
|
|
613
|
+
return this.config;
|
|
614
|
+
}
|
|
615
|
+
get l1PublishingTime() {
|
|
616
|
+
return this.config.l1PublishingTime ?? this.l1Constants.ethereumSlotDuration;
|
|
602
617
|
}
|
|
603
618
|
}
|
|
604
619
|
_ts_decorate([
|
|
605
620
|
trackSpan('Sequencer.work')
|
|
606
|
-
], Sequencer.prototype, "
|
|
607
|
-
_ts_decorate([
|
|
608
|
-
trackSpan('Sequencer.buildBlockAndEnqueuePublish', (_validTxs, proposalHeader)=>({
|
|
609
|
-
[Attributes.BLOCK_NUMBER]: proposalHeader.globalVariables.blockNumber.toNumber()
|
|
610
|
-
}))
|
|
611
|
-
], Sequencer.prototype, "buildBlockAndEnqueuePublish", null);
|
|
612
|
-
_ts_decorate([
|
|
613
|
-
trackSpan('Sequencer.collectAttestations', (block, txHashes)=>({
|
|
614
|
-
[Attributes.BLOCK_NUMBER]: block.number,
|
|
615
|
-
[Attributes.BLOCK_ARCHIVE]: block.archive.toString(),
|
|
616
|
-
[Attributes.BLOCK_TXS_COUNT]: txHashes.length
|
|
617
|
-
}))
|
|
618
|
-
], Sequencer.prototype, "collectAttestations", null);
|
|
619
|
-
_ts_decorate([
|
|
620
|
-
trackSpan('Sequencer.enqueuePublishL2Block', (block)=>({
|
|
621
|
-
[Attributes.BLOCK_NUMBER]: block.number
|
|
622
|
-
}))
|
|
623
|
-
], Sequencer.prototype, "enqueuePublishL2Block", null);
|
|
621
|
+
], Sequencer.prototype, "safeWork", null);
|