@aztec/sequencer-client 0.0.1-commit.fffb133c → 0.0.1-dev
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/sequencer-client.d.ts +16 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +56 -23
- package/dest/config.d.ts +25 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +46 -28
- package/dest/global_variable_builder/global_builder.d.ts +14 -10
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +22 -21
- package/dest/global_variable_builder/index.d.ts +2 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +31 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +101 -42
- package/dest/publisher/sequencer-publisher-factory.d.ts +11 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +13 -2
- package/dest/publisher/sequencer-publisher-metrics.d.ts +1 -1
- package/dest/publisher/sequencer-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-metrics.js +12 -4
- package/dest/publisher/sequencer-publisher.d.ts +28 -14
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +137 -74
- package/dest/sequencer/checkpoint_proposal_job.d.ts +35 -10
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +212 -137
- 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/metrics.d.ts +17 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +111 -30
- package/dest/sequencer/sequencer.d.ts +29 -13
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +48 -44
- package/dest/sequencer/timetable.d.ts +4 -6
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +7 -11
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +3 -5
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +12 -12
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +47 -36
- package/dest/test/utils.d.ts +3 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +5 -4
- package/package.json +28 -28
- package/src/client/sequencer-client.ts +78 -21
- package/src/config.ts +61 -38
- package/src/global_variable_builder/global_builder.ts +23 -24
- package/src/global_variable_builder/index.ts +1 -1
- package/src/publisher/config.ts +112 -43
- package/src/publisher/sequencer-publisher-factory.ts +23 -6
- package/src/publisher/sequencer-publisher-metrics.ts +7 -3
- package/src/publisher/sequencer-publisher.ts +149 -90
- package/src/sequencer/checkpoint_proposal_job.ts +309 -186
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/metrics.ts +124 -32
- package/src/sequencer/sequencer.ts +61 -50
- package/src/sequencer/timetable.ts +13 -12
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +67 -53
- package/src/test/utils.ts +5 -2
package/src/config.ts
CHANGED
|
@@ -11,59 +11,64 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
11
11
|
import { type KeyStoreConfig, keyStoreConfigMappings } from '@aztec/node-keystore/config';
|
|
12
12
|
import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
13
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
type ChainConfig,
|
|
16
|
+
type SequencerConfig,
|
|
17
|
+
chainConfigMappings,
|
|
18
|
+
sharedSequencerConfigMappings,
|
|
19
|
+
} from '@aztec/stdlib/config';
|
|
15
20
|
import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
|
|
21
|
+
import { DEFAULT_P2P_PROPAGATION_TIME } from '@aztec/stdlib/timetable';
|
|
16
22
|
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
17
23
|
|
|
18
24
|
import {
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
type SequencerPublisherConfig,
|
|
26
|
+
type SequencerTxSenderConfig,
|
|
27
|
+
sequencerPublisherConfigMappings,
|
|
28
|
+
sequencerTxSenderConfigMappings,
|
|
23
29
|
} from './publisher/config.js';
|
|
24
30
|
|
|
25
31
|
export * from './publisher/config.js';
|
|
26
32
|
export type { SequencerConfig };
|
|
27
33
|
|
|
28
|
-
export const DEFAULT_ATTESTATION_PROPAGATION_TIME = 2;
|
|
29
|
-
|
|
30
34
|
/**
|
|
31
35
|
* Default values for SequencerConfig.
|
|
32
36
|
* Centralized location for all sequencer configuration defaults.
|
|
33
37
|
*/
|
|
34
|
-
export const DefaultSequencerConfig
|
|
38
|
+
export const DefaultSequencerConfig = {
|
|
35
39
|
sequencerPollingIntervalMS: 500,
|
|
36
|
-
maxTxsPerBlock: 32,
|
|
37
40
|
minTxsPerBlock: 1,
|
|
38
41
|
buildCheckpointIfEmpty: false,
|
|
39
42
|
publishTxsWithProposals: false,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
maxBlockSizeInBytes: 1024 * 1024,
|
|
43
|
+
perBlockAllocationMultiplier: 1.2,
|
|
44
|
+
redistributeCheckpointBudget: true,
|
|
43
45
|
enforceTimeTable: true,
|
|
44
|
-
attestationPropagationTime:
|
|
46
|
+
attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
|
|
45
47
|
secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
|
|
46
48
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
|
|
47
49
|
skipCollectingAttestations: false,
|
|
48
50
|
skipInvalidateBlockAsProposer: false,
|
|
49
51
|
broadcastInvalidBlockProposal: false,
|
|
50
52
|
injectFakeAttestation: false,
|
|
53
|
+
injectHighSValueAttestation: false,
|
|
54
|
+
injectUnrecoverableSignatureAttestation: false,
|
|
51
55
|
fishermanMode: false,
|
|
52
56
|
shuffleAttestationOrdering: false,
|
|
53
57
|
skipPushProposedBlocksToArchiver: false,
|
|
54
|
-
|
|
58
|
+
skipPublishingCheckpointsPercent: 0,
|
|
59
|
+
} satisfies ResolvedSequencerConfig;
|
|
55
60
|
|
|
56
61
|
/**
|
|
57
62
|
* Configuration settings for the SequencerClient.
|
|
58
63
|
*/
|
|
59
|
-
export type SequencerClientConfig =
|
|
64
|
+
export type SequencerClientConfig = SequencerPublisherConfig &
|
|
60
65
|
KeyStoreConfig &
|
|
61
66
|
ValidatorClientConfig &
|
|
62
|
-
|
|
67
|
+
SequencerTxSenderConfig &
|
|
63
68
|
SequencerConfig &
|
|
64
69
|
L1ReaderConfig &
|
|
65
70
|
ChainConfig &
|
|
66
|
-
Pick<P2PConfig, '
|
|
71
|
+
Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
|
|
67
72
|
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
|
|
68
73
|
|
|
69
74
|
export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
@@ -72,10 +77,10 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
72
77
|
description: 'The number of ms to wait between polling for checking to build on the next slot.',
|
|
73
78
|
...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
|
|
74
79
|
},
|
|
75
|
-
|
|
76
|
-
env: '
|
|
77
|
-
description: 'The maximum number of txs
|
|
78
|
-
|
|
80
|
+
maxTxsPerCheckpoint: {
|
|
81
|
+
env: 'SEQ_MAX_TX_PER_CHECKPOINT',
|
|
82
|
+
description: 'The maximum number of txs across all blocks in a checkpoint.',
|
|
83
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
79
84
|
},
|
|
80
85
|
minTxsPerBlock: {
|
|
81
86
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
@@ -94,12 +99,25 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
94
99
|
maxL2BlockGas: {
|
|
95
100
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
96
101
|
description: 'The maximum L2 block gas.',
|
|
97
|
-
|
|
102
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
98
103
|
},
|
|
99
104
|
maxDABlockGas: {
|
|
100
105
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
101
106
|
description: 'The maximum DA block gas.',
|
|
102
|
-
|
|
107
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
108
|
+
},
|
|
109
|
+
perBlockAllocationMultiplier: {
|
|
110
|
+
env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
|
|
111
|
+
description:
|
|
112
|
+
'Per-block gas budget multiplier for both L2 and DA gas. Budget per block is (checkpointLimit / maxBlocks) * multiplier.' +
|
|
113
|
+
' Values greater than one allow early blocks to use more than their even share, relying on checkpoint-level capping for later blocks.',
|
|
114
|
+
...numberConfigHelper(DefaultSequencerConfig.perBlockAllocationMultiplier),
|
|
115
|
+
},
|
|
116
|
+
redistributeCheckpointBudget: {
|
|
117
|
+
env: 'SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET',
|
|
118
|
+
description:
|
|
119
|
+
'Redistribute remaining checkpoint budget evenly across remaining blocks instead of allowing a single block to consume the entire remaining budget.',
|
|
120
|
+
...booleanConfigHelper(DefaultSequencerConfig.redistributeCheckpointBudget),
|
|
103
121
|
},
|
|
104
122
|
coinbase: {
|
|
105
123
|
env: 'COINBASE',
|
|
@@ -119,11 +137,6 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
119
137
|
env: 'ACVM_BINARY_PATH',
|
|
120
138
|
description: 'The path to the ACVM binary',
|
|
121
139
|
},
|
|
122
|
-
maxBlockSizeInBytes: {
|
|
123
|
-
env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
|
|
124
|
-
description: 'Max block size',
|
|
125
|
-
...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
|
|
126
|
-
},
|
|
127
140
|
enforceTimeTable: {
|
|
128
141
|
env: 'SEQ_ENFORCE_TIME_TABLE',
|
|
129
142
|
description: 'Whether to enforce the time table when building blocks',
|
|
@@ -181,6 +194,14 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
181
194
|
description: 'Inject a fake attestation (for testing only)',
|
|
182
195
|
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
|
|
183
196
|
},
|
|
197
|
+
injectHighSValueAttestation: {
|
|
198
|
+
description: 'Inject a malleable attestation with a high-s value (for testing only)',
|
|
199
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectHighSValueAttestation),
|
|
200
|
+
},
|
|
201
|
+
injectUnrecoverableSignatureAttestation: {
|
|
202
|
+
description: 'Inject an attestation with an unrecoverable signature (for testing only)',
|
|
203
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectUnrecoverableSignatureAttestation),
|
|
204
|
+
},
|
|
184
205
|
fishermanMode: {
|
|
185
206
|
env: 'FISHERMAN_MODE',
|
|
186
207
|
description:
|
|
@@ -191,13 +212,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
191
212
|
description: 'Shuffle attestation ordering to create invalid ordering (for testing only)',
|
|
192
213
|
...booleanConfigHelper(DefaultSequencerConfig.shuffleAttestationOrdering),
|
|
193
214
|
},
|
|
194
|
-
|
|
195
|
-
env: 'SEQ_BLOCK_DURATION_MS',
|
|
196
|
-
description:
|
|
197
|
-
'Duration per block in milliseconds when building multiple blocks per slot. ' +
|
|
198
|
-
'If undefined (default), builds a single block per slot using the full slot duration.',
|
|
199
|
-
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
200
|
-
},
|
|
215
|
+
...sharedSequencerConfigMappings,
|
|
201
216
|
buildCheckpointIfEmpty: {
|
|
202
217
|
env: 'SEQ_BUILD_CHECKPOINT_IF_EMPTY',
|
|
203
218
|
description: 'Have sequencer build and publish an empty checkpoint if there are no txs',
|
|
@@ -207,7 +222,15 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
207
222
|
description: 'Skip pushing proposed blocks to archiver (default: true)',
|
|
208
223
|
...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
|
|
209
224
|
},
|
|
210
|
-
|
|
225
|
+
minBlocksForCheckpoint: {
|
|
226
|
+
description: 'Minimum number of blocks required for a checkpoint proposal (test only)',
|
|
227
|
+
},
|
|
228
|
+
skipPublishingCheckpointsPercent: {
|
|
229
|
+
env: 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT',
|
|
230
|
+
description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
|
|
231
|
+
...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent),
|
|
232
|
+
},
|
|
233
|
+
...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowListExtend']),
|
|
211
234
|
};
|
|
212
235
|
|
|
213
236
|
export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
|
|
@@ -215,8 +238,8 @@ export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientCo
|
|
|
215
238
|
...sequencerConfigMappings,
|
|
216
239
|
...keyStoreConfigMappings,
|
|
217
240
|
...l1ReaderConfigMappings,
|
|
218
|
-
...
|
|
219
|
-
...
|
|
241
|
+
...sequencerTxSenderConfigMappings,
|
|
242
|
+
...sequencerPublisherConfigMappings,
|
|
220
243
|
...chainConfigMappings,
|
|
221
244
|
...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
|
|
222
245
|
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
2
|
-
import type { L1ContractsConfig } from '@aztec/ethereum/config';
|
|
3
1
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
4
|
-
import type {
|
|
2
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
5
3
|
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
6
4
|
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
7
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
6
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
7
|
import { createLogger } from '@aztec/foundation/log';
|
|
8
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
10
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
-
import { type L1RollupConstants, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
10
|
+
import { type L1RollupConstants, getNextL1SlotTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
12
11
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
13
12
|
import type {
|
|
14
13
|
CheckpointGlobalVariables,
|
|
@@ -16,7 +15,12 @@ import type {
|
|
|
16
15
|
} from '@aztec/stdlib/tx';
|
|
17
16
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
/** Configuration for the GlobalVariableBuilder (excludes L1 client config). */
|
|
19
|
+
export type GlobalVariableBuilderConfig = {
|
|
20
|
+
l1Contracts: Pick<L1ContractAddresses, 'rollupAddress'>;
|
|
21
|
+
ethereumSlotDuration: number;
|
|
22
|
+
rollupVersion: bigint;
|
|
23
|
+
} & Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'>;
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* Simple global variables builder.
|
|
@@ -27,7 +31,6 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
27
31
|
private currentL1BlockNumber: bigint | undefined = undefined;
|
|
28
32
|
|
|
29
33
|
private readonly rollupContract: RollupContract;
|
|
30
|
-
private readonly publicClient: ViemPublicClient;
|
|
31
34
|
private readonly ethereumSlotDuration: number;
|
|
32
35
|
private readonly aztecSlotDuration: number;
|
|
33
36
|
private readonly l1GenesisTime: bigint;
|
|
@@ -36,28 +39,18 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
36
39
|
private version: Fr;
|
|
37
40
|
|
|
38
41
|
constructor(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
private readonly dateProvider: DateProvider,
|
|
43
|
+
private readonly publicClient: ViemPublicClient,
|
|
44
|
+
config: GlobalVariableBuilderConfig,
|
|
42
45
|
) {
|
|
43
|
-
const { l1RpcUrls, l1ChainId: chainId, l1Contracts } = config;
|
|
44
|
-
|
|
45
|
-
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
46
|
-
|
|
47
46
|
this.version = new Fr(config.rollupVersion);
|
|
48
|
-
this.chainId = new Fr(
|
|
47
|
+
this.chainId = new Fr(this.publicClient.chain!.id);
|
|
49
48
|
|
|
50
49
|
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
51
50
|
this.aztecSlotDuration = config.slotDuration;
|
|
52
51
|
this.l1GenesisTime = config.l1GenesisTime;
|
|
53
52
|
|
|
54
|
-
this.
|
|
55
|
-
chain: chain.chainInfo,
|
|
56
|
-
transport: fallback(chain.rpcUrls.map(url => http(url, { batch: false }))),
|
|
57
|
-
pollingInterval: config.viemPollingIntervalMS,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
this.rollupContract = new RollupContract(this.publicClient, l1Contracts.rollupAddress);
|
|
53
|
+
this.rollupContract = new RollupContract(this.publicClient, config.l1Contracts.rollupAddress);
|
|
61
54
|
}
|
|
62
55
|
|
|
63
56
|
/**
|
|
@@ -73,7 +66,10 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
73
66
|
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
74
67
|
SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
|
|
75
68
|
);
|
|
76
|
-
const nextEthTimestamp =
|
|
69
|
+
const nextEthTimestamp = getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
|
|
70
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
71
|
+
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
72
|
+
});
|
|
77
73
|
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
78
74
|
|
|
79
75
|
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
@@ -108,7 +104,10 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
108
104
|
const slot: SlotNumber =
|
|
109
105
|
maybeSlot ??
|
|
110
106
|
(await this.rollupContract.getSlotAt(
|
|
111
|
-
|
|
107
|
+
getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
|
|
108
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
109
|
+
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
110
|
+
}),
|
|
112
111
|
));
|
|
113
112
|
|
|
114
113
|
const checkpointGlobalVariables = await this.buildCheckpointGlobalVariables(coinbase, feeRecipient, slot);
|
|
@@ -120,7 +119,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
120
119
|
coinbase: EthAddress,
|
|
121
120
|
feeRecipient: AztecAddress,
|
|
122
121
|
slotNumber: SlotNumber,
|
|
123
|
-
): Promise<CheckpointGlobalVariables
|
|
122
|
+
): Promise<CheckpointGlobalVariables> {
|
|
124
123
|
const { chainId, version } = this;
|
|
125
124
|
|
|
126
125
|
const timestamp = getTimestampForSlot(slotNumber, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { GlobalVariableBuilder } from './global_builder.js';
|
|
1
|
+
export { GlobalVariableBuilder, type GlobalVariableBuilderConfig } from './global_builder.js';
|
package/src/publisher/config.ts
CHANGED
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
import { type BlobClientConfig, blobClientConfigMapping } from '@aztec/blob-client/client/config';
|
|
2
2
|
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
3
3
|
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from '@aztec/ethereum/l1-tx-utils/config';
|
|
4
|
-
import {
|
|
5
|
-
type ConfigMappingsType,
|
|
6
|
-
SecretValue,
|
|
7
|
-
booleanConfigHelper,
|
|
8
|
-
getConfigFromMappings,
|
|
9
|
-
} from '@aztec/foundation/config';
|
|
4
|
+
import { type ConfigMappingsType, SecretValue, booleanConfigHelper } from '@aztec/foundation/config';
|
|
10
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
11
6
|
|
|
12
|
-
/**
|
|
13
|
-
* The configuration of the rollup transaction publisher.
|
|
14
|
-
*/
|
|
7
|
+
/** Configuration of the transaction publisher. */
|
|
15
8
|
export type TxSenderConfig = L1ReaderConfig & {
|
|
16
|
-
/**
|
|
17
|
-
* The private key to be used by the publisher.
|
|
18
|
-
*/
|
|
9
|
+
/** The private key to be used by the publisher. */
|
|
19
10
|
publisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
20
11
|
|
|
21
|
-
/**
|
|
22
|
-
* Publisher addresses to be used with a remote signer
|
|
23
|
-
*/
|
|
12
|
+
/** Publisher addresses to be used with a remote signer */
|
|
24
13
|
publisherAddresses?: EthAddress[];
|
|
25
14
|
};
|
|
26
15
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
export type ProverTxSenderConfig = L1ReaderConfig & {
|
|
17
|
+
proverPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
18
|
+
proverPublisherAddresses?: EthAddress[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type SequencerTxSenderConfig = L1ReaderConfig & {
|
|
22
|
+
sequencerPublisherPrivateKeys?: SecretValue<`0x${string}`>[];
|
|
23
|
+
sequencerPublisherAddresses?: EthAddress[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function getTxSenderConfigFromProverConfig(config: ProverTxSenderConfig): TxSenderConfig {
|
|
27
|
+
return {
|
|
28
|
+
...config,
|
|
29
|
+
publisherPrivateKeys: config.proverPublisherPrivateKeys,
|
|
30
|
+
publisherAddresses: config.proverPublisherAddresses,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getTxSenderConfigFromSequencerConfig(config: SequencerTxSenderConfig): TxSenderConfig {
|
|
35
|
+
return {
|
|
36
|
+
...config,
|
|
37
|
+
publisherPrivateKeys: config.sequencerPublisherPrivateKeys,
|
|
38
|
+
publisherAddresses: config.sequencerPublisherAddresses,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Configuration of the L1Publisher. */
|
|
30
43
|
export type PublisherConfig = L1TxUtilsConfig &
|
|
31
44
|
BlobClientConfig & {
|
|
32
45
|
/** True to use publishers in invalid states (timed out, cancelled, etc) if no other is available */
|
|
@@ -37,35 +50,76 @@ export type PublisherConfig = L1TxUtilsConfig &
|
|
|
37
50
|
publisherForwarderAddress?: EthAddress;
|
|
38
51
|
};
|
|
39
52
|
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
export type ProverPublisherConfig = L1TxUtilsConfig &
|
|
54
|
+
BlobClientConfig & {
|
|
55
|
+
fishermanMode?: boolean;
|
|
56
|
+
proverPublisherAllowInvalidStates?: boolean;
|
|
57
|
+
proverPublisherForwarderAddress?: EthAddress;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type SequencerPublisherConfig = L1TxUtilsConfig &
|
|
61
|
+
BlobClientConfig & {
|
|
62
|
+
fishermanMode?: boolean;
|
|
63
|
+
sequencerPublisherAllowInvalidStates?: boolean;
|
|
64
|
+
sequencerPublisherForwarderAddress?: EthAddress;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig {
|
|
68
|
+
return {
|
|
69
|
+
...config,
|
|
70
|
+
publisherAllowInvalidStates: config.proverPublisherAllowInvalidStates,
|
|
71
|
+
publisherForwarderAddress: config.proverPublisherForwarderAddress,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function getPublisherConfigFromSequencerConfig(config: SequencerPublisherConfig): PublisherConfig {
|
|
76
|
+
return {
|
|
77
|
+
...config,
|
|
78
|
+
publisherAllowInvalidStates: config.sequencerPublisherAllowInvalidStates,
|
|
79
|
+
publisherForwarderAddress: config.sequencerPublisherForwarderAddress,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const proverTxSenderConfigMappings: ConfigMappingsType<Omit<ProverTxSenderConfig, 'l1Contracts'>> = {
|
|
43
84
|
...l1ReaderConfigMappings,
|
|
44
|
-
|
|
45
|
-
env:
|
|
46
|
-
description: 'The private keys to be used by the publisher.',
|
|
85
|
+
proverPublisherPrivateKeys: {
|
|
86
|
+
env: `PROVER_PUBLISHER_PRIVATE_KEYS`,
|
|
87
|
+
description: 'The private keys to be used by the prover publisher.',
|
|
47
88
|
parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
|
|
48
89
|
defaultValue: [],
|
|
49
|
-
fallback: [
|
|
90
|
+
fallback: [`PROVER_PUBLISHER_PRIVATE_KEY`],
|
|
50
91
|
},
|
|
51
|
-
|
|
52
|
-
env:
|
|
92
|
+
proverPublisherAddresses: {
|
|
93
|
+
env: `PROVER_PUBLISHER_ADDRESSES`,
|
|
53
94
|
description: 'The addresses of the publishers to use with remote signers',
|
|
54
95
|
parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
|
|
55
96
|
defaultValue: [],
|
|
56
97
|
},
|
|
57
|
-
}
|
|
98
|
+
};
|
|
58
99
|
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
100
|
+
export const sequencerTxSenderConfigMappings: ConfigMappingsType<Omit<SequencerTxSenderConfig, 'l1Contracts'>> = {
|
|
101
|
+
...l1ReaderConfigMappings,
|
|
102
|
+
sequencerPublisherPrivateKeys: {
|
|
103
|
+
env: `SEQ_PUBLISHER_PRIVATE_KEYS`,
|
|
104
|
+
description: 'The private keys to be used by the sequencer publisher.',
|
|
105
|
+
parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
|
|
106
|
+
defaultValue: [],
|
|
107
|
+
fallback: [`SEQ_PUBLISHER_PRIVATE_KEY`],
|
|
108
|
+
},
|
|
109
|
+
sequencerPublisherAddresses: {
|
|
110
|
+
env: `SEQ_PUBLISHER_ADDRESSES`,
|
|
111
|
+
description: 'The addresses of the publishers to use with remote signers',
|
|
112
|
+
parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
|
|
113
|
+
defaultValue: [],
|
|
114
|
+
},
|
|
115
|
+
};
|
|
62
116
|
|
|
63
|
-
export const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
117
|
+
export const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPublisherConfig & L1TxUtilsConfig> = {
|
|
118
|
+
...l1TxUtilsConfigMappings,
|
|
119
|
+
...blobClientConfigMapping,
|
|
120
|
+
sequencerPublisherAllowInvalidStates: {
|
|
121
|
+
env: `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
67
122
|
description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
|
|
68
|
-
env: scope === `PROVER` ? `PROVER_PUBLISHER_ALLOW_INVALID_STATES` : `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
69
123
|
...booleanConfigHelper(true),
|
|
70
124
|
},
|
|
71
125
|
fishermanMode: {
|
|
@@ -74,15 +128,30 @@ export const getPublisherConfigMappings: (
|
|
|
74
128
|
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
75
129
|
...booleanConfigHelper(false),
|
|
76
130
|
},
|
|
77
|
-
|
|
78
|
-
env:
|
|
131
|
+
sequencerPublisherForwarderAddress: {
|
|
132
|
+
env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
|
|
79
133
|
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
80
134
|
parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
|
|
81
135
|
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig> = {
|
|
82
139
|
...l1TxUtilsConfigMappings,
|
|
83
140
|
...blobClientConfigMapping,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
141
|
+
proverPublisherAllowInvalidStates: {
|
|
142
|
+
env: `PROVER_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
143
|
+
description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
|
|
144
|
+
...booleanConfigHelper(true),
|
|
145
|
+
},
|
|
146
|
+
fishermanMode: {
|
|
147
|
+
env: 'FISHERMAN_MODE',
|
|
148
|
+
description:
|
|
149
|
+
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
150
|
+
...booleanConfigHelper(false),
|
|
151
|
+
},
|
|
152
|
+
proverPublisherForwarderAddress: {
|
|
153
|
+
env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
|
|
154
|
+
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
155
|
+
parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
|
|
156
|
+
},
|
|
157
|
+
};
|
|
@@ -3,7 +3,7 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
|
3
3
|
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
4
4
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
5
5
|
import type { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
6
|
-
import type {
|
|
6
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
7
7
|
import type { PublisherFilter, PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
8
8
|
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
9
9
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
@@ -26,13 +26,15 @@ export class SequencerPublisherFactory {
|
|
|
26
26
|
/** Stores the last slot in which every action was carried out by a publisher */
|
|
27
27
|
private lastActions: Partial<Record<Action, SlotNumber>> = {};
|
|
28
28
|
|
|
29
|
+
private nodeKeyStore: NodeKeystoreAdapter;
|
|
30
|
+
|
|
29
31
|
private logger: Logger;
|
|
30
32
|
|
|
31
33
|
constructor(
|
|
32
34
|
private sequencerConfig: SequencerClientConfig,
|
|
33
35
|
private deps: {
|
|
34
36
|
telemetry: TelemetryClient;
|
|
35
|
-
publisherManager: PublisherManager<
|
|
37
|
+
publisherManager: PublisherManager<L1TxUtils>;
|
|
36
38
|
blobClient: BlobClientInterface;
|
|
37
39
|
dateProvider: DateProvider;
|
|
38
40
|
epochCache: EpochCache;
|
|
@@ -45,7 +47,17 @@ export class SequencerPublisherFactory {
|
|
|
45
47
|
) {
|
|
46
48
|
this.publisherMetrics = new SequencerPublisherMetrics(deps.telemetry, 'SequencerPublisher');
|
|
47
49
|
this.logger = deps.logger ?? createLogger('sequencer');
|
|
50
|
+
this.nodeKeyStore = this.deps.nodeKeyStore;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Updates the node keystore adapter used for publisher lookups.
|
|
55
|
+
* Called when the keystore is reloaded at runtime to reflect new validator-publisher mappings.
|
|
56
|
+
*/
|
|
57
|
+
public updateNodeKeyStore(adapter: NodeKeystoreAdapter): void {
|
|
58
|
+
this.nodeKeyStore = adapter;
|
|
48
59
|
}
|
|
60
|
+
|
|
49
61
|
/**
|
|
50
62
|
* Creates a new SequencerPublisher instance.
|
|
51
63
|
* @param _validatorAddress - The address of the validator that will be using the publisher.
|
|
@@ -54,17 +66,17 @@ export class SequencerPublisherFactory {
|
|
|
54
66
|
public async create(validatorAddress?: EthAddress): Promise<AttestorPublisherPair> {
|
|
55
67
|
// If we have been given an attestor address we must only allow publishers permitted for that attestor
|
|
56
68
|
|
|
57
|
-
const allowedPublishers = !validatorAddress ? [] : this.
|
|
58
|
-
const filter: PublisherFilter<
|
|
69
|
+
const allowedPublishers = !validatorAddress ? [] : this.nodeKeyStore.getPublisherAddresses(validatorAddress);
|
|
70
|
+
const filter: PublisherFilter<L1TxUtils> = !validatorAddress
|
|
59
71
|
? () => true
|
|
60
|
-
: (utils:
|
|
72
|
+
: (utils: L1TxUtils) => {
|
|
61
73
|
const publisherAddress = utils.getSenderAddress();
|
|
62
74
|
return allowedPublishers.some(allowedPublisher => allowedPublisher.equals(publisherAddress));
|
|
63
75
|
};
|
|
64
76
|
|
|
65
77
|
const l1Publisher = await this.deps.publisherManager.getAvailablePublisher(filter);
|
|
66
78
|
const attestorAddress =
|
|
67
|
-
validatorAddress ?? this.
|
|
79
|
+
validatorAddress ?? this.nodeKeyStore.getAttestorForPublisher(l1Publisher.getSenderAddress());
|
|
68
80
|
|
|
69
81
|
const rollup = this.deps.rollupContract;
|
|
70
82
|
const slashingProposerContract = await rollup.getSlashingProposer();
|
|
@@ -89,4 +101,9 @@ export class SequencerPublisherFactory {
|
|
|
89
101
|
publisher,
|
|
90
102
|
};
|
|
91
103
|
}
|
|
104
|
+
|
|
105
|
+
/** Interrupts all publishers managed by this factory. Used during sequencer shutdown. */
|
|
106
|
+
public interruptAll(): void {
|
|
107
|
+
this.deps.publisherManager.interrupt();
|
|
108
|
+
}
|
|
92
109
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
Metrics,
|
|
8
8
|
type TelemetryClient,
|
|
9
9
|
type UpDownCounter,
|
|
10
|
+
createUpDownCounterWithDefault,
|
|
10
11
|
} from '@aztec/telemetry-client';
|
|
11
12
|
|
|
12
13
|
import { formatEther } from 'viem/utils';
|
|
@@ -41,7 +42,10 @@ export class SequencerPublisherMetrics {
|
|
|
41
42
|
|
|
42
43
|
this.gasPrice = meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
|
|
43
44
|
|
|
44
|
-
this.txCount = meter
|
|
45
|
+
this.txCount = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_TX_COUNT, {
|
|
46
|
+
[Attributes.L1_TX_TYPE]: ['process'],
|
|
47
|
+
[Attributes.OK]: [true, false],
|
|
48
|
+
});
|
|
45
49
|
|
|
46
50
|
this.txDuration = meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
|
|
47
51
|
|
|
@@ -59,9 +63,9 @@ export class SequencerPublisherMetrics {
|
|
|
59
63
|
|
|
60
64
|
this.blobInclusionBlocksHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_INCLUSION_BLOCKS);
|
|
61
65
|
|
|
62
|
-
this.blobTxSuccessCounter = meter
|
|
66
|
+
this.blobTxSuccessCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_SUCCESS);
|
|
63
67
|
|
|
64
|
-
this.blobTxFailureCounter = meter
|
|
68
|
+
this.blobTxFailureCounter = createUpDownCounterWithDefault(meter, Metrics.L1_PUBLISHER_BLOB_TX_FAILURE);
|
|
65
69
|
|
|
66
70
|
this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE);
|
|
67
71
|
|