From bed8205ca8d74e88e992bfdc75f9ea99e39f85b8 Mon Sep 17 00:00:00 2001 From: Savinda Senevirathne Date: Wed, 6 Jan 2021 20:02:14 +0530 Subject: [PATCH] Config patch change detection. (#211) * Applying patch file changes to hpcore runtime after patch file change detection. * Removing unl sync functionality. * Removing subjecting unl changeset to consensus. --- src/consensus.cpp | 96 +------- src/consensus.hpp | 14 +- src/hpfs/hpfs_sync.cpp | 17 ++ src/main.cpp | 1 - src/msg/controlmsg_common.hpp | 1 - src/msg/controlmsg_parser.cpp | 5 - src/msg/controlmsg_parser.hpp | 1 - src/msg/fbuf/ledger_helpers.cpp | 9 +- src/msg/fbuf/ledger_schema.fbs | 7 - src/msg/fbuf/ledger_schema_generated.h | 121 +--------- src/msg/fbuf/p2pmsg_content.fbs | 20 +- src/msg/fbuf/p2pmsg_content_generated.h | 295 +----------------------- src/msg/fbuf/p2pmsg_helpers.cpp | 87 +------ src/msg/fbuf/p2pmsg_helpers.hpp | 8 - src/msg/json/controlmsg_json.cpp | 29 --- src/msg/json/controlmsg_json.hpp | 3 - src/p2p/p2p.hpp | 37 --- src/p2p/peer_session_handler.cpp | 35 --- src/sc.cpp | 29 ++- src/sc.hpp | 3 - src/unl.cpp | 266 ++------------------- src/unl.hpp | 39 +--- 22 files changed, 90 insertions(+), 1033 deletions(-) diff --git a/src/consensus.cpp b/src/consensus.cpp index 501e1883..10268fdf 100644 --- a/src/consensus.cpp +++ b/src/consensus.cpp @@ -113,7 +113,6 @@ namespace consensus const uint64_t lcl_seq_no = ledger::ctx.get_seq_no(); util::h32 state_hash = hpfs::ctx.get_hash(hpfs::HPFS_PARENT_COMPONENTS::STATE); util::h32 patch_hash = hpfs::ctx.get_hash(hpfs::HPFS_PARENT_COMPONENTS::PATCH); - std::string unl_hash = unl::get_hash(); if (ctx.stage == 0) { @@ -122,7 +121,7 @@ namespace consensus if (verify_and_populate_candidate_user_inputs(lcl_seq_no) == -1) return -1; - const p2p::proposal p = create_stage0_proposal(lcl, state_hash, patch_hash, unl_hash); + const p2p::proposal p = create_stage0_proposal(lcl, state_hash, patch_hash); broadcast_proposal(p); ctx.stage = 1; // Transition to next stage. @@ -133,12 +132,12 @@ namespace consensus const size_t unl_count = unl::count(); vote_counter votes; - const int sync_status = check_sync_status(lcl, unl_hash, unl_count, votes); + const int sync_status = check_sync_status(lcl, unl_count, votes); if (sync_status == 0) { // If we are in sync, vote and broadcast the winning votes to next stage. - const p2p::proposal p = create_stage123_proposal(votes, lcl, unl_count, state_hash, patch_hash, unl_hash); + const p2p::proposal p = create_stage123_proposal(votes, lcl, unl_count, state_hash, patch_hash); broadcast_proposal(p); // Upon successful consensus at stage 3, update the ledger and execute the contract using the consensus proposal. @@ -167,9 +166,9 @@ namespace consensus /** * Checks whether we are in sync with the received votes. - * @return 0 if we are in sync. -1 on lcl, hpfs or unl desync. -2 if majority lcl unreliable. + * @return 0 if we are in sync. -1 on lcl or hpfs desync. -2 if majority lcl unreliable. */ - int check_sync_status(std::string_view lcl, std::string_view unl_hash, const size_t unl_count, vote_counter &votes) + int check_sync_status(std::string_view lcl, const size_t unl_count, vote_counter &votes) { // Check if we're ahead/behind of consensus lcl. bool is_lcl_desync = false; @@ -200,19 +199,8 @@ namespace consensus hpfs_sync::set_target(majority_state_hash, majority_patch_hash); } - // Check unl hash with the majority unl hash. - bool is_unl_desync = false; - std::string majority_unl; - check_unl_votes(is_unl_desync, majority_unl, votes, unl_hash); - // Start unl sync if we are out-of-sync with majority unl. - if (is_unl_desync) - { - conf::change_role(conf::ROLE::OBSERVER); - unl::set_sync_target(majority_unl); - } - // Proceed further only if both lcl and state are in sync with majority. - if (!is_lcl_desync && !is_state_desync && !is_patch_desync && !is_unl_desync) + if (!is_lcl_desync && !is_state_desync && !is_patch_desync) { conf::change_role(conf::ROLE::VALIDATOR); return 0; @@ -232,7 +220,7 @@ namespace consensus */ void check_sync_completion() { - if (conf::cfg.node.role == conf::ROLE::OBSERVER && !hpfs_sync::ctx.is_syncing && !ledger::sync_ctx.is_syncing && !unl::sync_ctx.is_syncing) + if (conf::cfg.node.role == conf::ROLE::OBSERVER && !hpfs_sync::ctx.is_syncing && !ledger::sync_ctx.is_syncing) conf::change_role(conf::ROLE::VALIDATOR); } @@ -535,7 +523,7 @@ namespace consensus return 0; } - p2p::proposal create_stage0_proposal(std::string_view lcl, util::h32 state_hash, util::h32 patch_hash, std::string_view unl_hash) + p2p::proposal create_stage0_proposal(std::string_view lcl, util::h32 state_hash, util::h32 patch_hash) { // This is the proposal that stage 0 votes on. // We report our own values in stage 0. @@ -545,7 +533,6 @@ namespace consensus p.lcl = lcl; p.state_hash = state_hash; p.patch_hash = patch_hash; - p.unl_hash = unl_hash; crypto::random_bytes(p.nonce, ROUND_NONCE_SIZE); // Populate the proposal with set of candidate user pubkeys. @@ -559,13 +546,10 @@ namespace consensus p.output_hash = ctx.user_outputs_hashtree.root_hash(); p.output_sig = ctx.user_outputs_our_sig; - // Populate the proposal with unl changeset. - p.unl_changeset = ctx.candidate_unl_changeset; - return p; } - p2p::proposal create_stage123_proposal(vote_counter &votes, std::string_view lcl, const size_t unl_count, const util::h32 state_hash, const util::h32 patch_hash, std::string_view unl_hash) + p2p::proposal create_stage123_proposal(vote_counter &votes, std::string_view lcl, const size_t unl_count, const util::h32 state_hash, const util::h32 patch_hash) { // The proposal to be emited at the end of this stage. p2p::proposal p; @@ -574,13 +558,10 @@ namespace consensus p.patch_hash = patch_hash; // We always vote for our current lcl and state regardless of what other peers are saying. - // If there's a fork condition we will either request history and state from + // If there's a fork condition we will either request history and hpfs state from // our peers or we will halt depending on level of consensus on the sides of the fork. p.lcl = lcl; - // We always vote for our current unl hash. - p.unl_hash = unl_hash; - const uint64_t time_now = util::get_epoch_milliseconds(); // Vote for rest of the proposal fields by looking at candidate proposals. @@ -605,16 +586,6 @@ namespace consensus // Vote for contract output hash. increment(votes.output_hash, cp.output_hash); - - // Vote for unl additions. Only vote for the unl additions that are in our candidate_unl_changeset. - for (const std::string &pubkey : cp.unl_changeset.additions) - if (ctx.candidate_unl_changeset.additions.count(pubkey) > 0) - increment(votes.unl_additions, pubkey); - - // Vote for unl removals. Only vote for the unl removals that are in our candidate_unl_changeset. - for (const std::string &pubkey : cp.unl_changeset.removals) - if (ctx.candidate_unl_changeset.removals.count(pubkey) > 0) - increment(votes.unl_removals, pubkey); } uint32_t required_votes = ceil(STAGE_THRESHOLDS[ctx.stage - 1] * unl_count); @@ -634,19 +605,9 @@ namespace consensus if (numvotes >= required_votes || (ctx.stage == 1 && numvotes > 0)) p.input_hashes.emplace(hash); - // For the unl changeset, reset required votes for majority votes. + // Reset required votes for majority votes. required_votes = ceil(MAJORITY_THRESHOLD * unl_count); - // Add unl additions which have votes over majority threshold to proposal. - for (const auto &[pubkey, numvotes] : votes.unl_additions) - if (numvotes >= required_votes) - p.unl_changeset.additions.emplace(pubkey); - - // Add unl removals which have votes over majority threshold to proposal. - for (const auto &[pubkey, numvotes] : votes.unl_removals) - if (numvotes >= required_votes) - p.unl_changeset.removals.emplace(pubkey); - // Add the output hash which has most votes over stage threshold to proposal. uint32_t highest_output_vote = 0; for (const auto &[hash, numvotes] : votes.output_hash) @@ -820,33 +781,6 @@ namespace consensus is_patch_desync = (hpfs::ctx.get_hash(hpfs::HPFS_PARENT_COMPONENTS::PATCH) != majority_patch_hash); } - /** - * Check unl against the winning and canonical unl - * @param is_desync Is unl is in desync. - * @param majority_unl The majority unl. - * @param votes The voting table. - * @param unl_hash Hash of the current unl list. - */ - void check_unl_votes(bool &is_desync, std::string &majority_unl, vote_counter &votes, std::string_view unl_hash) - { - for (const auto &[pubkey, cp] : ctx.candidate_proposals) - { - increment(votes.unl, cp.unl_hash); - } - - uint32_t winning_votes = 0; - for (const auto [unl, votes] : votes.unl) - { - if (votes > winning_votes) - { - winning_votes = votes; - majority_unl = unl; - } - } - - is_desync = (unl_hash != majority_unl); - } - /** * Update the ledger and execute the contract after consensus. * @param cons_prop The proposal that reached consensus. @@ -897,10 +831,6 @@ namespace consensus } } - // Update the unl with the unl changeset that subjected to the consensus. - unl::apply_changeset(cons_prop.unl_changeset.additions, cons_prop.unl_changeset.removals); - ctx.candidate_unl_changeset.clear(); - // Send any output from the previous consensus round to locally connected users. if (dispatch_user_outputs(cons_prop, new_lcl_seq_no, new_lcl) == -1) return -1; @@ -945,10 +875,6 @@ namespace consensus ctx.user_outputs_our_sig = crypto::sign(ctx.user_outputs_hashtree.root_hash(), conf::cfg.node.private_key); } - // Prepare the consensus candidate unl changeset that we have accumulated so far. (We receive them as control inputs) - // The candidate unl changeset will be included in the stage 0 proposal. - std::swap(ctx.candidate_unl_changeset, ctx.contract_ctx->args.unl_changeset); - { std::scoped_lock lock(ctx.contract_ctx_mutex); ctx.contract_ctx.reset(); diff --git a/src/consensus.hpp b/src/consensus.hpp index 6c276ad8..ec96b211 100644 --- a/src/consensus.hpp +++ b/src/consensus.hpp @@ -68,9 +68,6 @@ namespace consensus std::string user_outputs_our_sig; std::vector> user_outputs_unl_sig; - // Collected unl changset to be subjected to the consensus. This will stay here until end of the current consensus round. - p2p::contract_unl_changeset candidate_unl_changeset; - uint8_t stage = 1; uint64_t round_start_time = 0; uint16_t stage_time = 0; // Time allocated to a consensus stage. @@ -97,9 +94,6 @@ namespace consensus std::map output_hash; std::map state_hash; std::map patch_hash; - std::map unl; - std::map unl_additions; - std::map unl_removals; }; int init(); @@ -112,7 +106,7 @@ namespace consensus int consensus(); - int check_sync_status(std::string_view lcl, std::string_view unl_hash, const size_t unl_count, vote_counter &votes); + int check_sync_status(std::string_view lcl, const size_t unl_count, vote_counter &votes); void check_sync_completion(); @@ -126,9 +120,9 @@ namespace consensus int verify_and_populate_candidate_user_inputs(const uint64_t lcl_seq_no); - p2p::proposal create_stage0_proposal(std::string_view lcl, util::h32 state_hash, util::h32 patch_hash, std::string_view unl_hash); + p2p::proposal create_stage0_proposal(std::string_view lcl, util::h32 state_hash, util::h32 patch_hash); - p2p::proposal create_stage123_proposal(vote_counter &votes, std::string_view lcl, const size_t unl_count, const util::h32 state_hash, const util::h32 patch_hash, std::string_view unl_hash); + p2p::proposal create_stage123_proposal(vote_counter &votes, std::string_view lcl, const size_t unl_count, const util::h32 state_hash, const util::h32 patch_hash); void broadcast_proposal(const p2p::proposal &p); @@ -138,8 +132,6 @@ namespace consensus void check_patch_votes(bool &is_patch_desync, util::h32 &majority_patch_hash, vote_counter &votes); - void check_unl_votes(bool &is_desync, std::string &majority_unl, vote_counter &votes, std::string_view unl_hash); - void timewait_stage(const bool reset, const uint64_t time); uint64_t get_ledger_time_resolution(const uint64_t time); diff --git a/src/hpfs/hpfs_sync.cpp b/src/hpfs/hpfs_sync.cpp index c85d242d..2ef9abae 100644 --- a/src/hpfs/hpfs_sync.cpp +++ b/src/hpfs/hpfs_sync.cpp @@ -10,6 +10,7 @@ #include "../util/h32.hpp" #include "hpfs_sync.hpp" #include "../sc.hpp" +#include "../unl.hpp" namespace hpfs_sync { @@ -132,6 +133,22 @@ namespace hpfs_sync { ctx.target_patch_hash = util::h32_empty; LOG_INFO << "hpfs sync: Target patch state achieved: " << new_state; + + // Appling new patch file changes to hpcore runtime. + if (conf::validate_and_apply_patch_config(conf::cfg.contract, conf::ctx.hpfs_rw_dir) == -1) + { + LOG_ERROR << "Appling patch file changes after sync failed"; + } + else + { + unl::update_unl_changes_from_patch(); + + // Update global hash tracker with the new patch file hash. + util::h32 updated_patch_hash; + hpfs::get_hash(updated_patch_hash, conf::ctx.hpfs_rw_dir, conf::PATCH_FILE_PATH); + hpfs::ctx.set_hash(hpfs::HPFS_PARENT_COMPONENTS::PATCH, updated_patch_hash); + } + if (ctx.target_state_hash == hpfs::ctx.get_hash(hpfs::HPFS_PARENT_COMPONENTS::STATE)) break; diff --git a/src/main.cpp b/src/main.cpp index a4484b06..b06d0318 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -76,7 +76,6 @@ void deinit() hpfs_sync::deinit(); hpfs_serve::deinit(); hpfs::deinit(); - unl::deinit(); ledger::deinit(); conf::deinit(); } diff --git a/src/msg/controlmsg_common.hpp b/src/msg/controlmsg_common.hpp index 9d6785ae..ddca4d6a 100644 --- a/src/msg/controlmsg_common.hpp +++ b/src/msg/controlmsg_common.hpp @@ -12,7 +12,6 @@ namespace msg::controlmsg // Message types constexpr const char *MSGTYPE_CONTRACT_END = "contract_end"; - constexpr const char *MSGTYPE_UNL_CHANGESET = "unl_changeset"; } // namespace msg::controlmsg diff --git a/src/msg/controlmsg_parser.cpp b/src/msg/controlmsg_parser.cpp index 940fdcea..4299e6ee 100644 --- a/src/msg/controlmsg_parser.cpp +++ b/src/msg/controlmsg_parser.cpp @@ -16,9 +16,4 @@ namespace msg::controlmsg return jctlmsg::extract_type(extracted_type, jdoc); } - int controlmsg_parser::extract_unl_changeset(std::set &additions, std::set &removals) - { - return jctlmsg::extract_unl_changeset(additions, removals, jdoc); - } - } // namespace msg::controlmsg \ No newline at end of file diff --git a/src/msg/controlmsg_parser.hpp b/src/msg/controlmsg_parser.hpp index a0944b8b..170efbea 100644 --- a/src/msg/controlmsg_parser.hpp +++ b/src/msg/controlmsg_parser.hpp @@ -12,7 +12,6 @@ namespace msg::controlmsg public: int parse(std::string_view message); int extract_type(std::string &extracted_type) const; - int extract_unl_changeset(std::set &additions, std::set &removals); }; } // namespace msg::controlmsg diff --git a/src/msg/fbuf/ledger_helpers.cpp b/src/msg/fbuf/ledger_helpers.cpp index e79aa3bc..6d08401c 100644 --- a/src/msg/fbuf/ledger_helpers.cpp +++ b/src/msg/fbuf/ledger_helpers.cpp @@ -13,11 +13,6 @@ namespace msg::fbuf::ledger */ void create_ledger_block_from_proposal(flatbuffers::FlatBufferBuilder &builder, const p2p::proposal &p, const uint64_t seq_no) { - const flatbuffers::Offset unl_changeset = CreateUnl_Changeset( - builder, - stringlist_to_flatbuf_bytearrayvector(builder, p.unl_changeset.additions), - stringlist_to_flatbuf_bytearrayvector(builder, p.unl_changeset.removals)); - flatbuffers::Offset ledger = ledger::CreateLedgerBlock( builder, @@ -27,11 +22,9 @@ namespace msg::fbuf::ledger sv_to_flatbuff_bytes(builder, p.lcl), hash_to_flatbuff_bytes(builder, p.state_hash), hash_to_flatbuff_bytes(builder, p.patch_hash), - sv_to_flatbuff_bytes(builder, p.unl_hash), stringlist_to_flatbuf_bytearrayvector(builder, p.users), stringlist_to_flatbuf_bytearrayvector(builder, p.input_hashes), - sv_to_flatbuff_bytes(builder, p.output_hash), - unl_changeset); + sv_to_flatbuff_bytes(builder, p.output_hash)); builder.Finish(ledger); // Finished building message content to get serialised content. } diff --git a/src/msg/fbuf/ledger_schema.fbs b/src/msg/fbuf/ledger_schema.fbs index fdf2aa78..ede65c7c 100644 --- a/src/msg/fbuf/ledger_schema.fbs +++ b/src/msg/fbuf/ledger_schema.fbs @@ -9,16 +9,9 @@ table LedgerBlock { lcl:[ubyte]; state_hash:[ubyte]; patch_hash:[ubyte]; - unl:[ubyte]; users: [ByteArray]; inputs: [ByteArray]; output: [ubyte]; - unl_changeset: Unl_Changeset; -} - -table Unl_Changeset { - additions:[ByteArray]; - removals:[ByteArray]; } root_type LedgerBlock; \ No newline at end of file diff --git a/src/msg/fbuf/ledger_schema_generated.h b/src/msg/fbuf/ledger_schema_generated.h index 26858b08..1e9f61aa 100644 --- a/src/msg/fbuf/ledger_schema_generated.h +++ b/src/msg/fbuf/ledger_schema_generated.h @@ -15,9 +15,6 @@ namespace ledger { struct LedgerBlock; struct LedgerBlockBuilder; -struct Unl_Changeset; -struct Unl_ChangesetBuilder; - struct LedgerBlock FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef LedgerBlockBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { @@ -27,11 +24,9 @@ struct LedgerBlock FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { VT_LCL = 10, VT_STATE_HASH = 12, VT_PATCH_HASH = 14, - VT_UNL = 16, - VT_USERS = 18, - VT_INPUTS = 20, - VT_OUTPUT = 22, - VT_UNL_CHANGESET = 24 + VT_USERS = 16, + VT_INPUTS = 18, + VT_OUTPUT = 20 }; const flatbuffers::String *version() const { return GetPointer(VT_VERSION); @@ -69,12 +64,6 @@ struct LedgerBlock FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { flatbuffers::Vector *mutable_patch_hash() { return GetPointer *>(VT_PATCH_HASH); } - const flatbuffers::Vector *unl() const { - return GetPointer *>(VT_UNL); - } - flatbuffers::Vector *mutable_unl() { - return GetPointer *>(VT_UNL); - } const flatbuffers::Vector> *users() const { return GetPointer> *>(VT_USERS); } @@ -93,12 +82,6 @@ struct LedgerBlock FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { flatbuffers::Vector *mutable_output() { return GetPointer *>(VT_OUTPUT); } - const msg::fbuf::ledger::Unl_Changeset *unl_changeset() const { - return GetPointer(VT_UNL_CHANGESET); - } - msg::fbuf::ledger::Unl_Changeset *mutable_unl_changeset() { - return GetPointer(VT_UNL_CHANGESET); - } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_VERSION) && @@ -111,8 +94,6 @@ struct LedgerBlock FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { verifier.VerifyVector(state_hash()) && VerifyOffset(verifier, VT_PATCH_HASH) && verifier.VerifyVector(patch_hash()) && - VerifyOffset(verifier, VT_UNL) && - verifier.VerifyVector(unl()) && VerifyOffset(verifier, VT_USERS) && verifier.VerifyVector(users()) && verifier.VerifyVectorOfTables(users()) && @@ -121,8 +102,6 @@ struct LedgerBlock FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { verifier.VerifyVectorOfTables(inputs()) && VerifyOffset(verifier, VT_OUTPUT) && verifier.VerifyVector(output()) && - VerifyOffset(verifier, VT_UNL_CHANGESET) && - verifier.VerifyTable(unl_changeset()) && verifier.EndTable(); } }; @@ -149,9 +128,6 @@ struct LedgerBlockBuilder { void add_patch_hash(flatbuffers::Offset> patch_hash) { fbb_.AddOffset(LedgerBlock::VT_PATCH_HASH, patch_hash); } - void add_unl(flatbuffers::Offset> unl) { - fbb_.AddOffset(LedgerBlock::VT_UNL, unl); - } void add_users(flatbuffers::Offset>> users) { fbb_.AddOffset(LedgerBlock::VT_USERS, users); } @@ -161,9 +137,6 @@ struct LedgerBlockBuilder { void add_output(flatbuffers::Offset> output) { fbb_.AddOffset(LedgerBlock::VT_OUTPUT, output); } - void add_unl_changeset(flatbuffers::Offset unl_changeset) { - fbb_.AddOffset(LedgerBlock::VT_UNL_CHANGESET, unl_changeset); - } explicit LedgerBlockBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); @@ -183,19 +156,15 @@ inline flatbuffers::Offset CreateLedgerBlock( flatbuffers::Offset> lcl = 0, flatbuffers::Offset> state_hash = 0, flatbuffers::Offset> patch_hash = 0, - flatbuffers::Offset> unl = 0, flatbuffers::Offset>> users = 0, flatbuffers::Offset>> inputs = 0, - flatbuffers::Offset> output = 0, - flatbuffers::Offset unl_changeset = 0) { + flatbuffers::Offset> output = 0) { LedgerBlockBuilder builder_(_fbb); builder_.add_time(time); builder_.add_seq_no(seq_no); - builder_.add_unl_changeset(unl_changeset); builder_.add_output(output); builder_.add_inputs(inputs); builder_.add_users(users); - builder_.add_unl(unl); builder_.add_patch_hash(patch_hash); builder_.add_state_hash(state_hash); builder_.add_lcl(lcl); @@ -211,16 +180,13 @@ inline flatbuffers::Offset CreateLedgerBlockDirect( const std::vector *lcl = nullptr, const std::vector *state_hash = nullptr, const std::vector *patch_hash = nullptr, - const std::vector *unl = nullptr, const std::vector> *users = nullptr, const std::vector> *inputs = nullptr, - const std::vector *output = nullptr, - flatbuffers::Offset unl_changeset = 0) { + const std::vector *output = nullptr) { auto version__ = version ? _fbb.CreateString(version) : 0; auto lcl__ = lcl ? _fbb.CreateVector(*lcl) : 0; auto state_hash__ = state_hash ? _fbb.CreateVector(*state_hash) : 0; auto patch_hash__ = patch_hash ? _fbb.CreateVector(*patch_hash) : 0; - auto unl__ = unl ? _fbb.CreateVector(*unl) : 0; auto users__ = users ? _fbb.CreateVector>(*users) : 0; auto inputs__ = inputs ? _fbb.CreateVector>(*inputs) : 0; auto output__ = output ? _fbb.CreateVector(*output) : 0; @@ -232,84 +198,9 @@ inline flatbuffers::Offset CreateLedgerBlockDirect( lcl__, state_hash__, patch_hash__, - unl__, users__, inputs__, - output__, - unl_changeset); -} - -struct Unl_Changeset FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Unl_ChangesetBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ADDITIONS = 4, - VT_REMOVALS = 6 - }; - const flatbuffers::Vector> *additions() const { - return GetPointer> *>(VT_ADDITIONS); - } - flatbuffers::Vector> *mutable_additions() { - return GetPointer> *>(VT_ADDITIONS); - } - const flatbuffers::Vector> *removals() const { - return GetPointer> *>(VT_REMOVALS); - } - flatbuffers::Vector> *mutable_removals() { - return GetPointer> *>(VT_REMOVALS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_ADDITIONS) && - verifier.VerifyVector(additions()) && - verifier.VerifyVectorOfTables(additions()) && - VerifyOffset(verifier, VT_REMOVALS) && - verifier.VerifyVector(removals()) && - verifier.VerifyVectorOfTables(removals()) && - verifier.EndTable(); - } -}; - -struct Unl_ChangesetBuilder { - typedef Unl_Changeset Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_additions(flatbuffers::Offset>> additions) { - fbb_.AddOffset(Unl_Changeset::VT_ADDITIONS, additions); - } - void add_removals(flatbuffers::Offset>> removals) { - fbb_.AddOffset(Unl_Changeset::VT_REMOVALS, removals); - } - explicit Unl_ChangesetBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateUnl_Changeset( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset>> additions = 0, - flatbuffers::Offset>> removals = 0) { - Unl_ChangesetBuilder builder_(_fbb); - builder_.add_removals(removals); - builder_.add_additions(additions); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateUnl_ChangesetDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector> *additions = nullptr, - const std::vector> *removals = nullptr) { - auto additions__ = additions ? _fbb.CreateVector>(*additions) : 0; - auto removals__ = removals ? _fbb.CreateVector>(*removals) : 0; - return msg::fbuf::ledger::CreateUnl_Changeset( - _fbb, - additions__, - removals__); + output__); } inline const msg::fbuf::ledger::LedgerBlock *GetLedgerBlock(const void *buf) { diff --git a/src/msg/fbuf/p2pmsg_content.fbs b/src/msg/fbuf/p2pmsg_content.fbs index 7bc266e8..b352c866 100644 --- a/src/msg/fbuf/p2pmsg_content.fbs +++ b/src/msg/fbuf/p2pmsg_content.fbs @@ -38,9 +38,7 @@ union Message { Peer_Requirement_Announcement_Message, Peer_List_Request_Message, Peer_List_Response_Message, - Available_Capacity_Announcement_Message, - Unl_Request_Message, - Unl_Response_Message + Available_Capacity_Announcement_Message } //message content type table Content { @@ -51,11 +49,6 @@ table NonUnl_Proposal_Message { user_inputs:[UserInputGroup]; } -table Unl_Changeset { - additions:[ByteArray]; - removals:[ByteArray]; -} - table Proposal_Message { //Proposal type message schema stage:uint8; time:uint64; @@ -66,8 +59,6 @@ table Proposal_Message { //Proposal type message schema output_sig:[ubyte]; state_hash: [ubyte]; patch_hash: [ubyte]; - unl_hash: [ubyte]; // Hash of the current unl list. - unl_changeset: Unl_Changeset; } table Npl_Message { //NPL type message schema @@ -78,15 +69,6 @@ table History_Request_Message { //Ledger History request type message schema required_lcl:[ubyte]; } -table Unl_Request_Message { - required_unl: [ubyte]; -} - -table Unl_Response_Message { - requester_unl:[ubyte]; // Unl hash of the sender. - unl_list: [ByteArray]; -} - enum Ledger_Response_Error : ubyte { None = 0, diff --git a/src/msg/fbuf/p2pmsg_content_generated.h b/src/msg/fbuf/p2pmsg_content_generated.h index 0ae3df55..8724b9e8 100644 --- a/src/msg/fbuf/p2pmsg_content_generated.h +++ b/src/msg/fbuf/p2pmsg_content_generated.h @@ -30,9 +30,6 @@ struct ContentBuilder; struct NonUnl_Proposal_Message; struct NonUnl_Proposal_MessageBuilder; -struct Unl_Changeset; -struct Unl_ChangesetBuilder; - struct Proposal_Message; struct Proposal_MessageBuilder; @@ -42,12 +39,6 @@ struct Npl_MessageBuilder; struct History_Request_Message; struct History_Request_MessageBuilder; -struct Unl_Request_Message; -struct Unl_Request_MessageBuilder; - -struct Unl_Response_Message; -struct Unl_Response_MessageBuilder; - struct History_Response_Message; struct History_Response_MessageBuilder; @@ -105,13 +96,11 @@ enum Message : uint8_t { Message_Peer_List_Request_Message = 11, Message_Peer_List_Response_Message = 12, Message_Available_Capacity_Announcement_Message = 13, - Message_Unl_Request_Message = 14, - Message_Unl_Response_Message = 15, Message_MIN = Message_NONE, - Message_MAX = Message_Unl_Response_Message + Message_MAX = Message_Available_Capacity_Announcement_Message }; -inline const Message (&EnumValuesMessage())[16] { +inline const Message (&EnumValuesMessage())[14] { static const Message values[] = { Message_NONE, Message_Peer_Challenge_Response_Message, @@ -126,15 +115,13 @@ inline const Message (&EnumValuesMessage())[16] { Message_Peer_Requirement_Announcement_Message, Message_Peer_List_Request_Message, Message_Peer_List_Response_Message, - Message_Available_Capacity_Announcement_Message, - Message_Unl_Request_Message, - Message_Unl_Response_Message + Message_Available_Capacity_Announcement_Message }; return values; } inline const char * const *EnumNamesMessage() { - static const char * const names[17] = { + static const char * const names[15] = { "NONE", "Peer_Challenge_Response_Message", "Peer_Challenge_Message", @@ -149,15 +136,13 @@ inline const char * const *EnumNamesMessage() { "Peer_List_Request_Message", "Peer_List_Response_Message", "Available_Capacity_Announcement_Message", - "Unl_Request_Message", - "Unl_Response_Message", nullptr }; return names; } inline const char *EnumNameMessage(Message e) { - if (flatbuffers::IsOutRange(e, Message_NONE, Message_Unl_Response_Message)) return ""; + if (flatbuffers::IsOutRange(e, Message_NONE, Message_Available_Capacity_Announcement_Message)) return ""; const size_t index = static_cast(e); return EnumNamesMessage()[index]; } @@ -218,14 +203,6 @@ template<> struct MessageTraits struct MessageTraits { - static const Message enum_value = Message_Unl_Request_Message; -}; - -template<> struct MessageTraits { - static const Message enum_value = Message_Unl_Response_Message; -}; - bool VerifyMessage(flatbuffers::Verifier &verifier, const void *obj, Message type); bool VerifyMessageVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); @@ -669,12 +646,6 @@ struct Content FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { const msg::fbuf::p2pmsg::Available_Capacity_Announcement_Message *message_as_Available_Capacity_Announcement_Message() const { return message_type() == msg::fbuf::p2pmsg::Message_Available_Capacity_Announcement_Message ? static_cast(message()) : nullptr; } - const msg::fbuf::p2pmsg::Unl_Request_Message *message_as_Unl_Request_Message() const { - return message_type() == msg::fbuf::p2pmsg::Message_Unl_Request_Message ? static_cast(message()) : nullptr; - } - const msg::fbuf::p2pmsg::Unl_Response_Message *message_as_Unl_Response_Message() const { - return message_type() == msg::fbuf::p2pmsg::Message_Unl_Response_Message ? static_cast(message()) : nullptr; - } void *mutable_message() { return GetPointer(VT_MESSAGE); } @@ -739,14 +710,6 @@ template<> inline const msg::fbuf::p2pmsg::Available_Capacity_Announcement_Messa return message_as_Available_Capacity_Announcement_Message(); } -template<> inline const msg::fbuf::p2pmsg::Unl_Request_Message *Content::message_as() const { - return message_as_Unl_Request_Message(); -} - -template<> inline const msg::fbuf::p2pmsg::Unl_Response_Message *Content::message_as() const { - return message_as_Unl_Response_Message(); -} - struct ContentBuilder { typedef Content Table; flatbuffers::FlatBufferBuilder &fbb_; @@ -833,79 +796,6 @@ inline flatbuffers::Offset CreateNonUnl_Proposal_Messag user_inputs__); } -struct Unl_Changeset FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Unl_ChangesetBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_ADDITIONS = 4, - VT_REMOVALS = 6 - }; - const flatbuffers::Vector> *additions() const { - return GetPointer> *>(VT_ADDITIONS); - } - flatbuffers::Vector> *mutable_additions() { - return GetPointer> *>(VT_ADDITIONS); - } - const flatbuffers::Vector> *removals() const { - return GetPointer> *>(VT_REMOVALS); - } - flatbuffers::Vector> *mutable_removals() { - return GetPointer> *>(VT_REMOVALS); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_ADDITIONS) && - verifier.VerifyVector(additions()) && - verifier.VerifyVectorOfTables(additions()) && - VerifyOffset(verifier, VT_REMOVALS) && - verifier.VerifyVector(removals()) && - verifier.VerifyVectorOfTables(removals()) && - verifier.EndTable(); - } -}; - -struct Unl_ChangesetBuilder { - typedef Unl_Changeset Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_additions(flatbuffers::Offset>> additions) { - fbb_.AddOffset(Unl_Changeset::VT_ADDITIONS, additions); - } - void add_removals(flatbuffers::Offset>> removals) { - fbb_.AddOffset(Unl_Changeset::VT_REMOVALS, removals); - } - explicit Unl_ChangesetBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateUnl_Changeset( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset>> additions = 0, - flatbuffers::Offset>> removals = 0) { - Unl_ChangesetBuilder builder_(_fbb); - builder_.add_removals(removals); - builder_.add_additions(additions); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateUnl_ChangesetDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector> *additions = nullptr, - const std::vector> *removals = nullptr) { - auto additions__ = additions ? _fbb.CreateVector>(*additions) : 0; - auto removals__ = removals ? _fbb.CreateVector>(*removals) : 0; - return msg::fbuf::p2pmsg::CreateUnl_Changeset( - _fbb, - additions__, - removals__); -} - struct Proposal_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef Proposal_MessageBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { @@ -917,9 +807,7 @@ struct Proposal_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { VT_OUTPUT_HASH = 14, VT_OUTPUT_SIG = 16, VT_STATE_HASH = 18, - VT_PATCH_HASH = 20, - VT_UNL_HASH = 22, - VT_UNL_CHANGESET = 24 + VT_PATCH_HASH = 20 }; uint8_t stage() const { return GetField(VT_STAGE, 0); @@ -975,18 +863,6 @@ struct Proposal_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { flatbuffers::Vector *mutable_patch_hash() { return GetPointer *>(VT_PATCH_HASH); } - const flatbuffers::Vector *unl_hash() const { - return GetPointer *>(VT_UNL_HASH); - } - flatbuffers::Vector *mutable_unl_hash() { - return GetPointer *>(VT_UNL_HASH); - } - const msg::fbuf::p2pmsg::Unl_Changeset *unl_changeset() const { - return GetPointer(VT_UNL_CHANGESET); - } - msg::fbuf::p2pmsg::Unl_Changeset *mutable_unl_changeset() { - return GetPointer(VT_UNL_CHANGESET); - } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField(verifier, VT_STAGE) && @@ -1007,10 +883,6 @@ struct Proposal_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { verifier.VerifyVector(state_hash()) && VerifyOffset(verifier, VT_PATCH_HASH) && verifier.VerifyVector(patch_hash()) && - VerifyOffset(verifier, VT_UNL_HASH) && - verifier.VerifyVector(unl_hash()) && - VerifyOffset(verifier, VT_UNL_CHANGESET) && - verifier.VerifyTable(unl_changeset()) && verifier.EndTable(); } }; @@ -1046,12 +918,6 @@ struct Proposal_MessageBuilder { void add_patch_hash(flatbuffers::Offset> patch_hash) { fbb_.AddOffset(Proposal_Message::VT_PATCH_HASH, patch_hash); } - void add_unl_hash(flatbuffers::Offset> unl_hash) { - fbb_.AddOffset(Proposal_Message::VT_UNL_HASH, unl_hash); - } - void add_unl_changeset(flatbuffers::Offset unl_changeset) { - fbb_.AddOffset(Proposal_Message::VT_UNL_CHANGESET, unl_changeset); - } explicit Proposal_MessageBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); @@ -1073,13 +939,9 @@ inline flatbuffers::Offset CreateProposal_Message( flatbuffers::Offset> output_hash = 0, flatbuffers::Offset> output_sig = 0, flatbuffers::Offset> state_hash = 0, - flatbuffers::Offset> patch_hash = 0, - flatbuffers::Offset> unl_hash = 0, - flatbuffers::Offset unl_changeset = 0) { + flatbuffers::Offset> patch_hash = 0) { Proposal_MessageBuilder builder_(_fbb); builder_.add_time(time); - builder_.add_unl_changeset(unl_changeset); - builder_.add_unl_hash(unl_hash); builder_.add_patch_hash(patch_hash); builder_.add_state_hash(state_hash); builder_.add_output_sig(output_sig); @@ -1101,9 +963,7 @@ inline flatbuffers::Offset CreateProposal_MessageDirect( const std::vector *output_hash = nullptr, const std::vector *output_sig = nullptr, const std::vector *state_hash = nullptr, - const std::vector *patch_hash = nullptr, - const std::vector *unl_hash = nullptr, - flatbuffers::Offset unl_changeset = 0) { + const std::vector *patch_hash = nullptr) { auto nonce__ = nonce ? _fbb.CreateVector(*nonce) : 0; auto users__ = users ? _fbb.CreateVector>(*users) : 0; auto input_hashes__ = input_hashes ? _fbb.CreateVector>(*input_hashes) : 0; @@ -1111,7 +971,6 @@ inline flatbuffers::Offset CreateProposal_MessageDirect( auto output_sig__ = output_sig ? _fbb.CreateVector(*output_sig) : 0; auto state_hash__ = state_hash ? _fbb.CreateVector(*state_hash) : 0; auto patch_hash__ = patch_hash ? _fbb.CreateVector(*patch_hash) : 0; - auto unl_hash__ = unl_hash ? _fbb.CreateVector(*unl_hash) : 0; return msg::fbuf::p2pmsg::CreateProposal_Message( _fbb, stage, @@ -1122,9 +981,7 @@ inline flatbuffers::Offset CreateProposal_MessageDirect( output_hash__, output_sig__, state_hash__, - patch_hash__, - unl_hash__, - unl_changeset); + patch_hash__); } struct Npl_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { @@ -1235,132 +1092,6 @@ inline flatbuffers::Offset CreateHistory_Request_Messag required_lcl__); } -struct Unl_Request_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Unl_Request_MessageBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_REQUIRED_UNL = 4 - }; - const flatbuffers::Vector *required_unl() const { - return GetPointer *>(VT_REQUIRED_UNL); - } - flatbuffers::Vector *mutable_required_unl() { - return GetPointer *>(VT_REQUIRED_UNL); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_REQUIRED_UNL) && - verifier.VerifyVector(required_unl()) && - verifier.EndTable(); - } -}; - -struct Unl_Request_MessageBuilder { - typedef Unl_Request_Message Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_required_unl(flatbuffers::Offset> required_unl) { - fbb_.AddOffset(Unl_Request_Message::VT_REQUIRED_UNL, required_unl); - } - explicit Unl_Request_MessageBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateUnl_Request_Message( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset> required_unl = 0) { - Unl_Request_MessageBuilder builder_(_fbb); - builder_.add_required_unl(required_unl); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateUnl_Request_MessageDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector *required_unl = nullptr) { - auto required_unl__ = required_unl ? _fbb.CreateVector(*required_unl) : 0; - return msg::fbuf::p2pmsg::CreateUnl_Request_Message( - _fbb, - required_unl__); -} - -struct Unl_Response_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Unl_Response_MessageBuilder Builder; - enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_REQUESTER_UNL = 4, - VT_UNL_LIST = 6 - }; - const flatbuffers::Vector *requester_unl() const { - return GetPointer *>(VT_REQUESTER_UNL); - } - flatbuffers::Vector *mutable_requester_unl() { - return GetPointer *>(VT_REQUESTER_UNL); - } - const flatbuffers::Vector> *unl_list() const { - return GetPointer> *>(VT_UNL_LIST); - } - flatbuffers::Vector> *mutable_unl_list() { - return GetPointer> *>(VT_UNL_LIST); - } - bool Verify(flatbuffers::Verifier &verifier) const { - return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_REQUESTER_UNL) && - verifier.VerifyVector(requester_unl()) && - VerifyOffset(verifier, VT_UNL_LIST) && - verifier.VerifyVector(unl_list()) && - verifier.VerifyVectorOfTables(unl_list()) && - verifier.EndTable(); - } -}; - -struct Unl_Response_MessageBuilder { - typedef Unl_Response_Message Table; - flatbuffers::FlatBufferBuilder &fbb_; - flatbuffers::uoffset_t start_; - void add_requester_unl(flatbuffers::Offset> requester_unl) { - fbb_.AddOffset(Unl_Response_Message::VT_REQUESTER_UNL, requester_unl); - } - void add_unl_list(flatbuffers::Offset>> unl_list) { - fbb_.AddOffset(Unl_Response_Message::VT_UNL_LIST, unl_list); - } - explicit Unl_Response_MessageBuilder(flatbuffers::FlatBufferBuilder &_fbb) - : fbb_(_fbb) { - start_ = fbb_.StartTable(); - } - flatbuffers::Offset Finish() { - const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); - return o; - } -}; - -inline flatbuffers::Offset CreateUnl_Response_Message( - flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset> requester_unl = 0, - flatbuffers::Offset>> unl_list = 0) { - Unl_Response_MessageBuilder builder_(_fbb); - builder_.add_unl_list(unl_list); - builder_.add_requester_unl(requester_unl); - return builder_.Finish(); -} - -inline flatbuffers::Offset CreateUnl_Response_MessageDirect( - flatbuffers::FlatBufferBuilder &_fbb, - const std::vector *requester_unl = nullptr, - const std::vector> *unl_list = nullptr) { - auto requester_unl__ = requester_unl ? _fbb.CreateVector(*requester_unl) : 0; - auto unl_list__ = unl_list ? _fbb.CreateVector>(*unl_list) : 0; - return msg::fbuf::p2pmsg::CreateUnl_Response_Message( - _fbb, - requester_unl__, - unl_list__); -} - struct History_Response_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef History_Response_MessageBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { @@ -2419,14 +2150,6 @@ inline bool VerifyMessage(flatbuffers::Verifier &verifier, const void *obj, Mess auto ptr = reinterpret_cast(obj); return verifier.VerifyTable(ptr); } - case Message_Unl_Request_Message: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } - case Message_Unl_Response_Message: { - auto ptr = reinterpret_cast(obj); - return verifier.VerifyTable(ptr); - } default: return true; } } diff --git a/src/msg/fbuf/p2pmsg_helpers.cpp b/src/msg/fbuf/p2pmsg_helpers.cpp index ece6c524..e5c383cb 100644 --- a/src/msg/fbuf/p2pmsg_helpers.cpp +++ b/src/msg/fbuf/p2pmsg_helpers.cpp @@ -231,14 +231,9 @@ namespace msg::fbuf::p2pmsg p.nonce = flatbuff_bytes_to_sv(msg.nonce()); p.stage = msg.stage(); p.lcl = flatbuff_bytes_to_sv(lcl); - p.unl_hash = flatbuff_bytes_to_sv(msg.unl_hash()); p.state_hash = flatbuff_bytes_to_sv(msg.state_hash()); p.patch_hash = flatbuff_bytes_to_sv(msg.patch_hash()); - const auto unl_changeset = msg.unl_changeset(); - p.unl_changeset.additions = flatbuf_bytearrayvector_to_stringlist(unl_changeset->additions()); - p.unl_changeset.removals = flatbuf_bytearrayvector_to_stringlist(unl_changeset->removals()); - if (msg.users()) p.users = flatbuf_bytearrayvector_to_stringlist(msg.users()); @@ -378,11 +373,6 @@ namespace msg::fbuf::p2pmsg // todo:get a average propsal message size and allocate content builder based on that. flatbuffers::FlatBufferBuilder builder(1024); - const flatbuffers::Offset unl_changeset = CreateUnl_Changeset( - builder, - stringlist_to_flatbuf_bytearrayvector(builder, p.unl_changeset.additions), - stringlist_to_flatbuf_bytearrayvector(builder, p.unl_changeset.removals)); - const flatbuffers::Offset proposal = CreateProposal_Message( builder, @@ -394,9 +384,7 @@ namespace msg::fbuf::p2pmsg sv_to_flatbuff_bytes(builder, p.output_hash), sv_to_flatbuff_bytes(builder, p.output_sig), hash_to_flatbuff_bytes(builder, p.state_hash), - hash_to_flatbuff_bytes(builder, p.patch_hash), - sv_to_flatbuff_bytes(builder, p.unl_hash), - unl_changeset); + hash_to_flatbuff_bytes(builder, p.patch_hash)); const flatbuffers::Offset message = CreateContent(builder, Message_Proposal_Message, proposal.Union()); builder.Finish(message); // Finished building message content to get serialised content. @@ -691,79 +679,6 @@ namespace msg::fbuf::p2pmsg create_containermsg_from_content(container_builder, builder, lcl, false); } - /** - * Create unl request message from the given unl sync request struct. - * @param container_builder Flatbuffer builder for the container message. - * @param unl_sync_message The Unl sync request struct to be placed in the container message. - */ - void create_msg_from_unl_sync_request(flatbuffers::FlatBufferBuilder &container_builder, const p2p::unl_sync_request &unl_sync_message) - { - flatbuffers::FlatBufferBuilder builder(1024); - - flatbuffers::Offset unl_req_msg = - CreateUnl_Request_Message( - builder, - sv_to_flatbuff_bytes(builder, unl_sync_message.required_unl)); - - flatbuffers::Offset message = CreateContent(builder, Message_Unl_Request_Message, unl_req_msg.Union()); - builder.Finish(message); // Finished building message content to get serialised content. - - // Now that we have built the content message, - // we need to place it inside a container message. - create_containermsg_from_content(container_builder, builder, {}, false); - } - - /** - * Creates a unl sync request struct from the given unl request message. - * @param unl_req_message Flatbuffer unl request message received from the peer. - * @return A unl sync request struct representing the message. - */ - const p2p::unl_sync_request create_unl_sync_request_from_msg(const Unl_Request_Message &unl_req_message) - { - p2p::unl_sync_request unl_sync; - unl_sync.required_unl = flatbuff_bytes_to_sv(unl_req_message.required_unl()); - - return unl_sync; - } - - /** - * Create unl response message from the given unl sync response struct. - * @param container_builder Flatbuffer builder for the container message. - * @param unl_response The unl sync response struct to be placed in the container message. - */ - void create_msg_from_unl_sync_response(flatbuffers::FlatBufferBuilder &container_builder, const p2p::unl_sync_response &unl_response) - { - flatbuffers::FlatBufferBuilder builder(1024); - - flatbuffers::Offset unl_res_msg = - CreateUnl_Response_Message( - builder, - sv_to_flatbuff_bytes(builder, unl_response.requester_unl), - stringlist_to_flatbuf_bytearrayvector(builder, unl_response.unl_list)); - - flatbuffers::Offset message = CreateContent(builder, Message_Unl_Response_Message, unl_res_msg.Union()); - builder.Finish(message); // Finished building message content to get serialised content. - - // Now that we have built the content message, - // we need to place it inside a container message. - create_containermsg_from_content(container_builder, builder, {}, false); - } - - /** - * Creates a unl sync response struct from the given unl response message. - * @param unl_response_message Flatbuffer unl response message received from the peer. - * @return A unl sync response struct representing the message. - */ - const p2p::unl_sync_response create_unl_sync_response_from_msg(const Unl_Response_Message &unl_response_message) - { - p2p::unl_sync_response unl_sync_response; - - unl_sync_response.requester_unl = flatbuff_bytes_to_sv(unl_response_message.requester_unl()); - unl_sync_response.unl_list = flatbuf_bytearrayvector_to_stringlist(unl_response_message.unl_list()); - - return unl_sync_response; - } - /** * Creates a Flatbuffer container message from the given Content message. * @param container_builder The Flatbuffer builder to which the final container message should be written to. diff --git a/src/msg/fbuf/p2pmsg_helpers.hpp b/src/msg/fbuf/p2pmsg_helpers.hpp index b1d04780..4e3d178c 100644 --- a/src/msg/fbuf/p2pmsg_helpers.hpp +++ b/src/msg/fbuf/p2pmsg_helpers.hpp @@ -37,10 +37,6 @@ namespace msg::fbuf::p2pmsg const p2p::history_response create_history_response_from_msg(const History_Response_Message &msg); const p2p::hpfs_request create_hpfs_request_from_msg(const Hpfs_Request_Message &msg); - - const p2p::unl_sync_request create_unl_sync_request_from_msg(const Unl_Request_Message &unl_req_message); - - const p2p::unl_sync_response create_unl_sync_response_from_msg(const Unl_Response_Message &unl_response_message); const std::vector create_peer_list_response_from_msg(const Peer_List_Response_Message &msg); @@ -61,10 +57,6 @@ namespace msg::fbuf::p2pmsg void create_msg_from_state_request(flatbuffers::FlatBufferBuilder &container_builder, const p2p::hpfs_request &hr, std::string_view lcl); - void create_msg_from_unl_sync_request(flatbuffers::FlatBufferBuilder &container_builder, const p2p::unl_sync_request &unl_sync_message); - - void create_msg_from_unl_sync_response(flatbuffers::FlatBufferBuilder &container_builder, const p2p::unl_sync_response &unl_response); - void create_msg_from_fsentry_response( flatbuffers::FlatBufferBuilder &container_builder, const std::string_view path, std::vector &hash_nodes, util::h32 expected_hash, std::string_view lcl); diff --git a/src/msg/json/controlmsg_json.cpp b/src/msg/json/controlmsg_json.cpp index d3ae835e..7b024a54 100644 --- a/src/msg/json/controlmsg_json.cpp +++ b/src/msg/json/controlmsg_json.cpp @@ -57,33 +57,4 @@ namespace msg::controlmsg::json return 0; } - /** - * Extracts unl additions and removals from the json document. - * Format: - * { - * "type": "unl_changeset", - * "add": ["pk1","pk2",...] - * "remove": ["pk1","pk2",...] - * } - */ - int extract_unl_changeset(std::set &additions, std::set &removals, const jsoncons::json &d) - { - extract_string_set(additions, d, FLD_ADD); - extract_string_set(removals, d, FLD_REMOVE); - return 0; - } - - void extract_string_set(std::set &vec, const jsoncons::json &d, const char *field_name) - { - if (!d.contains(field_name) || !d[field_name].is_array()) - return; - - for (const auto &pkhex : d[field_name].array_range()) - { - const std::string bin_pubkey = util::to_bin(pkhex.as()); - if (!bin_pubkey.empty()) - vec.emplace(bin_pubkey); - } - } - } // namespace msg::controlmsg::json \ No newline at end of file diff --git a/src/msg/json/controlmsg_json.hpp b/src/msg/json/controlmsg_json.hpp index 6b0b57f8..c839ed4b 100644 --- a/src/msg/json/controlmsg_json.hpp +++ b/src/msg/json/controlmsg_json.hpp @@ -12,9 +12,6 @@ namespace msg::controlmsg::json int extract_type(std::string &extracted_type, const jsoncons::json &d); - int extract_unl_changeset(std::set &additions, std::set &removals, const jsoncons::json &d); - - void extract_string_set(std::set &vec, const jsoncons::json &d, const char *field_name); } // namespace msg::controlmsg::json diff --git a/src/p2p/p2p.hpp b/src/p2p/p2p.hpp index 2599eda2..60523b33 100644 --- a/src/p2p/p2p.hpp +++ b/src/p2p/p2p.hpp @@ -18,30 +18,6 @@ namespace p2p constexpr uint16_t STATE_RES_LIST_CAP = 64; // Maximum state response count. constexpr uint16_t PEER_LIST_CAP = 64; // Maximum peer count. - struct contract_unl_changeset - { - std::set additions; // Pubkeys of the peers that need to be added to the unl. - std::set removals; // Pubkeys of the peers that need to be removed from the unl. - - void clear() - { - additions.clear(); - removals.clear(); - } - - // If there are items which are in both additions and removals. Remove them from the both sets. - void purify() - { - std::set intersect; - std::set_intersection(additions.begin(), additions.end(), removals.begin(), removals.end(), std::inserter(intersect, intersect.begin())); - for (const auto &item : intersect) - { - additions.erase(item); - removals.erase(item); - } - } - }; - struct proposal { std::string pubkey; @@ -52,14 +28,12 @@ namespace p2p uint8_t stage = 0; std::string nonce; // Random nonce that is used to reduce lcl predictability. std::string lcl; - std::string unl_hash; // Hash of the current unl list. util::h32 state_hash; // Contract state hash. util::h32 patch_hash; // Patch file hash. std::set users; std::set input_hashes; std::string output_hash; std::string output_sig; - contract_unl_changeset unl_changeset; // Additions and removals of the unl. }; struct nonunl_proposal @@ -73,17 +47,6 @@ namespace p2p std::string required_lcl; }; - struct unl_sync_request - { - std::string required_unl; - }; - - struct unl_sync_response - { - std::string requester_unl; // Unl hash of the sender. - std::set unl_list; - }; - struct history_ledger_block { std::string lcl; diff --git a/src/p2p/peer_session_handler.cpp b/src/p2p/peer_session_handler.cpp index db022d3e..6618d4a4 100644 --- a/src/p2p/peer_session_handler.cpp +++ b/src/p2p/peer_session_handler.cpp @@ -257,41 +257,6 @@ namespace p2p } } } - else if (content_message_type == p2pmsg::Message_Unl_Request_Message) //message is a unl request message. - { - // Check the cap and insert request with lock. - std::scoped_lock lock(unl::sync_ctx.list_mutex); - - // If max number of unl requests reached skip the rest. - if (unl::sync_ctx.collected_unl_sync_requests.size() < unl::UNL_REQ_LIST_CAP) - { - const p2p::unl_sync_request unl_request = p2pmsg::create_unl_sync_request_from_msg(*content->message_as_Unl_Request_Message()); - unl::sync_ctx.collected_unl_sync_requests.push_back(std::make_pair(session.pubkey, std::move(unl_request))); - } - else - { - LOG_DEBUG << "Unl request rejected. Maximum unl request count reached. " << session.display_name(); - } - } - else if (content_message_type == p2pmsg::Message_Unl_Response_Message) //message is a unl response message. - { - if (unl::sync_ctx.is_syncing) // Only accept unl responses if unl list is syncing. - { - // Check the cap and insert response with lock. - std::scoped_lock lock(unl::sync_ctx.list_mutex); - - // If max number of unl responses reached skip the rest. - if (unl::sync_ctx.collected_unl_sync_responses.size() < unl::UNL_RES_LIST_CAP) - { - const p2p::unl_sync_response unl_response = p2pmsg::create_unl_sync_response_from_msg(*content->message_as_Unl_Response_Message()); - unl::sync_ctx.collected_unl_sync_responses.push_back(std::move(unl_response)); - } - else - { - LOG_DEBUG << "Unl response rejected. Maximum unl response count reached. " << session.display_name(); - } - } - } else { session.increment_metric(comm::SESSION_THRESHOLDS::MAX_BADMSGS_PER_MINUTE, 1); diff --git a/src/sc.cpp b/src/sc.cpp index a4d8a545..06bb4f77 100644 --- a/src/sc.cpp +++ b/src/sc.cpp @@ -103,6 +103,28 @@ namespace sc } cleanup_fds(ctx); + + util::h32 patch_hash; + if (hpfs::get_hash(patch_hash, ctx.args.hpfs_dir, conf::PATCH_FILE_PATH) == 1) + { + if (patch_hash != hpfs::ctx.get_hash(hpfs::HPFS_PARENT_COMPONENTS::PATCH)) + { + + // Appling new patch file changes to hpcore runtime. + if (conf::validate_and_apply_patch_config(conf::cfg.contract, ctx.args.hpfs_dir) == -1) + { + LOG_ERROR << "Appling patch file after contract execution failed"; + } + else + { + // Update global hash tracker with the new patch file hash. + hpfs::ctx.set_hash(hpfs::HPFS_PARENT_COMPONENTS::PATCH, patch_hash); + + unl::update_unl_changes_from_patch(); + } + } + } + if (stop_hpfs_session(ctx) == -1) ret = -1; @@ -773,13 +795,6 @@ namespace sc { ctx.termination_signaled = true; } - else if (type == msg::controlmsg::MSGTYPE_UNL_CHANGESET && !ctx.args.readonly) - { - // Populate the received change set. Changeset will be affected after going through the consensus. - // Since changesets are std::set objects. It'll maintain a sorted set. - parser.extract_unl_changeset(ctx.args.unl_changeset.additions, ctx.args.unl_changeset.removals); - ctx.args.unl_changeset.purify(); - } } } // namespace sc diff --git a/src/sc.hpp b/src/sc.hpp index af5b682a..8cc2bf60 100644 --- a/src/sc.hpp +++ b/src/sc.hpp @@ -84,9 +84,6 @@ namespace sc // State hash after execution will be copied to this (not applicable to read only mode). util::h32 post_execution_state_hash = util::h32_empty; - // Collected unl addition and removal change sets. Holds the changeset until they are subjected to the consensus. - p2p::contract_unl_changeset unl_changeset; - contract_execution_args(util::buffer_store &user_input_store) : user_input_store(user_input_store), npl_messages(MAX_NPL_MSG_QUEUE_SIZE), diff --git a/src/unl.cpp b/src/unl.cpp index 0b2a1987..09f7c8e6 100644 --- a/src/unl.cpp +++ b/src/unl.cpp @@ -3,8 +3,6 @@ #include "conf.hpp" #include "unl.hpp" #include "crypto.hpp" -#include "p2p/p2p.hpp" -#include "./msg/fbuf/p2pmsg_helpers.hpp" /** * Manages the UNL public keys of this node. @@ -15,15 +13,6 @@ namespace unl std::string json_list; // Stringified json array of UNL. (To be fed into the contract args) std::shared_mutex unl_mutex; std::string hash; - sync_context sync_ctx; - bool init_success = false; - constexpr uint16_t SYNCER_IDLE_WAIT = 20; // unl syncer loop sleep time (milliseconds). - - // Max no. of repetitive reqeust resubmissions before abandoning the sync. - constexpr uint16_t ABANDON_THRESHOLD = 10; - - // No. of milliseconds to wait before resubmitting a request. - uint16_t REQUEST_RESUBMIT_TIMEOUT; /** * Performs startup activitites related to unl list. @@ -40,21 +29,9 @@ namespace unl conf::cfg.node.is_unl = (list.find(conf::cfg.node.public_key) != list.end()); update_json_list(); hash = calculate_hash(list); - sync_ctx.unl_sync_thread = std::thread(unl_syncer_loop); - REQUEST_RESUBMIT_TIMEOUT = conf::cfg.contract.roundtime; - init_success = true; return 0; } - void deinit() - { - if (init_success) - { - sync_ctx.is_shutting_down = true; - sync_ctx.unl_sync_thread.join(); - } - } - size_t count() { std::shared_lock lock(unl_mutex); @@ -84,75 +61,6 @@ namespace unl return list.find(bin_pubkey) != list.end(); } - /** - * Called by consensus to apply unl changesets that reached consensus. - */ - void apply_changeset(const std::set &additions, const std::set &removals) - { - if (additions.empty() && removals.empty()) - return; - - bool is_updated = false; - { - std::unique_lock lock(unl_mutex); - for (const std::string &pubkey : additions) - { - const auto [ele, is_success] = list.emplace(pubkey); - if (is_success) - is_updated = true; - } - - for (const std::string &pubkey : removals) - { - if (list.erase(pubkey)) - is_updated = true; - } - - if (is_updated) - { - update_json_list(); - conf::persist_unl_update(list); - hash = calculate_hash(list); - LOG_INFO << "UNL updated. Count:" << list.size(); - // Update the own node's unl status. - conf::cfg.node.is_unl = (list.find(conf::cfg.node.public_key) != list.end()); - } - } - - // Update the is_unl flag of peer sessions. - if (is_updated) - p2p::update_unl_connections(); - } - - /** - * Replace the unl list from the received new unl list after verifying it. - * @param new_list The received unl list from a random peer. - * @return Returns -1 on verification failure and 0 on successful replacement. - */ - int verify_and_replace(const std::set &new_list) - { - const std::string new_unl_hash = calculate_hash(new_list); - if (new_unl_hash != sync_ctx.target_unl) - { - LOG_INFO << "Hash verification on received unl list failed."; - return -1; - } - - { - std::unique_lock lock(unl_mutex); - list = new_list; - update_json_list(); - conf::persist_unl_update(list); - hash = new_unl_hash; - // Update the own node's unl status. - conf::cfg.node.is_unl = (list.find(conf::cfg.node.public_key) != list.end()); - } - - // Update the is_unl flag of peer sessions. - p2p::update_unl_connections(); - return 0; - } - void update_json_list() { std::ostringstream os; @@ -169,12 +77,6 @@ namespace unl json_list = os.str(); } - std::string get_hash() - { - std::shared_lock lock(unl_mutex); - return hash; - } - /** * Calculate hash of the given set. * @param unl_list UNL list. @@ -186,165 +88,33 @@ namespace unl return crypto::get_hash(unl_vector); } + /** - * Set sync target to the given unl hash and start syncing. - * @param target_unl_hash The majority unl from the consensus. + * Replace the unl list from the latest unl list from patch file. */ - void set_sync_target(std::string_view target_unl_hash) + void update_unl_changes_from_patch() { - if (sync_ctx.is_shutting_down) - return; - - std::scoped_lock lock(sync_ctx.target_unl_mutex); - if (sync_ctx.target_unl != target_unl_hash) + bool is_unl_list_changed = false; { - sync_ctx.is_syncing = true; - sync_ctx.target_unl = target_unl_hash; - sync_ctx.target_requested_on = 0; - sync_ctx.request_submissions = 0; - LOG_INFO << "unl sync: Syncing for target:" << util::to_hex(sync_ctx.target_unl).substr(0, 10) << " (current:" << util::to_hex(get_hash()).substr(0, 10) << ")"; - } - } - - /** - * Create and send unl request to random node from the unl list. - */ - void send_unl_sync_request() - { - const uint64_t time_now = util::get_epoch_milliseconds(); - // Check whether we need to send any requests or abandon the sync due to timeout. - if ((sync_ctx.target_requested_on == 0) || // Initial request. - (time_now - sync_ctx.target_requested_on) > REQUEST_RESUBMIT_TIMEOUT) // Request resubmission. - { - if (sync_ctx.request_submissions < ABANDON_THRESHOLD) + std::unique_lock lock(unl_mutex); + const std::string updated_hash = calculate_hash(conf::cfg.contract.unl); + if (hash != updated_hash) { - p2p::unl_sync_request unl_sync_message; - unl_sync_message.required_unl = sync_ctx.target_unl; + hash = updated_hash; + list = conf::cfg.contract.unl; + update_json_list(); - flatbuffers::FlatBufferBuilder fbuf(1024); - p2pmsg::create_msg_from_unl_sync_request(fbuf, unl_sync_message); - - std::string target_pubkey; - p2p::send_message_to_random_peer(fbuf, target_pubkey); - - LOG_DEBUG << "UNL list requested from [" << target_pubkey.substr(0, 10) << "]. Required unl hash:" << util::to_hex(sync_ctx.target_unl).substr(0, 10); - sync_ctx.target_requested_on = time_now; - sync_ctx.request_submissions++; - } - else - { - LOG_INFO << "unl sync: Resubmission threshold exceeded. Abandoning sync."; - sync_ctx.clear_target(); - } - } - } - - /** - * Perform unl syncing and serving. - */ - void unl_syncer_loop() - { - util::mask_signal(); - - LOG_INFO << "unl sync: Worker started."; - - while (!sync_ctx.is_shutting_down) - { - // Indicates whether any requests/responses were processed in the previous loop iteration. - bool prev_processed = false; - { - std::scoped_lock lock(sync_ctx.target_unl_mutex); - if (!sync_ctx.target_unl.empty()) - send_unl_sync_request(); - - if (!sync_ctx.target_unl.empty() && check_unl_sync_responses() == 1) - prev_processed = true; - } - - if (check_unl_sync_requests() == 1) - prev_processed = true; - - // Wait a small delay if there were no requests/responses processed during previous iteration. - if (!prev_processed) - util::sleep(SYNCER_IDLE_WAIT); - } - - LOG_INFO << "unl sync: Worker stopped."; - } - - /** - * Process any unl sync requests received. - * @return Returns 0 if no requests were processed and returns 1 if atleast one request is served. - */ - int check_unl_sync_requests() - { - // Move over the collected sync requests to the local list. - std::list> unl_requests; - { - std::scoped_lock(sync_ctx.list_mutex); - unl_requests.splice(unl_requests.end(), sync_ctx.collected_unl_sync_requests); - } - - const std::string unl_hash = get_hash(); - - std::shared_lock lock(unl_mutex); - for (const auto &[session_id, unl_request] : unl_requests) - { - // First check whether we are at the required unl state. - if (unl_request.required_unl != unl_hash) - continue; - - p2p::unl_sync_response resp; - resp.requester_unl = unl_hash; - resp.unl_list = list; - - flatbuffers::FlatBufferBuilder fbuf(1024); - p2pmsg::create_msg_from_unl_sync_response(fbuf, resp); - - std::string_view msg = std::string_view( - reinterpret_cast(fbuf.GetBufferPointer()), fbuf.GetSize()); - - // Find the peer that we should send the unl response to. - std::scoped_lock lock(p2p::ctx.peer_connections_mutex); - const auto peer_itr = p2p::ctx.peer_connections.find(session_id); - - if (peer_itr != p2p::ctx.peer_connections.end()) - { - comm::comm_session *session = peer_itr->second; - session->send(msg); + conf::persist_unl_update(list); + + // Update the own node's unl status. + conf::cfg.node.is_unl = (list.find(conf::cfg.node.public_key) != list.end()); + is_unl_list_changed = true; } } - return unl_requests.empty() ? 0 : 1; - } - - /** - * Check for any unl sync responses received. - * @return Returns 0 if no responses were processed and returns 1 if atleast one response was processed. - */ - int check_unl_sync_responses() - { - // Move over the collected sync response to the local list. - std::list unl_responses; - { - std::scoped_lock(sync_ctx.list_mutex); - unl_responses.splice(unl_responses.end(), sync_ctx.collected_unl_sync_responses); - } - - if (!sync_ctx.target_unl.empty()) - { - // Scan any queued unl sync responses. - // Only process the first successful item which matches with our target unl. - for (const p2p::unl_sync_response &unl : unl_responses) - { - if (unl.requester_unl == sync_ctx.target_unl && verify_and_replace(unl.unl_list) != -1) - { - LOG_INFO << "unl sync: Sync complete. New unl:" << util::to_hex(sync_ctx.target_unl).substr(0, 10); - sync_ctx.clear_target(); - } - } - } - return unl_responses.empty() ? 0 : 1; + // Update the is_unl flag of peer sessions. + if (is_unl_list_changed) + p2p::update_unl_connections(); } } // namespace unl diff --git a/src/unl.hpp b/src/unl.hpp index 4e663185..03a3e88f 100644 --- a/src/unl.hpp +++ b/src/unl.hpp @@ -9,52 +9,15 @@ */ namespace unl { - struct sync_context - { - // The current target unl that we are syncing towards. - std::string target_unl; - std::mutex target_unl_mutex; - - // Lists holding unl requests and responses collected from incoming p2p messages. - std::list> collected_unl_sync_requests; - std::list collected_unl_sync_responses; - std::mutex list_mutex; - - uint64_t target_requested_on = 0; - uint64_t request_submissions = 0; - - std::thread unl_sync_thread; - std::atomic is_syncing = false; - std::atomic is_shutting_down = false; - - void clear_target() - { - target_unl.clear(); - target_requested_on = 0; - request_submissions = 0; - is_syncing = false; - } - }; - extern sync_context sync_ctx; - constexpr uint16_t UNL_REQ_LIST_CAP = 64; // Maximum unl request count. - constexpr uint16_t UNL_RES_LIST_CAP = 64; // Maximum unl response count. size_t count(); std::set get(); std::string get_json(); bool exists(const std::string &bin_pubkey); int init(); - void deinit(); - void apply_changeset(const std::set &additions, const std::set &removals); void update_json_list(); - std::string get_hash(); std::string calculate_hash(const std::set &new_list); - void set_sync_target(std::string_view target_unl_hash); - void send_unl_sync_request(); - void unl_syncer_loop(); - int verify_and_replace(const std::set &new_list); - int check_unl_sync_requests(); - int check_unl_sync_responses(); + void update_unl_changes_from_patch(); } // namespace unl