Skip to content

Commit 99ad22f

Browse files
committed
params: add tests for blobschedule validation
1 parent fe8f608 commit 99ad22f

File tree

4 files changed

+80
-3
lines changed

4 files changed

+80
-3
lines changed

params/chainparam.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,16 @@ var BlobSchedule = Define(T[map[forks.Fork]BlobConfig]{
5555
// schedule configuration.
5656
func validateBlobSchedule(schedule map[forks.Fork]BlobConfig, cfg *Config2) error {
5757
for f := range forks.All() {
58-
if cfg.Scheduled(f) && f.Requires(forks.Cancun) {
58+
if _, defined := schedule[f]; f.BlockBased() && defined {
59+
return fmt.Errorf("contains fork %q with block-number based scheduling", f.ConfigName())
60+
}
61+
if cfg.Scheduled(f) && f.After(forks.Cancun) {
5962
bcfg, defined := schedule[f]
6063
if !defined {
61-
return fmt.Errorf("invalid chain configuration: missing entry for fork %q in blobSchedule", f)
64+
return fmt.Errorf("missing entry for fork %q", f.ConfigName())
6265
} else {
6366
if err := bcfg.validate(); err != nil {
64-
return fmt.Errorf("invalid chain configuration in blobSchedule for fork %q: %v", f, err)
67+
return fmt.Errorf("invalid blob config for fork %q: %v", f.ConfigName(), err)
6568
}
6669
}
6770
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"config": {
3+
"homesteadBlock": 0,
4+
"eip150Block": 0,
5+
"eip155Block": 0,
6+
"byzantiumBlock": 0,
7+
"constantinopleBlock": 0,
8+
"petersburgBlock": 0,
9+
"istanbulBlock": 0,
10+
"berlinBlock": 0,
11+
"londonBlock": 0,
12+
"mergeNetsplitBlock": 0,
13+
"shanghaiTime": 900,
14+
"chainId": 99,
15+
"blobSchedule": {
16+
"berlin": {
17+
"target": 8,
18+
"max": 5,
19+
"baseFeeUpdateFraction": 3338477
20+
}
21+
}
22+
},
23+
"error": "invalid blobSchedule: contains fork \"berlin\" with block-number based scheduling"
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"config": {
3+
"homesteadBlock": 0,
4+
"eip150Block": 0,
5+
"eip155Block": 0,
6+
"byzantiumBlock": 0,
7+
"constantinopleBlock": 0,
8+
"petersburgBlock": 0,
9+
"istanbulBlock": 0,
10+
"berlinBlock": 0,
11+
"londonBlock": 0,
12+
"mergeNetsplitBlock": 0,
13+
"shanghaiTime": 900,
14+
"cancunTime": 1000,
15+
"pragueTime": 1100,
16+
"chainId": 99,
17+
"blobSchedule": {
18+
"cancun": {
19+
"target": 8,
20+
"max": 5,
21+
"baseFeeUpdateFraction": 3338477
22+
}
23+
}
24+
},
25+
"error": "invalid blobSchedule: missing entry for fork \"prague\""
26+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"config": {
3+
"homesteadBlock": 0,
4+
"eip150Block": 0,
5+
"eip155Block": 0,
6+
"byzantiumBlock": 0,
7+
"constantinopleBlock": 0,
8+
"petersburgBlock": 0,
9+
"istanbulBlock": 0,
10+
"berlinBlock": 0,
11+
"londonBlock": 0,
12+
"mergeNetsplitBlock": 0,
13+
"shanghaiTime": 900,
14+
"cancunTime": 1000,
15+
"chainId": 99,
16+
"blobSchedule": {
17+
"cancun": {
18+
"target": 8,
19+
"max": 10
20+
}
21+
}
22+
},
23+
"error": "invalid blobSchedule: invalid blob config for fork \"cancun\": update fraction must be defined and non-zero"
24+
}

0 commit comments

Comments
 (0)