@aztec/sequencer-client 0.0.1-commit.e2b2873ed → 0.0.1-commit.e304674f1
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 +15 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +60 -30
- package/dest/config.d.ts +26 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +44 -21
- package/dest/global_variable_builder/global_builder.d.ts +15 -11
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +29 -25
- package/dest/global_variable_builder/index.d.ts +2 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +47 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +121 -42
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +27 -3
- package/dest/publisher/sequencer-publisher.d.ts +82 -37
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +430 -118
- package/dest/sequencer/checkpoint_proposal_job.d.ts +36 -9
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +361 -192
- package/dest/sequencer/checkpoint_voter.d.ts +1 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +2 -5
- package/dest/sequencer/events.d.ts +2 -1
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +21 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +97 -15
- package/dest/sequencer/sequencer.d.ts +40 -17
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +152 -95
- package/dest/sequencer/timetable.d.ts +7 -3
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +21 -12
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +3 -5
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +11 -11
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +45 -34
- package/dest/test/utils.d.ts +3 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +5 -4
- package/package.json +27 -28
- package/src/client/sequencer-client.ts +76 -30
- package/src/config.ts +56 -27
- package/src/global_variable_builder/global_builder.ts +38 -27
- package/src/global_variable_builder/index.ts +1 -1
- package/src/publisher/config.ts +153 -43
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-publisher-factory.ts +38 -9
- package/src/publisher/sequencer-publisher.ts +503 -168
- package/src/sequencer/README.md +81 -12
- package/src/sequencer/checkpoint_proposal_job.ts +471 -201
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/events.ts +1 -1
- package/src/sequencer/metrics.ts +106 -18
- package/src/sequencer/sequencer.ts +216 -109
- package/src/sequencer/timetable.ts +26 -15
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +63 -49
- package/src/test/utils.ts +5 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { NUM_CHECKPOINT_END_MARKER_FIELDS, getNumBlockEndBlobFields } from '@aztec/blob-lib/encoding';
|
|
2
|
-
import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB } from '@aztec/constants';
|
|
3
1
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
+
import { type FeeHeader, RollupContract } from '@aztec/ethereum/contracts';
|
|
4
3
|
import {
|
|
5
4
|
BlockNumber,
|
|
6
5
|
CheckpointNumber,
|
|
@@ -9,6 +8,11 @@ import {
|
|
|
9
8
|
SlotNumber,
|
|
10
9
|
} from '@aztec/foundation/branded-types';
|
|
11
10
|
import { randomInt } from '@aztec/foundation/crypto/random';
|
|
11
|
+
import {
|
|
12
|
+
flipSignature,
|
|
13
|
+
generateRecoverableSignature,
|
|
14
|
+
generateUnrecoverableSignature,
|
|
15
|
+
} from '@aztec/foundation/crypto/secp256k1-signer';
|
|
12
16
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
17
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
18
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
@@ -27,18 +31,23 @@ import {
|
|
|
27
31
|
type L2BlockSource,
|
|
28
32
|
MaliciousCommitteeAttestationsAndSigners,
|
|
29
33
|
} from '@aztec/stdlib/block';
|
|
30
|
-
import type
|
|
31
|
-
import { getSlotStartBuildTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
34
|
+
import { type Checkpoint, type ProposedCheckpointData, validateCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
35
|
+
import { computeQuorum, getSlotStartBuildTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
32
36
|
import { Gas } from '@aztec/stdlib/gas';
|
|
33
37
|
import {
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
type BlockBuilderOptions,
|
|
39
|
+
InsufficientValidTxsError,
|
|
36
40
|
type ResolvedSequencerConfig,
|
|
37
41
|
type WorldStateSynchronizer,
|
|
38
42
|
} from '@aztec/stdlib/interfaces/server';
|
|
39
43
|
import { type L1ToL2MessageSource, computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
40
|
-
import type {
|
|
41
|
-
|
|
44
|
+
import type {
|
|
45
|
+
BlockProposal,
|
|
46
|
+
BlockProposalOptions,
|
|
47
|
+
CheckpointProposal,
|
|
48
|
+
CheckpointProposalOptions,
|
|
49
|
+
} from '@aztec/stdlib/p2p';
|
|
50
|
+
import { orderAttestations, trimAttestations } from '@aztec/stdlib/p2p';
|
|
42
51
|
import type { L2BlockBuiltStats } from '@aztec/stdlib/stats';
|
|
43
52
|
import { type FailedTx, Tx } from '@aztec/stdlib/tx';
|
|
44
53
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
@@ -59,6 +68,13 @@ import { SequencerState } from './utils.js';
|
|
|
59
68
|
/** How much time to sleep while waiting for min transactions to accumulate for a block */
|
|
60
69
|
const TXS_POLLING_MS = 500;
|
|
61
70
|
|
|
71
|
+
/** Result from proposeCheckpoint when a checkpoint was successfully built and attested. */
|
|
72
|
+
type CheckpointProposalResult = {
|
|
73
|
+
checkpoint: Checkpoint;
|
|
74
|
+
attestations: CommitteeAttestationsAndSigners;
|
|
75
|
+
attestationsSignature: Signature;
|
|
76
|
+
};
|
|
77
|
+
|
|
62
78
|
/**
|
|
63
79
|
* Handles the execution of a checkpoint proposal after the initial preparation phase.
|
|
64
80
|
* This includes building blocks, collecting attestations, and publishing the checkpoint to L1,
|
|
@@ -68,9 +84,16 @@ const TXS_POLLING_MS = 500;
|
|
|
68
84
|
export class CheckpointProposalJob implements Traceable {
|
|
69
85
|
protected readonly log: Logger;
|
|
70
86
|
|
|
87
|
+
/** Tracks the fire-and-forget L1 submission promise so it can be awaited during shutdown. */
|
|
88
|
+
private pendingL1Submission: Promise<void> | undefined;
|
|
89
|
+
|
|
90
|
+
/** Fee header override computed during proposeCheckpoint, reused in enqueueCheckpointForSubmission. */
|
|
91
|
+
private computedForceProposedFeeHeader?: { checkpointNumber: CheckpointNumber; feeHeader: FeeHeader };
|
|
92
|
+
|
|
71
93
|
constructor(
|
|
72
|
-
private readonly
|
|
73
|
-
private readonly
|
|
94
|
+
private readonly slotNow: SlotNumber,
|
|
95
|
+
private readonly targetSlot: SlotNumber,
|
|
96
|
+
private readonly targetEpoch: EpochNumber,
|
|
74
97
|
private readonly checkpointNumber: CheckpointNumber,
|
|
75
98
|
private readonly syncedToBlockNumber: BlockNumber,
|
|
76
99
|
// TODO(palla/mbps): Can we remove the proposer in favor of attestorAddress? Need to check fisherman-node flows.
|
|
@@ -97,13 +120,25 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
97
120
|
private readonly setStateFn: (state: SequencerState, slot?: SlotNumber) => void,
|
|
98
121
|
public readonly tracer: Tracer,
|
|
99
122
|
bindings?: LoggerBindings,
|
|
123
|
+
private readonly proposedCheckpointData?: ProposedCheckpointData,
|
|
100
124
|
) {
|
|
101
|
-
this.log = createLogger('sequencer:checkpoint-proposal', {
|
|
125
|
+
this.log = createLogger('sequencer:checkpoint-proposal', {
|
|
126
|
+
...bindings,
|
|
127
|
+
instanceId: `slot-${this.slotNow}`,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Awaits the pending L1 submission if one is in progress. Call during shutdown. */
|
|
132
|
+
public async awaitPendingSubmission(): Promise<void> {
|
|
133
|
+
this.log.info('Awaiting pending L1 payload submission');
|
|
134
|
+
await this.pendingL1Submission;
|
|
102
135
|
}
|
|
103
136
|
|
|
104
137
|
/**
|
|
105
138
|
* Executes the checkpoint proposal job.
|
|
106
|
-
*
|
|
139
|
+
* Builds blocks, collects attestations, enqueues requests, and schedules L1 submission as a
|
|
140
|
+
* background task so the work loop can return to IDLE immediately.
|
|
141
|
+
* Returns the built checkpoint if successful, undefined otherwise.
|
|
107
142
|
*/
|
|
108
143
|
@trackSpan('CheckpointProposalJob.execute')
|
|
109
144
|
public async execute(): Promise<Checkpoint | undefined> {
|
|
@@ -111,7 +146,7 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
111
146
|
// In fisherman mode, we simulate slashing but don't actually publish to L1
|
|
112
147
|
// These are constant for the whole slot, so we only enqueue them once
|
|
113
148
|
const votesPromises = new CheckpointVoter(
|
|
114
|
-
this.
|
|
149
|
+
this.targetSlot,
|
|
115
150
|
this.publisher,
|
|
116
151
|
this.attestorAddress,
|
|
117
152
|
this.validatorClient,
|
|
@@ -122,14 +157,16 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
122
157
|
this.log,
|
|
123
158
|
).enqueueVotes();
|
|
124
159
|
|
|
125
|
-
// Build and propose the checkpoint.
|
|
126
|
-
|
|
160
|
+
// Build and propose the checkpoint. Builds blocks, broadcasts, collects attestations, and signs.
|
|
161
|
+
// Does NOT enqueue to L1 yet — that happens after the pipeline sleep.
|
|
162
|
+
const proposalResult = await this.proposeCheckpoint();
|
|
163
|
+
const checkpoint = proposalResult?.checkpoint;
|
|
127
164
|
|
|
128
165
|
// Wait until the voting promises have resolved, so all requests are enqueued (not sent)
|
|
129
166
|
await Promise.all(votesPromises);
|
|
130
167
|
|
|
131
168
|
if (checkpoint) {
|
|
132
|
-
this.metrics.
|
|
169
|
+
this.metrics.recordCheckpointProposalSuccess();
|
|
133
170
|
}
|
|
134
171
|
|
|
135
172
|
// Do not post anything to L1 if we are fishermen, but do perform L1 fee analysis
|
|
@@ -138,47 +175,133 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
138
175
|
return;
|
|
139
176
|
}
|
|
140
177
|
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
} else if (checkpoint) {
|
|
150
|
-
this.eventEmitter.emit('checkpoint-publish-failed', { ...l1Response, slot: this.slot });
|
|
151
|
-
return undefined;
|
|
178
|
+
// Enqueue the checkpoint for L1 submission
|
|
179
|
+
if (proposalResult) {
|
|
180
|
+
try {
|
|
181
|
+
await this.enqueueCheckpointForSubmission(proposalResult);
|
|
182
|
+
} catch (err) {
|
|
183
|
+
this.log.error(`Failed to enqueue checkpoint for L1 submission at slot ${this.targetSlot}`, err);
|
|
184
|
+
// Continue to sendRequestsAt so votes are still sent
|
|
185
|
+
}
|
|
152
186
|
}
|
|
187
|
+
|
|
188
|
+
// Compute the earliest time to submit: pipeline slot start when pipelining, now otherwise.
|
|
189
|
+
const submitAfter = this.epochCache.isProposerPipeliningEnabled()
|
|
190
|
+
? new Date(Number(getTimestampForSlot(this.targetSlot, this.l1Constants)) * 1000)
|
|
191
|
+
: new Date(this.dateProvider.now());
|
|
192
|
+
|
|
193
|
+
// Schedule L1 submission in the background so the work loop returns immediately.
|
|
194
|
+
// The publisher will sleep until submitAfter, then send the bundled requests.
|
|
195
|
+
// The promise is stored so it can be awaited during shutdown.
|
|
196
|
+
this.pendingL1Submission = this.publisher
|
|
197
|
+
.sendRequestsAt(submitAfter)
|
|
198
|
+
.then(async l1Response => {
|
|
199
|
+
const proposedAction = l1Response?.successfulActions.find(a => a === 'propose');
|
|
200
|
+
if (proposedAction) {
|
|
201
|
+
this.eventEmitter.emit('checkpoint-published', { checkpoint: this.checkpointNumber, slot: this.targetSlot });
|
|
202
|
+
const coinbase = checkpoint?.header.coinbase;
|
|
203
|
+
await this.metrics.incFilledSlot(this.publisher.getSenderAddress().toString(), coinbase);
|
|
204
|
+
} else if (checkpoint) {
|
|
205
|
+
this.eventEmitter.emit('checkpoint-publish-failed', { ...l1Response, slot: this.targetSlot });
|
|
206
|
+
|
|
207
|
+
if (this.epochCache.isProposerPipeliningEnabled()) {
|
|
208
|
+
this.metrics.recordPipelineDiscard();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
.catch(err => {
|
|
213
|
+
this.log.error(`Background L1 submission failed for slot ${this.targetSlot}`, err);
|
|
214
|
+
if (checkpoint) {
|
|
215
|
+
this.eventEmitter.emit('checkpoint-publish-failed', { slot: this.targetSlot });
|
|
216
|
+
|
|
217
|
+
if (this.epochCache.isProposerPipeliningEnabled()) {
|
|
218
|
+
this.metrics.recordPipelineDiscard();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// Return the built checkpoint immediately — the work loop is now unblocked
|
|
224
|
+
return checkpoint;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Enqueues the checkpoint for L1 submission. Called after pipeline sleep in execute(). */
|
|
228
|
+
private async enqueueCheckpointForSubmission(result: CheckpointProposalResult): Promise<void> {
|
|
229
|
+
const { checkpoint, attestations, attestationsSignature } = result;
|
|
230
|
+
|
|
231
|
+
this.setStateFn(SequencerState.PUBLISHING_CHECKPOINT, this.targetSlot);
|
|
232
|
+
const aztecSlotDuration = this.l1Constants.slotDuration;
|
|
233
|
+
const submissionSlotStart = Number(getTimestampForSlot(this.targetSlot, this.l1Constants));
|
|
234
|
+
const txTimeoutAt = new Date((submissionSlotStart + aztecSlotDuration) * 1000);
|
|
235
|
+
|
|
236
|
+
// If we have been configured to potentially skip publishing checkpoint then roll the dice here
|
|
237
|
+
if (
|
|
238
|
+
this.config.skipPublishingCheckpointsPercent !== undefined &&
|
|
239
|
+
this.config.skipPublishingCheckpointsPercent > 0
|
|
240
|
+
) {
|
|
241
|
+
const roll = Math.max(0, randomInt(100));
|
|
242
|
+
if (roll < this.config.skipPublishingCheckpointsPercent) {
|
|
243
|
+
this.log.warn(
|
|
244
|
+
`Skipping publishing proposal for checkpoint ${checkpoint.number}. Configured percentage: ${this.config.skipPublishingCheckpointsPercent}, generated value: ${roll}`,
|
|
245
|
+
);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
await this.publisher.enqueueProposeCheckpoint(checkpoint, attestations, attestationsSignature, {
|
|
251
|
+
txTimeoutAt,
|
|
252
|
+
forcePendingCheckpointNumber: this.invalidateCheckpoint?.forcePendingCheckpointNumber,
|
|
253
|
+
forceProposedFeeHeader: this.computedForceProposedFeeHeader,
|
|
254
|
+
});
|
|
153
255
|
}
|
|
154
256
|
|
|
155
257
|
@trackSpan('CheckpointProposalJob.proposeCheckpoint', function () {
|
|
156
258
|
return {
|
|
157
259
|
// nullish operator needed for tests
|
|
158
260
|
[Attributes.COINBASE]: this.validatorClient.getCoinbaseForAttestor(this.attestorAddress)?.toString(),
|
|
159
|
-
[Attributes.SLOT_NUMBER]: this.
|
|
261
|
+
[Attributes.SLOT_NUMBER]: this.targetSlot,
|
|
160
262
|
};
|
|
161
263
|
})
|
|
162
|
-
private async proposeCheckpoint(): Promise<
|
|
264
|
+
private async proposeCheckpoint(): Promise<CheckpointProposalResult | undefined> {
|
|
163
265
|
try {
|
|
164
266
|
// Get operator configured coinbase and fee recipient for this attestor
|
|
165
267
|
const coinbase = this.validatorClient.getCoinbaseForAttestor(this.attestorAddress);
|
|
166
268
|
const feeRecipient = this.validatorClient.getFeeRecipientForAttestor(this.attestorAddress);
|
|
167
269
|
|
|
168
270
|
// Start the checkpoint
|
|
169
|
-
this.setStateFn(SequencerState.INITIALIZING_CHECKPOINT, this.
|
|
170
|
-
this.
|
|
271
|
+
this.setStateFn(SequencerState.INITIALIZING_CHECKPOINT, this.targetSlot);
|
|
272
|
+
this.log.info(`Starting checkpoint proposal`, {
|
|
273
|
+
buildSlot: this.slotNow,
|
|
274
|
+
submissionSlot: this.targetSlot,
|
|
275
|
+
pipelining: this.epochCache.isProposerPipeliningEnabled(),
|
|
276
|
+
proposer: this.proposer?.toString(),
|
|
277
|
+
coinbase: coinbase.toString(),
|
|
278
|
+
});
|
|
279
|
+
this.metrics.incOpenSlot(this.targetSlot, this.proposer?.toString() ?? 'unknown');
|
|
171
280
|
|
|
172
281
|
// Enqueues checkpoint invalidation (constant for the whole slot)
|
|
173
282
|
if (this.invalidateCheckpoint && !this.config.skipInvalidateBlockAsProposer) {
|
|
174
283
|
this.publisher.enqueueInvalidateCheckpoint(this.invalidateCheckpoint);
|
|
175
284
|
}
|
|
176
285
|
|
|
177
|
-
// Create checkpoint builder for the slot
|
|
286
|
+
// Create checkpoint builder for the slot.
|
|
287
|
+
// When pipelining, force the proposed checkpoint number and fee header to our parent so the
|
|
288
|
+
// fee computation sees the same chain tip that L1 will see once the previous pipelined checkpoint lands.
|
|
289
|
+
const isPipelining = this.epochCache.isProposerPipeliningEnabled();
|
|
290
|
+
const parentCheckpointNumber = isPipelining ? CheckpointNumber(this.checkpointNumber - 1) : undefined;
|
|
291
|
+
|
|
292
|
+
// Compute the parent's fee header override when pipelining
|
|
293
|
+
if (isPipelining && this.proposedCheckpointData) {
|
|
294
|
+
this.computedForceProposedFeeHeader = await this.computeForceProposedFeeHeader(parentCheckpointNumber!);
|
|
295
|
+
}
|
|
296
|
+
|
|
178
297
|
const checkpointGlobalVariables = await this.globalsBuilder.buildCheckpointGlobalVariables(
|
|
179
298
|
coinbase,
|
|
180
299
|
feeRecipient,
|
|
181
|
-
this.
|
|
300
|
+
this.targetSlot,
|
|
301
|
+
{
|
|
302
|
+
forcePendingCheckpointNumber: parentCheckpointNumber,
|
|
303
|
+
forceProposedFeeHeader: this.computedForceProposedFeeHeader,
|
|
304
|
+
},
|
|
182
305
|
);
|
|
183
306
|
|
|
184
307
|
// Collect L1 to L2 messages for the checkpoint and compute their hash
|
|
@@ -186,18 +309,21 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
186
309
|
const inHash = computeInHashFromL1ToL2Messages(l1ToL2Messages);
|
|
187
310
|
|
|
188
311
|
// Collect the out hashes of all the checkpoints before this one in the same epoch
|
|
189
|
-
const
|
|
190
|
-
c => c.
|
|
191
|
-
|
|
192
|
-
|
|
312
|
+
const previousCheckpointOutHashes = (await this.l2BlockSource.getCheckpointsDataForEpoch(this.targetEpoch))
|
|
313
|
+
.filter(c => c.checkpointNumber < this.checkpointNumber)
|
|
314
|
+
.map(c => c.checkpointOutHash);
|
|
315
|
+
|
|
316
|
+
// Get the fee asset price modifier from the oracle
|
|
317
|
+
const feeAssetPriceModifier = await this.publisher.getFeeAssetPriceModifier();
|
|
193
318
|
|
|
194
319
|
// Create a long-lived forked world state for the checkpoint builder
|
|
195
|
-
using fork = await this.worldState.fork(this.syncedToBlockNumber, { closeDelayMs: 12_000 });
|
|
320
|
+
await using fork = await this.worldState.fork(this.syncedToBlockNumber, { closeDelayMs: 12_000 });
|
|
196
321
|
|
|
197
322
|
// Create checkpoint builder for the entire slot
|
|
198
323
|
const checkpointBuilder = await this.checkpointsBuilder.startCheckpoint(
|
|
199
324
|
this.checkpointNumber,
|
|
200
325
|
checkpointGlobalVariables,
|
|
326
|
+
feeAssetPriceModifier,
|
|
201
327
|
l1ToL2Messages,
|
|
202
328
|
previousCheckpointOutHashes,
|
|
203
329
|
fork,
|
|
@@ -216,7 +342,8 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
216
342
|
};
|
|
217
343
|
|
|
218
344
|
let blocksInCheckpoint: L2Block[] = [];
|
|
219
|
-
let blockPendingBroadcast:
|
|
345
|
+
let blockPendingBroadcast: BlockProposal | undefined = undefined;
|
|
346
|
+
const checkpointBuildTimer = new Timer();
|
|
220
347
|
|
|
221
348
|
try {
|
|
222
349
|
// Main loop: build blocks for the checkpoint
|
|
@@ -239,43 +366,75 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
239
366
|
}
|
|
240
367
|
|
|
241
368
|
if (blocksInCheckpoint.length === 0) {
|
|
242
|
-
this.log.warn(`No blocks were built for slot ${this.
|
|
243
|
-
this.eventEmitter.emit('checkpoint-empty', { slot: this.
|
|
369
|
+
this.log.warn(`No blocks were built for slot ${this.targetSlot}`, { slot: this.targetSlot });
|
|
370
|
+
this.eventEmitter.emit('checkpoint-empty', { slot: this.targetSlot });
|
|
371
|
+
return undefined;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const minBlocksForCheckpoint = this.config.minBlocksForCheckpoint;
|
|
375
|
+
if (minBlocksForCheckpoint !== undefined && blocksInCheckpoint.length < minBlocksForCheckpoint) {
|
|
376
|
+
this.log.warn(
|
|
377
|
+
`Checkpoint has fewer blocks than minimum (${blocksInCheckpoint.length} < ${minBlocksForCheckpoint}), skipping proposal`,
|
|
378
|
+
{ slot: this.targetSlot, blocksBuilt: blocksInCheckpoint.length, minBlocksForCheckpoint },
|
|
379
|
+
);
|
|
244
380
|
return undefined;
|
|
245
381
|
}
|
|
246
382
|
|
|
247
383
|
// Assemble and broadcast the checkpoint proposal, including the last block that was not
|
|
248
384
|
// broadcasted yet, and wait to collect the committee attestations.
|
|
249
|
-
this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.
|
|
385
|
+
this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.targetSlot);
|
|
250
386
|
const checkpoint = await checkpointBuilder.completeCheckpoint();
|
|
251
387
|
|
|
388
|
+
// Final validation: per-block limits are only checked if the operator set them explicitly.
|
|
389
|
+
// Otherwise, checkpoint-level budgets were already enforced by the redistribution logic.
|
|
390
|
+
try {
|
|
391
|
+
validateCheckpoint(checkpoint, {
|
|
392
|
+
rollupManaLimit: this.l1Constants.rollupManaLimit,
|
|
393
|
+
maxL2BlockGas: this.config.maxL2BlockGas,
|
|
394
|
+
maxDABlockGas: this.config.maxDABlockGas,
|
|
395
|
+
maxTxsPerBlock: this.config.maxTxsPerBlock,
|
|
396
|
+
maxTxsPerCheckpoint: this.config.maxTxsPerCheckpoint,
|
|
397
|
+
});
|
|
398
|
+
} catch (err) {
|
|
399
|
+
this.log.error(`Built an invalid checkpoint at slot ${this.slotNow} (skipping proposal)`, err, {
|
|
400
|
+
checkpoint: checkpoint.header.toInspect(),
|
|
401
|
+
});
|
|
402
|
+
return undefined;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Record checkpoint-level build metrics
|
|
406
|
+
this.metrics.recordCheckpointBuild(
|
|
407
|
+
checkpointBuildTimer.ms(),
|
|
408
|
+
blocksInCheckpoint.length,
|
|
409
|
+
checkpoint.getStats().txCount,
|
|
410
|
+
Number(checkpoint.header.totalManaUsed.toBigInt()),
|
|
411
|
+
);
|
|
412
|
+
|
|
252
413
|
// Do not collect attestations nor publish to L1 in fisherman mode
|
|
253
414
|
if (this.config.fishermanMode) {
|
|
254
415
|
this.log.info(
|
|
255
|
-
`Built checkpoint for slot ${this.
|
|
416
|
+
`Built checkpoint for slot ${this.targetSlot} with ${blocksInCheckpoint.length} blocks. ` +
|
|
256
417
|
`Skipping proposal in fisherman mode.`,
|
|
257
418
|
{
|
|
258
|
-
slot: this.
|
|
419
|
+
slot: this.targetSlot,
|
|
259
420
|
checkpoint: checkpoint.header.toInspect(),
|
|
260
421
|
blocksBuilt: blocksInCheckpoint.length,
|
|
261
422
|
},
|
|
262
423
|
);
|
|
263
424
|
this.metrics.recordCheckpointSuccess();
|
|
264
|
-
return
|
|
425
|
+
return {
|
|
426
|
+
checkpoint,
|
|
427
|
+
attestations: CommitteeAttestationsAndSigners.empty(),
|
|
428
|
+
attestationsSignature: Signature.empty(),
|
|
429
|
+
};
|
|
265
430
|
}
|
|
266
431
|
|
|
267
|
-
// Include the block pending broadcast in the checkpoint proposal if any
|
|
268
|
-
const lastBlock = blockPendingBroadcast && {
|
|
269
|
-
blockHeader: blockPendingBroadcast.block.header,
|
|
270
|
-
indexWithinCheckpoint: blockPendingBroadcast.block.indexWithinCheckpoint,
|
|
271
|
-
txs: blockPendingBroadcast.txs,
|
|
272
|
-
};
|
|
273
|
-
|
|
274
432
|
// Create the checkpoint proposal and broadcast it
|
|
275
433
|
const proposal = await this.validatorClient.createCheckpointProposal(
|
|
276
434
|
checkpoint.header,
|
|
277
435
|
checkpoint.archive.root,
|
|
278
|
-
|
|
436
|
+
feeAssetPriceModifier,
|
|
437
|
+
blockPendingBroadcast,
|
|
279
438
|
this.proposer,
|
|
280
439
|
checkpointProposalOptions,
|
|
281
440
|
);
|
|
@@ -283,7 +442,7 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
283
442
|
const blockProposedAt = this.dateProvider.now();
|
|
284
443
|
await this.p2pClient.broadcastCheckpointProposal(proposal);
|
|
285
444
|
|
|
286
|
-
this.setStateFn(SequencerState.COLLECTING_ATTESTATIONS, this.
|
|
445
|
+
this.setStateFn(SequencerState.COLLECTING_ATTESTATIONS, this.targetSlot);
|
|
287
446
|
const attestations = await this.waitForAttestations(proposal);
|
|
288
447
|
const blockAttestedAt = this.dateProvider.now();
|
|
289
448
|
|
|
@@ -296,7 +455,7 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
296
455
|
attestationsSignature = await this.validatorClient.signAttestationsAndSigners(
|
|
297
456
|
attestations,
|
|
298
457
|
signer,
|
|
299
|
-
this.
|
|
458
|
+
this.targetSlot,
|
|
300
459
|
this.checkpointNumber,
|
|
301
460
|
);
|
|
302
461
|
} catch (err) {
|
|
@@ -308,24 +467,15 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
308
467
|
throw err;
|
|
309
468
|
}
|
|
310
469
|
|
|
311
|
-
//
|
|
312
|
-
|
|
313
|
-
const aztecSlotDuration = this.l1Constants.slotDuration;
|
|
314
|
-
const slotStartBuildTimestamp = this.getSlotStartBuildTimestamp();
|
|
315
|
-
const txTimeoutAt = new Date((slotStartBuildTimestamp + aztecSlotDuration) * 1000);
|
|
316
|
-
await this.publisher.enqueueProposeCheckpoint(checkpoint, attestations, attestationsSignature, {
|
|
317
|
-
txTimeoutAt,
|
|
318
|
-
forcePendingCheckpointNumber: this.invalidateCheckpoint?.forcePendingCheckpointNumber,
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
return checkpoint;
|
|
470
|
+
// Return the result for the caller to enqueue after the pipeline sleep
|
|
471
|
+
return { checkpoint, attestations, attestationsSignature };
|
|
322
472
|
} catch (err) {
|
|
323
473
|
if (err && (err instanceof DutyAlreadySignedError || err instanceof SlashingProtectionError)) {
|
|
324
474
|
// swallow this error. It's already been logged by a function deeper in the stack
|
|
325
475
|
return undefined;
|
|
326
476
|
}
|
|
327
477
|
|
|
328
|
-
this.log.error(`Error building checkpoint at slot ${this.
|
|
478
|
+
this.log.error(`Error building checkpoint at slot ${this.targetSlot}`, err);
|
|
329
479
|
return undefined;
|
|
330
480
|
}
|
|
331
481
|
}
|
|
@@ -341,17 +491,14 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
341
491
|
blockProposalOptions: BlockProposalOptions,
|
|
342
492
|
): Promise<{
|
|
343
493
|
blocksInCheckpoint: L2Block[];
|
|
344
|
-
blockPendingBroadcast:
|
|
494
|
+
blockPendingBroadcast: BlockProposal | undefined;
|
|
345
495
|
}> {
|
|
346
496
|
const blocksInCheckpoint: L2Block[] = [];
|
|
347
497
|
const txHashesAlreadyIncluded = new Set<string>();
|
|
348
498
|
const initialBlockNumber = BlockNumber(this.syncedToBlockNumber + 1);
|
|
349
499
|
|
|
350
|
-
// Remaining blob fields available for blocks (checkpoint end marker already subtracted)
|
|
351
|
-
let remainingBlobFields = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB - NUM_CHECKPOINT_END_MARKER_FIELDS;
|
|
352
|
-
|
|
353
500
|
// Last block in the checkpoint will usually be flagged as pending broadcast, so we send it along with the checkpoint proposal
|
|
354
|
-
let blockPendingBroadcast:
|
|
501
|
+
let blockPendingBroadcast: BlockProposal | undefined = undefined;
|
|
355
502
|
|
|
356
503
|
while (true) {
|
|
357
504
|
const blocksBuilt = blocksInCheckpoint.length;
|
|
@@ -363,7 +510,7 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
363
510
|
|
|
364
511
|
if (!timingInfo.canStart) {
|
|
365
512
|
this.log.debug(`Not enough time left in slot to start another block`, {
|
|
366
|
-
slot: this.
|
|
513
|
+
slot: this.targetSlot,
|
|
367
514
|
blocksBuilt,
|
|
368
515
|
secondsIntoSlot,
|
|
369
516
|
});
|
|
@@ -382,25 +529,25 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
382
529
|
blockNumber,
|
|
383
530
|
indexWithinCheckpoint,
|
|
384
531
|
txHashesAlreadyIncluded,
|
|
385
|
-
remainingBlobFields,
|
|
386
532
|
});
|
|
387
533
|
|
|
388
|
-
//
|
|
389
|
-
if (
|
|
390
|
-
// If
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
534
|
+
// If we failed to build the block due to insufficient txs, we try again if there is still time left in the slot
|
|
535
|
+
if ('failure' in buildResult) {
|
|
536
|
+
// If this was the last subslot, or we're running with a single block per slot, we're done
|
|
537
|
+
if (timingInfo.isLastBlock || timingInfo.deadline === undefined) {
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
// Otherwise, if there is still time for more blocks, we wait until the next subslot and try again
|
|
394
541
|
await this.waitUntilNextSubslot(timingInfo.deadline);
|
|
395
542
|
continue;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// If there was an error building the block, we just exit the loop and give up the rest of the slot.
|
|
546
|
+
// We don't want to risk building more blocks if something went wrong.
|
|
547
|
+
if ('error' in buildResult) {
|
|
401
548
|
if (!(buildResult.error instanceof SequencerInterruptedError)) {
|
|
402
|
-
this.log.warn(`Halting block building for slot ${this.
|
|
403
|
-
slot: this.
|
|
549
|
+
this.log.warn(`Halting block building for slot ${this.targetSlot}`, {
|
|
550
|
+
slot: this.targetSlot,
|
|
404
551
|
blocksBuilt,
|
|
405
552
|
error: buildResult.error,
|
|
406
553
|
});
|
|
@@ -408,65 +555,74 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
408
555
|
break;
|
|
409
556
|
}
|
|
410
557
|
|
|
411
|
-
const { block, usedTxs
|
|
558
|
+
const { block, usedTxs } = buildResult;
|
|
412
559
|
blocksInCheckpoint.push(block);
|
|
560
|
+
usedTxs.forEach(tx => txHashesAlreadyIncluded.add(tx.txHash.toString()));
|
|
413
561
|
|
|
414
|
-
//
|
|
415
|
-
|
|
562
|
+
// Sign the block proposal. This will throw if HA signing fails.
|
|
563
|
+
const proposal = await this.createBlockProposal(block, inHash, usedTxs, blockProposalOptions);
|
|
416
564
|
|
|
417
|
-
// Sync the proposed block to the archiver to make it available
|
|
418
|
-
//
|
|
419
|
-
//
|
|
420
|
-
//
|
|
421
|
-
this.syncProposedBlockToArchiver(block)
|
|
422
|
-
this.log.error(`Failed to sync proposed block ${block.number} to archiver`, { blockNumber: block.number, err });
|
|
423
|
-
});
|
|
565
|
+
// Sync the proposed block to the archiver to make it available, only after we've managed to sign the proposal,
|
|
566
|
+
// so we avoid polluting our archive with a block that would fail.
|
|
567
|
+
// We wait for the sync to succeed, as this helps catch consistency errors, even if it means we lose some time for block-building.
|
|
568
|
+
// If this throws, we abort the entire checkpoint.
|
|
569
|
+
await this.syncProposedBlockToArchiver(block);
|
|
424
570
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
// If this is the last block, exit the loop now so we start collecting attestations
|
|
571
|
+
// If this is the last block, do not broadcast it, since it will be included in the checkpoint proposal.
|
|
428
572
|
if (timingInfo.isLastBlock) {
|
|
429
|
-
this.log.verbose(`Completed final block ${blockNumber} for slot ${this.
|
|
430
|
-
slot: this.
|
|
573
|
+
this.log.verbose(`Completed final block ${blockNumber} for slot ${this.targetSlot}`, {
|
|
574
|
+
slot: this.targetSlot,
|
|
431
575
|
blockNumber,
|
|
432
576
|
blocksBuilt,
|
|
433
577
|
});
|
|
434
|
-
blockPendingBroadcast =
|
|
578
|
+
blockPendingBroadcast = proposal;
|
|
435
579
|
break;
|
|
436
580
|
}
|
|
437
581
|
|
|
438
|
-
//
|
|
439
|
-
|
|
440
|
-
if (!this.config.fishermanMode) {
|
|
441
|
-
const proposal = await this.validatorClient.createBlockProposal(
|
|
442
|
-
block.header,
|
|
443
|
-
block.indexWithinCheckpoint,
|
|
444
|
-
inHash,
|
|
445
|
-
block.archive.root,
|
|
446
|
-
usedTxs,
|
|
447
|
-
this.proposer,
|
|
448
|
-
blockProposalOptions,
|
|
449
|
-
);
|
|
450
|
-
await this.p2pClient.broadcastProposal(proposal);
|
|
451
|
-
}
|
|
582
|
+
// Once we have a signed proposal and the archiver agreed with our proposed block, then we broadcast it.
|
|
583
|
+
proposal && (await this.p2pClient.broadcastProposal(proposal));
|
|
452
584
|
|
|
453
585
|
// Wait until the next block's start time
|
|
454
586
|
await this.waitUntilNextSubslot(timingInfo.deadline);
|
|
455
587
|
}
|
|
456
588
|
|
|
457
|
-
this.log.verbose(`Block building loop completed for slot ${this.
|
|
458
|
-
slot: this.
|
|
589
|
+
this.log.verbose(`Block building loop completed for slot ${this.targetSlot}`, {
|
|
590
|
+
slot: this.targetSlot,
|
|
459
591
|
blocksBuilt: blocksInCheckpoint.length,
|
|
460
592
|
});
|
|
461
593
|
|
|
462
594
|
return { blocksInCheckpoint, blockPendingBroadcast };
|
|
463
595
|
}
|
|
464
596
|
|
|
597
|
+
/** Creates a block proposal for a given block via the validator client (unless in fisherman mode) */
|
|
598
|
+
private createBlockProposal(
|
|
599
|
+
block: L2Block,
|
|
600
|
+
inHash: Fr,
|
|
601
|
+
usedTxs: Tx[],
|
|
602
|
+
blockProposalOptions: BlockProposalOptions,
|
|
603
|
+
): Promise<BlockProposal | undefined> {
|
|
604
|
+
if (this.config.fishermanMode) {
|
|
605
|
+
this.log.info(`Skipping block proposal for block ${block.number} in fisherman mode`);
|
|
606
|
+
return Promise.resolve(undefined);
|
|
607
|
+
}
|
|
608
|
+
return this.validatorClient.createBlockProposal(
|
|
609
|
+
block.header,
|
|
610
|
+
block.indexWithinCheckpoint,
|
|
611
|
+
inHash,
|
|
612
|
+
block.archive.root,
|
|
613
|
+
usedTxs,
|
|
614
|
+
this.proposer,
|
|
615
|
+
blockProposalOptions,
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
|
|
465
619
|
/** Sleeps until it is time to produce the next block in the slot */
|
|
466
620
|
@trackSpan('CheckpointProposalJob.waitUntilNextSubslot')
|
|
467
621
|
private async waitUntilNextSubslot(nextSubslotStart: number) {
|
|
468
|
-
this.setStateFn(SequencerState.WAITING_UNTIL_NEXT_BLOCK, this.
|
|
469
|
-
this.log.verbose(`Waiting until time for the next block at ${nextSubslotStart}s into slot`, {
|
|
622
|
+
this.setStateFn(SequencerState.WAITING_UNTIL_NEXT_BLOCK, this.targetSlot);
|
|
623
|
+
this.log.verbose(`Waiting until time for the next block at ${nextSubslotStart}s into slot`, {
|
|
624
|
+
slot: this.targetSlot,
|
|
625
|
+
});
|
|
470
626
|
await this.waitUntilTimeInSlot(nextSubslotStart);
|
|
471
627
|
}
|
|
472
628
|
|
|
@@ -481,64 +637,64 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
481
637
|
indexWithinCheckpoint: IndexWithinCheckpoint;
|
|
482
638
|
buildDeadline: Date | undefined;
|
|
483
639
|
txHashesAlreadyIncluded: Set<string>;
|
|
484
|
-
remainingBlobFields: number;
|
|
485
640
|
},
|
|
486
|
-
): Promise<
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
indexWithinCheckpoint,
|
|
492
|
-
buildDeadline,
|
|
493
|
-
txHashesAlreadyIncluded,
|
|
494
|
-
remainingBlobFields,
|
|
495
|
-
} = opts;
|
|
641
|
+
): Promise<
|
|
642
|
+
{ block: L2Block; usedTxs: Tx[] } | { failure: 'insufficient-txs' | 'insufficient-valid-txs' } | { error: Error }
|
|
643
|
+
> {
|
|
644
|
+
const { blockTimestamp, forceCreate, blockNumber, indexWithinCheckpoint, buildDeadline, txHashesAlreadyIncluded } =
|
|
645
|
+
opts;
|
|
496
646
|
|
|
497
647
|
this.log.verbose(
|
|
498
|
-
`Preparing block ${blockNumber} index ${indexWithinCheckpoint} at checkpoint ${this.checkpointNumber} for slot ${this.
|
|
648
|
+
`Preparing block ${blockNumber} index ${indexWithinCheckpoint} at checkpoint ${this.checkpointNumber} for slot ${this.targetSlot}`,
|
|
499
649
|
{ ...checkpointBuilder.getConstantData(), ...opts },
|
|
500
650
|
);
|
|
501
651
|
|
|
502
652
|
try {
|
|
503
653
|
// Wait until we have enough txs to build the block
|
|
504
|
-
const minTxs = this.
|
|
505
|
-
const { availableTxs, canStartBuilding } = await this.waitForMinTxs(opts);
|
|
654
|
+
const { availableTxs, canStartBuilding, minTxs } = await this.waitForMinTxs(opts);
|
|
506
655
|
if (!canStartBuilding) {
|
|
507
656
|
this.log.warn(
|
|
508
|
-
`Not enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.
|
|
509
|
-
{ blockNumber, slot: this.
|
|
657
|
+
`Not enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.targetSlot} (got ${availableTxs} txs but needs ${minTxs})`,
|
|
658
|
+
{ blockNumber, slot: this.targetSlot, indexWithinCheckpoint },
|
|
510
659
|
);
|
|
511
|
-
this.eventEmitter.emit('block-tx-count-check-failed', { minTxs, availableTxs, slot: this.
|
|
660
|
+
this.eventEmitter.emit('block-tx-count-check-failed', { minTxs, availableTxs, slot: this.targetSlot });
|
|
512
661
|
this.metrics.recordBlockProposalFailed('insufficient_txs');
|
|
513
|
-
return
|
|
662
|
+
return { failure: 'insufficient-txs' };
|
|
514
663
|
}
|
|
515
664
|
|
|
516
665
|
// Create iterator to pending txs. We filter out txs already included in previous blocks in the checkpoint
|
|
517
666
|
// just in case p2p failed to sync the provisional block and didn't get to remove those txs from the mempool yet.
|
|
518
667
|
const pendingTxs = filter(
|
|
519
|
-
this.p2pClient.
|
|
668
|
+
this.p2pClient.iterateEligiblePendingTxs(),
|
|
520
669
|
tx => !txHashesAlreadyIncluded.has(tx.txHash.toString()),
|
|
521
670
|
);
|
|
522
671
|
|
|
523
672
|
this.log.debug(
|
|
524
|
-
`Building block ${blockNumber} at index ${indexWithinCheckpoint} for slot ${this.
|
|
525
|
-
{ slot: this.
|
|
673
|
+
`Building block ${blockNumber} at index ${indexWithinCheckpoint} for slot ${this.targetSlot} with ${availableTxs} available txs`,
|
|
674
|
+
{ slot: this.targetSlot, blockNumber, indexWithinCheckpoint },
|
|
526
675
|
);
|
|
527
|
-
this.setStateFn(SequencerState.CREATING_BLOCK, this.
|
|
528
|
-
|
|
529
|
-
// Calculate blob fields limit for txs (remaining capacity - this block's end overhead)
|
|
530
|
-
const blockEndOverhead = getNumBlockEndBlobFields(indexWithinCheckpoint === 0);
|
|
531
|
-
const maxBlobFieldsForTxs = remainingBlobFields - blockEndOverhead;
|
|
676
|
+
this.setStateFn(SequencerState.CREATING_BLOCK, this.targetSlot);
|
|
532
677
|
|
|
533
|
-
|
|
678
|
+
// Per-block limits are operator overrides (from SEQ_MAX_L2_BLOCK_GAS etc.) further capped
|
|
679
|
+
// by remaining checkpoint-level budgets inside CheckpointBuilder before each block is built.
|
|
680
|
+
// minValidTxs is passed into the builder so it can reject the block *before* updating state.
|
|
681
|
+
const minValidTxs = forceCreate ? 0 : (this.config.minValidTxsPerBlock ?? minTxs);
|
|
682
|
+
const blockBuilderOptions: BlockBuilderOptions = {
|
|
534
683
|
maxTransactions: this.config.maxTxsPerBlock,
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
684
|
+
maxBlockGas:
|
|
685
|
+
this.config.maxL2BlockGas !== undefined || this.config.maxDABlockGas !== undefined
|
|
686
|
+
? new Gas(this.config.maxDABlockGas ?? Infinity, this.config.maxL2BlockGas ?? Infinity)
|
|
687
|
+
: undefined,
|
|
538
688
|
deadline: buildDeadline,
|
|
689
|
+
isBuildingProposal: true,
|
|
690
|
+
minValidTxs,
|
|
691
|
+
maxBlocksPerCheckpoint: this.timetable.maxNumberOfBlocks,
|
|
692
|
+
perBlockAllocationMultiplier: this.config.perBlockAllocationMultiplier,
|
|
539
693
|
};
|
|
540
694
|
|
|
541
|
-
// Actually build the block by executing txs
|
|
695
|
+
// Actually build the block by executing txs. The builder throws InsufficientValidTxsError
|
|
696
|
+
// if the number of successfully processed txs is below minValidTxs, ensuring state is not
|
|
697
|
+
// updated for blocks that will be discarded.
|
|
542
698
|
const buildResult = await this.buildSingleBlockWithCheckpointBuilder(
|
|
543
699
|
checkpointBuilder,
|
|
544
700
|
pendingTxs,
|
|
@@ -550,22 +706,27 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
550
706
|
// If any txs failed during execution, drop them from the mempool so we don't pick them up again
|
|
551
707
|
await this.dropFailedTxsFromP2P(buildResult.failedTxs);
|
|
552
708
|
|
|
553
|
-
|
|
554
|
-
// too long, then we may not get to minTxsPerBlock after executing public functions.
|
|
555
|
-
const minValidTxs = this.config.minValidTxsPerBlock ?? minTxs;
|
|
556
|
-
const numTxs = buildResult.status === 'no-valid-txs' ? 0 : buildResult.numTxs;
|
|
557
|
-
if (buildResult.status === 'no-valid-txs' || (!forceCreate && numTxs < minValidTxs)) {
|
|
709
|
+
if (buildResult.status === 'insufficient-valid-txs') {
|
|
558
710
|
this.log.warn(
|
|
559
|
-
`Block ${blockNumber} at index ${indexWithinCheckpoint} on slot ${this.
|
|
560
|
-
{
|
|
711
|
+
`Block ${blockNumber} at index ${indexWithinCheckpoint} on slot ${this.targetSlot} has too few valid txs to be proposed`,
|
|
712
|
+
{
|
|
713
|
+
slot: this.targetSlot,
|
|
714
|
+
blockNumber,
|
|
715
|
+
numTxs: buildResult.processedCount,
|
|
716
|
+
indexWithinCheckpoint,
|
|
717
|
+
minValidTxs,
|
|
718
|
+
},
|
|
561
719
|
);
|
|
562
|
-
this.eventEmitter.emit('block-build-failed', {
|
|
720
|
+
this.eventEmitter.emit('block-build-failed', {
|
|
721
|
+
reason: `Insufficient valid txs`,
|
|
722
|
+
slot: this.targetSlot,
|
|
723
|
+
});
|
|
563
724
|
this.metrics.recordBlockProposalFailed('insufficient_valid_txs');
|
|
564
|
-
return
|
|
725
|
+
return { failure: 'insufficient-valid-txs' };
|
|
565
726
|
}
|
|
566
727
|
|
|
567
728
|
// Block creation succeeded, emit stats and metrics
|
|
568
|
-
const {
|
|
729
|
+
const { block, publicProcessorDuration, usedTxs, blockBuildDuration, numTxs } = buildResult;
|
|
569
730
|
|
|
570
731
|
const blockStats = {
|
|
571
732
|
eventName: 'l2-block-built',
|
|
@@ -576,33 +737,42 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
576
737
|
|
|
577
738
|
const blockHash = await block.hash();
|
|
578
739
|
const txHashes = block.body.txEffects.map(tx => tx.txHash);
|
|
579
|
-
const manaPerSec =
|
|
740
|
+
const manaPerSec = block.header.totalManaUsed.toNumberUnsafe() / (blockBuildDuration / 1000);
|
|
580
741
|
|
|
581
742
|
this.log.info(
|
|
582
|
-
`Built block ${block.number} at checkpoint ${this.checkpointNumber} for slot ${this.
|
|
743
|
+
`Built block ${block.number} at checkpoint ${this.checkpointNumber} for slot ${this.targetSlot} with ${numTxs} txs`,
|
|
583
744
|
{ blockHash, txHashes, manaPerSec, ...blockStats },
|
|
584
745
|
);
|
|
585
746
|
|
|
586
|
-
|
|
587
|
-
|
|
747
|
+
// `slot` is the target/submission slot (may be one ahead when pipelining),
|
|
748
|
+
// `buildSlot` is the wall-clock slot during which the block was actually built.
|
|
749
|
+
this.eventEmitter.emit('block-proposed', {
|
|
750
|
+
blockNumber: block.number,
|
|
751
|
+
slot: this.targetSlot,
|
|
752
|
+
buildSlot: this.slotNow,
|
|
753
|
+
});
|
|
754
|
+
this.metrics.recordBuiltBlock(blockBuildDuration, block.header.totalManaUsed.toNumberUnsafe());
|
|
588
755
|
|
|
589
|
-
return { block, usedTxs
|
|
756
|
+
return { block, usedTxs };
|
|
590
757
|
} catch (err: any) {
|
|
591
|
-
this.eventEmitter.emit('block-build-failed', {
|
|
592
|
-
|
|
758
|
+
this.eventEmitter.emit('block-build-failed', {
|
|
759
|
+
reason: err.message,
|
|
760
|
+
slot: this.targetSlot,
|
|
761
|
+
});
|
|
762
|
+
this.log.error(`Error building block`, err, { blockNumber, slot: this.targetSlot });
|
|
593
763
|
this.metrics.recordBlockProposalFailed(err.name || 'unknown_error');
|
|
594
764
|
this.metrics.recordFailedBlock();
|
|
595
765
|
return { error: err };
|
|
596
766
|
}
|
|
597
767
|
}
|
|
598
768
|
|
|
599
|
-
/** Uses the checkpoint builder to build a block, catching
|
|
769
|
+
/** Uses the checkpoint builder to build a block, catching InsufficientValidTxsError. */
|
|
600
770
|
private async buildSingleBlockWithCheckpointBuilder(
|
|
601
771
|
checkpointBuilder: CheckpointBuilder,
|
|
602
772
|
pendingTxs: AsyncIterable<Tx>,
|
|
603
773
|
blockNumber: BlockNumber,
|
|
604
774
|
blockTimestamp: bigint,
|
|
605
|
-
blockBuilderOptions:
|
|
775
|
+
blockBuilderOptions: BlockBuilderOptions,
|
|
606
776
|
) {
|
|
607
777
|
try {
|
|
608
778
|
const workTimer = new Timer();
|
|
@@ -610,8 +780,12 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
610
780
|
const blockBuildDuration = workTimer.ms();
|
|
611
781
|
return { ...result, blockBuildDuration, status: 'success' as const };
|
|
612
782
|
} catch (err: unknown) {
|
|
613
|
-
if (isErrorClass(err,
|
|
614
|
-
return {
|
|
783
|
+
if (isErrorClass(err, InsufficientValidTxsError)) {
|
|
784
|
+
return {
|
|
785
|
+
failedTxs: err.failedTxs,
|
|
786
|
+
processedCount: err.processedCount,
|
|
787
|
+
status: 'insufficient-valid-txs' as const,
|
|
788
|
+
};
|
|
615
789
|
}
|
|
616
790
|
throw err;
|
|
617
791
|
}
|
|
@@ -624,7 +798,7 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
624
798
|
blockNumber: BlockNumber;
|
|
625
799
|
indexWithinCheckpoint: IndexWithinCheckpoint;
|
|
626
800
|
buildDeadline: Date | undefined;
|
|
627
|
-
}): Promise<{ canStartBuilding: boolean; availableTxs: number }> {
|
|
801
|
+
}): Promise<{ canStartBuilding: boolean; availableTxs: number; minTxs: number }> {
|
|
628
802
|
const { indexWithinCheckpoint, blockNumber, buildDeadline, forceCreate } = opts;
|
|
629
803
|
|
|
630
804
|
// We only allow a block with 0 txs in the first block of the checkpoint
|
|
@@ -641,20 +815,20 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
641
815
|
// If we're past deadline, or we have no deadline, give up
|
|
642
816
|
const now = this.dateProvider.nowAsDate();
|
|
643
817
|
if (startBuildingDeadline === undefined || now >= startBuildingDeadline) {
|
|
644
|
-
return { canStartBuilding: false, availableTxs
|
|
818
|
+
return { canStartBuilding: false, availableTxs, minTxs };
|
|
645
819
|
}
|
|
646
820
|
|
|
647
821
|
// Wait a bit before checking again
|
|
648
|
-
this.setStateFn(SequencerState.WAITING_FOR_TXS, this.
|
|
822
|
+
this.setStateFn(SequencerState.WAITING_FOR_TXS, this.targetSlot);
|
|
649
823
|
this.log.verbose(
|
|
650
|
-
`Waiting for enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.
|
|
651
|
-
{ blockNumber, slot: this.
|
|
824
|
+
`Waiting for enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.targetSlot} (have ${availableTxs} but need ${minTxs})`,
|
|
825
|
+
{ blockNumber, slot: this.targetSlot, indexWithinCheckpoint },
|
|
652
826
|
);
|
|
653
827
|
await this.waitForTxsPollingInterval();
|
|
654
828
|
availableTxs = await this.p2pClient.getPendingTxCount();
|
|
655
829
|
}
|
|
656
830
|
|
|
657
|
-
return { canStartBuilding: true, availableTxs };
|
|
831
|
+
return { canStartBuilding: true, availableTxs, minTxs };
|
|
658
832
|
}
|
|
659
833
|
|
|
660
834
|
/**
|
|
@@ -680,7 +854,7 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
680
854
|
this.log.debug(`Attesting committee length is ${committee.length}`, { committee });
|
|
681
855
|
}
|
|
682
856
|
|
|
683
|
-
const numberOfRequiredAttestations =
|
|
857
|
+
const numberOfRequiredAttestations = computeQuorum(committee.length);
|
|
684
858
|
|
|
685
859
|
if (this.config.skipCollectingAttestations) {
|
|
686
860
|
this.log.warn('Skipping attestation collection as per config (attesting with own keys only)');
|
|
@@ -706,11 +880,28 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
706
880
|
|
|
707
881
|
collectedAttestationsCount = attestations.length;
|
|
708
882
|
|
|
883
|
+
// Trim attestations to minimum required to save L1 calldata gas
|
|
884
|
+
const localAddresses = this.validatorClient.getValidatorAddresses();
|
|
885
|
+
const trimmed = trimAttestations(
|
|
886
|
+
attestations,
|
|
887
|
+
numberOfRequiredAttestations,
|
|
888
|
+
this.attestorAddress,
|
|
889
|
+
localAddresses,
|
|
890
|
+
);
|
|
891
|
+
if (trimmed.length < attestations.length) {
|
|
892
|
+
this.log.debug(`Trimmed attestations from ${attestations.length} to ${trimmed.length} for L1 submission`);
|
|
893
|
+
}
|
|
894
|
+
|
|
709
895
|
// Rollup contract requires that the signatures are provided in the order of the committee
|
|
710
|
-
const sorted = orderAttestations(
|
|
896
|
+
const sorted = orderAttestations(trimmed, committee);
|
|
711
897
|
|
|
712
898
|
// Manipulate the attestations if we've been configured to do so
|
|
713
|
-
if (
|
|
899
|
+
if (
|
|
900
|
+
this.config.injectFakeAttestation ||
|
|
901
|
+
this.config.injectHighSValueAttestation ||
|
|
902
|
+
this.config.injectUnrecoverableSignatureAttestation ||
|
|
903
|
+
this.config.shuffleAttestationOrdering
|
|
904
|
+
) {
|
|
714
905
|
return this.manipulateAttestations(proposal.slotNumber, epoch, seed, committee, sorted);
|
|
715
906
|
}
|
|
716
907
|
|
|
@@ -739,7 +930,11 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
739
930
|
this.epochCache.computeProposerIndex(slotNumber, epoch, seed, BigInt(committee.length)),
|
|
740
931
|
);
|
|
741
932
|
|
|
742
|
-
if (
|
|
933
|
+
if (
|
|
934
|
+
this.config.injectFakeAttestation ||
|
|
935
|
+
this.config.injectHighSValueAttestation ||
|
|
936
|
+
this.config.injectUnrecoverableSignatureAttestation
|
|
937
|
+
) {
|
|
743
938
|
// Find non-empty attestations that are not from the proposer
|
|
744
939
|
const nonProposerIndices: number[] = [];
|
|
745
940
|
for (let i = 0; i < attestations.length; i++) {
|
|
@@ -749,8 +944,20 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
749
944
|
}
|
|
750
945
|
if (nonProposerIndices.length > 0) {
|
|
751
946
|
const targetIndex = nonProposerIndices[randomInt(nonProposerIndices.length)];
|
|
752
|
-
this.
|
|
753
|
-
|
|
947
|
+
if (this.config.injectHighSValueAttestation) {
|
|
948
|
+
this.log.warn(
|
|
949
|
+
`Injecting high-s value attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`,
|
|
950
|
+
);
|
|
951
|
+
unfreeze(attestations[targetIndex]).signature = flipSignature(attestations[targetIndex].signature);
|
|
952
|
+
} else if (this.config.injectUnrecoverableSignatureAttestation) {
|
|
953
|
+
this.log.warn(
|
|
954
|
+
`Injecting unrecoverable signature attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`,
|
|
955
|
+
);
|
|
956
|
+
unfreeze(attestations[targetIndex]).signature = generateUnrecoverableSignature();
|
|
957
|
+
} else {
|
|
958
|
+
this.log.warn(`Injecting fake attestation in checkpoint for slot ${slotNumber} at index ${targetIndex}`);
|
|
959
|
+
unfreeze(attestations[targetIndex]).signature = generateRecoverableSignature();
|
|
960
|
+
}
|
|
754
961
|
}
|
|
755
962
|
return new CommitteeAttestationsAndSigners(attestations);
|
|
756
963
|
}
|
|
@@ -759,11 +966,20 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
759
966
|
this.log.warn(`Shuffling attestation ordering in checkpoint for slot ${slotNumber} (proposer #${proposerIndex})`);
|
|
760
967
|
|
|
761
968
|
const shuffled = [...attestations];
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
969
|
+
|
|
970
|
+
// Find two non-proposer positions that both have non-empty signatures to swap.
|
|
971
|
+
// This ensures the bitmap doesn't change, so the MaliciousCommitteeAttestationsAndSigners
|
|
972
|
+
// signers array stays correctly aligned with L1's committee reconstruction.
|
|
973
|
+
const swappable: number[] = [];
|
|
974
|
+
for (let k = 0; k < shuffled.length; k++) {
|
|
975
|
+
if (!shuffled[k].signature.isEmpty() && k !== proposerIndex) {
|
|
976
|
+
swappable.push(k);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
if (swappable.length >= 2) {
|
|
980
|
+
const [i, j] = [swappable[0], swappable[1]];
|
|
981
|
+
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
|
|
982
|
+
}
|
|
767
983
|
|
|
768
984
|
const signers = new CommitteeAttestationsAndSigners(attestations).getSigners();
|
|
769
985
|
return new MaliciousCommitteeAttestationsAndSigners(shuffled, signers);
|
|
@@ -786,9 +1002,13 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
786
1002
|
* Adds the proposed block to the archiver so it's available via P2P.
|
|
787
1003
|
* Gossip doesn't echo messages back to the sender, so the proposer's archiver/world-state
|
|
788
1004
|
* would never receive its own block without this explicit sync.
|
|
1005
|
+
*
|
|
1006
|
+
* In fisherman mode we skip this push: the fisherman builds blocks locally for validation
|
|
1007
|
+
* and fee analysis only, and pushing them to the archiver causes spurious reorg cascades
|
|
1008
|
+
* whenever the real proposer's block arrives from L1.
|
|
789
1009
|
*/
|
|
790
1010
|
private async syncProposedBlockToArchiver(block: L2Block): Promise<void> {
|
|
791
|
-
if (this.config.skipPushProposedBlocksToArchiver
|
|
1011
|
+
if (this.config.skipPushProposedBlocksToArchiver || this.config.fishermanMode) {
|
|
792
1012
|
this.log.warn(`Skipping push of proposed block ${block.number} to archiver`, {
|
|
793
1013
|
blockNumber: block.number,
|
|
794
1014
|
slot: block.header.globalVariables.slotNumber,
|
|
@@ -806,22 +1026,22 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
806
1026
|
private async handleCheckpointEndAsFisherman(checkpoint: Checkpoint | undefined) {
|
|
807
1027
|
// Perform L1 fee analysis before clearing requests
|
|
808
1028
|
// The callback is invoked asynchronously after the next block is mined
|
|
809
|
-
const feeAnalysis = await this.publisher.analyzeL1Fees(this.
|
|
1029
|
+
const feeAnalysis = await this.publisher.analyzeL1Fees(this.targetSlot, analysis =>
|
|
810
1030
|
this.metrics.recordFishermanFeeAnalysis(analysis),
|
|
811
1031
|
);
|
|
812
1032
|
|
|
813
1033
|
if (checkpoint) {
|
|
814
|
-
this.log.info(`Validation checkpoint building SUCCEEDED for slot ${this.
|
|
1034
|
+
this.log.info(`Validation checkpoint building SUCCEEDED for slot ${this.targetSlot}`, {
|
|
815
1035
|
...checkpoint.toCheckpointInfo(),
|
|
816
1036
|
...checkpoint.getStats(),
|
|
817
1037
|
feeAnalysisId: feeAnalysis?.id,
|
|
818
1038
|
});
|
|
819
1039
|
} else {
|
|
820
|
-
this.log.warn(`Validation block building FAILED for slot ${this.
|
|
821
|
-
slot: this.
|
|
1040
|
+
this.log.warn(`Validation block building FAILED for slot ${this.targetSlot}`, {
|
|
1041
|
+
slot: this.targetSlot,
|
|
822
1042
|
feeAnalysisId: feeAnalysis?.id,
|
|
823
1043
|
});
|
|
824
|
-
this.metrics.
|
|
1044
|
+
this.metrics.recordCheckpointProposalFailed('block_build_failed');
|
|
825
1045
|
}
|
|
826
1046
|
|
|
827
1047
|
this.publisher.clearPendingRequests();
|
|
@@ -832,15 +1052,15 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
832
1052
|
*/
|
|
833
1053
|
private handleHASigningError(err: any, errorContext: string): boolean {
|
|
834
1054
|
if (err instanceof DutyAlreadySignedError) {
|
|
835
|
-
this.log.info(`${errorContext} for slot ${this.
|
|
836
|
-
slot: this.
|
|
1055
|
+
this.log.info(`${errorContext} for slot ${this.targetSlot} already signed by another HA node, yielding`, {
|
|
1056
|
+
slot: this.targetSlot,
|
|
837
1057
|
signedByNode: err.signedByNode,
|
|
838
1058
|
});
|
|
839
1059
|
return true;
|
|
840
1060
|
}
|
|
841
1061
|
if (err instanceof SlashingProtectionError) {
|
|
842
|
-
this.log.info(`${errorContext} for slot ${this.
|
|
843
|
-
slot: this.
|
|
1062
|
+
this.log.info(`${errorContext} for slot ${this.targetSlot} blocked by slashing protection, yielding`, {
|
|
1063
|
+
slot: this.targetSlot,
|
|
844
1064
|
existingMessageHash: err.existingMessageHash,
|
|
845
1065
|
attemptedMessageHash: err.attemptedMessageHash,
|
|
846
1066
|
});
|
|
@@ -849,6 +1069,56 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
849
1069
|
return false;
|
|
850
1070
|
}
|
|
851
1071
|
|
|
1072
|
+
/**
|
|
1073
|
+
* In times of congestion we need to simulate using the correct fee header override for the previous block
|
|
1074
|
+
* We calculate the correct fee header values.
|
|
1075
|
+
*
|
|
1076
|
+
* If we are in block 1, or the checkpoint we are querying does not exist, we return undefined. However
|
|
1077
|
+
* If we are pipelining - where this function is called, the grandparentCheckpointNumber should always exist
|
|
1078
|
+
* @param parentCheckpointNumber
|
|
1079
|
+
* @returns
|
|
1080
|
+
*/
|
|
1081
|
+
protected async computeForceProposedFeeHeader(parentCheckpointNumber: CheckpointNumber): Promise<
|
|
1082
|
+
| {
|
|
1083
|
+
checkpointNumber: CheckpointNumber;
|
|
1084
|
+
feeHeader: FeeHeader;
|
|
1085
|
+
}
|
|
1086
|
+
| undefined
|
|
1087
|
+
> {
|
|
1088
|
+
if (!this.proposedCheckpointData) {
|
|
1089
|
+
return undefined;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
const rollup = this.publisher.rollupContract;
|
|
1093
|
+
const grandparentCheckpointNumber = CheckpointNumber(this.checkpointNumber - 2);
|
|
1094
|
+
try {
|
|
1095
|
+
const [grandparentCheckpoint, manaTarget] = await Promise.all([
|
|
1096
|
+
rollup.getCheckpoint(grandparentCheckpointNumber),
|
|
1097
|
+
rollup.getManaTarget(),
|
|
1098
|
+
]);
|
|
1099
|
+
|
|
1100
|
+
if (!grandparentCheckpoint || !grandparentCheckpoint.feeHeader) {
|
|
1101
|
+
this.log.error(
|
|
1102
|
+
`Grandparent checkpoint or its feeHeader is undefined for checkpointNumber=${grandparentCheckpointNumber.toString()}`,
|
|
1103
|
+
);
|
|
1104
|
+
return undefined;
|
|
1105
|
+
} else {
|
|
1106
|
+
const parentFeeHeader = RollupContract.computeChildFeeHeader(
|
|
1107
|
+
grandparentCheckpoint.feeHeader,
|
|
1108
|
+
this.proposedCheckpointData.totalManaUsed,
|
|
1109
|
+
this.proposedCheckpointData.feeAssetPriceModifier,
|
|
1110
|
+
manaTarget,
|
|
1111
|
+
);
|
|
1112
|
+
return { checkpointNumber: parentCheckpointNumber, feeHeader: parentFeeHeader };
|
|
1113
|
+
}
|
|
1114
|
+
} catch (err) {
|
|
1115
|
+
this.log.error(
|
|
1116
|
+
`Failed to fetch grandparent checkpoint or mana target for checkpointNumber=${grandparentCheckpointNumber.toString()}: ${err}`,
|
|
1117
|
+
);
|
|
1118
|
+
return undefined;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
|
|
852
1122
|
/** Waits until a specific time within the current slot */
|
|
853
1123
|
@trackSpan('CheckpointProposalJob.waitUntilTimeInSlot')
|
|
854
1124
|
protected async waitUntilTimeInSlot(targetSecondsIntoSlot: number): Promise<void> {
|
|
@@ -863,7 +1133,7 @@ export class CheckpointProposalJob implements Traceable {
|
|
|
863
1133
|
}
|
|
864
1134
|
|
|
865
1135
|
private getSlotStartBuildTimestamp(): number {
|
|
866
|
-
return getSlotStartBuildTimestamp(this.
|
|
1136
|
+
return getSlotStartBuildTimestamp(this.slotNow, this.l1Constants);
|
|
867
1137
|
}
|
|
868
1138
|
|
|
869
1139
|
private getSecondsIntoSlot(): number {
|