@aztec/sequencer-client 0.0.1-commit.733c4a3 → 0.0.1-commit.7689c7f
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.
- package/README.md +282 -21
- package/dest/client/sequencer-client.d.ts +8 -3
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +53 -30
- package/dest/config.d.ts +28 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +62 -27
- package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_predictor.js +128 -0
- package/dest/global_variable_builder/fee_provider.d.ts +21 -0
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_provider.js +58 -0
- package/dest/global_variable_builder/global_builder.d.ts +14 -14
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +16 -50
- package/dest/global_variable_builder/index.d.ts +4 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/global_variable_builder/index.js +2 -0
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/config.d.ts +15 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +19 -4
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +3 -4
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -1
- package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
- package/dest/publisher/sequencer-bundle-simulator.js +198 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +3 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +16 -3
- package/dest/publisher/sequencer-publisher.d.ts +77 -65
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +345 -512
- package/dest/sequencer/automine/automine_factory.d.ts +54 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +84 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +151 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +506 -0
- package/dest/sequencer/chain_state_overrides.d.ts +61 -0
- package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
- package/dest/sequencer/chain_state_overrides.js +98 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +54 -11
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +776 -227
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
- package/dest/sequencer/checkpoint_voter.d.ts +1 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +2 -5
- package/dest/sequencer/events.d.ts +47 -2
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/index.d.ts +3 -1
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +2 -0
- package/dest/sequencer/metrics.d.ts +13 -10
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +45 -20
- package/dest/sequencer/sequencer.d.ts +59 -16
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +333 -119
- package/dest/sequencer/timetable.d.ts +17 -3
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +51 -43
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +7 -9
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +39 -30
- package/dest/test/utils.d.ts +1 -1
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +7 -6
- package/package.json +27 -28
- package/src/client/sequencer-client.ts +72 -33
- package/src/config.ts +76 -27
- package/src/global_variable_builder/README.md +44 -0
- package/src/global_variable_builder/fee_predictor.ts +172 -0
- package/src/global_variable_builder/fee_provider.ts +75 -0
- package/src/global_variable_builder/global_builder.ts +25 -62
- package/src/global_variable_builder/index.ts +3 -1
- package/src/index.ts +10 -1
- package/src/publisher/config.ts +40 -6
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +3 -1
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +18 -6
- package/src/publisher/sequencer-publisher.ts +426 -567
- package/src/sequencer/README.md +152 -450
- package/src/sequencer/automine/README.md +46 -0
- package/src/sequencer/automine/automine_factory.ts +145 -0
- package/src/sequencer/automine/automine_sequencer.ts +592 -0
- package/src/sequencer/chain_state_overrides.ts +162 -0
- package/src/sequencer/checkpoint_proposal_job.ts +941 -256
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/events.ts +50 -2
- package/src/sequencer/index.ts +2 -0
- package/src/sequencer/metrics.ts +57 -24
- package/src/sequencer/sequencer.ts +414 -132
- package/src/sequencer/timetable.ts +64 -52
- package/src/sequencer/types.ts +1 -1
- package/src/test/mock_checkpoint_builder.ts +51 -48
- package/src/test/utils.ts +28 -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
|
+
}
|