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

BeaconConsensusEngineEvent generic data prims #12822

Closed
Tracked by #12578
emhane opened this issue Nov 24, 2024 · 1 comment · Fixed by #12831
Closed
Tracked by #12578

BeaconConsensusEngineEvent generic data prims #12822

emhane opened this issue Nov 24, 2024 · 1 comment · Fixed by #12831
Assignees
Labels
A-consensus Related to the consensus engine A-sdk Related to reth's use as a library C-debt Refactor of code section that is hard to understand or maintain D-good-first-issue Nice and easy! A great choice to get started

Comments

@emhane
Copy link
Member

emhane commented Nov 24, 2024

Describe the feature

Make BeaconConsensusEngineEvent generic over primitive types as BeaconConsensusEngineEvent<N: NodePrimitives = reth_primitives::EthPrimitives>. Pass generics N::BlockHeader and N::BlockBody, to the contained SealedHeader and SealedBlock. Update the impl body accordingly.

/// Events emitted by [`crate::BeaconConsensusEngine`].
#[derive(Clone, Debug)]
pub enum BeaconConsensusEngineEvent {
/// The fork choice state was updated, and the current fork choice status
ForkchoiceUpdated(ForkchoiceState, ForkchoiceStatus),
/// A block was added to the fork chain.
ForkBlockAdded(Arc<SealedBlock>, Duration),
/// A block was added to the canonical chain, and the elapsed time validating the block
CanonicalBlockAdded(Arc<SealedBlock>, Duration),
/// A canonical chain was committed, and the elapsed time committing the data
CanonicalChainCommitted(Box<SealedHeader>, Duration),
/// The consensus engine is involved in live sync, and has specific progress
LiveSyncProgress(ConsensusEngineLiveSyncProgress),
}
impl BeaconConsensusEngineEvent {
/// Returns the canonical header if the event is a
/// [`BeaconConsensusEngineEvent::CanonicalChainCommitted`].
pub const fn canonical_header(&self) -> Option<&SealedHeader> {
match self {
Self::CanonicalChainCommitted(header, _) => Some(header),
_ => None,
}
}
}
impl Display for BeaconConsensusEngineEvent {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match self {
Self::ForkchoiceUpdated(state, status) => {
write!(f, "ForkchoiceUpdated({state:?}, {status:?})")
}
Self::ForkBlockAdded(block, duration) => {
write!(f, "ForkBlockAdded({:?}, {duration:?})", block.num_hash())
}
Self::CanonicalBlockAdded(block, duration) => {
write!(f, "CanonicalBlockAdded({:?}, {duration:?})", block.num_hash())
}
Self::CanonicalChainCommitted(block, duration) => {
write!(f, "CanonicalChainCommitted({:?}, {duration:?})", block.num_hash())
}
Self::LiveSyncProgress(progress) => {
write!(f, "LiveSyncProgress({progress:?})")
}
}
}
}

Additional context

No response

@emhane emhane added A-consensus Related to the consensus engine A-sdk Related to reth's use as a library C-debt Refactor of code section that is hard to understand or maintain D-good-first-issue Nice and easy! A great choice to get started labels Nov 24, 2024
@programskillforverification
Copy link
Contributor

Can I take this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Related to the consensus engine A-sdk Related to reth's use as a library C-debt Refactor of code section that is hard to understand or maintain D-good-first-issue Nice and easy! A great choice to get started
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants