-
Notifications
You must be signed in to change notification settings - Fork 73
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
restore get_block_header_state
endpoint for usage both pre and post Savanna activation
#2311
restore get_block_header_state
endpoint for usage both pre and post Savanna activation
#2311
Conversation
@@ -1063,6 +1063,36 @@ struct controller_impl { | |||
}); | |||
} | |||
|
|||
template <typename F> | |||
std::optional<block_header_state_legacy> fetch_bhs_for_legacy_rpc_by_x(F&& f, const std::optional<block_num_type> block_num = std::nullopt) const { |
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.
It feels wrong for logic specific to how an RPC endpoint operates to be in controller
(instead of the chain_plugin
leveraging more generic calls against controller
), but controller
seems to be in the best position to create something concise with forkdb
& apply()
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.
We are trying to keep block_header_state
and block_header_state_legacy
from leaking out of controller. Seems like this should return a signed_block_ptr
and move the extraction of data into chain_plugin
. You should then be able to just use the existing fetch_block_by_id
and fetch_block_by_number
. Seems to me we can return the same data pre/post Savanna.
}; | ||
|
||
set_finalizers(policy_input); | ||
produce_blocks(10); |
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.
Test could use some love around the call's behavior during the transition -- what I guess is the new both
forkdb situation will handle -- when that is added.
Note:start |
@@ -1063,6 +1063,36 @@ struct controller_impl { | |||
}); | |||
} | |||
|
|||
template <typename F> | |||
std::optional<block_header_state_legacy> fetch_bhs_for_legacy_rpc_by_x(F&& f, const std::optional<block_num_type> block_num = std::nullopt) const { |
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.
We are trying to keep block_header_state
and block_header_state_legacy
from leaking out of controller. Seems like this should return a signed_block_ptr
and move the extraction of data into chain_plugin
. You should then be able to just use the existing fetch_block_by_id
and fetch_block_by_number
. Seems to me we can return the same data pre/post Savanna.
After some side band discussion, we want to go with a different approach: always behave the same both pre & post Savanna by returning an elided |
get_block_header_state
returns the pre-Savanna (legacy) block header state. Parts of this response are incompatible with the internals of the new Savanna block state. Originally the plan was to simply remove theget_block_header_state
endpoint, but some versions of eosjs (including thelatest
one, 22.1.0, apparently downloaded some 17k times in the last week) require operation of this endpoint given certain values ofblocksBehind
otherwise eosjs will be unable to push a transaction.So instead, restore the endpoint with some important restrictions. Prior to Savanna activation the endpoint will continue to -- strictly for reversible blocks -- return the entire legacy block header state as it does today. But after activation of Savanna, it will return a response containing all fields but with only
block_num
,id
,header
, andadditional_signatures
filled out. Other fields will still exist but will be empty or zero. Additionally, the endpoint will consider both reversible and irreversible blocks if the request used a block number. This latter tweak helps guard against a race condition in eosjs between callingget_info
and thenget_block_header_state
whenblocksBehind
is a low number such as 2 or 3.An example post Savanna activated response with the limited filled fields looks something like,
I've confirmed with eosjs 22.1.0, 21.0.4, and 20.0.3 that operation works as expected. (20.0.3 does not use
get_block_header_state
fortransact()
though, instead just always callingget_block
)Resolves AntelopeIO/spring#39