This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
Fix bug in get_block of chain_plugin that would lead to unnecessary failures for some block numbers #6904
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.
Change Description
This PR fixes a bug in
get_block
of chain_plugin that could lead to unnecessary failure when requesting a block by number. This PR also updates the fc submodule to the latest master.The
get_block
logic first tried to convert theblock_num_or_id
string input into a block ID and use it to try to find the block. If it failed to find the block, it would then attempt interpret the string as a block number and try to find the block that way.But the request should not just fail if the string input does not make a valid ID when it could make a perfectly valid block number. This was the failure mode that was being triggered in one of the tests after the fc submodule update. EOSIO/fc#64 added stricter validation rules to conversions from
fc::variant
tovector<char>
, whichfc::variant
conversions toblock_id_type
uses, to disallow odd-length hex strings. So with these fc changes, the original logic ofget_block
would fail requests made with block numbers that when represented as a decimal string were of odd-length.The new logic is aligned with how
get_block_header_state
already worked. It will try to interpretblock_num_or_id
as a number. If it can, it will try to lookup the block by the number. If it cannot interpretblock_num_or_id
as a number, it will then try to convert the string to a block ID (failing the request if not possible) and then use that ID to try to lookup the block.Consensus Changes
API Changes
Documentation Additions