Skip to content

Commit

Permalink
bail out if the ghost data checking is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzhhuang committed Nov 7, 2024
1 parent 3b2a145 commit 197bc4f
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions flexidag/src/ghostdag/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::util::Refs;
use crate::consensusdb::schemadb::{GhostdagStoreReader, HeaderStoreReader, RelationsStoreReader};
use crate::reachability::reachability_service::ReachabilityService;
use crate::types::{ghostdata::GhostdagData, ordering::*};
use anyhow::{ensure, Context, Result};
use anyhow::{bail, ensure, Context, Result};
use parking_lot::RwLock;
use starcoin_crypto::HashValue as Hash;
use starcoin_logger::prelude::*;
Expand Down Expand Up @@ -210,19 +210,30 @@ impl<
}
}

let remote_blue_set = blue_blocks
.iter()
.map(|header| header.id())
.collect::<HashSet<_>>();
if new_block_data
.mergeset_blues
.iter()
.skip(1)
.cloned()
.collect::<HashSet<_>>()
!= blue_blocks
.iter()
.map(|header| header.id())
.collect::<HashSet<_>>()
!= remote_blue_set
{
warn!("The data of blue set is not equal when executing the block: {:?}, for {:?}, checking data: {:?}", header.id(), blue_blocks.iter().map(|header| header.id()).collect::<Vec<_>>(), new_block_data.mergeset_blues);
return self.ghostdag(&header.parents_hash());
let ghostdata = self.ghostdag(&header.parents_hash())?;
if ghostdata
.mergeset_blues
.iter()
.skip(1)
.cloned()
.collect::<HashSet<_>>()
!= remote_blue_set
{
bail!("The ghost data of blue set is not equal when executing the block: {:?}, for {:?}, checking data: {:?}", header.id(), blue_blocks.iter().map(|header| header.id()).collect::<Vec<_>>(), ghostdata.mergeset_blues);
}
}

let blue_score = self
Expand Down

0 comments on commit 197bc4f

Please sign in to comment.