@aztec/sequencer-client 3.0.3 → 4.0.0-devnet.1-patch.1

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 (93) hide show
  1. package/dest/client/sequencer-client.d.ts +11 -11
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +29 -25
  4. package/dest/config.d.ts +7 -2
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +66 -28
  7. package/dest/global_variable_builder/global_builder.d.ts +19 -11
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +48 -39
  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 +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-metrics.js +23 -86
  22. package/dest/publisher/sequencer-publisher.d.ts +43 -39
  23. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  24. package/dest/publisher/sequencer-publisher.js +599 -130
  25. package/dest/sequencer/checkpoint_proposal_job.d.ts +102 -0
  26. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  27. package/dest/sequencer/checkpoint_proposal_job.js +1191 -0
  28. package/dest/sequencer/checkpoint_voter.d.ts +35 -0
  29. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  30. package/dest/sequencer/checkpoint_voter.js +109 -0
  31. package/dest/sequencer/events.d.ts +46 -0
  32. package/dest/sequencer/events.d.ts.map +1 -0
  33. package/dest/sequencer/events.js +1 -0
  34. package/dest/sequencer/index.d.ts +4 -2
  35. package/dest/sequencer/index.d.ts.map +1 -1
  36. package/dest/sequencer/index.js +3 -1
  37. package/dest/sequencer/metrics.d.ts +22 -2
  38. package/dest/sequencer/metrics.d.ts.map +1 -1
  39. package/dest/sequencer/metrics.js +143 -70
  40. package/dest/sequencer/sequencer.d.ts +107 -129
  41. package/dest/sequencer/sequencer.d.ts.map +1 -1
  42. package/dest/sequencer/sequencer.js +677 -603
  43. package/dest/sequencer/timetable.d.ts +51 -14
  44. package/dest/sequencer/timetable.d.ts.map +1 -1
  45. package/dest/sequencer/timetable.js +145 -59
  46. package/dest/sequencer/types.d.ts +3 -0
  47. package/dest/sequencer/types.d.ts.map +1 -0
  48. package/dest/sequencer/types.js +1 -0
  49. package/dest/sequencer/utils.d.ts +14 -8
  50. package/dest/sequencer/utils.d.ts.map +1 -1
  51. package/dest/sequencer/utils.js +7 -4
  52. package/dest/test/index.d.ts +3 -2
  53. package/dest/test/index.d.ts.map +1 -1
  54. package/dest/test/mock_checkpoint_builder.d.ts +95 -0
  55. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  56. package/dest/test/mock_checkpoint_builder.js +220 -0
  57. package/dest/test/utils.d.ts +53 -0
  58. package/dest/test/utils.d.ts.map +1 -0
  59. package/dest/test/utils.js +103 -0
  60. package/package.json +30 -28
  61. package/src/client/sequencer-client.ts +27 -35
  62. package/src/config.ts +73 -27
  63. package/src/global_variable_builder/global_builder.ts +57 -51
  64. package/src/index.ts +1 -7
  65. package/src/publisher/config.ts +3 -3
  66. package/src/publisher/sequencer-publisher-factory.ts +3 -3
  67. package/src/publisher/sequencer-publisher-metrics.ts +19 -71
  68. package/src/publisher/sequencer-publisher.ts +284 -161
  69. package/src/sequencer/README.md +531 -0
  70. package/src/sequencer/checkpoint_proposal_job.ts +877 -0
  71. package/src/sequencer/checkpoint_voter.ts +130 -0
  72. package/src/sequencer/events.ts +27 -0
  73. package/src/sequencer/index.ts +3 -1
  74. package/src/sequencer/metrics.ts +189 -77
  75. package/src/sequencer/sequencer.ts +416 -805
  76. package/src/sequencer/timetable.ts +175 -80
  77. package/src/sequencer/types.ts +6 -0
  78. package/src/sequencer/utils.ts +18 -9
  79. package/src/test/index.ts +2 -1
  80. package/src/test/mock_checkpoint_builder.ts +309 -0
  81. package/src/test/utils.ts +164 -0
  82. package/dest/sequencer/block_builder.d.ts +0 -28
  83. package/dest/sequencer/block_builder.d.ts.map +0 -1
  84. package/dest/sequencer/block_builder.js +0 -127
  85. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  86. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  87. package/dest/tx_validator/nullifier_cache.js +0 -24
  88. package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
  89. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  90. package/dest/tx_validator/tx_validator_factory.js +0 -53
  91. package/src/sequencer/block_builder.ts +0 -214
  92. package/src/tx_validator/nullifier_cache.ts +0 -30
  93. package/src/tx_validator/tx_validator_factory.ts +0 -133
@@ -0,0 +1,220 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { Checkpoint } from '@aztec/stdlib/checkpoint';
3
+ import { Gas } from '@aztec/stdlib/gas';
4
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
5
+ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
6
+ /**
7
+ * A fake CheckpointBuilder for testing that implements the same interface as the real one.
8
+ * Can be seeded with blocks to return sequentially on each `buildBlock` call.
9
+ */ export class MockCheckpointBuilder {
10
+ constants;
11
+ checkpointNumber;
12
+ blocks;
13
+ builtBlocks;
14
+ usedTxsPerBlock;
15
+ blockIndex;
16
+ /** Optional function to dynamically provide the block (alternative to seedBlocks) */ blockProvider;
17
+ /** Track calls for assertions */ buildBlockCalls;
18
+ /** Track all consumed transaction hashes across buildBlock calls */ consumedTxHashes;
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.consumedTxHashes = new Set();
32
+ this.completeCheckpointCalled = false;
33
+ this.getCheckpointCalled = false;
34
+ this.errorOnBuild = undefined;
35
+ }
36
+ /** Seed the builder with blocks to return on successive buildBlock calls */ seedBlocks(blocks, usedTxsPerBlock) {
37
+ this.blocks = blocks;
38
+ this.usedTxsPerBlock = usedTxsPerBlock ?? blocks.map(()=>[]);
39
+ this.blockIndex = 0;
40
+ this.blockProvider = undefined;
41
+ return this;
42
+ }
43
+ /**
44
+ * Set a function that provides blocks dynamically.
45
+ * Useful for tests where the block is determined at call time (e.g., sequencer tests).
46
+ */ setBlockProvider(provider) {
47
+ this.blockProvider = provider;
48
+ this.blocks = [];
49
+ return this;
50
+ }
51
+ getConstantData() {
52
+ return this.constants;
53
+ }
54
+ async buildBlock(pendingTxs, blockNumber, timestamp, opts) {
55
+ this.buildBlockCalls.push({
56
+ blockNumber,
57
+ timestamp,
58
+ opts
59
+ });
60
+ if (this.errorOnBuild) {
61
+ throw this.errorOnBuild;
62
+ }
63
+ let block;
64
+ let usedTxs;
65
+ if (this.blockProvider) {
66
+ // Dynamic mode: get block from provider
67
+ block = this.blockProvider();
68
+ usedTxs = [];
69
+ this.builtBlocks.push(block);
70
+ } else {
71
+ // Seeded mode: get block from pre-seeded list
72
+ block = this.blocks[this.blockIndex];
73
+ usedTxs = this.usedTxsPerBlock[this.blockIndex] ?? [];
74
+ this.blockIndex++;
75
+ this.builtBlocks.push(block);
76
+ }
77
+ // Check that no pending tx has already been consumed
78
+ for await (const tx of pendingTxs){
79
+ const hash = tx.getTxHash().toString();
80
+ if (this.consumedTxHashes.has(hash)) {
81
+ throw new Error(`Transaction ${hash} was already consumed in a previous block`);
82
+ }
83
+ }
84
+ // Add used txs to consumed set
85
+ for (const tx of usedTxs){
86
+ this.consumedTxHashes.add(tx.getTxHash().toString());
87
+ }
88
+ return {
89
+ block,
90
+ publicGas: Gas.empty(),
91
+ publicProcessorDuration: 0,
92
+ numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
93
+ usedTxs,
94
+ failedTxs: [],
95
+ usedTxBlobFields: block?.body?.txEffects?.reduce((sum, tx)=>sum + tx.getNumBlobFields(), 0) ?? 0
96
+ };
97
+ }
98
+ completeCheckpoint() {
99
+ this.completeCheckpointCalled = true;
100
+ const allBlocks = this.blockProvider ? this.builtBlocks : this.blocks;
101
+ const lastBlock = allBlocks[allBlocks.length - 1];
102
+ // Create a CheckpointHeader from the last block's header for testing
103
+ const checkpointHeader = this.createCheckpointHeader(lastBlock);
104
+ return Promise.resolve(new Checkpoint(makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1), checkpointHeader, allBlocks, this.checkpointNumber));
105
+ }
106
+ getCheckpoint() {
107
+ this.getCheckpointCalled = true;
108
+ const builtBlocks = this.blockProvider ? this.builtBlocks : this.blocks.slice(0, this.blockIndex);
109
+ const lastBlock = builtBlocks[builtBlocks.length - 1];
110
+ if (!lastBlock) {
111
+ throw new Error('No blocks built yet');
112
+ }
113
+ // Create a CheckpointHeader from the last block's header for testing
114
+ const checkpointHeader = this.createCheckpointHeader(lastBlock);
115
+ return Promise.resolve(new Checkpoint(makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1), checkpointHeader, builtBlocks, this.checkpointNumber));
116
+ }
117
+ /**
118
+ * Creates a CheckpointHeader from a block's header for testing.
119
+ * This is a simplified version that creates a minimal CheckpointHeader.
120
+ */ createCheckpointHeader(block) {
121
+ const header = block.header;
122
+ const gv = header.globalVariables;
123
+ return CheckpointHeader.empty({
124
+ lastArchiveRoot: header.lastArchive.root,
125
+ blockHeadersHash: Fr.random(),
126
+ slotNumber: gv.slotNumber,
127
+ timestamp: gv.timestamp,
128
+ coinbase: gv.coinbase,
129
+ feeRecipient: gv.feeRecipient,
130
+ gasFees: gv.gasFees,
131
+ totalManaUsed: header.totalManaUsed
132
+ });
133
+ }
134
+ /** Reset for reuse in another test */ reset() {
135
+ this.blocks = [];
136
+ this.builtBlocks = [];
137
+ this.usedTxsPerBlock = [];
138
+ this.blockIndex = 0;
139
+ this.buildBlockCalls = [];
140
+ this.consumedTxHashes.clear();
141
+ this.completeCheckpointCalled = false;
142
+ this.getCheckpointCalled = false;
143
+ this.errorOnBuild = undefined;
144
+ this.blockProvider = undefined;
145
+ }
146
+ }
147
+ /**
148
+ * A fake CheckpointsBuilder (factory) for testing that implements the same interface
149
+ * as FullNodeCheckpointsBuilder. Returns MockCheckpointBuilder instances.
150
+ * Does NOT use jest mocks - this is a proper test double.
151
+ */ export class MockCheckpointsBuilder {
152
+ checkpointBuilder;
153
+ /** Track calls for assertions */ startCheckpointCalls = [];
154
+ openCheckpointCalls = [];
155
+ updateConfigCalls = [];
156
+ /**
157
+ * Set the MockCheckpointBuilder to return from startCheckpoint.
158
+ * Must be called before startCheckpoint is invoked.
159
+ */ setCheckpointBuilder(builder) {
160
+ this.checkpointBuilder = builder;
161
+ return this;
162
+ }
163
+ /**
164
+ * Creates a new MockCheckpointBuilder with the given constants.
165
+ * Convenience method that creates and sets the builder in one call.
166
+ */ createCheckpointBuilder(constants, checkpointNumber) {
167
+ this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
168
+ return this.checkpointBuilder;
169
+ }
170
+ /** Get the current checkpoint builder (for assertions) */ getCheckpointBuilder() {
171
+ return this.checkpointBuilder;
172
+ }
173
+ getConfig() {
174
+ return {
175
+ l1GenesisTime: 0n,
176
+ slotDuration: 24,
177
+ l1ChainId: 1,
178
+ rollupVersion: 1
179
+ };
180
+ }
181
+ updateConfig(config) {
182
+ this.updateConfigCalls.push(config);
183
+ }
184
+ startCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, _fork) {
185
+ this.startCheckpointCalls.push({
186
+ checkpointNumber,
187
+ constants,
188
+ l1ToL2Messages,
189
+ previousCheckpointOutHashes
190
+ });
191
+ if (!this.checkpointBuilder) {
192
+ // Auto-create a builder if none was set
193
+ this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
194
+ }
195
+ return Promise.resolve(this.checkpointBuilder);
196
+ }
197
+ openCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, _fork, existingBlocks = []) {
198
+ this.openCheckpointCalls.push({
199
+ checkpointNumber,
200
+ constants,
201
+ l1ToL2Messages,
202
+ previousCheckpointOutHashes,
203
+ existingBlocks
204
+ });
205
+ if (!this.checkpointBuilder) {
206
+ // Auto-create a builder if none was set
207
+ this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
208
+ }
209
+ return Promise.resolve(this.checkpointBuilder);
210
+ }
211
+ getFork(_blockNumber) {
212
+ throw new Error('MockCheckpointsBuilder.getFork not implemented');
213
+ }
214
+ /** Reset for reuse in another test */ reset() {
215
+ this.checkpointBuilder = undefined;
216
+ this.startCheckpointCalls = [];
217
+ this.openCheckpointCalls = [];
218
+ this.updateConfigCalls = [];
219
+ }
220
+ }
@@ -0,0 +1,53 @@
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, L2Block } from '@aztec/stdlib/block';
7
+ import { BlockProposal, CheckpointAttestation, CheckpointProposal } 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 L2Block from transactions and global variables
17
+ */
18
+ export declare function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Promise<L2Block>;
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: L2Block, signature: Signature): BlockProposal;
35
+ /**
36
+ * Creates a checkpoint proposal from a block and signature
37
+ */
38
+ export declare function createCheckpointProposal(block: L2Block, checkpointSignature: Signature, blockSignature?: Signature): CheckpointProposal;
39
+ /**
40
+ * Creates a checkpoint attestation from a block and signature.
41
+ * Note: We manually set the sender since we use random signatures in tests.
42
+ * In production, the sender is recovered from the signature.
43
+ */
44
+ export declare function createCheckpointAttestation(block: L2Block, signature: Signature, sender: EthAddress): CheckpointAttestation;
45
+ /**
46
+ * Creates transactions and a block, and mocks P2P to return them.
47
+ * Helper for tests that need to set up a block with transactions.
48
+ */
49
+ export declare function setupTxsAndBlock(p2p: MockProxy<P2P>, globalVariables: GlobalVariables, txCount: number, chainId: Fr): Promise<{
50
+ txs: Tx[];
51
+ block: L2Block;
52
+ }>;
53
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L3V0aWxzLnRzIl0sIm5hbWVz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M,EAAE,eAAe,GAAG,oBAAoB,EAAE,CAGpF;AAuBD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,aAAa,CAUvF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EACd,mBAAmB,EAAE,SAAS,EAC9B,cAAc,CAAC,EAAE,SAAS,GACzB,kBAAkB,CASpB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,UAAU,GACjB,qBAAqB,CAOvB;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,OAAO,CAAA;CAAE,CAAC,CAKxC"}
@@ -0,0 +1,103 @@
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 { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload } from '@aztec/stdlib/p2p';
9
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
10
+ import { makeAppendOnlyTreeSnapshot, mockTxForRollup } from '@aztec/stdlib/testing';
11
+ import { BlockHeader, 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 L2Block 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 L2Block(archive, header, body, CheckpointNumber.fromBlockNumber(globalVariables.blockNumber), IndexWithinCheckpoint(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 L2Block for testing purposes.
57
+ * Uses mock values for blockHeadersHash, blobsHash and inHash since L2Block doesn't have these fields.
58
+ */ function createCheckpointHeaderFromBlock(block) {
59
+ const gv = block.header.globalVariables;
60
+ 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);
61
+ }
62
+ /**
63
+ * Creates a block proposal from a block and signature
64
+ */ export function createBlockProposal(block, signature) {
65
+ const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
66
+ return new BlockProposal(block.header, block.indexWithinCheckpoint, Fr.ZERO, block.archive.root, txHashes, signature);
67
+ }
68
+ /**
69
+ * Creates a checkpoint proposal from a block and signature
70
+ */ export function createCheckpointProposal(block, checkpointSignature, blockSignature) {
71
+ const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
72
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
73
+ return new CheckpointProposal(checkpointHeader, block.archive.root, checkpointSignature, {
74
+ blockHeader: block.header,
75
+ indexWithinCheckpoint: block.indexWithinCheckpoint,
76
+ txHashes,
77
+ signature: blockSignature ?? checkpointSignature
78
+ });
79
+ }
80
+ /**
81
+ * Creates a checkpoint attestation from a block and signature.
82
+ * Note: We manually set the sender since we use random signatures in tests.
83
+ * In production, the sender is recovered from the signature.
84
+ */ export function createCheckpointAttestation(block, signature, sender) {
85
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
86
+ const payload = new ConsensusPayload(checkpointHeader, block.archive.root);
87
+ const attestation = new CheckpointAttestation(payload, signature, signature);
88
+ // Set sender directly for testing (bypasses signature recovery)
89
+ attestation.sender = sender;
90
+ return attestation;
91
+ }
92
+ /**
93
+ * Creates transactions and a block, and mocks P2P to return them.
94
+ * Helper for tests that need to set up a block with transactions.
95
+ */ export async function setupTxsAndBlock(p2p, globalVariables, txCount, chainId) {
96
+ const txs = await Promise.all(times(txCount, (i)=>makeTx(i + 1, chainId)));
97
+ const block = await makeBlock(txs, globalVariables);
98
+ mockPendingTxs(p2p, txs);
99
+ return {
100
+ txs,
101
+ block
102
+ };
103
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/sequencer-client",
3
- "version": "3.0.3",
3
+ "version": "4.0.0-devnet.1-patch.1",
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": "3.0.3",
30
- "@aztec/bb-prover": "3.0.3",
31
- "@aztec/blob-lib": "3.0.3",
32
- "@aztec/blob-sink": "3.0.3",
33
- "@aztec/constants": "3.0.3",
34
- "@aztec/epoch-cache": "3.0.3",
35
- "@aztec/ethereum": "3.0.3",
36
- "@aztec/foundation": "3.0.3",
37
- "@aztec/l1-artifacts": "3.0.3",
38
- "@aztec/merkle-tree": "3.0.3",
39
- "@aztec/node-keystore": "3.0.3",
40
- "@aztec/noir-acvm_js": "3.0.3",
41
- "@aztec/noir-contracts.js": "3.0.3",
42
- "@aztec/noir-protocol-circuits-types": "3.0.3",
43
- "@aztec/noir-types": "3.0.3",
44
- "@aztec/p2p": "3.0.3",
45
- "@aztec/protocol-contracts": "3.0.3",
46
- "@aztec/prover-client": "3.0.3",
47
- "@aztec/simulator": "3.0.3",
48
- "@aztec/slasher": "3.0.3",
49
- "@aztec/stdlib": "3.0.3",
50
- "@aztec/telemetry-client": "3.0.3",
51
- "@aztec/validator-client": "3.0.3",
52
- "@aztec/world-state": "3.0.3",
29
+ "@aztec/aztec.js": "4.0.0-devnet.1-patch.1",
30
+ "@aztec/bb-prover": "4.0.0-devnet.1-patch.1",
31
+ "@aztec/blob-client": "4.0.0-devnet.1-patch.1",
32
+ "@aztec/blob-lib": "4.0.0-devnet.1-patch.1",
33
+ "@aztec/constants": "4.0.0-devnet.1-patch.1",
34
+ "@aztec/epoch-cache": "4.0.0-devnet.1-patch.1",
35
+ "@aztec/ethereum": "4.0.0-devnet.1-patch.1",
36
+ "@aztec/foundation": "4.0.0-devnet.1-patch.1",
37
+ "@aztec/l1-artifacts": "4.0.0-devnet.1-patch.1",
38
+ "@aztec/merkle-tree": "4.0.0-devnet.1-patch.1",
39
+ "@aztec/node-keystore": "4.0.0-devnet.1-patch.1",
40
+ "@aztec/noir-acvm_js": "4.0.0-devnet.1-patch.1",
41
+ "@aztec/noir-contracts.js": "4.0.0-devnet.1-patch.1",
42
+ "@aztec/noir-protocol-circuits-types": "4.0.0-devnet.1-patch.1",
43
+ "@aztec/noir-types": "4.0.0-devnet.1-patch.1",
44
+ "@aztec/p2p": "4.0.0-devnet.1-patch.1",
45
+ "@aztec/protocol-contracts": "4.0.0-devnet.1-patch.1",
46
+ "@aztec/prover-client": "4.0.0-devnet.1-patch.1",
47
+ "@aztec/simulator": "4.0.0-devnet.1-patch.1",
48
+ "@aztec/slasher": "4.0.0-devnet.1-patch.1",
49
+ "@aztec/stdlib": "4.0.0-devnet.1-patch.1",
50
+ "@aztec/telemetry-client": "4.0.0-devnet.1-patch.1",
51
+ "@aztec/validator-client": "4.0.0-devnet.1-patch.1",
52
+ "@aztec/validator-ha-signer": "4.0.0-devnet.1-patch.1",
53
+ "@aztec/world-state": "4.0.0-devnet.1-patch.1",
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": "3.0.3",
59
- "@aztec/kv-store": "3.0.3",
59
+ "@aztec/archiver": "4.0.0-devnet.1-patch.1",
60
+ "@aztec/kv-store": "4.0.0-devnet.1-patch.1",
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,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';
@@ -11,16 +11,12 @@ import type { DateProvider } from '@aztec/foundation/timer';
11
11
  import type { KeystoreManager } from '@aztec/node-keystore';
12
12
  import type { P2P } from '@aztec/p2p';
13
13
  import type { SlasherClientInterface } from '@aztec/slasher';
14
- import type { L2BlockSource } from '@aztec/stdlib/block';
15
- import type {
16
- IFullNodeBlockBuilder,
17
- ValidatorClientFullConfig,
18
- WorldStateSynchronizer,
19
- } from '@aztec/stdlib/interfaces/server';
14
+ import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
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';
23
- import { NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
19
+ import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
24
20
 
25
21
  import type { SequencerClientConfig } from '../config.js';
26
22
  import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
@@ -34,7 +30,7 @@ export class SequencerClient {
34
30
  constructor(
35
31
  protected publisherManager: PublisherManager<L1TxUtilsWithBlobs>,
36
32
  protected sequencer: Sequencer,
37
- protected blockBuilder: IFullNodeBlockBuilder,
33
+ protected checkpointsBuilder: FullNodeCheckpointsBuilder,
38
34
  protected validatorClient?: ValidatorClient,
39
35
  private l1Metrics?: L1Metrics,
40
36
  ) {}
@@ -54,16 +50,16 @@ export class SequencerClient {
54
50
  public static async new(
55
51
  config: SequencerClientConfig,
56
52
  deps: {
57
- validatorClient: ValidatorClient | undefined; // allowed to be undefined while we migrate
53
+ validatorClient: ValidatorClient;
58
54
  p2pClient: P2P;
59
55
  worldStateSynchronizer: WorldStateSynchronizer;
60
56
  slasherClient: SlasherClientInterface | undefined;
61
- blockBuilder: IFullNodeBlockBuilder;
62
- l2BlockSource: L2BlockSource;
57
+ checkpointsBuilder: FullNodeCheckpointsBuilder;
58
+ l2BlockSource: L2BlockSource & L2BlockSink;
63
59
  l1ToL2MessageSource: L1ToL2MessageSource;
64
60
  telemetry: TelemetryClient;
65
61
  publisherFactory?: SequencerPublisherFactory;
66
- blobSinkClient?: BlobSinkClientInterface;
62
+ blobClient: BlobClientInterface;
67
63
  dateProvider: DateProvider;
68
64
  epochCache?: EpochCache;
69
65
  l1TxUtils: L1TxUtilsWithBlobs[];
@@ -75,7 +71,7 @@ export class SequencerClient {
75
71
  p2pClient,
76
72
  worldStateSynchronizer,
77
73
  slasherClient,
78
- blockBuilder,
74
+ checkpointsBuilder,
79
75
  l2BlockSource,
80
76
  l1ToL2MessageSource,
81
77
  telemetry: telemetryClient,
@@ -89,11 +85,13 @@ export class SequencerClient {
89
85
  publicClient,
90
86
  l1TxUtils.map(x => x.getSenderAddress()),
91
87
  );
92
- const publisherManager = new PublisherManager(l1TxUtils, config);
88
+ const publisherManager = new PublisherManager(l1TxUtils, config, log.getBindings());
93
89
  const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
94
- const [l1GenesisTime, slotDuration] = await Promise.all([
90
+ const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
95
91
  rollupContract.getL1GenesisTime(),
96
92
  rollupContract.getSlotDuration(),
93
+ rollupContract.getVersion(),
94
+ rollupContract.getManaLimit().then(Number),
97
95
  ] as const);
98
96
 
99
97
  const governanceProposerContract = new GovernanceProposerContract(
@@ -122,7 +120,7 @@ export class SequencerClient {
122
120
  deps.publisherFactory ??
123
121
  new SequencerPublisherFactory(config, {
124
122
  telemetry: telemetryClient,
125
- blobSinkClient: deps.blobSinkClient,
123
+ blobClient: deps.blobClient,
126
124
  epochCache,
127
125
  governanceProposerContract,
128
126
  slashFactoryContract,
@@ -132,33 +130,27 @@ export class SequencerClient {
132
130
  nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(deps.nodeKeyStore),
133
131
  logger: log,
134
132
  });
135
- const globalsBuilder = new GlobalVariableBuilder(config);
136
133
 
137
134
  const ethereumSlotDuration = config.ethereumSlotDuration;
135
+ const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
136
+
137
+ const globalsBuilder = new GlobalVariableBuilder({ ...config, ...l1Constants, rollupVersion });
138
138
 
139
- const rollupManaLimit = Number(await rollupContract.getManaLimit());
140
139
  let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
141
140
  if (sequencerManaLimit > rollupManaLimit) {
142
141
  log.warn(
143
- `Provided maxL2BlockGas of ${sequencerManaLimit} is greater than the maximum allowed by the L1 (${rollupManaLimit}), setting limit to ${rollupManaLimit}`,
142
+ `Provided maxL2BlockGas ${sequencerManaLimit} is greater than the max allowed by L1. Setting limit to ${rollupManaLimit}.`,
144
143
  );
145
144
  sequencerManaLimit = rollupManaLimit;
146
145
  }
147
146
 
148
147
  // 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.
148
+ // Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
151
149
  // 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.
150
+ // reduce the publishing time allowance. However, we prefer being conservative.
153
151
  // 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
- };
152
+ const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
153
+ const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
162
154
 
163
155
  const sequencer = new Sequencer(
164
156
  publisherFactory,
@@ -169,19 +161,19 @@ export class SequencerClient {
169
161
  slasherClient,
170
162
  l2BlockSource,
171
163
  l1ToL2MessageSource,
172
- blockBuilder,
164
+ checkpointsBuilder,
173
165
  l1Constants,
174
166
  deps.dateProvider,
175
167
  epochCache,
176
168
  rollupContract,
177
- { ...config, maxL1TxInclusionTimeIntoSlot, maxL2BlockGas: sequencerManaLimit },
169
+ { ...config, l1PublishingTime, maxL2BlockGas: sequencerManaLimit },
178
170
  telemetryClient,
179
171
  log,
180
172
  );
181
173
 
182
174
  await sequencer.init();
183
175
 
184
- return new SequencerClient(publisherManager, sequencer, blockBuilder, validatorClient, l1Metrics);
176
+ return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics);
185
177
  }
186
178
 
187
179
  /**
@@ -190,7 +182,7 @@ export class SequencerClient {
190
182
  */
191
183
  public updateConfig(config: SequencerConfig & Partial<ValidatorClientFullConfig>) {
192
184
  this.sequencer.updateConfig(config);
193
- this.blockBuilder.updateConfig(config);
185
+ this.checkpointsBuilder.updateConfig(config);
194
186
  this.validatorClient?.updateConfig(config);
195
187
  }
196
188