Skip to content
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

Merged
merged 1 commit into from
Mar 9, 2019

Conversation

arhag
Copy link
Contributor

@arhag arhag commented Mar 9, 2019

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 the block_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 to vector<char>, which fc::variant conversions to block_id_type uses, to disallow odd-length hex strings. So with these fc changes, the original logic of get_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 interpret block_num_or_id as a number. If it can, it will try to lookup the block by the number. If it cannot interpret block_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

…ilure if passed in a block number; also update fc submodule
@arhag arhag merged commit 16889a2 into develop Mar 9, 2019
@arhag arhag deleted the fix-chain-plugin-get-block branch March 9, 2019 02:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants