@aztec/sequencer-client 5.0.0-private.20260318 → 5.0.0-rc.1
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 +8 -15
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +35 -96
- package/dest/config.d.ts +8 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +48 -26
- 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 +67 -0
- package/dest/global_variable_builder/global_builder.d.ts +14 -14
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +16 -51
- package/dest/global_variable_builder/index.d.ts +4 -2
- package/dest/global_variable_builder/index.d.ts.map +1 -1
- package/dest/global_variable_builder/index.js +2 -0
- package/dest/publisher/config.d.ts +15 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +19 -4
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts +3 -4
- package/dest/publisher/l1_tx_failed_store/failed_tx_store.d.ts.map +1 -1
- 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 +2 -3
- package/dest/publisher/sequencer-publisher.d.ts +73 -65
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +317 -532
- package/dest/sequencer/automine/automine_factory.d.ts +56 -0
- package/dest/sequencer/automine/automine_factory.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_factory.js +85 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts +184 -0
- package/dest/sequencer/automine/automine_sequencer.d.ts.map +1 -0
- package/dest/sequencer/automine/automine_sequencer.js +677 -0
- package/dest/sequencer/automine/index.d.ts +3 -0
- package/dest/sequencer/automine/index.d.ts.map +1 -0
- package/dest/sequencer/automine/index.js +2 -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 +77 -17
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +768 -209
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts +34 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.d.ts.map +1 -0
- package/dest/sequencer/checkpoint_proposal_job_metrics.js +72 -0
- package/dest/sequencer/checkpoint_voter.d.ts +1 -2
- package/dest/sequencer/checkpoint_voter.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_voter.js +2 -5
- package/dest/sequencer/errors.d.ts +1 -8
- package/dest/sequencer/errors.d.ts.map +1 -1
- package/dest/sequencer/errors.js +0 -9
- package/dest/sequencer/events.d.ts +62 -4
- package/dest/sequencer/events.d.ts.map +1 -1
- 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 +115 -30
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +506 -174
- package/dest/sequencer/types.d.ts +2 -2
- package/dest/sequencer/types.d.ts.map +1 -1
- package/dest/test/index.d.ts +3 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/mock_checkpoint_builder.d.ts +4 -8
- package/dest/test/mock_checkpoint_builder.d.ts.map +1 -1
- package/dest/test/utils.d.ts +15 -1
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +23 -6
- package/package.json +28 -27
- package/src/client/sequencer-client.ts +53 -123
- package/src/config.ts +57 -23
- 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 +80 -0
- package/src/global_variable_builder/global_builder.ts +25 -63
- package/src/global_variable_builder/index.ts +3 -1
- package/src/publisher/config.ts +40 -6
- package/src/publisher/l1_tx_failed_store/failed_tx_store.ts +3 -1
- package/src/publisher/sequencer-bundle-simulator.ts +254 -0
- package/src/publisher/sequencer-publisher-factory.ts +3 -6
- package/src/publisher/sequencer-publisher.ts +376 -577
- package/src/sequencer/automine/README.md +60 -0
- package/src/sequencer/automine/automine_factory.ts +152 -0
- package/src/sequencer/automine/automine_sequencer.ts +783 -0
- package/src/sequencer/automine/index.ts +6 -0
- package/src/sequencer/chain_state_overrides.ts +169 -0
- package/src/sequencer/checkpoint_proposal_job.ts +917 -241
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/checkpoint_voter.ts +1 -12
- package/src/sequencer/errors.ts +0 -15
- package/src/sequencer/events.ts +65 -4
- package/src/sequencer/metrics.ts +57 -24
- package/src/sequencer/sequencer.ts +604 -195
- package/src/sequencer/types.ts +1 -1
- package/src/test/index.ts +2 -2
- package/src/test/mock_checkpoint_builder.ts +3 -3
- package/src/test/utils.ts +59 -10
- package/dest/sequencer/timetable.d.ts +0 -88
- package/dest/sequencer/timetable.d.ts.map +0 -1
- package/dest/sequencer/timetable.js +0 -222
- package/src/sequencer/README.md +0 -531
- package/src/sequencer/timetable.ts +0 -283
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
|
|
2
2
|
import { EpochCache } from '@aztec/epoch-cache';
|
|
3
|
-
import { isAnvilTestChain } from '@aztec/ethereum/chain';
|
|
4
3
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
5
4
|
import { GovernanceProposerContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
6
5
|
import { PublisherManager } from '@aztec/ethereum/publisher-manager';
|
|
7
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
6
|
import { createLogger } from '@aztec/foundation/log';
|
|
9
|
-
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
10
7
|
import { L1Metrics } from '@aztec/telemetry-client';
|
|
11
8
|
import { NodeKeystoreAdapter } from '@aztec/validator-client';
|
|
12
|
-
import {
|
|
13
|
-
import { GlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
9
|
+
import { getPublisherConfigFromSequencerConfig } from '../config.js';
|
|
14
10
|
import { SequencerPublisherFactory } from '../publisher/sequencer-publisher-factory.js';
|
|
15
11
|
import { Sequencer } from '../sequencer/index.js';
|
|
16
|
-
import { SequencerTimetable } from '../sequencer/timetable.js';
|
|
17
12
|
/**
|
|
18
13
|
* Encapsulates the full sequencer and publisher.
|
|
19
14
|
*/ export class SequencerClient {
|
|
@@ -49,16 +44,18 @@ import { SequencerTimetable } from '../sequencer/timetable.js';
|
|
|
49
44
|
const publicClient = getPublicClient(config);
|
|
50
45
|
const l1TxUtils = deps.l1TxUtils;
|
|
51
46
|
const l1Metrics = new L1Metrics(telemetryClient.getMeter('L1PublisherMetrics'), publicClient, l1TxUtils.map((x)=>x.getSenderAddress()));
|
|
52
|
-
const publisherManager = new PublisherManager(l1TxUtils, getPublisherConfigFromSequencerConfig(config),
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
const publisherManager = new PublisherManager(l1TxUtils, getPublisherConfigFromSequencerConfig(config), {
|
|
48
|
+
bindings: log.getBindings(),
|
|
49
|
+
funder: deps.funderL1TxUtils
|
|
50
|
+
});
|
|
51
|
+
const rollupContract = new RollupContract(publicClient, config.rollupAddress.toString());
|
|
52
|
+
const [l1GenesisTime, slotDuration, rollupManaLimit] = await Promise.all([
|
|
55
53
|
rollupContract.getL1GenesisTime(),
|
|
56
54
|
rollupContract.getSlotDuration(),
|
|
57
|
-
rollupContract.getVersion(),
|
|
58
55
|
rollupContract.getManaLimit().then(Number)
|
|
59
56
|
]);
|
|
60
|
-
const governanceProposerContract = new GovernanceProposerContract(publicClient, config.
|
|
61
|
-
const epochCache = deps.epochCache ?? await EpochCache.create(config.
|
|
57
|
+
const governanceProposerContract = new GovernanceProposerContract(publicClient, config.governanceProposerAddress.toString());
|
|
58
|
+
const epochCache = deps.epochCache ?? await EpochCache.create(config.rollupAddress, {
|
|
62
59
|
l1RpcUrls: rpcUrls,
|
|
63
60
|
l1ChainId: chainId,
|
|
64
61
|
viemPollingIntervalMS: config.viemPollingIntervalMS,
|
|
@@ -66,13 +63,11 @@ import { SequencerTimetable } from '../sequencer/timetable.js';
|
|
|
66
63
|
}, {
|
|
67
64
|
dateProvider: deps.dateProvider
|
|
68
65
|
});
|
|
69
|
-
const slashFactoryContract = new SlashFactoryContract(publicClient, config.l1Contracts.slashFactoryAddress?.toString() ?? EthAddress.ZERO.toString());
|
|
70
66
|
const publisherFactory = deps.publisherFactory ?? new SequencerPublisherFactory(config, {
|
|
71
67
|
telemetry: telemetryClient,
|
|
72
68
|
blobClient: deps.blobClient,
|
|
73
69
|
epochCache,
|
|
74
70
|
governanceProposerContract,
|
|
75
|
-
slashFactoryContract,
|
|
76
71
|
rollupContract,
|
|
77
72
|
dateProvider: deps.dateProvider,
|
|
78
73
|
publisherManager,
|
|
@@ -80,34 +75,20 @@ import { SequencerTimetable } from '../sequencer/timetable.js';
|
|
|
80
75
|
logger: log
|
|
81
76
|
});
|
|
82
77
|
const ethereumSlotDuration = config.ethereumSlotDuration;
|
|
83
|
-
const globalsBuilder =
|
|
84
|
-
|
|
85
|
-
l1GenesisTime,
|
|
86
|
-
slotDuration: Number(slotDuration),
|
|
87
|
-
ethereumSlotDuration,
|
|
88
|
-
rollupVersion
|
|
89
|
-
});
|
|
90
|
-
// When running in anvil, assume we can post a tx up until one second before the end of an L1 slot.
|
|
91
|
-
// Otherwise, we need the full L1 slot duration for publishing to ensure inclusion.
|
|
92
|
-
// In theory, the L1 slot has an initial 4s phase where the block is propagated, so we could
|
|
93
|
-
// reduce the publishing time allowance. However, we prefer being conservative.
|
|
94
|
-
// See https://www.blocknative.com/blog/anatomy-of-a-slot#7 for more info.
|
|
95
|
-
const l1PublishingTimeBasedOnChain = isAnvilTestChain(config.l1ChainId) ? 1 : ethereumSlotDuration;
|
|
96
|
-
const l1PublishingTime = config.l1PublishingTime ?? l1PublishingTimeBasedOnChain;
|
|
97
|
-
const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock, maxBlocksPerCheckpoint } = computeBlockLimits(config, rollupManaLimit, l1PublishingTime, log);
|
|
78
|
+
const globalsBuilder = deps.globalVariableBuilder;
|
|
79
|
+
const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = capPerBlockLimits(config, rollupManaLimit, log);
|
|
98
80
|
const l1Constants = {
|
|
99
81
|
l1GenesisTime,
|
|
100
82
|
slotDuration: Number(slotDuration),
|
|
101
83
|
ethereumSlotDuration,
|
|
102
|
-
rollupManaLimit
|
|
84
|
+
rollupManaLimit,
|
|
85
|
+
epochDuration: config.aztecEpochDuration
|
|
103
86
|
};
|
|
104
87
|
const sequencer = new Sequencer(publisherFactory, validatorClient, globalsBuilder, p2pClient, worldStateSynchronizer, slasherClient, l2BlockSource, l1ToL2MessageSource, checkpointsBuilder, l1Constants, deps.dateProvider, epochCache, rollupContract, {
|
|
105
88
|
...config,
|
|
106
|
-
l1PublishingTime,
|
|
107
89
|
maxL2BlockGas,
|
|
108
90
|
maxDABlockGas,
|
|
109
|
-
maxTxsPerBlock
|
|
110
|
-
maxBlocksPerCheckpoint
|
|
91
|
+
maxTxsPerBlock
|
|
111
92
|
}, telemetryClient, log);
|
|
112
93
|
sequencer.init();
|
|
113
94
|
// Extract the shared delayer from the first L1TxUtils instance (all instances share the same delayer)
|
|
@@ -126,16 +107,19 @@ import { SequencerTimetable } from '../sequencer/timetable.js';
|
|
|
126
107
|
await this.validatorClient?.start();
|
|
127
108
|
this.sequencer.start();
|
|
128
109
|
this.l1Metrics?.start();
|
|
129
|
-
await this.publisherManager.
|
|
110
|
+
await this.publisherManager.start();
|
|
130
111
|
}
|
|
131
112
|
/**
|
|
132
113
|
* Stops the sequencer from processing new txs.
|
|
133
114
|
*/ async stop() {
|
|
134
115
|
await this.sequencer.stop();
|
|
135
116
|
await this.validatorClient?.stop();
|
|
136
|
-
this.publisherManager.
|
|
117
|
+
await this.publisherManager.stop();
|
|
137
118
|
this.l1Metrics?.stop();
|
|
138
119
|
}
|
|
120
|
+
/** Triggers an immediate run of the sequencer, bypassing the polling interval. */ trigger() {
|
|
121
|
+
return this.sequencer.trigger();
|
|
122
|
+
}
|
|
139
123
|
getSequencer() {
|
|
140
124
|
return this.sequencer;
|
|
141
125
|
}
|
|
@@ -153,72 +137,27 @@ import { SequencerTimetable } from '../sequencer/timetable.js';
|
|
|
153
137
|
}
|
|
154
138
|
}
|
|
155
139
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
l1PublishingTime,
|
|
164
|
-
p2pPropagationTime: config.attestationPropagationTime,
|
|
165
|
-
blockDurationMs: config.blockDurationMs,
|
|
166
|
-
enforce: config.enforceTimeTable ?? DefaultSequencerConfig.enforceTimeTable
|
|
167
|
-
}).maxNumberOfBlocks;
|
|
168
|
-
const multiplier = config.perBlockAllocationMultiplier ?? DefaultSequencerConfig.perBlockAllocationMultiplier;
|
|
169
|
-
// Compute maxL2BlockGas
|
|
170
|
-
let maxL2BlockGas;
|
|
171
|
-
if (config.maxL2BlockGas !== undefined) {
|
|
172
|
-
if (config.maxL2BlockGas > rollupManaLimit) {
|
|
173
|
-
log.warn(`Provided MAX_L2_BLOCK_GAS ${config.maxL2BlockGas} exceeds L1 rollup mana limit ${rollupManaLimit} (capping)`);
|
|
174
|
-
maxL2BlockGas = rollupManaLimit;
|
|
175
|
-
} else {
|
|
176
|
-
maxL2BlockGas = config.maxL2BlockGas;
|
|
177
|
-
}
|
|
178
|
-
} else {
|
|
179
|
-
maxL2BlockGas = Math.min(rollupManaLimit, Math.ceil(rollupManaLimit / maxNumberOfBlocks * multiplier));
|
|
140
|
+
* Caps operator-provided per-block limits at checkpoint-level limits.
|
|
141
|
+
* Returns undefined for any limit the operator didn't set — the checkpoint builder handles redistribution.
|
|
142
|
+
*/ function capPerBlockLimits(config, rollupManaLimit, log) {
|
|
143
|
+
let maxL2BlockGas = config.maxL2BlockGas;
|
|
144
|
+
if (maxL2BlockGas !== undefined && maxL2BlockGas > rollupManaLimit) {
|
|
145
|
+
log.warn(`Provided MAX_L2_BLOCK_GAS ${maxL2BlockGas} exceeds rollup mana limit ${rollupManaLimit} (capping)`);
|
|
146
|
+
maxL2BlockGas = rollupManaLimit;
|
|
180
147
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (config.maxDABlockGas > daCheckpointLimit) {
|
|
186
|
-
log.warn(`Provided MAX_DA_BLOCK_GAS ${config.maxDABlockGas} exceeds DA checkpoint limit ${daCheckpointLimit} (capping)`);
|
|
187
|
-
maxDABlockGas = daCheckpointLimit;
|
|
188
|
-
} else {
|
|
189
|
-
maxDABlockGas = config.maxDABlockGas;
|
|
190
|
-
}
|
|
191
|
-
} else {
|
|
192
|
-
maxDABlockGas = Math.min(daCheckpointLimit, Math.ceil(daCheckpointLimit / maxNumberOfBlocks * multiplier));
|
|
148
|
+
let maxDABlockGas = config.maxDABlockGas;
|
|
149
|
+
if (maxDABlockGas !== undefined && maxDABlockGas > MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT) {
|
|
150
|
+
log.warn(`Provided MAX_DA_BLOCK_GAS ${maxDABlockGas} exceeds DA checkpoint limit ${MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT} (capping)`);
|
|
151
|
+
maxDABlockGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
|
|
193
152
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (config.maxTxsPerCheckpoint !== undefined && config.maxTxsPerBlock > config.maxTxsPerCheckpoint) {
|
|
199
|
-
log.warn(`Provided MAX_TX_PER_BLOCK ${config.maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`);
|
|
200
|
-
maxTxsPerBlock = config.maxTxsPerCheckpoint;
|
|
201
|
-
} else {
|
|
202
|
-
maxTxsPerBlock = config.maxTxsPerBlock;
|
|
203
|
-
}
|
|
204
|
-
} else if (config.maxTxsPerCheckpoint !== undefined) {
|
|
205
|
-
maxTxsPerBlock = Math.min(config.maxTxsPerCheckpoint, Math.ceil(config.maxTxsPerCheckpoint / maxNumberOfBlocks * multiplier));
|
|
206
|
-
} else {
|
|
207
|
-
maxTxsPerBlock = defaultMaxTxsPerBlock;
|
|
153
|
+
let maxTxsPerBlock = config.maxTxsPerBlock;
|
|
154
|
+
if (maxTxsPerBlock !== undefined && config.maxTxsPerCheckpoint !== undefined && maxTxsPerBlock > config.maxTxsPerCheckpoint) {
|
|
155
|
+
log.warn(`Provided MAX_TX_PER_BLOCK ${maxTxsPerBlock} exceeds MAX_TX_PER_CHECKPOINT ${config.maxTxsPerCheckpoint} (capping)`);
|
|
156
|
+
maxTxsPerBlock = config.maxTxsPerCheckpoint;
|
|
208
157
|
}
|
|
209
|
-
log.info(`Computed block limits L2=${maxL2BlockGas} DA=${maxDABlockGas} maxTxs=${maxTxsPerBlock}`, {
|
|
210
|
-
maxL2BlockGas,
|
|
211
|
-
maxDABlockGas,
|
|
212
|
-
maxTxsPerBlock,
|
|
213
|
-
rollupManaLimit,
|
|
214
|
-
daCheckpointLimit,
|
|
215
|
-
maxNumberOfBlocks,
|
|
216
|
-
multiplier
|
|
217
|
-
});
|
|
218
158
|
return {
|
|
219
159
|
maxL2BlockGas,
|
|
220
160
|
maxDABlockGas,
|
|
221
|
-
maxTxsPerBlock
|
|
222
|
-
maxBlocksPerCheckpoint: maxNumberOfBlocks
|
|
161
|
+
maxTxsPerBlock
|
|
223
162
|
};
|
|
224
163
|
}
|
package/dest/config.d.ts
CHANGED
|
@@ -18,14 +18,19 @@ export declare const DefaultSequencerConfig: {
|
|
|
18
18
|
buildCheckpointIfEmpty: false;
|
|
19
19
|
publishTxsWithProposals: false;
|
|
20
20
|
perBlockAllocationMultiplier: number;
|
|
21
|
+
perBlockDAAllocationMultiplier: number;
|
|
21
22
|
redistributeCheckpointBudget: true;
|
|
22
|
-
|
|
23
|
+
blockDurationMs: number;
|
|
24
|
+
l1PublishingTime: number;
|
|
25
|
+
checkpointProposalSyncGraceSeconds: number;
|
|
23
26
|
attestationPropagationTime: number;
|
|
24
27
|
secondsBeforeInvalidatingBlockAsCommitteeMember: number;
|
|
25
28
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: number;
|
|
26
29
|
skipCollectingAttestations: false;
|
|
27
30
|
skipInvalidateBlockAsProposer: false;
|
|
31
|
+
skipWaitForValidParentCheckpointOnL1: false;
|
|
28
32
|
broadcastInvalidBlockProposal: false;
|
|
33
|
+
broadcastInvalidCheckpointProposalOnly: false;
|
|
29
34
|
injectFakeAttestation: false;
|
|
30
35
|
injectHighSValueAttestation: false;
|
|
31
36
|
injectUnrecoverableSignatureAttestation: false;
|
|
@@ -33,6 +38,7 @@ export declare const DefaultSequencerConfig: {
|
|
|
33
38
|
shuffleAttestationOrdering: false;
|
|
34
39
|
skipPushProposedBlocksToArchiver: false;
|
|
35
40
|
skipPublishingCheckpointsPercent: number;
|
|
41
|
+
maxBlocksPerCheckpoint: number;
|
|
36
42
|
};
|
|
37
43
|
/**
|
|
38
44
|
* Configuration settings for the SequencerClient.
|
|
@@ -44,4 +50,4 @@ export declare const sequencerClientConfigMappings: ConfigMappingsType<Sequencer
|
|
|
44
50
|
* Creates an instance of SequencerClientConfig out of environment variables using sensible defaults for integration testing if not set.
|
|
45
51
|
*/
|
|
46
52
|
export declare function getConfigEnvVars(): SequencerClientConfig;
|
|
47
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLGlCQUFpQixFQUE2QixNQUFNLHdCQUF3QixDQUFDO0FBQzNGLE9BQU8sRUFBRSxLQUFLLGNBQWMsRUFBMEIsTUFBTSwyQkFBMkIsQ0FBQztBQUN4RixPQUFPLEVBQ0wsS0FBSyxrQkFBa0IsRUFPeEIsTUFBTSwwQkFBMEIsQ0FBQztBQUVsQyxPQUFPLEVBQUUsS0FBSyxjQUFjLEVBQTBCLE1BQU0sNkJBQTZCLENBQUM7QUFDMUYsT0FBTyxFQUFFLEtBQUssU0FBUyxFQUFxQixNQUFNLG1CQUFtQixDQUFDO0FBRXRFLE9BQU8sRUFDTCxLQUFLLFdBQVcsRUFHaEIsS0FBSyxlQUFlLEVBR3JCLE1BQU0sc0JBQXNCLENBQUM7QUFJOUIsT0FBTyxFQUFFLEtBQUsscUJBQXFCLEVBQWlDLE1BQU0sZ0NBQWdDLENBQUM7QUFFM0csT0FBTyxFQUNMLEtBQUssd0JBQXdCLEVBQzdCLEtBQUssdUJBQXVCLEVBRzdCLE1BQU0sdUJBQXVCLENBQUM7QUFFL0IsY0FBYyx1QkFBdUIsQ0FBQztBQUN0QyxZQUFZLEVBQUUsZUFBZSxFQUFFLENBQUM7QUFFaEM7OztHQUdHO0FBQ0gsZUFBTyxNQUFNLHNCQUFzQjs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0NBMkJBLENBQUM7QUFFcEM7O0dBRUc7QUFDSCxNQUFNLE1BQU0scUJBQXFCLEdBQUcsd0JBQXdCLEdBQzFELGNBQWMsR0FDZCxxQkFBcUIsR0FDckIsdUJBQXVCLEdBQ3ZCLGVBQWUsR0FDZixjQUFjLEdBQ2QsV0FBVyxHQUNYLElBQUksQ0FBQyxTQUFTLEVBQUUsOEJBQThCLENBQUMsR0FDL0MsSUFBSSxDQUFDLGlCQUFpQixFQUFFLHNCQUFzQixHQUFHLG1CQUFtQixHQUFHLG9CQUFvQixDQUFDLENBQUM7QUFFL0YsZUFBTyxNQUFNLHVCQUF1QixFQUFFLGtCQUFrQixDQUFDLGVBQWUsQ0EwTHZFLENBQUM7QUFFRixlQUFPLE1BQU0sNkJBQTZCLEVBQUUsa0JBQWtCLENBQUMscUJBQXFCLENBU25GLENBQUM7QUFFRjs7R0FFRztBQUNILHdCQUFnQixnQkFBZ0IsSUFBSSxxQkFBcUIsQ0FFeEQifQ==
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAA6B,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,2BAA2B,CAAC;AACxF,OAAO,EACL,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAA6B,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,2BAA2B,CAAC;AACxF,OAAO,EACL,KAAK,kBAAkB,EAOxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,6BAA6B,CAAC;AAC1F,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,mBAAmB,CAAC;AAEtE,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,eAAe,EAGrB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,KAAK,qBAAqB,EAAiC,MAAM,gCAAgC,CAAC;AAE3G,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAG7B,MAAM,uBAAuB,CAAC;AAE/B,cAAc,uBAAuB,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,wBAAwB,GAC1D,cAAc,GACd,qBAAqB,GACrB,uBAAuB,GACvB,eAAe,GACf,cAAc,GACd,WAAW,GACX,IAAI,CAAC,SAAS,EAAE,8BAA8B,CAAC,GAC/C,IAAI,CAAC,iBAAiB,EAAE,sBAAsB,GAAG,mBAAmB,GAAG,oBAAoB,CAAC,CAAC;AAE/F,eAAO,MAAM,uBAAuB,EAAE,kBAAkB,CAAC,eAAe,CA0LvE,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,kBAAkB,CAAC,qBAAqB,CASnF,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAExD"}
|
package/dest/config.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { l1ContractsConfigMappings } from '@aztec/ethereum/config';
|
|
2
2
|
import { l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
3
|
-
import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper, pickConfigMappings } from '@aztec/foundation/config';
|
|
3
|
+
import { booleanConfigHelper, floatConfigHelper, getConfigFromMappings, numberConfigHelper, optionalNumberConfigHelper, pickConfigMappings } from '@aztec/foundation/config';
|
|
4
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import { keyStoreConfigMappings } from '@aztec/node-keystore/config';
|
|
6
6
|
import { p2pConfigMappings } from '@aztec/p2p/config';
|
|
7
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import { chainConfigMappings, sharedSequencerConfigMappings } from '@aztec/stdlib/config';
|
|
8
|
+
import { DEFAULT_BLOCK_DURATION_MS, DEFAULT_MAX_BLOCKS_PER_CHECKPOINT, chainConfigMappings, sharedSequencerConfigMappings } from '@aztec/stdlib/config';
|
|
9
|
+
import { MIN_PER_BLOCK_ALLOCATION_MULTIPLIER, MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER } from '@aztec/stdlib/gas';
|
|
9
10
|
import { DEFAULT_P2P_PROPAGATION_TIME } from '@aztec/stdlib/timetable';
|
|
10
11
|
import { validatorClientConfigMappings } from '@aztec/validator-client/config';
|
|
11
12
|
import { sequencerPublisherConfigMappings, sequencerTxSenderConfigMappings } from './publisher/config.js';
|
|
@@ -18,22 +19,28 @@ export * from './publisher/config.js';
|
|
|
18
19
|
minTxsPerBlock: 1,
|
|
19
20
|
buildCheckpointIfEmpty: false,
|
|
20
21
|
publishTxsWithProposals: false,
|
|
21
|
-
perBlockAllocationMultiplier:
|
|
22
|
+
perBlockAllocationMultiplier: MIN_PER_BLOCK_ALLOCATION_MULTIPLIER,
|
|
23
|
+
perBlockDAAllocationMultiplier: MIN_PER_BLOCK_DA_ALLOCATION_MULTIPLIER,
|
|
22
24
|
redistributeCheckpointBudget: true,
|
|
23
|
-
|
|
25
|
+
blockDurationMs: DEFAULT_BLOCK_DURATION_MS,
|
|
26
|
+
l1PublishingTime: 12,
|
|
27
|
+
checkpointProposalSyncGraceSeconds: 2 * (DEFAULT_BLOCK_DURATION_MS / 1000),
|
|
24
28
|
attestationPropagationTime: DEFAULT_P2P_PROPAGATION_TIME,
|
|
25
29
|
secondsBeforeInvalidatingBlockAsCommitteeMember: 144,
|
|
26
30
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: 432,
|
|
27
31
|
skipCollectingAttestations: false,
|
|
28
32
|
skipInvalidateBlockAsProposer: false,
|
|
33
|
+
skipWaitForValidParentCheckpointOnL1: false,
|
|
29
34
|
broadcastInvalidBlockProposal: false,
|
|
35
|
+
broadcastInvalidCheckpointProposalOnly: false,
|
|
30
36
|
injectFakeAttestation: false,
|
|
31
37
|
injectHighSValueAttestation: false,
|
|
32
38
|
injectUnrecoverableSignatureAttestation: false,
|
|
33
39
|
fishermanMode: false,
|
|
34
40
|
shuffleAttestationOrdering: false,
|
|
35
41
|
skipPushProposedBlocksToArchiver: false,
|
|
36
|
-
skipPublishingCheckpointsPercent: 0
|
|
42
|
+
skipPublishingCheckpointsPercent: 0,
|
|
43
|
+
maxBlocksPerCheckpoint: DEFAULT_MAX_BLOCKS_PER_CHECKPOINT
|
|
37
44
|
};
|
|
38
45
|
export const sequencerConfigMappings = {
|
|
39
46
|
sequencerPollingIntervalMS: {
|
|
@@ -44,7 +51,7 @@ export const sequencerConfigMappings = {
|
|
|
44
51
|
maxTxsPerCheckpoint: {
|
|
45
52
|
env: 'SEQ_MAX_TX_PER_CHECKPOINT',
|
|
46
53
|
description: 'The maximum number of txs across all blocks in a checkpoint.',
|
|
47
|
-
|
|
54
|
+
...optionalNumberConfigHelper()
|
|
48
55
|
},
|
|
49
56
|
minTxsPerBlock: {
|
|
50
57
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
@@ -62,29 +69,31 @@ export const sequencerConfigMappings = {
|
|
|
62
69
|
maxL2BlockGas: {
|
|
63
70
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
64
71
|
description: 'The maximum L2 block gas.',
|
|
65
|
-
|
|
72
|
+
...optionalNumberConfigHelper()
|
|
66
73
|
},
|
|
67
74
|
maxDABlockGas: {
|
|
68
75
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
69
76
|
description: 'The maximum DA block gas.',
|
|
70
|
-
|
|
77
|
+
...optionalNumberConfigHelper()
|
|
71
78
|
},
|
|
72
79
|
perBlockAllocationMultiplier: {
|
|
73
80
|
env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
|
|
74
81
|
description: 'Per-block gas budget multiplier for both L2 and DA gas. Budget per block is (checkpointLimit / maxBlocks) * multiplier.' + ' Values greater than one allow early blocks to use more than their even share, relying on checkpoint-level capping for later blocks.',
|
|
75
|
-
...
|
|
82
|
+
...floatConfigHelper(DefaultSequencerConfig.perBlockAllocationMultiplier)
|
|
83
|
+
},
|
|
84
|
+
perBlockDAAllocationMultiplier: {
|
|
85
|
+
env: 'SEQ_PER_BLOCK_DA_ALLOCATION_MULTIPLIER',
|
|
86
|
+
description: 'Per-block budget multiplier applied to DA gas and blob fields in place of perBlockAllocationMultiplier.' + ' Defaults higher than the general multiplier so the largest contract class deploy fits a single block.',
|
|
87
|
+
...numberConfigHelper(DefaultSequencerConfig.perBlockDAAllocationMultiplier)
|
|
76
88
|
},
|
|
77
89
|
redistributeCheckpointBudget: {
|
|
78
90
|
env: 'SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET',
|
|
79
91
|
description: 'Redistribute remaining checkpoint budget evenly across remaining blocks instead of allowing a single block to consume the entire remaining budget.',
|
|
80
92
|
...booleanConfigHelper(DefaultSequencerConfig.redistributeCheckpointBudget)
|
|
81
93
|
},
|
|
82
|
-
maxBlocksPerCheckpoint: {
|
|
83
|
-
description: 'Computed max number of blocks per checkpoint from timetable.'
|
|
84
|
-
},
|
|
85
94
|
coinbase: {
|
|
86
95
|
env: 'COINBASE',
|
|
87
|
-
parseEnv: (val)=>
|
|
96
|
+
parseEnv: (val)=>EthAddress.fromString(val),
|
|
88
97
|
description: 'Recipient of block reward.'
|
|
89
98
|
},
|
|
90
99
|
feeRecipient: {
|
|
@@ -100,11 +109,6 @@ export const sequencerConfigMappings = {
|
|
|
100
109
|
env: 'ACVM_BINARY_PATH',
|
|
101
110
|
description: 'The path to the ACVM binary'
|
|
102
111
|
},
|
|
103
|
-
enforceTimeTable: {
|
|
104
|
-
env: 'SEQ_ENFORCE_TIME_TABLE',
|
|
105
|
-
description: 'Whether to enforce the time table when building blocks',
|
|
106
|
-
...booleanConfigHelper(DefaultSequencerConfig.enforceTimeTable)
|
|
107
|
-
},
|
|
108
112
|
governanceProposerPayload: {
|
|
109
113
|
env: 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS',
|
|
110
114
|
description: 'The address of the payload for the governanceProposer',
|
|
@@ -112,13 +116,8 @@ export const sequencerConfigMappings = {
|
|
|
112
116
|
},
|
|
113
117
|
l1PublishingTime: {
|
|
114
118
|
env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
|
|
115
|
-
description: 'How much time
|
|
116
|
-
|
|
117
|
-
},
|
|
118
|
-
attestationPropagationTime: {
|
|
119
|
-
env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
|
|
120
|
-
description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way)',
|
|
121
|
-
...numberConfigHelper(DefaultSequencerConfig.attestationPropagationTime)
|
|
119
|
+
description: 'How much time in seconds to allow in the slot for publishing the L1 transaction.',
|
|
120
|
+
...numberConfigHelper(DefaultSequencerConfig.l1PublishingTime)
|
|
122
121
|
},
|
|
123
122
|
fakeProcessingDelayPerTxMs: {
|
|
124
123
|
description: 'Used for testing to introduce a fake delay after processing each tx'
|
|
@@ -144,10 +143,22 @@ export const sequencerConfigMappings = {
|
|
|
144
143
|
description: 'Do not invalidate the previous block if invalid when we are the proposer (for testing only)',
|
|
145
144
|
...booleanConfigHelper(DefaultSequencerConfig.skipInvalidateBlockAsProposer)
|
|
146
145
|
},
|
|
146
|
+
skipWaitForValidParentCheckpointOnL1: {
|
|
147
|
+
description: 'Bypass the parent checkpoint validity check before submitting a pipelined checkpoint, ' + 'allowing the proposer to publish even when the parent landed on L1 with invalid attestations (for testing only)',
|
|
148
|
+
...booleanConfigHelper(DefaultSequencerConfig.skipWaitForValidParentCheckpointOnL1)
|
|
149
|
+
},
|
|
147
150
|
broadcastInvalidBlockProposal: {
|
|
148
151
|
description: 'Broadcast invalid block proposals with corrupted state (for testing only)',
|
|
149
152
|
...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidBlockProposal)
|
|
150
153
|
},
|
|
154
|
+
invalidBlockProposalIndexWithinCheckpoint: {
|
|
155
|
+
description: 'Broadcast an invalid block proposal only at this indexWithinCheckpoint (for testing only)',
|
|
156
|
+
...optionalNumberConfigHelper()
|
|
157
|
+
},
|
|
158
|
+
broadcastInvalidCheckpointProposalOnly: {
|
|
159
|
+
description: 'Broadcast invalid checkpoint proposals while keeping the underlying block proposals valid (for testing only). When unset, the checkpoint follows broadcastInvalidBlockProposal.',
|
|
160
|
+
...booleanConfigHelper(DefaultSequencerConfig.broadcastInvalidCheckpointProposalOnly)
|
|
161
|
+
},
|
|
151
162
|
injectFakeAttestation: {
|
|
152
163
|
description: 'Inject a fake attestation (for testing only)',
|
|
153
164
|
...booleanConfigHelper(DefaultSequencerConfig.injectFakeAttestation)
|
|
@@ -187,18 +198,29 @@ export const sequencerConfigMappings = {
|
|
|
187
198
|
description: 'Percent probability (0 - 100) of sequencer skipping checkpoint publishing (testing only)',
|
|
188
199
|
...numberConfigHelper(DefaultSequencerConfig.skipPublishingCheckpointsPercent)
|
|
189
200
|
},
|
|
201
|
+
skipBroadcastProposals: {
|
|
202
|
+
description: 'Skip broadcasting checkpoint and block proposals via gossipsub when proposer (for testing only)',
|
|
203
|
+
...booleanConfigHelper(false)
|
|
204
|
+
},
|
|
205
|
+
skipBroadcastCheckpointProposal: {
|
|
206
|
+
description: 'Skip broadcasting only the CheckpointProposal via gossipsub when proposer; the held last block is broadcast ' + 'standalone instead so peers still receive it as a proposed-but-uncheckpointed tip (for testing only)',
|
|
207
|
+
...booleanConfigHelper(false)
|
|
208
|
+
},
|
|
209
|
+
pauseProposingForSlots: {
|
|
210
|
+
description: 'List of slots for which the sequencer will not produce a proposal (for testing only). Attestation paths are unaffected.'
|
|
211
|
+
},
|
|
190
212
|
...pickConfigMappings(p2pConfigMappings, [
|
|
191
213
|
'txPublicSetupAllowListExtend'
|
|
192
214
|
])
|
|
193
215
|
};
|
|
194
216
|
export const sequencerClientConfigMappings = {
|
|
217
|
+
...chainConfigMappings,
|
|
195
218
|
...validatorClientConfigMappings,
|
|
196
219
|
...sequencerConfigMappings,
|
|
197
220
|
...keyStoreConfigMappings,
|
|
198
221
|
...l1ReaderConfigMappings,
|
|
199
222
|
...sequencerTxSenderConfigMappings,
|
|
200
223
|
...sequencerPublisherConfigMappings,
|
|
201
|
-
...chainConfigMappings,
|
|
202
224
|
...pickConfigMappings(l1ContractsConfigMappings, [
|
|
203
225
|
'ethereumSlotDuration',
|
|
204
226
|
'aztecSlotDuration',
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
+
import { GasFees, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
4
|
+
/**
|
|
5
|
+
* Predicts min fees for LAG upcoming slots based on the L1 oracle state.
|
|
6
|
+
* A new oracle update can activate at startSlot + LAG, so only the first LAG entries
|
|
7
|
+
* are guaranteed stable. Caches L1 queries per L1 block and recomputes predictions
|
|
8
|
+
* for each mana usage estimate.
|
|
9
|
+
*/
|
|
10
|
+
export declare class FeePredictor {
|
|
11
|
+
private readonly rollupContract;
|
|
12
|
+
private readonly publicClient;
|
|
13
|
+
private readonly dateProvider;
|
|
14
|
+
private cachedState;
|
|
15
|
+
private cachedL1BlockNumber;
|
|
16
|
+
private readonly slotDuration;
|
|
17
|
+
private readonly l1GenesisTime;
|
|
18
|
+
private readonly ethereumSlotDuration;
|
|
19
|
+
constructor(rollupContract: RollupContract, publicClient: {
|
|
20
|
+
getBlockNumber: (opts?: {
|
|
21
|
+
cacheTime?: number;
|
|
22
|
+
}) => Promise<bigint>;
|
|
23
|
+
}, dateProvider: DateProvider, config: {
|
|
24
|
+
slotDuration: number;
|
|
25
|
+
l1GenesisTime: bigint;
|
|
26
|
+
ethereumSlotDuration: number;
|
|
27
|
+
});
|
|
28
|
+
/** Returns predicted min fees for each slot in the prediction window. */
|
|
29
|
+
getPredictedMinFees(manaUsage: ManaUsageEstimate): Promise<GasFees[]>;
|
|
30
|
+
private getState;
|
|
31
|
+
private fetchState;
|
|
32
|
+
/** Computes per-slot fee predictions given cached state and a mana usage assumption. */
|
|
33
|
+
private computePredictions;
|
|
34
|
+
private getAssumedManaUsed;
|
|
35
|
+
private computeGasFees;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlX3ByZWRpY3Rvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2dsb2JhbF92YXJpYWJsZV9idWlsZGVyL2ZlZV9wcmVkaWN0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFvRCxLQUFLLGNBQWMsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBR2xILE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBRTVELE9BQU8sRUFFTCxPQUFPLEVBRVAsaUJBQWlCLEVBR2xCLE1BQU0sbUJBQW1CLENBQUM7QUFlM0I7Ozs7O0dBS0c7QUFDSCxxQkFBYSxZQUFZO0lBU3JCLE9BQU8sQ0FBQyxRQUFRLENBQUMsY0FBYztJQUMvQixPQUFPLENBQUMsUUFBUSxDQUFDLFlBQVk7SUFDN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxZQUFZO0lBVi9CLE9BQU8sQ0FBQyxXQUFXLENBQXNDO0lBQ3pELE9BQU8sQ0FBQyxtQkFBbUIsQ0FBcUI7SUFFaEQsT0FBTyxDQUFDLFFBQVEsQ0FBQyxZQUFZLENBQVM7SUFDdEMsT0FBTyxDQUF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C,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAV/B,OAAO,CAAC,WAAW,CAAsC;IACzD,OAAO,CAAC,mBAAmB,CAAqB;IAEhD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAE9C,YACmB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE;QAAE,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE;YAAE,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,EACpF,YAAY,EAAE,YAAY,EAC3C,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,oBAAoB,EAAE,MAAM,CAAA;KAAE,EAKtF;IAED,yEAAyE;IACnE,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAG1E;YAGa,QAAQ;YASR,UAAU;IAiDxB,wFAAwF;IACxF,OAAO,CAAC,kBAAkB;IAuB1B,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,cAAc;CAmBvB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { MAX_FEE_ASSET_PRICE_MODIFIER_BPS } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { times } from '@aztec/foundation/collection';
|
|
4
|
+
import { getSlotAtNextL1Block, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
5
|
+
import { FEE_ORACLE_LAG, GasFees, MIN_ETH_PER_FEE_ASSET, ManaUsageEstimate, computeExcessMana, computeManaMinFee } from '@aztec/stdlib/gas';
|
|
6
|
+
/**
|
|
7
|
+
* Predicts min fees for LAG upcoming slots based on the L1 oracle state.
|
|
8
|
+
* A new oracle update can activate at startSlot + LAG, so only the first LAG entries
|
|
9
|
+
* are guaranteed stable. Caches L1 queries per L1 block and recomputes predictions
|
|
10
|
+
* for each mana usage estimate.
|
|
11
|
+
*/ export class FeePredictor {
|
|
12
|
+
rollupContract;
|
|
13
|
+
publicClient;
|
|
14
|
+
dateProvider;
|
|
15
|
+
cachedState;
|
|
16
|
+
cachedL1BlockNumber;
|
|
17
|
+
slotDuration;
|
|
18
|
+
l1GenesisTime;
|
|
19
|
+
ethereumSlotDuration;
|
|
20
|
+
constructor(rollupContract, publicClient, dateProvider, config){
|
|
21
|
+
this.rollupContract = rollupContract;
|
|
22
|
+
this.publicClient = publicClient;
|
|
23
|
+
this.dateProvider = dateProvider;
|
|
24
|
+
this.slotDuration = config.slotDuration;
|
|
25
|
+
this.l1GenesisTime = config.l1GenesisTime;
|
|
26
|
+
this.ethereumSlotDuration = config.ethereumSlotDuration;
|
|
27
|
+
}
|
|
28
|
+
/** Returns predicted min fees for each slot in the prediction window. */ async getPredictedMinFees(manaUsage) {
|
|
29
|
+
const state = await this.getState();
|
|
30
|
+
return this.computePredictions(state, manaUsage);
|
|
31
|
+
}
|
|
32
|
+
/** Fetches and caches rollup state. Refreshes when L1 block number advances. */ async getState() {
|
|
33
|
+
const blockNumber = await this.publicClient.getBlockNumber({
|
|
34
|
+
cacheTime: 0
|
|
35
|
+
});
|
|
36
|
+
if (this.cachedL1BlockNumber === undefined || blockNumber > this.cachedL1BlockNumber) {
|
|
37
|
+
this.cachedL1BlockNumber = blockNumber;
|
|
38
|
+
this.cachedState = this.fetchState(blockNumber);
|
|
39
|
+
}
|
|
40
|
+
return this.cachedState;
|
|
41
|
+
}
|
|
42
|
+
async fetchState(blockNumber) {
|
|
43
|
+
// Pin all non-constant queries to this L1 block number for a consistent snapshot.
|
|
44
|
+
const opts = {
|
|
45
|
+
blockNumber
|
|
46
|
+
};
|
|
47
|
+
// Cached constants don't need pinning
|
|
48
|
+
const [manaTarget, manaLimit, provingCostPerManaEth, epochDuration] = await Promise.all([
|
|
49
|
+
this.rollupContract.getManaTarget(),
|
|
50
|
+
this.rollupContract.getManaLimit(),
|
|
51
|
+
this.rollupContract.getProvingCostPerMana(),
|
|
52
|
+
this.rollupContract.getEpochDuration()
|
|
53
|
+
]);
|
|
54
|
+
// First, compute the earliest possible nextSlot independently of the checkpoint, so we can
|
|
55
|
+
// evaluate pruneability at the prediction start timestamp instead of the current L1 block time.
|
|
56
|
+
// This avoids an epoch-boundary edge case where the effective parent differs between now and nextSlot.
|
|
57
|
+
const slotConfig = {
|
|
58
|
+
slotDuration: this.slotDuration,
|
|
59
|
+
l1GenesisTime: this.l1GenesisTime
|
|
60
|
+
};
|
|
61
|
+
const currentSlot = await this.rollupContract.getSlotNumber(opts);
|
|
62
|
+
const slotAtNextL1Block = getSlotAtNextL1Block(BigInt(this.dateProvider.nowInSeconds()), {
|
|
63
|
+
l1GenesisTime: this.l1GenesisTime,
|
|
64
|
+
slotDuration: this.slotDuration,
|
|
65
|
+
ethereumSlotDuration: this.ethereumSlotDuration
|
|
66
|
+
});
|
|
67
|
+
const preliminaryNextSlot = SlotNumber(Math.max(currentSlot, slotAtNextL1Block));
|
|
68
|
+
const nextSlotTimestamp = getTimestampForSlot(preliminaryNextSlot, slotConfig);
|
|
69
|
+
// Resolve the effective checkpoint at the prediction start timestamp
|
|
70
|
+
const lastCheckpoint = await this.rollupContract.getEffectivePendingCheckpoint(nextSlotTimestamp, opts);
|
|
71
|
+
const lastSlot = lastCheckpoint.slotNumber;
|
|
72
|
+
// Refine nextSlot: also account for the slot after the last checkpoint
|
|
73
|
+
const nextSlot = SlotNumber(Math.max(SlotNumber.add(lastSlot, 1), preliminaryNextSlot));
|
|
74
|
+
const feeHeader = lastCheckpoint.feeHeader;
|
|
75
|
+
const slotCount = FEE_ORACLE_LAG;
|
|
76
|
+
const timestamps = times(slotCount, (i)=>getTimestampForSlot(SlotNumber.add(nextSlot, i), slotConfig));
|
|
77
|
+
const l1FeesBySlot = await Promise.all(timestamps.map((ts)=>this.rollupContract.getL1FeesAt(ts, opts)));
|
|
78
|
+
return {
|
|
79
|
+
lastSlot,
|
|
80
|
+
excessMana: computeExcessMana(feeHeader.excessMana, feeHeader.manaUsed, manaTarget),
|
|
81
|
+
ethPerFeeAsset: feeHeader.ethPerFeeAsset,
|
|
82
|
+
manaTarget,
|
|
83
|
+
manaLimit,
|
|
84
|
+
provingCostPerManaEth,
|
|
85
|
+
epochDuration: BigInt(epochDuration),
|
|
86
|
+
l1FeesBySlot
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** Computes per-slot fee predictions given cached state and a mana usage assumption. */ computePredictions(state, manaUsage) {
|
|
90
|
+
const assumedManaUsed = this.getAssumedManaUsed(state, manaUsage);
|
|
91
|
+
const result = [];
|
|
92
|
+
let { excessMana } = state;
|
|
93
|
+
let { ethPerFeeAsset } = state;
|
|
94
|
+
// Slot 0: current state (next available slot after last checkpoint)
|
|
95
|
+
result.push(this.computeGasFees(state, excessMana, ethPerFeeAsset, state.l1FeesBySlot[0]));
|
|
96
|
+
// Slots 1..LAG-1: advance excessMana with the assumed mana usage per checkpoint,
|
|
97
|
+
// and decay ethPerFeeAsset by MAX_FEE_ASSET_PRICE_MODIFIER_BPS per slot for conservative estimates.
|
|
98
|
+
// Lower ethPerFeeAsset means higher fees in fee asset terms.
|
|
99
|
+
for(let i = 1; i < state.l1FeesBySlot.length; i++){
|
|
100
|
+
excessMana = computeExcessMana(excessMana, assumedManaUsed, state.manaTarget);
|
|
101
|
+
const decayed = ethPerFeeAsset * (10000n - MAX_FEE_ASSET_PRICE_MODIFIER_BPS) / 10000n;
|
|
102
|
+
ethPerFeeAsset = decayed < MIN_ETH_PER_FEE_ASSET ? MIN_ETH_PER_FEE_ASSET : decayed;
|
|
103
|
+
result.push(this.computeGasFees(state, excessMana, ethPerFeeAsset, state.l1FeesBySlot[i]));
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
getAssumedManaUsed(state, manaUsage) {
|
|
108
|
+
switch(manaUsage){
|
|
109
|
+
case ManaUsageEstimate.None:
|
|
110
|
+
return 0n;
|
|
111
|
+
case ManaUsageEstimate.Target:
|
|
112
|
+
return state.manaTarget;
|
|
113
|
+
case ManaUsageEstimate.Limit:
|
|
114
|
+
return state.manaLimit;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
computeGasFees(state, excessMana, ethPerFeeAsset, l1Fees) {
|
|
118
|
+
return new GasFees(0, computeManaMinFee({
|
|
119
|
+
l1BaseFee: l1Fees.baseFee,
|
|
120
|
+
l1BlobFee: l1Fees.blobFee,
|
|
121
|
+
manaTarget: state.manaTarget,
|
|
122
|
+
epochDuration: state.epochDuration,
|
|
123
|
+
provingCostPerManaEth: state.provingCostPerManaEth,
|
|
124
|
+
excessMana,
|
|
125
|
+
ethPerFeeAsset
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
2
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
+
import { GasFees, ManaUsageEstimate } from '@aztec/stdlib/gas';
|
|
4
|
+
import type { FeeProvider } from '@aztec/stdlib/tx';
|
|
5
|
+
import type { GlobalVariableBuilderConfig } from './global_builder.js';
|
|
6
|
+
/** Provides current and predicted fee information based on on-chain state. */
|
|
7
|
+
export declare class FeeProviderImpl implements FeeProvider {
|
|
8
|
+
private readonly dateProvider;
|
|
9
|
+
private readonly publicClient;
|
|
10
|
+
private currentMinFees;
|
|
11
|
+
private currentL1BlockNumber;
|
|
12
|
+
private readonly rollupContract;
|
|
13
|
+
private readonly feePredictor;
|
|
14
|
+
private readonly ethereumSlotDuration;
|
|
15
|
+
private readonly l1GenesisTime;
|
|
16
|
+
constructor(dateProvider: DateProvider, publicClient: ViemPublicClient, config: GlobalVariableBuilderConfig);
|
|
17
|
+
private computeCur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