AntelopeIO / leap

C++ implementation of the Antelope protocol
Other
113 stars 69 forks source link

IF: add get_blocks_result_v1 support to SHiP #2349

Closed linh2931 closed 3 months ago

linh2931 commented 3 months ago

https://github.com/AntelopeIO/leap/pull/2321 added SHiP support for IBC. A new get_blocks_request_v1 was introduced to include a field fetch_finality_data, but existing get_blocks_result_v0 was reused to return the result of get_blocks_request_v1. That can cause confusions to the users, and a client's ABI bin_to_json() would add an extra "finality_data": null to the JSON output in Legacy (as finality_data does not exist).

This PR adds get_blocks_result_v1 which stores the result of get_blocks_request_v1; get_blocks_result_v0 is restored to its original use: only storing the result of get_blocks_result_v0.

get_blocks_request_v1 adds extra get_blocks_request_v1 to get_blocks_request_v0; get_blocks_result_v1 adds extra finality_data to get_blocks_result_v0.

struct get_blocks_request_v1 : get_blocks_request_v0 {
   bool                        fetch_finality_data    = false;
};

struct get_blocks_result_v1 : get_blocks_result_v0 {
   std::optional<bytes>        finality_data;
};

Tests are updated to check both get_blocks_result_v0 and get_blocks_result_v1 work.

Resolved https://github.com/AntelopeIO/leap/issues/2340

ericpassmore commented 3 months ago

Note:start group: IF category: INTERNALS summary: Adds get_blocks_result_v1 to SHiP as part of IBC support; get_blocks_result_v0 is restored to its original use. Note:end