mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(engine): track elapsed on fork block added (#10710)
This commit is contained in:
@ -8,14 +8,14 @@ use std::{sync::Arc, time::Duration};
|
||||
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),
|
||||
/// A block was added to the fork chain.
|
||||
ForkBlockAdded(Arc<SealedBlock>),
|
||||
}
|
||||
|
||||
impl BeaconConsensusEngineEvent {
|
||||
|
||||
@ -1244,7 +1244,7 @@ where
|
||||
let event = if attachment.is_canonical() {
|
||||
BeaconConsensusEngineEvent::CanonicalBlockAdded(block, elapsed)
|
||||
} else {
|
||||
BeaconConsensusEngineEvent::ForkBlockAdded(block)
|
||||
BeaconConsensusEngineEvent::ForkBlockAdded(block, elapsed)
|
||||
};
|
||||
self.event_sender.notify(event);
|
||||
PayloadStatusEnum::Valid
|
||||
|
||||
@ -2112,10 +2112,11 @@ where
|
||||
let finalized = self.state.forkchoice_state_tracker.sync_target_finalized();
|
||||
|
||||
// emit insert event
|
||||
let elapsed = start.elapsed();
|
||||
let engine_event = if self.is_fork(block_hash, finalized)? {
|
||||
BeaconConsensusEngineEvent::ForkBlockAdded(sealed_block)
|
||||
BeaconConsensusEngineEvent::ForkBlockAdded(sealed_block, elapsed)
|
||||
} else {
|
||||
BeaconConsensusEngineEvent::CanonicalBlockAdded(sealed_block, start.elapsed())
|
||||
BeaconConsensusEngineEvent::CanonicalBlockAdded(sealed_block, elapsed)
|
||||
};
|
||||
self.emit_event(EngineApiEvent::BeaconConsensus(engine_event));
|
||||
|
||||
@ -2665,6 +2666,7 @@ mod tests {
|
||||
match event {
|
||||
EngineApiEvent::BeaconConsensus(BeaconConsensusEngineEvent::ForkBlockAdded(
|
||||
block,
|
||||
_,
|
||||
)) => {
|
||||
assert!(block.hash() == expected_hash);
|
||||
}
|
||||
|
||||
@ -275,8 +275,8 @@ impl NodeState {
|
||||
|
||||
info!(number=head.number, hash=?head.hash(), ?elapsed, "Canonical chain committed");
|
||||
}
|
||||
BeaconConsensusEngineEvent::ForkBlockAdded(block) => {
|
||||
info!(number=block.number, hash=?block.hash(), "Block added to fork chain");
|
||||
BeaconConsensusEngineEvent::ForkBlockAdded(block, elapsed) => {
|
||||
info!(number=block.number, hash=?block.hash(), ?elapsed, "Block added to fork chain");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user