@aztec/sequencer-client 0.0.1-commit.6230a0c → 0.0.1-commit.643667a5cb

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.
Files changed (51) hide show
  1. package/dest/client/sequencer-client.d.ts +12 -7
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +15 -4
  4. package/dest/config.d.ts +3 -4
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +17 -12
  7. package/dest/global_variable_builder/global_builder.d.ts +2 -4
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/publisher/config.d.ts +31 -17
  10. package/dest/publisher/config.d.ts.map +1 -1
  11. package/dest/publisher/config.js +101 -42
  12. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
  13. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  14. package/dest/publisher/sequencer-publisher-factory.js +13 -2
  15. package/dest/publisher/sequencer-publisher.d.ts +16 -7
  16. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  17. package/dest/publisher/sequencer-publisher.js +41 -21
  18. package/dest/sequencer/checkpoint_proposal_job.d.ts +3 -1
  19. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  20. package/dest/sequencer/checkpoint_proposal_job.js +44 -13
  21. package/dest/sequencer/metrics.d.ts +17 -5
  22. package/dest/sequencer/metrics.d.ts.map +1 -1
  23. package/dest/sequencer/metrics.js +86 -15
  24. package/dest/sequencer/sequencer.d.ts +15 -7
  25. package/dest/sequencer/sequencer.d.ts.map +1 -1
  26. package/dest/sequencer/sequencer.js +24 -25
  27. package/dest/sequencer/timetable.d.ts +1 -4
  28. package/dest/sequencer/timetable.d.ts.map +1 -1
  29. package/dest/sequencer/timetable.js +1 -4
  30. package/dest/test/index.d.ts +3 -5
  31. package/dest/test/index.d.ts.map +1 -1
  32. package/dest/test/mock_checkpoint_builder.d.ts +5 -3
  33. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  34. package/dest/test/mock_checkpoint_builder.js +6 -4
  35. package/dest/test/utils.d.ts +3 -3
  36. package/dest/test/utils.d.ts.map +1 -1
  37. package/dest/test/utils.js +5 -4
  38. package/package.json +28 -28
  39. package/src/client/sequencer-client.ts +25 -7
  40. package/src/config.ts +26 -19
  41. package/src/global_variable_builder/global_builder.ts +1 -1
  42. package/src/publisher/config.ts +112 -43
  43. package/src/publisher/sequencer-publisher-factory.ts +23 -6
  44. package/src/publisher/sequencer-publisher.ts +63 -28
  45. package/src/sequencer/checkpoint_proposal_job.ts +66 -12
  46. package/src/sequencer/metrics.ts +92 -18
  47. package/src/sequencer/sequencer.ts +32 -30
  48. package/src/sequencer/timetable.ts +6 -5
  49. package/src/test/index.ts +2 -4
  50. package/src/test/mock_checkpoint_builder.ts +12 -1
  51. package/src/test/utils.ts +5 -2
@@ -3,7 +3,7 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
3
3
  import type { BlobClientInterface } from '@aztec/blob-client/client';
4
4
  import type { EpochCache } from '@aztec/epoch-cache';
5
5
  import type { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
6
- import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
6
+ import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
7
7
  import type { PublisherFilter, PublisherManager } from '@aztec/ethereum/publisher-manager';
8
8
  import { SlotNumber } from '@aztec/foundation/branded-types';
9
9
  import type { DateProvider } from '@aztec/foundation/timer';
@@ -26,13 +26,15 @@ export class SequencerPublisherFactory {
26
26
  /** Stores the last slot in which every action was carried out by a publisher */
27
27
  private lastActions: Partial<Record<Action, SlotNumber>> = {};
28
28
 
29
+ private nodeKeyStore: NodeKeystoreAdapter;
30
+
29
31
  private logger: Logger;
30
32
 
31
33
  constructor(
32
34
  private sequencerConfig: SequencerClientConfig,
33
35
  private deps: {
34
36
  telemetry: TelemetryClient;
35
- publisherManager: PublisherManager<L1TxUtilsWithBlobs>;
37
+ publisherManager: PublisherManager<L1TxUtils>;
36
38
  blobClient: BlobClientInterface;
37
39
  dateProvider: DateProvider;
38
40
  epochCache: EpochCache;
@@ -45,7 +47,17 @@ export class SequencerPublisherFactory {
45
47
  ) {
46
48
  this.publisherMetrics = new SequencerPublisherMetrics(deps.telemetry, 'SequencerPublisher');
47
49
  this.logger = deps.logger ?? createLogger('sequencer');
50
+ this.nodeKeyStore = this.deps.nodeKeyStore;
51
+ }
52
+
53
+ /**
54
+ * Updates the node keystore adapter used for publisher lookups.
55
+ * Called when the keystore is reloaded at runtime to reflect new validator-publisher mappings.
56
+ */
57
+ public updateNodeKeyStore(adapter: NodeKeystoreAdapter): void {
58
+ this.nodeKeyStore = adapter;
48
59
  }
60
+
49
61
  /**
50
62
  * Creates a new SequencerPublisher instance.
51
63
  * @param _validatorAddress - The address of the validator that will be using the publisher.
@@ -54,17 +66,17 @@ export class SequencerPublisherFactory {
54
66
  public async create(validatorAddress?: EthAddress): Promise<AttestorPublisherPair> {
55
67
  // If we have been given an attestor address we must only allow publishers permitted for that attestor
56
68
 
57
- const allowedPublishers = !validatorAddress ? [] : this.deps.nodeKeyStore.getPublisherAddresses(validatorAddress);
58
- const filter: PublisherFilter<L1TxUtilsWithBlobs> = !validatorAddress
69
+ const allowedPublishers = !validatorAddress ? [] : this.nodeKeyStore.getPublisherAddresses(validatorAddress);
70
+ const filter: PublisherFilter<L1TxUtils> = !validatorAddress
59
71
  ? () => true
60
- : (utils: L1TxUtilsWithBlobs) => {
72
+ : (utils: L1TxUtils) => {
61
73
  const publisherAddress = utils.getSenderAddress();
62
74
  return allowedPublishers.some(allowedPublisher => allowedPublisher.equals(publisherAddress));
63
75
  };
64
76
 
65
77
  const l1Publisher = await this.deps.publisherManager.getAvailablePublisher(filter);
66
78
  const attestorAddress =
67
- validatorAddress ?? this.deps.nodeKeyStore.getAttestorForPublisher(l1Publisher.getSenderAddress());
79
+ validatorAddress ?? this.nodeKeyStore.getAttestorForPublisher(l1Publisher.getSenderAddress());
68
80
 
69
81
  const rollup = this.deps.rollupContract;
70
82
  const slashingProposerContract = await rollup.getSlashingProposer();
@@ -89,4 +101,9 @@ export class SequencerPublisherFactory {
89
101
  publisher,
90
102
  };
91
103
  }
104
+
105
+ /** Interrupts all publishers managed by this factory. Used during sequencer shutdown. */
106
+ public interruptAll(): void {
107
+ this.deps.publisherManager.interrupt();
108
+ }
92
109
  }
@@ -4,6 +4,7 @@ import type { EpochCache } from '@aztec/epoch-cache';
4
4
  import type { L1ContractsConfig } from '@aztec/ethereum/config';
5
5
  import {
6
6
  type EmpireSlashingProposerContract,
7
+ FeeAssetPriceOracle,
7
8
  type GovernanceProposerContract,
8
9
  type IEmpireBase,
9
10
  MULTI_CALL_3_ADDRESS,
@@ -18,11 +19,11 @@ import {
18
19
  type L1BlobInputs,
19
20
  type L1TxConfig,
20
21
  type L1TxRequest,
22
+ type L1TxUtils,
21
23
  MAX_L1_TX_LIMIT,
22
24
  type TransactionStats,
23
25
  WEI_CONST,
24
26
  } from '@aztec/ethereum/l1-tx-utils';
25
- import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
26
27
  import { FormattedViemError, formatViemError, mergeAbis, tryExtractEvent } from '@aztec/ethereum/utils';
27
28
  import { sumBigint } from '@aztec/foundation/bigint';
28
29
  import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
@@ -32,6 +33,7 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
32
33
  import { EthAddress } from '@aztec/foundation/eth-address';
33
34
  import { Signature, type ViemSignature } from '@aztec/foundation/eth-signature';
34
35
  import { type Logger, createLogger } from '@aztec/foundation/log';
36
+ import { makeBackoff, retry } from '@aztec/foundation/retry';
35
37
  import { bufferToHex } from '@aztec/foundation/string';
36
38
  import { DateProvider, Timer } from '@aztec/foundation/timer';
37
39
  import { EmpireBaseAbi, ErrorsAbi, RollupAbi } from '@aztec/l1-artifacts';
@@ -45,7 +47,7 @@ import { type TelemetryClient, type Tracer, getTelemetryClient, trackSpan } from
45
47
 
46
48
  import { type StateOverride, type TransactionReceipt, type TypedDataDefinition, encodeFunctionData, toHex } from 'viem';
47
49
 
48
- import type { PublisherConfig, TxSenderConfig } from './config.js';
50
+ import type { SequencerPublisherConfig } from './config.js';
49
51
  import { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
50
52
 
51
53
  /** Arguments to the process method of the rollup contract */
@@ -60,6 +62,8 @@ type L1ProcessArgs = {
60
62
  attestationsAndSigners: CommitteeAttestationsAndSigners;
61
63
  /** Attestations and signers signature */
62
64
  attestationsAndSignersSignature: Signature;
65
+ /** The fee asset price modifier in basis points (from oracle) */
66
+ feeAssetPriceModifier: bigint;
63
67
  };
64
68
 
65
69
  export const Actions = [
@@ -112,6 +116,7 @@ export class SequencerPublisher {
112
116
  protected lastActions: Partial<Record<Action, SlotNumber>> = {};
113
117
 
114
118
  private isPayloadEmptyCache: Map<string, boolean> = new Map<string, boolean>();
119
+ private payloadProposedCache: Set<string> = new Set<string>();
115
120
 
116
121
  protected log: Logger;
117
122
  protected ethereumSlotDuration: bigint;
@@ -123,13 +128,17 @@ export class SequencerPublisher {
123
128
 
124
129
  /** L1 fee analyzer for fisherman mode */
125
130
  private l1FeeAnalyzer?: L1FeeAnalyzer;
131
+
132
+ /** Fee asset price oracle for computing price modifiers from Uniswap V4 */
133
+ private feeAssetPriceOracle: FeeAssetPriceOracle;
134
+
126
135
  // A CALL to a cold address is 2700 gas
127
136
  public static MULTICALL_OVERHEAD_GAS_GUESS = 5000n;
128
137
 
129
138
  // Gas report for VotingWithSigTest shows a max gas of 100k, but we've seen it cost 700k+ in testnet
130
139
  public static VOTE_GAS_GUESS: bigint = 800_000n;
131
140
 
132
- public l1TxUtils: L1TxUtilsWithBlobs;
141
+ public l1TxUtils: L1TxUtils;
133
142
  public rollupContract: RollupContract;
134
143
  public govProposerContract: GovernanceProposerContract;
135
144
  public slashingProposerContract: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
@@ -140,11 +149,12 @@ export class SequencerPublisher {
140
149
  protected requests: RequestWithExpiry[] = [];
141
150
 
142
151
  constructor(
143
- private config: TxSenderConfig & PublisherConfig & Pick<L1ContractsConfig, 'ethereumSlotDuration'>,
152
+ private config: Pick<SequencerPublisherConfig, 'fishermanMode'> &
153
+ Pick<L1ContractsConfig, 'ethereumSlotDuration'> & { l1ChainId: number },
144
154
  deps: {
145
155
  telemetry?: TelemetryClient;
146
156
  blobClient: BlobClientInterface;
147
- l1TxUtils: L1TxUtilsWithBlobs;
157
+ l1TxUtils: L1TxUtils;
148
158
  rollupContract: RollupContract;
149
159
  slashingProposerContract: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
150
160
  governanceProposerContract: GovernanceProposerContract;
@@ -188,12 +198,27 @@ export class SequencerPublisher {
188
198
  createLogger('sequencer:publisher:fee-analyzer'),
189
199
  );
190
200
  }
201
+
202
+ // Initialize fee asset price oracle
203
+ this.feeAssetPriceOracle = new FeeAssetPriceOracle(
204
+ this.l1TxUtils.client,
205
+ this.rollupContract,
206
+ createLogger('sequencer:publisher:price-oracle'),
207
+ );
191
208
  }
192
209
 
193
210
  public getRollupContract(): RollupContract {
194
211
  return this.rollupContract;
195
212
  }
196
213
 
214
+ /**
215
+ * Gets the fee asset price modifier from the oracle.
216
+ * Returns 0n if the oracle query fails.
217
+ */
218
+ public getFeeAssetPriceModifier(): Promise<bigint> {
219
+ return this.feeAssetPriceOracle.computePriceModifier();
220
+ }
221
+
197
222
  public getSenderAddress() {
198
223
  return this.l1TxUtils.getSenderAddress();
199
224
  }
@@ -617,24 +642,8 @@ export class SequencerPublisher {
617
642
  options: { forcePendingCheckpointNumber?: CheckpointNumber },
618
643
  ): Promise<bigint> {
619
644
  const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);
620
-
621
- // TODO(palla/mbps): This should not be needed, there's no flow where we propose with zero attestations. Or is there?
622
- // If we have no attestations, we still need to provide the empty attestations
623
- // so that the committee is recalculated correctly
624
- // const ignoreSignatures = attestationsAndSigners.attestations.length === 0;
625
- // if (ignoreSignatures) {
626
- // const { committee } = await this.epochCache.getCommittee(block.header.globalVariables.slotNumber);
627
- // if (!committee) {
628
- // this.log.warn(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
629
- // throw new Error(`No committee found for slot ${block.header.globalVariables.slotNumber}`);
630
- // }
631
- // attestationsAndSigners.attestations = committee.map(committeeMember =>
632
- // CommitteeAttestation.fromAddress(committeeMember),
633
- // );
634
- // }
635
-
636
645
  const blobFields = checkpoint.toBlobFields();
637
- const blobs = getBlobsPerL1Block(blobFields);
646
+ const blobs = await getBlobsPerL1Block(blobFields);
638
647
  const blobInput = getPrefixedEthBlobCommitments(blobs);
639
648
 
640
649
  const args = [
@@ -642,7 +651,7 @@ export class SequencerPublisher {
642
651
  header: checkpoint.header.toViem(),
643
652
  archive: toHex(checkpoint.archive.root.toBuffer()),
644
653
  oracleInput: {
645
- feeAssetPriceModifier: 0n,
654
+ feeAssetPriceModifier: checkpoint.feeAssetPriceModifier,
646
655
  },
647
656
  },
648
657
  attestationsAndSigners.getPackedAttestations(),
@@ -691,6 +700,32 @@ export class SequencerPublisher {
691
700
  return false;
692
701
  }
693
702
 
703
+ // Check if payload was already submitted to governance
704
+ const cacheKey = payload.toString();
705
+ if (!this.payloadProposedCache.has(cacheKey)) {
706
+ try {
707
+ const l1StartBlock = await this.rollupContract.getL1StartBlock();
708
+ const proposed = await retry(
709
+ () => base.hasPayloadBeenProposed(payload.toString(), l1StartBlock),
710
+ 'Check if payload was proposed',
711
+ makeBackoff([0, 1, 2]),
712
+ this.log,
713
+ true,
714
+ );
715
+ if (proposed) {
716
+ this.payloadProposedCache.add(cacheKey);
717
+ }
718
+ } catch (err) {
719
+ this.log.warn(`Failed to check if payload ${payload} was proposed after retries, skipping signal`, err);
720
+ return false;
721
+ }
722
+ }
723
+
724
+ if (this.payloadProposedCache.has(cacheKey)) {
725
+ this.log.info(`Payload ${payload} was already proposed to governance, stopping signals`);
726
+ return false;
727
+ }
728
+
694
729
  const cachedLastVote = this.lastActions[signalType];
695
730
  this.lastActions[signalType] = slotNumber;
696
731
  const action = signalType;
@@ -918,14 +953,15 @@ export class SequencerPublisher {
918
953
  const checkpointHeader = checkpoint.header;
919
954
 
920
955
  const blobFields = checkpoint.toBlobFields();
921
- const blobs = getBlobsPerL1Block(blobFields);
956
+ const blobs = await getBlobsPerL1Block(blobFields);
922
957
 
923
- const proposeTxArgs = {
958
+ const proposeTxArgs: L1ProcessArgs = {
924
959
  header: checkpointHeader,
925
960
  archive: checkpoint.archive.root.toBuffer(),
926
961
  blobs,
927
962
  attestationsAndSigners,
928
963
  attestationsAndSignersSignature,
964
+ feeAssetPriceModifier: checkpoint.feeAssetPriceModifier,
929
965
  };
930
966
 
931
967
  let ts: bigint;
@@ -1113,8 +1149,7 @@ export class SequencerPublisher {
1113
1149
  header: encodedData.header.toViem(),
1114
1150
  archive: toHex(encodedData.archive),
1115
1151
  oracleInput: {
1116
- // We are currently not modifying these. See #9963
1117
- feeAssetPriceModifier: 0n,
1152
+ feeAssetPriceModifier: encodedData.feeAssetPriceModifier,
1118
1153
  },
1119
1154
  },
1120
1155
  encodedData.attestationsAndSigners.getPackedAttestations(),
@@ -1140,7 +1175,7 @@ export class SequencerPublisher {
1140
1175
  readonly header: ViemHeader;
1141
1176
  readonly archive: `0x${string}`;
1142
1177
  readonly oracleInput: {
1143
- readonly feeAssetPriceModifier: 0n;
1178
+ readonly feeAssetPriceModifier: bigint;
1144
1179
  };
1145
1180
  },
1146
1181
  ViemCommitteeAttestations,
@@ -38,7 +38,7 @@ import {
38
38
  } from '@aztec/stdlib/interfaces/server';
39
39
  import { type L1ToL2MessageSource, computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
40
40
  import type { BlockProposalOptions, CheckpointProposal, CheckpointProposalOptions } from '@aztec/stdlib/p2p';
41
- import { orderAttestations } from '@aztec/stdlib/p2p';
41
+ import { orderAttestations, trimAttestations } from '@aztec/stdlib/p2p';
42
42
  import type { L2BlockBuiltStats } from '@aztec/stdlib/stats';
43
43
  import { type FailedTx, Tx } from '@aztec/stdlib/tx';
44
44
  import { AttestationTimeoutError } from '@aztec/stdlib/validators';
@@ -129,7 +129,7 @@ export class CheckpointProposalJob implements Traceable {
129
129
  await Promise.all(votesPromises);
130
130
 
131
131
  if (checkpoint) {
132
- this.metrics.recordBlockProposalSuccess();
132
+ this.metrics.recordCheckpointProposalSuccess();
133
133
  }
134
134
 
135
135
  // Do not post anything to L1 if we are fishermen, but do perform L1 fee analysis
@@ -186,18 +186,21 @@ export class CheckpointProposalJob implements Traceable {
186
186
  const inHash = computeInHashFromL1ToL2Messages(l1ToL2Messages);
187
187
 
188
188
  // Collect the out hashes of all the checkpoints before this one in the same epoch
189
- const previousCheckpoints = (await this.l2BlockSource.getCheckpointsForEpoch(this.epoch)).filter(
190
- c => c.number < this.checkpointNumber,
191
- );
192
- const previousCheckpointOutHashes = previousCheckpoints.map(c => c.getCheckpointOutHash());
189
+ const previousCheckpointOutHashes = (await this.l2BlockSource.getCheckpointsDataForEpoch(this.epoch))
190
+ .filter(c => c.checkpointNumber < this.checkpointNumber)
191
+ .map(c => c.checkpointOutHash);
192
+
193
+ // Get the fee asset price modifier from the oracle
194
+ const feeAssetPriceModifier = await this.publisher.getFeeAssetPriceModifier();
193
195
 
194
196
  // Create a long-lived forked world state for the checkpoint builder
195
- using fork = await this.worldState.fork(this.syncedToBlockNumber, { closeDelayMs: 12_000 });
197
+ await using fork = await this.worldState.fork(this.syncedToBlockNumber, { closeDelayMs: 12_000 });
196
198
 
197
199
  // Create checkpoint builder for the entire slot
198
200
  const checkpointBuilder = await this.checkpointsBuilder.startCheckpoint(
199
201
  this.checkpointNumber,
200
202
  checkpointGlobalVariables,
203
+ feeAssetPriceModifier,
201
204
  l1ToL2Messages,
202
205
  previousCheckpointOutHashes,
203
206
  fork,
@@ -217,6 +220,7 @@ export class CheckpointProposalJob implements Traceable {
217
220
 
218
221
  let blocksInCheckpoint: L2Block[] = [];
219
222
  let blockPendingBroadcast: { block: L2Block; txs: Tx[] } | undefined = undefined;
223
+ const checkpointBuildTimer = new Timer();
220
224
 
221
225
  try {
222
226
  // Main loop: build blocks for the checkpoint
@@ -244,11 +248,28 @@ export class CheckpointProposalJob implements Traceable {
244
248
  return undefined;
245
249
  }
246
250
 
251
+ const minBlocksForCheckpoint = this.config.minBlocksForCheckpoint;
252
+ if (minBlocksForCheckpoint !== undefined && blocksInCheckpoint.length < minBlocksForCheckpoint) {
253
+ this.log.warn(
254
+ `Checkpoint has fewer blocks than minimum (${blocksInCheckpoint.length} < ${minBlocksForCheckpoint}), skipping proposal`,
255
+ { slot: this.slot, blocksBuilt: blocksInCheckpoint.length, minBlocksForCheckpoint },
256
+ );
257
+ return undefined;
258
+ }
259
+
247
260
  // Assemble and broadcast the checkpoint proposal, including the last block that was not
248
261
  // broadcasted yet, and wait to collect the committee attestations.
249
262
  this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.slot);
250
263
  const checkpoint = await checkpointBuilder.completeCheckpoint();
251
264
 
265
+ // Record checkpoint-level build metrics
266
+ this.metrics.recordCheckpointBuild(
267
+ checkpointBuildTimer.ms(),
268
+ blocksInCheckpoint.length,
269
+ checkpoint.getStats().txCount,
270
+ Number(checkpoint.header.totalManaUsed.toBigInt()),
271
+ );
272
+
252
273
  // Do not collect attestations nor publish to L1 in fisherman mode
253
274
  if (this.config.fishermanMode) {
254
275
  this.log.info(
@@ -275,6 +296,7 @@ export class CheckpointProposalJob implements Traceable {
275
296
  const proposal = await this.validatorClient.createCheckpointProposal(
276
297
  checkpoint.header,
277
298
  checkpoint.archive.root,
299
+ feeAssetPriceModifier,
278
300
  lastBlock,
279
301
  this.proposer,
280
302
  checkpointProposalOptions,
@@ -313,6 +335,21 @@ export class CheckpointProposalJob implements Traceable {
313
335
  const aztecSlotDuration = this.l1Constants.slotDuration;
314
336
  const slotStartBuildTimestamp = this.getSlotStartBuildTimestamp();
315
337
  const txTimeoutAt = new Date((slotStartBuildTimestamp + aztecSlotDuration) * 1000);
338
+
339
+ // If we have been configured to potentially skip publishing checkpoint then roll the dice here
340
+ if (
341
+ this.config.skipPublishingCheckpointsPercent !== undefined &&
342
+ this.config.skipPublishingCheckpointsPercent > 0
343
+ ) {
344
+ const result = Math.max(0, randomInt(100));
345
+ if (result < this.config.skipPublishingCheckpointsPercent) {
346
+ this.log.warn(
347
+ `Skipping publishing proposal for checkpoint ${checkpoint.number}. Configured percentage: ${this.config.skipPublishingCheckpointsPercent}, generated value: ${result}`,
348
+ );
349
+ return checkpoint;
350
+ }
351
+ }
352
+
316
353
  await this.publisher.enqueueProposeCheckpoint(checkpoint, attestations, attestationsSignature, {
317
354
  txTimeoutAt,
318
355
  forcePendingCheckpointNumber: this.invalidateCheckpoint?.forcePendingCheckpointNumber,
@@ -516,7 +553,7 @@ export class CheckpointProposalJob implements Traceable {
516
553
  // Create iterator to pending txs. We filter out txs already included in previous blocks in the checkpoint
517
554
  // just in case p2p failed to sync the provisional block and didn't get to remove those txs from the mempool yet.
518
555
  const pendingTxs = filter(
519
- this.p2pClient.iteratePendingTxs(),
556
+ this.p2pClient.iterateEligiblePendingTxs(),
520
557
  tx => !txHashesAlreadyIncluded.has(tx.txHash.toString()),
521
558
  );
522
559
 
@@ -650,7 +687,7 @@ export class CheckpointProposalJob implements Traceable {
650
687
  `Waiting for enough txs to build block ${blockNumber} at index ${indexWithinCheckpoint} in slot ${this.slot} (have ${availableTxs} but need ${minTxs})`,
651
688
  { blockNumber, slot: this.slot, indexWithinCheckpoint },
652
689
  );
653
- await sleep(TXS_POLLING_MS);
690
+ await this.waitForTxsPollingInterval();
654
691
  availableTxs = await this.p2pClient.getPendingTxCount();
655
692
  }
656
693
 
@@ -706,8 +743,20 @@ export class CheckpointProposalJob implements Traceable {
706
743
 
707
744
  collectedAttestationsCount = attestations.length;
708
745
 
746
+ // Trim attestations to minimum required to save L1 calldata gas
747
+ const localAddresses = this.validatorClient.getValidatorAddresses();
748
+ const trimmed = trimAttestations(
749
+ attestations,
750
+ numberOfRequiredAttestations,
751
+ this.attestorAddress,
752
+ localAddresses,
753
+ );
754
+ if (trimmed.length < attestations.length) {
755
+ this.log.debug(`Trimmed attestations from ${attestations.length} to ${trimmed.length} for L1 submission`);
756
+ }
757
+
709
758
  // Rollup contract requires that the signatures are provided in the order of the committee
710
- const sorted = orderAttestations(attestations, committee);
759
+ const sorted = orderAttestations(trimmed, committee);
711
760
 
712
761
  // Manipulate the attestations if we've been configured to do so
713
762
  if (this.config.injectFakeAttestation || this.config.shuffleAttestationOrdering) {
@@ -779,7 +828,7 @@ export class CheckpointProposalJob implements Traceable {
779
828
  const failedTxData = failedTxs.map(fail => fail.tx);
780
829
  const failedTxHashes = failedTxData.map(tx => tx.getTxHash());
781
830
  this.log.verbose(`Dropping failed txs ${failedTxHashes.join(', ')}`);
782
- await this.p2pClient.deleteTxs(failedTxHashes);
831
+ await this.p2pClient.handleFailedExecution(failedTxHashes);
783
832
  }
784
833
 
785
834
  /**
@@ -821,7 +870,7 @@ export class CheckpointProposalJob implements Traceable {
821
870
  slot: this.slot,
822
871
  feeAnalysisId: feeAnalysis?.id,
823
872
  });
824
- this.metrics.recordBlockProposalFailed('block_build_failed');
873
+ this.metrics.recordCheckpointProposalFailed('block_build_failed');
825
874
  }
826
875
 
827
876
  this.publisher.clearPendingRequests();
@@ -857,6 +906,11 @@ export class CheckpointProposalJob implements Traceable {
857
906
  await sleepUntil(new Date(targetTimestamp * 1000), this.dateProvider.nowAsDate());
858
907
  }
859
908
 
909
+ /** Waits the polling interval for transactions. Extracted for test overriding. */
910
+ protected async waitForTxsPollingInterval(): Promise<void> {
911
+ await sleep(TXS_POLLING_MS);
912
+ }
913
+
860
914
  private getSlotStartBuildTimestamp(): number {
861
915
  return getSlotStartBuildTimestamp(this.slot, this.l1Constants);
862
916
  }