@aztec/sequencer-client 0.0.1-commit.5914bae → 0.0.1-commit.59a0419c6
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 +2 -1
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +8 -8
- package/dest/config.d.ts +3 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +10 -12
- 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 +3 -8
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +4 -39
- 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/publisher/config.d.ts +17 -1
- 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-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 +52 -41
- package/dest/publisher/sequencer-publisher.d.ts.map +1 -1
- package/dest/publisher/sequencer-publisher.js +345 -101
- package/dest/sequencer/chain_state_overrides.d.ts +25 -0
- package/dest/sequencer/chain_state_overrides.d.ts.map +1 -0
- package/dest/sequencer/chain_state_overrides.js +39 -0
- package/dest/sequencer/checkpoint_proposal_job.d.ts +38 -8
- package/dest/sequencer/checkpoint_proposal_job.d.ts.map +1 -1
- package/dest/sequencer/checkpoint_proposal_job.js +427 -171
- 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 +7 -1
- package/dest/sequencer/events.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +11 -10
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +38 -20
- package/dest/sequencer/sequencer.d.ts +17 -5
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +120 -58
- package/dest/sequencer/timetable.d.ts +14 -1
- package/dest/sequencer/timetable.d.ts.map +1 -1
- package/dest/sequencer/timetable.js +45 -36
- 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/package.json +27 -28
- package/src/client/sequencer-client.ts +8 -14
- package/src/config.ts +12 -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 +8 -43
- package/src/global_variable_builder/index.ts +2 -0
- package/src/publisher/config.ts +47 -4
- 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-publisher-factory.ts +18 -6
- package/src/publisher/sequencer-publisher.ts +389 -140
- package/src/sequencer/README.md +83 -13
- package/src/sequencer/chain_state_overrides.ts +87 -0
- package/src/sequencer/checkpoint_proposal_job.ts +517 -180
- package/src/sequencer/checkpoint_proposal_job_metrics.ts +128 -0
- package/src/sequencer/events.ts +6 -1
- package/src/sequencer/metrics.ts +49 -25
- package/src/sequencer/sequencer.ts +177 -63
- package/src/sequencer/timetable.ts +57 -45
- package/src/test/mock_checkpoint_builder.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock_checkpoint_builder.d.ts","sourceRoot":"","sources":["../../src/test/mock_checkpoint_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,gBAAgB,EAAyB,MAAM,iCAAiC,CAAC;AAC5G,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,iCAAiC,CAAC;AAGzC,OAAO,KAAK,EAAE,yBAAyB,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,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K,EAAE,yBAAyB,EAChC,cAAc,GAAE,OAAO,EAAO,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CAgBlC;IAED,OAAO,CAAC,YAAY,EAAE,WAAW,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAErE;IAED,sCAAsC;IACtC,KAAK,IAAI,IAAI,CAKZ;CACF"}
|
|
@@ -216,8 +216,6 @@ import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
|
216
216
|
if (!this.checkpointBuilder) {
|
|
217
217
|
// Auto-create a builder if none was set
|
|
218
218
|
this.checkpointBuilder = new MockCheckpointBuilder(constants, checkpointNumber);
|
|
219
|
-
} else {
|
|
220
|
-
this.checkpointBuilder.resetCheckpointState();
|
|
221
219
|
}
|
|
222
220
|
return Promise.resolve(this.checkpointBuilder);
|
|
223
221
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/sequencer-client",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.59a0419c6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -26,38 +26,37 @@
|
|
|
26
26
|
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --config jest.integration.config.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
30
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
31
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
32
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
33
|
-
"@aztec/constants": "0.0.1-commit.
|
|
34
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
35
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
36
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
37
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
38
|
-
"@aztec/
|
|
39
|
-
"@aztec/
|
|
40
|
-
"@aztec/noir-
|
|
41
|
-
"@aztec/noir-
|
|
42
|
-
"@aztec/noir-
|
|
43
|
-
"@aztec/
|
|
44
|
-
"@aztec/
|
|
45
|
-
"@aztec/
|
|
46
|
-
"@aztec/
|
|
47
|
-
"@aztec/
|
|
48
|
-
"@aztec/
|
|
49
|
-
"@aztec/
|
|
50
|
-
"@aztec/
|
|
51
|
-
"@aztec/validator-
|
|
52
|
-
"@aztec/
|
|
53
|
-
"@aztec/world-state": "0.0.1-commit.5914bae",
|
|
29
|
+
"@aztec/aztec.js": "0.0.1-commit.59a0419c6",
|
|
30
|
+
"@aztec/bb-prover": "0.0.1-commit.59a0419c6",
|
|
31
|
+
"@aztec/blob-client": "0.0.1-commit.59a0419c6",
|
|
32
|
+
"@aztec/blob-lib": "0.0.1-commit.59a0419c6",
|
|
33
|
+
"@aztec/constants": "0.0.1-commit.59a0419c6",
|
|
34
|
+
"@aztec/epoch-cache": "0.0.1-commit.59a0419c6",
|
|
35
|
+
"@aztec/ethereum": "0.0.1-commit.59a0419c6",
|
|
36
|
+
"@aztec/foundation": "0.0.1-commit.59a0419c6",
|
|
37
|
+
"@aztec/l1-artifacts": "0.0.1-commit.59a0419c6",
|
|
38
|
+
"@aztec/node-keystore": "0.0.1-commit.59a0419c6",
|
|
39
|
+
"@aztec/noir-acvm_js": "0.0.1-commit.59a0419c6",
|
|
40
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.59a0419c6",
|
|
41
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.59a0419c6",
|
|
42
|
+
"@aztec/noir-types": "0.0.1-commit.59a0419c6",
|
|
43
|
+
"@aztec/p2p": "0.0.1-commit.59a0419c6",
|
|
44
|
+
"@aztec/protocol-contracts": "0.0.1-commit.59a0419c6",
|
|
45
|
+
"@aztec/prover-client": "0.0.1-commit.59a0419c6",
|
|
46
|
+
"@aztec/simulator": "0.0.1-commit.59a0419c6",
|
|
47
|
+
"@aztec/slasher": "0.0.1-commit.59a0419c6",
|
|
48
|
+
"@aztec/stdlib": "0.0.1-commit.59a0419c6",
|
|
49
|
+
"@aztec/telemetry-client": "0.0.1-commit.59a0419c6",
|
|
50
|
+
"@aztec/validator-client": "0.0.1-commit.59a0419c6",
|
|
51
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.59a0419c6",
|
|
52
|
+
"@aztec/world-state": "0.0.1-commit.59a0419c6",
|
|
54
53
|
"lodash.chunk": "^4.2.0",
|
|
55
54
|
"tslib": "^2.4.0",
|
|
56
55
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
57
56
|
},
|
|
58
57
|
"devDependencies": {
|
|
59
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
60
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
58
|
+
"@aztec/archiver": "0.0.1-commit.59a0419c6",
|
|
59
|
+
"@aztec/kv-store": "0.0.1-commit.59a0419c6",
|
|
61
60
|
"@electric-sql/pglite": "^0.3.14",
|
|
62
61
|
"@jest/globals": "^30.0.0",
|
|
63
62
|
"@types/jest": "^30.0.0",
|
|
@@ -14,7 +14,6 @@ import type { P2P } from '@aztec/p2p';
|
|
|
14
14
|
import type { SlasherClientInterface } from '@aztec/slasher';
|
|
15
15
|
import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
16
16
|
import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
17
|
-
import { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
18
17
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
19
18
|
import { L1Metrics, type TelemetryClient } from '@aztec/telemetry-client';
|
|
20
19
|
import { FullNodeCheckpointsBuilder, NodeKeystoreAdapter, type ValidatorClient } from '@aztec/validator-client';
|
|
@@ -65,6 +64,7 @@ export class SequencerClient {
|
|
|
65
64
|
dateProvider: DateProvider;
|
|
66
65
|
epochCache?: EpochCache;
|
|
67
66
|
l1TxUtils: L1TxUtils[];
|
|
67
|
+
funderL1TxUtils?: L1TxUtils;
|
|
68
68
|
nodeKeyStore: KeystoreManager;
|
|
69
69
|
globalVariableBuilder: GlobalVariableBuilder;
|
|
70
70
|
},
|
|
@@ -88,11 +88,10 @@ export class SequencerClient {
|
|
|
88
88
|
publicClient,
|
|
89
89
|
l1TxUtils.map(x => x.getSenderAddress()),
|
|
90
90
|
);
|
|
91
|
-
const publisherManager = new PublisherManager(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
);
|
|
91
|
+
const publisherManager = new PublisherManager(l1TxUtils, getPublisherConfigFromSequencerConfig(config), {
|
|
92
|
+
bindings: log.getBindings(),
|
|
93
|
+
funder: deps.funderL1TxUtils,
|
|
94
|
+
});
|
|
96
95
|
const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
|
|
97
96
|
const [l1GenesisTime, slotDuration, rollupManaLimit] = await Promise.all([
|
|
98
97
|
rollupContract.getL1GenesisTime(),
|
|
@@ -113,15 +112,11 @@ export class SequencerClient {
|
|
|
113
112
|
l1ChainId: chainId,
|
|
114
113
|
viemPollingIntervalMS: config.viemPollingIntervalMS,
|
|
115
114
|
ethereumSlotDuration: config.ethereumSlotDuration,
|
|
115
|
+
enableProposerPipelining: config.enableProposerPipelining,
|
|
116
116
|
},
|
|
117
117
|
{ dateProvider: deps.dateProvider },
|
|
118
118
|
));
|
|
119
119
|
|
|
120
|
-
const slashFactoryContract = new SlashFactoryContract(
|
|
121
|
-
publicClient,
|
|
122
|
-
config.l1Contracts.slashFactoryAddress?.toString() ?? EthAddress.ZERO.toString(),
|
|
123
|
-
);
|
|
124
|
-
|
|
125
120
|
const publisherFactory =
|
|
126
121
|
deps.publisherFactory ??
|
|
127
122
|
new SequencerPublisherFactory(config, {
|
|
@@ -129,7 +124,6 @@ export class SequencerClient {
|
|
|
129
124
|
blobClient: deps.blobClient,
|
|
130
125
|
epochCache,
|
|
131
126
|
governanceProposerContract,
|
|
132
|
-
slashFactoryContract,
|
|
133
127
|
rollupContract,
|
|
134
128
|
dateProvider: deps.dateProvider,
|
|
135
129
|
publisherManager,
|
|
@@ -195,7 +189,7 @@ export class SequencerClient {
|
|
|
195
189
|
await this.validatorClient?.start();
|
|
196
190
|
this.sequencer.start();
|
|
197
191
|
this.l1Metrics?.start();
|
|
198
|
-
await this.publisherManager.
|
|
192
|
+
await this.publisherManager.start();
|
|
199
193
|
}
|
|
200
194
|
|
|
201
195
|
/**
|
|
@@ -204,7 +198,7 @@ export class SequencerClient {
|
|
|
204
198
|
public async stop() {
|
|
205
199
|
await this.sequencer.stop();
|
|
206
200
|
await this.validatorClient?.stop();
|
|
207
|
-
this.publisherManager.
|
|
201
|
+
await this.publisherManager.stop();
|
|
208
202
|
this.l1Metrics?.stop();
|
|
209
203
|
}
|
|
210
204
|
|
package/src/config.ts
CHANGED
|
@@ -13,8 +13,10 @@ import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
|
|
|
13
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
14
|
import {
|
|
15
15
|
type ChainConfig,
|
|
16
|
+
type PipelineConfig,
|
|
16
17
|
type SequencerConfig,
|
|
17
18
|
chainConfigMappings,
|
|
19
|
+
pipelineConfigMappings,
|
|
18
20
|
sharedSequencerConfigMappings,
|
|
19
21
|
} from '@aztec/stdlib/config';
|
|
20
22
|
import type { ResolvedSequencerConfig } from '@aztec/stdlib/interfaces/server';
|
|
@@ -68,6 +70,7 @@ export type SequencerClientConfig = SequencerPublisherConfig &
|
|
|
68
70
|
SequencerConfig &
|
|
69
71
|
L1ReaderConfig &
|
|
70
72
|
ChainConfig &
|
|
73
|
+
PipelineConfig &
|
|
71
74
|
Pick<P2PConfig, 'txPublicSetupAllowListExtend'> &
|
|
72
75
|
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
|
|
73
76
|
|
|
@@ -80,7 +83,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
80
83
|
maxTxsPerCheckpoint: {
|
|
81
84
|
env: 'SEQ_MAX_TX_PER_CHECKPOINT',
|
|
82
85
|
description: 'The maximum number of txs across all blocks in a checkpoint.',
|
|
83
|
-
parseEnv: (val: string) =>
|
|
86
|
+
parseEnv: (val: string) => parseInt(val, 10),
|
|
84
87
|
},
|
|
85
88
|
minTxsPerBlock: {
|
|
86
89
|
env: 'SEQ_MIN_TX_PER_BLOCK',
|
|
@@ -99,12 +102,12 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
99
102
|
maxL2BlockGas: {
|
|
100
103
|
env: 'SEQ_MAX_L2_BLOCK_GAS',
|
|
101
104
|
description: 'The maximum L2 block gas.',
|
|
102
|
-
parseEnv: (val: string) =>
|
|
105
|
+
parseEnv: (val: string) => parseInt(val, 10),
|
|
103
106
|
},
|
|
104
107
|
maxDABlockGas: {
|
|
105
108
|
env: 'SEQ_MAX_DA_BLOCK_GAS',
|
|
106
109
|
description: 'The maximum DA block gas.',
|
|
107
|
-
parseEnv: (val: string) =>
|
|
110
|
+
parseEnv: (val: string) => parseInt(val, 10),
|
|
108
111
|
},
|
|
109
112
|
perBlockAllocationMultiplier: {
|
|
110
113
|
env: 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER',
|
|
@@ -121,7 +124,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
121
124
|
},
|
|
122
125
|
coinbase: {
|
|
123
126
|
env: 'COINBASE',
|
|
124
|
-
parseEnv: (val: string) =>
|
|
127
|
+
parseEnv: (val: string) => EthAddress.fromString(val),
|
|
125
128
|
description: 'Recipient of block reward.',
|
|
126
129
|
},
|
|
127
130
|
feeRecipient: {
|
|
@@ -150,12 +153,7 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
150
153
|
l1PublishingTime: {
|
|
151
154
|
env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
|
|
152
155
|
description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
|
|
153
|
-
parseEnv: (val: string) =>
|
|
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),
|
|
156
|
+
parseEnv: (val: string) => parseInt(val, 10),
|
|
159
157
|
},
|
|
160
158
|
fakeProcessingDelayPerTxMs: {
|
|
161
159
|
description: 'Used for testing to introduce a fake delay after processing each tx',
|
|
@@ -234,13 +232,16 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
|
|
|
234
232
|
};
|
|
235
233
|
|
|
236
234
|
export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
|
|
235
|
+
// chainConfigMappings must come first: its l1Contracts only maps rollupAddress,
|
|
236
|
+
// while l1ReaderConfigMappings (spread later) maps all L1 contract addresses.
|
|
237
|
+
...chainConfigMappings,
|
|
237
238
|
...validatorClientConfigMappings,
|
|
238
239
|
...sequencerConfigMappings,
|
|
239
240
|
...keyStoreConfigMappings,
|
|
240
241
|
...l1ReaderConfigMappings,
|
|
241
242
|
...sequencerTxSenderConfigMappings,
|
|
242
243
|
...sequencerPublisherConfigMappings,
|
|
243
|
-
...
|
|
244
|
+
...pipelineConfigMappings,
|
|
244
245
|
...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
|
|
245
246
|
};
|
|
246
247
|
|
|
@@ -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.l1Contracts.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,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
RollupContract,
|
|
3
|
+
type SimulationOverridesPlan,
|
|
4
|
+
buildSimulationOverridesStateOverride,
|
|
5
|
+
} from '@aztec/ethereum/contracts';
|
|
2
6
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
7
|
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
4
8
|
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
5
9
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
10
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
8
11
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
9
12
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
13
|
import { type L1RollupConstants, getNextL1SlotTimestamp, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
@@ -26,10 +29,6 @@ export type GlobalVariableBuilderConfig = {
|
|
|
26
29
|
* Simple global variables builder.
|
|
27
30
|
*/
|
|
28
31
|
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
32
|
private readonly rollupContract: RollupContract;
|
|
34
33
|
private readonly ethereumSlotDuration: number;
|
|
35
34
|
private readonly aztecSlotDuration: number;
|
|
@@ -53,40 +52,6 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
53
52
|
this.rollupContract = new RollupContract(this.publicClient, config.l1Contracts.rollupAddress);
|
|
54
53
|
}
|
|
55
54
|
|
|
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;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
55
|
/**
|
|
91
56
|
* Simple builder of global variables.
|
|
92
57
|
* @param blockNumber - The block number to build global variables for.
|
|
@@ -119,6 +84,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
119
84
|
coinbase: EthAddress,
|
|
120
85
|
feeRecipient: AztecAddress,
|
|
121
86
|
slotNumber: SlotNumber,
|
|
87
|
+
simulationOverridesPlan?: SimulationOverridesPlan,
|
|
122
88
|
): Promise<CheckpointGlobalVariables> {
|
|
123
89
|
const { chainId, version } = this;
|
|
124
90
|
|
|
@@ -127,9 +93,8 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
|
|
|
127
93
|
l1GenesisTime: this.l1GenesisTime,
|
|
128
94
|
});
|
|
129
95
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true));
|
|
96
|
+
const stateOverride = await buildSimulationOverridesStateOverride(this.rollupContract, simulationOverridesPlan);
|
|
97
|
+
const gasFees = new GasFees(0, await this.rollupContract.getManaMinFeeAt(timestamp, true, stateOverride));
|
|
133
98
|
|
|
134
99
|
return { chainId, version, slotNumber, timestamp, coinbase, feeRecipient, gasFees };
|
|
135
100
|
}
|