@aztec/sequencer-client 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c

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 (96) hide show
  1. package/dest/client/sequencer-client.d.ts +21 -16
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +45 -27
  4. package/dest/config.d.ts +14 -8
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +83 -35
  7. package/dest/global_variable_builder/global_builder.d.ts +20 -13
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +51 -41
  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 +37 -20
  14. package/dest/publisher/config.d.ts.map +1 -1
  15. package/dest/publisher/config.js +104 -39
  16. package/dest/publisher/sequencer-publisher-factory.d.ts +15 -6
  17. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  18. package/dest/publisher/sequencer-publisher-factory.js +14 -3
  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 +63 -47
  23. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  24. package/dest/publisher/sequencer-publisher.js +630 -137
  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 +1213 -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/config.d.ts +3 -2
  32. package/dest/sequencer/config.d.ts.map +1 -1
  33. package/dest/sequencer/events.d.ts +46 -0
  34. package/dest/sequencer/events.d.ts.map +1 -0
  35. package/dest/sequencer/events.js +1 -0
  36. package/dest/sequencer/index.d.ts +4 -2
  37. package/dest/sequencer/index.d.ts.map +1 -1
  38. package/dest/sequencer/index.js +3 -1
  39. package/dest/sequencer/metrics.d.ts +38 -6
  40. package/dest/sequencer/metrics.d.ts.map +1 -1
  41. package/dest/sequencer/metrics.js +216 -72
  42. package/dest/sequencer/sequencer.d.ts +119 -133
  43. package/dest/sequencer/sequencer.d.ts.map +1 -1
  44. package/dest/sequencer/sequencer.js +717 -625
  45. package/dest/sequencer/timetable.d.ts +51 -14
  46. package/dest/sequencer/timetable.d.ts.map +1 -1
  47. package/dest/sequencer/timetable.js +145 -59
  48. package/dest/sequencer/types.d.ts +3 -0
  49. package/dest/sequencer/types.d.ts.map +1 -0
  50. package/dest/sequencer/types.js +1 -0
  51. package/dest/sequencer/utils.d.ts +14 -8
  52. package/dest/sequencer/utils.d.ts.map +1 -1
  53. package/dest/sequencer/utils.js +7 -4
  54. package/dest/test/index.d.ts +6 -7
  55. package/dest/test/index.d.ts.map +1 -1
  56. package/dest/test/mock_checkpoint_builder.d.ts +97 -0
  57. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  58. package/dest/test/mock_checkpoint_builder.js +222 -0
  59. package/dest/test/utils.d.ts +53 -0
  60. package/dest/test/utils.d.ts.map +1 -0
  61. package/dest/test/utils.js +104 -0
  62. package/package.json +32 -30
  63. package/src/client/sequencer-client.ts +54 -47
  64. package/src/config.ts +95 -44
  65. package/src/global_variable_builder/global_builder.ts +65 -61
  66. package/src/index.ts +1 -7
  67. package/src/publisher/config.ts +122 -50
  68. package/src/publisher/sequencer-publisher-factory.ts +28 -10
  69. package/src/publisher/sequencer-publisher-metrics.ts +19 -71
  70. package/src/publisher/sequencer-publisher.ts +350 -176
  71. package/src/sequencer/README.md +531 -0
  72. package/src/sequencer/checkpoint_proposal_job.ts +914 -0
  73. package/src/sequencer/checkpoint_voter.ts +130 -0
  74. package/src/sequencer/config.ts +2 -1
  75. package/src/sequencer/events.ts +27 -0
  76. package/src/sequencer/index.ts +3 -1
  77. package/src/sequencer/metrics.ts +268 -82
  78. package/src/sequencer/sequencer.ts +464 -831
  79. package/src/sequencer/timetable.ts +175 -80
  80. package/src/sequencer/types.ts +6 -0
  81. package/src/sequencer/utils.ts +18 -9
  82. package/src/test/index.ts +5 -6
  83. package/src/test/mock_checkpoint_builder.ts +320 -0
  84. package/src/test/utils.ts +167 -0
  85. package/dest/sequencer/block_builder.d.ts +0 -27
  86. package/dest/sequencer/block_builder.d.ts.map +0 -1
  87. package/dest/sequencer/block_builder.js +0 -134
  88. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  89. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  90. package/dest/tx_validator/nullifier_cache.js +0 -24
  91. package/dest/tx_validator/tx_validator_factory.d.ts +0 -17
  92. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  93. package/dest/tx_validator/tx_validator_factory.js +0 -53
  94. package/src/sequencer/block_builder.ts +0 -222
  95. package/src/tx_validator/nullifier_cache.ts +0 -30
  96. package/src/tx_validator/tx_validator_factory.ts +0 -132
@@ -0,0 +1,222 @@
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, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, _fork) {
185
+ this.startCheckpointCalls.push({
186
+ checkpointNumber,
187
+ constants,
188
+ l1ToL2Messages,
189
+ previousCheckpointOutHashes,
190
+ feeAssetPriceModifier
191
+ });
192
+ if (!this.checkpointBuilder) {
193
+ // Auto-create a builder if none was set
194
+ this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
195
+ }
196
+ return Promise.resolve(this.checkpointBuilder);
197
+ }
198
+ openCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, _fork, existingBlocks = []) {
199
+ this.openCheckpointCalls.push({
200
+ checkpointNumber,
201
+ constants,
202
+ l1ToL2Messages,
203
+ previousCheckpointOutHashes,
204
+ existingBlocks,
205
+ feeAssetPriceModifier
206
+ });
207
+ if (!this.checkpointBuilder) {
208
+ // Auto-create a builder if none was set
209
+ this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
210
+ }
211
+ return Promise.resolve(this.checkpointBuilder);
212
+ }
213
+ getFork(_blockNumber) {
214
+ throw new Error('MockCheckpointsBuilder.getFork not implemented');
215
+ }
216
+ /** Reset for reuse in another test */ reset() {
217
+ this.checkpointBuilder = undefined;
218
+ this.startCheckpointCalls = [];
219
+ this.openCheckpointCalls = [];
220
+ this.updateConfigCalls = [];
221
+ }
222
+ }
@@ -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, feeAssetPriceModifier?: bigint): 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, feeAssetPriceModifier?: bigint): 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
+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gB7F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,IAAI,CAInE;AAED;;GAEG;AACH,wBAAuB,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,qBAAqB,CAAC,EAAE,CAAC,CAInF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,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,EAC1B,qBAAqB,GAAE,MAAW,GACjC,kBAAkB,CASpB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,UAAU,EAClB,qBAAqB,GAAE,MAAW,GACjC,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,104 @@
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
+ p2p.iterateEligiblePendingTxs.mockImplementation(()=>mockTxIterator(Promise.resolve(txs)));
40
+ }
41
+ /**
42
+ * Creates an async iterator for transactions
43
+ */ export async function* mockTxIterator(txs) {
44
+ for (const tx of (await txs)){
45
+ yield tx;
46
+ }
47
+ }
48
+ /**
49
+ * Creates mock committee attestations from a signer
50
+ */ export function createMockSignatures(signer) {
51
+ const mockedSig = Signature.random();
52
+ return [
53
+ new CommitteeAttestation(signer.address, mockedSig)
54
+ ];
55
+ }
56
+ /**
57
+ * Creates a CheckpointHeader from an L2Block for testing purposes.
58
+ * Uses mock values for blockHeadersHash, blobsHash and inHash since L2Block doesn't have these fields.
59
+ */ function createCheckpointHeaderFromBlock(block) {
60
+ const gv = block.header.globalVariables;
61
+ return new CheckpointHeader(block.header.lastArchive.root, Fr.random(), Fr.random(), Fr.random(), Fr.random(), gv.slotNumber, gv.timestamp, gv.coinbase, gv.feeRecipient, gv.gasFees, block.header.totalManaUsed);
62
+ }
63
+ /**
64
+ * Creates a block proposal from a block and signature
65
+ */ export function createBlockProposal(block, signature) {
66
+ const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
67
+ return new BlockProposal(block.header, block.indexWithinCheckpoint, Fr.ZERO, block.archive.root, txHashes, signature);
68
+ }
69
+ /**
70
+ * Creates a checkpoint proposal from a block and signature
71
+ */ export function createCheckpointProposal(block, checkpointSignature, blockSignature, feeAssetPriceModifier = 0n) {
72
+ const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
73
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
74
+ return new CheckpointProposal(checkpointHeader, block.archive.root, feeAssetPriceModifier, checkpointSignature, {
75
+ blockHeader: block.header,
76
+ indexWithinCheckpoint: block.indexWithinCheckpoint,
77
+ txHashes,
78
+ signature: blockSignature ?? checkpointSignature
79
+ });
80
+ }
81
+ /**
82
+ * Creates a checkpoint attestation from a block and signature.
83
+ * Note: We manually set the sender since we use random signatures in tests.
84
+ * In production, the sender is recovered from the signature.
85
+ */ export function createCheckpointAttestation(block, signature, sender, feeAssetPriceModifier = 0n) {
86
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
87
+ const payload = new ConsensusPayload(checkpointHeader, block.archive.root, feeAssetPriceModifier);
88
+ const attestation = new CheckpointAttestation(payload, signature, signature);
89
+ // Set sender directly for testing (bypasses signature recovery)
90
+ attestation.sender = sender;
91
+ return attestation;
92
+ }
93
+ /**
94
+ * Creates transactions and a block, and mocks P2P to return them.
95
+ * Helper for tests that need to set up a block with transactions.
96
+ */ export async function setupTxsAndBlock(p2p, globalVariables, txCount, chainId) {
97
+ const txs = await Promise.all(times(txCount, (i)=>makeTx(i + 1, chainId)));
98
+ const block = await makeBlock(txs, globalVariables);
99
+ mockPendingTxs(p2p, txs);
100
+ return {
101
+ txs,
102
+ block
103
+ };
104
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/sequencer-client",
3
- "version": "0.0.1-commit.fce3e4f",
3
+ "version": "0.0.1-commit.ff7989d6c",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -18,51 +18,53 @@
18
18
  "../package.common.json"
19
19
  ],
20
20
  "scripts": {
21
- "build": "yarn clean && tsgo -b",
22
- "build:dev": "tsgo -b --watch",
21
+ "build": "yarn clean && ../scripts/tsc.sh",
22
+ "build:dev": "../scripts/tsc.sh --watch",
23
23
  "clean": "rm -rf ./dest .tsbuildinfo",
24
24
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
25
25
  "test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
26
26
  "test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
27
27
  },
28
28
  "dependencies": {
29
- "@aztec/aztec.js": "0.0.1-commit.fce3e4f",
30
- "@aztec/bb-prover": "0.0.1-commit.fce3e4f",
31
- "@aztec/blob-lib": "0.0.1-commit.fce3e4f",
32
- "@aztec/blob-sink": "0.0.1-commit.fce3e4f",
33
- "@aztec/constants": "0.0.1-commit.fce3e4f",
34
- "@aztec/epoch-cache": "0.0.1-commit.fce3e4f",
35
- "@aztec/ethereum": "0.0.1-commit.fce3e4f",
36
- "@aztec/foundation": "0.0.1-commit.fce3e4f",
37
- "@aztec/l1-artifacts": "0.0.1-commit.fce3e4f",
38
- "@aztec/merkle-tree": "0.0.1-commit.fce3e4f",
39
- "@aztec/node-keystore": "0.0.1-commit.fce3e4f",
40
- "@aztec/noir-acvm_js": "0.0.1-commit.fce3e4f",
41
- "@aztec/noir-contracts.js": "0.0.1-commit.fce3e4f",
42
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.fce3e4f",
43
- "@aztec/noir-types": "0.0.1-commit.fce3e4f",
44
- "@aztec/p2p": "0.0.1-commit.fce3e4f",
45
- "@aztec/protocol-contracts": "0.0.1-commit.fce3e4f",
46
- "@aztec/prover-client": "0.0.1-commit.fce3e4f",
47
- "@aztec/simulator": "0.0.1-commit.fce3e4f",
48
- "@aztec/slasher": "0.0.1-commit.fce3e4f",
49
- "@aztec/stdlib": "0.0.1-commit.fce3e4f",
50
- "@aztec/telemetry-client": "0.0.1-commit.fce3e4f",
51
- "@aztec/validator-client": "0.0.1-commit.fce3e4f",
52
- "@aztec/world-state": "0.0.1-commit.fce3e4f",
29
+ "@aztec/aztec.js": "0.0.1-commit.ff7989d6c",
30
+ "@aztec/bb-prover": "0.0.1-commit.ff7989d6c",
31
+ "@aztec/blob-client": "0.0.1-commit.ff7989d6c",
32
+ "@aztec/blob-lib": "0.0.1-commit.ff7989d6c",
33
+ "@aztec/constants": "0.0.1-commit.ff7989d6c",
34
+ "@aztec/epoch-cache": "0.0.1-commit.ff7989d6c",
35
+ "@aztec/ethereum": "0.0.1-commit.ff7989d6c",
36
+ "@aztec/foundation": "0.0.1-commit.ff7989d6c",
37
+ "@aztec/l1-artifacts": "0.0.1-commit.ff7989d6c",
38
+ "@aztec/merkle-tree": "0.0.1-commit.ff7989d6c",
39
+ "@aztec/node-keystore": "0.0.1-commit.ff7989d6c",
40
+ "@aztec/noir-acvm_js": "0.0.1-commit.ff7989d6c",
41
+ "@aztec/noir-contracts.js": "0.0.1-commit.ff7989d6c",
42
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.ff7989d6c",
43
+ "@aztec/noir-types": "0.0.1-commit.ff7989d6c",
44
+ "@aztec/p2p": "0.0.1-commit.ff7989d6c",
45
+ "@aztec/protocol-contracts": "0.0.1-commit.ff7989d6c",
46
+ "@aztec/prover-client": "0.0.1-commit.ff7989d6c",
47
+ "@aztec/simulator": "0.0.1-commit.ff7989d6c",
48
+ "@aztec/slasher": "0.0.1-commit.ff7989d6c",
49
+ "@aztec/stdlib": "0.0.1-commit.ff7989d6c",
50
+ "@aztec/telemetry-client": "0.0.1-commit.ff7989d6c",
51
+ "@aztec/validator-client": "0.0.1-commit.ff7989d6c",
52
+ "@aztec/validator-ha-signer": "0.0.1-commit.ff7989d6c",
53
+ "@aztec/world-state": "0.0.1-commit.ff7989d6c",
53
54
  "lodash.chunk": "^4.2.0",
54
55
  "tslib": "^2.4.0",
55
56
  "viem": "npm:@aztec/viem@2.38.2"
56
57
  },
57
58
  "devDependencies": {
58
- "@aztec/archiver": "0.0.1-commit.fce3e4f",
59
- "@aztec/kv-store": "0.0.1-commit.fce3e4f",
59
+ "@aztec/archiver": "0.0.1-commit.ff7989d6c",
60
+ "@aztec/kv-store": "0.0.1-commit.ff7989d6c",
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",