@aztec/sequencer-client 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dest/client/index.d.ts +1 -1
  2. package/dest/client/sequencer-client.d.ts +10 -8
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +40 -28
  5. package/dest/config.d.ts +13 -5
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +82 -25
  8. package/dest/global_variable_builder/global_builder.d.ts +19 -13
  9. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  10. package/dest/global_variable_builder/global_builder.js +41 -28
  11. package/dest/global_variable_builder/index.d.ts +1 -1
  12. package/dest/index.d.ts +2 -2
  13. package/dest/index.d.ts.map +1 -1
  14. package/dest/index.js +1 -1
  15. package/dest/publisher/config.d.ts +11 -8
  16. package/dest/publisher/config.d.ts.map +1 -1
  17. package/dest/publisher/config.js +21 -13
  18. package/dest/publisher/index.d.ts +2 -2
  19. package/dest/publisher/index.d.ts.map +1 -1
  20. package/dest/publisher/index.js +1 -1
  21. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
  22. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  23. package/dest/publisher/sequencer-publisher-factory.js +9 -2
  24. package/dest/publisher/sequencer-publisher-metrics.d.ts +4 -4
  25. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  26. package/dest/publisher/sequencer-publisher-metrics.js +1 -1
  27. package/dest/publisher/sequencer-publisher.d.ts +76 -69
  28. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  29. package/dest/publisher/sequencer-publisher.js +290 -180
  30. package/dest/sequencer/block_builder.d.ts +6 -10
  31. package/dest/sequencer/block_builder.d.ts.map +1 -1
  32. package/dest/sequencer/block_builder.js +21 -10
  33. package/dest/sequencer/checkpoint_builder.d.ts +63 -0
  34. package/dest/sequencer/checkpoint_builder.d.ts.map +1 -0
  35. package/dest/sequencer/checkpoint_builder.js +131 -0
  36. package/dest/sequencer/checkpoint_proposal_job.d.ts +74 -0
  37. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
  38. package/dest/sequencer/checkpoint_proposal_job.js +642 -0
  39. package/dest/sequencer/checkpoint_voter.d.ts +34 -0
  40. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
  41. package/dest/sequencer/checkpoint_voter.js +85 -0
  42. package/dest/sequencer/config.d.ts +3 -2
  43. package/dest/sequencer/config.d.ts.map +1 -1
  44. package/dest/sequencer/errors.d.ts +11 -0
  45. package/dest/sequencer/errors.d.ts.map +1 -0
  46. package/dest/sequencer/errors.js +15 -0
  47. package/dest/sequencer/events.d.ts +46 -0
  48. package/dest/sequencer/events.d.ts.map +1 -0
  49. package/dest/sequencer/events.js +1 -0
  50. package/dest/sequencer/index.d.ts +5 -1
  51. package/dest/sequencer/index.d.ts.map +1 -1
  52. package/dest/sequencer/index.js +4 -0
  53. package/dest/sequencer/metrics.d.ts +37 -20
  54. package/dest/sequencer/metrics.d.ts.map +1 -1
  55. package/dest/sequencer/metrics.js +211 -85
  56. package/dest/sequencer/sequencer.d.ts +109 -121
  57. package/dest/sequencer/sequencer.d.ts.map +1 -1
  58. package/dest/sequencer/sequencer.js +798 -525
  59. package/dest/sequencer/timetable.d.ts +57 -21
  60. package/dest/sequencer/timetable.d.ts.map +1 -1
  61. package/dest/sequencer/timetable.js +150 -68
  62. package/dest/sequencer/types.d.ts +3 -0
  63. package/dest/sequencer/types.d.ts.map +1 -0
  64. package/dest/sequencer/types.js +1 -0
  65. package/dest/sequencer/utils.d.ts +20 -28
  66. package/dest/sequencer/utils.d.ts.map +1 -1
  67. package/dest/sequencer/utils.js +12 -24
  68. package/dest/test/index.d.ts +4 -2
  69. package/dest/test/index.d.ts.map +1 -1
  70. package/dest/test/mock_checkpoint_builder.d.ts +83 -0
  71. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
  72. package/dest/test/mock_checkpoint_builder.js +179 -0
  73. package/dest/test/utils.d.ts +49 -0
  74. package/dest/test/utils.d.ts.map +1 -0
  75. package/dest/test/utils.js +94 -0
  76. package/dest/tx_validator/nullifier_cache.d.ts +1 -1
  77. package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
  78. package/dest/tx_validator/tx_validator_factory.d.ts +4 -3
  79. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
  80. package/dest/tx_validator/tx_validator_factory.js +12 -9
  81. package/package.json +32 -31
  82. package/src/client/sequencer-client.ts +34 -40
  83. package/src/config.ts +89 -29
  84. package/src/global_variable_builder/global_builder.ts +56 -48
  85. package/src/index.ts +2 -0
  86. package/src/publisher/config.ts +32 -19
  87. package/src/publisher/index.ts +1 -1
  88. package/src/publisher/sequencer-publisher-factory.ts +19 -6
  89. package/src/publisher/sequencer-publisher-metrics.ts +3 -3
  90. package/src/publisher/sequencer-publisher.ts +410 -240
  91. package/src/sequencer/README.md +531 -0
  92. package/src/sequencer/block_builder.ts +28 -30
  93. package/src/sequencer/checkpoint_builder.ts +217 -0
  94. package/src/sequencer/checkpoint_proposal_job.ts +706 -0
  95. package/src/sequencer/checkpoint_voter.ts +105 -0
  96. package/src/sequencer/config.ts +2 -1
  97. package/src/sequencer/errors.ts +21 -0
  98. package/src/sequencer/events.ts +27 -0
  99. package/src/sequencer/index.ts +4 -0
  100. package/src/sequencer/metrics.ts +269 -94
  101. package/src/sequencer/sequencer.ts +506 -676
  102. package/src/sequencer/timetable.ts +181 -91
  103. package/src/sequencer/types.ts +6 -0
  104. package/src/sequencer/utils.ts +24 -29
  105. package/src/test/index.ts +3 -1
  106. package/src/test/mock_checkpoint_builder.ts +247 -0
  107. package/src/test/utils.ts +137 -0
  108. package/src/tx_validator/tx_validator_factory.ts +13 -7
@@ -0,0 +1,247 @@
1
+ import { type BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { Timer } from '@aztec/foundation/timer';
4
+ import type { FunctionsOf } from '@aztec/foundation/types';
5
+ import { L2BlockNew } from '@aztec/stdlib/block';
6
+ import { Checkpoint } from '@aztec/stdlib/checkpoint';
7
+ import { Gas } from '@aztec/stdlib/gas';
8
+ import type { FullNodeBlockBuilderConfig, PublicProcessorLimits } from '@aztec/stdlib/interfaces/server';
9
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
10
+ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
11
+ import type { CheckpointGlobalVariables, Tx } from '@aztec/stdlib/tx';
12
+
13
+ import type {
14
+ BuildBlockInCheckpointResult,
15
+ CheckpointBuilder,
16
+ FullNodeCheckpointsBuilder,
17
+ } from '../sequencer/checkpoint_builder.js';
18
+
19
+ /**
20
+ * A fake CheckpointBuilder for testing that implements the same interface as the real one.
21
+ * Can be seeded with blocks to return sequentially on each `buildBlock` call.
22
+ */
23
+ export class MockCheckpointBuilder implements FunctionsOf<CheckpointBuilder> {
24
+ private blocks: L2BlockNew[] = [];
25
+ private builtBlocks: L2BlockNew[] = [];
26
+ private usedTxsPerBlock: Tx[][] = [];
27
+ private blockIndex = 0;
28
+
29
+ /** Optional function to dynamically provide the block (alternative to seedBlocks) */
30
+ private blockProvider: (() => L2BlockNew) | undefined = undefined;
31
+
32
+ /** Track calls for assertions */
33
+ public buildBlockCalls: Array<{
34
+ blockNumber: BlockNumber;
35
+ timestamp: bigint;
36
+ opts: PublicProcessorLimits;
37
+ }> = [];
38
+ public completeCheckpointCalled = false;
39
+ public getCheckpointCalled = false;
40
+
41
+ /** Set to an error to make buildBlock throw on next call */
42
+ public errorOnBuild: Error | undefined = undefined;
43
+
44
+ constructor(
45
+ private readonly constants: CheckpointGlobalVariables,
46
+ private readonly checkpointNumber: CheckpointNumber,
47
+ ) {}
48
+
49
+ /** Seed the builder with blocks to return on successive buildBlock calls */
50
+ seedBlocks(blocks: L2BlockNew[], usedTxsPerBlock?: Tx[][]): this {
51
+ this.blocks = blocks;
52
+ this.usedTxsPerBlock = usedTxsPerBlock ?? blocks.map(() => []);
53
+ this.blockIndex = 0;
54
+ this.blockProvider = undefined;
55
+ return this;
56
+ }
57
+
58
+ /**
59
+ * Set a function that provides blocks dynamically.
60
+ * Useful for tests where the block is determined at call time (e.g., sequencer tests).
61
+ */
62
+ setBlockProvider(provider: () => L2BlockNew): this {
63
+ this.blockProvider = provider;
64
+ this.blocks = [];
65
+ return this;
66
+ }
67
+
68
+ getConstantData(): CheckpointGlobalVariables {
69
+ return this.constants;
70
+ }
71
+
72
+ buildBlock(
73
+ _pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
74
+ blockNumber: BlockNumber,
75
+ timestamp: bigint,
76
+ opts: PublicProcessorLimits,
77
+ ): Promise<BuildBlockInCheckpointResult> {
78
+ this.buildBlockCalls.push({ blockNumber, timestamp, opts });
79
+
80
+ if (this.errorOnBuild) {
81
+ return Promise.reject(this.errorOnBuild);
82
+ }
83
+
84
+ let block: L2BlockNew;
85
+ let usedTxs: Tx[];
86
+
87
+ if (this.blockProvider) {
88
+ // Dynamic mode: get block from provider
89
+ block = this.blockProvider();
90
+ usedTxs = [];
91
+ this.builtBlocks.push(block);
92
+ } else {
93
+ // Seeded mode: get block from pre-seeded list
94
+ block = this.blocks[this.blockIndex];
95
+ usedTxs = this.usedTxsPerBlock[this.blockIndex] ?? [];
96
+ this.blockIndex++;
97
+ this.builtBlocks.push(block);
98
+ }
99
+
100
+ return Promise.resolve({
101
+ block,
102
+ publicGas: Gas.empty(),
103
+ publicProcessorDuration: 0,
104
+ numTxs: block?.body?.txEffects?.length ?? usedTxs.length,
105
+ blockBuildingTimer: new Timer(),
106
+ usedTxs,
107
+ failedTxs: [],
108
+ });
109
+ }
110
+
111
+ completeCheckpoint(): Promise<Checkpoint> {
112
+ this.completeCheckpointCalled = true;
113
+ const allBlocks = this.blockProvider ? this.builtBlocks : this.blocks;
114
+ const lastBlock = allBlocks[allBlocks.length - 1];
115
+ // Create a CheckpointHeader from the last block's header for testing
116
+ const checkpointHeader = this.createCheckpointHeader(lastBlock);
117
+ return Promise.resolve(
118
+ new Checkpoint(
119
+ makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
120
+ checkpointHeader,
121
+ allBlocks,
122
+ this.checkpointNumber,
123
+ ),
124
+ );
125
+ }
126
+
127
+ getCheckpoint(): Promise<Checkpoint> {
128
+ this.getCheckpointCalled = true;
129
+ const builtBlocks = this.blockProvider ? this.builtBlocks : this.blocks.slice(0, this.blockIndex);
130
+ const lastBlock = builtBlocks[builtBlocks.length - 1];
131
+ if (!lastBlock) {
132
+ throw new Error('No blocks built yet');
133
+ }
134
+ // Create a CheckpointHeader from the last block's header for testing
135
+ const checkpointHeader = this.createCheckpointHeader(lastBlock);
136
+ return Promise.resolve(
137
+ new Checkpoint(
138
+ makeAppendOnlyTreeSnapshot(lastBlock.header.globalVariables.blockNumber + 1),
139
+ checkpointHeader,
140
+ builtBlocks,
141
+ this.checkpointNumber,
142
+ ),
143
+ );
144
+ }
145
+
146
+ /**
147
+ * Creates a CheckpointHeader from a block's header for testing.
148
+ * This is a simplified version that creates a minimal CheckpointHeader.
149
+ */
150
+ private createCheckpointHeader(block: L2BlockNew): CheckpointHeader {
151
+ const header = block.header;
152
+ const gv = header.globalVariables;
153
+ return CheckpointHeader.empty({
154
+ lastArchiveRoot: header.lastArchive.root,
155
+ blockHeadersHash: Fr.random(), // Use random for testing
156
+ slotNumber: gv.slotNumber,
157
+ timestamp: gv.timestamp,
158
+ coinbase: gv.coinbase,
159
+ feeRecipient: gv.feeRecipient,
160
+ gasFees: gv.gasFees,
161
+ totalManaUsed: header.totalManaUsed,
162
+ });
163
+ }
164
+
165
+ /** Reset for reuse in another test */
166
+ reset(): void {
167
+ this.blocks = [];
168
+ this.builtBlocks = [];
169
+ this.usedTxsPerBlock = [];
170
+ this.blockIndex = 0;
171
+ this.buildBlockCalls = [];
172
+ this.completeCheckpointCalled = false;
173
+ this.getCheckpointCalled = false;
174
+ this.errorOnBuild = undefined;
175
+ this.blockProvider = undefined;
176
+ }
177
+ }
178
+
179
+ /**
180
+ * A fake CheckpointsBuilder (factory) for testing that implements the same interface
181
+ * as FullNodeCheckpointsBuilder. Returns MockCheckpointBuilder instances.
182
+ * Does NOT use jest mocks - this is a proper test double.
183
+ */
184
+ export class MockCheckpointsBuilder implements FunctionsOf<FullNodeCheckpointsBuilder> {
185
+ private checkpointBuilder: MockCheckpointBuilder | undefined;
186
+
187
+ /** Track calls for assertions */
188
+ public startCheckpointCalls: Array<{
189
+ checkpointNumber: CheckpointNumber;
190
+ constants: CheckpointGlobalVariables;
191
+ l1ToL2Messages: Fr[];
192
+ }> = [];
193
+ public updateConfigCalls: Array<Partial<FullNodeBlockBuilderConfig>> = [];
194
+
195
+ /**
196
+ * Set the MockCheckpointBuilder to return from startCheckpoint.
197
+ * Must be called before startCheckpoint is invoked.
198
+ */
199
+ setCheckpointBuilder(builder: MockCheckpointBuilder): this {
200
+ this.checkpointBuilder = builder;
201
+ return this;
202
+ }
203
+
204
+ /**
205
+ * Creates a new MockCheckpointBuilder with the given constants.
206
+ * Convenience method that creates and sets the builder in one call.
207
+ */
208
+ createCheckpointBuilder(
209
+ constants: CheckpointGlobalVariables,
210
+ checkpointNumber: CheckpointNumber,
211
+ ): MockCheckpointBuilder {
212
+ this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
213
+ return this.checkpointBuilder;
214
+ }
215
+
216
+ /** Get the current checkpoint builder (for assertions) */
217
+ getCheckpointBuilder(): MockCheckpointBuilder | undefined {
218
+ return this.checkpointBuilder;
219
+ }
220
+
221
+ updateConfig(config: Partial<FullNodeBlockBuilderConfig>): void {
222
+ this.updateConfigCalls.push(config);
223
+ }
224
+
225
+ startCheckpoint(
226
+ checkpointNumber: CheckpointNumber,
227
+ constants: CheckpointGlobalVariables,
228
+ l1ToL2Messages: Fr[],
229
+ _fork: unknown,
230
+ ): Promise<CheckpointBuilder> {
231
+ this.startCheckpointCalls.push({ checkpointNumber, constants, l1ToL2Messages });
232
+
233
+ if (!this.checkpointBuilder) {
234
+ // Auto-create a builder if none was set
235
+ this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
236
+ }
237
+
238
+ return Promise.resolve(this.checkpointBuilder as unknown as CheckpointBuilder);
239
+ }
240
+
241
+ /** Reset for reuse in another test */
242
+ reset(): void {
243
+ this.checkpointBuilder = undefined;
244
+ this.startCheckpointCalls = [];
245
+ this.updateConfigCalls = [];
246
+ }
247
+ }
@@ -0,0 +1,137 @@
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 { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
5
+ import { Fr } from '@aztec/foundation/curves/bn254';
6
+ import type { EthAddress } from '@aztec/foundation/eth-address';
7
+ import { Signature } from '@aztec/foundation/eth-signature';
8
+ import type { P2P } from '@aztec/p2p';
9
+ import { PublicDataWrite } from '@aztec/stdlib/avm';
10
+ import { CommitteeAttestation, L2BlockNew } from '@aztec/stdlib/block';
11
+ import { BlockAttestation, BlockProposal, ConsensusPayload } from '@aztec/stdlib/p2p';
12
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
13
+ import { makeAppendOnlyTreeSnapshot, mockTxForRollup } from '@aztec/stdlib/testing';
14
+ import {
15
+ BlockHeader,
16
+ ContentCommitment,
17
+ GlobalVariables,
18
+ type Tx,
19
+ makeProcessedTxFromPrivateOnlyTx,
20
+ } from '@aztec/stdlib/tx';
21
+
22
+ import type { MockProxy } from 'jest-mock-extended';
23
+
24
+ // Re-export mock classes from their dedicated file
25
+ export { MockCheckpointBuilder, MockCheckpointsBuilder } from './mock_checkpoint_builder.js';
26
+
27
+ /**
28
+ * Creates a mock transaction with a specific seed for deterministic testing
29
+ */
30
+ export async function makeTx(seed?: number, chainId?: Fr): Promise<Tx> {
31
+ const tx = await mockTxForRollup(seed);
32
+ if (chainId) {
33
+ tx.data.constants.txContext.chainId = chainId;
34
+ }
35
+ return tx;
36
+ }
37
+
38
+ /**
39
+ * Creates an L2BlockNew from transactions and global variables
40
+ */
41
+ export async function makeBlock(txs: Tx[], globalVariables: GlobalVariables): Promise<L2BlockNew> {
42
+ const processedTxs = await Promise.all(
43
+ txs.map(tx =>
44
+ makeProcessedTxFromPrivateOnlyTx(tx, Fr.ZERO, new PublicDataWrite(Fr.random(), Fr.random()), globalVariables),
45
+ ),
46
+ );
47
+ const body = new Body(processedTxs.map(tx => tx.txEffect));
48
+ const header = BlockHeader.empty({ globalVariables });
49
+ const archive = makeAppendOnlyTreeSnapshot(globalVariables.blockNumber + 1);
50
+ return new L2BlockNew(archive, header, body, CheckpointNumber(globalVariables.blockNumber), 0);
51
+ }
52
+
53
+ /**
54
+ * Mocks the P2P client to return specific pending transactions
55
+ */
56
+ export function mockPendingTxs(p2p: MockProxy<P2P>, txs: Tx[]): void {
57
+ p2p.getPendingTxCount.mockResolvedValue(txs.length);
58
+ p2p.iteratePendingTxs.mockImplementation(() => mockTxIterator(Promise.resolve(txs)));
59
+ }
60
+
61
+ /**
62
+ * Creates an async iterator for transactions
63
+ */
64
+ export async function* mockTxIterator(txs: Promise<Tx[]>): AsyncIterableIterator<Tx> {
65
+ for (const tx of await txs) {
66
+ yield tx;
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Creates mock committee attestations from a signer
72
+ */
73
+ export function createMockSignatures(signer: Secp256k1Signer): CommitteeAttestation[] {
74
+ const mockedSig = Signature.random();
75
+ return [new CommitteeAttestation(signer.address, mockedSig)];
76
+ }
77
+
78
+ /**
79
+ * Creates a CheckpointHeader from an L2BlockNew for testing purposes.
80
+ * Uses mock values for contentCommitment and blockHeadersHash since
81
+ * L2BlockNew doesn't have these fields.
82
+ */
83
+ function createCheckpointHeaderFromBlock(block: L2BlockNew): CheckpointHeader {
84
+ const gv = block.header.globalVariables;
85
+ return new CheckpointHeader(
86
+ block.header.lastArchive.root,
87
+ Fr.random(), // blockHeadersHash - mock value for testing
88
+ ContentCommitment.empty(), // contentCommitment - mock value for testing
89
+ gv.slotNumber,
90
+ gv.timestamp,
91
+ gv.coinbase,
92
+ gv.feeRecipient,
93
+ gv.gasFees,
94
+ block.header.totalManaUsed,
95
+ );
96
+ }
97
+
98
+ /**
99
+ * Creates a block proposal from a block and signature
100
+ */
101
+ export function createBlockProposal(block: L2BlockNew, signature: Signature): BlockProposal {
102
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
103
+ const consensusPayload = new ConsensusPayload(checkpointHeader, block.archive.root);
104
+ const txHashes = block.body.txEffects.map(tx => tx.txHash);
105
+ return new BlockProposal(consensusPayload, signature, txHashes);
106
+ }
107
+
108
+ /**
109
+ * Creates a block attestation from a block and signature.
110
+ * Note: We manually set the sender since we use random signatures in tests.
111
+ * In production, the sender is recovered from the signature.
112
+ */
113
+ export function createBlockAttestation(block: L2BlockNew, signature: Signature, sender: EthAddress): BlockAttestation {
114
+ const checkpointHeader = createCheckpointHeaderFromBlock(block);
115
+ const consensusPayload = new ConsensusPayload(checkpointHeader, block.archive.root);
116
+ const attestation = new BlockAttestation(consensusPayload, signature, signature);
117
+ // Set sender directly for testing (bypasses signature recovery)
118
+
119
+ (attestation as any).sender = sender;
120
+ return attestation;
121
+ }
122
+
123
+ /**
124
+ * Creates transactions and a block, and mocks P2P to return them.
125
+ * Helper for tests that need to set up a block with transactions.
126
+ */
127
+ export async function setupTxsAndBlock(
128
+ p2p: MockProxy<P2P>,
129
+ globalVariables: GlobalVariables,
130
+ txCount: number,
131
+ chainId: Fr,
132
+ ): Promise<{ txs: Tx[]; block: L2BlockNew }> {
133
+ const txs = await Promise.all(times(txCount, i => makeTx(i + 1, chainId)));
134
+ const block = await makeBlock(txs, globalVariables);
135
+ mockPendingTxs(p2p, txs);
136
+ return { txs, block };
137
+ }
@@ -1,4 +1,5 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
3
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
3
4
  import {
4
5
  AggregateTxValidator,
@@ -9,10 +10,11 @@ import {
9
10
  GasTxValidator,
10
11
  MetadataTxValidator,
11
12
  PhasesTxValidator,
13
+ TimestampTxValidator,
12
14
  TxPermittedValidator,
13
15
  TxProofValidator,
14
16
  } from '@aztec/p2p';
15
- import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
17
+ import { ProtocolContractAddress, protocolContractsHash } from '@aztec/protocol-contracts';
16
18
  import type { ContractDataSource } from '@aztec/stdlib/contract';
17
19
  import type { GasFees } from '@aztec/stdlib/gas';
18
20
  import type {
@@ -47,7 +49,7 @@ export function createValidatorForAcceptingTxs(
47
49
  gasFees: GasFees;
48
50
  skipFeeEnforcement?: boolean;
49
51
  timestamp: UInt64;
50
- blockNumber: number;
52
+ blockNumber: BlockNumber;
51
53
  txsPermitted: boolean;
52
54
  },
53
55
  ): TxValidator<Tx> {
@@ -57,10 +59,12 @@ export function createValidatorForAcceptingTxs(
57
59
  new MetadataTxValidator({
58
60
  l1ChainId: new Fr(l1ChainId),
59
61
  rollupVersion: new Fr(rollupVersion),
62
+ protocolContractsHash,
63
+ vkTreeRoot: getVKTreeRoot(),
64
+ }),
65
+ new TimestampTxValidator({
60
66
  timestamp,
61
67
  blockNumber,
62
- protocolContractTreeRoot,
63
- vkTreeRoot: getVKTreeRoot(),
64
68
  }),
65
69
  new DoubleSpendTxValidator(new NullifierCache(db)),
66
70
  new PhasesTxValidator(contractDataSource, setupAllowList, timestamp),
@@ -114,10 +118,12 @@ function preprocessValidator(
114
118
  new MetadataTxValidator({
115
119
  l1ChainId: globalVariables.chainId,
116
120
  rollupVersion: globalVariables.version,
121
+ protocolContractsHash,
122
+ vkTreeRoot: getVKTreeRoot(),
123
+ }),
124
+ new TimestampTxValidator({
117
125
  timestamp: globalVariables.timestamp,
118
126
  blockNumber: globalVariables.blockNumber,
119
- protocolContractTreeRoot,
120
- vkTreeRoot: getVKTreeRoot(),
121
127
  }),
122
128
  new DoubleSpendTxValidator(nullifierCache),
123
129
  new PhasesTxValidator(contractDataSource, setupAllowList, globalVariables.timestamp),