@aztec/sequencer-client 3.0.0-rc.5 → 4.0.0-nightly.20260107

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 (88) hide show
  1. package/dest/client/sequencer-client.d.ts +9 -8
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +28 -24
  4. package/dest/config.d.ts +7 -1
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +63 -26
  7. package/dest/global_variable_builder/global_builder.d.ts +16 -8
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +37 -28
  10. package/dest/index.d.ts +2 -2
  11. package/dest/index.d.ts.map +1 -1
  12. package/dest/index.js +1 -1
  13. package/dest/publisher/config.d.ts +3 -3
  14. package/dest/publisher/config.d.ts.map +1 -1
  15. package/dest/publisher/config.js +2 -2
  16. package/dest/publisher/sequencer-publisher-factory.d.ts +3 -3
  17. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  18. package/dest/publisher/sequencer-publisher-factory.js +1 -1
  19. package/dest/publisher/sequencer-publisher-metrics.d.ts +3 -3
  20. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  21. package/dest/publisher/sequencer-publisher.d.ts +27 -23
  22. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  23. package/dest/publisher/sequencer-publisher.js +119 -64
  24. package/dest/sequencer/block_builder.d.ts +1 -3
  25. package/dest/sequencer/block_builder.d.ts.map +1 -1
  26. package/dest/sequencer/block_builder.js +4 -2
  27. package/dest/sequencer/checkpoint_builder.d.ts +63 -0
  28. package/dest/sequencer/checkpoint_builder.d.ts.map +1 -0
  29. package/dest/sequencer/checkpoint_builder.js +131 -0
  30. package/dest/sequencer/checkpoint_proposal_job.d.ts +74 -0
  31. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  32. package/dest/sequencer/checkpoint_proposal_job.js +642 -0
  33. package/dest/sequencer/checkpoint_voter.d.ts +34 -0
  34. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  35. package/dest/sequencer/checkpoint_voter.js +85 -0
  36. package/dest/sequencer/events.d.ts +46 -0
  37. package/dest/sequencer/events.d.ts.map +1 -0
  38. package/dest/sequencer/events.js +1 -0
  39. package/dest/sequencer/index.d.ts +5 -1
  40. package/dest/sequencer/index.d.ts.map +1 -1
  41. package/dest/sequencer/index.js +4 -0
  42. package/dest/sequencer/metrics.d.ts +21 -1
  43. package/dest/sequencer/metrics.d.ts.map +1 -1
  44. package/dest/sequencer/metrics.js +154 -0
  45. package/dest/sequencer/sequencer.d.ts +91 -125
  46. package/dest/sequencer/sequencer.d.ts.map +1 -1
  47. package/dest/sequencer/sequencer.js +581 -582
  48. package/dest/sequencer/timetable.d.ts +54 -14
  49. package/dest/sequencer/timetable.d.ts.map +1 -1
  50. package/dest/sequencer/timetable.js +148 -59
  51. package/dest/sequencer/types.d.ts +3 -0
  52. package/dest/sequencer/types.d.ts.map +1 -0
  53. package/dest/sequencer/types.js +1 -0
  54. package/dest/sequencer/utils.d.ts +14 -8
  55. package/dest/sequencer/utils.d.ts.map +1 -1
  56. package/dest/sequencer/utils.js +7 -4
  57. package/dest/test/index.d.ts +3 -1
  58. package/dest/test/index.d.ts.map +1 -1
  59. package/dest/test/mock_checkpoint_builder.d.ts +83 -0
  60. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  61. package/dest/test/mock_checkpoint_builder.js +179 -0
  62. package/dest/test/utils.d.ts +49 -0
  63. package/dest/test/utils.d.ts.map +1 -0
  64. package/dest/test/utils.js +94 -0
  65. package/package.json +27 -27
  66. package/src/client/sequencer-client.ts +24 -31
  67. package/src/config.ts +68 -25
  68. package/src/global_variable_builder/global_builder.ts +47 -41
  69. package/src/index.ts +2 -0
  70. package/src/publisher/config.ts +3 -3
  71. package/src/publisher/sequencer-publisher-factory.ts +3 -3
  72. package/src/publisher/sequencer-publisher-metrics.ts +2 -2
  73. package/src/publisher/sequencer-publisher.ts +170 -74
  74. package/src/sequencer/README.md +531 -0
  75. package/src/sequencer/block_builder.ts +4 -1
  76. package/src/sequencer/checkpoint_builder.ts +217 -0
  77. package/src/sequencer/checkpoint_proposal_job.ts +706 -0
  78. package/src/sequencer/checkpoint_voter.ts +105 -0
  79. package/src/sequencer/events.ts +27 -0
  80. package/src/sequencer/index.ts +4 -0
  81. package/src/sequencer/metrics.ts +202 -0
  82. package/src/sequencer/sequencer.ts +300 -779
  83. package/src/sequencer/timetable.ts +173 -79
  84. package/src/sequencer/types.ts +6 -0
  85. package/src/sequencer/utils.ts +18 -9
  86. package/src/test/index.ts +2 -0
  87. package/src/test/mock_checkpoint_builder.ts +247 -0
  88. package/src/test/utils.ts +137 -0
@@ -0,0 +1,179 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { Timer } from '@aztec/foundation/timer';
3
+ import { Checkpoint } from '@aztec/stdlib/checkpoint';
4
+ import { Gas } from '@aztec/stdlib/gas';
5
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
6
+ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
7
+ /**
8
+ * A fake CheckpointBuilder for testing that implements the same interface as the real one.
9
+ * Can be seeded with blocks to return sequentially on each `buildBlock` call.
10
+ */ export class MockCheckpointBuilder {
11
+ constants;
12
+ checkpointNumber;
13
+ blocks;
14
+ builtBlocks;
15
+ usedTxsPerBlock;
16
+ blockIndex;
17
+ /** Optional function to dynamically provide the block (alternative to seedBlocks) */ blockProvider;
18
+ /** Track calls for assertions */ buildBlockCalls;
19
+ completeCheckpointCalled;
20
+ getCheckpointCalled;
21
+ /** Set to an error to make buildBlock throw on next call */ errorOnBuild;
22
+ constructor(constants, checkpointNumber){
23
+ this.constants = constants;
24
+ this.checkpointNumber = checkpointNumber;
25
+ this.blocks = [];
26
+ this.builtBlocks = [];
27
+ this.usedTxsPerBlock = [];
28
+ this.blockIndex = 0;
29
+ this.blockProvider = undefined;
30
+ this.buildBlockCalls = [];
31
+ this.completeCheckpointCalled = false;
32
+ this.getCheckpointCalled = false;
33
+ this.errorOnBuild = undefined;
34
+ }
35
+ /** Seed the builder with blocks to return on successive buildBlock calls */ seedBlocks(blocks, usedTxsPerBlock) {
36
+ this.blocks = blocks;
37
+ this.usedTxsPerBlock = usedTxsPerBlock ?? blocks.map(()=>[]);
38
+ this.blockIndex = 0;
39
+ this.blockProvider = undefined;
40
+ return this;
41
+ }
42
+ /**
43
+ * Set a function that provides blocks dynamically.
44
+ * Useful for tests where the block is determined at call time (e.g., sequencer tests).
45
+ */ setBlockProvider(provider) {
46
+ this.blockProvider = provider;
47
+ this.blocks = [];
48
+ return this;
49
+ }
50
+ getConstantData() {
51
+ return this.constants;
52
+ }
53
+ buildBlock(_pendingTxs, blockNumber, timestamp, opts) {
54
+ this.buildBlockCalls.push({
55
+ blockNumber,
56
+ timestamp,
57
+ opts
58
+ });
59
+ if (this.errorOnBuild) {
60
+ return Promise.reject(this.errorOnBuild);
61
+ }
62
+ let block;
63
+ let usedTxs;
64
+ if (this.blockProvider) {
65
+ // Dynamic mode: get block from provider
66
+ block = this.blockProvider();
67
+ usedTxs = [];
68
+ this.builtBlocks.push(block);
69
+ } else {
70
+ // Seeded mode: get block from pre-seeded list
71
+ block = this.blocks[this.blockIndex];
72
+ usedTxs = this.usedTxsPerBlock[this.blockIndex] ?? [];
73
+ this.blockIndex++;
74
+ this.builtBlocks.push(block);
75
+ }
76
+ return Promise.resolve({
77
+ block,
78
+ publicGas: Gas.empty(),
79
+ publicProcessorDuration: 0,
80
+ numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
81
+ blockBuildingTimer: new Timer(),
82
+ usedTxs,
83
+ failedTxs: []
84
+ });
85
+ }
86
+ completeCheckpoint() {
87
+ this.completeCheckpointCalled = true;
88
+ const allBlocks = this.blockProvider ? this.builtBlocks : this.blocks;
89
+ const lastBlock = allBlocks[allBlocks.length - 1];
90
+ // Create a CheckpointHeader from the last block's header for testing
91
+ const checkpointHeader = this.createCheckpointHeader(lastBlock);
92
+ return Promise.resolve(new Checkpoint(makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1), checkpointHeader, allBlocks, this.checkpointNumber));
93
+ }
94
+ getCheckpoint() {
95
+ this.getCheckpointCalled = true;
96
+ const builtBlocks = this.blockProvider ? this.builtBlocks : this.blocks.slice(0, this.blockIndex);
97
+ const lastBlock = builtBlocks[builtBlocks.length - 1];
98
+ if (!lastBlock) {
99
+ throw new Error('No blocks built yet');
100
+ }
101
+ // Create a CheckpointHeader from the last block's header for testing
102
+ const checkpointHeader = this.createCheckpointHeader(lastBlock);
103
+ return Promise.resolve(new Checkpoint(makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1), checkpointHeader, builtBlocks, this.checkpointNumber));
104
+ }
105
+ /**
106
+ * Creates a CheckpointHeader from a block's header for testing.
107
+ * This is a simplified version that creates a minimal CheckpointHeader.
108
+ */ createCheckpointHeader(block) {
109
+ const header = block.header;
110
+ const gv = header.globalVariables;
111
+ return CheckpointHeader.empty({
112
+ lastArchiveRoot: header.lastArchive.root,
113
+ blockHeadersHash: Fr.random(),
114
+ slotNumber: gv.slotNumber,
115
+ timestamp: gv.timestamp,
116
+ coinbase: gv.coinbase,
117
+ feeRecipient: gv.feeRecipient,
118
+ gasFees: gv.gasFees,
119
+ totalManaUsed: header.totalManaUsed
120
+ });
121
+ }
122
+ /** Reset for reuse in another test */ reset() {
123
+ this.blocks = [];
124
+ this.builtBlocks = [];
125
+ this.usedTxsPerBlock = [];
126
+ this.blockIndex = 0;
127
+ this.buildBlockCalls = [];
128
+ this.completeCheckpointCalled = false;
129
+ this.getCheckpointCalled = false;
130
+ this.errorOnBuild = undefined;
131
+ this.blockProvider = undefined;
132
+ }
133
+ }
134
+ /**
135
+ * A fake CheckpointsBuilder (factory) for testing that implements the same interface
136
+ * as FullNodeCheckpointsBuilder. Returns MockCheckpointBuilder instances.
137
+ * Does NOT use jest mocks - this is a proper test double.
138
+ */ export class MockCheckpointsBuilder {
139
+ checkpointBuilder;
140
+ /** Track calls for assertions */ startCheckpointCalls = [];
141
+ updateConfigCalls = [];
142
+ /**
143
+ * Set the MockCheckpointBuilder to return from startCheckpoint.
144
+ * Must be called before startCheckpoint is invoked.
145
+ */ setCheckpointBuilder(builder) {
146
+ this.checkpointBuilder = builder;
147
+ return this;
148
+ }
149
+ /**
150
+ * Creates a new MockCheckpointBuilder with the given constants.
151
+ * Convenience method that creates and sets the builder in one call.
152
+ */ createCheckpointBuilder(constants, checkpointNumber) {
153
+ this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
154
+ return this.checkpointBuilder;
155
+ }
156
+ /** Get the current checkpoint builder (for assertions) */ getCheckpointBuilder() {
157
+ return this.checkpointBuilder;
158
+ }
159
+ updateConfig(config) {
160
+ this.updateConfigCalls.push(config);
161
+ }
162
+ startCheckpoint(checkpointNumber, constants, l1ToL2Messages, _fork) {
163
+ this.startCheckpointCalls.push({
164
+ checkpointNumber,
165
+ constants,
166
+ l1ToL2Messages
167
+ });
168
+ if (!this.checkpointBuilder) {
169
+ // Auto-create a builder if none was set
170
+ this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
171
+ }
172
+ return Promise.resolve(this.checkpointBuilder);
173
+ }
174
+ /** Reset for reuse in another test */ reset() {
175
+ this.checkpointBuilder = undefined;
176
+ this.startCheckpointCalls = [];
177
+ this.updateConfigCalls = [];
178
+ }
179
+ }
@@ -0,0 +1,49 @@
1
+ import { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { EthAddress } from '@aztec/foundation/eth-address';
4
+ import { Signature } from '@aztec/foundation/eth-signature';
5
+ import type { P2P } from '@aztec/p2p';
6
+ import { CommitteeAttestation, L2BlockNew } from '@aztec/stdlib/block';
7
+ import { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
8
+ import { GlobalVariables, type Tx } from '@aztec/stdlib/tx';
9
+ import type { MockProxy } from 'jest-mock-extended';
10
+ export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint_builder.js';
11
+ /**
12
+ * Creates a mock transaction with a specific seed for deterministic testing
13
+ */
14
+ export declare function makeTx(seed?: number, chainId?: Fr): Promise<Tx>;
15
+ /**
16
+ * Creates an L2BlockNew from transactions and global variables
17
+ */
18
+ export declare function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Promise<L2BlockNew>;
19
+ /**
20
+ * Mocks the P2P client to return specific pending transactions
21
+ */
22
+ export declare function mockPendingTxs(p2p: MockProxy<P2P>, txs: Tx[]): void;
23
+ /**
24
+ * Creates an async iterator for transactions
25
+ */
26
+ export declare function mockTxIterator(txs: Promise<Tx[]>): AsyncIterableIterator<Tx>;
27
+ /**
28
+ * Creates mock committee attestations from a signer
29
+ */
30
+ export declare function createMockSignatures(signer: Secp256k1Signer): CommitteeAttestation[];
31
+ /**
32
+ * Creates a block proposal from a block and signature
33
+ */
34
+ export declare function createBlockProposal(block: L2BlockNew, signature: Signature): BlockProposal;
35
+ /**
36
+ * Creates a block attestation from a block and signature.
37
+ * Note: We manually set the sender since we use random signatures in tests.
38
+ * In production, the sender is recovered from the signature.
39
+ */
40
+ export declare function createBlockAttestation(block: L2BlockNew, signature: Signature, sender: EthAddress): BlockAttestation;
41
+ /**
42
+ * Creates transactions and a block, and mocks P2P to return them.
43
+ * Helper for tests that need to set up a block with transactions.
44
+ */
45
+ export declare function setupTxsAndBlock(p2p: MockProxy<P2P>, globalVariables: GlobalVariables, txCount: number, chainId: Fr): Promise<{
46
+ txs: Tx[];
47
+ block: L2BlockNew;
48
+ }>;
49
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L3V0aWxzLnRzIl0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AE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,gBAAgB,CAQpH;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,EACnB,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,EAAE,GACV,OAAO,CAAC;IAAE,GAAG,EAAE,EAAE,EAAE,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC,CAK3C"}
@@ -0,0 +1,94 @@
1
+ import { Body } from '@aztec/aztec.js/block';
2
+ import { CheckpointNumber } 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, L2BlockNew } from '@aztec/stdlib/block';
8
+ import { BlockAttestation, BlockProposal, ConsensusPayload } from '@aztec/stdlib/p2p';
9
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
10
+ import { makeAppendOnlyTreeSnapshot, mockTxForRollup } from '@aztec/stdlib/testing';
11
+ import { BlockHeader, ContentCommitment, makeProcessedTxFromPrivateOnlyTx } from '@aztec/stdlib/tx';
12
+ // Re-export mock classes from their dedicated file
13
+ export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint_builder.js';
14
+ /**
15
+ * Creates a mock transaction with a specific seed for deterministic testing
16
+ */ export async function makeTx(seed, chainId) {
17
+ const tx = await mockTxForRollup(seed);
18
+ if (chainId) {
19
+ tx.data.constants.txContext.chainId = chainId;
20
+ }
21
+ return tx;
22
+ }
23
+ /**
24
+ * Creates an L2BlockNew from transactions and global variables
25
+ */ export async function makeBlock(txs, globalVariables) {
26
+ const processedTxs = await Promise.all(txs.map((tx)=>makeProcessedTxFromPrivateOnlyTx(tx, Fr.ZERO, new PublicDataWrite(Fr.random(), Fr.random()), globalVariables)));
27
+ const body = new Body(processedTxs.map((tx)=>tx.txEffect));
28
+ const header = BlockHeader.empty({
29
+ globalVariables
30
+ });
31
+ const archive = makeAppendOnlyTreeSnapshot(globalVariables.blockNumber + 1);
32
+ return new L2BlockNew(archive, header, body, CheckpointNumber(globalVariables.blockNumber), 0);
33
+ }
34
+ /**
35
+ * Mocks the P2P client to return specific pending transactions
36
+ */ export function mockPendingTxs(p2p, txs) {
37
+ p2p.getPendingTxCount.mockResolvedValue(txs.length);
38
+ p2p.iteratePendingTxs.mockImplementation(()=>mockTxIterator(Promise.resolve(txs)));
39
+ }
40
+ /**
41
+ * Creates an async iterator for transactions
42
+ */ export async function* mockTxIterator(txs) {
43
+ for (const tx of (await txs)){
44
+ yield tx;
45
+ }
46
+ }
47
+ /**
48
+ * Creates mock committee attestations from a signer
49
+ */ export function createMockSignatures(signer) {
50
+ const mockedSig = Signature.random();
51
+ return [
52
+ new CommitteeAttestation(signer.address, mockedSig)
53
+ ];
54
+ }
55
+ /**
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.
59
+ */ function createCheckpointHeaderFromBlock(block) {
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);
62
+ }
63
+ /**
64
+ * Creates a block proposal from a block and signature
65
+ */ export function createBlockProposal(block, signature) {
66
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
67
+ const consensusPayload = new ConsensusPayload(checkpointHeader, block.archive.root);
68
+ const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
69
+ return new BlockProposal(consensusPayload, signature, txHashes);
70
+ }
71
+ /**
72
+ * Creates a block attestation from a block and signature.
73
+ * Note: We manually set the sender since we use random signatures in tests.
74
+ * In production, the sender is recovered from the signature.
75
+ */ export function createBlockAttestation(block, signature, sender) {
76
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
77
+ const consensusPayload = new ConsensusPayload(checkpointHeader, block.archive.root);
78
+ const attestation = new BlockAttestation(consensusPayload, signature, signature);
79
+ // Set sender directly for testing (bypasses signature recovery)
80
+ attestation.sender = sender;
81
+ return attestation;
82
+ }
83
+ /**
84
+ * Creates transactions and a block, and mocks P2P to return them.
85
+ * Helper for tests that need to set up a block with transactions.
86
+ */ export async function setupTxsAndBlock(p2p, globalVariables, txCount, chainId) {
87
+ const txs = await Promise.all(times(txCount, (i)=>makeTx(i + 1, chainId)));
88
+ const block = await makeBlock(txs, globalVariables);
89
+ mockPendingTxs(p2p, txs);
90
+ return {
91
+ txs,
92
+ block
93
+ };
94
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/sequencer-client",
3
- "version": "3.0.0-rc.5",
3
+ "version": "4.0.0-nightly.20260107",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -26,37 +26,37 @@
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": "3.0.0-rc.5",
30
- "@aztec/bb-prover": "3.0.0-rc.5",
31
- "@aztec/blob-lib": "3.0.0-rc.5",
32
- "@aztec/blob-sink": "3.0.0-rc.5",
33
- "@aztec/constants": "3.0.0-rc.5",
34
- "@aztec/epoch-cache": "3.0.0-rc.5",
35
- "@aztec/ethereum": "3.0.0-rc.5",
36
- "@aztec/foundation": "3.0.0-rc.5",
37
- "@aztec/l1-artifacts": "3.0.0-rc.5",
38
- "@aztec/merkle-tree": "3.0.0-rc.5",
39
- "@aztec/node-keystore": "3.0.0-rc.5",
40
- "@aztec/noir-acvm_js": "3.0.0-rc.5",
41
- "@aztec/noir-contracts.js": "3.0.0-rc.5",
42
- "@aztec/noir-protocol-circuits-types": "3.0.0-rc.5",
43
- "@aztec/noir-types": "3.0.0-rc.5",
44
- "@aztec/p2p": "3.0.0-rc.5",
45
- "@aztec/protocol-contracts": "3.0.0-rc.5",
46
- "@aztec/prover-client": "3.0.0-rc.5",
47
- "@aztec/simulator": "3.0.0-rc.5",
48
- "@aztec/slasher": "3.0.0-rc.5",
49
- "@aztec/stdlib": "3.0.0-rc.5",
50
- "@aztec/telemetry-client": "3.0.0-rc.5",
51
- "@aztec/validator-client": "3.0.0-rc.5",
52
- "@aztec/world-state": "3.0.0-rc.5",
29
+ "@aztec/aztec.js": "4.0.0-nightly.20260107",
30
+ "@aztec/bb-prover": "4.0.0-nightly.20260107",
31
+ "@aztec/blob-client": "4.0.0-nightly.20260107",
32
+ "@aztec/blob-lib": "4.0.0-nightly.20260107",
33
+ "@aztec/constants": "4.0.0-nightly.20260107",
34
+ "@aztec/epoch-cache": "4.0.0-nightly.20260107",
35
+ "@aztec/ethereum": "4.0.0-nightly.20260107",
36
+ "@aztec/foundation": "4.0.0-nightly.20260107",
37
+ "@aztec/l1-artifacts": "4.0.0-nightly.20260107",
38
+ "@aztec/merkle-tree": "4.0.0-nightly.20260107",
39
+ "@aztec/node-keystore": "4.0.0-nightly.20260107",
40
+ "@aztec/noir-acvm_js": "4.0.0-nightly.20260107",
41
+ "@aztec/noir-contracts.js": "4.0.0-nightly.20260107",
42
+ "@aztec/noir-protocol-circuits-types": "4.0.0-nightly.20260107",
43
+ "@aztec/noir-types": "4.0.0-nightly.20260107",
44
+ "@aztec/p2p": "4.0.0-nightly.20260107",
45
+ "@aztec/protocol-contracts": "4.0.0-nightly.20260107",
46
+ "@aztec/prover-client": "4.0.0-nightly.20260107",
47
+ "@aztec/simulator": "4.0.0-nightly.20260107",
48
+ "@aztec/slasher": "4.0.0-nightly.20260107",
49
+ "@aztec/stdlib": "4.0.0-nightly.20260107",
50
+ "@aztec/telemetry-client": "4.0.0-nightly.20260107",
51
+ "@aztec/validator-client": "4.0.0-nightly.20260107",
52
+ "@aztec/world-state": "4.0.0-nightly.20260107",
53
53
  "lodash.chunk": "^4.2.0",
54
54
  "tslib": "^2.4.0",
55
55
  "viem": "npm:@aztec/viem@2.38.2"
56
56
  },
57
57
  "devDependencies": {
58
- "@aztec/archiver": "3.0.0-rc.5",
59
- "@aztec/kv-store": "3.0.0-rc.5",
58
+ "@aztec/archiver": "4.0.0-nightly.20260107",
59
+ "@aztec/kv-store": "4.0.0-nightly.20260107",
60
60
  "@jest/globals": "^30.0.0",
61
61
  "@types/jest": "^30.0.0",
62
62
  "@types/lodash.chunk": "^4.2.7",
@@ -1,4 +1,4 @@
1
- import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
1
+ import type { BlobClientInterface } from '@aztec/blob-client/client';
2
2
  import { EpochCache } from '@aztec/epoch-cache';
3
3
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
4
4
  import { getPublicClient } from '@aztec/ethereum/client';
@@ -12,11 +12,7 @@ import type { KeystoreManager } from '@aztec/node-keystore';
12
12
  import type { P2P } from '@aztec/p2p';
13
13
  import type { SlasherClientInterface } from '@aztec/slasher';
14
14
  import type { L2BlockSource } from '@aztec/stdlib/block';
15
- import type {
16
- IFullNodeBlockBuilder,
17
- ValidatorClientFullConfig,
18
- WorldStateSynchronizer,
19
- } from '@aztec/stdlib/interfaces/server';
15
+ import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
20
16
  import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
21
17
  import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
22
18
  import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
@@ -25,6 +21,7 @@ import { NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-clie
25
21
  import type { SequencerClientConfig } from '../config.js';
26
22
  import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
27
23
  import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
24
+ import { FullNodeCheckpointsBuilder } from '../sequencer/checkpoint_builder.js';
28
25
  import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
29
26
 
30
27
  /**
@@ -34,7 +31,7 @@ export class SequencerClient {
34
31
  constructor(
35
32
  protected publisherManager: PublisherManager<L1TxUtilsWithBlobs>,
36
33
  protected sequencer: Sequencer,
37
- protected blockBuilder: IFullNodeBlockBuilder,
34
+ protected checkpointsBuilder: FullNodeCheckpointsBuilder,
38
35
  protected validatorClient?: ValidatorClient,
39
36
  private l1Metrics?: L1Metrics,
40
37
  ) {}
@@ -54,16 +51,16 @@ export class SequencerClient {
54
51
  public static async new(
55
52
  config: SequencerClientConfig,
56
53
  deps: {
57
- validatorClient: ValidatorClient | undefined; // allowed to be undefined while we migrate
54
+ validatorClient: ValidatorClient;
58
55
  p2pClient: P2P;
59
56
  worldStateSynchronizer: WorldStateSynchronizer;
60
57
  slasherClient: SlasherClientInterface | undefined;
61
- blockBuilder: IFullNodeBlockBuilder;
58
+ checkpointsBuilder: FullNodeCheckpointsBuilder;
62
59
  l2BlockSource: L2BlockSource;
63
60
  l1ToL2MessageSource: L1ToL2MessageSource;
64
61
  telemetry: TelemetryClient;
65
62
  publisherFactory?: SequencerPublisherFactory;
66
- blobSinkClient?: BlobSinkClientInterface;
63
+ blobClient: BlobClientInterface;
67
64
  dateProvider: DateProvider;
68
65
  epochCache?: EpochCache;
69
66
  l1TxUtils: L1TxUtilsWithBlobs[];
@@ -75,7 +72,7 @@ export class SequencerClient {
75
72
  p2pClient,
76
73
  worldStateSynchronizer,
77
74
  slasherClient,
78
- blockBuilder,
75
+ checkpointsBuilder,
79
76
  l2BlockSource,
80
77
  l1ToL2MessageSource,
81
78
  telemetry: telemetryClient,
@@ -91,9 +88,11 @@ export class SequencerClient {
91
88
  );
92
89
  const publisherManager = new PublisherManager(l1TxUtils, config);
93
90
  const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
94
- const [l1GenesisTime, slotDuration] = await Promise.all([
91
+ const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
95
92
  rollupContract.getL1GenesisTime(),
96
93
  rollupContract.getSlotDuration(),
94
+ rollupContract.getVersion(),
95
+ rollupContract.getManaLimit().then(Number),
97
96
  ] as const);
98
97
 
99
98
  const governanceProposerContract = new GovernanceProposerContract(
@@ -122,7 +121,7 @@ export class SequencerClient {
122
121
  deps.publisherFactory ??
123
122
  new SequencerPublisherFactory(config, {
124
123
  telemetry: telemetryClient,
125
- blobSinkClient: deps.blobSinkClient,
124
+ blobClient: deps.blobClient,
126
125
  epochCache,
127
126
  governanceProposerContract,
128
127
  slashFactoryContract,
@@ -132,33 +131,27 @@ export class SequencerClient {
132
131
  nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(deps.nodeKeyStore),
133
132
  logger: log,
134
133
  });
135
- const globalsBuilder = new GlobalVariableBuilder(config);
136
134
 
137
135
  const ethereumSlotDuration = config.ethereumSlotDuration;
136
+ const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
137
+
138
+ const globalsBuilder = new GlobalVariableBuilder({ ...config, ...l1Constants, rollupVersion });
138
139
 
139
- const rollupManaLimit = Number(await rollupContract.getManaLimit());
140
140
  let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
141
141
  if (sequencerManaLimit > rollupManaLimit) {
142
142
  log.warn(
143
- `Provided maxL2BlockGas of ${sequencerManaLimit} is greater than the maximum allowed by the L1 (${rollupManaLimit}), setting limit to ${rollupManaLimit}`,
143
+ `Provided maxL2BlockGas ${sequencerManaLimit} is greater than the max allowed by L1. Setting limit to ${rollupManaLimit}.`,
144
144
  );
145
145
  sequencerManaLimit = rollupManaLimit;
146
146
  }
147
147
 
148
148
  // When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
149
- // Otherwise, assume we must have broadcasted the tx before the slot started (we use a default
150
- // maxL1TxInclusionTimeIntoSlot of zero) to get the tx into that L1 slot.
149
+ // Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
151
150
  // In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
152
- // make it with a propagation time into slot equal to 4s. However, we prefer being conservative.
151
+ // reduce the publishing time allowance. However, we prefer being conservative.
153
152
  // See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
154
- const maxInclusionBasedOnChain = isAnvilTestChain(config.l1ChainId) ? ethereumSlotDuration - 1 : 0;
155
- const maxL1TxInclusionTimeIntoSlot = config.maxL1TxInclusionTimeIntoSlot ?? maxInclusionBasedOnChain;
156
-
157
- const l1Constants = {
158
- l1GenesisTime,
159
- slotDuration: Number(slotDuration),
160
- ethereumSlotDuration,
161
- };
153
+ const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
154
+ const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
162
155
 
163
156
  const sequencer = new Sequencer(
164
157
  publisherFactory,
@@ -169,19 +162,19 @@ export class SequencerClient {
169
162
  slasherClient,
170
163
  l2BlockSource,
171
164
  l1ToL2MessageSource,
172
- blockBuilder,
165
+ checkpointsBuilder,
173
166
  l1Constants,
174
167
  deps.dateProvider,
175
168
  epochCache,
176
169
  rollupContract,
177
- { ...config, maxL1TxInclusionTimeIntoSlot, maxL2BlockGas: sequencerManaLimit },
170
+ { ...config, l1PublishingTime, maxL2BlockGas: sequencerManaLimit },
178
171
  telemetryClient,
179
172
  log,
180
173
  );
181
174
 
182
175
  await sequencer.init();
183
176
 
184
- return new SequencerClient(publisherManager, sequencer, blockBuilder, validatorClient, l1Metrics);
177
+ return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics);
185
178
  }
186
179
 
187
180
  /**
@@ -190,7 +183,7 @@ export class SequencerClient {
190
183
  */
191
184
  public updateConfig(config: SequencerConfig & Partial<ValidatorClientFullConfig>) {
192
185
  this.sequencer.updateConfig(config);
193
- this.blockBuilder.updateConfig(config);
186
+ this.checkpointsBuilder.updateConfig(config);
194
187
  this.validatorClient?.updateConfig(config);
195
188
  }
196
189