@aztec/sequencer-client 0.0.1-commit.2448fdb → 0.0.1-commit.2606882
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +281 -21
- package/dest/client/sequencer-client.d.ts +4 -3
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +11 -11
- package/dest/config.d.ts +4 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +35 -14
- package/dest/global_variable_builder/fee_predictor.d.ts +37 -0
- package/dest/global_variable_builder/fee_predictor.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_predictor.js +128 -0
- package/dest/global_variable_builder/fee_provider.d.ts +21 -0
- package/dest/global_variable_builder/fee_provider.d.ts.map +1 -0
- package/dest/global_variable_builder/fee_provider.js +58 -0
- package/dest/global_variable_builder/global_builder.d.ts +4 -10
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +5 -40
- package/dest/global_variable_builder/index.d.ts +3 -1
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/global_variable_builder/index.js +2 -0
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/publisher/config.d.ts +19 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +25 -5
- 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 +58 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.js +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts +15 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/file_store_failed_tx_store.js +34 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts +4 -0
- package/dest/publisher/l1_tx_failed_store/index.d.ts.map +1 -0
- package/dest/publisher/l1_tx_failed_store/index.js +2 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts +96 -0
- package/dest/publisher/sequencer-bundle-simulator.d.ts.map +1 -0
- package/dest/publisher/sequencer-bundle-simulator.js +198 -0
- package/dest/publisher/sequencer-publisher-factory.d.ts +3 -5
- package/dest/publisher/sequencer-publisher-factory.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher-factory.js +16 -3
- package/dest/publisher/sequencer-publisher.d.ts +77 -66
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +410 -398
- package/dest/sequencer/automine/automine_factory.d.ts +54 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +84 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +151 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +509 -0
- package/dest/sequencer/chain_state_overrides.d.ts +61 -0
- package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
- package/dest/sequencer/chain_state_overrides.js +98 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +58 -10
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +736 -191
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
- package/dest/sequencer/events.d.ts +48 -2
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/index.d.ts +3 -1
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +2 -0
- package/dest/sequencer/metrics.d.ts +13 -10
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +45 -20
- package/dest/sequencer/sequencer.d.ts +59 -12
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +344 -105
- package/dest/sequencer/timetable.d.ts +11 -1
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +41 -36
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.js +0 -2
- package/dest/test/utils.d.ts +1 -1
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +7 -6
- package/package.json +27 -28
- package/src/client/sequencer-client.ts +19 -20
- package/src/config.ts +40 -11
- package/src/global_variable_builder/README.md +44 -0
- package/src/global_variable_builder/fee_predictor.ts +172 -0
- package/src/global_variable_builder/fee_provider.ts +75 -0
- package/src/global_variable_builder/global_builder.ts +10 -46
- package/src/global_variable_builder/index.ts +2 -0
- package/src/index.ts +10 -1
- package/src/publisher/config.ts +49 -6
- 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 +57 -0
- package/src/publisher/l1_tx_failed_store/file_store_failed_tx_store.ts +46 -0
- package/src/publisher/l1_tx_failed_store/index.ts +3 -0
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +18 -6
- package/src/publisher/sequencer-publisher.ts +485 -474
- package/src/sequencer/README.md +162 -450
- package/src/sequencer/automine/README.md +46 -0
- package/src/sequencer/automine/automine_factory.ts +145 -0
- package/src/sequencer/automine/automine_sequencer.ts +595 -0
- package/src/sequencer/chain_state_overrides.ts +162 -0
- package/src/sequencer/checkpoint_proposal_job.ts +857 -201
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/events.ts +51 -2
- package/src/sequencer/index.ts +2 -0
- package/src/sequencer/metrics.ts +57 -24
- package/src/sequencer/sequencer.ts +421 -118
- package/src/sequencer/timetable.ts +49 -44
- package/src/sequencer/types.ts +1 -1
- package/src/test/mock_checkpoint_builder.ts +0 -2
- package/src/test/utils.ts +28 -10
package/src/config.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
booleanConfigHelper,
|
|
6
6
|
getConfigFromMappings,
|
|
7
7
|
numberConfigHelper,
|
|
8
|
+
optionalNumberConfigHelper,
|
|
8
9
|
pickConfigMappings,
|
|
9
10
|
} from '@aztec/foundation/config';
|
|
10
11
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -13,6 +14,7 @@ import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
|
13
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
15
|
import {
|
|
15
16
|
type ChainConfig,
|
|
17
|
+
DEFAULT_MAX_BLOCKS_PER_CHECKPOINT,
|
|
16
18
|
type SequencerConfig,
|
|
17
19
|
chainConfigMappings,
|
|
18
20
|
sharedSequencerConfigMappings,
|
|
@@ -48,7 +50,9 @@ export const DefaultSequencerConfig = {
|
|
|
48
50
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432, // 36 L1 blocks
|
|
49
51
|
skipCollectingAttestations: false,
|
|
50
52
|
skipInvalidateBlockAsProposer: false,
|
|
53
|
+
skipWaitForValidParentCheckpointOnL1: false,
|
|
51
54
|
broadcastInvalidBlockProposal: false,
|
|
55
|
+
broadcastInvalidCheckpointProposalOnly: false,
|
|
52
56
|
injectFakeAttestation: false,
|
|
53
57
|
injectHighSValueAttestation: false,
|
|
54
58
|
injectUnrecoverableSignatureAttestation: false,
|
|
@@ -56,6 +60,7 @@ export const DefaultSequencerConfig = {
|
|
|
56
60
|
shuffleAttestationOrdering: false,
|
|
57
61
|
skipPushProposedBlocksToArchiver: false,
|
|
58
62
|
skipPublishingCheckpointsPercent: 0,
|
|
63
|
+
maxBlocksPerCheckpoint: DEFAULT_MAX_BLOCKS_PER_CHECKPOINT,
|
|
59
64
|
} satisfies ResolvedSequencerConfig;
|
|
60
65
|
|
|
61
66
|
/**
|
|
@@ -80,7 +85,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
80
85
|
maxTxsPerCheckpoint: {
|
|
81
86
|
env: 'SEQ_MAX_TX_PER_CHECKPOINT',
|
|
82
87
|
description: 'The maximum number of txs across all blocks in a checkpoint.',
|
|
83
|
-
|
|
88
|
+
...optionalNumberConfigHelper(),
|
|
84
89
|
},
|
|
85
90
|
minTxsPerBlock: {
|
|
86
91
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
@@ -99,12 +104,12 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
99
104
|
maxL2BlockGas: {
|
|
100
105
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
101
106
|
description: 'The maximum L2 block gas.',
|
|
102
|
-
|
|
107
|
+
...optionalNumberConfigHelper(),
|
|
103
108
|
},
|
|
104
109
|
maxDABlockGas: {
|
|
105
110
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
106
111
|
description: 'The maximum DA block gas.',
|
|
107
|
-
|
|
112
|
+
...optionalNumberConfigHelper(),
|
|
108
113
|
},
|
|
109
114
|
perBlockAllocationMultiplier: {
|
|
110
115
|
env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
|
|
@@ -121,7 +126,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
121
126
|
},
|
|
122
127
|
coinbase: {
|
|
123
128
|
env: 'COINBASE',
|
|
124
|
-
parseEnv: (val: string) =>
|
|
129
|
+
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
125
130
|
description: 'Recipient of block reward.',
|
|
126
131
|
},
|
|
127
132
|
feeRecipient: {
|
|
@@ -150,12 +155,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
150
155
|
l1PublishingTime: {
|
|
151
156
|
env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
|
|
152
157
|
description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
|
|
153
|
-
|
|
154
|
-
},
|
|
155
|
-
attestationPropagationTime: {
|
|
156
|
-
env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
|
|
157
|
-
description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way)',
|
|
158
|
-
...numberConfigHelper(DefaultSequencerConfig.attestationPropagationTime),
|
|
158
|
+
...optionalNumberConfigHelper(),
|
|
159
159
|
},
|
|
160
160
|
fakeProcessingDelayPerTxMs: {
|
|
161
161
|
description: 'Used for testing to introduce a fake delay after processing each tx',
|
|
@@ -186,10 +186,25 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
186
186
|
description: 'Do not invalidate the previous block if invalid when we are the proposer (for testing only)',
|
|
187
187
|
...booleanConfigHelper(DefaultSequencerConfig.skipInvalidateBlockAsProposer),
|
|
188
188
|
},
|
|
189
|
+
skipWaitForValidParentCheckpointOnL1: {
|
|
190
|
+
description:
|
|
191
|
+
'Bypass the parent checkpoint validity check before submitting a pipelined checkpoint, ' +
|
|
192
|
+
'allowing the proposer to publish even when the parent landed on L1 with invalid attestations (for testing only)',
|
|
193
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipWaitForValidParentCheckpointOnL1),
|
|
194
|
+
},
|
|
189
195
|
broadcastInvalidBlockProposal: {
|
|
190
196
|
description: 'Broadcast invalid block proposals with corrupted state (for testing only)',
|
|
191
197
|
...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidBlockProposal),
|
|
192
198
|
},
|
|
199
|
+
invalidBlockProposalIndexWithinCheckpoint: {
|
|
200
|
+
description: 'Broadcast an invalid block proposal only at this indexWithinCheckpoint (for testing only)',
|
|
201
|
+
...optionalNumberConfigHelper(),
|
|
202
|
+
},
|
|
203
|
+
broadcastInvalidCheckpointProposalOnly: {
|
|
204
|
+
description:
|
|
205
|
+
'Broadcast invalid checkpoint proposals while keeping the underlying block proposals valid (for testing only). When unset, the checkpoint follows broadcastInvalidBlockProposal.',
|
|
206
|
+
...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidCheckpointProposalOnly),
|
|
207
|
+
},
|
|
193
208
|
injectFakeAttestation: {
|
|
194
209
|
description: 'Inject a fake attestation (for testing only)',
|
|
195
210
|
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation),
|
|
@@ -230,17 +245,31 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
230
245
|
description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
|
|
231
246
|
...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent),
|
|
232
247
|
},
|
|
248
|
+
skipBroadcastProposals: {
|
|
249
|
+
description: 'Skip broadcasting checkpoint and block proposals via gossipsub when proposer (for testing only)',
|
|
250
|
+
...booleanConfigHelper(false),
|
|
251
|
+
},
|
|
252
|
+
skipBroadcastCheckpointProposal: {
|
|
253
|
+
description:
|
|
254
|
+
'Skip broadcasting only the CheckpointProposal via gossipsub when proposer; the held last block is broadcast ' +
|
|
255
|
+
'standalone instead so peers still receive it as a proposed-but-uncheckpointed tip (for testing only)',
|
|
256
|
+
...booleanConfigHelper(false),
|
|
257
|
+
},
|
|
258
|
+
pauseProposingForSlots: {
|
|
259
|
+
description:
|
|
260
|
+
'List of slots for which the sequencer will not produce a proposal (for testing only). Attestation paths are unaffected.',
|
|
261
|
+
},
|
|
233
262
|
...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowListExtend']),
|
|
234
263
|
};
|
|
235
264
|
|
|
236
265
|
export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
|
|
266
|
+
...chainConfigMappings,
|
|
237
267
|
...validatorClientConfigMappings,
|
|
238
268
|
...sequencerConfigMappings,
|
|
239
269
|
...keyStoreConfigMappings,
|
|
240
270
|
...l1ReaderConfigMappings,
|
|
241
271
|
...sequencerTxSenderConfigMappings,
|
|
242
272
|
...sequencerPublisherConfigMappings,
|
|
243
|
-
...chainConfigMappings,
|
|
244
273
|
...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
|
|
245
274
|
};
|
|
246
275
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Fee Prediction
|
|
2
|
+
|
|
3
|
+
The `FeePredictor` predicts min fees for upcoming L2 slots based on the current L1
|
|
4
|
+
oracle state and an assumed mana usage pattern.
|
|
5
|
+
|
|
6
|
+
## Prediction Window
|
|
7
|
+
|
|
8
|
+
The prediction covers `LAG = 2` entries (the next available slot plus 1 more).
|
|
9
|
+
A new oracle update can activate at `startSlot + LAG`, so only the first LAG entries
|
|
10
|
+
are guaranteed stable. Beyond that, L1 fees could change unpredictably.
|
|
11
|
+
|
|
12
|
+
Each entry uses:
|
|
13
|
+
|
|
14
|
+
- The **actual L1 fees** the oracle would return for that slot's timestamp (pre or post,
|
|
15
|
+
depending on whether the slot is before or after `slotOfChange`).
|
|
16
|
+
- A **configurable congestion assumption** (`ManaUsageEstimate`): none (0 mana), target
|
|
17
|
+
(steady state), or limit (worst case, 2x target).
|
|
18
|
+
|
|
19
|
+
The client picks `max(predicted[0..LAG-1])` as their `maxFeesPerGas`.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
predicted[0] → fee at next slot (current oracle + current congestion)
|
|
23
|
+
predicted[1] → fee at next slot + 1 (congestion may change based on usage estimate)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Why LAG and not LIFETIME?
|
|
27
|
+
|
|
28
|
+
The L1 gas oracle has two timing constants:
|
|
29
|
+
|
|
30
|
+
- **LAG = 2 slots**: when new fees are queued, they activate LAG slots later
|
|
31
|
+
- **LIFETIME = 5 slots**: after an oracle update, the next update is rejected until
|
|
32
|
+
`slotOfChange + (LIFETIME - LAG)` slots have passed
|
|
33
|
+
|
|
34
|
+
If the oracle cooldown has already elapsed (i.e., no recent update), a new update can
|
|
35
|
+
be enqueued at any moment. Its new values would activate LAG slots later. This means
|
|
36
|
+
predictions beyond LAG slots could be invalidated by an oracle update that happens
|
|
37
|
+
right after we query.
|
|
38
|
+
|
|
39
|
+
With a LIFETIME-sized window, we'd give a false sense of coverage: the prediction
|
|
40
|
+
would look like it covers 6 slots, but slots beyond LAG could be wrong if an update
|
|
41
|
+
is enqueued after the prediction is computed.
|
|
42
|
+
|
|
43
|
+
By limiting to LAG entries, we guarantee that all predicted L1 fees are the ones that
|
|
44
|
+
will actually be used — no oracle update can change them within this window.
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { type L1FeeData, MAX_FEE_ASSET_PRICE_MODIFIER_BPS, type RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { times } from '@aztec/foundation/collection';
|
|
4
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
import { getSlotAtNextL1Block, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
6
|
+
import {
|
|
7
|
+
FEE_ORACLE_LAG,
|
|
8
|
+
GasFees,
|
|
9
|
+
MIN_ETH_PER_FEE_ASSET,
|
|
10
|
+
ManaUsageEstimate,
|
|
11
|
+
computeExcessMana,
|
|
12
|
+
computeManaMinFee,
|
|
13
|
+
} from '@aztec/stdlib/gas';
|
|
14
|
+
|
|
15
|
+
/** Cached rollup state for fee prediction. Refreshed once per L1 block. */
|
|
16
|
+
type FeeOracleState = {
|
|
17
|
+
lastSlot: SlotNumber;
|
|
18
|
+
excessMana: bigint;
|
|
19
|
+
ethPerFeeAsset: bigint;
|
|
20
|
+
manaTarget: bigint;
|
|
21
|
+
manaLimit: bigint;
|
|
22
|
+
provingCostPerManaEth: bigint;
|
|
23
|
+
epochDuration: bigint;
|
|
24
|
+
/** Pre-resolved L1 fees for each slot in the prediction window. */
|
|
25
|
+
l1FeesBySlot: L1FeeData[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Predicts min fees for LAG upcoming slots based on the L1 oracle state.
|
|
30
|
+
* A new oracle update can activate at startSlot + LAG, so only the first LAG entries
|
|
31
|
+
* are guaranteed stable. Caches L1 queries per L1 block and recomputes predictions
|
|
32
|
+
* for each mana usage estimate.
|
|
33
|
+
*/
|
|
34
|
+
export class FeePredictor {
|
|
35
|
+
private cachedState: Promise<FeeOracleState> | undefined;
|
|
36
|
+
private cachedL1BlockNumber: bigint | undefined;
|
|
37
|
+
|
|
38
|
+
private readonly slotDuration: number;
|
|
39
|
+
private readonly l1GenesisTime: bigint;
|
|
40
|
+
private readonly ethereumSlotDuration: number;
|
|
41
|
+
|
|
42
|
+
constructor(
|
|
43
|
+
private readonly rollupContract: RollupContract,
|
|
44
|
+
private readonly publicClient: { getBlockNumber: (opts?: { cacheTime?: number }) => Promise<bigint> },
|
|
45
|
+
private readonly dateProvider: DateProvider,
|
|
46
|
+
config: { slotDuration: number; l1GenesisTime: bigint; ethereumSlotDuration: number },
|
|
47
|
+
) {
|
|
48
|
+
this.slotDuration = config.slotDuration;
|
|
49
|
+
this.l1GenesisTime = config.l1GenesisTime;
|
|
50
|
+
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Returns predicted min fees for each slot in the prediction window. */
|
|
54
|
+
async getPredictedMinFees(manaUsage: ManaUsageEstimate): Promise<GasFees[]> {
|
|
55
|
+
const state = await this.getState();
|
|
56
|
+
return this.computePredictions(state, manaUsage);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Fetches and caches rollup state. Refreshes when L1 block number advances. */
|
|
60
|
+
private async getState(): Promise<FeeOracleState> {
|
|
61
|
+
const blockNumber = await this.publicClient.getBlockNumber({ cacheTime: 0 });
|
|
62
|
+
if (this.cachedL1BlockNumber === undefined || blockNumber > this.cachedL1BlockNumber) {
|
|
63
|
+
this.cachedL1BlockNumber = blockNumber;
|
|
64
|
+
this.cachedState = this.fetchState(blockNumber);
|
|
65
|
+
}
|
|
66
|
+
return this.cachedState!;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private async fetchState(blockNumber: bigint): Promise<FeeOracleState> {
|
|
70
|
+
// Pin all non-constant queries to this L1 block number for a consistent snapshot.
|
|
71
|
+
const opts = { blockNumber };
|
|
72
|
+
|
|
73
|
+
// Cached constants don't need pinning
|
|
74
|
+
const [manaTarget, manaLimit, provingCostPerManaEth, epochDuration] = await Promise.all([
|
|
75
|
+
this.rollupContract.getManaTarget(),
|
|
76
|
+
this.rollupContract.getManaLimit(),
|
|
77
|
+
this.rollupContract.getProvingCostPerMana(),
|
|
78
|
+
this.rollupContract.getEpochDuration(),
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
// First, compute the earliest possible nextSlot independently of the checkpoint, so we can
|
|
82
|
+
// evaluate pruneability at the prediction start timestamp instead of the current L1 block time.
|
|
83
|
+
// This avoids an epoch-boundary edge case where the effective parent differs between now and nextSlot.
|
|
84
|
+
const slotConfig = { slotDuration: this.slotDuration, l1GenesisTime: this.l1GenesisTime };
|
|
85
|
+
const currentSlot = await this.rollupContract.getSlotNumber(opts);
|
|
86
|
+
|
|
87
|
+
const slotAtNextL1Block = getSlotAtNextL1Block(BigInt(this.dateProvider.nowInSeconds()), {
|
|
88
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
89
|
+
slotDuration: this.slotDuration,
|
|
90
|
+
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
91
|
+
});
|
|
92
|
+
const preliminaryNextSlot = SlotNumber(Math.max(currentSlot, slotAtNextL1Block));
|
|
93
|
+
const nextSlotTimestamp = getTimestampForSlot(preliminaryNextSlot, slotConfig);
|
|
94
|
+
|
|
95
|
+
// Resolve the effective checkpoint at the prediction start timestamp
|
|
96
|
+
const lastCheckpoint = await this.rollupContract.getEffectivePendingCheckpoint(nextSlotTimestamp, opts);
|
|
97
|
+
const lastSlot = lastCheckpoint.slotNumber;
|
|
98
|
+
// Refine nextSlot: also account for the slot after the last checkpoint
|
|
99
|
+
const nextSlot = SlotNumber(Math.max(SlotNumber.add(lastSlot, 1), preliminaryNextSlot));
|
|
100
|
+
const feeHeader = lastCheckpoint.feeHeader;
|
|
101
|
+
|
|
102
|
+
const slotCount = FEE_ORACLE_LAG;
|
|
103
|
+
const timestamps = times(slotCount, i => getTimestampForSlot(SlotNumber.add(nextSlot, i), slotConfig));
|
|
104
|
+
const l1FeesBySlot = await Promise.all(timestamps.map(ts => this.rollupContract.getL1FeesAt(ts, opts)));
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
lastSlot,
|
|
108
|
+
excessMana: computeExcessMana(feeHeader.excessMana, feeHeader.manaUsed, manaTarget),
|
|
109
|
+
ethPerFeeAsset: feeHeader.ethPerFeeAsset,
|
|
110
|
+
manaTarget,
|
|
111
|
+
manaLimit,
|
|
112
|
+
provingCostPerManaEth,
|
|
113
|
+
epochDuration: BigInt(epochDuration),
|
|
114
|
+
l1FeesBySlot,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Computes per-slot fee predictions given cached state and a mana usage assumption. */
|
|
119
|
+
private computePredictions(state: FeeOracleState, manaUsage: ManaUsageEstimate): GasFees[] {
|
|
120
|
+
const assumedManaUsed = this.getAssumedManaUsed(state, manaUsage);
|
|
121
|
+
|
|
122
|
+
const result: GasFees[] = [];
|
|
123
|
+
let { excessMana } = state;
|
|
124
|
+
let { ethPerFeeAsset } = state;
|
|
125
|
+
|
|
126
|
+
// Slot 0: current state (next available slot after last checkpoint)
|
|
127
|
+
result.push(this.computeGasFees(state, excessMana, ethPerFeeAsset, state.l1FeesBySlot[0]));
|
|
128
|
+
|
|
129
|
+
// Slots 1..LAG-1: advance excessMana with the assumed mana usage per checkpoint,
|
|
130
|
+
// and decay ethPerFeeAsset by MAX_FEE_ASSET_PRICE_MODIFIER_BPS per slot for conservative estimates.
|
|
131
|
+
// Lower ethPerFeeAsset means higher fees in fee asset terms.
|
|
132
|
+
for (let i = 1; i < state.l1FeesBySlot.length; i++) {
|
|
133
|
+
excessMana = computeExcessMana(excessMana, assumedManaUsed, state.manaTarget);
|
|
134
|
+
const decayed = (ethPerFeeAsset * (10000n - MAX_FEE_ASSET_PRICE_MODIFIER_BPS)) / 10000n;
|
|
135
|
+
ethPerFeeAsset = decayed < MIN_ETH_PER_FEE_ASSET ? MIN_ETH_PER_FEE_ASSET : decayed;
|
|
136
|
+
result.push(this.computeGasFees(state, excessMana, ethPerFeeAsset, state.l1FeesBySlot[i]));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private getAssumedManaUsed(state: FeeOracleState, manaUsage: ManaUsageEstimate): bigint {
|
|
143
|
+
switch (manaUsage) {
|
|
144
|
+
case ManaUsageEstimate.None:
|
|
145
|
+
return 0n;
|
|
146
|
+
case ManaUsageEstimate.Target:
|
|
147
|
+
return state.manaTarget;
|
|
148
|
+
case ManaUsageEstimate.Limit:
|
|
149
|
+
return state.manaLimit;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private computeGasFees(
|
|
154
|
+
state: FeeOracleState,
|
|
155
|
+
excessMana: bigint,
|
|
156
|
+
ethPerFeeAsset: bigint,
|
|
157
|
+
l1Fees: L1FeeData,
|
|
158
|
+
): GasFees {
|
|
159
|
+
return new GasFees(
|
|
160
|
+
0,
|
|
161
|
+
computeManaMinFee({
|
|
162
|
+
l1BaseFee: l1Fees.baseFee,
|
|
163
|
+
l1BlobFee: l1Fees.blobFee,
|
|
164
|
+
manaTarget: state.manaTarget,
|
|
165
|
+
epochDuration: state.epochDuration,
|
|
166
|
+
provingCostPerManaEth: state.provingCostPerManaEth,
|
|
167
|
+
excessMana,
|
|
168
|
+
ethPerFeeAsset,
|
|
169
|
+
}),
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
3
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
import { getNextL1SlotTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
6
|
+
import { GasFees, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
7
|
+
import type { FeeProvider } from '@aztec/stdlib/tx';
|
|
8
|
+
|
|
9
|
+
import { FeePredictor } from './fee_predictor.js';
|
|
10
|
+
import type { GlobalVariableBuilderConfig } from './global_builder.js';
|
|
11
|
+
|
|
12
|
+
/** Provides current and predicted fee information based on on-chain state. */
|
|
13
|
+
export class FeeProviderImpl implements FeeProvider {
|
|
14
|
+
private currentMinFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
|
|
15
|
+
private currentL1BlockNumber: bigint | undefined = undefined;
|
|
16
|
+
|
|
17
|
+
private readonly rollupContract: RollupContract;
|
|
18
|
+
private readonly feePredictor: FeePredictor;
|
|
19
|
+
private readonly ethereumSlotDuration: number;
|
|
20
|
+
private readonly l1GenesisTime: bigint;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
private readonly dateProvider: DateProvider,
|
|
24
|
+
private readonly publicClient: ViemPublicClient,
|
|
25
|
+
config: GlobalVariableBuilderConfig,
|
|
26
|
+
) {
|
|
27
|
+
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
28
|
+
this.l1GenesisTime = config.l1GenesisTime;
|
|
29
|
+
|
|
30
|
+
this.rollupContract = new RollupContract(this.publicClient, config.rollupAddress);
|
|
31
|
+
this.feePredictor = new FeePredictor(this.rollupContract, this.publicClient, this.dateProvider, {
|
|
32
|
+
slotDuration: config.slotDuration,
|
|
33
|
+
l1GenesisTime: config.l1GenesisTime,
|
|
34
|
+
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
|
|
40
|
+
* @returns Min fees for the next block
|
|
41
|
+
*/
|
|
42
|
+
private async computeCurrentMinFees(): Promise<GasFees> {
|
|
43
|
+
// Since this might be called in the middle of a slot where a block might have been published,
|
|
44
|
+
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
45
|
+
// The timestamp of that last block will act as a lower bound for the next block.
|
|
46
|
+
|
|
47
|
+
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
48
|
+
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
49
|
+
SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
|
|
50
|
+
);
|
|
51
|
+
const nextEthTimestamp = getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
|
|
52
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
53
|
+
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
54
|
+
});
|
|
55
|
+
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
56
|
+
|
|
57
|
+
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public async getCurrentMinFees(): Promise<GasFees> {
|
|
61
|
+
// Get the current block number
|
|
62
|
+
const blockNumber = await this.publicClient.getBlockNumber();
|
|
63
|
+
|
|
64
|
+
// If the L1 block number has changed then chain a new promise to get the current min fees
|
|
65
|
+
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
66
|
+
this.currentL1BlockNumber = blockNumber;
|
|
67
|
+
this.currentMinFees = this.currentMinFees.then(() => this.computeCurrentMinFees());
|
|
68
|
+
}
|
|
69
|
+
return this.currentMinFees;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]> {
|
|
73
|
+
return this.feePredictor.getPredictedMinFees(manaUsage ?? ManaUsageEstimate.Target);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
RollupContract,
|
|
3
|
+
type SimulationOverridesPlan,
|
|
4
|
+
buildSimulationOverridesStateOverride,
|
|
5
|
+
} from '@aztec/ethereum/contracts';
|
|
3
6
|
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
4
7
|
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
5
8
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
9
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
8
10
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
9
11
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
12
|
import { type L1RollupConstants, getNextL1SlotTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
@@ -17,7 +19,7 @@ import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
|
17
19
|
|
|
18
20
|
/** Configuration for the GlobalVariableBuilder (excludes L1 client config). */
|
|
19
21
|
export type GlobalVariableBuilderConfig = {
|
|
20
|
-
|
|
22
|
+
rollupAddress: EthAddress;
|
|
21
23
|
ethereumSlotDuration: number;
|
|
22
24
|
rollupVersion: bigint;
|
|
23
25
|
} & Pick<L1RollupConstants, 'slotDuration' | 'l1GenesisTime'>;
|
|
@@ -26,10 +28,6 @@ export type GlobalVariableBuilderConfig = {
|
|
|
26
28
|
* Simple global variables builder.
|
|
27
29
|
*/
|
|
28
30
|
export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
29
|
-
private log = createLogger('sequencer:global_variable_builder');
|
|
30
|
-
private currentMinFees: Promise<GasFees> = Promise.resolve(new GasFees(0, 0));
|
|
31
|
-
private currentL1BlockNumber: bigint | undefined = undefined;
|
|
32
|
-
|
|
33
31
|
private readonly rollupContract: RollupContract;
|
|
34
32
|
private readonly ethereumSlotDuration: number;
|
|
35
33
|
private readonly aztecSlotDuration: number;
|
|
@@ -50,41 +48,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
50
48
|
this.aztecSlotDuration = config.slotDuration;
|
|
51
49
|
this.l1GenesisTime = config.l1GenesisTime;
|
|
52
50
|
|
|
53
|
-
this.rollupContract = new RollupContract(this.publicClient, config.
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Computes the "current" min fees, e.g., the price that you currently should pay to get include in the next block
|
|
58
|
-
* @returns Min fees for the next block
|
|
59
|
-
*/
|
|
60
|
-
private async computeCurrentMinFees(): Promise<GasFees> {
|
|
61
|
-
// Since this might be called in the middle of a slot where a block might have been published,
|
|
62
|
-
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
|
|
63
|
-
// The timestamp of that last block will act as a lower bound for the next block.
|
|
64
|
-
|
|
65
|
-
const lastCheckpoint = await this.rollupContract.getPendingCheckpoint();
|
|
66
|
-
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
|
|
67
|
-
SlotNumber.fromBigInt(BigInt(lastCheckpoint.slotNumber) + 1n),
|
|
68
|
-
);
|
|
69
|
-
const nextEthTimestamp = getNextL1SlotTimestamp(this.dateProvider.nowInSeconds(), {
|
|
70
|
-
l1GenesisTime: this.l1GenesisTime,
|
|
71
|
-
ethereumSlotDuration: this.ethereumSlotDuration,
|
|
72
|
-
});
|
|
73
|
-
const timestamp = earliestTimestamp > nextEthTimestamp ? earliestTimestamp : nextEthTimestamp;
|
|
74
|
-
|
|
75
|
-
return new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public async getCurrentMinFees(): Promise<GasFees> {
|
|
79
|
-
// Get the current block number
|
|
80
|
-
const blockNumber = await this.publicClient.getBlockNumber();
|
|
81
|
-
|
|
82
|
-
// If the L1 block number has changed then chain a new promise to get the current min fees
|
|
83
|
-
if (this.currentL1BlockNumber === undefined || blockNumber > this.currentL1BlockNumber) {
|
|
84
|
-
this.currentL1BlockNumber = blockNumber;
|
|
85
|
-
this.currentMinFees = this.currentMinFees.then(() => this.computeCurrentMinFees());
|
|
86
|
-
}
|
|
87
|
-
return this.currentMinFees;
|
|
51
|
+
this.rollupContract = new RollupContract(this.publicClient, config.rollupAddress);
|
|
88
52
|
}
|
|
89
53
|
|
|
90
54
|
/**
|
|
@@ -119,6 +83,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
119
83
|
coinbase: EthAddress,
|
|
120
84
|
feeRecipient: AztecAddress,
|
|
121
85
|
slotNumber: SlotNumber,
|
|
86
|
+
simulationOverridesPlan?: SimulationOverridesPlan,
|
|
122
87
|
): Promise<CheckpointGlobalVariables> {
|
|
123
88
|
const { chainId, version } = this;
|
|
124
89
|
|
|
@@ -127,9 +92,8 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
127
92
|
l1GenesisTime: this.l1GenesisTime,
|
|
128
93
|
});
|
|
129
94
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
95
|
+
const stateOverride = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
|
|
96
|
+
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true, stateOverride));
|
|
133
97
|
|
|
134
98
|
return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
|
|
135
99
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
export * from './client/index.js';
|
|
2
2
|
export * from './config.js';
|
|
3
3
|
export * from './publisher/index.js';
|
|
4
|
-
export {
|
|
4
|
+
export {
|
|
5
|
+
AutomineSequencer,
|
|
6
|
+
type AutomineSequencerConstants,
|
|
7
|
+
type AutomineSequencerDeps,
|
|
8
|
+
createAutomineSequencer,
|
|
9
|
+
type CreateAutomineSequencerArgs,
|
|
10
|
+
Sequencer,
|
|
11
|
+
SequencerState,
|
|
12
|
+
type SequencerEvents,
|
|
13
|
+
} from './sequencer/index.js';
|
|
5
14
|
|
|
6
15
|
// Used by the node to simulate public parts of transactions. Should these be moved to a shared library?
|
|
7
16
|
// ISSUE(#9832)
|
package/src/publisher/config.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from '@aztec/ethereum/l
|
|
|
4
4
|
import { type ConfigMappingsType, SecretValue, booleanConfigHelper } from '@aztec/foundation/config';
|
|
5
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
6
|
|
|
7
|
+
import { parseEther } from 'viem';
|
|
8
|
+
|
|
7
9
|
/** Configuration of the transaction publisher. */
|
|
8
10
|
export type TxSenderConfig = L1ReaderConfig & {
|
|
9
11
|
/** The private key to be used by the publisher. */
|
|
@@ -48,13 +50,39 @@ export type PublisherConfig = L1TxUtilsConfig &
|
|
|
48
50
|
fishermanMode?: boolean;
|
|
49
51
|
/** Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only) */
|
|
50
52
|
publisherForwarderAddress?: EthAddress;
|
|
53
|
+
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
54
|
+
l1TxFailedStore?: string;
|
|
55
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
56
|
+
publisherFundingThreshold?: bigint;
|
|
57
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
58
|
+
publisherFundingAmount?: bigint;
|
|
51
59
|
};
|
|
52
60
|
|
|
61
|
+
/** Shared config mappings for publisher funding, used by both sequencer and prover publisher configs. */
|
|
62
|
+
const publisherFundingConfigMappings = {
|
|
63
|
+
publisherFundingThreshold: {
|
|
64
|
+
env: 'PUBLISHER_FUNDING_THRESHOLD' as const,
|
|
65
|
+
description:
|
|
66
|
+
'Min ETH balance below which a publisher gets funded. Specified in ether (e.g. 0.1). Unset = funding disabled.',
|
|
67
|
+
parseEnv: (val: string) => parseEther(val),
|
|
68
|
+
},
|
|
69
|
+
publisherFundingAmount: {
|
|
70
|
+
env: 'PUBLISHER_FUNDING_AMOUNT' as const,
|
|
71
|
+
description:
|
|
72
|
+
'Amount of ETH to send when funding a publisher. Specified in ether (e.g. 0.5). Unset = funding disabled.',
|
|
73
|
+
parseEnv: (val: string) => parseEther(val),
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
53
77
|
export type ProverPublisherConfig = L1TxUtilsConfig &
|
|
54
78
|
BlobClientConfig & {
|
|
55
79
|
fishermanMode?: boolean;
|
|
56
80
|
proverPublisherAllowInvalidStates?: boolean;
|
|
57
81
|
proverPublisherForwarderAddress?: EthAddress;
|
|
82
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
83
|
+
publisherFundingThreshold?: bigint;
|
|
84
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
85
|
+
publisherFundingAmount?: bigint;
|
|
58
86
|
};
|
|
59
87
|
|
|
60
88
|
export type SequencerPublisherConfig = L1TxUtilsConfig &
|
|
@@ -62,6 +90,12 @@ export type SequencerPublisherConfig = L1TxUtilsConfig &
|
|
|
62
90
|
fishermanMode?: boolean;
|
|
63
91
|
sequencerPublisherAllowInvalidStates?: boolean;
|
|
64
92
|
sequencerPublisherForwarderAddress?: EthAddress;
|
|
93
|
+
/** Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path */
|
|
94
|
+
l1TxFailedStore?: string;
|
|
95
|
+
/** Min ETH balance below which a publisher gets funded. Undefined = funding disabled. */
|
|
96
|
+
publisherFundingThreshold?: bigint;
|
|
97
|
+
/** Amount of ETH to send when funding a publisher. Undefined = funding disabled. */
|
|
98
|
+
publisherFundingAmount?: bigint;
|
|
65
99
|
};
|
|
66
100
|
|
|
67
101
|
export function getPublisherConfigFromProverConfig(config: ProverPublisherConfig): PublisherConfig {
|
|
@@ -77,15 +111,17 @@ export function getPublisherConfigFromSequencerConfig(config: SequencerPublisher
|
|
|
77
111
|
...config,
|
|
78
112
|
publisherAllowInvalidStates: config.sequencerPublisherAllowInvalidStates,
|
|
79
113
|
publisherForwarderAddress: config.sequencerPublisherForwarderAddress,
|
|
114
|
+
l1TxFailedStore: config.l1TxFailedStore,
|
|
80
115
|
};
|
|
81
116
|
}
|
|
82
117
|
|
|
83
|
-
export const proverTxSenderConfigMappings: ConfigMappingsType<
|
|
118
|
+
export const proverTxSenderConfigMappings: ConfigMappingsType<ProverTxSenderConfig> = {
|
|
84
119
|
...l1ReaderConfigMappings,
|
|
85
120
|
proverPublisherPrivateKeys: {
|
|
86
121
|
env: `PROVER_PUBLISHER_PRIVATE_KEYS`,
|
|
87
122
|
description: 'The private keys to be used by the prover publisher.',
|
|
88
|
-
parseEnv: (val: string) =>
|
|
123
|
+
parseEnv: (val: string) =>
|
|
124
|
+
val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}` as `0x${string}`)),
|
|
89
125
|
defaultValue: [],
|
|
90
126
|
fallback: [`PROVER_PUBLISHER_PRIVATE_KEY`],
|
|
91
127
|
},
|
|
@@ -97,12 +133,13 @@ export const proverTxSenderConfigMappings: ConfigMappingsType<Omit<ProverTxSende
|
|
|
97
133
|
},
|
|
98
134
|
};
|
|
99
135
|
|
|
100
|
-
export const sequencerTxSenderConfigMappings: ConfigMappingsType<
|
|
136
|
+
export const sequencerTxSenderConfigMappings: ConfigMappingsType<SequencerTxSenderConfig> = {
|
|
101
137
|
...l1ReaderConfigMappings,
|
|
102
138
|
sequencerPublisherPrivateKeys: {
|
|
103
139
|
env: `SEQ_PUBLISHER_PRIVATE_KEYS`,
|
|
104
140
|
description: 'The private keys to be used by the sequencer publisher.',
|
|
105
|
-
parseEnv: (val: string) =>
|
|
141
|
+
parseEnv: (val: string) =>
|
|
142
|
+
val.split(',').map(key => new SecretValue(`0x${key.replace('0x', '')}` as `0x${string}`)),
|
|
106
143
|
defaultValue: [],
|
|
107
144
|
fallback: [`SEQ_PUBLISHER_PRIVATE_KEY`],
|
|
108
145
|
},
|
|
@@ -131,8 +168,13 @@ export const sequencerPublisherConfigMappings: ConfigMappingsType<SequencerPubli
|
|
|
131
168
|
sequencerPublisherForwarderAddress: {
|
|
132
169
|
env: `SEQ_PUBLISHER_FORWARDER_ADDRESS`,
|
|
133
170
|
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
134
|
-
parseEnv: (val: string) =>
|
|
171
|
+
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
172
|
+
},
|
|
173
|
+
l1TxFailedStore: {
|
|
174
|
+
env: 'L1_TX_FAILED_STORE',
|
|
175
|
+
description: 'Store for failed L1 transaction inputs (test networks only). Format: gs://bucket/path',
|
|
135
176
|
},
|
|
177
|
+
...publisherFundingConfigMappings,
|
|
136
178
|
};
|
|
137
179
|
|
|
138
180
|
export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherConfig & L1TxUtilsConfig> = {
|
|
@@ -152,6 +194,7 @@ export const proverPublisherConfigMappings: ConfigMappingsType<ProverPublisherCo
|
|
|
152
194
|
proverPublisherForwarderAddress: {
|
|
153
195
|
env: `PROVER_PUBLISHER_FORWARDER_ADDRESS`,
|
|
154
196
|
description: 'Address of the forwarder contract to wrap all L1 transactions through (for testing purposes only)',
|
|
155
|
-
parseEnv: (val: string) =>
|
|
197
|
+
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
156
198
|
},
|
|
199
|
+
...publisherFundingConfigMappings,
|
|
157
200
|
};
|