@aztec/sequencer-client 0.0.1-commit.7cf39cb55 → 0.0.1-commit.7ffbba4
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 +23 -7
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +99 -16
- package/dest/config.d.ts +24 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +36 -20
- package/dest/global_variable_builder/global_builder.d.ts +2 -4
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +35 -17
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +106 -42
- package/dest/publisher/index.d.ts +2 -1
- package/dest/publisher/index.d.ts.map +1 -1
- 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 +59 -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-publisher-factory.d.ts +11 -3
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +27 -2
- package/dest/publisher/sequencer-publisher.d.ts +26 -7
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +299 -30
- package/dest/sequencer/checkpoint_proposal_job.d.ts +2 -4
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +98 -45
- package/dest/sequencer/metrics.d.ts +14 -5
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +61 -15
- package/dest/sequencer/sequencer.d.ts +23 -12
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +24 -26
- package/dest/sequencer/timetable.d.ts +4 -3
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +6 -7
- package/dest/sequencer/types.d.ts +5 -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 +8 -8
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +45 -34
- package/dest/test/utils.d.ts +3 -3
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +4 -4
- package/package.json +28 -28
- package/src/client/sequencer-client.ts +135 -18
- package/src/config.ts +45 -27
- package/src/global_variable_builder/global_builder.ts +1 -1
- package/src/publisher/config.ts +121 -43
- package/src/publisher/index.ts +3 -0
- package/src/publisher/l1_tx_failed_store/factory.ts +32 -0
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +55 -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-publisher-factory.ts +38 -6
- package/src/publisher/sequencer-publisher.ts +300 -43
- package/src/sequencer/checkpoint_proposal_job.ts +134 -51
- package/src/sequencer/metrics.ts +68 -18
- package/src/sequencer/sequencer.ts +32 -31
- package/src/sequencer/timetable.ts +7 -7
- package/src/sequencer/types.ts +4 -1
- package/src/test/index.ts +2 -4
- package/src/test/mock_checkpoint_builder.ts +60 -46
- package/src/test/utils.ts +4 -2
package/src/config.ts
CHANGED
|
@@ -22,10 +22,10 @@ import { DEFAULT_P2P_PROPAGATION_TIME } from '@aztec/stdlib/timetable';
|
|
|
22
22
|
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
type
|
|
26
|
-
type
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
type SequencerPublisherConfig,
|
|
26
|
+
type SequencerTxSenderConfig,
|
|
27
|
+
sequencerPublisherConfigMappings,
|
|
28
|
+
sequencerTxSenderConfigMappings,
|
|
29
29
|
} from './publisher/config.js';
|
|
30
30
|
|
|
31
31
|
export * from './publisher/config.js';
|
|
@@ -35,15 +35,12 @@ export type { SequencerConfig };
|
|
|
35
35
|
* Default values for SequencerConfig.
|
|
36
36
|
* Centralized location for all sequencer configuration defaults.
|
|
37
37
|
*/
|
|
38
|
-
export const DefaultSequencerConfig
|
|
38
|
+
export const DefaultSequencerConfig = {
|
|
39
39
|
sequencerPollingIntervalMS: 500,
|
|
40
|
-
maxTxsPerBlock: 32,
|
|
41
40
|
minTxsPerBlock: 1,
|
|
42
41
|
buildCheckpointIfEmpty: false,
|
|
43
42
|
publishTxsWithProposals: false,
|
|
44
|
-
|
|
45
|
-
maxDABlockGas: 10e9,
|
|
46
|
-
maxBlockSizeInBytes: 1024 * 1024,
|
|
43
|
+
perBlockAllocationMultiplier: 2,
|
|
47
44
|
enforceTimeTable: true,
|
|
48
45
|
attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
|
|
49
46
|
secondsBeforeInvalidatingBlockAsCommitteeMember: 144, // 12 L1 blocks
|
|
@@ -52,22 +49,25 @@ export const DefaultSequencerConfig: ResolvedSequencerConfig = {
|
|
|
52
49
|
skipInvalidateBlockAsProposer: false,
|
|
53
50
|
broadcastInvalidBlockProposal: false,
|
|
54
51
|
injectFakeAttestation: false,
|
|
52
|
+
injectHighSValueAttestation: false,
|
|
53
|
+
injectUnrecoverableSignatureAttestation: false,
|
|
55
54
|
fishermanMode: false,
|
|
56
55
|
shuffleAttestationOrdering: false,
|
|
57
56
|
skipPushProposedBlocksToArchiver: false,
|
|
58
|
-
|
|
57
|
+
skipPublishingCheckpointsPercent: 0,
|
|
58
|
+
} satisfies ResolvedSequencerConfig;
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Configuration settings for the SequencerClient.
|
|
62
62
|
*/
|
|
63
|
-
export type SequencerClientConfig =
|
|
63
|
+
export type SequencerClientConfig = SequencerPublisherConfig &
|
|
64
64
|
KeyStoreConfig &
|
|
65
65
|
ValidatorClientConfig &
|
|
66
|
-
|
|
66
|
+
SequencerTxSenderConfig &
|
|
67
67
|
SequencerConfig &
|
|
68
68
|
L1ReaderConfig &
|
|
69
69
|
ChainConfig &
|
|
70
|
-
Pick<P2PConfig, '
|
|
70
|
+
Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
|
|
71
71
|
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
|
|
72
72
|
|
|
73
73
|
export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
@@ -76,10 +76,10 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
76
76
|
description: 'The number of ms to wait between polling for checking to build on the next slot.',
|
|
77
77
|
...numberConfigHelper(DefaultSequencerConfig.sequencerPollingIntervalMS),
|
|
78
78
|
},
|
|
79
|
-
|
|
80
|
-
env: '
|
|
81
|
-
description: 'The maximum number of txs
|
|
82
|
-
|
|
79
|
+
maxTxsPerCheckpoint: {
|
|
80
|
+
env: 'SEQ_MAX_TX_PER_CHECKPOINT',
|
|
81
|
+
description: 'The maximum number of txs across all blocks in a checkpoint.',
|
|
82
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
83
83
|
},
|
|
84
84
|
minTxsPerBlock: {
|
|
85
85
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
@@ -98,12 +98,19 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
98
98
|
maxL2BlockGas: {
|
|
99
99
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
100
100
|
description: 'The maximum L2 block gas.',
|
|
101
|
-
|
|
101
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
102
102
|
},
|
|
103
103
|
maxDABlockGas: {
|
|
104
104
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
105
105
|
description: 'The maximum DA block gas.',
|
|
106
|
-
|
|
106
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
107
|
+
},
|
|
108
|
+
perBlockAllocationMultiplier: {
|
|
109
|
+
env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
|
|
110
|
+
description:
|
|
111
|
+
'Per-block gas budget multiplier for both L2 and DA gas. Budget per block is (checkpointLimit / maxBlocks) * multiplier.' +
|
|
112
|
+
' Values greater than one allow early blocks to use more than their even share, relying on checkpoint-level capping for later blocks.',
|
|
113
|
+
...numberConfigHelper(DefaultSequencerConfig.perBlockAllocationMultiplier),
|
|
107
114
|
},
|
|
108
115
|
coinbase: {
|
|
109
116
|
env: 'COINBASE',
|
|
@@ -123,11 +130,6 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
123
130
|
env: 'ACVM_BINARY_PATH',
|
|
124
131
|
description: 'The path to the ACVM binary',
|
|
125
132
|
},
|
|
126
|
-
maxBlockSizeInBytes: {
|
|
127
|
-
env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
|
|
128
|
-
description: 'Max block size',
|
|
129
|
-
...numberConfigHelper(DefaultSequencerConfig.maxBlockSizeInBytes),
|
|
130
|
-
},
|
|
131
133
|
enforceTimeTable: {
|
|
132
134
|
env: 'SEQ_ENFORCE_TIME_TABLE',
|
|
133
135
|
description: 'Whether to enforce the time table when building blocks',
|
|
@@ -185,6 +187,14 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
185
187
|
description: 'Inject a fake attestation (for testing only)',
|
|
186
188
|
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
|
|
187
189
|
},
|
|
190
|
+
injectHighSValueAttestation: {
|
|
191
|
+
description: 'Inject a malleable attestation with a high-s value (for testing only)',
|
|
192
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectHighSValueAttestation),
|
|
193
|
+
},
|
|
194
|
+
injectUnrecoverableSignatureAttestation: {
|
|
195
|
+
description: 'Inject an attestation with an unrecoverable signature (for testing only)',
|
|
196
|
+
...booleanConfigHelper(DefaultSequencerConfig.injectUnrecoverableSignatureAttestation),
|
|
197
|
+
},
|
|
188
198
|
fishermanMode: {
|
|
189
199
|
env: 'FISHERMAN_MODE',
|
|
190
200
|
description:
|
|
@@ -205,7 +215,15 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
205
215
|
description: 'Skip pushing proposed blocks to archiver (default: true)',
|
|
206
216
|
...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
|
|
207
217
|
},
|
|
208
|
-
|
|
218
|
+
minBlocksForCheckpoint: {
|
|
219
|
+
description: 'Minimum number of blocks required for a checkpoint proposal (test only)',
|
|
220
|
+
},
|
|
221
|
+
skipPublishingCheckpointsPercent: {
|
|
222
|
+
env: 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT',
|
|
223
|
+
description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
|
|
224
|
+
...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent),
|
|
225
|
+
},
|
|
226
|
+
...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowListExtend']),
|
|
209
227
|
};
|
|
210
228
|
|
|
211
229
|
export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
|
|
@@ -213,8 +231,8 @@ export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientCo
|
|
|
213
231
|
...sequencerConfigMappings,
|
|
214
232
|
...keyStoreConfigMappings,
|
|
215
233
|
...l1ReaderConfigMappings,
|
|
216
|
-
...
|
|
217
|
-
...
|
|
234
|
+
...sequencerTxSenderConfigMappings,
|
|
235
|
+
...sequencerPublisherConfigMappings,
|
|
218
236
|
...chainConfigMappings,
|
|
219
237
|
...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
|
|
220
238
|
};
|
|
@@ -120,7 +120,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
120
120
|
coinbase: EthAddress,
|
|
121
121
|
feeRecipient: AztecAddress,
|
|
122
122
|
slotNumber: SlotNumber,
|
|
123
|
-
): Promise<CheckpointGlobalVariables
|
|
123
|
+
): Promise<CheckpointGlobalVariables> {
|
|
124
124
|
const { chainId, version } = this;
|
|
125
125
|
|
|
126
126
|
const timestamp = getTimestampForSlot(slotNumber, {
|
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 */
|
|
@@ -35,37 +48,83 @@ export type PublisherConfig = L1TxUtilsConfig &
|
|
|
35
48
|
fishermanMode?: boolean;
|
|
36
49
|
/** Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only) */
|
|
37
50
|
publisherForwarderAddress?: EthAddress;
|
|
51
|
+
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
52
|
+
l1TxFailedStore?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type ProverPublisherConfig = L1TxUtilsConfig &
|
|
56
|
+
BlobClientConfig & {
|
|
57
|
+
fishermanMode?: boolean;
|
|
58
|
+
proverPublisherAllowInvalidStates?: boolean;
|
|
59
|
+
proverPublisherForwarderAddress?: EthAddress;
|
|
38
60
|
};
|
|
39
61
|
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
62
|
+
export type SequencerPublisherConfig = L1TxUtilsConfig &
|
|
63
|
+
BlobClientConfig & {
|
|
64
|
+
fishermanMode?: boolean;
|
|
65
|
+
sequencerPublisherAllowInvalidStates?: boolean;
|
|
66
|
+
sequencerPublisherForwarderAddress?: EthAddress;
|
|
67
|
+
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
68
|
+
l1TxFailedStore?: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig {
|
|
72
|
+
return {
|
|
73
|
+
...config,
|
|
74
|
+
publisherAllowInvalidStates: config.proverPublisherAllowInvalidStates,
|
|
75
|
+
publisherForwarderAddress: config.proverPublisherForwarderAddress,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function getPublisherConfigFromSequencerConfig(config: SequencerPublisherConfig): PublisherConfig {
|
|
80
|
+
return {
|
|
81
|
+
...config,
|
|
82
|
+
publisherAllowInvalidStates: config.sequencerPublisherAllowInvalidStates,
|
|
83
|
+
publisherForwarderAddress: config.sequencerPublisherForwarderAddress,
|
|
84
|
+
l1TxFailedStore: config.l1TxFailedStore,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const proverTxSenderConfigMappings: ConfigMappingsType<Omit<ProverTxSenderConfig, 'l1Contracts'>> = {
|
|
43
89
|
...l1ReaderConfigMappings,
|
|
44
|
-
|
|
45
|
-
env:
|
|
46
|
-
description: 'The private keys to be used by the publisher.',
|
|
90
|
+
proverPublisherPrivateKeys: {
|
|
91
|
+
env: `PROVER_PUBLISHER_PRIVATE_KEYS`,
|
|
92
|
+
description: 'The private keys to be used by the prover publisher.',
|
|
47
93
|
parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
|
|
48
94
|
defaultValue: [],
|
|
49
|
-
fallback: [
|
|
95
|
+
fallback: [`PROVER_PUBLISHER_PRIVATE_KEY`],
|
|
50
96
|
},
|
|
51
|
-
|
|
52
|
-
env:
|
|
97
|
+
proverPublisherAddresses: {
|
|
98
|
+
env: `PROVER_PUBLISHER_ADDRESSES`,
|
|
53
99
|
description: 'The addresses of the publishers to use with remote signers',
|
|
54
100
|
parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
|
|
55
101
|
defaultValue: [],
|
|
56
102
|
},
|
|
57
|
-
}
|
|
103
|
+
};
|
|
58
104
|
|
|
59
|
-
export
|
|
60
|
-
|
|
61
|
-
|
|
105
|
+
export const sequencerTxSenderConfigMappings: ConfigMappingsType<Omit<SequencerTxSenderConfig, 'l1Contracts'>> = {
|
|
106
|
+
...l1ReaderConfigMappings,
|
|
107
|
+
sequencerPublisherPrivateKeys: {
|
|
108
|
+
env: `SEQ_PUBLISHER_PRIVATE_KEYS`,
|
|
109
|
+
description: 'The private keys to be used by the sequencer publisher.',
|
|
110
|
+
parseEnv: (val: string) => val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}`)),
|
|
111
|
+
defaultValue: [],
|
|
112
|
+
fallback: [`SEQ_PUBLISHER_PRIVATE_KEY`],
|
|
113
|
+
},
|
|
114
|
+
sequencerPublisherAddresses: {
|
|
115
|
+
env: `SEQ_PUBLISHER_ADDRESSES`,
|
|
116
|
+
description: 'The addresses of the publishers to use with remote signers',
|
|
117
|
+
parseEnv: (val: string) => val.split(',').map(address => EthAddress.fromString(address)),
|
|
118
|
+
defaultValue: [],
|
|
119
|
+
},
|
|
120
|
+
};
|
|
62
121
|
|
|
63
|
-
export const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
122
|
+
export const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPublisherConfig & L1TxUtilsConfig> = {
|
|
123
|
+
...l1TxUtilsConfigMappings,
|
|
124
|
+
...blobClientConfigMapping,
|
|
125
|
+
sequencerPublisherAllowInvalidStates: {
|
|
126
|
+
env: `SEQ_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
67
127
|
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
128
|
...booleanConfigHelper(true),
|
|
70
129
|
},
|
|
71
130
|
fishermanMode: {
|
|
@@ -74,15 +133,34 @@ export const getPublisherConfigMappings: (
|
|
|
74
133
|
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
75
134
|
...booleanConfigHelper(false),
|
|
76
135
|
},
|
|
77
|
-
|
|
78
|
-
env:
|
|
136
|
+
sequencerPublisherForwarderAddress: {
|
|
137
|
+
env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
|
|
79
138
|
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
80
139
|
parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
|
|
81
140
|
},
|
|
141
|
+
l1TxFailedStore: {
|
|
142
|
+
env: 'L1_TX_FAILED_STORE',
|
|
143
|
+
description: 'Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path',
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig> = {
|
|
82
148
|
...l1TxUtilsConfigMappings,
|
|
83
149
|
...blobClientConfigMapping,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
150
|
+
proverPublisherAllowInvalidStates: {
|
|
151
|
+
env: `PROVER_PUBLISHER_ALLOW_INVALID_STATES`,
|
|
152
|
+
description: 'True to use publishers in invalid states (timed out, cancelled, etc) if no other is available',
|
|
153
|
+
...booleanConfigHelper(true),
|
|
154
|
+
},
|
|
155
|
+
fishermanMode: {
|
|
156
|
+
env: 'FISHERMAN_MODE',
|
|
157
|
+
description:
|
|
158
|
+
'Whether to run in fisherman mode: builds blocks on every slot for validation without publishing to L1',
|
|
159
|
+
...booleanConfigHelper(false),
|
|
160
|
+
},
|
|
161
|
+
proverPublisherForwarderAddress: {
|
|
162
|
+
env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
|
|
163
|
+
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
164
|
+
parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
|
|
165
|
+
},
|
|
166
|
+
};
|
package/src/publisher/index.ts
CHANGED
|
@@ -3,3 +3,6 @@ export { SequencerPublisherFactory } from './sequencer-publisher-factory.js';
|
|
|
3
3
|
|
|
4
4
|
// Used for tests
|
|
5
5
|
export { SequencerPublisherMetrics } from './sequencer-publisher-metrics.js';
|
|
6
|
+
|
|
7
|
+
// Failed L1 tx store (optional, for test networks)
|
|
8
|
+
export { type FailedL1Tx, type FailedL1TxUri, type L1TxFailedStore } from './l1_tx_failed_store/index.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { createFileStore } from '@aztec/stdlib/file-store';
|
|
3
|
+
|
|
4
|
+
import type { L1TxFailedStore } from './failed_tx_store.js';
|
|
5
|
+
import { FileStoreL1TxFailedStore } from './file_store_failed_tx_store.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates an L1TxFailedStore from a config string.
|
|
9
|
+
* Supports any backend that FileStore supports (GCS, S3, R2, local filesystem).
|
|
10
|
+
* @param config - Config string (e.g., 'gs://bucket/path', 's3://bucket/path', 'file:///path'). If undefined, returns undefined.
|
|
11
|
+
* @param logger - Optional logger.
|
|
12
|
+
* @returns The store instance, or undefined if config is not provided.
|
|
13
|
+
*/
|
|
14
|
+
export async function createL1TxFailedStore(
|
|
15
|
+
config: string | undefined,
|
|
16
|
+
logger: Logger = createLogger('sequencer:l1-tx-failed-store'),
|
|
17
|
+
): Promise<L1TxFailedStore | undefined> {
|
|
18
|
+
if (!config) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const fileStore = await createFileStore(config, logger);
|
|
23
|
+
if (!fileStore) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Failed to create file store from config: '${config}'. ` +
|
|
26
|
+
`Supported formats: 'gs://bucket/path', 's3://bucket/path', 'file:///path'.`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
logger.info(`Created L1 tx failed store`, { config });
|
|
31
|
+
return new FileStoreL1TxFailedStore(fileStore, logger);
|
|
32
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
|
|
3
|
+
/** URI pointing to a stored failed L1 transaction. */
|
|
4
|
+
export type FailedL1TxUri = string & { __brand: 'FailedL1TxUri' };
|
|
5
|
+
|
|
6
|
+
/** A failed L1 transaction captured for debugging and replay. */
|
|
7
|
+
export type FailedL1Tx = {
|
|
8
|
+
/** Tx hash (for reverts) or keccak256(request.data) (for simulation/send failures). */
|
|
9
|
+
id: Hex;
|
|
10
|
+
/** Unix timestamp (ms) when failure occurred. */
|
|
11
|
+
timestamp: number;
|
|
12
|
+
/** Whether the failure was during simulation or after sending. */
|
|
13
|
+
failureType: 'simulation' | 'revert' | 'send-error';
|
|
14
|
+
/** The actual L1 transaction for replay (multicall-encoded for bundled txs). */
|
|
15
|
+
request: {
|
|
16
|
+
to: Hex;
|
|
17
|
+
data: Hex;
|
|
18
|
+
value?: string; // bigint as string
|
|
19
|
+
};
|
|
20
|
+
/** Raw blob data as hex for replay. */
|
|
21
|
+
blobData?: Hex[];
|
|
22
|
+
/** L1 block number at time of failure (simulation target or receipt block). */
|
|
23
|
+
l1BlockNumber: string; // bigint as string
|
|
24
|
+
/** Receipt info (present only for on-chain reverts). */
|
|
25
|
+
receipt?: {
|
|
26
|
+
transactionHash: Hex;
|
|
27
|
+
blockNumber: string; // bigint as string
|
|
28
|
+
gasUsed: string; // bigint as string
|
|
29
|
+
status: 'reverted';
|
|
30
|
+
};
|
|
31
|
+
/** Error information. */
|
|
32
|
+
error: {
|
|
33
|
+
message: string;
|
|
34
|
+
/** Decoded error name (e.g., 'Rollup__InvalidProposer'). */
|
|
35
|
+
name?: string;
|
|
36
|
+
};
|
|
37
|
+
/** Context metadata. */
|
|
38
|
+
context: {
|
|
39
|
+
/** Actions involved (e.g., ['propose', 'governance-signal']). */
|
|
40
|
+
actions: string[];
|
|
41
|
+
/** Individual request data for each action (metadata, not used for replay). */
|
|
42
|
+
requests?: Array<{ action: string; to: Hex; data: Hex }>;
|
|
43
|
+
checkpointNumber?: number;
|
|
44
|
+
slot?: number;
|
|
45
|
+
sender: Hex;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** Store for failed L1 transactions for debugging purposes. */
|
|
50
|
+
export interface L1TxFailedStore {
|
|
51
|
+
/** Saves a failed transaction and returns its URI. */
|
|
52
|
+
saveFailedTx(tx: FailedL1Tx): Promise<FailedL1TxUri>;
|
|
53
|
+
/** Retrieves a failed transaction by its URI. */
|
|
54
|
+
getFailedTx(uri: FailedL1TxUri): Promise<FailedL1Tx>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import type { FileStore } from '@aztec/stdlib/file-store';
|
|
3
|
+
|
|
4
|
+
import type { FailedL1Tx, FailedL1TxUri, L1TxFailedStore } from './failed_tx_store.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* L1TxFailedStore implementation using the FileStore abstraction.
|
|
8
|
+
* Supports any backend that FileStore supports (GCS, S3, R2, local filesystem).
|
|
9
|
+
*/
|
|
10
|
+
export class FileStoreL1TxFailedStore implements L1TxFailedStore {
|
|
11
|
+
private readonly log: Logger;
|
|
12
|
+
|
|
13
|
+
constructor(
|
|
14
|
+
private readonly fileStore: FileStore,
|
|
15
|
+
logger?: Logger,
|
|
16
|
+
) {
|
|
17
|
+
this.log = logger ?? createLogger('sequencer:l1-tx-failed-store');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async saveFailedTx(tx: FailedL1Tx): Promise<FailedL1TxUri> {
|
|
21
|
+
const prefix = tx.receipt ? 'tx' : 'data';
|
|
22
|
+
const path = `${tx.failureType}/${prefix}-${tx.id}.json`;
|
|
23
|
+
const json = JSON.stringify(tx, null, 2);
|
|
24
|
+
|
|
25
|
+
const uri = await this.fileStore.save(path, Buffer.from(json), {
|
|
26
|
+
metadata: {
|
|
27
|
+
'content-type': 'application/json',
|
|
28
|
+
actions: tx.context.actions.join(','),
|
|
29
|
+
'failure-type': tx.failureType,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
this.log.info(`Saved failed L1 tx to ${uri}`, {
|
|
34
|
+
id: tx.id,
|
|
35
|
+
failureType: tx.failureType,
|
|
36
|
+
actions: tx.context.actions.join(','),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return uri as FailedL1TxUri;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public async getFailedTx(uri: FailedL1TxUri): Promise<FailedL1Tx> {
|
|
43
|
+
const data = await this.fileStore.read(uri);
|
|
44
|
+
return JSON.parse(data.toString()) as FailedL1Tx;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -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,23 +66,38 @@ 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();
|
|
71
83
|
|
|
84
|
+
const getNextPublisher = async (excludeAddresses: EthAddress[]): Promise<L1TxUtils | undefined> => {
|
|
85
|
+
const exclusionFilter: PublisherFilter<L1TxUtils> = (utils: L1TxUtils) => {
|
|
86
|
+
if (excludeAddresses.some(addr => addr.equals(utils.getSenderAddress()))) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return filter(utils);
|
|
90
|
+
};
|
|
91
|
+
try {
|
|
92
|
+
return await this.deps.publisherManager.getAvailablePublisher(exclusionFilter);
|
|
93
|
+
} catch {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
72
98
|
const publisher = new SequencerPublisher(this.sequencerConfig, {
|
|
73
99
|
l1TxUtils: l1Publisher,
|
|
100
|
+
getNextPublisher,
|
|
74
101
|
telemetry: this.deps.telemetry,
|
|
75
102
|
blobClient: this.deps.blobClient,
|
|
76
103
|
rollupContract: this.deps.rollupContract,
|
|
@@ -89,4 +116,9 @@ export class SequencerPublisherFactory {
|
|
|
89
116
|
publisher,
|
|
90
117
|
};
|
|
91
118
|
}
|
|
119
|
+
|
|
120
|
+
/** Interrupts all publishers managed by this factory. Used during sequencer shutdown. */
|
|
121
|
+
public interruptAll(): void {
|
|
122
|
+
this.deps.publisherManager.interrupt();
|
|
123
|
+
}
|
|
92
124
|
}
|