add focil epoch activation

This commit is contained in:
Eitan Seri-Levi
2025-02-01 23:54:50 +03:00
parent d3368f59a3
commit f31c0b69e3
5 changed files with 123 additions and 11 deletions

View File

@@ -9,12 +9,13 @@ use std::sync::Arc;
use types::{
Attestation, AttestationBase, AttestationElectra, AttesterSlashing, AttesterSlashingBase,
AttesterSlashingElectra, BlobSidecar, DataColumnSidecar, DataColumnSubnetId, EthSpec,
ForkContext, ForkName, InclusionList, LightClientFinalityUpdate, LightClientOptimisticUpdate,
ForkContext, ForkName, LightClientFinalityUpdate, LightClientOptimisticUpdate,
ProposerSlashing, SignedAggregateAndProof, SignedAggregateAndProofBase,
SignedAggregateAndProofElectra, SignedBeaconBlock, SignedBeaconBlockAltair,
SignedBeaconBlockBase, SignedBeaconBlockBellatrix, SignedBeaconBlockCapella,
SignedBeaconBlockDeneb, SignedBeaconBlockElectra, SignedBlsToExecutionChange,
SignedContributionAndProof, SignedVoluntaryExit, SubnetId, SyncCommitteeMessage, SyncSubnetId,
SignedContributionAndProof, SignedInclusionList, SignedVoluntaryExit, SubnetId,
SyncCommitteeMessage, SyncSubnetId,
};
#[derive(Debug, Clone, PartialEq)]
@@ -46,7 +47,7 @@ pub enum PubsubMessage<E: EthSpec> {
/// Gossipsub message providing notification of a light client optimistic update.
LightClientOptimisticUpdate(Box<LightClientOptimisticUpdate<E>>),
/// Gossipsub message providing notification of an inclusion list.
InclusionList(Box<InclusionList<E>>),
InclusionList(Box<SignedInclusionList<E>>),
}
// Implements the `DataTransform` trait of gossipsub to employ snappy compression
@@ -394,9 +395,27 @@ impl<E: EthSpec> PubsubMessage<E> {
)))
}
GossipKind::InclusionList => {
let il =
InclusionList::from_ssz_bytes(data).map_err(|e| format!("{:?}", e))?;
Ok(PubsubMessage::InclusionList(Box::new(il)))
match fork_context.from_context_bytes(gossip_topic.fork_digest) {
Some(fork) if fork.electra_enabled() => {
let il = SignedInclusionList::from_ssz_bytes(data)
.map_err(|e| format!("{:?}", e))?;
let focil_enabled = fork_context.spec.is_focil_enabled_for_epoch(
il.message.slot.epoch(E::slots_per_epoch()),
);
if focil_enabled {
Ok(PubsubMessage::InclusionList(Box::new(il)))
} else {
Err(format!(
"inclusion_List topic invalid for given fork digest {:?}",
gossip_topic.fork_digest
))
}
}
Some(_) | None => Err(format!(
"inclusion_List topic invalid for given fork digest {:?}",
gossip_topic.fork_digest
)),
}
}
}
}