Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: sanity-check fork configuration in genesis init #31171

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
}
newCfg := genesis.chainConfigOrDefault(ghash, storedCfg)

// Sanity-check the new configuration.
if err := newCfg.CheckConfigForkOrder(); err != nil {
return nil, common.Hash{}, nil, err
}

// TODO(rjl493456442) better to define the comparator of chain config
// and short circuit if the chain config is not changed.
compatErr := storedCfg.CheckCompatible(newCfg, head.Number.Uint64(), head.Time)
Expand Down
4 changes: 2 additions & 2 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,13 +735,13 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
} {
if cur.config != nil {
if err := cur.config.validate(); err != nil {
return fmt.Errorf("invalid blob configuration for fork %s: %v", cur.name, err)
return fmt.Errorf("invalid chain configuration in blobSchedule for fork %q: %v", cur.name, err)
}
}
if cur.timestamp != nil {
// If the fork is configured, a blob schedule must be defined for it.
if cur.config == nil {
return fmt.Errorf("unsupported fork configuration: missing blob configuration entry for %v in schedule", cur.name)
return fmt.Errorf("invalid chain configuration: missing entry for fork %q in blobSchedule", cur.name)
}
}
}
Expand Down
Loading