-
Notifications
You must be signed in to change notification settings - Fork 649
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
Store correct block ID when switching forks #938
Conversation
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.
Good find. Are there tests that exercise forking, switching forks, etc? Can a test be developed to demonstrate this issue?
Update: Found it... block_tests::fork_blocks
Looks good. @jmjatlanta are you working on a test case? |
added some dumps at @abitmore code to see the difference and running as can be seen, the
i think this is the expected behavior, please check and confirm. |
I was not working on a test case, but I will. |
tests/tests/block_tests.cpp
Outdated
{ | ||
fc::optional<signed_block> curr_block = db1.fetch_block_by_number( curr_block_num ); | ||
BOOST_CHECK( curr_block.valid() ); | ||
BOOST_CHECK_EQUAL( curr_block->previous, previous_block->id() ); |
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.
This test should fail with the old code, but is not.
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.
fetch_block_by_number
here will read data from _fork_db
, thus will pass the check.
I think we can add more tests in the end: close db, reopen db, run this check again.
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.
Unfortunately, the original problem still does not show up. I haven't dug too deeply, but I'm guessing the reindexing that happens when the database opens fixes things.
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.
Oh, reopen at this point doesn't work. Try generate 30 more blocks to push the 2 blocks out of fork_db
.
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.
Oh, seems due to empty blocks. I'm trying to update the test case.
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.
My comment earlier about empty block is incorrect.
Actually PUSH_BLOCK( db1, good_block );
made all blocks stored in db1
correct. I'm trying to reproduce.
@pmconrad @jmjatlanta @oxarbitrage test case fixed, please review again. |
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.
Good job!
Related to #831 .