mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-30 11:24:31 +00:00
deprecate disallowed-offsets config for re-orgs (#9449)
https://github.com/ethereum/consensus-specs/pull/5348. As per discussions in issue we no longer need to support `disallowed-offsets` for pre-Fulu forks. Co-Authored-By: hopinheimer <knmanas6@gmail.com>
This commit is contained in:
@@ -50,7 +50,6 @@ pub enum Error {
|
||||
block_root: Hash256,
|
||||
parent_root: Hash256,
|
||||
},
|
||||
InvalidEpochOffset(u64),
|
||||
Arith(ArithError),
|
||||
InvalidNodeVariant {
|
||||
block_root: Hash256,
|
||||
|
||||
@@ -8,8 +8,8 @@ mod ssz_container;
|
||||
pub use crate::justified_balances::JustifiedBalances;
|
||||
pub use crate::proto_array::{InvalidationOperation, calculate_committee_fraction};
|
||||
pub use crate::proto_array_fork_choice::{
|
||||
Block, DisallowedReOrgOffsets, DoNotReOrg, ExecutionStatus, LatestMessage, PayloadStatus,
|
||||
ProposerHeadError, ProposerHeadInfo, ProtoArrayForkChoice, ReOrgThreshold,
|
||||
Block, DoNotReOrg, ExecutionStatus, LatestMessage, PayloadStatus, ProposerHeadError,
|
||||
ProposerHeadInfo, ProtoArrayForkChoice, ReOrgThreshold,
|
||||
};
|
||||
pub use error::Error;
|
||||
|
||||
|
||||
@@ -385,10 +385,6 @@ pub enum DoNotReOrg {
|
||||
MissingHeadFinalizedCheckpoint,
|
||||
ParentDistance,
|
||||
HeadDistance,
|
||||
ShufflingUnstable,
|
||||
DisallowedOffset {
|
||||
offset: u64,
|
||||
},
|
||||
JustificationAndFinalizationNotCompetitive,
|
||||
ChainNotFinalizing {
|
||||
epochs_since_finalization: u64,
|
||||
@@ -413,10 +409,6 @@ impl std::fmt::Display for DoNotReOrg {
|
||||
Self::MissingHeadFinalizedCheckpoint => write!(f, "finalized checkpoint missing"),
|
||||
Self::ParentDistance => write!(f, "parent too far from head"),
|
||||
Self::HeadDistance => write!(f, "head too far from current slot"),
|
||||
Self::ShufflingUnstable => write!(f, "shuffling unstable at epoch boundary"),
|
||||
Self::DisallowedOffset { offset } => {
|
||||
write!(f, "re-orgs disabled at offset {offset}")
|
||||
}
|
||||
Self::JustificationAndFinalizationNotCompetitive => {
|
||||
write!(f, "justification or finalization not competitive")
|
||||
}
|
||||
@@ -462,31 +454,6 @@ impl std::fmt::Display for DoNotReOrg {
|
||||
#[serde(transparent)]
|
||||
pub struct ReOrgThreshold(pub u64);
|
||||
|
||||
/// New-type for disallowed re-org slots.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct DisallowedReOrgOffsets {
|
||||
// Vecs are faster than hashmaps for small numbers of items.
|
||||
offsets: Vec<u64>,
|
||||
}
|
||||
|
||||
impl Default for DisallowedReOrgOffsets {
|
||||
fn default() -> Self {
|
||||
DisallowedReOrgOffsets { offsets: vec![0] }
|
||||
}
|
||||
}
|
||||
|
||||
impl DisallowedReOrgOffsets {
|
||||
pub fn new<E: EthSpec>(offsets: Vec<u64>) -> Result<Self, Error> {
|
||||
for &offset in &offsets {
|
||||
if offset >= E::slots_per_epoch() {
|
||||
return Err(Error::InvalidEpochOffset(offset));
|
||||
}
|
||||
}
|
||||
Ok(Self { offsets })
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub struct ProtoArrayForkChoice {
|
||||
pub(crate) proto_array: ProtoArray,
|
||||
@@ -724,7 +691,6 @@ impl ProtoArrayForkChoice {
|
||||
justified_balances: &JustifiedBalances,
|
||||
re_org_head_threshold: ReOrgThreshold,
|
||||
re_org_parent_threshold: ReOrgThreshold,
|
||||
disallowed_offsets: &DisallowedReOrgOffsets,
|
||||
max_epochs_since_finalization: Epoch,
|
||||
) -> Result<ProposerHeadInfo, ProposerHeadError<Error>> {
|
||||
let info = self.get_proposer_head_info::<E>(
|
||||
@@ -733,7 +699,6 @@ impl ProtoArrayForkChoice {
|
||||
justified_balances,
|
||||
re_org_head_threshold,
|
||||
re_org_parent_threshold,
|
||||
disallowed_offsets,
|
||||
max_epochs_since_finalization,
|
||||
)?;
|
||||
|
||||
@@ -784,7 +749,6 @@ impl ProtoArrayForkChoice {
|
||||
justified_balances: &JustifiedBalances,
|
||||
re_org_head_threshold: ReOrgThreshold,
|
||||
re_org_parent_threshold: ReOrgThreshold,
|
||||
disallowed_offsets: &DisallowedReOrgOffsets,
|
||||
max_epochs_since_finalization: Epoch,
|
||||
) -> Result<ProposerHeadInfo, ProposerHeadError<Error>> {
|
||||
let mut nodes = self
|
||||
@@ -823,18 +787,6 @@ impl ProtoArrayForkChoice {
|
||||
return Err(DoNotReOrg::ParentDistance.into());
|
||||
}
|
||||
|
||||
// Check shuffling stability.
|
||||
let shuffling_stable = re_org_block_slot % E::slots_per_epoch() != 0;
|
||||
if !shuffling_stable {
|
||||
return Err(DoNotReOrg::ShufflingUnstable.into());
|
||||
}
|
||||
|
||||
// Check allowed slot offsets.
|
||||
let offset = (re_org_block_slot % E::slots_per_epoch()).as_u64();
|
||||
if disallowed_offsets.offsets.contains(&offset) {
|
||||
return Err(DoNotReOrg::DisallowedOffset { offset }.into());
|
||||
}
|
||||
|
||||
// Check FFG.
|
||||
let ffg_competitive = parent_node.unrealized_justified_checkpoint()
|
||||
== head_node.unrealized_justified_checkpoint()
|
||||
|
||||
Reference in New Issue
Block a user