@aztec/sequencer-client 0.0.1-commit.c7c42ec → 0.0.1-commit.c949de6bc

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 (103) hide show
  1. package/dest/client/sequencer-client.d.ts +14 -10
  2. package/dest/client/sequencer-client.d.ts.map +1 -1
  3. package/dest/client/sequencer-client.js +15 -4
  4. package/dest/config.d.ts +3 -4
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +22 -12
  7. package/dest/global_variable_builder/global_builder.d.ts +5 -7
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/global_variable_builder/global_builder.js +13 -13
  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 +35 -17
  14. package/dest/publisher/config.d.ts.map +1 -1
  15. package/dest/publisher/config.js +106 -42
  16. package/dest/publisher/index.d.ts +2 -1
  17. package/dest/publisher/index.d.ts.map +1 -1
  18. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  19. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  20. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  21. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
  22. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  23. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  24. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  25. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  26. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  27. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  28. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  29. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  30. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
  31. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  32. package/dest/publisher/sequencer-publisher-factory.js +13 -2
  33. package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
  34. package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
  35. package/dest/publisher/sequencer-publisher-metrics.js +23 -86
  36. package/dest/publisher/sequencer-publisher.d.ts +38 -23
  37. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  38. package/dest/publisher/sequencer-publisher.js +739 -96
  39. package/dest/sequencer/checkpoint_proposal_job.d.ts +40 -12
  40. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  41. package/dest/sequencer/checkpoint_proposal_job.js +641 -64
  42. package/dest/sequencer/checkpoint_voter.d.ts +3 -2
  43. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  44. package/dest/sequencer/checkpoint_voter.js +34 -10
  45. package/dest/sequencer/index.d.ts +1 -3
  46. package/dest/sequencer/index.d.ts.map +1 -1
  47. package/dest/sequencer/index.js +0 -2
  48. package/dest/sequencer/metrics.d.ts +19 -7
  49. package/dest/sequencer/metrics.d.ts.map +1 -1
  50. package/dest/sequencer/metrics.js +131 -141
  51. package/dest/sequencer/sequencer.d.ts +38 -18
  52. package/dest/sequencer/sequencer.d.ts.map +1 -1
  53. package/dest/sequencer/sequencer.js +513 -66
  54. package/dest/sequencer/timetable.d.ts +1 -4
  55. package/dest/sequencer/timetable.d.ts.map +1 -1
  56. package/dest/sequencer/timetable.js +2 -5
  57. package/dest/test/index.d.ts +4 -7
  58. package/dest/test/index.d.ts.map +1 -1
  59. package/dest/test/mock_checkpoint_builder.d.ts +25 -11
  60. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  61. package/dest/test/mock_checkpoint_builder.js +52 -9
  62. package/dest/test/utils.d.ts +13 -9
  63. package/dest/test/utils.d.ts.map +1 -1
  64. package/dest/test/utils.js +27 -17
  65. package/package.json +30 -28
  66. package/src/client/sequencer-client.ts +28 -11
  67. package/src/config.ts +31 -19
  68. package/src/global_variable_builder/global_builder.ts +14 -14
  69. package/src/index.ts +1 -9
  70. package/src/publisher/config.ts +121 -43
  71. package/src/publisher/index.ts +3 -0
  72. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  73. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
  74. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  75. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  76. package/src/publisher/sequencer-publisher-factory.ts +23 -6
  77. package/src/publisher/sequencer-publisher-metrics.ts +17 -69
  78. package/src/publisher/sequencer-publisher.ts +358 -126
  79. package/src/sequencer/checkpoint_proposal_job.ts +313 -93
  80. package/src/sequencer/checkpoint_voter.ts +32 -7
  81. package/src/sequencer/index.ts +0 -2
  82. package/src/sequencer/metrics.ts +132 -148
  83. package/src/sequencer/sequencer.ts +159 -68
  84. package/src/sequencer/timetable.ts +7 -6
  85. package/src/test/index.ts +3 -6
  86. package/src/test/mock_checkpoint_builder.ts +102 -29
  87. package/src/test/utils.ts +58 -28
  88. package/dest/sequencer/block_builder.d.ts +0 -26
  89. package/dest/sequencer/block_builder.d.ts.map +0 -1
  90. package/dest/sequencer/block_builder.js +0 -129
  91. package/dest/sequencer/checkpoint_builder.d.ts +0 -63
  92. package/dest/sequencer/checkpoint_builder.d.ts.map +0 -1
  93. package/dest/sequencer/checkpoint_builder.js +0 -131
  94. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  95. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  96. package/dest/tx_validator/nullifier_cache.js +0 -24
  97. package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
  98. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  99. package/dest/tx_validator/tx_validator_factory.js +0 -53
  100. package/src/sequencer/block_builder.ts +0 -217
  101. package/src/sequencer/checkpoint_builder.ts +0 -217
  102. package/src/tx_validator/nullifier_cache.ts +0 -30
  103. package/src/tx_validator/tx_validator_factory.ts +0 -133
@@ -3,7 +3,7 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
3
3
  import type { BlobClientInterface } from '@aztec/blob-client/client';
4
4
  import type { EpochCache } from '@aztec/epoch-cache';
5
5
  import type { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
6
- import type { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
6
+ import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
7
7
  import type { PublisherFilter, PublisherManager } from '@aztec/ethereum/publisher-manager';
8
8
  import { SlotNumber } from '@aztec/foundation/branded-types';
9
9
  import type { DateProvider } from '@aztec/foundation/timer';
@@ -26,13 +26,15 @@ export class SequencerPublisherFactory {
26
26
  /** Stores the last slot in which every action was carried out by a publisher */
27
27
  private lastActions: Partial<Record<Action, SlotNumber>> = {};
28
28
 
29
+ private nodeKeyStore: NodeKeystoreAdapter;
30
+
29
31
  private logger: Logger;
30
32
 
31
33
  constructor(
32
34
  private sequencerConfig: SequencerClientConfig,
33
35
  private deps: {
34
36
  telemetry: TelemetryClient;
35
- publisherManager: PublisherManager<L1TxUtilsWithBlobs>;
37
+ publisherManager: PublisherManager<L1TxUtils>;
36
38
  blobClient: BlobClientInterface;
37
39
  dateProvider: DateProvider;
38
40
  epochCache: EpochCache;
@@ -45,7 +47,17 @@ export class SequencerPublisherFactory {
45
47
  ) {
46
48
  this.publisherMetrics = new SequencerPublisherMetrics(deps.telemetry, 'SequencerPublisher');
47
49
  this.logger = deps.logger ?? createLogger('sequencer');
50
+ this.nodeKeyStore = this.deps.nodeKeyStore;
51
+ }
52
+
53
+ /**
54
+ * Updates the node keystore adapter used for publisher lookups.
55
+ * Called when the keystore is reloaded at runtime to reflect new validator-publisher mappings.
56
+ */
57
+ public updateNodeKeyStore(adapter: NodeKeystoreAdapter): void {
58
+ this.nodeKeyStore = adapter;
48
59
  }
60
+
49
61
  /**
50
62
  * Creates a new SequencerPublisher instance.
51
63
  * @param _validatorAddress - The address of the validator that will be using the publisher.
@@ -54,17 +66,17 @@ export class SequencerPublisherFactory {
54
66
  public async create(validatorAddress?: EthAddress): Promise<AttestorPublisherPair> {
55
67
  // If we have been given an attestor address we must only allow publishers permitted for that attestor
56
68
 
57
- const allowedPublishers = !validatorAddress ? [] : this.deps.nodeKeyStore.getPublisherAddresses(validatorAddress);
58
- const filter: PublisherFilter<L1TxUtilsWithBlobs> = !validatorAddress
69
+ const allowedPublishers = !validatorAddress ? [] : this.nodeKeyStore.getPublisherAddresses(validatorAddress);
70
+ const filter: PublisherFilter<L1TxUtils> = !validatorAddress
59
71
  ? () => true
60
- : (utils: L1TxUtilsWithBlobs) => {
72
+ : (utils: L1TxUtils) => {
61
73
  const publisherAddress = utils.getSenderAddress();
62
74
  return allowedPublishers.some(allowedPublisher => allowedPublisher.equals(publisherAddress));
63
75
  };
64
76
 
65
77
  const l1Publisher = await this.deps.publisherManager.getAvailablePublisher(filter);
66
78
  const attestorAddress =
67
- validatorAddress ?? this.deps.nodeKeyStore.getAttestorForPublisher(l1Publisher.getSenderAddress());
79
+ validatorAddress ?? this.nodeKeyStore.getAttestorForPublisher(l1Publisher.getSenderAddress());
68
80
 
69
81
  const rollup = this.deps.rollupContract;
70
82
  const slashingProposerContract = await rollup.getSlashingProposer();
@@ -89,4 +101,9 @@ export class SequencerPublisherFactory {
89
101
  publisher,
90
102
  };
91
103
  }
104
+
105
+ /** Interrupts all publishers managed by this factory. Used during sequencer shutdown. */
106
+ public interruptAll(): void {
107
+ this.deps.publisherManager.interrupt();
108
+ }
92
109
  }
@@ -7,7 +7,7 @@ import {
7
7
  Metrics,
8
8
  type TelemetryClient,
9
9
  type UpDownCounter,
10
- ValueType,
10
+ createUpDownCounterWithDefault,
11
11
  } from '@aztec/telemetry-client';
12
12
 
13
13
  import { formatEther } from 'viem/utils';
@@ -40,88 +40,36 @@ export class SequencerPublisherMetrics {
40
40
  ) {
41
41
  const meter = client.getMeter(name);
42
42
 
43
- this.gasPrice = meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE, {
44
- description: 'The gas price used for transactions',
45
- unit: 'gwei',
46
- valueType: ValueType.DOUBLE,
47
- });
43
+ this.gasPrice = meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
48
44
 
49
- this.txCount = meter.createUpDownCounter(Metrics.L1_PUBLISHER_TX_COUNT, {
50
- description: 'The number of transactions processed',
45
+ this.txCount = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_TX_COUNT, {
46
+ [Attributes.L1_TX_TYPE]: ['process'],
47
+ [Attributes.OK]: [true, false],
51
48
  });
52
49
 
53
- this.txDuration = meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION, {
54
- description: 'The duration of transaction processing',
55
- unit: 'ms',
56
- valueType: ValueType.INT,
57
- });
50
+ this.txDuration = meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
58
51
 
59
- this.txGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS, {
60
- description: 'The gas consumed by transactions',
61
- unit: 'gas',
62
- valueType: ValueType.INT,
63
- });
52
+ this.txGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS);
64
53
 
65
- this.txCalldataSize = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE, {
66
- description: 'The size of the calldata in transactions',
67
- unit: 'By',
68
- valueType: ValueType.INT,
69
- });
54
+ this.txCalldataSize = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE);
70
55
 
71
- this.txCalldataGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS, {
72
- description: 'The gas consumed by the calldata in transactions',
73
- unit: 'gas',
74
- valueType: ValueType.INT,
75
- });
56
+ this.txCalldataGas = meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS);
76
57
 
77
- this.txBlobDataGasUsed = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED, {
78
- description: 'The amount of blob gas used in transactions',
79
- unit: 'gas',
80
- valueType: ValueType.INT,
81
- });
58
+ this.txBlobDataGasUsed = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED);
82
59
 
83
- this.txBlobDataGasCost = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST, {
84
- description: 'The gas cost of blobs in transactions',
85
- unit: 'gwei',
86
- valueType: ValueType.INT,
87
- });
60
+ this.txBlobDataGasCost = meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST);
88
61
 
89
- this.blobCountHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_COUNT, {
90
- description: 'Number of blobs in L1 transactions',
91
- unit: 'blobs',
92
- valueType: ValueType.INT,
93
- });
62
+ this.blobCountHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_COUNT);
94
63
 
95
- this.blobInclusionBlocksHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_INCLUSION_BLOCKS, {
96
- description: 'Number of L1 blocks between blob tx submission and inclusion',
97
- unit: 'blocks',
98
- valueType: ValueType.INT,
99
- });
64
+ this.blobInclusionBlocksHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_INCLUSION_BLOCKS);
100
65
 
101
- this.blobTxSuccessCounter = meter.createUpDownCounter(Metrics.L1_PUBLISHER_BLOB_TX_SUCCESS, {
102
- description: 'Number of successful L1 transactions with blobs',
103
- });
66
+ this.blobTxSuccessCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_SUCCESS);
104
67
 
105
- this.blobTxFailureCounter = meter.createUpDownCounter(Metrics.L1_PUBLISHER_BLOB_TX_FAILURE, {
106
- description: 'Number of failed L1 transactions with blobs',
107
- });
68
+ this.blobTxFailureCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_FAILURE);
108
69
 
109
- this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE, {
110
- description: 'How much L1 tx costs',
111
- unit: 'eth',
112
- valueType: ValueType.DOUBLE,
113
- advice: {
114
- explicitBucketBoundaries: [
115
- 0.001, 0.002, 0.004, 0.008, 0.01, 0.02, 0.04, 0.08, 0.1, 0.2, 0.4, 0.8, 1, 1.2, 1.4, 1.8, 2,
116
- ],
117
- },
118
- });
70
+ this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE);
119
71
 
120
- this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE, {
121
- unit: 'eth',
122
- description: 'The balance of the sender address',
123
- valueType: ValueType.DOUBLE,
124
- });
72
+ this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE);
125
73
  }
126
74
 
127
75
  recordFailedTx(txType: L1TxType) {