@aztec/sequencer-client 0.0.1-commit.9b94fc1 → 0.0.1-commit.c7c42ec
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client/sequencer-client.d.ts +10 -9
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +32 -25
- package/dest/config.d.ts +12 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +68 -30
- package/dest/global_variable_builder/global_builder.d.ts +19 -10
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +39 -29
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/config.d.ts +7 -4
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +9 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts +5 -4
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.d.ts +40 -33
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +133 -74
- package/dest/sequencer/block_builder.d.ts +4 -5
- package/dest/sequencer/block_builder.d.ts.map +1 -1
- package/dest/sequencer/block_builder.js +8 -13
- 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 +642 -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 +3 -2
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/events.d.ts +46 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +5 -1
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +4 -0
- package/dest/sequencer/metrics.d.ts +22 -2
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +154 -0
- package/dest/sequencer/sequencer.d.ts +93 -127
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +223 -578
- package/dest/sequencer/timetable.d.ts +54 -14
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +148 -59
- package/dest/sequencer/types.d.ts +3 -0
- package/dest/sequencer/types.d.ts.map +1 -0
- package/dest/sequencer/types.js +1 -0
- package/dest/sequencer/utils.d.ts +14 -8
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +7 -4
- package/dest/test/index.d.ts +4 -2
- package/dest/test/index.d.ts.map +1 -1
- 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/tx_validator_factory.d.ts +3 -2
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +1 -1
- package/package.json +29 -29
- package/src/client/sequencer-client.ts +28 -38
- package/src/config.ts +73 -34
- package/src/global_variable_builder/global_builder.ts +54 -50
- package/src/index.ts +2 -0
- package/src/publisher/config.ts +12 -9
- package/src/publisher/sequencer-publisher-factory.ts +5 -4
- package/src/publisher/sequencer-publisher-metrics.ts +2 -2
- package/src/publisher/sequencer-publisher.ts +214 -102
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/block_builder.ts +11 -16
- package/src/sequencer/checkpoint_builder.ts +217 -0
- package/src/sequencer/checkpoint_proposal_job.ts +706 -0
- package/src/sequencer/checkpoint_voter.ts +105 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +4 -0
- package/src/sequencer/metrics.ts +203 -1
- package/src/sequencer/sequencer.ts +330 -788
- package/src/sequencer/timetable.ts +173 -79
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +18 -9
- package/src/test/index.ts +3 -1
- package/src/test/mock_checkpoint_builder.ts +247 -0
- package/src/test/utils.ts +137 -0
- package/src/tx_validator/tx_validator_factory.ts +3 -2
|
@@ -4,29 +4,24 @@ 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 {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { getKzg } from '@aztec/blob-lib';
|
|
8
|
+
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
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';
|
|
11
13
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
|
-
import { Signature } from '@aztec/foundation/eth-signature';
|
|
13
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
14
14
|
import { createLogger } from '@aztec/foundation/log';
|
|
15
15
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
16
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
17
|
-
import { unfreeze } from '@aztec/foundation/types';
|
|
18
|
-
import { CommitteeAttestationsAndSigners, MaliciousCommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
19
16
|
import { getSlotAtTimestamp, getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
20
|
-
import { Gas } from '@aztec/stdlib/gas';
|
|
21
17
|
import { SequencerConfigSchema } from '@aztec/stdlib/interfaces/server';
|
|
22
|
-
import { orderAttestations } from '@aztec/stdlib/p2p';
|
|
23
|
-
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
24
18
|
import { pickFromSchema } from '@aztec/stdlib/schemas';
|
|
25
19
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
26
|
-
import {
|
|
27
|
-
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
28
|
-
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
20
|
+
import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
29
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';
|
|
30
25
|
import { SequencerInterruptedError, SequencerTooSlowError } from './errors.js';
|
|
31
26
|
import { SequencerMetrics } from './metrics.js';
|
|
32
27
|
import { SequencerTimetable } from './timetable.js';
|
|
@@ -34,12 +29,11 @@ import { SequencerState } from './utils.js';
|
|
|
34
29
|
export { SequencerState };
|
|
35
30
|
/**
|
|
36
31
|
* Sequencer client
|
|
37
|
-
* -
|
|
38
|
-
* -
|
|
39
|
-
* -
|
|
40
|
-
* -
|
|
41
|
-
* -
|
|
42
|
-
* - Publishes L1 tx(s) to the rollup contract via RollupPublisher.
|
|
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
|
|
43
37
|
*/ export class Sequencer extends EventEmitter {
|
|
44
38
|
publisherFactory;
|
|
45
39
|
validatorClient;
|
|
@@ -49,116 +43,64 @@ export { SequencerState };
|
|
|
49
43
|
slasherClient;
|
|
50
44
|
l2BlockSource;
|
|
51
45
|
l1ToL2MessageSource;
|
|
52
|
-
|
|
46
|
+
checkpointsBuilder;
|
|
53
47
|
l1Constants;
|
|
54
48
|
dateProvider;
|
|
55
49
|
epochCache;
|
|
56
50
|
rollupContract;
|
|
57
|
-
config;
|
|
58
51
|
telemetry;
|
|
59
52
|
log;
|
|
60
53
|
runningPromise;
|
|
61
|
-
pollingIntervalMs;
|
|
62
|
-
maxTxsPerBlock;
|
|
63
|
-
minTxsPerBlock;
|
|
64
|
-
maxL1TxInclusionTimeIntoSlot;
|
|
65
54
|
state;
|
|
66
|
-
maxBlockSizeInBytes;
|
|
67
|
-
maxBlockGas;
|
|
68
55
|
metrics;
|
|
69
|
-
lastBlockPublished;
|
|
70
|
-
governanceProposerPayload;
|
|
71
56
|
/** The last slot for which we attempted to vote when sync failed, to prevent duplicate attempts. */ lastSlotForVoteWhenSyncFailed;
|
|
72
|
-
/** The last slot for which we
|
|
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;
|
|
73
60
|
/** The maximum number of seconds that the sequencer can be into a slot to transition to a particular state. */ timetable;
|
|
74
|
-
enforceTimeTable;
|
|
75
61
|
// This shouldn't be here as this gets re-created each time we build/propose a block.
|
|
76
62
|
// But we have a number of tests that abuse/rely on this class having a permanent publisher.
|
|
77
63
|
// As long as those tests only configure a single publisher they will continue to work.
|
|
78
64
|
// This will get re-assigned every time the sequencer goes to build a new block to a publisher that is valid
|
|
79
65
|
// for the block proposer.
|
|
66
|
+
// TODO(palla/mbps): Remove this field and fix tests
|
|
80
67
|
publisher;
|
|
81
|
-
|
|
82
|
-
|
|
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;
|
|
83
71
|
// Add [FISHERMAN] prefix to logger if in fisherman mode
|
|
84
|
-
if (
|
|
72
|
+
if (config.fishermanMode) {
|
|
85
73
|
this.log = log.createChild('[FISHERMAN]');
|
|
86
74
|
}
|
|
87
75
|
this.metrics = new SequencerMetrics(telemetry, this.rollupContract, 'Sequencer');
|
|
88
|
-
|
|
89
|
-
this.updateConfig(this.config);
|
|
90
|
-
}
|
|
91
|
-
get tracer() {
|
|
92
|
-
return this.metrics.tracer;
|
|
93
|
-
}
|
|
94
|
-
getValidatorAddresses() {
|
|
95
|
-
return this.validatorClient?.getValidatorAddresses();
|
|
76
|
+
this.updateConfig(config);
|
|
96
77
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* Updates sequencer config by the defined values in the config on input.
|
|
102
|
-
* @param config - New parameters.
|
|
103
|
-
*/ updateConfig(config) {
|
|
104
|
-
this.log.info(`Sequencer config set`, omit(pickFromSchema(config, SequencerConfigSchema), 'txPublicSetupAllowList'));
|
|
105
|
-
if (config.transactionPollingIntervalMS !== undefined) {
|
|
106
|
-
this.pollingIntervalMs = config.transactionPollingIntervalMS;
|
|
107
|
-
}
|
|
108
|
-
if (config.maxTxsPerBlock !== undefined) {
|
|
109
|
-
this.maxTxsPerBlock = config.maxTxsPerBlock;
|
|
110
|
-
}
|
|
111
|
-
if (config.minTxsPerBlock !== undefined) {
|
|
112
|
-
this.minTxsPerBlock = config.minTxsPerBlock;
|
|
113
|
-
}
|
|
114
|
-
if (config.maxDABlockGas !== undefined) {
|
|
115
|
-
this.maxBlockGas = new Gas(config.maxDABlockGas, this.maxBlockGas.l2Gas);
|
|
116
|
-
}
|
|
117
|
-
if (config.maxL2BlockGas !== undefined) {
|
|
118
|
-
this.maxBlockGas = new Gas(this.maxBlockGas.daGas, config.maxL2BlockGas);
|
|
119
|
-
}
|
|
120
|
-
if (config.maxBlockSizeInBytes !== undefined) {
|
|
121
|
-
this.maxBlockSizeInBytes = config.maxBlockSizeInBytes;
|
|
122
|
-
}
|
|
123
|
-
if (config.governanceProposerPayload) {
|
|
124
|
-
this.governanceProposerPayload = config.governanceProposerPayload;
|
|
125
|
-
}
|
|
126
|
-
if (config.maxL1TxInclusionTimeIntoSlot !== undefined) {
|
|
127
|
-
this.maxL1TxInclusionTimeIntoSlot = config.maxL1TxInclusionTimeIntoSlot;
|
|
128
|
-
}
|
|
129
|
-
if (config.enforceTimeTable !== undefined) {
|
|
130
|
-
this.enforceTimeTable = config.enforceTimeTable;
|
|
131
|
-
}
|
|
132
|
-
this.setTimeTable();
|
|
133
|
-
// TODO: Just read everything from the config object as needed instead of copying everything into local vars.
|
|
134
|
-
// Update all values on this.config that are populated in the config object.
|
|
135
|
-
Object.assign(this.config, config);
|
|
136
|
-
}
|
|
137
|
-
setTimeTable() {
|
|
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);
|
|
138
82
|
this.timetable = new SequencerTimetable({
|
|
139
83
|
ethereumSlotDuration: this.l1Constants.ethereumSlotDuration,
|
|
140
84
|
aztecSlotDuration: this.aztecSlotDuration,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
85
|
+
l1PublishingTime: this.l1PublishingTime,
|
|
86
|
+
p2pPropagationTime: this.config.attestationPropagationTime,
|
|
87
|
+
blockDurationMs: this.config.blockDurationMs,
|
|
88
|
+
enforce: this.config.enforceTimeTable
|
|
144
89
|
}, this.metrics, this.log);
|
|
145
90
|
}
|
|
146
|
-
async init() {
|
|
91
|
+
/** Initializes the sequencer (precomputes tables and creates a publisher). Takes about 3s. */ async init() {
|
|
92
|
+
getKzg();
|
|
147
93
|
this.publisher = (await this.publisherFactory.create(undefined)).publisher;
|
|
148
94
|
}
|
|
149
|
-
/**
|
|
150
|
-
|
|
151
|
-
*/ start() {
|
|
152
|
-
this.runningPromise = new RunningPromise(this.safeWork.bind(this), this.log, this.pollingIntervalMs);
|
|
95
|
+
/** Starts the sequencer and moves to IDLE state. */ start() {
|
|
96
|
+
this.runningPromise = new RunningPromise(this.safeWork.bind(this), this.log, this.config.sequencerPollingIntervalMS);
|
|
153
97
|
this.setState(SequencerState.IDLE, undefined, {
|
|
154
98
|
force: true
|
|
155
99
|
});
|
|
156
100
|
this.runningPromise.start();
|
|
157
101
|
this.log.info('Started sequencer');
|
|
158
102
|
}
|
|
159
|
-
/**
|
|
160
|
-
* Stops the sequencer from processing txs and moves to STOPPED state.
|
|
161
|
-
*/ async stop() {
|
|
103
|
+
/** Stops the sequencer from building blocks and moves to STOPPED state. */ async stop() {
|
|
162
104
|
this.log.info(`Stopping sequencer`);
|
|
163
105
|
this.setState(SequencerState.STOPPING, undefined, {
|
|
164
106
|
force: true
|
|
@@ -170,29 +112,81 @@ export { SequencerState };
|
|
|
170
112
|
});
|
|
171
113
|
this.log.info('Stopped sequencer');
|
|
172
114
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/** Returns the current state of the sequencer. */ status() {
|
|
177
141
|
return {
|
|
178
142
|
state: this.state
|
|
179
143
|
};
|
|
180
144
|
}
|
|
181
145
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
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
|
|
188
152
|
*/ async work() {
|
|
189
153
|
this.setState(SequencerState.SYNCHRONIZING, undefined);
|
|
190
|
-
const { slot, ts, now } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
191
|
-
// Check we
|
|
192
|
-
|
|
193
|
-
|
|
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) {
|
|
194
158
|
return;
|
|
195
159
|
}
|
|
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;
|
|
189
|
+
}
|
|
196
190
|
// Check all components are synced to latest as seen by the archiver (queries all subsystems)
|
|
197
191
|
const syncedTo = await this.checkSync({
|
|
198
192
|
ts,
|
|
@@ -203,18 +197,17 @@ export { SequencerState };
|
|
|
203
197
|
slot,
|
|
204
198
|
ts
|
|
205
199
|
});
|
|
206
|
-
return;
|
|
200
|
+
return undefined;
|
|
207
201
|
}
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
const
|
|
202
|
+
// TODO(palla/mbps): Compute proper checkpoint number
|
|
203
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(BlockNumber(syncedTo.blockNumber + 1));
|
|
204
|
+
const logCtx = {
|
|
211
205
|
now,
|
|
212
206
|
syncedToL1Ts: syncedTo.l1Timestamp,
|
|
213
207
|
syncedToL2Slot: getSlotAtTimestamp(syncedTo.l1Timestamp, this.l1Constants),
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
newBlockNumber,
|
|
208
|
+
slot,
|
|
209
|
+
slotTs: ts,
|
|
210
|
+
checkpointNumber,
|
|
218
211
|
isPendingChainValid: pick(syncedTo.pendingChainValidationStatus, 'valid', 'reason', 'invalidIndex')
|
|
219
212
|
};
|
|
220
213
|
// Check that we are a proposer for the next slot
|
|
@@ -223,216 +216,88 @@ export { SequencerState };
|
|
|
223
216
|
// If we are not a proposer check if we should invalidate a invalid block, and bail
|
|
224
217
|
if (!canPropose) {
|
|
225
218
|
await this.considerInvalidatingBlock(syncedTo, slot);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
// In fisherman mode, check if we've already validated this slot to prevent duplicate attempts
|
|
229
|
-
if (this.config.fishermanMode) {
|
|
230
|
-
if (this.lastSlotForValidationBlock === slot) {
|
|
231
|
-
this.log.trace(`Already validated block building for slot ${slot} (skipping)`, {
|
|
232
|
-
slot
|
|
233
|
-
});
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
this.log.debug(`Building validation block for slot ${slot} (actual proposer: ${proposer?.toString() ?? 'none'})`, {
|
|
237
|
-
slot,
|
|
238
|
-
proposer: proposer?.toString()
|
|
239
|
-
});
|
|
240
|
-
// Mark this slot as being validated
|
|
241
|
-
this.lastSlotForValidationBlock = slot;
|
|
219
|
+
return undefined;
|
|
242
220
|
}
|
|
243
221
|
// Check that the slot is not taken by a block already (should never happen, since only us can propose for this slot)
|
|
244
222
|
if (syncedTo.block && syncedTo.block.header.getSlot() >= slot) {
|
|
245
223
|
this.log.warn(`Cannot propose block at next L2 slot ${slot} since that slot was taken by block ${syncedTo.blockNumber}`, {
|
|
246
|
-
...
|
|
224
|
+
...logCtx,
|
|
247
225
|
block: syncedTo.block.header.toInspect()
|
|
248
226
|
});
|
|
249
227
|
this.metrics.recordBlockProposalPrecheckFailed('slot_already_taken');
|
|
250
|
-
return;
|
|
228
|
+
return undefined;
|
|
251
229
|
}
|
|
252
230
|
// We now need to get ourselves a publisher.
|
|
253
231
|
// The returned attestor will be the one we provided if we provided one.
|
|
254
232
|
// Otherwise it will be a valid attestor for the returned publisher.
|
|
255
233
|
// In fisherman mode, pass undefined to use the fisherman's own keystore instead of the actual proposer's
|
|
256
|
-
const
|
|
234
|
+
const proposerForPublisher = this.config.fishermanMode ? undefined : proposer;
|
|
235
|
+
const { attestorAddress, publisher } = await this.publisherFactory.create(proposerForPublisher);
|
|
257
236
|
this.log.verbose(`Created publisher at address ${publisher.getSenderAddress()} for attestor ${attestorAddress}`);
|
|
258
237
|
this.publisher = publisher;
|
|
259
238
|
// In fisherman mode, set the actual proposer's address for simulations
|
|
260
|
-
if (this.config.fishermanMode) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this.log.debug(`Set proposer address ${proposer} for simulation in fisherman mode`);
|
|
264
|
-
}
|
|
239
|
+
if (this.config.fishermanMode && proposer) {
|
|
240
|
+
publisher.setProposerAddressForSimulation(proposer);
|
|
241
|
+
this.log.debug(`Set proposer address ${proposer} for simulation in fisherman mode`);
|
|
265
242
|
}
|
|
266
|
-
// Get proposer credentials
|
|
267
|
-
const coinbase = this.validatorClient.getCoinbaseForAttestor(attestorAddress);
|
|
268
|
-
const feeRecipient = this.validatorClient.getFeeRecipientForAttestor(attestorAddress);
|
|
269
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
|
|
270
245
|
const invalidateBlock = await publisher.simulateInvalidateBlock(syncedTo.pendingChainValidationStatus);
|
|
271
|
-
// Check with the rollup if we can indeed propose at the next L2 slot. This check should not fail
|
|
246
|
+
// Check with the rollup contract if we can indeed propose at the next L2 slot. This check should not fail
|
|
272
247
|
// if all the previous checks are good, but we do it just in case.
|
|
273
|
-
const canProposeCheck = await publisher.canProposeAtNextEthBlock(
|
|
248
|
+
const canProposeCheck = await publisher.canProposeAtNextEthBlock(syncedTo.archive, proposer ?? EthAddress.ZERO, invalidateBlock);
|
|
274
249
|
if (canProposeCheck === undefined) {
|
|
275
|
-
this.log.warn(`Cannot propose
|
|
250
|
+
this.log.warn(`Cannot propose checkpoint ${checkpointNumber} at slot ${slot} due to failed rollup contract check`, logCtx);
|
|
276
251
|
this.emit('proposer-rollup-check-failed', {
|
|
277
|
-
reason: 'Rollup contract check failed'
|
|
252
|
+
reason: 'Rollup contract check failed',
|
|
253
|
+
slot
|
|
278
254
|
});
|
|
279
255
|
this.metrics.recordBlockProposalPrecheckFailed('rollup_contract_check_failed');
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
if (canProposeCheck.slot !== slot) {
|
|
282
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}.`, {
|
|
283
|
-
...
|
|
260
|
+
...logCtx,
|
|
284
261
|
rollup: canProposeCheck,
|
|
285
|
-
newBlockNumber,
|
|
286
262
|
expectedSlot: slot
|
|
287
263
|
});
|
|
288
264
|
this.emit('proposer-rollup-check-failed', {
|
|
289
|
-
reason: 'Slot mismatch'
|
|
265
|
+
reason: 'Slot mismatch',
|
|
266
|
+
slot
|
|
290
267
|
});
|
|
291
268
|
this.metrics.recordBlockProposalPrecheckFailed('slot_mismatch');
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
269
|
+
return undefined;
|
|
270
|
+
}
|
|
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,
|
|
296
274
|
rollup: canProposeCheck,
|
|
297
|
-
newBlockNumber,
|
|
298
275
|
expectedSlot: slot
|
|
299
276
|
});
|
|
300
277
|
this.emit('proposer-rollup-check-failed', {
|
|
301
|
-
reason: 'Block mismatch'
|
|
278
|
+
reason: 'Block mismatch',
|
|
279
|
+
slot
|
|
302
280
|
});
|
|
303
281
|
this.metrics.recordBlockProposalPrecheckFailed('block_number_mismatch');
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
this.log.debug(`Can propose block ${newBlockNumber} at slot ${slot} as ${proposer}`, {
|
|
307
|
-
...syncLogData
|
|
308
|
-
});
|
|
309
|
-
const newGlobalVariables = await this.globalsBuilder.buildGlobalVariables(newBlockNumber, coinbase, feeRecipient, slot);
|
|
310
|
-
// Enqueue governance and slashing votes (returns promises that will be awaited later)
|
|
311
|
-
// In fisherman mode, we simulate slashing but don't actually publish to L1
|
|
312
|
-
const votesPromises = this.enqueueGovernanceAndSlashingVotes(publisher, attestorAddress, slot, newGlobalVariables.timestamp);
|
|
313
|
-
// Enqueues block invalidation
|
|
314
|
-
if (invalidateBlock && !this.config.skipInvalidateBlockAsProposer) {
|
|
315
|
-
publisher.enqueueInvalidateBlock(invalidateBlock);
|
|
316
|
-
}
|
|
317
|
-
// Actual block building
|
|
318
|
-
this.setState(SequencerState.INITIALIZING_PROPOSAL, slot);
|
|
319
|
-
this.metrics.incOpenSlot(slot, proposer?.toString() ?? 'unknown');
|
|
320
|
-
const block = await this.tryBuildBlockAndEnqueuePublish(slot, proposer, newBlockNumber, publisher, newGlobalVariables, chainTipArchive, invalidateBlock);
|
|
321
|
-
// Wait until the voting promises have resolved, so all requests are enqueued
|
|
322
|
-
await Promise.all(votesPromises);
|
|
323
|
-
// In fisherman mode, we don't publish to L1
|
|
324
|
-
if (this.config.fishermanMode) {
|
|
325
|
-
// Clear pending requests
|
|
326
|
-
publisher.clearPendingRequests();
|
|
327
|
-
if (block) {
|
|
328
|
-
this.log.info(`Validation block building SUCCEEDED for slot ${slot}`, {
|
|
329
|
-
blockNumber: newBlockNumber,
|
|
330
|
-
slot: Number(slot),
|
|
331
|
-
archive: block.archive.toString(),
|
|
332
|
-
txCount: block.body.txEffects.length
|
|
333
|
-
});
|
|
334
|
-
this.lastBlockPublished = block;
|
|
335
|
-
this.metrics.recordBlockProposalSuccess();
|
|
336
|
-
} else {
|
|
337
|
-
// Block building failed in fisherman mode
|
|
338
|
-
this.log.warn(`Validation block building FAILED for slot ${slot}`, {
|
|
339
|
-
blockNumber: newBlockNumber,
|
|
340
|
-
slot: Number(slot)
|
|
341
|
-
});
|
|
342
|
-
this.metrics.recordBlockProposalFailed('block_build_failed');
|
|
343
|
-
}
|
|
344
|
-
} else {
|
|
345
|
-
// Normal mode: send the tx to L1
|
|
346
|
-
const l1Response = await publisher.sendRequests();
|
|
347
|
-
const proposedBlock = l1Response?.successfulActions.find((a)=>a === 'propose');
|
|
348
|
-
if (proposedBlock) {
|
|
349
|
-
this.lastBlockPublished = block;
|
|
350
|
-
this.emit('block-published', {
|
|
351
|
-
blockNumber: newBlockNumber,
|
|
352
|
-
slot: Number(slot)
|
|
353
|
-
});
|
|
354
|
-
await this.metrics.incFilledSlot(publisher.getSenderAddress().toString(), coinbase);
|
|
355
|
-
} else if (block) {
|
|
356
|
-
this.emit('block-publish-failed', l1Response ?? {});
|
|
357
|
-
}
|
|
282
|
+
return undefined;
|
|
358
283
|
}
|
|
359
|
-
this.
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
proposer,
|
|
364
|
-
publisher: publisher.getSenderAddress(),
|
|
365
|
-
globalVariables: newGlobalVariables.toInspect(),
|
|
366
|
-
chainTipArchive,
|
|
367
|
-
blockNumber: newBlockNumber,
|
|
368
|
-
slot
|
|
369
|
-
});
|
|
370
|
-
const proposalHeader = CheckpointHeader.from({
|
|
371
|
-
...newGlobalVariables,
|
|
372
|
-
timestamp: newGlobalVariables.timestamp,
|
|
373
|
-
lastArchiveRoot: chainTipArchive,
|
|
374
|
-
blockHeadersHash: Fr.ZERO,
|
|
375
|
-
contentCommitment: ContentCommitment.empty(),
|
|
376
|
-
totalManaUsed: Fr.ZERO
|
|
284
|
+
this.lastSlotForCheckpointProposalJob = slot;
|
|
285
|
+
this.log.info(`Preparing checkpoint proposal ${checkpointNumber} at slot ${slot}`, {
|
|
286
|
+
...logCtx,
|
|
287
|
+
proposer
|
|
377
288
|
});
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
if (pendingTxCount >= this.minTxsPerBlock) {
|
|
381
|
-
// We don't fetch exactly maxTxsPerBlock txs here because we may not need all of them if we hit a limit before,
|
|
382
|
-
// and also we may need to fetch more if we don't have enough valid txs.
|
|
383
|
-
const pendingTxs = this.p2pClient.iteratePendingTxs();
|
|
384
|
-
try {
|
|
385
|
-
block = await this.buildBlockAndEnqueuePublish(pendingTxs, proposalHeader, newGlobalVariables, proposer, invalidateBlock, publisher);
|
|
386
|
-
} catch (err) {
|
|
387
|
-
this.emit('block-build-failed', {
|
|
388
|
-
reason: err.message
|
|
389
|
-
});
|
|
390
|
-
if (err instanceof FormattedViemError) {
|
|
391
|
-
this.log.verbose(`Unable to build/enqueue block ${err.message}`);
|
|
392
|
-
} else {
|
|
393
|
-
this.log.error(`Error building/enqueuing block`, err, {
|
|
394
|
-
blockNumber: newBlockNumber,
|
|
395
|
-
slot
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
this.metrics.recordBlockProposalFailed(err.name || 'unknown_error');
|
|
399
|
-
}
|
|
400
|
-
} else {
|
|
401
|
-
this.log.verbose(`Not enough txs to build block ${newBlockNumber} at slot ${slot} (got ${pendingTxCount} txs, need ${this.minTxsPerBlock})`, {
|
|
402
|
-
chainTipArchive,
|
|
403
|
-
blockNumber: newBlockNumber,
|
|
404
|
-
slot
|
|
405
|
-
});
|
|
406
|
-
this.emit('tx-count-check-failed', {
|
|
407
|
-
minTxs: this.minTxsPerBlock,
|
|
408
|
-
availableTxs: pendingTxCount
|
|
409
|
-
});
|
|
410
|
-
this.metrics.recordBlockProposalFailed('insufficient_txs');
|
|
411
|
-
}
|
|
412
|
-
return block;
|
|
289
|
+
// Create and return the checkpoint proposal job
|
|
290
|
+
return this.createCheckpointProposalJob(slot, checkpointNumber, syncedTo.blockNumber, proposer, publisher, attestorAddress, invalidateBlock);
|
|
413
291
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
await this.work();
|
|
417
|
-
} catch (err) {
|
|
418
|
-
if (err instanceof SequencerTooSlowError) {
|
|
419
|
-
// Log as warn only if we had to abort halfway through the block proposal
|
|
420
|
-
const logLvl = [
|
|
421
|
-
SequencerState.INITIALIZING_PROPOSAL,
|
|
422
|
-
SequencerState.PROPOSER_CHECK
|
|
423
|
-
].includes(err.proposedState) ? 'debug' : 'warn';
|
|
424
|
-
this.log[logLvl](err.message, {
|
|
425
|
-
now: this.dateProvider.nowInSeconds()
|
|
426
|
-
});
|
|
427
|
-
} else {
|
|
428
|
-
// Re-throw other errors
|
|
429
|
-
throw err;
|
|
430
|
-
}
|
|
431
|
-
} finally{
|
|
432
|
-
this.setState(SequencerState.IDLE, undefined);
|
|
433
|
-
}
|
|
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);
|
|
434
294
|
}
|
|
435
|
-
|
|
295
|
+
/**
|
|
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.
|
|
297
|
+
* @param proposedState - The new state to transition to.
|
|
298
|
+
* @param slotNumber - The current slot number.
|
|
299
|
+
* @param force - Whether to force the transition even if the sequencer is stopped.
|
|
300
|
+
*/ setState(proposedState, slotNumber, opts = {}) {
|
|
436
301
|
if (this.state === SequencerState.STOPPING && proposedState !== SequencerState.STOPPED && !opts.force) {
|
|
437
302
|
this.log.warn(`Cannot set sequencer to ${proposedState} as it is stopping.`);
|
|
438
303
|
throw new SequencerInterruptedError();
|
|
@@ -459,220 +324,10 @@ export { SequencerState };
|
|
|
459
324
|
oldState: this.state,
|
|
460
325
|
newState: proposedState,
|
|
461
326
|
secondsIntoSlot,
|
|
462
|
-
slotNumber
|
|
327
|
+
slot: slotNumber
|
|
463
328
|
});
|
|
464
329
|
this.state = proposedState;
|
|
465
330
|
}
|
|
466
|
-
async dropFailedTxsFromP2P(failedTxs) {
|
|
467
|
-
if (failedTxs.length === 0) {
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
const failedTxData = failedTxs.map((fail)=>fail.tx);
|
|
471
|
-
const failedTxHashes = failedTxData.map((tx)=>tx.getTxHash());
|
|
472
|
-
this.log.verbose(`Dropping failed txs ${failedTxHashes.join(', ')}`);
|
|
473
|
-
await this.p2pClient.deleteTxs(failedTxHashes);
|
|
474
|
-
}
|
|
475
|
-
getBlockBuilderOptions(slot) {
|
|
476
|
-
// Deadline for processing depends on whether we're proposing a block
|
|
477
|
-
const secondsIntoSlot = this.getSecondsIntoSlot(slot);
|
|
478
|
-
const processingEndTimeWithinSlot = this.timetable.getBlockProposalExecTimeEnd(secondsIntoSlot);
|
|
479
|
-
// Deadline is only set if enforceTimeTable is enabled.
|
|
480
|
-
const deadline = this.enforceTimeTable ? new Date((this.getSlotStartBuildTimestamp(slot) + processingEndTimeWithinSlot) * 1000) : undefined;
|
|
481
|
-
return {
|
|
482
|
-
maxTransactions: this.maxTxsPerBlock,
|
|
483
|
-
maxBlockSize: this.maxBlockSizeInBytes,
|
|
484
|
-
maxBlockGas: this.maxBlockGas,
|
|
485
|
-
maxBlobFields: BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB,
|
|
486
|
-
deadline
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* @notice Build and propose a block to the chain
|
|
491
|
-
*
|
|
492
|
-
* @dev MUST throw instead of exiting early to ensure that world-state
|
|
493
|
-
* is being rolled back if the block is dropped.
|
|
494
|
-
*
|
|
495
|
-
* @param pendingTxs - Iterable of pending transactions to construct the block from
|
|
496
|
-
* @param proposalHeader - The partial header constructed for the proposal
|
|
497
|
-
* @param newGlobalVariables - The global variables for the new block
|
|
498
|
-
* @param proposerAddress - The address of the proposer
|
|
499
|
-
*/ async buildBlockAndEnqueuePublish(pendingTxs, proposalHeader, newGlobalVariables, proposerAddress, invalidateBlock, publisher) {
|
|
500
|
-
await publisher.validateBlockHeader(proposalHeader, invalidateBlock);
|
|
501
|
-
const blockNumber = newGlobalVariables.blockNumber;
|
|
502
|
-
const slot = proposalHeader.slotNumber;
|
|
503
|
-
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(blockNumber);
|
|
504
|
-
const workTimer = new Timer();
|
|
505
|
-
this.setState(SequencerState.CREATING_BLOCK, slot);
|
|
506
|
-
try {
|
|
507
|
-
const blockBuilderOptions = this.getBlockBuilderOptions(slot);
|
|
508
|
-
const buildBlockRes = await this.blockBuilder.buildBlock(pendingTxs, l1ToL2Messages, newGlobalVariables, blockBuilderOptions);
|
|
509
|
-
const { publicGas, block, publicProcessorDuration, numTxs, numMsgs, blockBuildingTimer, usedTxs, failedTxs } = buildBlockRes;
|
|
510
|
-
const blockBuildDuration = workTimer.ms();
|
|
511
|
-
await this.dropFailedTxsFromP2P(failedTxs);
|
|
512
|
-
const minTxsPerBlock = this.minTxsPerBlock;
|
|
513
|
-
if (numTxs < minTxsPerBlock) {
|
|
514
|
-
this.log.warn(`Block ${blockNumber} has too few txs to be proposed (got ${numTxs} but required ${minTxsPerBlock})`, {
|
|
515
|
-
slot,
|
|
516
|
-
blockNumber,
|
|
517
|
-
numTxs
|
|
518
|
-
});
|
|
519
|
-
throw new Error(`Block has too few successful txs to be proposed`);
|
|
520
|
-
}
|
|
521
|
-
// TODO(@PhilWindle) We should probably periodically check for things like another
|
|
522
|
-
// block being published before ours instead of just waiting on our block
|
|
523
|
-
await publisher.validateBlockHeader(block.getCheckpointHeader(), invalidateBlock);
|
|
524
|
-
const blockStats = {
|
|
525
|
-
eventName: 'l2-block-built',
|
|
526
|
-
creator: proposerAddress?.toString() ?? publisher.getSenderAddress().toString(),
|
|
527
|
-
duration: workTimer.ms(),
|
|
528
|
-
publicProcessDuration: publicProcessorDuration,
|
|
529
|
-
rollupCircuitsDuration: blockBuildingTimer.ms(),
|
|
530
|
-
...block.getStats()
|
|
531
|
-
};
|
|
532
|
-
const blockHash = await block.hash();
|
|
533
|
-
const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
|
|
534
|
-
this.log.info(`Built block ${block.number} for slot ${slot} with ${numTxs} txs and ${numMsgs} messages. ${publicGas.l2Gas / workTimer.s()} mana/s`, {
|
|
535
|
-
blockHash,
|
|
536
|
-
globalVariables: block.header.globalVariables.toInspect(),
|
|
537
|
-
txHashes,
|
|
538
|
-
...blockStats
|
|
539
|
-
});
|
|
540
|
-
// In fisherman mode, skip attestation collection
|
|
541
|
-
let attestationsAndSigners;
|
|
542
|
-
if (this.config.fishermanMode) {
|
|
543
|
-
this.log.debug('Skipping attestation collection');
|
|
544
|
-
attestationsAndSigners = CommitteeAttestationsAndSigners.empty();
|
|
545
|
-
} else {
|
|
546
|
-
this.log.debug('Collecting attestations');
|
|
547
|
-
attestationsAndSigners = await this.collectAttestations(block, usedTxs, proposerAddress);
|
|
548
|
-
this.log.verbose(`Collected ${attestationsAndSigners.attestations.length} attestations for block ${blockNumber} at slot ${slot}`, {
|
|
549
|
-
blockHash,
|
|
550
|
-
blockNumber,
|
|
551
|
-
slot
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
// In fisherman mode, skip attestation signing
|
|
555
|
-
const attestationsAndSignersSignature = this.config.fishermanMode || !this.validatorClient ? Signature.empty() : await this.validatorClient.signAttestationsAndSigners(attestationsAndSigners, proposerAddress ?? publisher.getSenderAddress());
|
|
556
|
-
await this.enqueuePublishL2Block(block, attestationsAndSigners, attestationsAndSignersSignature, invalidateBlock, publisher);
|
|
557
|
-
this.metrics.recordBuiltBlock(blockBuildDuration, publicGas.l2Gas);
|
|
558
|
-
return block;
|
|
559
|
-
} catch (err) {
|
|
560
|
-
this.metrics.recordFailedBlock();
|
|
561
|
-
throw err;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
async collectAttestations(block, txs, proposerAddress) {
|
|
565
|
-
const { committee, seed, epoch } = await this.epochCache.getCommittee(block.slot);
|
|
566
|
-
// We checked above that the committee is defined, so this should never happen.
|
|
567
|
-
if (!committee) {
|
|
568
|
-
throw new Error('No committee when collecting attestations');
|
|
569
|
-
}
|
|
570
|
-
if (committee.length === 0) {
|
|
571
|
-
this.log.verbose(`Attesting committee is empty`);
|
|
572
|
-
return CommitteeAttestationsAndSigners.empty();
|
|
573
|
-
} else {
|
|
574
|
-
this.log.debug(`Attesting committee length is ${committee.length}`);
|
|
575
|
-
}
|
|
576
|
-
if (!this.validatorClient) {
|
|
577
|
-
throw new Error('Missing validator client: Cannot collect attestations');
|
|
578
|
-
}
|
|
579
|
-
const numberOfRequiredAttestations = Math.floor(committee.length * 2 / 3) + 1;
|
|
580
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
581
|
-
this.setState(SequencerState.COLLECTING_ATTESTATIONS, slotNumber);
|
|
582
|
-
this.log.debug('Creating block proposal for validators');
|
|
583
|
-
const blockProposalOptions = {
|
|
584
|
-
publishFullTxs: !!this.config.publishTxsWithProposals,
|
|
585
|
-
broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal
|
|
586
|
-
};
|
|
587
|
-
const proposal = await this.validatorClient.createBlockProposal(block.header.globalVariables.blockNumber, block.getCheckpointHeader(), block.archive.root, txs, proposerAddress, blockProposalOptions);
|
|
588
|
-
if (!proposal) {
|
|
589
|
-
throw new Error(`Failed to create block proposal`);
|
|
590
|
-
}
|
|
591
|
-
if (this.config.skipCollectingAttestations) {
|
|
592
|
-
this.log.warn('Skipping attestation collection as per config (attesting with own keys only)');
|
|
593
|
-
const attestations = await this.validatorClient?.collectOwnAttestations(proposal);
|
|
594
|
-
return new CommitteeAttestationsAndSigners(orderAttestations(attestations ?? [], committee));
|
|
595
|
-
}
|
|
596
|
-
this.log.debug('Broadcasting block proposal to validators');
|
|
597
|
-
await this.validatorClient.broadcastBlockProposal(proposal);
|
|
598
|
-
const attestationTimeAllowed = this.enforceTimeTable ? this.timetable.getMaxAllowedTime(SequencerState.PUBLISHING_BLOCK) : this.aztecSlotDuration;
|
|
599
|
-
this.metrics.recordRequiredAttestations(numberOfRequiredAttestations, attestationTimeAllowed);
|
|
600
|
-
const timer = new Timer();
|
|
601
|
-
let collectedAttestationsCount = 0;
|
|
602
|
-
try {
|
|
603
|
-
const attestationDeadline = new Date(this.dateProvider.now() + attestationTimeAllowed * 1000);
|
|
604
|
-
const attestations = await this.validatorClient.collectAttestations(proposal, numberOfRequiredAttestations, attestationDeadline);
|
|
605
|
-
collectedAttestationsCount = attestations.length;
|
|
606
|
-
// note: the smart contract requires that the signatures are provided in the order of the committee
|
|
607
|
-
const sorted = orderAttestations(attestations, committee);
|
|
608
|
-
// manipulate the attestations if we've been configured to do so
|
|
609
|
-
if (this.config.injectFakeAttestation || this.config.shuffleAttestationOrdering) {
|
|
610
|
-
return this.manipulateAttestations(block, epoch, seed, committee, sorted);
|
|
611
|
-
}
|
|
612
|
-
return new CommitteeAttestationsAndSigners(sorted);
|
|
613
|
-
} catch (err) {
|
|
614
|
-
if (err && err instanceof AttestationTimeoutError) {
|
|
615
|
-
collectedAttestationsCount = err.collectedCount;
|
|
616
|
-
}
|
|
617
|
-
throw err;
|
|
618
|
-
} finally{
|
|
619
|
-
this.metrics.recordCollectedAttestations(collectedAttestationsCount, timer.ms());
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
/** Breaks the attestations before publishing based on attack configs */ manipulateAttestations(block, epoch, seed, committee, attestations) {
|
|
623
|
-
// Compute the proposer index in the committee, since we dont want to tweak it.
|
|
624
|
-
// Otherwise, the L1 rollup contract will reject the block outright.
|
|
625
|
-
const proposerIndex = Number(this.epochCache.computeProposerIndex(block.slot, epoch, seed, BigInt(committee.length)));
|
|
626
|
-
if (this.config.injectFakeAttestation) {
|
|
627
|
-
// Find non-empty attestations that are not from the proposer
|
|
628
|
-
const nonProposerIndices = [];
|
|
629
|
-
for(let i = 0; i < attestations.length; i++){
|
|
630
|
-
if (!attestations[i].signature.isEmpty() && i !== proposerIndex) {
|
|
631
|
-
nonProposerIndices.push(i);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
if (nonProposerIndices.length > 0) {
|
|
635
|
-
const targetIndex = nonProposerIndices[randomInt(nonProposerIndices.length)];
|
|
636
|
-
this.log.warn(`Injecting fake attestation in block ${block.number} at index ${targetIndex}`);
|
|
637
|
-
unfreeze(attestations[targetIndex]).signature = Signature.random();
|
|
638
|
-
}
|
|
639
|
-
return new CommitteeAttestationsAndSigners(attestations);
|
|
640
|
-
}
|
|
641
|
-
if (this.config.shuffleAttestationOrdering) {
|
|
642
|
-
this.log.warn(`Shuffling attestation ordering in block ${block.number} (proposer index ${proposerIndex})`);
|
|
643
|
-
const shuffled = [
|
|
644
|
-
...attestations
|
|
645
|
-
];
|
|
646
|
-
const [i, j] = [
|
|
647
|
-
(proposerIndex + 1) % shuffled.length,
|
|
648
|
-
(proposerIndex + 2) % shuffled.length
|
|
649
|
-
];
|
|
650
|
-
const valueI = shuffled[i];
|
|
651
|
-
const valueJ = shuffled[j];
|
|
652
|
-
shuffled[i] = valueJ;
|
|
653
|
-
shuffled[j] = valueI;
|
|
654
|
-
const signers = new CommitteeAttestationsAndSigners(attestations).getSigners();
|
|
655
|
-
return new MaliciousCommitteeAttestationsAndSigners(shuffled, signers);
|
|
656
|
-
}
|
|
657
|
-
return new CommitteeAttestationsAndSigners(attestations);
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* Publishes the L2Block to the rollup contract.
|
|
661
|
-
* @param block - The L2Block to be published.
|
|
662
|
-
*/ async enqueuePublishL2Block(block, attestationsAndSigners, attestationsAndSignersSignature, invalidateBlock, publisher) {
|
|
663
|
-
// Publishes new block to the network and awaits the tx to be mined
|
|
664
|
-
this.setState(SequencerState.PUBLISHING_BLOCK, block.header.globalVariables.slotNumber);
|
|
665
|
-
// Time out tx at the end of the slot
|
|
666
|
-
const slot = block.header.globalVariables.slotNumber;
|
|
667
|
-
const txTimeoutAt = new Date((this.getSlotStartBuildTimestamp(slot) + this.aztecSlotDuration) * 1000);
|
|
668
|
-
const enqueued = await publisher.enqueueProposeL2Block(block, attestationsAndSigners, attestationsAndSignersSignature, {
|
|
669
|
-
txTimeoutAt,
|
|
670
|
-
forcePendingBlockNumber: invalidateBlock?.forcePendingBlockNumber
|
|
671
|
-
});
|
|
672
|
-
if (!enqueued) {
|
|
673
|
-
throw new Error(`Failed to enqueue publish of block ${block.number}`);
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
331
|
/**
|
|
677
332
|
* Returns whether all dependencies have caught up.
|
|
678
333
|
* We don't check against the previous block submitted since it may have been reorg'd out.
|
|
@@ -701,9 +356,9 @@ export { SequencerState };
|
|
|
701
356
|
this.l2BlockSource.getPendingChainValidationStatus()
|
|
702
357
|
]);
|
|
703
358
|
const [worldState, l2BlockSource, p2p, l1ToL2MessageSource, pendingChainValidationStatus] = syncedBlocks;
|
|
704
|
-
//
|
|
705
|
-
//
|
|
706
|
-
const result = l2BlockSource.
|
|
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;
|
|
707
362
|
if (!result) {
|
|
708
363
|
this.log.debug(`Sequencer sync check failed`, {
|
|
709
364
|
worldState,
|
|
@@ -718,13 +373,13 @@ export { SequencerState };
|
|
|
718
373
|
if (blockNumber < INITIAL_L2_BLOCK_NUM) {
|
|
719
374
|
const archive = new Fr((await this.worldState.getCommitted().getTreeInfo(MerkleTreeId.ARCHIVE)).root);
|
|
720
375
|
return {
|
|
721
|
-
blockNumber: INITIAL_L2_BLOCK_NUM - 1,
|
|
376
|
+
blockNumber: BlockNumber(INITIAL_L2_BLOCK_NUM - 1),
|
|
722
377
|
archive,
|
|
723
378
|
l1Timestamp,
|
|
724
379
|
pendingChainValidationStatus
|
|
725
380
|
};
|
|
726
381
|
}
|
|
727
|
-
const block = await this.l2BlockSource.
|
|
382
|
+
const block = await this.l2BlockSource.getL2BlockNew(blockNumber);
|
|
728
383
|
if (!block) {
|
|
729
384
|
// this shouldn't really happen because a moment ago we checked that all components were in sync
|
|
730
385
|
this.log.error(`Failed to get L2 block ${blockNumber} from the archiver with all components in sync`);
|
|
@@ -739,52 +394,6 @@ export { SequencerState };
|
|
|
739
394
|
};
|
|
740
395
|
}
|
|
741
396
|
/**
|
|
742
|
-
* Enqueues governance and slashing votes with the publisher. Does not block.
|
|
743
|
-
* @param publisher - The publisher to enqueue votes with
|
|
744
|
-
* @param attestorAddress - The attestor address to use for signing
|
|
745
|
-
* @param slot - The slot number
|
|
746
|
-
* @param timestamp - The timestamp for the votes
|
|
747
|
-
* @param context - Optional context for logging (e.g., block number)
|
|
748
|
-
* @returns A tuple of [governanceEnqueued, slashingEnqueued]
|
|
749
|
-
*/ enqueueGovernanceAndSlashingVotes(publisher, attestorAddress, slot, timestamp) {
|
|
750
|
-
try {
|
|
751
|
-
const signerFn = (msg)=>this.validatorClient.signWithAddress(attestorAddress, msg).then((s)=>s.toString());
|
|
752
|
-
const enqueueGovernancePromise = this.governanceProposerPayload && !this.governanceProposerPayload.isZero() ? publisher.enqueueGovernanceCastSignal(this.governanceProposerPayload, slot, timestamp, attestorAddress, signerFn).catch((err)=>{
|
|
753
|
-
this.log.error(`Error enqueuing governance vote`, err, {
|
|
754
|
-
slot
|
|
755
|
-
});
|
|
756
|
-
return false;
|
|
757
|
-
}) : undefined;
|
|
758
|
-
const enqueueSlashingPromise = this.slasherClient ? this.slasherClient.getProposerActions(slot).then((actions)=>{
|
|
759
|
-
// Record metrics for fisherman mode
|
|
760
|
-
if (this.config.fishermanMode && actions.length > 0) {
|
|
761
|
-
this.log.debug(`Fisherman mode: simulating ${actions.length} slashing action(s) for slot ${slot}`, {
|
|
762
|
-
slot,
|
|
763
|
-
actionCount: actions.length
|
|
764
|
-
});
|
|
765
|
-
this.metrics.recordSlashingAttempt(actions.length);
|
|
766
|
-
}
|
|
767
|
-
// Enqueue the actions to fully simulate L1 tx building (they won't be sent in fisherman mode)
|
|
768
|
-
return publisher.enqueueSlashingActions(actions, slot, timestamp, attestorAddress, signerFn);
|
|
769
|
-
}).catch((err)=>{
|
|
770
|
-
this.log.error(`Error enqueuing slashing actions`, err, {
|
|
771
|
-
slot
|
|
772
|
-
});
|
|
773
|
-
return false;
|
|
774
|
-
}) : undefined;
|
|
775
|
-
return [
|
|
776
|
-
enqueueGovernancePromise,
|
|
777
|
-
enqueueSlashingPromise
|
|
778
|
-
];
|
|
779
|
-
} catch (err) {
|
|
780
|
-
this.log.error(`Error enqueueing governance and slashing votes`, err);
|
|
781
|
-
return [
|
|
782
|
-
undefined,
|
|
783
|
-
undefined
|
|
784
|
-
];
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
397
|
* Checks if we are the proposer for the next slot.
|
|
789
398
|
* @returns True if we can propose, and the proposer address (undefined if anyone can propose)
|
|
790
399
|
*/ async checkCanPropose(slot) {
|
|
@@ -840,32 +449,32 @@ export { SequencerState };
|
|
|
840
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.
|
|
841
450
|
* This allows the sequencer to participate in governance/slashing votes even when it cannot build blocks.
|
|
842
451
|
*/ async tryVoteWhenSyncFails(args) {
|
|
843
|
-
const { slot
|
|
452
|
+
const { slot } = args;
|
|
844
453
|
// Prevent duplicate attempts in the same slot
|
|
845
454
|
if (this.lastSlotForVoteWhenSyncFailed === slot) {
|
|
846
|
-
this.log.
|
|
455
|
+
this.log.trace(`Already attempted to vote in slot ${slot} (skipping)`);
|
|
847
456
|
return;
|
|
848
457
|
}
|
|
849
458
|
// Check if we're past the max time for initializing a proposal
|
|
850
459
|
const secondsIntoSlot = this.getSecondsIntoSlot(slot);
|
|
851
|
-
const maxAllowedTime = this.timetable.getMaxAllowedTime(SequencerState.
|
|
460
|
+
const maxAllowedTime = this.timetable.getMaxAllowedTime(SequencerState.INITIALIZING_CHECKPOINT);
|
|
852
461
|
// If we haven't exceeded the time limit for initializing a proposal, don't proceed with voting
|
|
853
462
|
// We use INITIALIZING_PROPOSAL time limit because if we're past that, we can't build a block anyway
|
|
854
463
|
if (maxAllowedTime === undefined || secondsIntoSlot <= maxAllowedTime) {
|
|
855
|
-
this.log.trace(`Not attempting to vote since there is still for block building`, {
|
|
464
|
+
this.log.trace(`Not attempting to vote since there is still time for block building`, {
|
|
856
465
|
secondsIntoSlot,
|
|
857
466
|
maxAllowedTime
|
|
858
467
|
});
|
|
859
468
|
return;
|
|
860
469
|
}
|
|
861
|
-
this.log.
|
|
470
|
+
this.log.trace(`Sync for slot ${slot} failed, checking for voting opportunities`, {
|
|
862
471
|
secondsIntoSlot,
|
|
863
472
|
maxAllowedTime
|
|
864
473
|
});
|
|
865
474
|
// Check if we're a proposer or proposal is open
|
|
866
475
|
const [canPropose, proposer] = await this.checkCanPropose(slot);
|
|
867
476
|
if (!canPropose) {
|
|
868
|
-
this.log.
|
|
477
|
+
this.log.trace(`Cannot vote in slot ${slot} since we are not a proposer`, {
|
|
869
478
|
slot,
|
|
870
479
|
proposer
|
|
871
480
|
});
|
|
@@ -879,10 +488,11 @@ export { SequencerState };
|
|
|
879
488
|
attestorAddress,
|
|
880
489
|
slot
|
|
881
490
|
});
|
|
882
|
-
// Enqueue governance and slashing votes
|
|
883
|
-
const
|
|
884
|
-
|
|
885
|
-
|
|
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)) {
|
|
886
496
|
this.log.debug(`No votes to enqueue for slot ${slot}`);
|
|
887
497
|
return;
|
|
888
498
|
}
|
|
@@ -901,7 +511,6 @@ export { SequencerState };
|
|
|
901
511
|
if (pendingChainValidationStatus.valid) {
|
|
902
512
|
return;
|
|
903
513
|
}
|
|
904
|
-
const { publisher } = await this.publisherFactory.create(undefined);
|
|
905
514
|
const invalidBlockNumber = pendingChainValidationStatus.block.blockNumber;
|
|
906
515
|
const invalidBlockTimestamp = pendingChainValidationStatus.block.timestamp;
|
|
907
516
|
const timeSinceChainInvalid = this.dateProvider.nowInSeconds() - Number(invalidBlockTimestamp);
|
|
@@ -923,6 +532,21 @@ export { SequencerState };
|
|
|
923
532
|
this.log.debug(`Not invalidating pending chain`, logData);
|
|
924
533
|
return;
|
|
925
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];
|
|
544
|
+
}
|
|
545
|
+
} else {
|
|
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);
|
|
926
550
|
const invalidateBlock = await publisher.simulateInvalidateBlock(pendingChainValidationStatus);
|
|
927
551
|
if (!invalidateBlock) {
|
|
928
552
|
this.log.warn(`Failed to simulate invalidate block`, logData);
|
|
@@ -937,6 +561,32 @@ export { SequencerState };
|
|
|
937
561
|
publisher.clearPendingRequests();
|
|
938
562
|
}
|
|
939
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;
|
|
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
|
+
});
|
|
589
|
+
}
|
|
940
590
|
getSlotStartBuildTimestamp(slotNumber) {
|
|
941
591
|
return getSlotStartBuildTimestamp(slotNumber, this.l1Constants);
|
|
942
592
|
}
|
|
@@ -953,24 +603,19 @@ export { SequencerState };
|
|
|
953
603
|
getSlasherClient() {
|
|
954
604
|
return this.slasherClient;
|
|
955
605
|
}
|
|
606
|
+
get tracer() {
|
|
607
|
+
return this.metrics.tracer;
|
|
608
|
+
}
|
|
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;
|
|
617
|
+
}
|
|
956
618
|
}
|
|
957
619
|
_ts_decorate([
|
|
958
620
|
trackSpan('Sequencer.work')
|
|
959
621
|
], Sequencer.prototype, "safeWork", null);
|
|
960
|
-
_ts_decorate([
|
|
961
|
-
trackSpan('Sequencer.buildBlockAndEnqueuePublish', (_validTxs, _proposalHeader, newGlobalVariables)=>({
|
|
962
|
-
[Attributes.BLOCK_NUMBER]: newGlobalVariables.blockNumber
|
|
963
|
-
}))
|
|
964
|
-
], Sequencer.prototype, "buildBlockAndEnqueuePublish", null);
|
|
965
|
-
_ts_decorate([
|
|
966
|
-
trackSpan('Sequencer.collectAttestations', (block, txHashes)=>({
|
|
967
|
-
[Attributes.BLOCK_NUMBER]: block.number,
|
|
968
|
-
[Attributes.BLOCK_ARCHIVE]: block.archive.toString(),
|
|
969
|
-
[Attributes.BLOCK_TXS_COUNT]: txHashes.length
|
|
970
|
-
}))
|
|
971
|
-
], Sequencer.prototype, "collectAttestations", null);
|
|
972
|
-
_ts_decorate([
|
|
973
|
-
trackSpan('Sequencer.enqueuePublishL2Block', (block)=>({
|
|
974
|
-
[Attributes.BLOCK_NUMBER]: block.number
|
|
975
|
-
}))
|
|
976
|
-
], Sequencer.prototype, "enqueuePublishL2Block", null);
|