@aztec/sequencer-client 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa

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 (165) hide show
  1. package/README.md +281 -21
  2. package/dest/client/index.d.ts +1 -1
  3. package/dest/client/sequencer-client.d.ts +41 -18
  4. package/dest/client/sequencer-client.d.ts.map +1 -1
  5. package/dest/client/sequencer-client.js +88 -42
  6. package/dest/config.d.ts +41 -8
  7. package/dest/config.d.ts.map +1 -1
  8. package/dest/config.js +153 -53
  9. package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
  10. package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
  11. package/dest/global_variable_builder/fee_predictor.js +138 -0
  12. package/dest/global_variable_builder/fee_provider.d.ts +21 -0
  13. package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
  14. package/dest/global_variable_builder/fee_provider.js +80 -0
  15. package/dest/global_variable_builder/global_builder.d.ts +20 -29
  16. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  17. package/dest/global_variable_builder/global_builder.js +28 -72
  18. package/dest/global_variable_builder/index.d.ts +4 -2
  19. package/dest/global_variable_builder/index.d.ts.map +1 -1
  20. package/dest/global_variable_builder/index.js +2 -0
  21. package/dest/index.d.ts +2 -3
  22. package/dest/index.d.ts.map +1 -1
  23. package/dest/index.js +1 -2
  24. package/dest/publisher/config.d.ts +59 -20
  25. package/dest/publisher/config.d.ts.map +1 -1
  26. package/dest/publisher/config.js +134 -34
  27. package/dest/publisher/index.d.ts +2 -1
  28. package/dest/publisher/index.d.ts.map +1 -1
  29. package/dest/publisher/l1_to_l2_messaging.d.ts +21 -0
  30. package/dest/publisher/l1_to_l2_messaging.d.ts.map +1 -0
  31. package/dest/publisher/l1_to_l2_messaging.js +70 -0
  32. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  33. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  34. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  35. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +98 -0
  36. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  37. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +68 -0
  38. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  39. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  40. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +36 -0
  41. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  42. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  43. package/dest/publisher/l1_tx_failed_store/index.js +3 -0
  44. package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
  45. package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
  46. package/dest/publisher/sequencer-bundle-simulator.js +198 -0
  47. package/dest/publisher/sequencer-publisher-factory.d.ts +15 -8
  48. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  49. package/dest/publisher/sequencer-publisher-factory.js +28 -4
  50. package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
  51. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  52. package/dest/publisher/sequencer-publisher-metrics.js +23 -86
  53. package/dest/publisher/sequencer-publisher.d.ts +164 -96
  54. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  55. package/dest/publisher/sequencer-publisher.js +1305 -416
  56. package/dest/publisher/write_json.d.ts +11 -0
  57. package/dest/publisher/write_json.d.ts.map +1 -0
  58. package/dest/publisher/write_json.js +57 -0
  59. package/dest/sequencer/automine/automine_factory.d.ts +56 -0
  60. package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
  61. package/dest/sequencer/automine/automine_factory.js +85 -0
  62. package/dest/sequencer/automine/automine_sequencer.d.ts +189 -0
  63. package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
  64. package/dest/sequencer/automine/automine_sequencer.js +690 -0
  65. package/dest/sequencer/automine/index.d.ts +3 -0
  66. package/dest/sequencer/automine/index.d.ts.map +1 -0
  67. package/dest/sequencer/automine/index.js +2 -0
  68. package/dest/sequencer/checkpoint_proposal_job.d.ts +158 -0
  69. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  70. package/dest/sequencer/checkpoint_proposal_job.js +1801 -0
  71. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
  72. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
  73. package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
  74. package/dest/sequencer/checkpoint_voter.d.ts +34 -0
  75. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  76. package/dest/sequencer/checkpoint_voter.js +106 -0
  77. package/dest/sequencer/config.d.ts +3 -2
  78. package/dest/sequencer/config.d.ts.map +1 -1
  79. package/dest/sequencer/errors.d.ts +1 -1
  80. package/dest/sequencer/errors.d.ts.map +1 -1
  81. package/dest/sequencer/events.d.ts +103 -0
  82. package/dest/sequencer/events.d.ts.map +1 -0
  83. package/dest/sequencer/events.js +1 -0
  84. package/dest/sequencer/index.d.ts +4 -2
  85. package/dest/sequencer/index.d.ts.map +1 -1
  86. package/dest/sequencer/index.js +3 -1
  87. package/dest/sequencer/metrics.d.ts +48 -4
  88. package/dest/sequencer/metrics.d.ts.map +1 -1
  89. package/dest/sequencer/metrics.js +257 -50
  90. package/dest/sequencer/requests_tracker.d.ts +22 -0
  91. package/dest/sequencer/requests_tracker.d.ts.map +1 -0
  92. package/dest/sequencer/requests_tracker.js +33 -0
  93. package/dest/sequencer/sequencer.d.ts +253 -148
  94. package/dest/sequencer/sequencer.d.ts.map +1 -1
  95. package/dest/sequencer/sequencer.js +1208 -598
  96. package/dest/sequencer/types.d.ts +3 -0
  97. package/dest/sequencer/types.d.ts.map +1 -0
  98. package/dest/sequencer/types.js +1 -0
  99. package/dest/sequencer/utils.d.ts +14 -8
  100. package/dest/sequencer/utils.d.ts.map +1 -1
  101. package/dest/sequencer/utils.js +7 -4
  102. package/dest/test/index.d.ts +8 -9
  103. package/dest/test/index.d.ts.map +1 -1
  104. package/dest/test/mock_checkpoint_builder.d.ts +95 -0
  105. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  106. package/dest/test/mock_checkpoint_builder.js +231 -0
  107. package/dest/test/utils.d.ts +67 -0
  108. package/dest/test/utils.d.ts.map +1 -0
  109. package/dest/test/utils.js +122 -0
  110. package/package.json +34 -30
  111. package/src/client/sequencer-client.ts +118 -66
  112. package/src/config.ts +181 -62
  113. package/src/global_variable_builder/README.md +44 -0
  114. package/src/global_variable_builder/fee_predictor.ts +182 -0
  115. package/src/global_variable_builder/fee_provider.ts +97 -0
  116. package/src/global_variable_builder/global_builder.ts +45 -106
  117. package/src/global_variable_builder/index.ts +3 -1
  118. package/src/index.ts +1 -7
  119. package/src/publisher/config.ts +190 -46
  120. package/src/publisher/index.ts +3 -0
  121. package/src/publisher/l1_to_l2_messaging.ts +85 -0
  122. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  123. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +164 -0
  124. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +47 -0
  125. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  126. package/src/publisher/sequencer-bundle-simulator.ts +254 -0
  127. package/src/publisher/sequencer-publisher-factory.ts +45 -14
  128. package/src/publisher/sequencer-publisher-metrics.ts +19 -71
  129. package/src/publisher/sequencer-publisher.ts +1109 -538
  130. package/src/publisher/write_json.ts +78 -0
  131. package/src/sequencer/README.md +243 -0
  132. package/src/sequencer/automine/README.md +60 -0
  133. package/src/sequencer/automine/automine_factory.ts +152 -0
  134. package/src/sequencer/automine/automine_sequencer.ts +796 -0
  135. package/src/sequencer/automine/index.ts +6 -0
  136. package/src/sequencer/checkpoint_proposal_job.ts +1652 -0
  137. package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
  138. package/src/sequencer/checkpoint_voter.ts +119 -0
  139. package/src/sequencer/config.ts +2 -1
  140. package/src/sequencer/events.ts +88 -0
  141. package/src/sequencer/index.ts +3 -1
  142. package/src/sequencer/metrics.ts +330 -62
  143. package/src/sequencer/requests_tracker.ts +43 -0
  144. package/src/sequencer/sequencer.ts +1033 -777
  145. package/src/sequencer/types.ts +6 -0
  146. package/src/sequencer/utils.ts +18 -9
  147. package/src/test/index.ts +7 -8
  148. package/src/test/mock_checkpoint_builder.ts +323 -0
  149. package/src/test/utils.ts +218 -0
  150. package/dest/sequencer/block_builder.d.ts +0 -27
  151. package/dest/sequencer/block_builder.d.ts.map +0 -1
  152. package/dest/sequencer/block_builder.js +0 -130
  153. package/dest/sequencer/timetable.d.ts +0 -50
  154. package/dest/sequencer/timetable.d.ts.map +0 -1
  155. package/dest/sequencer/timetable.js +0 -137
  156. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  157. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  158. package/dest/tx_validator/nullifier_cache.js +0 -24
  159. package/dest/tx_validator/tx_validator_factory.d.ts +0 -17
  160. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  161. package/dest/tx_validator/tx_validator_factory.js +0 -53
  162. package/src/sequencer/block_builder.ts +0 -218
  163. package/src/sequencer/timetable.ts +0 -188
  164. package/src/tx_validator/nullifier_cache.ts +0 -30
  165. package/src/tx_validator/tx_validator_factory.ts +0 -132
@@ -0,0 +1,122 @@
1
+ import { Body } from '@aztec/aztec.js/block';
2
+ import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
3
+ import { times } from '@aztec/foundation/collection';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import { Signature } from '@aztec/foundation/eth-signature';
6
+ import { PublicDataWrite } from '@aztec/stdlib/avm';
7
+ import { CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
8
+ import { DEFAULT_BLOCK_DURATION_MS } from '@aztec/stdlib/config';
9
+ import { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload } from '@aztec/stdlib/p2p';
10
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
11
+ import { TEST_COORDINATION_SIGNATURE_CONTEXT, makeAppendOnlyTreeSnapshot, mockTxForRollup } from '@aztec/stdlib/testing';
12
+ import { DEFAULT_CHECKPOINT_PROPOSAL_INIT_TIME, DEFAULT_CHECKPOINT_PROPOSAL_PREPARE_TIME, DEFAULT_MIN_BLOCK_DURATION, DEFAULT_P2P_PROPAGATION_TIME, ProposerTimetable } from '@aztec/stdlib/timetable';
13
+ import { BlockHeader, makeProcessedTxFromPrivateOnlyTx } from '@aztec/stdlib/tx';
14
+ // Re-export mock classes from their dedicated file
15
+ export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint_builder.js';
16
+ /**
17
+ * Builds a {@link ProposerTimetable} for tests from a millisecond block duration and optional budgets,
18
+ * filling unset budgets with the shared `DEFAULT_*` values the sequencer config layer applies. Mirrors how
19
+ * the sequencer constructs its timetable so tests exercise the same budget resolution.
20
+ */ export function makeProposerTimetable(opts) {
21
+ return new ProposerTimetable({
22
+ l1Constants: opts.l1Constants,
23
+ blockDuration: (opts.blockDurationMs ?? DEFAULT_BLOCK_DURATION_MS) / 1000,
24
+ minBlockDuration: opts.minBlockDuration ?? DEFAULT_MIN_BLOCK_DURATION,
25
+ p2pPropagationTime: opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME,
26
+ checkpointProposalPrepareTime: opts.checkpointProposalPrepareTime ?? DEFAULT_CHECKPOINT_PROPOSAL_PREPARE_TIME,
27
+ checkpointProposalInitTime: DEFAULT_CHECKPOINT_PROPOSAL_INIT_TIME
28
+ });
29
+ }
30
+ /**
31
+ * Creates a mock transaction with a specific seed for deterministic testing
32
+ */ export async function makeTx(seed, chainId) {
33
+ const tx = await mockTxForRollup(seed);
34
+ if (chainId) {
35
+ tx.data.constants.txContext.chainId = chainId;
36
+ }
37
+ return tx;
38
+ }
39
+ /**
40
+ * Creates an L2Block from transactions and global variables
41
+ */ export async function makeBlock(txs, globalVariables) {
42
+ const processedTxs = await Promise.all(txs.map((tx)=>makeProcessedTxFromPrivateOnlyTx(tx, Fr.ZERO, new PublicDataWrite(Fr.random(), Fr.random()), globalVariables)));
43
+ const body = new Body(processedTxs.map((tx)=>tx.txEffect));
44
+ const header = BlockHeader.empty({
45
+ globalVariables
46
+ });
47
+ const archive = makeAppendOnlyTreeSnapshot(globalVariables.blockNumber + 1);
48
+ return new L2Block(archive, header, body, CheckpointNumber.fromBlockNumber(globalVariables.blockNumber), IndexWithinCheckpoint(0));
49
+ }
50
+ /**
51
+ * Mocks the P2P client to return specific pending transactions
52
+ */ export function mockPendingTxs(p2p, txs) {
53
+ p2p.getPendingTxCount.mockResolvedValue(txs.length);
54
+ p2p.hasEligiblePendingTxs.mockImplementation((minCount)=>Promise.resolve(txs.length >= minCount));
55
+ p2p.iteratePendingTxs.mockImplementation(()=>mockTxIterator(Promise.resolve(txs)));
56
+ p2p.iterateEligiblePendingTxs.mockImplementation(()=>mockTxIterator(Promise.resolve(txs)));
57
+ }
58
+ /**
59
+ * Creates an async iterator for transactions
60
+ */ export async function* mockTxIterator(txs) {
61
+ for (const tx of (await txs)){
62
+ yield tx;
63
+ }
64
+ }
65
+ /**
66
+ * Creates mock committee attestations from a signer
67
+ */ export function createMockSignatures(signer) {
68
+ const mockedSig = Signature.random();
69
+ return [
70
+ new CommitteeAttestation(signer.address, mockedSig)
71
+ ];
72
+ }
73
+ /**
74
+ * Creates a CheckpointHeader from an L2Block for testing purposes.
75
+ * Uses mock values for blockHeadersHash, blobsHash and inHash since L2Block doesn't have these fields.
76
+ */ function createCheckpointHeaderFromBlock(block) {
77
+ const gv = block.header.globalVariables;
78
+ 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, block.header.totalFees);
79
+ }
80
+ /**
81
+ * Creates a block proposal from a block and signature
82
+ */ export function createBlockProposal(block, signature) {
83
+ const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
84
+ return new BlockProposal(block.header, block.indexWithinCheckpoint, Fr.ZERO, block.archive.root, txHashes, signature, TEST_COORDINATION_SIGNATURE_CONTEXT);
85
+ }
86
+ /**
87
+ * Creates a checkpoint proposal from a block and signature
88
+ */ export function createCheckpointProposal(block, checkpointSignature, blockSignature, feeAssetPriceModifier = 0n) {
89
+ const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
90
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
91
+ return new CheckpointProposal(checkpointHeader, block.archive.root, feeAssetPriceModifier, checkpointSignature, TEST_COORDINATION_SIGNATURE_CONTEXT, {
92
+ blockHeader: block.header,
93
+ indexWithinCheckpoint: block.indexWithinCheckpoint,
94
+ txHashes,
95
+ signature: blockSignature ?? checkpointSignature
96
+ });
97
+ }
98
+ /**
99
+ * Creates a checkpoint attestation from a block and signature.
100
+ * Note: We manually set the sender since we use random signatures in tests.
101
+ * In production, the sender is recovered from the signature.
102
+ */ export function createCheckpointAttestation(block, signature, sender, feeAssetPriceModifier = 0n) {
103
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
104
+ const payload = new ConsensusPayload(checkpointHeader, block.archive.root, feeAssetPriceModifier, TEST_COORDINATION_SIGNATURE_CONTEXT);
105
+ const attestation = new CheckpointAttestation(payload, signature, signature);
106
+ // Bypass signature recovery for testing since we use random signatures
107
+ attestation.getSender = ()=>sender;
108
+ attestation.getProposer = ()=>sender;
109
+ return attestation;
110
+ }
111
+ /**
112
+ * Creates transactions and a block, and mocks P2P to return them.
113
+ * Helper for tests that need to set up a block with transactions.
114
+ */ export async function setupTxsAndBlock(p2p, globalVariables, txCount, chainId) {
115
+ const txs = await Promise.all(times(txCount, (i)=>makeTx(i + 1, chainId)));
116
+ const block = await makeBlock(txs, globalVariables);
117
+ mockPendingTxs(p2p, txs);
118
+ return {
119
+ txs,
120
+ block
121
+ };
122
+ }
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@aztec/sequencer-client",
3
- "version": "0.0.1-commit.b655e406",
3
+ "version": "0.0.1-commit.b8a057fa",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
7
+ "./automine": "./dest/sequencer/automine/index.js",
7
8
  "./config": "./dest/config.js",
8
9
  "./test": "./dest/test/index.js"
9
10
  },
@@ -18,50 +19,53 @@
18
19
  "../package.common.json"
19
20
  ],
20
21
  "scripts": {
21
- "build": "yarn clean && tsc -b",
22
- "build:dev": "tsc -b --watch",
22
+ "build": "yarn clean && ../scripts/tsc.sh",
23
+ "build:dev": "../scripts/tsc.sh --watch",
23
24
  "clean": "rm -rf ./dest .tsbuildinfo",
24
25
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
25
26
  "test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
26
27
  "test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
27
28
  },
28
29
  "dependencies": {
29
- "@aztec/aztec.js": "0.0.1-commit.b655e406",
30
- "@aztec/bb-prover": "0.0.1-commit.b655e406",
31
- "@aztec/blob-lib": "0.0.1-commit.b655e406",
32
- "@aztec/blob-sink": "0.0.1-commit.b655e406",
33
- "@aztec/constants": "0.0.1-commit.b655e406",
34
- "@aztec/epoch-cache": "0.0.1-commit.b655e406",
35
- "@aztec/ethereum": "0.0.1-commit.b655e406",
36
- "@aztec/foundation": "0.0.1-commit.b655e406",
37
- "@aztec/l1-artifacts": "0.0.1-commit.b655e406",
38
- "@aztec/merkle-tree": "0.0.1-commit.b655e406",
39
- "@aztec/node-keystore": "0.0.1-commit.b655e406",
40
- "@aztec/noir-acvm_js": "0.0.1-commit.b655e406",
41
- "@aztec/noir-contracts.js": "0.0.1-commit.b655e406",
42
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.b655e406",
43
- "@aztec/noir-types": "0.0.1-commit.b655e406",
44
- "@aztec/p2p": "0.0.1-commit.b655e406",
45
- "@aztec/protocol-contracts": "0.0.1-commit.b655e406",
46
- "@aztec/prover-client": "0.0.1-commit.b655e406",
47
- "@aztec/simulator": "0.0.1-commit.b655e406",
48
- "@aztec/slasher": "0.0.1-commit.b655e406",
49
- "@aztec/stdlib": "0.0.1-commit.b655e406",
50
- "@aztec/telemetry-client": "0.0.1-commit.b655e406",
51
- "@aztec/validator-client": "0.0.1-commit.b655e406",
52
- "@aztec/world-state": "0.0.1-commit.b655e406",
30
+ "@aztec/aztec.js": "0.0.1-commit.b8a057fa",
31
+ "@aztec/bb-prover": "0.0.1-commit.b8a057fa",
32
+ "@aztec/blob-client": "0.0.1-commit.b8a057fa",
33
+ "@aztec/blob-lib": "0.0.1-commit.b8a057fa",
34
+ "@aztec/constants": "0.0.1-commit.b8a057fa",
35
+ "@aztec/epoch-cache": "0.0.1-commit.b8a057fa",
36
+ "@aztec/ethereum": "0.0.1-commit.b8a057fa",
37
+ "@aztec/foundation": "0.0.1-commit.b8a057fa",
38
+ "@aztec/l1-artifacts": "0.0.1-commit.b8a057fa",
39
+ "@aztec/node-keystore": "0.0.1-commit.b8a057fa",
40
+ "@aztec/noir-acvm_js": "0.0.1-commit.b8a057fa",
41
+ "@aztec/noir-contracts.js": "0.0.1-commit.b8a057fa",
42
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.b8a057fa",
43
+ "@aztec/noir-types": "0.0.1-commit.b8a057fa",
44
+ "@aztec/p2p": "0.0.1-commit.b8a057fa",
45
+ "@aztec/protocol-contracts": "0.0.1-commit.b8a057fa",
46
+ "@aztec/prover-client": "0.0.1-commit.b8a057fa",
47
+ "@aztec/simulator": "0.0.1-commit.b8a057fa",
48
+ "@aztec/slasher": "0.0.1-commit.b8a057fa",
49
+ "@aztec/stdlib": "0.0.1-commit.b8a057fa",
50
+ "@aztec/telemetry-client": "0.0.1-commit.b8a057fa",
51
+ "@aztec/validator-client": "0.0.1-commit.b8a057fa",
52
+ "@aztec/validator-ha-signer": "0.0.1-commit.b8a057fa",
53
+ "@aztec/world-state": "0.0.1-commit.b8a057fa",
53
54
  "lodash.chunk": "^4.2.0",
54
55
  "tslib": "^2.4.0",
55
- "viem": "npm:@spalladino/viem@2.38.2-eip7594.0"
56
+ "viem": "npm:@aztec/viem@2.38.2",
57
+ "zod": "^4"
56
58
  },
57
59
  "devDependencies": {
58
- "@aztec/archiver": "0.0.1-commit.b655e406",
59
- "@aztec/kv-store": "0.0.1-commit.b655e406",
60
+ "@aztec/archiver": "0.0.1-commit.b8a057fa",
61
+ "@aztec/kv-store": "0.0.1-commit.b8a057fa",
62
+ "@electric-sql/pglite": "^0.3.14",
60
63
  "@jest/globals": "^30.0.0",
61
64
  "@types/jest": "^30.0.0",
62
65
  "@types/lodash.chunk": "^4.2.7",
63
66
  "@types/lodash.pick": "^4.4.7",
64
67
  "@types/node": "^22.15.17",
68
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
65
69
  "concurrently": "^7.6.0",
66
70
  "eslint": "^9.26.0",
67
71
  "express": "^4.21.2",
@@ -1,32 +1,24 @@
1
- import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
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
- import {
4
- GovernanceProposerContract,
5
- PublisherManager,
6
- RollupContract,
7
- getPublicClient,
8
- isAnvilTestChain,
9
- } from '@aztec/ethereum';
10
- import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
4
+ import { getPublicClient } from '@aztec/ethereum/client';
5
+ import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
6
+ import { type Delayer, L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
7
+ import { PublisherManager } from '@aztec/ethereum/publisher-manager';
11
8
  import { EthAddress } from '@aztec/foundation/eth-address';
12
9
  import { createLogger } from '@aztec/foundation/log';
13
10
  import type { DateProvider } from '@aztec/foundation/timer';
14
11
  import type { KeystoreManager } from '@aztec/node-keystore';
15
12
  import type { P2P } from '@aztec/p2p';
16
13
  import type { SlasherClientInterface } from '@aztec/slasher';
17
- import type { L2BlockSource } from '@aztec/stdlib/block';
18
- import type {
19
- IFullNodeBlockBuilder,
20
- ValidatorClientFullConfig,
21
- WorldStateSynchronizer,
22
- } from '@aztec/stdlib/interfaces/server';
23
- import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
14
+ import type { L2BlockSink, L2BlockSource, ProposedCheckpointSink } from '@aztec/stdlib/block';
15
+ import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
24
16
  import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
25
17
  import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
26
- import { NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
18
+ import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
27
19
 
28
- import type { SequencerClientConfig } from '../config.js';
29
- import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
20
+ import { type SequencerClientConfig, getPublisherConfigFromSequencerConfig } from '../config.js';
21
+ import type { GlobalVariableBuilder } from '../global_variable_builder/index.js';
30
22
  import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
31
23
  import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
32
24
 
@@ -35,11 +27,12 @@ import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
35
27
  */
36
28
  export class SequencerClient {
37
29
  constructor(
38
- protected publisherManager: PublisherManager<L1TxUtilsWithBlobs>,
30
+ protected publisherManager: PublisherManager<L1TxUtils>,
39
31
  protected sequencer: Sequencer,
40
- protected blockBuilder: IFullNodeBlockBuilder,
32
+ protected checkpointsBuilder: FullNodeCheckpointsBuilder,
41
33
  protected validatorClient?: ValidatorClient,
42
34
  private l1Metrics?: L1Metrics,
35
+ private delayer_?: Delayer,
43
36
  ) {}
44
37
 
45
38
  /**
@@ -57,20 +50,22 @@ export class SequencerClient {
57
50
  public static async new(
58
51
  config: SequencerClientConfig,
59
52
  deps: {
60
- validatorClient: ValidatorClient | undefined; // allowed to be undefined while we migrate
53
+ validatorClient: ValidatorClient;
61
54
  p2pClient: P2P;
62
55
  worldStateSynchronizer: WorldStateSynchronizer;
63
56
  slasherClient: SlasherClientInterface | undefined;
64
- blockBuilder: IFullNodeBlockBuilder;
65
- l2BlockSource: L2BlockSource;
57
+ checkpointsBuilder: FullNodeCheckpointsBuilder;
58
+ l2BlockSource: L2BlockSource & L2BlockSink & ProposedCheckpointSink;
66
59
  l1ToL2MessageSource: L1ToL2MessageSource;
67
60
  telemetry: TelemetryClient;
68
61
  publisherFactory?: SequencerPublisherFactory;
69
- blobSinkClient?: BlobSinkClientInterface;
62
+ blobClient: BlobClientInterface;
70
63
  dateProvider: DateProvider;
71
64
  epochCache?: EpochCache;
72
- l1TxUtils: L1TxUtilsWithBlobs[];
65
+ l1TxUtils: L1TxUtils[];
66
+ funderL1TxUtils?: L1TxUtils;
73
67
  nodeKeyStore: KeystoreManager;
68
+ globalVariableBuilder: GlobalVariableBuilder;
74
69
  },
75
70
  ) {
76
71
  const {
@@ -78,7 +73,7 @@ export class SequencerClient {
78
73
  p2pClient,
79
74
  worldStateSynchronizer,
80
75
  slasherClient,
81
- blockBuilder,
76
+ checkpointsBuilder,
82
77
  l2BlockSource,
83
78
  l1ToL2MessageSource,
84
79
  telemetry: telemetryClient,
@@ -92,21 +87,25 @@ export class SequencerClient {
92
87
  publicClient,
93
88
  l1TxUtils.map(x => x.getSenderAddress()),
94
89
  );
95
- const publisherManager = new PublisherManager(l1TxUtils, config);
96
- const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
97
- const [l1GenesisTime, slotDuration] = await Promise.all([
90
+ const publisherManager = new PublisherManager(l1TxUtils, getPublisherConfigFromSequencerConfig(config), {
91
+ bindings: log.getBindings(),
92
+ funder: deps.funderL1TxUtils,
93
+ });
94
+ const rollupContract = new RollupContract(publicClient, config.rollupAddress.toString());
95
+ const [l1GenesisTime, slotDuration, rollupManaLimit] = await Promise.all([
98
96
  rollupContract.getL1GenesisTime(),
99
97
  rollupContract.getSlotDuration(),
98
+ rollupContract.getManaLimit().then(Number),
100
99
  ] as const);
101
100
 
102
101
  const governanceProposerContract = new GovernanceProposerContract(
103
102
  publicClient,
104
- config.l1Contracts.governanceProposerAddress.toString(),
103
+ config.governanceProposerAddress.toString(),
105
104
  );
106
105
  const epochCache =
107
106
  deps.epochCache ??
108
107
  (await EpochCache.create(
109
- config.l1Contracts.rollupAddress,
108
+ config.rollupAddress,
110
109
  {
111
110
  l1RpcUrls: rpcUrls,
112
111
  l1ChainId: chainId,
@@ -116,51 +115,32 @@ export class SequencerClient {
116
115
  { dateProvider: deps.dateProvider },
117
116
  ));
118
117
 
119
- const slashFactoryContract = new SlashFactoryContract(
120
- publicClient,
121
- config.l1Contracts.slashFactoryAddress?.toString() ?? EthAddress.ZERO.toString(),
122
- );
123
-
124
118
  const publisherFactory =
125
119
  deps.publisherFactory ??
126
120
  new SequencerPublisherFactory(config, {
127
121
  telemetry: telemetryClient,
128
- blobSinkClient: deps.blobSinkClient,
122
+ blobClient: deps.blobClient,
129
123
  epochCache,
130
124
  governanceProposerContract,
131
- slashFactoryContract,
132
125
  rollupContract,
133
126
  dateProvider: deps.dateProvider,
134
127
  publisherManager,
135
128
  nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(deps.nodeKeyStore),
136
129
  logger: log,
137
130
  });
138
- const globalsBuilder = new GlobalVariableBuilder(config);
139
131
 
140
132
  const ethereumSlotDuration = config.ethereumSlotDuration;
141
133
 
142
- const rollupManaLimit = Number(await rollupContract.getManaLimit());
143
- let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
144
- if (sequencerManaLimit > rollupManaLimit) {
145
- log.warn(
146
- `Provided maxL2BlockGas of ${sequencerManaLimit} is greater than the maximum allowed by the L1 (${rollupManaLimit}), setting limit to ${rollupManaLimit}`,
147
- );
148
- sequencerManaLimit = rollupManaLimit;
149
- }
150
-
151
- // When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
152
- // Otherwise, assume we must have broadcasted the tx before the slot started (we use a default
153
- // maxL1TxInclusionTimeIntoSlot of zero) to get the tx into that L1 slot.
154
- // In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
155
- // make it with a propagation time into slot equal to 4s. However, we prefer being conservative.
156
- // See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
157
- const maxL1TxInclusionTimeIntoSlot =
158
- (config.maxL1TxInclusionTimeIntoSlot ?? isAnvilTestChain(config.l1ChainId)) ? ethereumSlotDuration - 1 : 0;
134
+ const globalsBuilder = deps.globalVariableBuilder;
135
+
136
+ const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = capPerBlockLimits(config, rollupManaLimit, log);
159
137
 
160
138
  const l1Constants = {
161
139
  l1GenesisTime,
162
140
  slotDuration: Number(slotDuration),
163
141
  ethereumSlotDuration,
142
+ rollupManaLimit,
143
+ epochDuration: config.aztecEpochDuration,
164
144
  };
165
145
 
166
146
  const sequencer = new Sequencer(
@@ -172,19 +152,22 @@ export class SequencerClient {
172
152
  slasherClient,
173
153
  l2BlockSource,
174
154
  l1ToL2MessageSource,
175
- blockBuilder,
155
+ checkpointsBuilder,
176
156
  l1Constants,
177
157
  deps.dateProvider,
178
158
  epochCache,
179
159
  rollupContract,
180
- { ...config, maxL1TxInclusionTimeIntoSlot, maxL2BlockGas: sequencerManaLimit },
160
+ { ...config, maxL2BlockGas, maxDABlockGas, maxTxsPerBlock },
181
161
  telemetryClient,
182
162
  log,
183
163
  );
184
164
 
185
- await sequencer.init();
165
+ sequencer.init();
186
166
 
187
- return new SequencerClient(publisherManager, sequencer, blockBuilder, validatorClient, l1Metrics);
167
+ // Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
168
+ const delayer = l1TxUtils[0]?.delayer;
169
+
170
+ return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics, delayer);
188
171
  }
189
172
 
190
173
  /**
@@ -193,32 +176,63 @@ export class SequencerClient {
193
176
  */
194
177
  public updateConfig(config: SequencerConfig & Partial<ValidatorClientFullConfig>) {
195
178
  this.sequencer.updateConfig(config);
196
- this.blockBuilder.updateConfig(config);
179
+ this.checkpointsBuilder.updateConfig(config);
197
180
  this.validatorClient?.updateConfig(config);
198
181
  }
199
182
 
200
- /** Starts the sequencer. */
183
+ /**
184
+ * Starts (or resumes) the sequencer, validator, publishers, and metrics. Each underlying start is
185
+ * idempotent, so this is safe to call after a previous {@link pause} to resume building and publishing.
186
+ * The publisher manager is started before the sequencer's poll loop so publishing is ready before the
187
+ * sequencer first tries to publish to L1.
188
+ */
201
189
  public async start() {
202
190
  await this.validatorClient?.start();
191
+ await this.publisherManager.start();
203
192
  this.sequencer.start();
204
193
  this.l1Metrics?.start();
205
- await this.publisherManager.loadState();
206
194
  }
207
195
 
208
196
  /**
209
- * Stops the sequencer from processing new txs.
197
+ * Stops the sequencer, validator, publishers, and metrics for good, draining in-flight work. This is the
198
+ * final teardown path: stopping the validator client closes its slashing-protection database. For a
199
+ * restartable pause (e.g. around a test clock warp) use {@link pause} instead.
210
200
  */
211
201
  public async stop() {
212
202
  await this.sequencer.stop();
213
203
  await this.validatorClient?.stop();
214
- this.publisherManager.interrupt();
204
+ await this.publisherManager.stop();
215
205
  this.l1Metrics?.stop();
216
206
  }
217
207
 
208
+ /**
209
+ * Gracefully pauses block production, waiting for in-flight work to finish rather than interrupting it,
210
+ * while leaving the validator, publishers, and metrics running so the sequencer can be resumed with
211
+ * {@link start}. Used by tests that pause sequencers around an L1 clock warp.
212
+ */
213
+ public async pause() {
214
+ await this.sequencer.pause();
215
+ }
216
+
217
+ /** Triggers an immediate run of the sequencer, bypassing the polling interval. */
218
+ public trigger() {
219
+ return this.sequencer.trigger();
220
+ }
221
+
218
222
  public getSequencer(): Sequencer {
219
223
  return this.sequencer;
220
224
  }
221
225
 
226
+ /** Updates the publisher factory's node keystore adapter after a keystore reload. */
227
+ public updatePublisherNodeKeyStore(adapter: NodeKeystoreAdapter): void {
228
+ this.sequencer.updatePublisherNodeKeyStore(adapter);
229
+ }
230
+
231
+ /** Returns the shared tx delayer for sequencer L1 txs, if enabled. Test-only. */
232
+ getDelayer(): Delayer | undefined {
233
+ return this.delayer_;
234
+ }
235
+
222
236
  get validatorAddresses(): EthAddress[] | undefined {
223
237
  return this.sequencer.getValidatorAddresses();
224
238
  }
@@ -227,3 +241,41 @@ export class SequencerClient {
227
241
  return this.sequencer.maxL2BlockGas;
228
242
  }
229
243
  }
244
+
245
+ /**
246
+ * Caps operator-provided per-block limits at checkpoint-level limits.
247
+ * Returns undefined for any limit the operator didn't set — the checkpoint builder handles redistribution.
248
+ */
249
+ function capPerBlockLimits(
250
+ config: SequencerClientConfig,
251
+ rollupManaLimit: number,
252
+ log: ReturnType<typeof createLogger>,
253
+ ): { maxL2BlockGas: number | undefined; maxDABlockGas: number | undefined; maxTxsPerBlock: number | undefined } {
254
+ let maxL2BlockGas = config.maxL2BlockGas;
255
+ if (maxL2BlockGas !== undefined && maxL2BlockGas > rollupManaLimit) {
256
+ log.warn(`Provided MAX_L2_BLOCK_GAS ${maxL2BlockGas} exceeds rollup mana limit ${rollupManaLimit} (capping)`);
257
+ maxL2BlockGas = rollupManaLimit;
258
+ }
259
+
260
+ let maxDABlockGas = config.maxDABlockGas;
261
+ if (maxDABlockGas !== undefined && maxDABlockGas > MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT) {
262
+ log.warn(
263
+ `Provided MAX_DA_BLOCK_GAS ${maxDABlockGas} exceeds DA checkpoint limit ${MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT} (capping)`,
264
+ );
265
+ maxDABlockGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
266
+ }
267
+
268
+ let maxTxsPerBlock = config.maxTxsPerBlock;
269
+ if (
270
+ maxTxsPerBlock !== undefined &&
271
+ config.maxTxsPerCheckpoint !== undefined &&
272
+ maxTxsPerBlock > config.maxTxsPerCheckpoint
273
+ ) {
274
+ log.warn(
275
+ `Provided MAX_TX_PER_BLOCK ${maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`,
276
+ );
277
+ maxTxsPerBlock = config.maxTxsPerCheckpoint;
278
+ }
279
+
280
+ return { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock };
281
+ }