@aztec/sequencer-client 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.dbf9cec

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 (68) hide show
  1. package/dest/client/sequencer-client.d.ts +12 -7
  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 -3
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +13 -4
  7. package/dest/global_variable_builder/global_builder.d.ts +2 -4
  8. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  9. package/dest/publisher/config.d.ts +35 -17
  10. package/dest/publisher/config.d.ts.map +1 -1
  11. package/dest/publisher/config.js +106 -42
  12. package/dest/publisher/index.d.ts +2 -1
  13. package/dest/publisher/index.d.ts.map +1 -1
  14. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  15. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  16. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  17. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +59 -0
  18. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  19. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  20. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  21. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  22. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  23. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  24. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  25. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  26. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
  27. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  28. package/dest/publisher/sequencer-publisher-factory.js +13 -2
  29. package/dest/publisher/sequencer-publisher.d.ts +22 -7
  30. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  31. package/dest/publisher/sequencer-publisher.js +258 -29
  32. package/dest/sequencer/checkpoint_proposal_job.d.ts +1 -1
  33. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  34. package/dest/sequencer/checkpoint_proposal_job.js +39 -11
  35. package/dest/sequencer/metrics.d.ts +17 -5
  36. package/dest/sequencer/metrics.d.ts.map +1 -1
  37. package/dest/sequencer/metrics.js +86 -15
  38. package/dest/sequencer/sequencer.d.ts +15 -7
  39. package/dest/sequencer/sequencer.d.ts.map +1 -1
  40. package/dest/sequencer/sequencer.js +23 -25
  41. package/dest/sequencer/timetable.js +1 -1
  42. package/dest/test/index.d.ts +3 -5
  43. package/dest/test/index.d.ts.map +1 -1
  44. package/dest/test/mock_checkpoint_builder.d.ts +5 -3
  45. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  46. package/dest/test/mock_checkpoint_builder.js +6 -4
  47. package/dest/test/utils.d.ts +3 -3
  48. package/dest/test/utils.d.ts.map +1 -1
  49. package/dest/test/utils.js +5 -4
  50. package/package.json +28 -28
  51. package/src/client/sequencer-client.ts +25 -7
  52. package/src/config.ts +17 -8
  53. package/src/global_variable_builder/global_builder.ts +1 -1
  54. package/src/publisher/config.ts +121 -43
  55. package/src/publisher/index.ts +3 -0
  56. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  57. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -0
  58. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  59. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  60. package/src/publisher/sequencer-publisher-factory.ts +23 -6
  61. package/src/publisher/sequencer-publisher.ts +241 -36
  62. package/src/sequencer/checkpoint_proposal_job.ts +59 -10
  63. package/src/sequencer/metrics.ts +92 -18
  64. package/src/sequencer/sequencer.ts +31 -30
  65. package/src/sequencer/timetable.ts +1 -1
  66. package/src/test/index.ts +2 -4
  67. package/src/test/mock_checkpoint_builder.ts +12 -1
  68. package/src/test/utils.ts +5 -2
@@ -0,0 +1,32 @@
1
+ import { type Logger, createLogger } from '@aztec/foundation/log';
2
+ import { createFileStore } from '@aztec/stdlib/file-store';
3
+
4
+ import type { L1TxFailedStore } from './failed_tx_store.js';
5
+ import { FileStoreL1TxFailedStore } from './file_store_failed_tx_store.js';
6
+
7
+ /**
8
+ * Creates an L1TxFailedStore from a config string.
9
+ * Supports any backend that FileStore supports (GCS, S3, R2, local filesystem).
10
+ * @param config - Config string (e.g., 'gs://bucket/path', 's3://bucket/path', 'file:///path'). If undefined, returns undefined.
11
+ * @param logger - Optional logger.
12
+ * @returns The store instance, or undefined if config is not provided.
13
+ */
14
+ export async function createL1TxFailedStore(
15
+ config: string | undefined,
16
+ logger: Logger = createLogger('sequencer:l1-tx-failed-store'),
17
+ ): Promise<L1TxFailedStore | undefined> {
18
+ if (!config) {
19
+ return undefined;
20
+ }
21
+
22
+ const fileStore = await createFileStore(config, logger);
23
+ if (!fileStore) {
24
+ throw new Error(
25
+ `Failed to create file store from config: '${config}'. ` +
26
+ `Supported formats: 'gs://bucket/path', 's3://bucket/path', 'file:///path'.`,
27
+ );
28
+ }
29
+
30
+ logger.info(`Created L1 tx failed store`, { config });
31
+ return new FileStoreL1TxFailedStore(fileStore, logger);
32
+ }
@@ -0,0 +1,55 @@
1
+ import type { Hex } from 'viem';
2
+
3
+ /** URI pointing to a stored failed L1 transaction. */
4
+ export type FailedL1TxUri = string & { __brand: 'FailedL1TxUri' };
5
+
6
+ /** A failed L1 transaction captured for debugging and replay. */
7
+ export type FailedL1Tx = {
8
+ /** Tx hash (for reverts) or keccak256(request.data) (for simulation/send failures). */
9
+ id: Hex;
10
+ /** Unix timestamp (ms) when failure occurred. */
11
+ timestamp: number;
12
+ /** Whether the failure was during simulation or after sending. */
13
+ failureType: 'simulation' | 'revert' | 'send-error';
14
+ /** The actual L1 transaction for replay (multicall-encoded for bundled txs). */
15
+ request: {
16
+ to: Hex;
17
+ data: Hex;
18
+ value?: string; // bigint as string
19
+ };
20
+ /** Raw blob data as hex for replay. */
21
+ blobData?: Hex[];
22
+ /** L1 block number at time of failure (simulation target or receipt block). */
23
+ l1BlockNumber: string; // bigint as string
24
+ /** Receipt info (present only for on-chain reverts). */
25
+ receipt?: {
26
+ transactionHash: Hex;
27
+ blockNumber: string; // bigint as string
28
+ gasUsed: string; // bigint as string
29
+ status: 'reverted';
30
+ };
31
+ /** Error information. */
32
+ error: {
33
+ message: string;
34
+ /** Decoded error name (e.g., 'Rollup__InvalidProposer'). */
35
+ name?: string;
36
+ };
37
+ /** Context metadata. */
38
+ context: {
39
+ /** Actions involved (e.g., ['propose', 'governance-signal']). */
40
+ actions: string[];
41
+ /** Individual request data for each action (metadata, not used for replay). */
42
+ requests?: Array<{ action: string; to: Hex; data: Hex }>;
43
+ checkpointNumber?: number;
44
+ slot?: number;
45
+ sender: Hex;
46
+ };
47
+ };
48
+
49
+ /** Store for failed L1 transactions for debugging purposes. */
50
+ export interface L1TxFailedStore {
51
+ /** Saves a failed transaction and returns its URI. */
52
+ saveFailedTx(tx: FailedL1Tx): Promise<FailedL1TxUri>;
53
+ /** Retrieves a failed transaction by its URI. */
54
+ getFailedTx(uri: FailedL1TxUri): Promise<FailedL1Tx>;
55
+ }
@@ -0,0 +1,46 @@
1
+ import { type Logger, createLogger } from '@aztec/foundation/log';
2
+ import type { FileStore } from '@aztec/stdlib/file-store';
3
+
4
+ import type { FailedL1Tx, FailedL1TxUri, L1TxFailedStore } from './failed_tx_store.js';
5
+
6
+ /**
7
+ * L1TxFailedStore implementation using the FileStore abstraction.
8
+ * Supports any backend that FileStore supports (GCS, S3, R2, local filesystem).
9
+ */
10
+ export class FileStoreL1TxFailedStore implements L1TxFailedStore {
11
+ private readonly log: Logger;
12
+
13
+ constructor(
14
+ private readonly fileStore: FileStore,
15
+ logger?: Logger,
16
+ ) {
17
+ this.log = logger ?? createLogger('sequencer:l1-tx-failed-store');
18
+ }
19
+
20
+ public async saveFailedTx(tx: FailedL1Tx): Promise<FailedL1TxUri> {
21
+ const prefix = tx.receipt ? 'tx' : 'data';
22
+ const path = `${tx.failureType}/${prefix}-${tx.id}.json`;
23
+ const json = JSON.stringify(tx, null, 2);
24
+
25
+ const uri = await this.fileStore.save(path, Buffer.from(json), {
26
+ metadata: {
27
+ 'content-type': 'application/json',
28
+ actions: tx.context.actions.join(','),
29
+ 'failure-type': tx.failureType,
30
+ },
31
+ });
32
+
33
+ this.log.info(`Saved failed L1 tx to ${uri}`, {
34
+ id: tx.id,
35
+ failureType: tx.failureType,
36
+ actions: tx.context.actions.join(','),
37
+ });
38
+
39
+ return uri as FailedL1TxUri;
40
+ }
41
+
42
+ public async getFailedTx(uri: FailedL1TxUri): Promise<FailedL1Tx> {
43
+ const data = await this.fileStore.read(uri);
44
+ return JSON.parse(data.toString()) as FailedL1Tx;
45
+ }
46
+ }
@@ -0,0 +1,3 @@
1
+ export { type FailedL1Tx, type FailedL1TxUri, type L1TxFailedStore } from './failed_tx_store.js';
2
+ export { createL1TxFailedStore } from './factory.js';
3
+ export { FileStoreL1TxFailedStore } from './file_store_failed_tx_store.js';
@@ -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
  }