@aztec/sequencer-client 0.0.1-commit.e558bd1c → 0.0.1-commit.e57c76e

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 (125) hide show
  1. package/README.md +281 -21
  2. package/dest/client/sequencer-client.d.ts +19 -9
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +65 -32
  5. package/dest/config.d.ts +28 -6
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +76 -37
  8. package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
  9. package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
  10. package/dest/global_variable_builder/fee_predictor.js +128 -0
  11. package/dest/global_variable_builder/fee_provider.d.ts +21 -0
  12. package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
  13. package/dest/global_variable_builder/fee_provider.js +58 -0
  14. package/dest/global_variable_builder/global_builder.d.ts +14 -16
  15. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  16. package/dest/global_variable_builder/global_builder.js +16 -50
  17. package/dest/global_variable_builder/index.d.ts +4 -2
  18. package/dest/global_variable_builder/index.d.ts.map +1 -1
  19. package/dest/global_variable_builder/index.js +2 -0
  20. package/dest/index.d.ts +2 -2
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +1 -1
  23. package/dest/publisher/config.d.ts +47 -17
  24. package/dest/publisher/config.d.ts.map +1 -1
  25. package/dest/publisher/config.js +121 -42
  26. package/dest/publisher/index.d.ts +2 -1
  27. package/dest/publisher/index.d.ts.map +1 -1
  28. package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
  29. package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
  30. package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
  31. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +58 -0
  32. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
  33. package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
  34. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
  35. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
  36. package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
  37. package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
  38. package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
  39. package/dest/publisher/l1_tx_failed_store/index.js +2 -0
  40. package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
  41. package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
  42. package/dest/publisher/sequencer-bundle-simulator.js +198 -0
  43. package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
  44. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  45. package/dest/publisher/sequencer-publisher-factory.js +27 -3
  46. package/dest/publisher/sequencer-publisher.d.ts +94 -67
  47. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  48. package/dest/publisher/sequencer-publisher.js +439 -378
  49. package/dest/sequencer/automine/automine_factory.d.ts +54 -0
  50. package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
  51. package/dest/sequencer/automine/automine_factory.js +84 -0
  52. package/dest/sequencer/automine/automine_sequencer.d.ts +151 -0
  53. package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
  54. package/dest/sequencer/automine/automine_sequencer.js +509 -0
  55. package/dest/sequencer/chain_state_overrides.d.ts +61 -0
  56. package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
  57. package/dest/sequencer/chain_state_overrides.js +98 -0
  58. package/dest/sequencer/checkpoint_proposal_job.d.ts +60 -12
  59. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  60. package/dest/sequencer/checkpoint_proposal_job.js +830 -229
  61. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
  62. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
  63. package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
  64. package/dest/sequencer/checkpoint_voter.d.ts +1 -2
  65. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  66. package/dest/sequencer/checkpoint_voter.js +2 -5
  67. package/dest/sequencer/events.d.ts +48 -2
  68. package/dest/sequencer/events.d.ts.map +1 -1
  69. package/dest/sequencer/index.d.ts +3 -1
  70. package/dest/sequencer/index.d.ts.map +1 -1
  71. package/dest/sequencer/index.js +2 -0
  72. package/dest/sequencer/metrics.d.ts +23 -8
  73. package/dest/sequencer/metrics.d.ts.map +1 -1
  74. package/dest/sequencer/metrics.js +117 -21
  75. package/dest/sequencer/sequencer.d.ts +83 -22
  76. package/dest/sequencer/sequencer.d.ts.map +1 -1
  77. package/dest/sequencer/sequencer.js +378 -139
  78. package/dest/sequencer/timetable.d.ts +14 -6
  79. package/dest/sequencer/timetable.d.ts.map +1 -1
  80. package/dest/sequencer/timetable.js +47 -46
  81. package/dest/sequencer/types.d.ts +2 -2
  82. package/dest/sequencer/types.d.ts.map +1 -1
  83. package/dest/test/index.d.ts +3 -5
  84. package/dest/test/index.d.ts.map +1 -1
  85. package/dest/test/mock_checkpoint_builder.d.ts +11 -11
  86. package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
  87. package/dest/test/mock_checkpoint_builder.js +45 -34
  88. package/dest/test/utils.d.ts +3 -3
  89. package/dest/test/utils.d.ts.map +1 -1
  90. package/dest/test/utils.js +10 -8
  91. package/package.json +27 -28
  92. package/src/client/sequencer-client.ts +91 -35
  93. package/src/config.ts +98 -46
  94. package/src/global_variable_builder/README.md +44 -0
  95. package/src/global_variable_builder/fee_predictor.ts +172 -0
  96. package/src/global_variable_builder/fee_provider.ts +75 -0
  97. package/src/global_variable_builder/global_builder.ts +26 -63
  98. package/src/global_variable_builder/index.ts +3 -1
  99. package/src/index.ts +10 -1
  100. package/src/publisher/config.ts +157 -45
  101. package/src/publisher/index.ts +3 -0
  102. package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
  103. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +57 -0
  104. package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
  105. package/src/publisher/l1_tx_failed_store/index.ts +3 -0
  106. package/src/publisher/sequencer-bundle-simulator.ts +254 -0
  107. package/src/publisher/sequencer-publisher-factory.ts +38 -9
  108. package/src/publisher/sequencer-publisher.ts +532 -469
  109. package/src/sequencer/README.md +162 -450
  110. package/src/sequencer/automine/README.md +46 -0
  111. package/src/sequencer/automine/automine_factory.ts +145 -0
  112. package/src/sequencer/automine/automine_sequencer.ts +595 -0
  113. package/src/sequencer/chain_state_overrides.ts +162 -0
  114. package/src/sequencer/checkpoint_proposal_job.ts +1003 -248
  115. package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
  116. package/src/sequencer/checkpoint_voter.ts +1 -12
  117. package/src/sequencer/events.ts +51 -2
  118. package/src/sequencer/index.ts +2 -0
  119. package/src/sequencer/metrics.ts +132 -25
  120. package/src/sequencer/sequencer.ts +466 -158
  121. package/src/sequencer/timetable.ts +62 -56
  122. package/src/sequencer/types.ts +1 -1
  123. package/src/test/index.ts +2 -4
  124. package/src/test/mock_checkpoint_builder.ts +63 -49
  125. package/src/test/utils.ts +31 -10
@@ -0,0 +1,46 @@
1
+ # AutomineSequencer
2
+
3
+ A minimal, deterministic, queue-driven sequencer for e2e tests that do not exercise block-building or consensus mechanics (e.g. `e2e_token`, `e2e_amm`, `e2e_authwit`).
4
+
5
+ ## When to use it
6
+
7
+ Use `AutomineSequencer` (via `AUTOMINE_E2E_OPTS`) for single-sequencer tests that care about contract logic, not about proposer selection, attestations, pipelining, or multi-validator coordination. It bypasses all of that machinery.
8
+
9
+ Use the production `Sequencer` (via `PIPELINING_SETUP_OPTS` or the default) for tests that explicitly exercise consensus, validator rotation, P2P gossip, slashing, or multi-node behavior.
10
+
11
+ **Requirement**: the deployed rollup must have `aztecTargetCommitteeSize == 0`. This causes `Rollup.verifyProposer` / `verifyAttestations` on L1 to short-circuit and accept an empty `CommitteeAttestationsAndSigners`, which is what `AutomineSequencer` always sends.
12
+
13
+ ## What it omits
14
+
15
+ Compared to the production `Sequencer`:
16
+
17
+ - No proposer-turn check (single sequencer, always proposes).
18
+ - No sync check, no pipelining, no timetable enforcement.
19
+ - No validator orchestration, attestation collection, or P2P proposal gossip.
20
+ - No slashing, no governance votes, no `SequencerEvents`.
21
+
22
+ Consumers (archiver, world-state, `EpochTestSettler`) observe L1 and the archiver tip directly rather than listening for sequencer events.
23
+
24
+ ## Serial-queue invariant
25
+
26
+ Every operation — mempool-driven block builds, explicit empty-block builds, time warps, and reorgs — is serialized through a single `SerialQueue`. They never interleave.
27
+
28
+ Public entry points:
29
+
30
+ | Method | Description |
31
+ | --- | --- |
32
+ | `buildIfPending()` | Enqueues a mempool-driven build. Coalesces bursts into one job. |
33
+ | `buildEmptyBlock()` | Enqueues a forced empty-block build. |
34
+ | `warpTo(ts)` / `warpBy(delta)` | Advances L1 time to a slot boundary. |
35
+ | `revertToCheckpoint(n)` | Rolls L1 back to the block that published checkpoint `n`, then resets archiver, world-state, and P2P pool. |
36
+ | `syncPoint()` | Awaits the queue reaching idle. |
37
+
38
+ ## Entry points
39
+
40
+ **Factory** — `createAutomineSequencer` in `automine_factory.ts` wires up all dependencies (publisher manager, keystore, cheat codes, etc.), starts the `PublisherManager`, and returns an unstarted `AutomineSequencer`. The caller (`AztecNodeService.createAndSync` in `aztec-node/src/aztec-node/server.ts`) invokes `AutomineSequencer.start()` separately. It is called by the full node when `aztecTargetCommitteeSize == 0`.
41
+
42
+ **Test fixture** — `AUTOMINE_E2E_OPTS` in `end-to-end/src/fixtures/fixtures.ts` is the test-side entry point. Pass it to `setup()` to get a node + `AutomineSequencer` instead of the production sequencer stack.
43
+
44
+ ## Epoch proving caveat
45
+
46
+ Epoch proving remains manual under `AUTOMINE_E2E_OPTS`. The e2e `setup()` fixture does NOT wire an `EpochTestSettler` — that observer is only attached in `local-network.ts`. Tests that cross epoch boundaries must therefore advance the proven anchor explicitly via `cheatCodes.rollup.markAsProven(...)`. See `e2e_lending_contract.test.ts` (which calls `progressSlots` in `simulators/lending_simulator.ts`) and `e2e_pruned_blocks.test.ts` for real examples.
@@ -0,0 +1,145 @@
1
+ import type { Archiver } from '@aztec/archiver';
2
+ import type { BlobClientInterface } from '@aztec/blob-client/client';
3
+ import type { EpochCache } from '@aztec/epoch-cache';
4
+ import { GovernanceProposerContract, type RollupContract } from '@aztec/ethereum/contracts';
5
+ import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
6
+ import { PublisherManager } from '@aztec/ethereum/publisher-manager';
7
+ import { EthCheatCodes } from '@aztec/ethereum/test';
8
+ import type { ViemPublicClient } from '@aztec/ethereum/types';
9
+ import type { Logger } from '@aztec/foundation/log';
10
+ import type { DateProvider } from '@aztec/foundation/timer';
11
+ import type { KeystoreManager } from '@aztec/node-keystore';
12
+ import type { P2PClient as ConcreteP2PClient, P2P } from '@aztec/p2p';
13
+ import type { L2BlockSource } from '@aztec/stdlib/block';
14
+ import type { ChainConfig } from '@aztec/stdlib/config';
15
+ import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
16
+ import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
17
+ import type { TelemetryClient } from '@aztec/telemetry-client';
18
+ import { type FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
19
+
20
+ import { type SequencerClientConfig, getPublisherConfigFromSequencerConfig } from '../../config.js';
21
+ import type { GlobalVariableBuilder } from '../../global_variable_builder/global_builder.js';
22
+ import { SequencerPublisherFactory } from '../../publisher/sequencer-publisher-factory.js';
23
+ import { AutomineSequencer } from './automine_sequencer.js';
24
+
25
+ /** Arguments for {@link createAutomineSequencer}. */
26
+ export type CreateAutomineSequencerArgs = {
27
+ config: SequencerClientConfig & Pick<ChainConfig, 'l1ChainId' | 'rollupAddress'>;
28
+ l1TxUtils: L1TxUtils[];
29
+ funderL1TxUtils: L1TxUtils | undefined;
30
+ publicClient: ViemPublicClient;
31
+ rollupContract: RollupContract;
32
+ epochCache: EpochCache;
33
+ blobClient: BlobClientInterface | undefined;
34
+ telemetry: TelemetryClient;
35
+ dateProvider: DateProvider;
36
+ keyStoreManager: KeystoreManager;
37
+ validatorClient: ValidatorClient;
38
+ checkpointsBuilder: FullNodeCheckpointsBuilder;
39
+ globalVariableBuilder: GlobalVariableBuilder;
40
+ worldStateSynchronizer: WorldStateSynchronizer;
41
+ archiver: L2BlockSource &
42
+ L1ToL2MessageSource &
43
+ Pick<Archiver, 'rollbackTo' | 'addBlock' | 'addProposedCheckpoint' | 'syncImmediate'>;
44
+ p2pClient: P2P & Pick<ConcreteP2PClient, 'sync'>;
45
+ l1Constants: { l1GenesisTime: bigint; slotDuration: number; ethereumSlotDuration: number; rollupManaLimit: number };
46
+ log: Logger;
47
+ };
48
+
49
+ /**
50
+ * Builds an {@link AutomineSequencer} for use in single-sequencer e2e tests.
51
+ *
52
+ * Constructs the PublisherManager, GovernanceProposerContract, SequencerPublisherFactory,
53
+ * looks up the attestor/coinbase/feeRecipient from the keystore, wires EthCheatCodes,
54
+ * and starts the publisher manager before returning.
55
+ */
56
+ export async function createAutomineSequencer({
57
+ config,
58
+ l1TxUtils,
59
+ funderL1TxUtils,
60
+ publicClient,
61
+ rollupContract,
62
+ epochCache,
63
+ blobClient,
64
+ telemetry,
65
+ dateProvider,
66
+ keyStoreManager,
67
+ validatorClient,
68
+ checkpointsBuilder,
69
+ globalVariableBuilder,
70
+ worldStateSynchronizer,
71
+ archiver,
72
+ p2pClient,
73
+ l1Constants,
74
+ log,
75
+ }: CreateAutomineSequencerArgs): Promise<AutomineSequencer> {
76
+ const publisherManager = new PublisherManager(l1TxUtils, getPublisherConfigFromSequencerConfig(config), {
77
+ bindings: log.getBindings(),
78
+ funder: funderL1TxUtils,
79
+ });
80
+ const governanceProposerContract = new GovernanceProposerContract(
81
+ publicClient,
82
+ config.governanceProposerAddress.toString(),
83
+ );
84
+ const publisherFactory = new SequencerPublisherFactory(config, {
85
+ telemetry,
86
+ blobClient: blobClient!,
87
+ epochCache,
88
+ governanceProposerContract,
89
+ rollupContract,
90
+ dateProvider,
91
+ publisherManager,
92
+ nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager),
93
+ logger: log,
94
+ });
95
+ const attestorAddresses = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAttesterAddresses();
96
+ const attestor = attestorAddresses[0];
97
+ if (!attestor) {
98
+ throw new Error('AutomineSequencer requires at least one attestor address in the keystore');
99
+ }
100
+ const coinbase = validatorClient.getCoinbaseForAttestor(attestor);
101
+ const feeRecipient = validatorClient.getFeeRecipientForAttestor(attestor);
102
+ const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, dateProvider, log.createChild('eth-cheat-codes'));
103
+
104
+ // Include the funder's L1TxUtils in the reorg reset list so funding-tx nonces don't
105
+ // go stale after L1 rollbacks. Dedupe by sender address in case the funder reuses a
106
+ // publisher's signer.
107
+ const reorgResetL1TxUtils = (() => {
108
+ if (!funderL1TxUtils) {
109
+ return l1TxUtils;
110
+ }
111
+ const funderAddress = funderL1TxUtils.getSenderAddress().toString();
112
+ const alreadyIncluded = l1TxUtils.some(utils => utils.getSenderAddress().toString() === funderAddress);
113
+ return alreadyIncluded ? l1TxUtils : [...l1TxUtils, funderL1TxUtils];
114
+ })();
115
+
116
+ const automineSequencer = new AutomineSequencer({
117
+ publisherFactory,
118
+ checkpointsBuilder,
119
+ globalsBuilder: globalVariableBuilder,
120
+ worldState: worldStateSynchronizer,
121
+ l2BlockSource: archiver,
122
+ l1ToL2MessageSource: archiver,
123
+ p2pClient,
124
+ ethCheatCodes,
125
+ dateProvider: dateProvider as any, // TestDateProvider; verified at construction in fixture
126
+ l1Constants: {
127
+ l1GenesisTime: l1Constants.l1GenesisTime,
128
+ slotDuration: l1Constants.slotDuration,
129
+ ethereumSlotDuration: l1Constants.ethereumSlotDuration,
130
+ rollupManaLimit: l1Constants.rollupManaLimit,
131
+ epochDuration: config.aztecEpochDuration,
132
+ },
133
+ coinbase,
134
+ feeRecipient,
135
+ signatureContext: { chainId: config.l1ChainId, rollupAddress: config.rollupAddress },
136
+ config,
137
+ archiver,
138
+ l1TxUtils: reorgResetL1TxUtils,
139
+ stopExtras: () => publisherManager.stop(),
140
+ log: log.createChild('automine-sequencer'),
141
+ });
142
+
143
+ await publisherManager.start();
144
+ return automineSequencer;
145
+ }