@aztec/sequencer-client 0.0.0-test.1 → 0.0.1-commit.017a351
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 +281 -21
- package/dest/client/index.d.ts +1 -1
- package/dest/client/sequencer-client.d.ts +43 -33
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +117 -62
- package/dest/config.d.ts +38 -17
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +172 -85
- 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 +26 -17
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +45 -61
- 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 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -3
- package/dest/publisher/config.d.ts +60 -27
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +124 -32
- package/dest/publisher/index.d.ts +4 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +3 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts +11 -0
- package/dest/publisher/l1_tx_failed_store/factory.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/factory.js +22 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +58 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- 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 +50 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -0
- package/dest/publisher/sequencer-publisher-factory.js +75 -0
- package/dest/publisher/sequencer-publisher-metrics.d.ts +5 -4
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +34 -62
- package/dest/publisher/sequencer-publisher.d.ts +170 -97
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +1255 -276
- 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 +509 -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 +150 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +1792 -0
- 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 +34 -0
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_voter.js +106 -0
- package/dest/sequencer/config.d.ts +7 -1
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/errors.d.ts +11 -0
- package/dest/sequencer/errors.d.ts.map +1 -0
- package/dest/sequencer/errors.js +15 -0
- package/dest/sequencer/events.d.ts +92 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +6 -2
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +5 -1
- package/dest/sequencer/metrics.d.ts +64 -13
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +309 -68
- package/dest/sequencer/sequencer.d.ts +205 -135
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +1208 -523
- package/dest/sequencer/timetable.d.ts +85 -25
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +177 -60
- package/dest/sequencer/types.d.ts +3 -0
- package/dest/sequencer/types.d.ts.map +1 -0
- package/dest/sequencer/types.js +1 -0
- package/dest/sequencer/utils.d.ts +20 -38
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +12 -47
- package/dest/test/index.d.ts +9 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -4
- package/dest/test/mock_checkpoint_builder.d.ts +95 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +231 -0
- package/dest/test/utils.d.ts +53 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +105 -0
- package/package.json +46 -45
- package/src/client/sequencer-client.ts +158 -103
- package/src/config.ts +201 -99
- 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 +68 -76
- package/src/global_variable_builder/index.ts +3 -1
- package/src/index.ts +10 -3
- package/src/publisher/config.ts +184 -59
- package/src/publisher/index.ts +7 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +57 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +121 -0
- package/src/publisher/sequencer-publisher-metrics.ts +33 -63
- package/src/publisher/sequencer-publisher.ts +1101 -350
- package/src/sequencer/README.md +243 -0
- package/src/sequencer/automine/README.md +46 -0
- package/src/sequencer/automine/automine_factory.ts +145 -0
- package/src/sequencer/automine/automine_sequencer.ts +595 -0
- package/src/sequencer/chain_state_overrides.ts +162 -0
- package/src/sequencer/checkpoint_proposal_job.ts +1632 -0
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +119 -0
- package/src/sequencer/config.ts +8 -0
- package/src/sequencer/errors.ts +21 -0
- package/src/sequencer/events.ts +76 -0
- package/src/sequencer/index.ts +5 -1
- package/src/sequencer/metrics.ts +397 -75
- package/src/sequencer/sequencer.ts +1013 -579
- package/src/sequencer/timetable.ts +225 -60
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +28 -60
- package/src/test/index.ts +11 -5
- package/src/test/mock_checkpoint_builder.ts +323 -0
- package/src/test/utils.ts +185 -0
- package/dest/sequencer/allowed.d.ts +0 -3
- package/dest/sequencer/allowed.d.ts.map +0 -1
- package/dest/sequencer/allowed.js +0 -27
- package/dest/slasher/factory.d.ts +0 -7
- package/dest/slasher/factory.d.ts.map +0 -1
- package/dest/slasher/factory.js +0 -8
- package/dest/slasher/index.d.ts +0 -3
- package/dest/slasher/index.d.ts.map +0 -1
- package/dest/slasher/index.js +0 -2
- package/dest/slasher/slasher_client.d.ts +0 -75
- package/dest/slasher/slasher_client.d.ts.map +0 -1
- package/dest/slasher/slasher_client.js +0 -132
- package/dest/tx_validator/archive_cache.d.ts +0 -14
- package/dest/tx_validator/archive_cache.d.ts.map +0 -1
- package/dest/tx_validator/archive_cache.js +0 -22
- package/dest/tx_validator/gas_validator.d.ts +0 -14
- package/dest/tx_validator/gas_validator.d.ts.map +0 -1
- package/dest/tx_validator/gas_validator.js +0 -78
- package/dest/tx_validator/nullifier_cache.d.ts +0 -16
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/phases_validator.d.ts +0 -12
- package/dest/tx_validator/phases_validator.d.ts.map +0 -1
- package/dest/tx_validator/phases_validator.js +0 -80
- package/dest/tx_validator/test_utils.d.ts +0 -23
- package/dest/tx_validator/test_utils.d.ts.map +0 -1
- package/dest/tx_validator/test_utils.js +0 -26
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -50
- package/src/sequencer/allowed.ts +0 -36
- package/src/slasher/factory.ts +0 -15
- package/src/slasher/index.ts +0 -2
- package/src/slasher/slasher_client.ts +0 -193
- package/src/tx_validator/archive_cache.ts +0 -28
- package/src/tx_validator/gas_validator.ts +0 -101
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/phases_validator.ts +0 -98
- package/src/tx_validator/test_utils.ts +0 -48
- package/src/tx_validator/tx_validator_factory.ts +0 -120
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
|
+
import { MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
|
|
2
3
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
createEthereumChain,
|
|
9
|
-
createL1Clients,
|
|
10
|
-
isAnvilTestChain,
|
|
11
|
-
} from '@aztec/ethereum';
|
|
12
|
-
import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
4
|
+
import { isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
5
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
6
|
+
import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
7
|
+
import { type Delayer, L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
8
|
+
import { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
13
9
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
15
11
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
12
|
+
import type { KeystoreManager } from '@aztec/node-keystore';
|
|
16
13
|
import type { P2P } from '@aztec/p2p';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import type {
|
|
20
|
-
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
21
|
-
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
22
|
-
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
14
|
+
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
15
|
+
import type { L2BlockSink, L2BlockSource, ProposedCheckpointSink } from '@aztec/stdlib/block';
|
|
16
|
+
import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
23
17
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
24
|
-
import type
|
|
25
|
-
import type
|
|
18
|
+
import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
|
|
19
|
+
import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
26
20
|
|
|
27
|
-
import type
|
|
28
|
-
import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
29
|
-
import {
|
|
21
|
+
import { type SequencerClientConfig, getPublisherConfigFromSequencerConfig } from '../config.js';
|
|
22
|
+
import type { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
23
|
+
import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
30
24
|
import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
31
|
-
import type { SlasherClient } from '../slasher/index.js';
|
|
32
25
|
|
|
33
26
|
/**
|
|
34
27
|
* Encapsulates the full sequencer and publisher.
|
|
35
28
|
*/
|
|
36
29
|
export class SequencerClient {
|
|
37
|
-
constructor(
|
|
30
|
+
constructor(
|
|
31
|
+
protected publisherManager: PublisherManager<L1TxUtils>,
|
|
32
|
+
protected sequencer: Sequencer,
|
|
33
|
+
protected checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
34
|
+
protected validatorClient?: ValidatorClient,
|
|
35
|
+
private l1Metrics?: L1Metrics,
|
|
36
|
+
private delayer_?: Delayer,
|
|
37
|
+
) {}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Initializes
|
|
40
|
+
* Initializes a new instance.
|
|
41
41
|
* @param config - Configuration for the sequencer, publisher, and L1 tx sender.
|
|
42
42
|
* @param p2pClient - P2P client that provides the txs to be sequenced.
|
|
43
43
|
* @param validatorClient - Validator client performs attestation duties when rotating proposers.
|
|
@@ -46,25 +46,27 @@ export class SequencerClient {
|
|
|
46
46
|
* @param l2BlockSource - Provides information about the previously published blocks.
|
|
47
47
|
* @param l1ToL2MessageSource - Provides access to L1 to L2 messages.
|
|
48
48
|
* @param prover - An instance of a block prover
|
|
49
|
-
* @param simulationProvider - An instance of a simulation provider
|
|
50
49
|
* @returns A new running instance.
|
|
51
50
|
*/
|
|
52
51
|
public static async new(
|
|
53
52
|
config: SequencerClientConfig,
|
|
54
53
|
deps: {
|
|
55
|
-
validatorClient: ValidatorClient
|
|
54
|
+
validatorClient: ValidatorClient;
|
|
56
55
|
p2pClient: P2P;
|
|
57
56
|
worldStateSynchronizer: WorldStateSynchronizer;
|
|
58
|
-
slasherClient:
|
|
59
|
-
|
|
60
|
-
l2BlockSource: L2BlockSource;
|
|
57
|
+
slasherClient: SlasherClientInterface | undefined;
|
|
58
|
+
checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
59
|
+
l2BlockSource: L2BlockSource & L2BlockSink & ProposedCheckpointSink;
|
|
61
60
|
l1ToL2MessageSource: L1ToL2MessageSource;
|
|
62
61
|
telemetry: TelemetryClient;
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
publisherFactory?: SequencerPublisherFactory;
|
|
63
|
+
blobClient: BlobClientInterface;
|
|
65
64
|
dateProvider: DateProvider;
|
|
66
65
|
epochCache?: EpochCache;
|
|
67
|
-
l1TxUtils
|
|
66
|
+
l1TxUtils: L1TxUtils[];
|
|
67
|
+
funderL1TxUtils?: L1TxUtils;
|
|
68
|
+
nodeKeyStore: KeystoreManager;
|
|
69
|
+
globalVariableBuilder: GlobalVariableBuilder;
|
|
68
70
|
},
|
|
69
71
|
) {
|
|
70
72
|
const {
|
|
@@ -72,118 +74,127 @@ export class SequencerClient {
|
|
|
72
74
|
p2pClient,
|
|
73
75
|
worldStateSynchronizer,
|
|
74
76
|
slasherClient,
|
|
75
|
-
|
|
77
|
+
checkpointsBuilder,
|
|
76
78
|
l2BlockSource,
|
|
77
79
|
l1ToL2MessageSource,
|
|
78
80
|
telemetry: telemetryClient,
|
|
79
81
|
} = deps;
|
|
80
|
-
const { l1RpcUrls: rpcUrls, l1ChainId: chainId
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
const { l1RpcUrls: rpcUrls, l1ChainId: chainId } = config;
|
|
83
|
+
const log = createLogger('sequencer');
|
|
84
|
+
const publicClient = getPublicClient(config);
|
|
85
|
+
const l1TxUtils = deps.l1TxUtils;
|
|
86
|
+
const l1Metrics = new L1Metrics(
|
|
87
|
+
telemetryClient.getMeter('L1PublisherMetrics'),
|
|
88
|
+
publicClient,
|
|
89
|
+
l1TxUtils.map(x => x.getSenderAddress()),
|
|
90
|
+
);
|
|
91
|
+
const publisherManager = new PublisherManager(l1TxUtils, getPublisherConfigFromSequencerConfig(config), {
|
|
92
|
+
bindings: log.getBindings(),
|
|
93
|
+
funder: deps.funderL1TxUtils,
|
|
94
|
+
});
|
|
95
|
+
const rollupContract = new RollupContract(publicClient, config.rollupAddress.toString());
|
|
96
|
+
const [l1GenesisTime, slotDuration, rollupManaLimit] = await Promise.all([
|
|
87
97
|
rollupContract.getL1GenesisTime(),
|
|
88
98
|
rollupContract.getSlotDuration(),
|
|
99
|
+
rollupContract.getManaLimit().then(Number),
|
|
89
100
|
] as const);
|
|
90
|
-
const forwarderContract =
|
|
91
|
-
config.customForwarderContractAddress && config.customForwarderContractAddress !== EthAddress.ZERO
|
|
92
|
-
? new ForwarderContract(
|
|
93
|
-
publicClient,
|
|
94
|
-
config.customForwarderContractAddress.toString(),
|
|
95
|
-
config.l1Contracts.rollupAddress.toString(),
|
|
96
|
-
)
|
|
97
|
-
: await ForwarderContract.create(
|
|
98
|
-
walletClient.account.address,
|
|
99
|
-
walletClient,
|
|
100
|
-
publicClient,
|
|
101
|
-
log,
|
|
102
|
-
config.l1Contracts.rollupAddress.toString(),
|
|
103
|
-
);
|
|
104
101
|
|
|
105
102
|
const governanceProposerContract = new GovernanceProposerContract(
|
|
106
103
|
publicClient,
|
|
107
|
-
config.
|
|
104
|
+
config.governanceProposerAddress.toString(),
|
|
108
105
|
);
|
|
109
|
-
const slashingProposerAddress = await rollupContract.getSlashingProposerAddress();
|
|
110
|
-
const slashingProposerContract = new SlashingProposerContract(publicClient, slashingProposerAddress.toString());
|
|
111
106
|
const epochCache =
|
|
112
107
|
deps.epochCache ??
|
|
113
108
|
(await EpochCache.create(
|
|
114
|
-
config.
|
|
109
|
+
config.rollupAddress,
|
|
115
110
|
{
|
|
116
111
|
l1RpcUrls: rpcUrls,
|
|
117
112
|
l1ChainId: chainId,
|
|
118
113
|
viemPollingIntervalMS: config.viemPollingIntervalMS,
|
|
119
|
-
aztecSlotDuration: config.aztecSlotDuration,
|
|
120
114
|
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
121
|
-
aztecEpochDuration: config.aztecEpochDuration,
|
|
122
115
|
},
|
|
123
116
|
{ dateProvider: deps.dateProvider },
|
|
124
117
|
));
|
|
125
118
|
|
|
126
|
-
const
|
|
127
|
-
deps.
|
|
128
|
-
new
|
|
129
|
-
l1TxUtils,
|
|
119
|
+
const publisherFactory =
|
|
120
|
+
deps.publisherFactory ??
|
|
121
|
+
new SequencerPublisherFactory(config, {
|
|
130
122
|
telemetry: telemetryClient,
|
|
131
|
-
|
|
132
|
-
rollupContract,
|
|
123
|
+
blobClient: deps.blobClient,
|
|
133
124
|
epochCache,
|
|
134
|
-
forwarderContract,
|
|
135
125
|
governanceProposerContract,
|
|
136
|
-
|
|
126
|
+
rollupContract,
|
|
127
|
+
dateProvider: deps.dateProvider,
|
|
128
|
+
publisherManager,
|
|
129
|
+
nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(deps.nodeKeyStore),
|
|
130
|
+
logger: log,
|
|
137
131
|
});
|
|
138
|
-
const globalsBuilder = new GlobalVariableBuilder(config);
|
|
139
|
-
|
|
140
|
-
const publicProcessorFactory = new PublicProcessorFactory(contractDataSource, deps.dateProvider, telemetryClient);
|
|
141
132
|
|
|
142
133
|
const ethereumSlotDuration = config.ethereumSlotDuration;
|
|
143
134
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
//
|
|
135
|
+
const globalsBuilder = deps.globalVariableBuilder;
|
|
136
|
+
|
|
137
|
+
// When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
|
|
138
|
+
// Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
|
|
147
139
|
// In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
|
|
148
|
-
//
|
|
140
|
+
// reduce the publishing time allowance. However, we prefer being conservative.
|
|
149
141
|
// See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
|
|
150
|
-
const
|
|
151
|
-
|
|
142
|
+
const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
|
|
143
|
+
const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
|
|
144
|
+
|
|
145
|
+
const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = capPerBlockLimits(config, rollupManaLimit, log);
|
|
152
146
|
|
|
153
147
|
const l1Constants = {
|
|
154
148
|
l1GenesisTime,
|
|
155
149
|
slotDuration: Number(slotDuration),
|
|
156
150
|
ethereumSlotDuration,
|
|
151
|
+
rollupManaLimit,
|
|
152
|
+
epochDuration: config.aztecEpochDuration,
|
|
157
153
|
};
|
|
158
154
|
|
|
159
155
|
const sequencer = new Sequencer(
|
|
160
|
-
|
|
156
|
+
publisherFactory,
|
|
161
157
|
validatorClient,
|
|
162
158
|
globalsBuilder,
|
|
163
159
|
p2pClient,
|
|
164
160
|
worldStateSynchronizer,
|
|
165
161
|
slasherClient,
|
|
166
|
-
new LightweightBlockBuilderFactory(telemetryClient),
|
|
167
162
|
l2BlockSource,
|
|
168
163
|
l1ToL2MessageSource,
|
|
169
|
-
|
|
170
|
-
contractDataSource,
|
|
164
|
+
checkpointsBuilder,
|
|
171
165
|
l1Constants,
|
|
172
166
|
deps.dateProvider,
|
|
173
|
-
|
|
167
|
+
epochCache,
|
|
168
|
+
rollupContract,
|
|
169
|
+
{ ...config, l1PublishingTime, maxL2BlockGas, maxDABlockGas, maxTxsPerBlock },
|
|
174
170
|
telemetryClient,
|
|
171
|
+
log,
|
|
175
172
|
);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
|
|
174
|
+
sequencer.init();
|
|
175
|
+
|
|
176
|
+
// Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
|
|
177
|
+
const delayer = l1TxUtils[0]?.delayer;
|
|
178
|
+
|
|
179
|
+
return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics, delayer);
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
/**
|
|
182
|
-
* Updates sequencer config.
|
|
183
|
+
* Updates sequencer and validator client config.
|
|
183
184
|
* @param config - New parameters.
|
|
184
185
|
*/
|
|
185
|
-
public
|
|
186
|
-
|
|
186
|
+
public updateConfig(config: SequencerConfig & Partial<ValidatorClientFullConfig>) {
|
|
187
|
+
this.sequencer.updateConfig(config);
|
|
188
|
+
this.checkpointsBuilder.updateConfig(config);
|
|
189
|
+
this.validatorClient?.updateConfig(config);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Starts the sequencer. */
|
|
193
|
+
public async start() {
|
|
194
|
+
await this.validatorClient?.start();
|
|
195
|
+
this.sequencer.start();
|
|
196
|
+
this.l1Metrics?.start();
|
|
197
|
+
await this.publisherManager.start();
|
|
187
198
|
}
|
|
188
199
|
|
|
189
200
|
/**
|
|
@@ -191,29 +202,73 @@ export class SequencerClient {
|
|
|
191
202
|
*/
|
|
192
203
|
public async stop() {
|
|
193
204
|
await this.sequencer.stop();
|
|
205
|
+
await this.validatorClient?.stop();
|
|
206
|
+
await this.publisherManager.stop();
|
|
207
|
+
this.l1Metrics?.stop();
|
|
194
208
|
}
|
|
195
209
|
|
|
196
|
-
/**
|
|
197
|
-
public
|
|
198
|
-
this.sequencer.
|
|
210
|
+
/** Triggers an immediate run of the sequencer, bypassing the polling interval. */
|
|
211
|
+
public trigger() {
|
|
212
|
+
return this.sequencer.trigger();
|
|
199
213
|
}
|
|
200
214
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
*/
|
|
204
|
-
public restart() {
|
|
205
|
-
this.sequencer.restart();
|
|
215
|
+
public getSequencer(): Sequencer {
|
|
216
|
+
return this.sequencer;
|
|
206
217
|
}
|
|
207
218
|
|
|
208
|
-
|
|
209
|
-
|
|
219
|
+
/** Updates the publisher factory's node keystore adapter after a keystore reload. */
|
|
220
|
+
public updatePublisherNodeKeyStore(adapter: NodeKeystoreAdapter): void {
|
|
221
|
+
this.sequencer.updatePublisherNodeKeyStore(adapter);
|
|
210
222
|
}
|
|
211
223
|
|
|
212
|
-
|
|
213
|
-
|
|
224
|
+
/** Returns the shared tx delayer for sequencer L1 txs, if enabled. Test-only. */
|
|
225
|
+
getDelayer(): Delayer | undefined {
|
|
226
|
+
return this.delayer_;
|
|
214
227
|
}
|
|
215
228
|
|
|
216
|
-
get
|
|
217
|
-
return this.sequencer.
|
|
229
|
+
get validatorAddresses(): EthAddress[] | undefined {
|
|
230
|
+
return this.sequencer.getValidatorAddresses();
|
|
218
231
|
}
|
|
232
|
+
|
|
233
|
+
get maxL2BlockGas(): number | undefined {
|
|
234
|
+
return this.sequencer.maxL2BlockGas;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Caps operator-provided per-block limits at checkpoint-level limits.
|
|
240
|
+
* Returns undefined for any limit the operator didn't set — the checkpoint builder handles redistribution.
|
|
241
|
+
*/
|
|
242
|
+
function capPerBlockLimits(
|
|
243
|
+
config: SequencerClientConfig,
|
|
244
|
+
rollupManaLimit: number,
|
|
245
|
+
log: ReturnType<typeof createLogger>,
|
|
246
|
+
): { maxL2BlockGas: number | undefined; maxDABlockGas: number | undefined; maxTxsPerBlock: number | undefined } {
|
|
247
|
+
let maxL2BlockGas = config.maxL2BlockGas;
|
|
248
|
+
if (maxL2BlockGas !== undefined && maxL2BlockGas > rollupManaLimit) {
|
|
249
|
+
log.warn(`Provided MAX_L2_BLOCK_GAS ${maxL2BlockGas} exceeds rollup mana limit ${rollupManaLimit} (capping)`);
|
|
250
|
+
maxL2BlockGas = rollupManaLimit;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
let maxDABlockGas = config.maxDABlockGas;
|
|
254
|
+
if (maxDABlockGas !== undefined && maxDABlockGas > MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT) {
|
|
255
|
+
log.warn(
|
|
256
|
+
`Provided MAX_DA_BLOCK_GAS ${maxDABlockGas} exceeds DA checkpoint limit ${MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT} (capping)`,
|
|
257
|
+
);
|
|
258
|
+
maxDABlockGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
let maxTxsPerBlock = config.maxTxsPerBlock;
|
|
262
|
+
if (
|
|
263
|
+
maxTxsPerBlock !== undefined &&
|
|
264
|
+
config.maxTxsPerCheckpoint !== undefined &&
|
|
265
|
+
maxTxsPerBlock > config.maxTxsPerCheckpoint
|
|
266
|
+
) {
|
|
267
|
+
log.warn(
|
|
268
|
+
`Provided MAX_TX_PER_BLOCK ${maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`,
|
|
269
|
+
);
|
|
270
|
+
maxTxsPerBlock = config.maxTxsPerCheckpoint;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock };
|
|
219
274
|
}
|