@aztec/sequencer-client 5.0.0-private.20260319 → 5.0.0-rc.1

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 (105) hide show
  1. package/README.md +281 -21
  2. package/dest/client/sequencer-client.d.ts +8 -3
  3. package/dest/client/sequencer-client.d.ts.map +1 -1
  4. package/dest/client/sequencer-client.js +17 -32
  5. package/dest/config.d.ts +10 -4
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +48 -24
  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 +67 -0
  14. package/dest/global_variable_builder/global_builder.d.ts +14 -14
  15. package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
  16. package/dest/global_variable_builder/global_builder.js +16 -51
  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/publisher/config.d.ts +15 -3
  21. package/dest/publisher/config.d.ts.map +1 -1
  22. package/dest/publisher/config.js +19 -4
  23. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +3 -4
  24. package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -1
  25. package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
  26. package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
  27. package/dest/publisher/sequencer-bundle-simulator.js +198 -0
  28. package/dest/publisher/sequencer-publisher-factory.d.ts +3 -5
  29. package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
  30. package/dest/publisher/sequencer-publisher-factory.js +2 -3
  31. package/dest/publisher/sequencer-publisher.d.ts +70 -64
  32. package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
  33. package/dest/publisher/sequencer-publisher.js +312 -533
  34. package/dest/sequencer/automine/automine_factory.d.ts +56 -0
  35. package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
  36. package/dest/sequencer/automine/automine_factory.js +85 -0
  37. package/dest/sequencer/automine/automine_sequencer.d.ts +184 -0
  38. package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
  39. package/dest/sequencer/automine/automine_sequencer.js +677 -0
  40. package/dest/sequencer/automine/index.d.ts +3 -0
  41. package/dest/sequencer/automine/index.d.ts.map +1 -0
  42. package/dest/sequencer/automine/index.js +2 -0
  43. package/dest/sequencer/chain_state_overrides.d.ts +61 -0
  44. package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
  45. package/dest/sequencer/chain_state_overrides.js +98 -0
  46. package/dest/sequencer/checkpoint_proposal_job.d.ts +73 -21
  47. package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
  48. package/dest/sequencer/checkpoint_proposal_job.js +709 -199
  49. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
  50. package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
  51. package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
  52. package/dest/sequencer/checkpoint_voter.d.ts +1 -2
  53. package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
  54. package/dest/sequencer/checkpoint_voter.js +2 -5
  55. package/dest/sequencer/errors.d.ts +1 -8
  56. package/dest/sequencer/errors.d.ts.map +1 -1
  57. package/dest/sequencer/errors.js +0 -9
  58. package/dest/sequencer/events.d.ts +61 -4
  59. package/dest/sequencer/events.d.ts.map +1 -1
  60. package/dest/sequencer/metrics.d.ts +9 -10
  61. package/dest/sequencer/metrics.d.ts.map +1 -1
  62. package/dest/sequencer/metrics.js +34 -20
  63. package/dest/sequencer/sequencer.d.ts +112 -27
  64. package/dest/sequencer/sequencer.d.ts.map +1 -1
  65. package/dest/sequencer/sequencer.js +467 -147
  66. package/dest/sequencer/types.d.ts +2 -2
  67. package/dest/sequencer/types.d.ts.map +1 -1
  68. package/dest/test/index.d.ts +3 -3
  69. package/dest/test/index.d.ts.map +1 -1
  70. package/dest/test/utils.d.ts +15 -1
  71. package/dest/test/utils.d.ts.map +1 -1
  72. package/dest/test/utils.js +23 -6
  73. package/package.json +28 -27
  74. package/src/client/sequencer-client.ts +29 -41
  75. package/src/config.ts +57 -24
  76. package/src/global_variable_builder/README.md +44 -0
  77. package/src/global_variable_builder/fee_predictor.ts +172 -0
  78. package/src/global_variable_builder/fee_provider.ts +80 -0
  79. package/src/global_variable_builder/global_builder.ts +25 -63
  80. package/src/global_variable_builder/index.ts +3 -1
  81. package/src/publisher/config.ts +40 -6
  82. package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +3 -1
  83. package/src/publisher/sequencer-bundle-simulator.ts +254 -0
  84. package/src/publisher/sequencer-publisher-factory.ts +3 -6
  85. package/src/publisher/sequencer-publisher.ts +368 -577
  86. package/src/sequencer/automine/README.md +60 -0
  87. package/src/sequencer/automine/automine_factory.ts +152 -0
  88. package/src/sequencer/automine/automine_sequencer.ts +783 -0
  89. package/src/sequencer/automine/index.ts +6 -0
  90. package/src/sequencer/chain_state_overrides.ts +169 -0
  91. package/src/sequencer/checkpoint_proposal_job.ts +818 -224
  92. package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
  93. package/src/sequencer/checkpoint_voter.ts +1 -12
  94. package/src/sequencer/errors.ts +0 -15
  95. package/src/sequencer/events.ts +65 -4
  96. package/src/sequencer/metrics.ts +43 -24
  97. package/src/sequencer/sequencer.ts +542 -164
  98. package/src/sequencer/types.ts +1 -1
  99. package/src/test/index.ts +2 -2
  100. package/src/test/utils.ts +59 -10
  101. package/dest/sequencer/timetable.d.ts +0 -88
  102. package/dest/sequencer/timetable.d.ts.map +0 -1
  103. package/dest/sequencer/timetable.js +0 -222
  104. package/src/sequencer/README.md +0 -531
  105. package/src/sequencer/timetable.ts +0 -283
@@ -0,0 +1,60 @@
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) 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, reorgs, and synthetic epoch proving — 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
+ | `prove(upToCheckpoint?)` | Synthetically proves epochs up to a checkpoint (default: the latest checkpointed): writes the epoch out hashes into the L1 Outbox so L2-to-L1 messages become consumable, then advances the proven tip. No real proof. Clamps to the checkpointed tip and no-ops when already proven. |
36
+ | `revertToCheckpoint(n)` | Rolls L1 back to the block that published checkpoint `n`, then resets archiver, world-state, and P2P pool. |
37
+ | `syncPoint()` | Awaits the queue reaching idle. |
38
+
39
+ ## Time control
40
+
41
+ The AutomineSequencer owns L1 time in the local network (replacing the deleted `AnvilTestWatcher`). It builds and publishes each checkpoint at the next aztec-slot boundary, and `warpTo` / `warpBy` advance the clock by publishing an empty checkpoint at the target slot. Before every build, warp, and prove it reconciles the injected `TestDateProvider` to the latest *mined* L1 timestamp, so node-side consumers of `dateProvider.now()` stay aligned with L1 even when an unrelated L1 tx mines a block between our builds. It never advances the clock to the pending, un-mined timestamp.
42
+
43
+ ## Publish-failure recovery
44
+
45
+ A failed propose mines no checkpoint on L1 (it reverts inside the multicall or is never sent), so recovery is purely local — there is **no L1 reorg**. The optimistic archiver insert (the proposed block plus its proposed checkpoint) is rolled back via `archiver.removeUncheckpointedBlocksAfter`, which removes the uncheckpointed block and evicts the proposed checkpoint that referenced it. `p2pClient.sync()` then observes the lowered proposed tip and returns the block's txs to the pending pool, `worldState.syncImmediate()` drops any applied effects, and the L1 nonce is reset. The build is not retried inline; the mempool poller re-enqueues one once the txs are back in the pool.
46
+
47
+ ## Entry points
48
+
49
+ **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`.
50
+
51
+ **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.
52
+
53
+ ## Epoch proving
54
+
55
+ There is no real prover in the automine setup, so epochs are settled synthetically: the epoch out hash is written into the L1 Outbox via cheat codes and the rollup's proven tip is advanced — the local-network equivalent of an epoch proof landing on L1. The grouping/out-hash logic lives in the shared `settleEpochOutbox` helper in `@aztec/prover-client/test`, used by both proving drivers below.
56
+
57
+ Who drives proving depends on the `automineEnableProveEpoch` config flag:
58
+
59
+ - **Local network / sandbox** (`automineEnableProveEpoch: true`): the AutomineSequencer runs an auto-prove loop that calls `prove()` as checkpoints land, through the same serial queue as its builds. This replaces the standalone `EpochTestSettler`, which used to race the build loop. The loop also reconciles the clock on each tick.
60
+ - **e2e tests** (`AUTOMINE_E2E_OPTS`, flag off): proving is manual so tests stay deterministic. Cross-epoch tests advance the proven anchor explicitly via `node.prove(...)`, `cheatCodes.rollup.markAsProven(...)`, or a hand-driven `EpochTestSettler`. See `e2e_pruned_blocks.test.ts` and `e2e_epochs/epochs_partial_proof_multi_root.test.ts` for real examples.
@@ -0,0 +1,152 @@
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<
44
+ Archiver,
45
+ 'rollbackTo' | 'addBlock' | 'addProposedCheckpoint' | 'syncImmediate' | 'removeUncheckpointedBlocksAfter'
46
+ >;
47
+ p2pClient: P2P & Pick<ConcreteP2PClient, 'sync'>;
48
+ l1Constants: { l1GenesisTime: bigint; slotDuration: number; ethereumSlotDuration: number; rollupManaLimit: number };
49
+ /** When true, run the auto-settle / clock-reconcile loop (local-network only). */
50
+ autoSettle?: boolean;
51
+ log: Logger;
52
+ };
53
+
54
+ /**
55
+ * Builds an {@link AutomineSequencer} for use in single-sequencer e2e tests.
56
+ *
57
+ * Constructs the PublisherManager, GovernanceProposerContract, SequencerPublisherFactory,
58
+ * looks up the attestor/coinbase/feeRecipient from the keystore, wires EthCheatCodes,
59
+ * and starts the publisher manager before returning.
60
+ */
61
+ export async function createAutomineSequencer({
62
+ config,
63
+ l1TxUtils,
64
+ funderL1TxUtils,
65
+ publicClient,
66
+ rollupContract,
67
+ epochCache,
68
+ blobClient,
69
+ telemetry,
70
+ dateProvider,
71
+ keyStoreManager,
72
+ validatorClient,
73
+ checkpointsBuilder,
74
+ globalVariableBuilder,
75
+ worldStateSynchronizer,
76
+ archiver,
77
+ p2pClient,
78
+ l1Constants,
79
+ autoSettle,
80
+ log,
81
+ }: CreateAutomineSequencerArgs): Promise<AutomineSequencer> {
82
+ const publisherManager = new PublisherManager(l1TxUtils, getPublisherConfigFromSequencerConfig(config), {
83
+ bindings: log.getBindings(),
84
+ funder: funderL1TxUtils,
85
+ });
86
+ const governanceProposerContract = new GovernanceProposerContract(
87
+ publicClient,
88
+ config.governanceProposerAddress.toString(),
89
+ );
90
+ const publisherFactory = new SequencerPublisherFactory(config, {
91
+ telemetry,
92
+ blobClient: blobClient!,
93
+ epochCache,
94
+ governanceProposerContract,
95
+ rollupContract,
96
+ dateProvider,
97
+ publisherManager,
98
+ nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager),
99
+ logger: log,
100
+ });
101
+ const attestorAddresses = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager).getAttesterAddresses();
102
+ const attestor = attestorAddresses[0];
103
+ if (!attestor) {
104
+ throw new Error('AutomineSequencer requires at least one attestor address in the keystore');
105
+ }
106
+ const coinbase = validatorClient.getCoinbaseForAttestor(attestor);
107
+ const feeRecipient = validatorClient.getFeeRecipientForAttestor(attestor);
108
+ const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, dateProvider, log.createChild('eth-cheat-codes'));
109
+
110
+ // Include the funder's L1TxUtils in the reorg reset list so funding-tx nonces don't
111
+ // go stale after L1 rollbacks. Dedupe by sender address in case the funder reuses a
112
+ // publisher's signer.
113
+ const reorgResetL1TxUtils = (() => {
114
+ if (!funderL1TxUtils) {
115
+ return l1TxUtils;
116
+ }
117
+ const funderAddress = funderL1TxUtils.getSenderAddress().toString();
118
+ const alreadyIncluded = l1TxUtils.some(utils => utils.getSenderAddress().toString() === funderAddress);
119
+ return alreadyIncluded ? l1TxUtils : [...l1TxUtils, funderL1TxUtils];
120
+ })();
121
+
122
+ const automineSequencer = new AutomineSequencer({
123
+ publisherFactory,
124
+ checkpointsBuilder,
125
+ globalsBuilder: globalVariableBuilder,
126
+ worldState: worldStateSynchronizer,
127
+ l2BlockSource: archiver,
128
+ l1ToL2MessageSource: archiver,
129
+ p2pClient,
130
+ ethCheatCodes,
131
+ dateProvider: dateProvider as any, // TestDateProvider; verified at construction in fixture
132
+ l1Constants: {
133
+ l1GenesisTime: l1Constants.l1GenesisTime,
134
+ slotDuration: l1Constants.slotDuration,
135
+ ethereumSlotDuration: l1Constants.ethereumSlotDuration,
136
+ rollupManaLimit: l1Constants.rollupManaLimit,
137
+ epochDuration: config.aztecEpochDuration,
138
+ },
139
+ coinbase,
140
+ feeRecipient,
141
+ signatureContext: { chainId: config.l1ChainId, rollupAddress: config.rollupAddress },
142
+ config,
143
+ archiver,
144
+ l1TxUtils: reorgResetL1TxUtils,
145
+ autoSettle,
146
+ stopExtras: () => publisherManager.stop(),
147
+ log: log.createChild('automine-sequencer'),
148
+ });
149
+
150
+ await publisherManager.start();
151
+ return automineSequencer;
152
+ }