Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Testing Reversion Speed on Dispute Concluded Against #6880

Merged
merged 7 commits into from
Mar 16, 2023
9 changes: 9 additions & 0 deletions node/core/chain-selection/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ fn apply_ancestor_reversions(
// of unviability is only heavy on the first log.
for revert_number in reversions {
let maybe_block_entry = load_ancestor(backend, block_hash, block_number, revert_number)?;
if let Some(block_entry) = &maybe_block_entry {
gum::trace!(target: LOG_TARGET, ?revert_number, ?block_entry.block_hash, "Block marked as reverted via scraped on-chain reversions");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: cargo fmt does not work for macros, it's not that critical, but it's better to fold the lines manually to fit into 100 chars

}
revert_single_block_entry_if_present(
backend,
maybe_block_entry,
Expand All @@ -380,6 +383,12 @@ pub(crate) fn apply_single_reversion(
revert_hash: Hash,
revert_number: BlockNumber,
) -> Result<(), Error> {
gum::trace!(
target: LOG_TARGET,
?revert_number,
?revert_hash,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use same key as above: revert_hash or block_hash

"Block marked as reverted via ChainSelectionMessage::RevertBlocks"
);
let maybe_block_entry = backend.load_block_entry(&revert_hash)?;
revert_single_block_entry_if_present(
backend,
Expand Down
9 changes: 9 additions & 0 deletions node/core/dispute-coordinator/src/initialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,15 @@ impl Initialized {
// will need to mark the candidate's relay parent as reverted.
if import_result.is_freshly_concluded_against() {
let blocks_including = self.scraper.get_blocks_including_candidate(&candidate_hash);
for (parent_block_number, parent_block_hash) in &blocks_including {
gum::trace!(
target: LOG_TARGET,
?candidate_hash,
?parent_block_number,
?parent_block_hash,
"Dispute has just concluded against the candidate hash noted. Its parent will be marked as reverted."
);
}
if blocks_including.len() > 0 {
ctx.send_message(ChainSelectionMessage::RevertBlocks(blocks_including)).await;
} else {
Expand Down