@aztec/sequencer-client 0.0.1-commit.03f7ef2 → 0.0.1-commit.04852196a

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 (106) hide show
  1. package/dest/client/sequencer-client.d.ts +26 -11
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +99 -16
  4. package/dest/config.d.ts +24 -6
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +45 -28
  7. package/dest/global_variable_builder/global_builder.d.ts +5 -7
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +13 -13
  10. package/dest/index.d.ts +2 -3
  11. package/dest/index.d.ts.map +1 -1
  12. package/dest/index.js +1 -2
  13. package/dest/publisher/config.d.ts +35 -17
  14. package/dest/publisher/config.d.ts.map +1 -1
  15. package/dest/publisher/config.js +106 -42
  16. package/dest/publisher/index.d.ts +2 -1
  17. package/dest/publisher/index.d.ts.map +1 -1
  18. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  19. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  20. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  21. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
  22. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  23. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  24. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  25. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  26. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  27. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  28. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  29. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  30. package/dest/publisher/sequencer-publisher-factory.d.ts +12 -4
  31. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  32. package/dest/publisher/sequencer-publisher-factory.js +27 -2
  33. package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
  34. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  35. package/dest/publisher/sequencer-publisher-metrics.js +23 -86
  36. package/dest/publisher/sequencer-publisher.d.ts +44 -25
  37. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  38. package/dest/publisher/sequencer-publisher.js +781 -101
  39. package/dest/sequencer/checkpoint_proposal_job.d.ts +39 -13
  40. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  41. package/dest/sequencer/checkpoint_proposal_job.js +683 -79
  42. package/dest/sequencer/checkpoint_voter.d.ts +3 -2
  43. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  44. package/dest/sequencer/checkpoint_voter.js +34 -10
  45. package/dest/sequencer/index.d.ts +1 -3
  46. package/dest/sequencer/index.d.ts.map +1 -1
  47. package/dest/sequencer/index.js +0 -2
  48. package/dest/sequencer/metrics.d.ts +19 -7
  49. package/dest/sequencer/metrics.d.ts.map +1 -1
  50. package/dest/sequencer/metrics.js +131 -141
  51. package/dest/sequencer/sequencer.d.ts +46 -23
  52. package/dest/sequencer/sequencer.d.ts.map +1 -1
  53. package/dest/sequencer/sequencer.js +514 -67
  54. package/dest/sequencer/timetable.d.ts +4 -6
  55. package/dest/sequencer/timetable.d.ts.map +1 -1
  56. package/dest/sequencer/timetable.js +7 -11
  57. package/dest/sequencer/types.d.ts +5 -2
  58. package/dest/sequencer/types.d.ts.map +1 -1
  59. package/dest/test/index.d.ts +4 -7
  60. package/dest/test/index.d.ts.map +1 -1
  61. package/dest/test/mock_checkpoint_builder.d.ts +28 -16
  62. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  63. package/dest/test/mock_checkpoint_builder.js +86 -34
  64. package/dest/test/utils.d.ts +13 -9
  65. package/dest/test/utils.d.ts.map +1 -1
  66. package/dest/test/utils.js +27 -17
  67. package/package.json +30 -28
  68. package/src/client/sequencer-client.ts +139 -23
  69. package/src/config.ts +59 -38
  70. package/src/global_variable_builder/global_builder.ts +14 -14
  71. package/src/index.ts +1 -9
  72. package/src/publisher/config.ts +121 -43
  73. package/src/publisher/index.ts +3 -0
  74. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  75. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
  76. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  77. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  78. package/src/publisher/sequencer-publisher-factory.ts +39 -7
  79. package/src/publisher/sequencer-publisher-metrics.ts +17 -69
  80. package/src/publisher/sequencer-publisher.ts +420 -137
  81. package/src/sequencer/checkpoint_proposal_job.ts +361 -104
  82. package/src/sequencer/checkpoint_voter.ts +32 -7
  83. package/src/sequencer/index.ts +0 -2
  84. package/src/sequencer/metrics.ts +132 -148
  85. package/src/sequencer/sequencer.ts +160 -69
  86. package/src/sequencer/timetable.ts +13 -12
  87. package/src/sequencer/types.ts +4 -1
  88. package/src/test/index.ts +3 -6
  89. package/src/test/mock_checkpoint_builder.ts +147 -71
  90. package/src/test/utils.ts +58 -28
  91. package/dest/sequencer/block_builder.d.ts +0 -26
  92. package/dest/sequencer/block_builder.d.ts.map +0 -1
  93. package/dest/sequencer/block_builder.js +0 -129
  94. package/dest/sequencer/checkpoint_builder.d.ts +0 -63
  95. package/dest/sequencer/checkpoint_builder.d.ts.map +0 -1
  96. package/dest/sequencer/checkpoint_builder.js +0 -131
  97. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  98. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  99. package/dest/tx_validator/nullifier_cache.js +0 -24
  100. package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
  101. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  102. package/dest/tx_validator/tx_validator_factory.js +0 -53
  103. package/src/sequencer/block_builder.ts +0 -217
  104. package/src/sequencer/checkpoint_builder.ts +0 -217
  105. package/src/tx_validator/nullifier_cache.ts +0 -30
  106. package/src/tx_validator/tx_validator_factory.ts +0 -133
@@ -1,14 +1,14 @@
1
1
  import { Body } from '@aztec/aztec.js/block';
2
- import { CheckpointNumber } from '@aztec/foundation/branded-types';
2
+ import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
3
3
  import { times } from '@aztec/foundation/collection';
4
4
  import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import { Signature } from '@aztec/foundation/eth-signature';
6
6
  import { PublicDataWrite } from '@aztec/stdlib/avm';
7
- import { CommitteeAttestation, L2BlockNew } from '@aztec/stdlib/block';
8
- import { BlockAttestation, BlockProposal, ConsensusPayload } from '@aztec/stdlib/p2p';
7
+ import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
8
+ import { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload } from '@aztec/stdlib/p2p';
9
9
  import { CheckpointHeader } from '@aztec/stdlib/rollup';
10
10
  import { makeAppendOnlyTreeSnapshot, mockTxForRollup } from '@aztec/stdlib/testing';
11
- import { BlockHeader, ContentCommitment, makeProcessedTxFromPrivateOnlyTx } from '@aztec/stdlib/tx';
11
+ import { BlockHeader, makeProcessedTxFromPrivateOnlyTx } from '@aztec/stdlib/tx';
12
12
  // Re-export mock classes from their dedicated file
13
13
  export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint_builder.js';
14
14
  /**
@@ -21,7 +21,7 @@ export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint
21
21
  return tx;
22
22
  }
23
23
  /**
24
- * Creates an L2BlockNew from transactions and global variables
24
+ * Creates an L2Block from transactions and global variables
25
25
  */ export async function makeBlock(txs, globalVariables) {
26
26
  const processedTxs = await Promise.all(txs.map((tx)=>makeProcessedTxFromPrivateOnlyTx(tx, Fr.ZERO, new PublicDataWrite(Fr.random(), Fr.random()), globalVariables)));
27
27
  const body = new Body(processedTxs.map((tx)=>tx.txEffect));
@@ -29,13 +29,14 @@ export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint
29
29
  globalVariables
30
30
  });
31
31
  const archive = makeAppendOnlyTreeSnapshot(globalVariables.blockNumber + 1);
32
- return new L2BlockNew(archive, header, body, CheckpointNumber(globalVariables.blockNumber), 0);
32
+ return new L2Block(archive, header, body, CheckpointNumber.fromBlockNumber(globalVariables.blockNumber), IndexWithinCheckpoint(0));
33
33
  }
34
34
  /**
35
35
  * Mocks the P2P client to return specific pending transactions
36
36
  */ export function mockPendingTxs(p2p, txs) {
37
37
  p2p.getPendingTxCount.mockResolvedValue(txs.length);
38
38
  p2p.iteratePendingTxs.mockImplementation(()=>mockTxIterator(Promise.resolve(txs)));
39
+ p2p.iterateEligiblePendingTxs.mockImplementation(()=>mockTxIterator(Promise.resolve(txs)));
39
40
  }
40
41
  /**
41
42
  * Creates an async iterator for transactions
@@ -53,29 +54,38 @@ export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint
53
54
  ];
54
55
  }
55
56
  /**
56
- * Creates a CheckpointHeader from an L2BlockNew for testing purposes.
57
- * Uses mock values for contentCommitment and blockHeadersHash since
58
- * L2BlockNew doesn't have these fields.
57
+ * Creates a CheckpointHeader from an L2Block for testing purposes.
58
+ * Uses mock values for blockHeadersHash, blobsHash and inHash since L2Block doesn't have these fields.
59
59
  */ function createCheckpointHeaderFromBlock(block) {
60
60
  const gv = block.header.globalVariables;
61
- return new CheckpointHeader(block.header.lastArchive.root, Fr.random(), ContentCommitment.empty(), gv.slotNumber, gv.timestamp, gv.coinbase, gv.feeRecipient, gv.gasFees, block.header.totalManaUsed);
61
+ return new CheckpointHeader(block.header.lastArchive.root, Fr.random(), Fr.random(), Fr.random(), Fr.random(), gv.slotNumber, gv.timestamp, gv.coinbase, gv.feeRecipient, gv.gasFees, block.header.totalManaUsed);
62
62
  }
63
63
  /**
64
64
  * Creates a block proposal from a block and signature
65
65
  */ export function createBlockProposal(block, signature) {
66
- const checkpointHeader = createCheckpointHeaderFromBlock(block);
67
- const consensusPayload = new ConsensusPayload(checkpointHeader, block.archive.root);
68
66
  const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
69
- return new BlockProposal(consensusPayload, signature, txHashes);
67
+ return new BlockProposal(block.header, block.indexWithinCheckpoint, Fr.ZERO, block.archive.root, txHashes, signature);
68
+ }
69
+ /**
70
+ * Creates a checkpoint proposal from a block and signature
71
+ */ export function createCheckpointProposal(block, checkpointSignature, blockSignature, feeAssetPriceModifier = 0n) {
72
+ const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
73
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
74
+ return new CheckpointProposal(checkpointHeader, block.archive.root, feeAssetPriceModifier, checkpointSignature, {
75
+ blockHeader: block.header,
76
+ indexWithinCheckpoint: block.indexWithinCheckpoint,
77
+ txHashes,
78
+ signature: blockSignature ?? checkpointSignature
79
+ });
70
80
  }
71
81
  /**
72
- * Creates a block attestation from a block and signature.
82
+ * Creates a checkpoint attestation from a block and signature.
73
83
  * Note: We manually set the sender since we use random signatures in tests.
74
84
  * In production, the sender is recovered from the signature.
75
- */ export function createBlockAttestation(block, signature, sender) {
85
+ */ export function createCheckpointAttestation(block, signature, sender, feeAssetPriceModifier = 0n) {
76
86
  const checkpointHeader = createCheckpointHeaderFromBlock(block);
77
- const consensusPayload = new ConsensusPayload(checkpointHeader, block.archive.root);
78
- const attestation = new BlockAttestation(consensusPayload, signature, signature);
87
+ const payload = new ConsensusPayload(checkpointHeader, block.archive.root, feeAssetPriceModifier);
88
+ const attestation = new CheckpointAttestation(payload, signature, signature);
79
89
  // Set sender directly for testing (bypasses signature recovery)
80
90
  attestation.sender = sender;
81
91
  return attestation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/sequencer-client",
3
- "version": "0.0.1-commit.03f7ef2",
3
+ "version": "0.0.1-commit.04852196a",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -26,43 +26,45 @@
26
26
  "test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
27
27
  },
28
28
  "dependencies": {
29
- "@aztec/aztec.js": "0.0.1-commit.03f7ef2",
30
- "@aztec/bb-prover": "0.0.1-commit.03f7ef2",
31
- "@aztec/blob-client": "0.0.1-commit.03f7ef2",
32
- "@aztec/blob-lib": "0.0.1-commit.03f7ef2",
33
- "@aztec/constants": "0.0.1-commit.03f7ef2",
34
- "@aztec/epoch-cache": "0.0.1-commit.03f7ef2",
35
- "@aztec/ethereum": "0.0.1-commit.03f7ef2",
36
- "@aztec/foundation": "0.0.1-commit.03f7ef2",
37
- "@aztec/l1-artifacts": "0.0.1-commit.03f7ef2",
38
- "@aztec/merkle-tree": "0.0.1-commit.03f7ef2",
39
- "@aztec/node-keystore": "0.0.1-commit.03f7ef2",
40
- "@aztec/noir-acvm_js": "0.0.1-commit.03f7ef2",
41
- "@aztec/noir-contracts.js": "0.0.1-commit.03f7ef2",
42
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.03f7ef2",
43
- "@aztec/noir-types": "0.0.1-commit.03f7ef2",
44
- "@aztec/p2p": "0.0.1-commit.03f7ef2",
45
- "@aztec/protocol-contracts": "0.0.1-commit.03f7ef2",
46
- "@aztec/prover-client": "0.0.1-commit.03f7ef2",
47
- "@aztec/simulator": "0.0.1-commit.03f7ef2",
48
- "@aztec/slasher": "0.0.1-commit.03f7ef2",
49
- "@aztec/stdlib": "0.0.1-commit.03f7ef2",
50
- "@aztec/telemetry-client": "0.0.1-commit.03f7ef2",
51
- "@aztec/validator-client": "0.0.1-commit.03f7ef2",
52
- "@aztec/world-state": "0.0.1-commit.03f7ef2",
29
+ "@aztec/aztec.js": "0.0.1-commit.04852196a",
30
+ "@aztec/bb-prover": "0.0.1-commit.04852196a",
31
+ "@aztec/blob-client": "0.0.1-commit.04852196a",
32
+ "@aztec/blob-lib": "0.0.1-commit.04852196a",
33
+ "@aztec/constants": "0.0.1-commit.04852196a",
34
+ "@aztec/epoch-cache": "0.0.1-commit.04852196a",
35
+ "@aztec/ethereum": "0.0.1-commit.04852196a",
36
+ "@aztec/foundation": "0.0.1-commit.04852196a",
37
+ "@aztec/l1-artifacts": "0.0.1-commit.04852196a",
38
+ "@aztec/merkle-tree": "0.0.1-commit.04852196a",
39
+ "@aztec/node-keystore": "0.0.1-commit.04852196a",
40
+ "@aztec/noir-acvm_js": "0.0.1-commit.04852196a",
41
+ "@aztec/noir-contracts.js": "0.0.1-commit.04852196a",
42
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.04852196a",
43
+ "@aztec/noir-types": "0.0.1-commit.04852196a",
44
+ "@aztec/p2p": "0.0.1-commit.04852196a",
45
+ "@aztec/protocol-contracts": "0.0.1-commit.04852196a",
46
+ "@aztec/prover-client": "0.0.1-commit.04852196a",
47
+ "@aztec/simulator": "0.0.1-commit.04852196a",
48
+ "@aztec/slasher": "0.0.1-commit.04852196a",
49
+ "@aztec/stdlib": "0.0.1-commit.04852196a",
50
+ "@aztec/telemetry-client": "0.0.1-commit.04852196a",
51
+ "@aztec/validator-client": "0.0.1-commit.04852196a",
52
+ "@aztec/validator-ha-signer": "0.0.1-commit.04852196a",
53
+ "@aztec/world-state": "0.0.1-commit.04852196a",
53
54
  "lodash.chunk": "^4.2.0",
54
55
  "tslib": "^2.4.0",
55
56
  "viem": "npm:@aztec/viem@2.38.2"
56
57
  },
57
58
  "devDependencies": {
58
- "@aztec/archiver": "0.0.1-commit.03f7ef2",
59
- "@aztec/kv-store": "0.0.1-commit.03f7ef2",
59
+ "@aztec/archiver": "0.0.1-commit.04852196a",
60
+ "@aztec/kv-store": "0.0.1-commit.04852196a",
61
+ "@electric-sql/pglite": "^0.3.14",
60
62
  "@jest/globals": "^30.0.0",
61
63
  "@types/jest": "^30.0.0",
62
64
  "@types/lodash.chunk": "^4.2.7",
63
65
  "@types/lodash.pick": "^4.4.7",
64
66
  "@types/node": "^22.15.17",
65
- "@typescript/native-preview": "7.0.0-dev.20251126.1",
67
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
66
68
  "concurrently": "^7.6.0",
67
69
  "eslint": "^9.26.0",
68
70
  "express": "^4.21.2",
@@ -1,9 +1,10 @@
1
1
  import type { BlobClientInterface } from '@aztec/blob-client/client';
2
+ import { MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
2
3
  import { EpochCache } from '@aztec/epoch-cache';
3
4
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
4
5
  import { getPublicClient } from '@aztec/ethereum/client';
5
6
  import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
6
- import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
7
+ import { type Delayer, L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
7
8
  import { PublisherManager } from '@aztec/ethereum/publisher-manager';
8
9
  import { EthAddress } from '@aztec/foundation/eth-address';
9
10
  import { createLogger } from '@aztec/foundation/log';
@@ -11,29 +12,34 @@ import type { DateProvider } from '@aztec/foundation/timer';
11
12
  import type { KeystoreManager } from '@aztec/node-keystore';
12
13
  import type { P2P } from '@aztec/p2p';
13
14
  import type { SlasherClientInterface } from '@aztec/slasher';
14
- import type { L2BlockSource } from '@aztec/stdlib/block';
15
+ import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
15
16
  import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
16
17
  import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
17
18
  import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
18
19
  import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
19
- import { NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
20
+ import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
20
21
 
21
- import type { SequencerClientConfig } from '../config.js';
22
+ import {
23
+ DefaultSequencerConfig,
24
+ type SequencerClientConfig,
25
+ getPublisherConfigFromSequencerConfig,
26
+ } from '../config.js';
22
27
  import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
23
28
  import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
24
- import { FullNodeCheckpointsBuilder } from '../sequencer/checkpoint_builder.js';
25
29
  import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
30
+ import { SequencerTimetable } from '../sequencer/timetable.js';
26
31
 
27
32
  /**
28
33
  * Encapsulates the full sequencer and publisher.
29
34
  */
30
35
  export class SequencerClient {
31
36
  constructor(
32
- protected publisherManager: PublisherManager<L1TxUtilsWithBlobs>,
37
+ protected publisherManager: PublisherManager<L1TxUtils>,
33
38
  protected sequencer: Sequencer,
34
39
  protected checkpointsBuilder: FullNodeCheckpointsBuilder,
35
40
  protected validatorClient?: ValidatorClient,
36
41
  private l1Metrics?: L1Metrics,
42
+ private delayer_?: Delayer,
37
43
  ) {}
38
44
 
39
45
  /**
@@ -56,14 +62,14 @@ export class SequencerClient {
56
62
  worldStateSynchronizer: WorldStateSynchronizer;
57
63
  slasherClient: SlasherClientInterface | undefined;
58
64
  checkpointsBuilder: FullNodeCheckpointsBuilder;
59
- l2BlockSource: L2BlockSource;
65
+ l2BlockSource: L2BlockSource & L2BlockSink;
60
66
  l1ToL2MessageSource: L1ToL2MessageSource;
61
67
  telemetry: TelemetryClient;
62
68
  publisherFactory?: SequencerPublisherFactory;
63
- blobClient?: BlobClientInterface;
69
+ blobClient: BlobClientInterface;
64
70
  dateProvider: DateProvider;
65
71
  epochCache?: EpochCache;
66
- l1TxUtils: L1TxUtilsWithBlobs[];
72
+ l1TxUtils: L1TxUtils[];
67
73
  nodeKeyStore: KeystoreManager;
68
74
  },
69
75
  ) {
@@ -86,7 +92,11 @@ export class SequencerClient {
86
92
  publicClient,
87
93
  l1TxUtils.map(x => x.getSenderAddress()),
88
94
  );
89
- const publisherManager = new PublisherManager(l1TxUtils, config);
95
+ const publisherManager = new PublisherManager(
96
+ l1TxUtils,
97
+ getPublisherConfigFromSequencerConfig(config),
98
+ log.getBindings(),
99
+ );
90
100
  const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
91
101
  const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
92
102
  rollupContract.getL1GenesisTime(),
@@ -133,17 +143,14 @@ export class SequencerClient {
133
143
  });
134
144
 
135
145
  const ethereumSlotDuration = config.ethereumSlotDuration;
136
- const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
137
-
138
- const globalsBuilder = new GlobalVariableBuilder({ ...config, ...l1Constants, rollupVersion });
139
146
 
140
- let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
141
- if (sequencerManaLimit > rollupManaLimit) {
142
- log.warn(
143
- `Provided maxL2BlockGas ${sequencerManaLimit} is greater than the max allowed by L1. Setting limit to ${rollupManaLimit}.`,
144
- );
145
- sequencerManaLimit = rollupManaLimit;
146
- }
147
+ const globalsBuilder = new GlobalVariableBuilder({
148
+ ...config,
149
+ l1GenesisTime,
150
+ slotDuration: Number(slotDuration),
151
+ ethereumSlotDuration,
152
+ rollupVersion,
153
+ });
147
154
 
148
155
  // When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
149
156
  // Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
@@ -153,6 +160,15 @@ export class SequencerClient {
153
160
  const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
154
161
  const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
155
162
 
163
+ const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = computeBlockLimits(
164
+ config,
165
+ rollupManaLimit,
166
+ l1PublishingTime,
167
+ log,
168
+ );
169
+
170
+ const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration, rollupManaLimit };
171
+
156
172
  const sequencer = new Sequencer(
157
173
  publisherFactory,
158
174
  validatorClient,
@@ -167,14 +183,17 @@ export class SequencerClient {
167
183
  deps.dateProvider,
168
184
  epochCache,
169
185
  rollupContract,
170
- { ...config, l1PublishingTime, maxL2BlockGas: sequencerManaLimit },
186
+ { ...config, l1PublishingTime, maxL2BlockGas, maxDABlockGas, maxTxsPerBlock },
171
187
  telemetryClient,
172
188
  log,
173
189
  );
174
190
 
175
- await sequencer.init();
191
+ sequencer.init();
192
+
193
+ // Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
194
+ const delayer = l1TxUtils[0]?.delayer;
176
195
 
177
- return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics);
196
+ return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics, delayer);
178
197
  }
179
198
 
180
199
  /**
@@ -209,6 +228,16 @@ export class SequencerClient {
209
228
  return this.sequencer;
210
229
  }
211
230
 
231
+ /** Updates the publisher factory's node keystore adapter after a keystore reload. */
232
+ public updatePublisherNodeKeyStore(adapter: NodeKeystoreAdapter): void {
233
+ this.sequencer.updatePublisherNodeKeyStore(adapter);
234
+ }
235
+
236
+ /** Returns the shared tx delayer for sequencer L1 txs, if enabled. Test-only. */
237
+ getDelayer(): Delayer | undefined {
238
+ return this.delayer_;
239
+ }
240
+
212
241
  get validatorAddresses(): EthAddress[] | undefined {
213
242
  return this.sequencer.getValidatorAddresses();
214
243
  }
@@ -217,3 +246,90 @@ export class SequencerClient {
217
246
  return this.sequencer.maxL2BlockGas;
218
247
  }
219
248
  }
249
+
250
+ /**
251
+ * Computes per-block L2 gas, DA gas, and TX count budgets based on the L1 rollup limits and the timetable.
252
+ * If the user explicitly set a limit, it is capped at the corresponding checkpoint limit.
253
+ * Otherwise, derives it as (checkpointLimit / maxBlocks) * multiplier, capped at the checkpoint limit.
254
+ */
255
+ export function computeBlockLimits(
256
+ config: SequencerClientConfig,
257
+ rollupManaLimit: number,
258
+ l1PublishingTime: number,
259
+ log: ReturnType<typeof createLogger>,
260
+ ): { maxL2BlockGas: number; maxDABlockGas: number; maxTxsPerBlock: number } {
261
+ const maxNumberOfBlocks = new SequencerTimetable({
262
+ ethereumSlotDuration: config.ethereumSlotDuration,
263
+ aztecSlotDuration: config.aztecSlotDuration,
264
+ l1PublishingTime,
265
+ p2pPropagationTime: config.attestationPropagationTime,
266
+ blockDurationMs: config.blockDurationMs,
267
+ enforce: config.enforceTimeTable ?? DefaultSequencerConfig.enforceTimeTable,
268
+ }).maxNumberOfBlocks;
269
+
270
+ const multiplier = config.perBlockAllocationMultiplier ?? DefaultSequencerConfig.perBlockAllocationMultiplier;
271
+
272
+ // Compute maxL2BlockGas
273
+ let maxL2BlockGas: number;
274
+ if (config.maxL2BlockGas !== undefined) {
275
+ if (config.maxL2BlockGas > rollupManaLimit) {
276
+ log.warn(
277
+ `Provided MAX_L2_BLOCK_GAS ${config.maxL2BlockGas} exceeds L1 rollup mana limit ${rollupManaLimit} (capping)`,
278
+ );
279
+ maxL2BlockGas = rollupManaLimit;
280
+ } else {
281
+ maxL2BlockGas = config.maxL2BlockGas;
282
+ }
283
+ } else {
284
+ maxL2BlockGas = Math.min(rollupManaLimit, Math.ceil((rollupManaLimit / maxNumberOfBlocks) * multiplier));
285
+ }
286
+
287
+ // Compute maxDABlockGas
288
+ const daCheckpointLimit = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
289
+ let maxDABlockGas: number;
290
+ if (config.maxDABlockGas !== undefined) {
291
+ if (config.maxDABlockGas > daCheckpointLimit) {
292
+ log.warn(
293
+ `Provided MAX_DA_BLOCK_GAS ${config.maxDABlockGas} exceeds DA checkpoint limit ${daCheckpointLimit} (capping)`,
294
+ );
295
+ maxDABlockGas = daCheckpointLimit;
296
+ } else {
297
+ maxDABlockGas = config.maxDABlockGas;
298
+ }
299
+ } else {
300
+ maxDABlockGas = Math.min(daCheckpointLimit, Math.ceil((daCheckpointLimit / maxNumberOfBlocks) * multiplier));
301
+ }
302
+
303
+ // Compute maxTxsPerBlock
304
+ const defaultMaxTxsPerBlock = 32;
305
+ let maxTxsPerBlock: number;
306
+ if (config.maxTxsPerBlock !== undefined) {
307
+ if (config.maxTxsPerCheckpoint !== undefined && config.maxTxsPerBlock > config.maxTxsPerCheckpoint) {
308
+ log.warn(
309
+ `Provided MAX_TX_PER_BLOCK ${config.maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`,
310
+ );
311
+ maxTxsPerBlock = config.maxTxsPerCheckpoint;
312
+ } else {
313
+ maxTxsPerBlock = config.maxTxsPerBlock;
314
+ }
315
+ } else if (config.maxTxsPerCheckpoint !== undefined) {
316
+ maxTxsPerBlock = Math.min(
317
+ config.maxTxsPerCheckpoint,
318
+ Math.ceil((config.maxTxsPerCheckpoint / maxNumberOfBlocks) * multiplier),
319
+ );
320
+ } else {
321
+ maxTxsPerBlock = defaultMaxTxsPerBlock;
322
+ }
323
+
324
+ log.info(`Computed block limits L2=${maxL2BlockGas} DA=${maxDABlockGas} maxTxs=${maxTxsPerBlock}`, {
325
+ maxL2BlockGas,
326
+ maxDABlockGas,
327
+ maxTxsPerBlock,
328
+ rollupManaLimit,
329
+ daCheckpointLimit,
330
+ maxNumberOfBlocks,
331
+ multiplier,
332
+ });
333
+
334
+ return { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock };
335
+ }
package/src/config.ts CHANGED
@@ -11,58 +11,63 @@ import { EthAddress } from '@aztec/foundation/eth-address';
11
11
  import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
12
12
  import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
13
13
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
- import { type ChainConfig, type SequencerConfig, chainConfigMappings } from '@aztec/stdlib/config';
14
+ import {
15
+ type ChainConfig,
16
+ type SequencerConfig,
17
+ chainConfigMappings,
18
+ sharedSequencerConfigMappings,
19
+ } from '@aztec/stdlib/config';
15
20
  import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
21
+ import { DEFAULT_P2P_PROPAGATION_TIME } from '@aztec/stdlib/timetable';
16
22
  import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
17
23
 
18
24
  import {
19
- type PublisherConfig,
20
- type TxSenderConfig,
21
- getPublisherConfigMappings,
22
- getTxSenderConfigMappings,
25
+ type SequencerPublisherConfig,
26
+ type SequencerTxSenderConfig,
27
+ sequencerPublisherConfigMappings,
28
+ sequencerTxSenderConfigMappings,
23
29
  } from './publisher/config.js';
24
30
 
25
31
  export * from './publisher/config.js';
26
32
  export type { SequencerConfig };
27
33
 
28
- export const DEFAULT_ATTESTATION_PROPAGATION_TIME = 2;
29
-
30
34
  /**
31
35
  * Default values for SequencerConfig.
32
36
  * Centralized location for all sequencer configuration defaults.
33
37
  */
34
- export const DefaultSequencerConfig: ResolvedSequencerConfig = {
38
+ export const DefaultSequencerConfig = {
35
39
  sequencerPollingIntervalMS: 500,
36
- maxTxsPerBlock: 32,
37
40
  minTxsPerBlock: 1,
38
41
  buildCheckpointIfEmpty: false,
39
42
  publishTxsWithProposals: false,
40
- maxL2BlockGas: 10e9,
41
- maxDABlockGas: 10e9,
42
- maxBlockSizeInBytes: 1024 * 1024,
43
+ perBlockAllocationMultiplier: 2,
43
44
  enforceTimeTable: true,
44
- attestationPropagationTime: DEFAULT_ATTESTATION_PROPAGATION_TIME,
45
+ attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
45
46
  secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
46
47
  secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
47
48
  skipCollectingAttestations: false,
48
49
  skipInvalidateBlockAsProposer: false,
49
50
  broadcastInvalidBlockProposal: false,
50
51
  injectFakeAttestation: false,
52
+ injectHighSValueAttestation: false,
53
+ injectUnrecoverableSignatureAttestation: false,
51
54
  fishermanMode: false,
52
55
  shuffleAttestationOrdering: false,
53
- };
56
+ skipPushProposedBlocksToArchiver: false,
57
+ skipPublishingCheckpointsPercent: 0,
58
+ } satisfies ResolvedSequencerConfig;
54
59
 
55
60
  /**
56
61
  * Configuration settings for the SequencerClient.
57
62
  */
58
- export type SequencerClientConfig = PublisherConfig &
63
+ export type SequencerClientConfig = SequencerPublisherConfig &
59
64
  KeyStoreConfig &
60
65
  ValidatorClientConfig &
61
- TxSenderConfig &
66
+ SequencerTxSenderConfig &
62
67
  SequencerConfig &
63
68
  L1ReaderConfig &
64
69
  ChainConfig &
65
- Pick<P2PConfig, 'txPublicSetupAllowList'> &
70
+ Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
66
71
  Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
67
72
 
68
73
  export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
@@ -71,10 +76,10 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
71
76
  description: 'The number of ms to wait between polling for checking to build on the next slot.',
72
77
  ...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
73
78
  },
74
- maxTxsPerBlock: {
75
- env: 'SEQ_MAX_TX_PER_BLOCK',
76
- description: 'The maximum number of txs to include in a block.',
77
- ...numberConfigHelper(DefaultSequencerConfig.maxTxsPerBlock),
79
+ maxTxsPerCheckpoint: {
80
+ env: 'SEQ_MAX_TX_PER_CHECKPOINT',
81
+ description: 'The maximum number of txs across all blocks in a checkpoint.',
82
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
78
83
  },
79
84
  minTxsPerBlock: {
80
85
  env: 'SEQ_MIN_TX_PER_BLOCK',
@@ -93,12 +98,19 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
93
98
  maxL2BlockGas: {
94
99
  env: 'SEQ_MAX_L2_BLOCK_GAS',
95
100
  description: 'The maximum L2 block gas.',
96
- ...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas),
101
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
97
102
  },
98
103
  maxDABlockGas: {
99
104
  env: 'SEQ_MAX_DA_BLOCK_GAS',
100
105
  description: 'The maximum DA block gas.',
101
- ...numberConfigHelper(DefaultSequencerConfig.maxDABlockGas),
106
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
107
+ },
108
+ perBlockAllocationMultiplier: {
109
+ env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
110
+ description:
111
+ 'Per-block gas budget multiplier for both L2 and DA gas. Budget per block is (checkpointLimit / maxBlocks) * multiplier.' +
112
+ ' Values greater than one allow early blocks to use more than their even share, relying on checkpoint-level capping for later blocks.',
113
+ ...numberConfigHelper(DefaultSequencerConfig.perBlockAllocationMultiplier),
102
114
  },
103
115
  coinbase: {
104
116
  env: 'COINBASE',
@@ -118,11 +130,6 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
118
130
  env: 'ACVM_BINARY_PATH',
119
131
  description: 'The path to the ACVM binary',
120
132
  },
121
- maxBlockSizeInBytes: {
122
- env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
123
- description: 'Max block size',
124
- ...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
125
- },
126
133
  enforceTimeTable: {
127
134
  env: 'SEQ_ENFORCE_TIME_TABLE',
128
135
  description: 'Whether to enforce the time table when building blocks',
@@ -180,6 +187,14 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
180
187
  description: 'Inject a fake attestation (for testing only)',
181
188
  ...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
182
189
  },
190
+ injectHighSValueAttestation: {
191
+ description: 'Inject a malleable attestation with a high-s value (for testing only)',
192
+ ...booleanConfigHelper(DefaultSequencerConfig.injectHighSValueAttestation),
193
+ },
194
+ injectUnrecoverableSignatureAttestation: {
195
+ description: 'Inject an attestation with an unrecoverable signature (for testing only)',
196
+ ...booleanConfigHelper(DefaultSequencerConfig.injectUnrecoverableSignatureAttestation),
197
+ },
183
198
  fishermanMode: {
184
199
  env: 'FISHERMAN_MODE',
185
200
  description:
@@ -190,19 +205,25 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
190
205
  description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
191
206
  ...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
192
207
  },
193
- blockDurationMs: {
194
- env: 'SEQ_BLOCK_DURATION_MS',
195
- description:
196
- 'Duration per block in milliseconds when building multiple blocks per slot. ' +
197
- 'If undefined (default), builds a single block per slot using the full slot duration.',
198
- parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
199
- },
208
+ ...sharedSequencerConfigMappings,
200
209
  buildCheckpointIfEmpty: {
201
210
  env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
202
211
  description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
203
212
  ...booleanConfigHelper(DefaultSequencerConfig.buildCheckpointIfEmpty),
204
213
  },
205
- ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
214
+ skipPushProposedBlocksToArchiver: {
215
+ description: 'Skip pushing proposed blocks to archiver (default: true)',
216
+ ...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
217
+ },
218
+ minBlocksForCheckpoint: {
219
+ description: 'Minimum number of blocks required for a checkpoint proposal (test only)',
220
+ },
221
+ skipPublishingCheckpointsPercent: {
222
+ env: 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT',
223
+ description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
224
+ ...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent),
225
+ },
226
+ ...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowListExtend']),
206
227
  };
207
228
 
208
229
  export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
@@ -210,8 +231,8 @@ export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientCo
210
231
  ...sequencerConfigMappings,
211
232
  ...keyStoreConfigMappings,
212
233
  ...l1ReaderConfigMappings,
213
- ...getTxSenderConfigMappings('SEQ'),
214
- ...getPublisherConfigMappings('SEQ'),
234
+ ...sequencerTxSenderConfigMappings,
235
+ ...sequencerPublisherConfigMappings,
215
236
  ...chainConfigMappings,
216
237
  ...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
217
238
  };