@aztec/sequencer-client 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107
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/dest/client/index.d.ts +1 -1
- package/dest/client/sequencer-client.d.ts +10 -8
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +40 -28
- package/dest/config.d.ts +13 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +82 -25
- package/dest/global_variable_builder/global_builder.d.ts +19 -13
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +41 -28
- package/dest/global_variable_builder/index.d.ts +1 -1
- 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 +11 -8
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +21 -13
- package/dest/publisher/index.d.ts +2 -2
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +1 -1
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +9 -2
- package/dest/publisher/sequencer-publisher-metrics.d.ts +4 -4
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +1 -1
- package/dest/publisher/sequencer-publisher.d.ts +76 -69
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +290 -180
- package/dest/sequencer/block_builder.d.ts +6 -10
- package/dest/sequencer/block_builder.d.ts.map +1 -1
- package/dest/sequencer/block_builder.js +21 -10
- package/dest/sequencer/checkpoint_builder.d.ts +63 -0
- package/dest/sequencer/checkpoint_builder.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_builder.js +131 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +74 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job.js +642 -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 +85 -0
- package/dest/sequencer/config.d.ts +3 -2
- 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 +46 -0
- package/dest/sequencer/events.d.ts.map +1 -0
- package/dest/sequencer/events.js +1 -0
- package/dest/sequencer/index.d.ts +5 -1
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +4 -0
- package/dest/sequencer/metrics.d.ts +37 -20
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +211 -85
- package/dest/sequencer/sequencer.d.ts +109 -121
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +798 -525
- package/dest/sequencer/timetable.d.ts +57 -21
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +150 -68
- 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 -28
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +12 -24
- package/dest/test/index.d.ts +4 -2
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +83 -0
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -0
- package/dest/test/mock_checkpoint_builder.js +179 -0
- package/dest/test/utils.d.ts +49 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +94 -0
- package/dest/tx_validator/nullifier_cache.d.ts +1 -1
- package/dest/tx_validator/nullifier_cache.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.d.ts +4 -3
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +12 -9
- package/package.json +32 -31
- package/src/client/sequencer-client.ts +34 -40
- package/src/config.ts +89 -29
- package/src/global_variable_builder/global_builder.ts +56 -48
- package/src/index.ts +2 -0
- package/src/publisher/config.ts +32 -19
- package/src/publisher/index.ts +1 -1
- package/src/publisher/sequencer-publisher-factory.ts +19 -6
- package/src/publisher/sequencer-publisher-metrics.ts +3 -3
- package/src/publisher/sequencer-publisher.ts +410 -240
- package/src/sequencer/README.md +531 -0
- package/src/sequencer/block_builder.ts +28 -30
- package/src/sequencer/checkpoint_builder.ts +217 -0
- package/src/sequencer/checkpoint_proposal_job.ts +706 -0
- package/src/sequencer/checkpoint_voter.ts +105 -0
- package/src/sequencer/config.ts +2 -1
- package/src/sequencer/errors.ts +21 -0
- package/src/sequencer/events.ts +27 -0
- package/src/sequencer/index.ts +4 -0
- package/src/sequencer/metrics.ts +269 -94
- package/src/sequencer/sequencer.ts +506 -676
- package/src/sequencer/timetable.ts +181 -91
- package/src/sequencer/types.ts +6 -0
- package/src/sequencer/utils.ts +24 -29
- package/src/test/index.ts +3 -1
- package/src/test/mock_checkpoint_builder.ts +247 -0
- package/src/test/utils.ts +137 -0
- package/src/tx_validator/tx_validator_factory.ts +13 -7
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
2
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
RollupContract,
|
|
7
|
-
getPublicClient,
|
|
8
|
-
isAnvilTestChain,
|
|
9
|
-
} from '@aztec/ethereum';
|
|
3
|
+
import { isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
4
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
5
|
+
import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
10
6
|
import { L1TxUtilsWithBlobs } from '@aztec/ethereum/l1-tx-utils-with-blobs';
|
|
7
|
+
import { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
11
8
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
13
10
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
@@ -15,11 +12,7 @@ import type { KeystoreManager } from '@aztec/node-keystore';
|
|
|
15
12
|
import type { P2P } from '@aztec/p2p';
|
|
16
13
|
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
17
14
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
18
|
-
import type {
|
|
19
|
-
IFullNodeBlockBuilder,
|
|
20
|
-
ValidatorClientFullConfig,
|
|
21
|
-
WorldStateSynchronizer,
|
|
22
|
-
} from '@aztec/stdlib/interfaces/server';
|
|
15
|
+
import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
23
16
|
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
24
17
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
25
18
|
import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
|
|
@@ -28,6 +21,7 @@ import { NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-clie
|
|
|
28
21
|
import type { SequencerClientConfig } from '../config.js';
|
|
29
22
|
import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
30
23
|
import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
24
|
+
import { FullNodeCheckpointsBuilder } from '../sequencer/checkpoint_builder.js';
|
|
31
25
|
import { Sequencer, type SequencerConfig } from '../sequencer/index.js';
|
|
32
26
|
|
|
33
27
|
/**
|
|
@@ -37,6 +31,7 @@ export class SequencerClient {
|
|
|
37
31
|
constructor(
|
|
38
32
|
protected publisherManager: PublisherManager<L1TxUtilsWithBlobs>,
|
|
39
33
|
protected sequencer: Sequencer,
|
|
34
|
+
protected checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
40
35
|
protected validatorClient?: ValidatorClient,
|
|
41
36
|
private l1Metrics?: L1Metrics,
|
|
42
37
|
) {}
|
|
@@ -56,16 +51,16 @@ export class SequencerClient {
|
|
|
56
51
|
public static async new(
|
|
57
52
|
config: SequencerClientConfig,
|
|
58
53
|
deps: {
|
|
59
|
-
validatorClient: ValidatorClient
|
|
54
|
+
validatorClient: ValidatorClient;
|
|
60
55
|
p2pClient: P2P;
|
|
61
56
|
worldStateSynchronizer: WorldStateSynchronizer;
|
|
62
57
|
slasherClient: SlasherClientInterface | undefined;
|
|
63
|
-
|
|
58
|
+
checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
64
59
|
l2BlockSource: L2BlockSource;
|
|
65
60
|
l1ToL2MessageSource: L1ToL2MessageSource;
|
|
66
61
|
telemetry: TelemetryClient;
|
|
67
62
|
publisherFactory?: SequencerPublisherFactory;
|
|
68
|
-
|
|
63
|
+
blobClient: BlobClientInterface;
|
|
69
64
|
dateProvider: DateProvider;
|
|
70
65
|
epochCache?: EpochCache;
|
|
71
66
|
l1TxUtils: L1TxUtilsWithBlobs[];
|
|
@@ -77,13 +72,13 @@ export class SequencerClient {
|
|
|
77
72
|
p2pClient,
|
|
78
73
|
worldStateSynchronizer,
|
|
79
74
|
slasherClient,
|
|
80
|
-
|
|
75
|
+
checkpointsBuilder,
|
|
81
76
|
l2BlockSource,
|
|
82
77
|
l1ToL2MessageSource,
|
|
83
78
|
telemetry: telemetryClient,
|
|
84
79
|
} = deps;
|
|
85
80
|
const { l1RpcUrls: rpcUrls, l1ChainId: chainId } = config;
|
|
86
|
-
const log = createLogger('sequencer
|
|
81
|
+
const log = createLogger('sequencer');
|
|
87
82
|
const publicClient = getPublicClient(config);
|
|
88
83
|
const l1TxUtils = deps.l1TxUtils;
|
|
89
84
|
const l1Metrics = new L1Metrics(
|
|
@@ -91,11 +86,13 @@ export class SequencerClient {
|
|
|
91
86
|
publicClient,
|
|
92
87
|
l1TxUtils.map(x => x.getSenderAddress()),
|
|
93
88
|
);
|
|
94
|
-
const publisherManager = new PublisherManager(l1TxUtils);
|
|
89
|
+
const publisherManager = new PublisherManager(l1TxUtils, config);
|
|
95
90
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
96
|
-
const [l1GenesisTime, slotDuration] = await Promise.all([
|
|
91
|
+
const [l1GenesisTime, slotDuration, rollupVersion, rollupManaLimit] = await Promise.all([
|
|
97
92
|
rollupContract.getL1GenesisTime(),
|
|
98
93
|
rollupContract.getSlotDuration(),
|
|
94
|
+
rollupContract.getVersion(),
|
|
95
|
+
rollupContract.getManaLimit().then(Number),
|
|
99
96
|
] as const);
|
|
100
97
|
|
|
101
98
|
const governanceProposerContract = new GovernanceProposerContract(
|
|
@@ -110,9 +107,7 @@ export class SequencerClient {
|
|
|
110
107
|
l1RpcUrls: rpcUrls,
|
|
111
108
|
l1ChainId: chainId,
|
|
112
109
|
viemPollingIntervalMS: config.viemPollingIntervalMS,
|
|
113
|
-
aztecSlotDuration: config.aztecSlotDuration,
|
|
114
110
|
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
115
|
-
aztecEpochDuration: config.aztecEpochDuration,
|
|
116
111
|
},
|
|
117
112
|
{ dateProvider: deps.dateProvider },
|
|
118
113
|
));
|
|
@@ -126,7 +121,7 @@ export class SequencerClient {
|
|
|
126
121
|
deps.publisherFactory ??
|
|
127
122
|
new SequencerPublisherFactory(config, {
|
|
128
123
|
telemetry: telemetryClient,
|
|
129
|
-
|
|
124
|
+
blobClient: deps.blobClient,
|
|
130
125
|
epochCache,
|
|
131
126
|
governanceProposerContract,
|
|
132
127
|
slashFactoryContract,
|
|
@@ -134,34 +129,29 @@ export class SequencerClient {
|
|
|
134
129
|
dateProvider: deps.dateProvider,
|
|
135
130
|
publisherManager,
|
|
136
131
|
nodeKeyStore: NodeKeystoreAdapter.fromKeyStoreManager(deps.nodeKeyStore),
|
|
132
|
+
logger: log,
|
|
137
133
|
});
|
|
138
|
-
const globalsBuilder = new GlobalVariableBuilder(config);
|
|
139
134
|
|
|
140
135
|
const ethereumSlotDuration = config.ethereumSlotDuration;
|
|
136
|
+
const l1Constants = { l1GenesisTime, slotDuration: Number(slotDuration), ethereumSlotDuration };
|
|
137
|
+
|
|
138
|
+
const globalsBuilder = new GlobalVariableBuilder({ ...config, ...l1Constants, rollupVersion });
|
|
141
139
|
|
|
142
|
-
const rollupManaLimit = Number(await rollupContract.getManaLimit());
|
|
143
140
|
let sequencerManaLimit = config.maxL2BlockGas ?? rollupManaLimit;
|
|
144
141
|
if (sequencerManaLimit > rollupManaLimit) {
|
|
145
142
|
log.warn(
|
|
146
|
-
`Provided maxL2BlockGas
|
|
143
|
+
`Provided maxL2BlockGas ${sequencerManaLimit} is greater than the max allowed by L1. Setting limit to ${rollupManaLimit}.`,
|
|
147
144
|
);
|
|
148
145
|
sequencerManaLimit = rollupManaLimit;
|
|
149
146
|
}
|
|
150
147
|
|
|
151
148
|
// When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
|
|
152
|
-
// Otherwise,
|
|
153
|
-
// maxL1TxInclusionTimeIntoSlot of zero) to get the tx into that L1 slot.
|
|
149
|
+
// Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
|
|
154
150
|
// In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
|
|
155
|
-
//
|
|
151
|
+
// reduce the publishing time allowance. However, we prefer being conservative.
|
|
156
152
|
// See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const l1Constants = {
|
|
161
|
-
l1GenesisTime,
|
|
162
|
-
slotDuration: Number(slotDuration),
|
|
163
|
-
ethereumSlotDuration,
|
|
164
|
-
};
|
|
153
|
+
const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
|
|
154
|
+
const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
|
|
165
155
|
|
|
166
156
|
const sequencer = new Sequencer(
|
|
167
157
|
publisherFactory,
|
|
@@ -172,18 +162,19 @@ export class SequencerClient {
|
|
|
172
162
|
slasherClient,
|
|
173
163
|
l2BlockSource,
|
|
174
164
|
l1ToL2MessageSource,
|
|
175
|
-
|
|
165
|
+
checkpointsBuilder,
|
|
176
166
|
l1Constants,
|
|
177
167
|
deps.dateProvider,
|
|
178
168
|
epochCache,
|
|
179
169
|
rollupContract,
|
|
180
|
-
{ ...config,
|
|
170
|
+
{ ...config, l1PublishingTime, maxL2BlockGas: sequencerManaLimit },
|
|
181
171
|
telemetryClient,
|
|
172
|
+
log,
|
|
182
173
|
);
|
|
183
174
|
|
|
184
175
|
await sequencer.init();
|
|
185
176
|
|
|
186
|
-
return new SequencerClient(publisherManager, sequencer, validatorClient, l1Metrics);
|
|
177
|
+
return new SequencerClient(publisherManager, sequencer, checkpointsBuilder, validatorClient, l1Metrics);
|
|
187
178
|
}
|
|
188
179
|
|
|
189
180
|
/**
|
|
@@ -192,6 +183,7 @@ export class SequencerClient {
|
|
|
192
183
|
*/
|
|
193
184
|
public updateConfig(config: SequencerConfig & Partial<ValidatorClientFullConfig>) {
|
|
194
185
|
this.sequencer.updateConfig(config);
|
|
186
|
+
this.checkpointsBuilder.updateConfig(config);
|
|
195
187
|
this.validatorClient?.updateConfig(config);
|
|
196
188
|
}
|
|
197
189
|
|
|
@@ -200,6 +192,7 @@ export class SequencerClient {
|
|
|
200
192
|
await this.validatorClient?.start();
|
|
201
193
|
this.sequencer.start();
|
|
202
194
|
this.l1Metrics?.start();
|
|
195
|
+
await this.publisherManager.loadState();
|
|
203
196
|
}
|
|
204
197
|
|
|
205
198
|
/**
|
|
@@ -207,6 +200,7 @@ export class SequencerClient {
|
|
|
207
200
|
*/
|
|
208
201
|
public async stop() {
|
|
209
202
|
await this.sequencer.stop();
|
|
203
|
+
await this.validatorClient?.stop();
|
|
210
204
|
this.publisherManager.interrupt();
|
|
211
205
|
this.l1Metrics?.stop();
|
|
212
206
|
}
|
package/src/config.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type L1ReaderConfig,
|
|
4
|
-
l1ContractsConfigMappings,
|
|
5
|
-
l1ReaderConfigMappings,
|
|
6
|
-
} from '@aztec/ethereum';
|
|
1
|
+
import { type L1ContractsConfig, l1ContractsConfigMappings } from '@aztec/ethereum/config';
|
|
2
|
+
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
7
3
|
import {
|
|
8
4
|
type ConfigMappingsType,
|
|
9
5
|
booleanConfigHelper,
|
|
@@ -12,10 +8,12 @@ import {
|
|
|
12
8
|
pickConfigMappings,
|
|
13
9
|
} from '@aztec/foundation/config';
|
|
14
10
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
|
-
import { type
|
|
11
|
+
import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
|
|
12
|
+
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
16
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
17
14
|
import { type ChainConfig, type SequencerConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
18
|
-
import
|
|
15
|
+
import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
|
|
16
|
+
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
19
17
|
|
|
20
18
|
import {
|
|
21
19
|
type PublisherConfig,
|
|
@@ -29,10 +27,36 @@ export type { SequencerConfig };
|
|
|
29
27
|
|
|
30
28
|
export const DEFAULT_ATTESTATION_PROPAGATION_TIME = 2;
|
|
31
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Default values for SequencerConfig.
|
|
32
|
+
* Centralized location for all sequencer configuration defaults.
|
|
33
|
+
*/
|
|
34
|
+
export const DefaultSequencerConfig: ResolvedSequencerConfig = {
|
|
35
|
+
sequencerPollingIntervalMS: 500,
|
|
36
|
+
maxTxsPerBlock: 32,
|
|
37
|
+
minTxsPerBlock: 1,
|
|
38
|
+
buildCheckpointIfEmpty: false,
|
|
39
|
+
publishTxsWithProposals: false,
|
|
40
|
+
maxL2BlockGas: 10e9,
|
|
41
|
+
maxDABlockGas: 10e9,
|
|
42
|
+
maxBlockSizeInBytes: 1024 * 1024,
|
|
43
|
+
enforceTimeTable: true,
|
|
44
|
+
attestationPropagationTime: DEFAULT_ATTESTATION_PROPAGATION_TIME,
|
|
45
|
+
secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
|
|
46
|
+
secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
|
|
47
|
+
skipCollectingAttestations: false,
|
|
48
|
+
skipInvalidateBlockAsProposer: false,
|
|
49
|
+
broadcastInvalidBlockProposal: false,
|
|
50
|
+
injectFakeAttestation: false,
|
|
51
|
+
fishermanMode: false,
|
|
52
|
+
shuffleAttestationOrdering: false,
|
|
53
|
+
};
|
|
54
|
+
|
|
32
55
|
/**
|
|
33
56
|
* Configuration settings for the SequencerClient.
|
|
34
57
|
*/
|
|
35
58
|
export type SequencerClientConfig = PublisherConfig &
|
|
59
|
+
KeyStoreConfig &
|
|
36
60
|
ValidatorClientConfig &
|
|
37
61
|
TxSenderConfig &
|
|
38
62
|
SequencerConfig &
|
|
@@ -42,35 +66,39 @@ export type SequencerClientConfig = PublisherConfig &
|
|
|
42
66
|
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
|
|
43
67
|
|
|
44
68
|
export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
45
|
-
|
|
46
|
-
env: '
|
|
47
|
-
description: 'The number of ms to wait between polling for
|
|
48
|
-
...numberConfigHelper(
|
|
69
|
+
sequencerPollingIntervalMS: {
|
|
70
|
+
env: 'SEQ_POLLING_INTERVAL_MS',
|
|
71
|
+
description: 'The number of ms to wait between polling for checking to build on the next slot.',
|
|
72
|
+
...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
|
|
49
73
|
},
|
|
50
74
|
maxTxsPerBlock: {
|
|
51
75
|
env: 'SEQ_MAX_TX_PER_BLOCK',
|
|
52
76
|
description: 'The maximum number of txs to include in a block.',
|
|
53
|
-
...numberConfigHelper(
|
|
77
|
+
...numberConfigHelper(DefaultSequencerConfig.maxTxsPerBlock),
|
|
54
78
|
},
|
|
55
79
|
minTxsPerBlock: {
|
|
56
80
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
57
81
|
description: 'The minimum number of txs to include in a block.',
|
|
58
|
-
...numberConfigHelper(
|
|
82
|
+
...numberConfigHelper(DefaultSequencerConfig.minTxsPerBlock),
|
|
83
|
+
},
|
|
84
|
+
minValidTxsPerBlock: {
|
|
85
|
+
description:
|
|
86
|
+
'The minimum number of valid txs (after execution) to include in a block. If not set, falls back to minTxsPerBlock.',
|
|
59
87
|
},
|
|
60
88
|
publishTxsWithProposals: {
|
|
61
89
|
env: 'SEQ_PUBLISH_TXS_WITH_PROPOSALS',
|
|
62
90
|
description: 'Whether to publish txs with proposals.',
|
|
63
|
-
...booleanConfigHelper(
|
|
91
|
+
...booleanConfigHelper(DefaultSequencerConfig.publishTxsWithProposals),
|
|
64
92
|
},
|
|
65
93
|
maxL2BlockGas: {
|
|
66
94
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
67
95
|
description: 'The maximum L2 block gas.',
|
|
68
|
-
...numberConfigHelper(
|
|
96
|
+
...numberConfigHelper(DefaultSequencerConfig.maxL2BlockGas),
|
|
69
97
|
},
|
|
70
98
|
maxDABlockGas: {
|
|
71
99
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
72
100
|
description: 'The maximum DA block gas.',
|
|
73
|
-
...numberConfigHelper(
|
|
101
|
+
...numberConfigHelper(DefaultSequencerConfig.maxDABlockGas),
|
|
74
102
|
},
|
|
75
103
|
coinbase: {
|
|
76
104
|
env: 'COINBASE',
|
|
@@ -93,55 +121,86 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
93
121
|
maxBlockSizeInBytes: {
|
|
94
122
|
env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
|
|
95
123
|
description: 'Max block size',
|
|
96
|
-
...numberConfigHelper(
|
|
124
|
+
...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
|
|
97
125
|
},
|
|
98
126
|
enforceTimeTable: {
|
|
99
127
|
env: 'SEQ_ENFORCE_TIME_TABLE',
|
|
100
128
|
description: 'Whether to enforce the time table when building blocks',
|
|
101
|
-
...booleanConfigHelper(),
|
|
102
|
-
defaultValue: true,
|
|
129
|
+
...booleanConfigHelper(DefaultSequencerConfig.enforceTimeTable),
|
|
103
130
|
},
|
|
104
131
|
governanceProposerPayload: {
|
|
105
132
|
env: 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS',
|
|
106
133
|
description: 'The address of the payload for the governanceProposer',
|
|
107
134
|
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
108
|
-
defaultValue: EthAddress.ZERO,
|
|
109
135
|
},
|
|
110
|
-
|
|
111
|
-
env: '
|
|
112
|
-
description: 'How
|
|
136
|
+
l1PublishingTime: {
|
|
137
|
+
env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
|
|
138
|
+
description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
|
|
113
139
|
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
114
140
|
},
|
|
115
141
|
attestationPropagationTime: {
|
|
116
142
|
env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
|
|
117
143
|
description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way)',
|
|
118
|
-
...numberConfigHelper(
|
|
144
|
+
...numberConfigHelper(DefaultSequencerConfig.attestationPropagationTime),
|
|
119
145
|
},
|
|
120
146
|
fakeProcessingDelayPerTxMs: {
|
|
121
147
|
description: 'Used for testing to introduce a fake delay after processing each tx',
|
|
122
148
|
},
|
|
149
|
+
fakeThrowAfterProcessingTxCount: {
|
|
150
|
+
description: 'Used for testing to throw an error after processing N txs',
|
|
151
|
+
},
|
|
123
152
|
secondsBeforeInvalidatingBlockAsCommitteeMember: {
|
|
124
153
|
env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER',
|
|
125
154
|
description:
|
|
126
155
|
'How many seconds to wait before trying to invalidate a block from the pending chain as a committee member (zero to never invalidate).' +
|
|
127
156
|
' The next proposer is expected to invalidate, so the committee acts as a fallback.',
|
|
128
|
-
...numberConfigHelper(
|
|
157
|
+
...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsCommitteeMember),
|
|
129
158
|
},
|
|
130
159
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: {
|
|
131
160
|
env: 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER',
|
|
132
161
|
description:
|
|
133
162
|
'How many seconds to wait before trying to invalidate a block from the pending chain as a non-committee member (zero to never invalidate).' +
|
|
134
163
|
' The next proposer is expected to invalidate, then the committee, so other sequencers act as a fallback.',
|
|
135
|
-
...numberConfigHelper(
|
|
164
|
+
...numberConfigHelper(DefaultSequencerConfig.secondsBeforeInvalidatingBlockAsNonCommitteeMember),
|
|
136
165
|
},
|
|
137
166
|
skipCollectingAttestations: {
|
|
138
167
|
description:
|
|
139
168
|
'Whether to skip collecting attestations from validators and only use self-attestations (for testing only)',
|
|
140
|
-
...booleanConfigHelper(
|
|
169
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipCollectingAttestations),
|
|
141
170
|
},
|
|
142
171
|
skipInvalidateBlockAsProposer: {
|
|
143
172
|
description: 'Do not invalidate the previous block if invalid when we are the proposer (for testing only)',
|
|
144
|
-
...booleanConfigHelper(
|
|
173
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipInvalidateBlockAsProposer),
|
|
174
|
+
},
|
|
175
|
+
broadcastInvalidBlockProposal: {
|
|
176
|
+
description: 'Broadcast invalid block proposals with corrupted state (for testing only)',
|
|
177
|
+
...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidBlockProposal),
|
|
178
|
+
},
|
|
179
|
+
injectFakeAttestation: {
|
|
180
|
+
description: 'Inject a fake attestation (for testing only)',
|
|
181
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
|
|
182
|
+
},
|
|
183
|
+
fishermanMode: {
|
|
184
|
+
env: 'FISHERMAN_MODE',
|
|
185
|
+
description:
|
|
186
|
+
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
187
|
+
...booleanConfigHelper(DefaultSequencerConfig.fishermanMode),
|
|
188
|
+
},
|
|
189
|
+
shuffleAttestationOrdering: {
|
|
190
|
+
description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
|
|
191
|
+
...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
|
|
192
|
+
},
|
|
193
|
+
blockDurationMs: {
|
|
194
|
+
env: 'SEQ_BLOCK_DURATION_MS',
|
|
195
|
+
description:
|
|
196
|
+
'Duration per block in milliseconds when building multiple blocks per slot. ' +
|
|
197
|
+
'If undefined (default), builds a single block per slot using the full slot duration.',
|
|
198
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
199
|
+
},
|
|
200
|
+
buildCheckpointIfEmpty: {
|
|
201
|
+
env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
|
|
202
|
+
description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
|
|
203
|
+
...booleanConfigHelper(DefaultSequencerConfig.buildCheckpointIfEmpty),
|
|
145
204
|
},
|
|
146
205
|
...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
|
|
147
206
|
};
|
|
@@ -149,6 +208,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
149
208
|
export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
|
|
150
209
|
...validatorClientConfigMappings,
|
|
151
210
|
...sequencerConfigMappings,
|
|
211
|
+
...keyStoreConfigMappings,
|
|
152
212
|
...l1ReaderConfigMappings,
|
|
153
213
|
...getTxSenderConfigMappings('SEQ'),
|
|
154
214
|
...getPublisherConfigMappings('SEQ'),
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@aztec/
|
|
1
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
2
|
+
import type { L1ContractsConfig } from '@aztec/ethereum/config';
|
|
3
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
4
|
+
import type { L1ReaderConfig } from '@aztec/ethereum/l1-reader';
|
|
5
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
6
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
7
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
8
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
10
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
11
10
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
+
import { type L1RollupConstants, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
12
12
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
13
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
CheckpointGlobalVariables,
|
|
15
|
+
GlobalVariableBuilder as GlobalVariableBuilderInterface,
|
|
16
|
+
} from '@aztec/stdlib/tx';
|
|
14
17
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
15
18
|
|
|
16
19
|
import { createPublicClient, fallback, http } from 'viem';
|
|
@@ -26,20 +29,31 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
26
29
|
private readonly rollupContract: RollupContract;
|
|
27
30
|
private readonly publicClient: ViemPublicClient;
|
|
28
31
|
private readonly ethereumSlotDuration: number;
|
|
32
|
+
private readonly aztecSlotDuration: number;
|
|
33
|
+
private readonly l1GenesisTime: bigint;
|
|
29
34
|
|
|
30
|
-
private chainId
|
|
31
|
-
private version
|
|
35
|
+
private chainId: Fr;
|
|
36
|
+
private version: Fr;
|
|
32
37
|
|
|
33
|
-
constructor(
|
|
38
|
+
constructor(
|
|
39
|
+
config: L1ReaderConfig &
|
|
40
|
+
Pick<L1ContractsConfig, 'ethereumSlotDuration'> &
|
|
41
|
+
Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'> & { rollupVersion: bigint },
|
|
42
|
+
) {
|
|
34
43
|
const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
|
|
35
44
|
|
|
36
45
|
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
37
46
|
|
|
47
|
+
this.version = new Fr(config.rollupVersion);
|
|
48
|
+
this.chainId = new Fr(chainId);
|
|
49
|
+
|
|
38
50
|
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
51
|
+
this.aztecSlotDuration = config.slotDuration;
|
|
52
|
+
this.l1GenesisTime = config.l1GenesisTime;
|
|
39
53
|
|
|
40
54
|
this.publicClient = createPublicClient({
|
|
41
55
|
chain: chain.chainInfo,
|
|
42
|
-
transport: fallback(chain.rpcUrls.map(url => http(url))),
|
|
56
|
+
transport: fallback(chain.rpcUrls.map(url => http(url, { batch: false }))),
|
|
43
57
|
pollingInterval: config.viemPollingIntervalMS,
|
|
44
58
|
});
|
|
45
59
|
|
|
@@ -55,8 +69,10 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
55
69
|
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
56
70
|
// The timestamp of that last block will act as a lower bound for the next block.
|
|
57
71
|
|
|
58
|
-
const lastBlock = await this.rollupContract.
|
|
59
|
-
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
72
|
+
const lastBlock = await this.rollupContract.getPendingCheckpoint();
|
|
73
|
+
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
74
|
+
SlotNumber.fromBigInt(BigInt(lastBlock.slotNumber) + 1n),
|
|
75
|
+
);
|
|
60
76
|
const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));
|
|
61
77
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
62
78
|
|
|
@@ -75,18 +91,8 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
75
91
|
return this.currentBaseFees;
|
|
76
92
|
}
|
|
77
93
|
|
|
78
|
-
public async getGlobalConstantVariables(): Promise<Pick<GlobalVariables, 'chainId' | 'version'>> {
|
|
79
|
-
if (!this.chainId) {
|
|
80
|
-
this.chainId = new Fr(this.publicClient.chain.id);
|
|
81
|
-
}
|
|
82
|
-
if (!this.version) {
|
|
83
|
-
this.version = new Fr(await this.rollupContract.getVersion());
|
|
84
|
-
}
|
|
85
|
-
return { chainId: this.chainId, version: this.version };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
94
|
/**
|
|
89
|
-
* Simple builder of global variables
|
|
95
|
+
* Simple builder of global variables.
|
|
90
96
|
* @param blockNumber - The block number to build global variables for.
|
|
91
97
|
* @param coinbase - The address to receive block reward.
|
|
92
98
|
* @param feeRecipient - The address to receive fees.
|
|
@@ -94,36 +100,38 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
94
100
|
* @returns The global variables for the given block number.
|
|
95
101
|
*/
|
|
96
102
|
public async buildGlobalVariables(
|
|
97
|
-
blockNumber:
|
|
103
|
+
blockNumber: BlockNumber,
|
|
98
104
|
coinbase: EthAddress,
|
|
99
105
|
feeRecipient: AztecAddress,
|
|
100
|
-
|
|
106
|
+
maybeSlot?: SlotNumber,
|
|
101
107
|
): Promise<GlobalVariables> {
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
const slot: SlotNumber =
|
|
109
|
+
maybeSlot ??
|
|
110
|
+
(await this.rollupContract.getSlotAt(
|
|
111
|
+
BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration)),
|
|
112
|
+
));
|
|
113
|
+
|
|
114
|
+
const checkpointGlobalVariables = await this.buildCheckpointGlobalVariables(coinbase, feeRecipient, slot);
|
|
115
|
+
return GlobalVariables.from({ blockNumber, ...checkpointGlobalVariables });
|
|
116
|
+
}
|
|
108
117
|
|
|
109
|
-
|
|
118
|
+
/** Builds global variables that are constant throughout a checkpoint. */
|
|
119
|
+
public async buildCheckpointGlobalVariables(
|
|
120
|
+
coinbase: EthAddress,
|
|
121
|
+
feeRecipient: AztecAddress,
|
|
122
|
+
slotNumber: SlotNumber,
|
|
123
|
+
): Promise<CheckpointGlobalVariables & { timestamp: bigint }> {
|
|
124
|
+
const { chainId, version } = this;
|
|
110
125
|
|
|
111
|
-
const
|
|
126
|
+
const timestamp = getTimestampForSlot(slotNumber, {
|
|
127
|
+
slotDuration: this.aztecSlotDuration,
|
|
128
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
129
|
+
});
|
|
112
130
|
|
|
113
131
|
// We can skip much of the logic in getCurrentBaseFees since it we already check that we are not within a slot elsewhere.
|
|
132
|
+
// TODO(palla/mbps): Can we use a cached value here?
|
|
114
133
|
const gasFees = new GasFees(0, await this.rollupContract.getManaBaseFeeAt(timestamp, true));
|
|
115
134
|
|
|
116
|
-
|
|
117
|
-
chainId,
|
|
118
|
-
version,
|
|
119
|
-
blockNumber,
|
|
120
|
-
slotFr,
|
|
121
|
-
timestamp,
|
|
122
|
-
coinbase,
|
|
123
|
-
feeRecipient,
|
|
124
|
-
gasFees,
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
return globalVariables;
|
|
135
|
+
return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
|
|
128
136
|
}
|
|
129
137
|
}
|
package/src/index.ts
CHANGED