Skip to content

Commit

Permalink
Merge pull request ralexstokes#398 from jacobkaufmann/add-electra-fork
Browse files Browse the repository at this point in the history
feat: add electra variant to fork enum
  • Loading branch information
ralexstokes authored May 7, 2024
2 parents 2ce2ca4 + 8b07ce8 commit 51fae41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ethereum-consensus/src/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub enum Fork {
Bellatrix,
Capella,
Deneb,
Electra,
}

impl fmt::Display for Fork {
Expand All @@ -19,6 +20,7 @@ impl fmt::Display for Fork {
Self::Bellatrix => write!(f, "bellatrix"),
Self::Capella => write!(f, "capella"),
Self::Deneb => write!(f, "deneb"),
Self::Electra => write!(f, "electra"),
}
}
}
5 changes: 4 additions & 1 deletion ethereum-consensus/src/state_transition/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ impl Context {

pub fn fork_for(&self, slot: Slot) -> Fork {
let epoch = slot / self.slots_per_epoch;
if epoch >= self.deneb_fork_epoch {
if epoch >= self.electra_fork_epoch {
Fork::Electra
} else if epoch >= self.deneb_fork_epoch {
Fork::Deneb
} else if epoch >= self.capella_fork_epoch {
Fork::Capella
Expand All @@ -448,6 +450,7 @@ impl Context {
Fork::Bellatrix => self.bellatrix_fork_version,
Fork::Capella => self.capella_fork_version,
Fork::Deneb => self.deneb_fork_version,
Fork::Electra => self.electra_fork_version,
}
}

Expand Down

0 comments on commit 51fae41

Please sign in to comment.