From 78ad69ef83f350a015adf6d3cb5324bb5c250067 Mon Sep 17 00:00:00 2001 From: jackzhhuang Date: Sat, 14 Dec 2024 10:03:55 +0800 Subject: [PATCH] data inconsistent will be ignore when adding dag into reachability data --- flexidag/src/blockdag.rs | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/flexidag/src/blockdag.rs b/flexidag/src/blockdag.rs index b9035fcfae..fb59e2f007 100644 --- a/flexidag/src/blockdag.rs +++ b/flexidag/src/blockdag.rs @@ -17,6 +17,7 @@ use crate::consensusdb::{ use crate::ghostdag::protocol::GhostdagManager; use crate::process_key_already_error; use crate::prune::pruning_point_manager::PruningPointManagerT; +use crate::reachability::ReachabilityError; use anyhow::{bail, ensure, Ok}; use rocksdb::WriteBatch; use starcoin_config::temp_dir; @@ -242,13 +243,26 @@ impl BlockDAG { .filter(|hash| self.storage.reachability_store.read().has(*hash).unwrap()) .collect::>() .into_iter(); - inquirer::add_block( + match inquirer::add_block( &mut stage, header.id(), ghostdata.selected_parent, &mut merge_set, - ) - .expect("failed to add reachability in stage batch"); + ) { + std::result::Result::Ok(_) => {} + Err(e) => match e { + ReachabilityError::DataInconsistency => { + info!( + "the key {:?} was already processed, original error message: {:?}", + header.id(), + ReachabilityError::DataInconsistency + ); + } + _ => { + panic!("failed to add block in batch for error: {:?}", e); + } + }, + } process_key_already_error(self.storage.relations_store.write().insert_batch( &mut batch, @@ -339,13 +353,26 @@ impl BlockDAG { .collect::>() .into_iter(); - inquirer::add_block( + match inquirer::add_block( &mut stage, header.id(), ghostdata.selected_parent, &mut merge_set, - ) - .expect("failed to add block in batch"); + ) { + std::result::Result::Ok(_) => {} + Err(e) => match e { + ReachabilityError::DataInconsistency => { + info!( + "the key {:?} was already processed, original error message: {:?}", + header.id(), + ReachabilityError::DataInconsistency + ); + } + _ => { + panic!("failed to add block in batch for error: {:?}", e); + } + }, + } process_key_already_error(self.storage.relations_store.write().insert_batch( &mut batch,