@aztec/sequencer-client 0.0.1-commit.d3ec352c → 0.0.1-commit.fcb71a6

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 +10 -9
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +32 -25
  4. package/dest/config.d.ts +12 -5
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +68 -30
  7. package/dest/global_variable_builder/global_builder.d.ts +18 -9
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +39 -29
  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 +7 -4
  14. package/dest/publisher/config.d.ts.map +1 -1
  15. package/dest/publisher/config.js +9 -3
  16. package/dest/publisher/sequencer-publisher-factory.d.ts +5 -4
  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 +32 -25
  22. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  23. package/dest/publisher/sequencer-publisher.js +122 -65
  24. package/dest/sequencer/block_builder.d.ts +2 -4
  25. package/dest/sequencer/block_builder.d.ts.map +1 -1
  26. package/dest/sequencer/block_builder.js +6 -11
  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/config.d.ts +3 -2
  37. package/dest/sequencer/config.d.ts.map +1 -1
  38. package/dest/sequencer/events.d.ts +46 -0
  39. package/dest/sequencer/events.d.ts.map +1 -0
  40. package/dest/sequencer/events.js +1 -0
  41. package/dest/sequencer/index.d.ts +5 -1
  42. package/dest/sequencer/index.d.ts.map +1 -1
  43. package/dest/sequencer/index.js +4 -0
  44. package/dest/sequencer/metrics.d.ts +22 -2
  45. package/dest/sequencer/metrics.d.ts.map +1 -1
  46. package/dest/sequencer/metrics.js +154 -0
  47. package/dest/sequencer/sequencer.d.ts +93 -127
  48. package/dest/sequencer/sequencer.d.ts.map +1 -1
  49. package/dest/sequencer/sequencer.js +218 -574
  50. package/dest/sequencer/timetable.d.ts +54 -14
  51. package/dest/sequencer/timetable.d.ts.map +1 -1
  52. package/dest/sequencer/timetable.js +148 -59
  53. package/dest/sequencer/types.d.ts +3 -0
  54. package/dest/sequencer/types.d.ts.map +1 -0
  55. package/dest/sequencer/types.js +1 -0
  56. package/dest/sequencer/utils.d.ts +14 -8
  57. package/dest/sequencer/utils.d.ts.map +1 -1
  58. package/dest/sequencer/utils.js +7 -4
  59. package/dest/test/index.d.ts +4 -2
  60. package/dest/test/index.d.ts.map +1 -1
  61. package/dest/test/mock_checkpoint_builder.d.ts +83 -0
  62. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  63. package/dest/test/mock_checkpoint_builder.js +179 -0
  64. package/dest/test/utils.d.ts +49 -0
  65. package/dest/test/utils.d.ts.map +1 -0
  66. package/dest/test/utils.js +94 -0
  67. package/dest/tx_validator/tx_validator_factory.js +1 -1
  68. package/package.json +27 -27
  69. package/src/client/sequencer-client.ts +28 -38
  70. package/src/config.ts +73 -34
  71. package/src/global_variable_builder/global_builder.ts +52 -48
  72. package/src/index.ts +2 -0
  73. package/src/publisher/config.ts +12 -9
  74. package/src/publisher/sequencer-publisher-factory.ts +5 -4
  75. package/src/publisher/sequencer-publisher-metrics.ts +2 -2
  76. package/src/publisher/sequencer-publisher.ts +180 -84
  77. package/src/sequencer/README.md +531 -0
  78. package/src/sequencer/block_builder.ts +7 -12
  79. package/src/sequencer/checkpoint_builder.ts +217 -0
  80. package/src/sequencer/checkpoint_proposal_job.ts +706 -0
  81. package/src/sequencer/checkpoint_voter.ts +105 -0
  82. package/src/sequencer/config.ts +2 -1
  83. package/src/sequencer/events.ts +27 -0
  84. package/src/sequencer/index.ts +4 -0
  85. package/src/sequencer/metrics.ts +203 -1
  86. package/src/sequencer/sequencer.ts +322 -779
  87. package/src/sequencer/timetable.ts +173 -79
  88. package/src/sequencer/types.ts +6 -0
  89. package/src/sequencer/utils.ts +18 -9
  90. package/src/test/index.ts +3 -1
  91. package/src/test/mock_checkpoint_builder.ts +247 -0
  92. package/src/test/utils.ts +137 -0
  93. package/src/tx_validator/tx_validator_factory.ts +1 -1
@@ -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
+ }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AEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,aAAa,CAK1F;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,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
+ }
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
3
3
  import { AggregateTxValidator, ArchiveCache, BlockHeaderTxValidator, DataTxValidator, DoubleSpendTxValidator, GasTxValidator, MetadataTxValidator, PhasesTxValidator, TimestampTxValidator, TxPermittedValidator, TxProofValidator } from '@aztec/p2p';
4
4
  import { ProtocolContractAddress, protocolContractsHash } from '@aztec/protocol-contracts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/sequencer-client",
3
- "version": "0.0.1-commit.d3ec352c",
3
+ "version": "0.0.1-commit.fcb71a6",
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": "0.0.1-commit.d3ec352c",
30
- "@aztec/bb-prover": "0.0.1-commit.d3ec352c",
31
- "@aztec/blob-lib": "0.0.1-commit.d3ec352c",
32
- "@aztec/blob-sink": "0.0.1-commit.d3ec352c",
33
- "@aztec/constants": "0.0.1-commit.d3ec352c",
34
- "@aztec/epoch-cache": "0.0.1-commit.d3ec352c",
35
- "@aztec/ethereum": "0.0.1-commit.d3ec352c",
36
- "@aztec/foundation": "0.0.1-commit.d3ec352c",
37
- "@aztec/l1-artifacts": "0.0.1-commit.d3ec352c",
38
- "@aztec/merkle-tree": "0.0.1-commit.d3ec352c",
39
- "@aztec/node-keystore": "0.0.1-commit.d3ec352c",
40
- "@aztec/noir-acvm_js": "0.0.1-commit.d3ec352c",
41
- "@aztec/noir-contracts.js": "0.0.1-commit.d3ec352c",
42
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.d3ec352c",
43
- "@aztec/noir-types": "0.0.1-commit.d3ec352c",
44
- "@aztec/p2p": "0.0.1-commit.d3ec352c",
45
- "@aztec/protocol-contracts": "0.0.1-commit.d3ec352c",
46
- "@aztec/prover-client": "0.0.1-commit.d3ec352c",
47
- "@aztec/simulator": "0.0.1-commit.d3ec352c",
48
- "@aztec/slasher": "0.0.1-commit.d3ec352c",
49
- "@aztec/stdlib": "0.0.1-commit.d3ec352c",
50
- "@aztec/telemetry-client": "0.0.1-commit.d3ec352c",
51
- "@aztec/validator-client": "0.0.1-commit.d3ec352c",
52
- "@aztec/world-state": "0.0.1-commit.d3ec352c",
29
+ "@aztec/aztec.js": "0.0.1-commit.fcb71a6",
30
+ "@aztec/bb-prover": "0.0.1-commit.fcb71a6",
31
+ "@aztec/blob-client": "0.0.1-commit.fcb71a6",
32
+ "@aztec/blob-lib": "0.0.1-commit.fcb71a6",
33
+ "@aztec/constants": "0.0.1-commit.fcb71a6",
34
+ "@aztec/epoch-cache": "0.0.1-commit.fcb71a6",
35
+ "@aztec/ethereum": "0.0.1-commit.fcb71a6",
36
+ "@aztec/foundation": "0.0.1-commit.fcb71a6",
37
+ "@aztec/l1-artifacts": "0.0.1-commit.fcb71a6",
38
+ "@aztec/merkle-tree": "0.0.1-commit.fcb71a6",
39
+ "@aztec/node-keystore": "0.0.1-commit.fcb71a6",
40
+ "@aztec/noir-acvm_js": "0.0.1-commit.fcb71a6",
41
+ "@aztec/noir-contracts.js": "0.0.1-commit.fcb71a6",
42
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.fcb71a6",
43
+ "@aztec/noir-types": "0.0.1-commit.fcb71a6",
44
+ "@aztec/p2p": "0.0.1-commit.fcb71a6",
45
+ "@aztec/protocol-contracts": "0.0.1-commit.fcb71a6",
46
+ "@aztec/prover-client": "0.0.1-commit.fcb71a6",
47
+ "@aztec/simulator": "0.0.1-commit.fcb71a6",
48
+ "@aztec/slasher": "0.0.1-commit.fcb71a6",
49
+ "@aztec/stdlib": "0.0.1-commit.fcb71a6",
50
+ "@aztec/telemetry-client": "0.0.1-commit.fcb71a6",
51
+ "@aztec/validator-client": "0.0.1-commit.fcb71a6",
52
+ "@aztec/world-state": "0.0.1-commit.fcb71a6",
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": "0.0.1-commit.d3ec352c",
59
- "@aztec/kv-store": "0.0.1-commit.d3ec352c",
58
+ "@aztec/archiver": "0.0.1-commit.fcb71a6",
59
+ "@aztec/kv-store": "0.0.1-commit.fcb71a6",
60
60
  "@jest/globals": "^30.0.0",
61
61
  "@types/jest": "^30.0.0",
62
62
  "@types/lodash.chunk": "^4.2.7",
@@ -1,13 +1,10 @@
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
- import {
4
- GovernanceProposerContract,
5
- PublisherManager,
6
- RollupContract,
7
- getPublicClient,
8
- isAnvilTestChain,
9
- } from '@aztec/ethereum';
3
+ import { isAnvilTestChain } from '@aztec/ethereum/chain';
4
+ import { getPublicClient } from '@aztec/ethereum/client';
5
+ import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
10
6
  import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
7
+ import { PublisherManager } from '@aztec/ethereum/publisher-manager';
11
8
  import { EthAddress } from '@aztec/foundation/eth-address';
12
9
  import { createLogger } from '@aztec/foundation/log';
13
10
  import type { DateProvider } from '@aztec/foundation/timer';
@@ -15,11 +12,7 @@ import type { KeystoreManager } from '@aztec/node-keystore';
15
12
  import type { P2P } from '@aztec/p2p';
16
13
  import type { SlasherClientInterface } from '@aztec/slasher';
17
14
  import type { L2BlockSource } from '@aztec/stdlib/block';
18
- import type {
19
- IFullNodeBlockBuilder,
20
- ValidatorClientFullConfig,
21
- WorldStateSynchronizer,
22
- } from '@aztec/stdlib/interfaces/server';
15
+ import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
23
16
  import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
24
17
  import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
25
18
  import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
@@ -28,6 +21,7 @@ import { NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-clie
28
21
  import type { SequencerClientConfig } from '../config.js';
29
22
  import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
30
23
  import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
24
+ import { FullNodeCheckpointsBuilder } from '../sequencer/checkpoint_builder.js';
31
25
  import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
32
26
 
33
27
  /**
@@ -37,7 +31,7 @@ export class SequencerClient {
37
31
  constructor(
38
32
  protected publisherManager: PublisherManager<L1TxUtilsWithBlobs>,
39
33
  protected sequencer: Sequencer,
40
- protected blockBuilder: IFullNodeBlockBuilder,
34
+ protected checkpointsBuilder: FullNodeCheckpointsBuilder,
41
35
  protected validatorClient?: ValidatorClient,
42
36
  private l1Metrics?: L1Metrics,
43
37
  ) {}
@@ -57,16 +51,16 @@ export class SequencerClient {
57
51
  public static async new(
58
52
  config: SequencerClientConfig,
59
53
  deps: {
60
- validatorClient: ValidatorClient | undefined; // allowed to be undefined while we migrate
54
+ validatorClient: ValidatorClient;
61
55
  p2pClient: P2P;
62
56
  worldStateSynchronizer: WorldStateSynchronizer;
63
57
  slasherClient: SlasherClientInterface | undefined;
64
- blockBuilder: IFullNodeBlockBuilder;
58
+ checkpointsBuilder: FullNodeCheckpointsBuilder;
65
59
  l2BlockSource: L2BlockSource;
66
60
  l1ToL2MessageSource: L1ToL2MessageSource;
67
61
  telemetry: TelemetryClient;
68
62
  publisherFactory?: SequencerPublisherFactory;
69
- blobSinkClient?: BlobSinkClientInterface;
63
+ blobClient: BlobClientInterface;
70
64
  dateProvider: DateProvider;
71
65
  epochCache?: EpochCache;
72
66
  l1TxUtils: L1TxUtilsWithBlobs[];
@@ -78,7 +72,7 @@ export class SequencerClient {
78
72
  p2pClient,
79
73
  worldStateSynchronizer,
80
74
  slasherClient,
81
- blockBuilder,
75
+ checkpointsBuilder,
82
76
  l2BlockSource,
83
77
  l1ToL2MessageSource,
84
78
  telemetry: telemetryClient,
@@ -94,9 +88,11 @@ export class SequencerClient {
94
88
  );
95
89
  const publisherManager = new PublisherManager(l1TxUtils, config);
96
90
  const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
97
- const [l1GenesisTime, slotDuration] = await Promise.all([
91
+ const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
98
92
  rollupContract.getL1GenesisTime(),
99
93
  rollupContract.getSlotDuration(),
94
+ rollupContract.getVersion(),
95
+ rollupContract.getManaLimit().then(Number),
100
96
  ] as const);
101
97
 
102
98
  const governanceProposerContract = new GovernanceProposerContract(
@@ -125,7 +121,7 @@ export class SequencerClient {
125
121
  deps.publisherFactory ??
126
122
  new SequencerPublisherFactory(config, {
127
123
  telemetry: telemetryClient,
128
- blobSinkClient: deps.blobSinkClient,
124
+ blobClient: deps.blobClient,
129
125
  epochCache,
130
126
  governanceProposerContract,
131
127
  slashFactoryContract,
@@ -135,33 +131,27 @@ export class SequencerClient {
135
131
  nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(deps.nodeKeyStore),
136
132
  logger: log,
137
133
  });
138
- const globalsBuilder = new GlobalVariableBuilder(config);
139
134
 
140
135
  const ethereumSlotDuration = config.ethereumSlotDuration;
136
+ const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
137
+
138
+ const globalsBuilder = new GlobalVariableBuilder({ ...config, ...l1Constants, rollupVersion });
141
139
 
142
- const rollupManaLimit = Number(await rollupContract.getManaLimit());
143
140
  let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
144
141
  if (sequencerManaLimit > rollupManaLimit) {
145
142
  log.warn(
146
- `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}.`,
147
144
  );
148
145
  sequencerManaLimit = rollupManaLimit;
149
146
  }
150
147
 
151
148
  // When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
152
- // Otherwise, assume we must have broadcasted the tx before the slot started (we use a default
153
- // maxL1TxInclusionTimeIntoSlot of zero) to get the tx into that L1 slot.
149
+ // Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
154
150
  // In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
155
- // make it with a propagation time into slot equal to 4s. However, we prefer being conservative.
151
+ // reduce the publishing time allowance. However, we prefer being conservative.
156
152
  // See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
157
- const maxInclusionBasedOnChain = isAnvilTestChain(config.l1ChainId) ? ethereumSlotDuration - 1 : 0;
158
- const maxL1TxInclusionTimeIntoSlot = config.maxL1TxInclusionTimeIntoSlot ?? maxInclusionBasedOnChain;
159
-
160
- const l1Constants = {
161
- l1GenesisTime,
162
- slotDuration: Number(slotDuration),
163
- ethereumSlotDuration,
164
- };
153
+ const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
154
+ const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
165
155
 
166
156
  const sequencer = new Sequencer(
167
157
  publisherFactory,
@@ -172,19 +162,19 @@ export class SequencerClient {
172
162
  slasherClient,
173
163
  l2BlockSource,
174
164
  l1ToL2MessageSource,
175
- blockBuilder,
165
+ checkpointsBuilder,
176
166
  l1Constants,
177
167
  deps.dateProvider,
178
168
  epochCache,
179
169
  rollupContract,
180
- { ...config, maxL1TxInclusionTimeIntoSlot, maxL2BlockGas: sequencerManaLimit },
170
+ { ...config, l1PublishingTime, maxL2BlockGas: sequencerManaLimit },
181
171
  telemetryClient,
182
172
  log,
183
173
  );
184
174
 
185
175
  await sequencer.init();
186
176
 
187
- return new SequencerClient(publisherManager, sequencer, blockBuilder, validatorClient, l1Metrics);
177
+ return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics);
188
178
  }
189
179
 
190
180
  /**
@@ -193,7 +183,7 @@ export class SequencerClient {
193
183
  */
194
184
  public updateConfig(config: SequencerConfig & Partial<ValidatorClientFullConfig>) {
195
185
  this.sequencer.updateConfig(config);
196
- this.blockBuilder.updateConfig(config);
186
+ this.checkpointsBuilder.updateConfig(config);
197
187
  this.validatorClient?.updateConfig(config);
198
188
  }
199
189