check root block num before returning it when include_root_t::yes
#234
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.
Without this change it's possible for forkdb to return a block that does not match the block number requested which is causing a ship test malfunction.
Consider a forkdb that is rooted at block 300, has a head that is 300, and no block log exists, something calls
get_block_id_for_num(299)
spring/libraries/chain/controller.cpp
Lines 5201 to 5208 in 2b1228e
so,
spring/libraries/chain/controller.cpp
Lines 1140 to 1142 in 2b1228e
ultimately,
spring/libraries/chain/fork_database.cpp
Lines 532 to 534 in 2b1228e
notice above that the first parameter will be the block id for block 300. then,
spring/libraries/chain/fork_database.cpp
Lines 513 to 516 in 2b1228e
since
root == head && include_root_t
the block id for block 300 will be returned. But we asked for block 299!