Log warning on startup if chain spec contains misaligned fork epochs (#5859)

* Log a warning if any fork epoch isn't a multiple of 256.

* Merge branch 'unstable' into warn-invalid-fork-epochs

* Clean up.
This commit is contained in:
Jimmy Chen
2024-07-11 16:10:27 +10:00
committed by GitHub
parent 880523d8d7
commit 4c7277c646
2 changed files with 63 additions and 1 deletions

View File

@@ -31,6 +31,16 @@ impl ForkName {
]
}
pub fn list_all_fork_epochs(spec: &ChainSpec) -> Vec<(ForkName, Option<Epoch>)> {
vec![
(ForkName::Altair, spec.altair_fork_epoch),
(ForkName::Bellatrix, spec.bellatrix_fork_epoch),
(ForkName::Capella, spec.capella_fork_epoch),
(ForkName::Deneb, spec.deneb_fork_epoch),
(ForkName::Electra, spec.electra_fork_epoch),
]
}
pub fn latest() -> ForkName {
// This unwrap is safe as long as we have 1+ forks. It is tested below.
*ForkName::list_all().last().unwrap()