AntelopeIO / leap

C++ implementation of the Antelope protocol
Other
116 stars 70 forks source link

IF: SHiP changes to support IBC services (adding finality_data log) #2321

Closed linh2931 closed 6 months ago

linh2931 commented 6 months ago

A new log finality_data is introduced to SHiP to stream finality related data. It is enabled by option --finality-data-history when starting a SHiP.

To fetch finality_data, use the new version of get_blocks_request:

struct get_blocks_request_v1 {
   uint32_t                    start_block_num        = 0;
   uint32_t                    end_block_num          = 0;
   uint32_t                    max_messages_in_flight = 0;
   std::vector<block_position> have_positions         = {};
   bool                        irreversible_only      = false;
   bool                        fetch_block            = false;
   bool                        fetch_traces           = false;
   bool                        fetch_deltas           = false;
   bool                        fetch_finality_data    = false;;
};

finality_data contains the following data:

struct finality_data_t {
   uint32_t     major_version{light_header_protocol_version_major};
   uint32_t     minor_version{light_header_protocol_version_minor};
   uint32_t     active_finalizer_policy_generation{0};
   digest_type  action_mroot{};
   digest_type  base_digest{};
};

A sample test run result looks like

{ "get_blocks_result_v0":
{
    "head": {
        "block_num": 143,
        "block_id": "0000008F3FF69AE70A77046027927082E922F2E42B0DAABE3A5053CB22179840"
    },
    "last_irreversible": {
        "block_num": 139,
        "block_id": "0000008B8289314ABA3DEE3B53245DA6FC74E5F9C49F6E80F5C265D50AD81805"
    },
    "this_block": {
        "block_num": 134,
        "block_id": "00000086F65F560E02C07B15B7D860BBE7D1282B4997A7538A1952B23739D535"
    },
    "prev_block": {
        "block_num": 133,
        "block_id": "000000852EE672A6249D9DE12B403B36B79449DBB1CD829890D2ABF74DA6B997"
    },
    "block": "0868165B80AE423AD15B974A0000000000852EE672A6249D9DE12B403B36B79449DBB1CD829890D2ABF74DA6B99700000000
000000000000000000000000000000000000000000000000000000002FC5444BCB1DFEBF0E4EB31ABCEC349EC55D5F70B678D796B257F3C6BC
903FD000000080000102000785000000010000002064365970301F6B7EE19CBC088869168E7BFF7CB6A826403ED3D620326119F30321923023
56C6087384941A3DEDA8ADAFBDFC57ADAE53C748E840C0E9B1A11DE700010300AB028500000001010F000000009DB726DF78ABF2BDEF6E8CEA
3B30761B2345CA2CEE61052BA62AF43FB4D68E501A7F85AD81D7E50F029CD130BD9FDE115BFF3072CD606649FECA6B8597804B79A1B356E03E
15804DA9AFD2F88B3B3D0AEF1FFAC61FAE5AB3C545AF29C13A4B068588353300903C41E9F8E2FFBA4331F879BA12CFDC6DD64FE672DF18E837
8AC6A9EAA2A72B7B45DF514794856CEB160916AA7BD9B327A11D62E09C31361AD892815F7F4AAE03B2E5F24C80CA30B9EBC6C5F64A68A96E8E
38E89D2162B94DA1180F3A3EE11AE6DB7C2BFD8C56B5D8CFE60EBB80BD159580B31CB005FC75D46D4D41CCC34674DDACFB340F29B6CB38D70E
1CF1D4D88B067533A29983B8AF350A3C1469D3A5FD0B84B41EB7F28A781C9555F443D7A64BE42E767079279479A8810E",
    "traces": "01008F9869B957E33758F276EA11400DB8E470B6B8571D81402F6E10F56EA635DE560064000000000000000000000000000
0000000000000000101010001000000000000EA3055F481D9FDB0F0AB441396E51B62DF6006B13CAB7AA3848F42AF437520F706A6E9C200000
000000000B500000000000000010000000000EA3055BC0000000000000002020000000000EA30550000000000EA305500000000221ACFA4010
000000000EA305500000000A8ED32327E0768165B70AE423AD15B974A0000000000848B75D25E89E1C801D2838C75D4BB56F9827D22563E794
769EAD53CC90000000000000000000000000000000000000000000000000000000000000000B4AA479BB182B047BE9A3F94C5CD8C4C21478CB
570F316D250DB5177238E834100000080000102000784000000010000000000000000000000000000000000000000010000000000000000000
000000000000000",
    "deltas": "02000E7265736F757263655F757361676501013B000000000000EA3055000868165B5C8A020000000000010000000000000
0000868165BA77A05000000000065000000000000003FEF06000000000000157265736F757263655F6C696D6974735F7374617465010153000
086000000D2D4D80A00000000B6000000000000000086000000DC19E51300000000B1010000000000000000000000000000000000000000000
00000000000000000B0461200000000009FB4080000000000",
    "finality_data": "010000000000000000000000EF01DE2A75105982A0D6A88FD934E3BA7C88FFC339DC1E3F33130C36717D7E245A85
1A54FA6F4E1174D92D2480D21CE66026B296803DFA12B1E3847E699EF4A0"
}
}

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

ericpassmore commented 6 months ago

Note:start group: IF category: INTERNALS summary: Add finality_data log updating SHiP to support IBC services. Note:end

greg7mdp commented 6 months ago

Currently test_chain_plugin fails in this branch (probably an integration issue).

linh2931 commented 6 months ago

Currently test_chain_plugin fails in this branch (probably an integration issue).

Hm, the PR branch passed all the tests after updating with the hotstuff_integration branch.

greg7mdp commented 6 months ago

Hm, the PR branch passed all the tests after updating with the hotstuff_integration branch.

Weird, running ./plugins/chain_plugin/test/test_chain_plugin in my build of your branch fails every time.

Rebuilt the branch from scratch, and now the test passes. Must have been some leftover file.