-
Notifications
You must be signed in to change notification settings - Fork 290
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
Fix bug: no store the sync dag block #4259
Open
jackzhhuang
wants to merge
16
commits into
dag-master
Choose a base branch
from
sync-store-clear
base: dag-master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a6403bc
no store the sync dag block
jackzhhuang c173559
add rm sync in kube file
jackzhhuang 48c9bac
use ghostdata to verify the dag block
jackzhhuang c8b259a
use ghodata if the verify is not correct
jackzhhuang 1a6c851
use ghostdata instead of verify
jackzhhuang 264a5d6
add verification code for discovering the blue blocks error
jackzhhuang 3b2a145
verify and if it fails it use ghostdata
jackzhhuang 197bc4f
bail out if the ghost data checking is wrong
jackzhhuang adfcb23
remove to print red blocks avoiding lots log data
jackzhhuang e06797d
test dag verification
jackzhhuang 86ee296
add log to trace
jackzhhuang 8250159
add reachability data with parents
jackzhhuang 573bc89
fix fmt
jackzhhuang e3dca70
use unordered_mergeset_without_selected_parent when storing into the …
jackzhhuang 248b7fb
rm commented codes
jackzhhuang e4eff6c
add uncle test in reachability
jackzhhuang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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::{bail, ensure, Context, Result}; | ||
use anyhow::{ensure, Context, Result}; | ||
use parking_lot::RwLock; | ||
use starcoin_crypto::HashValue as Hash; | ||
use starcoin_logger::prelude::*; | ||
|
@@ -171,7 +171,7 @@ impl< | |
Ok(new_block_data) | ||
} | ||
|
||
pub(crate) fn verify_and_ghostdata( | ||
pub(crate) fn _verify_and_ghostdata( | ||
&self, | ||
blue_blocks: &[BlockHeader], | ||
header: &BlockHeader, | ||
|
@@ -221,12 +221,8 @@ impl< | |
.map(|header| header.id()) | ||
.collect::<HashSet<_>>() | ||
{ | ||
if header.number() < 10000000 { | ||
// no bail before 10000000 | ||
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); | ||
} else { | ||
bail!("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); | ||
} | ||
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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve error handling and logging. The current implementation has several issues:
Consider this alternative implementation: - 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 expected_blues: HashSet<_> = blue_blocks.iter().map(|header| header.id()).collect();
+ let actual_blues: HashSet<_> = new_block_data.mergeset_blues.iter().skip(1).cloned().collect();
+ let missing_blues: Vec<_> = expected_blues.difference(&actual_blues).collect();
+ let extra_blues: Vec<_> = actual_blues.difference(&expected_blues).collect();
+
+ warn!(
+ "Blue set mismatch for block {:?}:\nMissing blues: {:?}\nUnexpected blues: {:?}",
+ header.id(),
+ missing_blues,
+ extra_blues
+ );
+
+ return Err(anyhow::anyhow!(
+ "Blue set verification failed for block {:?}",
+ header.id()
+ )); This change:
|
||
} | ||
|
||
let blue_score = self | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Remove underscore prefix from verify_and_ghostdata method
The underscore prefix is inconsistent with the method's usage pattern. The evidence shows:
chain/src/chain.rs
andchain/src/verifier/mod.rs
)BlockDag::verify_and_ghostdata
which is a public interfaceThe underscore prefix suggests internal use, but this is clearly a public-facing API method. Remove the underscore to match its actual visibility and usage pattern.
🔗 Analysis chain
Clarify method visibility intention
The underscore prefix suggests this method is intended for internal/private use, but it's still marked as
pub(crate)
. This creates confusion about the intended visibility scope.Let's check if this method is still being used by other modules:
Consider either:
pub(crate)
if it's only used within this module🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 536
Script:
Length of output: 1804
Script:
Length of output: 1085