@aztec/sequencer-client 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212

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 (73) hide show
  1. package/dest/client/index.d.ts +1 -1
  2. package/dest/client/sequencer-client.d.ts +7 -6
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +23 -14
  5. package/dest/config.d.ts +5 -3
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +21 -1
  8. package/dest/global_variable_builder/global_builder.d.ts +5 -7
  9. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  10. package/dest/global_variable_builder/global_builder.js +12 -8
  11. package/dest/global_variable_builder/index.d.ts +1 -1
  12. package/dest/index.d.ts +1 -1
  13. package/dest/publisher/config.d.ts +9 -10
  14. package/dest/publisher/config.d.ts.map +1 -1
  15. package/dest/publisher/config.js +19 -17
  16. package/dest/publisher/index.d.ts +2 -2
  17. package/dest/publisher/index.d.ts.map +1 -1
  18. package/dest/publisher/index.js +1 -1
  19. package/dest/publisher/sequencer-publisher-factory.d.ts +9 -3
  20. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  21. package/dest/publisher/sequencer-publisher-factory.js +8 -1
  22. package/dest/publisher/sequencer-publisher-metrics.d.ts +2 -2
  23. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  24. package/dest/publisher/sequencer-publisher-metrics.js +1 -1
  25. package/dest/publisher/sequencer-publisher.d.ts +53 -50
  26. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  27. package/dest/publisher/sequencer-publisher.js +187 -132
  28. package/dest/sequencer/block_builder.d.ts +6 -8
  29. package/dest/sequencer/block_builder.d.ts.map +1 -1
  30. package/dest/sequencer/block_builder.js +18 -9
  31. package/dest/sequencer/config.d.ts +2 -2
  32. package/dest/sequencer/config.d.ts.map +1 -1
  33. package/dest/sequencer/errors.d.ts +11 -0
  34. package/dest/sequencer/errors.d.ts.map +1 -0
  35. package/dest/sequencer/errors.js +15 -0
  36. package/dest/sequencer/index.d.ts +1 -1
  37. package/dest/sequencer/metrics.d.ts +17 -20
  38. package/dest/sequencer/metrics.d.ts.map +1 -1
  39. package/dest/sequencer/metrics.js +59 -87
  40. package/dest/sequencer/sequencer.d.ts +54 -32
  41. package/dest/sequencer/sequencer.d.ts.map +1 -1
  42. package/dest/sequencer/sequencer.js +458 -184
  43. package/dest/sequencer/timetable.d.ts +4 -8
  44. package/dest/sequencer/timetable.d.ts.map +1 -1
  45. package/dest/sequencer/timetable.js +3 -10
  46. package/dest/sequencer/utils.d.ts +11 -25
  47. package/dest/sequencer/utils.d.ts.map +1 -1
  48. package/dest/sequencer/utils.js +9 -24
  49. package/dest/test/index.d.ts +2 -2
  50. package/dest/test/index.d.ts.map +1 -1
  51. package/dest/tx_validator/nullifier_cache.d.ts +1 -1
  52. package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
  53. package/dest/tx_validator/tx_validator_factory.d.ts +4 -3
  54. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
  55. package/dest/tx_validator/tx_validator_factory.js +12 -9
  56. package/package.json +32 -31
  57. package/src/client/sequencer-client.ts +24 -18
  58. package/src/config.ts +23 -6
  59. package/src/global_variable_builder/global_builder.ts +19 -17
  60. package/src/publisher/config.ts +29 -27
  61. package/src/publisher/index.ts +1 -1
  62. package/src/publisher/sequencer-publisher-factory.ts +16 -3
  63. package/src/publisher/sequencer-publisher-metrics.ts +1 -1
  64. package/src/publisher/sequencer-publisher.ts +257 -183
  65. package/src/sequencer/block_builder.ts +23 -28
  66. package/src/sequencer/config.ts +1 -1
  67. package/src/sequencer/errors.ts +21 -0
  68. package/src/sequencer/metrics.ts +71 -98
  69. package/src/sequencer/sequencer.ts +546 -237
  70. package/src/sequencer/timetable.ts +10 -14
  71. package/src/sequencer/utils.ts +10 -24
  72. package/src/test/index.ts +1 -1
  73. package/src/tx_validator/tx_validator_factory.ts +13 -7
@@ -1,6 +1,7 @@
1
- import { createLogger } from '@aztec/aztec.js';
1
+ import { createLogger } from '@aztec/aztec.js/log';
2
2
 
3
3
  import { DEFAULT_ATTESTATION_PROPAGATION_TIME } from '../config.js';
4
+ import { SequencerTooSlowError } from './errors.js';
4
5
  import type { SequencerMetrics } from './metrics.js';
5
6
  import { SequencerState } from './utils.js';
6
7
 
@@ -136,9 +137,17 @@ export class SequencerTimetable {
136
137
  return validationTimeEnd;
137
138
  }
138
139
 
140
+ public getMaxAllowedTime(
141
+ state: Extract<SequencerState, SequencerState.STOPPED | SequencerState.IDLE | SequencerState.SYNCHRONIZING>,
142
+ ): undefined;
143
+ public getMaxAllowedTime(
144
+ state: Exclude<SequencerState, SequencerState.STOPPED | SequencerState.IDLE | SequencerState.SYNCHRONIZING>,
145
+ ): number;
146
+ public getMaxAllowedTime(state: SequencerState): number | undefined;
139
147
  public getMaxAllowedTime(state: SequencerState): number | undefined {
140
148
  switch (state) {
141
149
  case SequencerState.STOPPED:
150
+ case SequencerState.STOPPING:
142
151
  case SequencerState.IDLE:
143
152
  case SequencerState.SYNCHRONIZING:
144
153
  return; // We don't really care about times for this states
@@ -177,16 +186,3 @@ export class SequencerTimetable {
177
186
  this.log.trace(`Enough time to transition to ${newState}`, { maxAllowedTime, secondsIntoSlot });
178
187
  }
179
188
  }
180
-
181
- export class SequencerTooSlowError extends Error {
182
- constructor(
183
- public readonly proposedState: SequencerState,
184
- public readonly maxAllowedTime: number,
185
- public readonly currentTime: number,
186
- ) {
187
- super(
188
- `Too far into slot for ${proposedState} (time into slot ${currentTime}s greater than ${maxAllowedTime}s allowance)`,
189
- );
190
- this.name = 'SequencerTooSlowError';
191
- }
192
- }
@@ -1,35 +1,21 @@
1
1
  export enum SequencerState {
2
- /**
3
- * Sequencer is stopped and not processing any txs from the pool.
4
- */
2
+ /** Sequencer is stopped and not processing any txs from the pool. */
5
3
  STOPPED = 'STOPPED',
6
- /**
7
- * Sequencer is awaiting the next call to work().
8
- */
4
+ /** Sequencer is being stopped. Will move to STOPPED shortly. */
5
+ STOPPING = 'STOPPING',
6
+ /** Sequencer is awaiting the next call to work(). */
9
7
  IDLE = 'IDLE',
10
- /**
11
- * Synchronizing with the L2 chain.
12
- */
8
+ /** Synchronizing with the L2 chain. */
13
9
  SYNCHRONIZING = 'SYNCHRONIZING',
14
- /**
15
- * Checking if we are the proposer for the current slot.
16
- */
10
+ /** Checking if we are the proposer for the current slot. */
17
11
  PROPOSER_CHECK = 'PROPOSER_CHECK',
18
- /**
19
- * Initializing the block proposal. Will move to CREATING_BLOCK if there are valid txs to include, or back to SYNCHRONIZING otherwise.
20
- */
12
+ /** Initializing the block proposal. Will move to CREATING_BLOCK if there are valid txs to include, or back to SYNCHRONIZING otherwise. */
21
13
  INITIALIZING_PROPOSAL = 'INITIALIZING_PROPOSAL',
22
- /**
23
- * Creating a new L2 block. Includes processing public function calls and running rollup circuits. Will move to PUBLISHING_CONTRACT_DATA.
24
- */
14
+ /** Creating a new L2 block. Includes processing public function calls and running rollup circuits. Will move to PUBLISHING_CONTRACT_DATA. */
25
15
  CREATING_BLOCK = 'CREATING_BLOCK',
26
- /**
27
- * Collecting attestations from its peers. Will move to PUBLISHING_BLOCK.
28
- */
16
+ /** Collecting attestations from its peers. Will move to PUBLISHING_BLOCK. */
29
17
  COLLECTING_ATTESTATIONS = 'COLLECTING_ATTESTATIONS',
30
- /**
31
- * Sending the tx to L1 with the L2 block data and awaiting it to be mined. Will move to SYNCHRONIZING.
32
- */
18
+ /** Sending the tx to L1 with the L2 block data and awaiting it to be mined. Will move to SYNCHRONIZING. */
33
19
  PUBLISHING_BLOCK = 'PUBLISHING_BLOCK',
34
20
  }
35
21
 
package/src/test/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { PublisherManager } from '@aztec/ethereum';
2
1
  import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
2
+ import type { PublisherManager } from '@aztec/ethereum/publisher-manager';
3
3
  import type { PublicProcessorFactory } from '@aztec/simulator/server';
4
4
  import type { ValidatorClient } from '@aztec/validator-client';
5
5
 
@@ -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),