Skip to content

Commit

Permalink
Fix and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Jan 27, 2025
1 parent 47ed980 commit 5f0dee8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nimbus/common/chain_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,17 @@ proc configureBlobSchedule(conf: ChainConfig) =
var prevFork = Cancun
if conf.blobSchedule[Cancun].isNone:
conf.blobSchedule[Cancun] = Opt.some(BlobSchedule(target: 3'u64, max: 6'u64, baseFeeUpdateFraction: 3_338_477'u64))
else:
if conf.blobSchedule[Cancun].value.baseFeeUpdateFraction == 0:
conf.blobSchedule[Cancun].value.baseFeeUpdateFraction = 3_338_477'u64

for fork in Prague..HardFork.high:
if conf.blobSchedule[fork].isNone:
conf.blobSchedule[fork] = conf.blobSchedule[prevFork]
if conf.blobSchedule[fork].baseFeeUpdateFraction == 0:
if conf.blobSchedule[fork].value.baseFeeUpdateFraction == 0:
# Set fallback to Cancun's baseFeeUpdateFraction and prevent division by zero
warn "baseFeeUpdateFraction not set, fallback to Cancun's", fork=fork
conf.blobSchedule[fork].baseFeeUpdateFraction = 3_338_477'u64
conf.blobSchedule[fork].value.baseFeeUpdateFraction = 3_338_477'u64
prevFork = fork

proc parseGenesis*(data: string): Genesis
Expand Down
27 changes: 27 additions & 0 deletions tests/customgenesis/blobschedule_nobasefee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"config": {
"chainId": 7,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x5de1ee4135274003348e80b788e5afa4b18b18d320a5622218d5c493fedf5689",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"blobSchedule": {
"cancun": {
"target": 3,
"max": 6
},
"prague": {
"target": 6,
"max": 9
}
}
}
}
5 changes: 5 additions & 0 deletions tests/test_genesis.nim
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ proc customGenesisTest() =
validateBlobSchedule(cg, Prague, 6, 9, 5007716)
validateBlobSchedule(cg, Osaka, 6, 9, 5007716)

check loadNetworkParams("blobschedule_nobasefee.json".findFilePath, cg)
validateBlobSchedule(cg, Cancun, 3, 6, 3338477)
validateBlobSchedule(cg, Prague, 6, 9, 3338477)
validateBlobSchedule(cg, Osaka, 6, 9, 3338477)

proc genesisMain*() =
genesisTest()
customGenesisTest()
Expand Down

0 comments on commit 5f0dee8

Please sign in to comment.