From 647759501f52e2c7a54c52c0b1f9cd6cd8f88ba0 Mon Sep 17 00:00:00 2001 From: Ravin Perera <33562092+ravinsp@users.noreply.github.com> Date: Wed, 22 Sep 2021 09:28:01 +0530 Subject: [PATCH] Refactored vote status reporting. (#349) * Refactored global sync status tracking. * Updated streamer for vote status. * Docker image now uses 'latest' tag. * Updated hp version. --- examples/js_client/lib/hp-client-lib.js | 8 ++--- src/consensus.cpp | 42 ++++++++++++------------- src/consensus.hpp | 8 +---- src/msg/bson/usrmsg_bson.cpp | 19 +++++------ src/msg/bson/usrmsg_bson.hpp | 2 +- src/msg/json/usrmsg_json.cpp | 27 ++++++++-------- src/msg/json/usrmsg_json.hpp | 2 +- src/msg/usrmsg_common.hpp | 5 +-- src/msg/usrmsg_parser.cpp | 6 ++-- src/msg/usrmsg_parser.hpp | 2 +- src/status.cpp | 28 +++++++---------- src/status.hpp | 24 +++++++++----- src/usr/usr.cpp | 6 ++-- src/util/version.hpp | 2 +- test/docker/build.sh | 5 +-- test/vm-cluster/stream.js | 11 ++++--- 16 files changed, 99 insertions(+), 98 deletions(-) diff --git a/examples/js_client/lib/hp-client-lib.js b/examples/js_client/lib/hp-client-lib.js index fb2b7b0c..4bac75ed 100644 --- a/examples/js_client/lib/hp-client-lib.js +++ b/examples/js_client/lib/hp-client-lib.js @@ -22,7 +22,7 @@ TextDecoder = util.TextDecoder; } - const supportedHpVersion = "0.5."; + const supportedHpVersion = "0.6."; const serverChallengeSize = 16; const outputValidationPassThreshold = 0.8; const connectionCheckIntervalMs = 1000; @@ -663,7 +663,7 @@ hpVersion: m.hp_version, ledgerSeqNo: m.ledger_seq_no, ledgerHash: msgHelper.deserializeValue(m.ledger_hash), - inSync: m.in_sync, + voteStatus: m.vote_status, roundTime: m.round_time, contractExecutionEnabled: m.contract_execution_enabled, readRequestsEnabled: m.read_requests_enabled, @@ -691,8 +691,8 @@ const ev = { event: m.event }; if (ev.event == "ledger_created") ev.ledger = msgHelper.deserializeLedger(m.ledger); - else if (ev.event == "sync_status") - ev.inSync = m.in_sync; + else if (ev.event == "vote_status") + ev.voteStatus = m.vote_status; emitter.emit(events.ledgerEvent, ev); } else if (m.type == "health_event") { diff --git a/src/consensus.cpp b/src/consensus.cpp index 9ec80e1f..ee01865a 100644 --- a/src/consensus.cpp +++ b/src/consensus.cpp @@ -117,12 +117,14 @@ namespace consensus LOG_DEBUG << "Started stage " << std::to_string(ctx.stage); + const bool was_in_sync = (status::get_vote_status() == status::VOTE_STATUS::SYNCED); + // Throughout consensus, we continously update and prune the candidate proposals for newly // arived ones and expired ones. - revise_candidate_proposals(ctx.vote_status == VOTES_SYNCED); + revise_candidate_proposals(was_in_sync); // Attempt to close the ledger after scanning last round stage 3 proposals. - if (ctx.stage == 0 && ctx.vote_status == VOTES_SYNCED) + if (ctx.stage == 0 && was_in_sync) attempt_ledger_close(); // Get current lcl, state, patch, primary shard and raw shard info. @@ -160,10 +162,12 @@ namespace consensus vote_counter votes; // Check whether we are in sync with other nodes using the proposals we received. + status::VOTE_STATUS new_vote_status = status::VOTE_STATUS::UNKNOWN; { - int new_sync_status = check_sync_status(unl_count, votes, lcl_id); + new_vote_status = check_vote_status(unl_count, votes, lcl_id); + bool newly_in_sync = (new_vote_status == status::VOTE_STATUS::SYNCED); - if (ctx.vote_status != VOTES_SYNCED && new_sync_status == VOTES_SYNCED) + if (!was_in_sync && newly_in_sync) { // If we are just becoming 'in-sync' after being out-of-sync, check the vote status again after the proper // pruning of candidate proposals. This is because we relax the proposal pruning rules when we are not in sync, @@ -173,15 +177,12 @@ namespace consensus // Reset the voter for the new votes. votes.reset(); revise_candidate_proposals(true); - new_sync_status = check_sync_status(unl_count, votes, lcl_id); + new_vote_status = check_vote_status(unl_count, votes, lcl_id); + newly_in_sync = (new_vote_status == status::VOTE_STATUS::SYNCED); } - // Update the node's status if we went from in-sync to not-in-sync. We will report back as being in-sync only when ledger is created. - if (new_sync_status == VOTES_DESYNC) - status::sync_status_changed(false); - - // This marks entering into a new sync cycle. - if (new_sync_status == VOTES_DESYNC && !ctx.sync_ongoing) + // This marks starting a new sync cycle. + if (new_vote_status == status::VOTE_STATUS::DESYNC && !ctx.sync_ongoing) { // Cleanup any unconsensed contract outputs we may have had before the sync cycle began because those are going to be // irrelavant after the sync. @@ -189,14 +190,14 @@ namespace consensus ctx.sync_ongoing = true; } - // If we just bacame in-sync after being in desync, we need to restore consensus context information from the synced ledger. - if (ctx.vote_status != VOTES_SYNCED && new_sync_status == VOTES_SYNCED && ctx.sync_ongoing) + // If we just bacame in-sync after being in a sync cucle, we need to restore consensus context information from the synced ledger. + if (!was_in_sync && newly_in_sync && ctx.sync_ongoing) dispatch_synced_ledger_input_statuses(lcl_id); - ctx.vote_status = new_sync_status; + status::set_vote_status(new_vote_status); } - if (ctx.vote_status == VOTES_UNRELIABLE) + if (new_vote_status == status::VOTE_STATUS::UNRELIABLE) { ctx.stage = 0; ctx.unreliable_votes_attempts++; @@ -213,7 +214,7 @@ namespace consensus { ctx.unreliable_votes_attempts = 0; - if (ctx.vote_status == VOTES_SYNCED) + if (new_vote_status == status::VOTE_STATUS::SYNCED) { // If we are in sync, vote and broadcast the winning votes to next stage. const p2p::proposal p = create_stage123_proposal(votes, unl_count, state_hash, patch_hash, last_primary_shard_id, last_raw_shard_id); @@ -224,7 +225,6 @@ namespace consensus { // Clear any sync recovery pending state if we enter stage 1 while being in sync. ctx.sync_ongoing = false; - status::sync_status_changed(true); LOG_DEBUG << "Sync recovery completed."; } } @@ -357,7 +357,7 @@ namespace consensus * Checks whether we are in sync with the received votes. * @return 0 if we are in sync. -1 on ledger or contract state desync. -2 if majority last ledger primary shard hash unreliable. */ - int check_sync_status(const size_t unl_count, vote_counter &votes, const util::sequence_hash &lcl_id) + status::VOTE_STATUS check_vote_status(const size_t unl_count, vote_counter &votes, const util::sequence_hash &lcl_id) { bool is_last_primary_shard_desync = false; util::sequence_hash majority_primary_shard_id; @@ -438,14 +438,14 @@ namespace consensus // Proceed further only if last primary shard, last raw shard, state and patch hashes are in sync with majority. if (!is_last_primary_shard_desync && !is_last_raw_shard_desync && !is_state_desync && !is_patch_desync) - return VOTES_SYNCED; + return status::VOTE_STATUS::SYNCED; // Last primary shard hash, last raw shard hash, patch or state desync. - return VOTES_DESYNC; + return status::VOTE_STATUS::DESYNC; } // Majority last primary shard hash couldn't be detected reliably. - return VOTES_UNRELIABLE; + return status::VOTE_STATUS::UNRELIABLE; } /** diff --git a/src/consensus.hpp b/src/consensus.hpp index 7720fe0a..34a20b7c 100644 --- a/src/consensus.hpp +++ b/src/consensus.hpp @@ -80,11 +80,6 @@ namespace consensus } }; -#define VOTES_UNKNOWN -3 -#define VOTES_UNRELIABLE -2 -#define VOTES_DESYNC -1 -#define VOTES_SYNCED 0 - /** * This is used to store consensus information */ @@ -118,7 +113,6 @@ namespace consensus uint32_t stage_reset_wait_threshold = 0; // Minimum stage wait time to reset the stage. uint64_t round_boundry_offset = 0; // Time window boundry offset based on contract id. uint16_t unreliable_votes_attempts = 0; // No. of times we failed to get reliable votes continously. - int vote_status = VOTES_UNKNOWN; // Current status of votes. // Indicates whether we are inside a sync cycle or not. Sync cycle is considered to being when we first detect that we are out of sync // and considered to end when we detect to be in sync inside stage 1 of a round for the first time after we began a sync. @@ -179,7 +173,7 @@ namespace consensus int commit_consensus_results(const p2p::proposal &cons_prop, const consensus::consensed_user_map &consensed_users); - int check_sync_status(const size_t unl_count, vote_counter &votes, const util::sequence_hash &lcl_id); + status::VOTE_STATUS check_vote_status(const size_t unl_count, vote_counter &votes, const util::sequence_hash &lcl_id); void revise_candidate_proposals(const bool in_sync); diff --git a/src/msg/bson/usrmsg_bson.cpp b/src/msg/bson/usrmsg_bson.cpp index aad7392f..da9dda7a 100644 --- a/src/msg/bson/usrmsg_bson.cpp +++ b/src/msg/bson/usrmsg_bson.cpp @@ -20,6 +20,7 @@ namespace msg::usrmsg::bson * "hp_version": "", * "ledger_seq_no": , * "ledger_hash": , + * "vote_status": "synced" | "desync" | "unreliable", * "roundtime": , * "contract_execution_enabled": true | false, * "read_requests_enabled": true | false, @@ -33,7 +34,7 @@ namespace msg::usrmsg::bson { const util::sequence_hash lcl_id = status::get_lcl_id(); const std::set unl = status::get_unl(); - const bool in_sync = status::is_in_sync(); + const status::VOTE_STATUS vote_status = status::get_vote_status(); const bool weakly_connected = status::get_weakly_connected(); jsoncons::bson::bson_bytes_encoder encoder(msg); @@ -46,8 +47,8 @@ namespace msg::usrmsg::bson encoder.int64_value(lcl_id.seq_no); encoder.key(msg::usrmsg::FLD_LEDGER_HASH); encoder.byte_string_value(lcl_id.hash.to_string_view()); - encoder.key(msg::usrmsg::FLD_IN_SYNC); - encoder.bool_value(in_sync); + encoder.key(msg::usrmsg::FLD_VOTE_STATUS); + encoder.string_value(msg::usrmsg::VOTE_STATUSES[vote_status]); encoder.key(msg::usrmsg::FLD_ROUND_TIME); encoder.uint64_value(conf::cfg.contract.roundtime); encoder.key(msg::usrmsg::FLD_CONTARCT_EXECUTION_ENABLED); @@ -300,21 +301,21 @@ namespace msg::usrmsg::bson * Message format: * { * "type": "ledger_event", - * "event": "sync_status", - * "in_sync": true | false + * "event": "vote_status", + * "vote_status": "synced" | "desync" | "unreliable" * } * @param in_sync Whether the node is in sync or not. */ - void create_sync_status_notification(std::vector &msg, const bool in_sync) + void create_vote_status_notification(std::vector &msg, const status::VOTE_STATUS vote_status) { jsoncons::bson::bson_bytes_encoder encoder(msg); encoder.begin_object(); encoder.key(msg::usrmsg::FLD_TYPE); encoder.string_value(msg::usrmsg::MSGTYPE_LEDGER_EVENT); encoder.key(msg::usrmsg::FLD_EVENT); - encoder.string_value(msg::usrmsg::LEDGER_EVENT_SYNC_STATUS); - encoder.key(msg::usrmsg::FLD_IN_SYNC); - encoder.bool_value(in_sync); + encoder.string_value(msg::usrmsg::LEDGER_EVENT_VOTE_STATUS); + encoder.key(msg::usrmsg::FLD_VOTE_STATUS); + encoder.string_value(msg::usrmsg::VOTE_STATUSES[vote_status]); encoder.end_object(); encoder.flush(); } diff --git a/src/msg/bson/usrmsg_bson.hpp b/src/msg/bson/usrmsg_bson.hpp index 8791bec6..66317228 100644 --- a/src/msg/bson/usrmsg_bson.hpp +++ b/src/msg/bson/usrmsg_bson.hpp @@ -27,7 +27,7 @@ namespace msg::usrmsg::bson void create_ledger_created_notification(std::vector &msg, const ledger::ledger_record &ledger); - void create_sync_status_notification(std::vector &msg, const bool in_sync); + void create_vote_status_notification(std::vector &msg, const status::VOTE_STATUS vote_status); void create_health_notification(std::vector &msg, const status::health_event &ev); diff --git a/src/msg/json/usrmsg_json.cpp b/src/msg/json/usrmsg_json.cpp index f5c9494c..321a1816 100644 --- a/src/msg/json/usrmsg_json.cpp +++ b/src/msg/json/usrmsg_json.cpp @@ -139,6 +139,7 @@ namespace msg::usrmsg::json * "hp_version": "", * "ledger_seq_no": , * "ledger_hash": "", + * "vote_status": "synced" | "desync" | "unreliable", * "roundtime": , * "contract_execution_enabled": true | false, * "read_requests_enabled": true | false, @@ -152,7 +153,7 @@ namespace msg::usrmsg::json { const util::sequence_hash lcl_id = status::get_lcl_id(); const std::set unl = status::get_unl(); - const bool in_sync = status::is_in_sync(); + const status::VOTE_STATUS vote_status = status::get_vote_status(); const bool weakly_connected = status::get_weakly_connected(); msg.reserve(1024); @@ -173,10 +174,10 @@ namespace msg::usrmsg::json msg += SEP_COLON; msg += util::to_hex(lcl_id.hash.to_string_view()); msg += SEP_COMMA; - msg += msg::usrmsg::FLD_IN_SYNC; - msg += SEP_COLON_NOQUOTE; - msg += in_sync ? STR_TRUE : STR_FALSE; - msg += SEP_COMMA_NOQUOTE; + msg += msg::usrmsg::FLD_VOTE_STATUS; + msg += SEP_COLON; + msg += msg::usrmsg::VOTE_STATUSES[vote_status]; + msg += SEP_COMMA; msg += msg::usrmsg::FLD_ROUND_TIME; msg += SEP_COLON_NOQUOTE; msg += std::to_string(conf::cfg.contract.roundtime); @@ -530,12 +531,12 @@ namespace msg::usrmsg::json * Message format: * { * "type": "ledger_event", - * "event": "sync_status", - * "in_sync": true | false + * "event": "vote_status", + * "vote_status": "synced" | "desync" | "unreliable" * } * @param in_sync Whether the node is in sync or not. */ - void create_sync_status_notification(std::vector &msg, const bool in_sync) + void create_vote_status_notification(std::vector &msg, const status::VOTE_STATUS vote_status) { msg.reserve(128); msg += "{\""; @@ -545,12 +546,12 @@ namespace msg::usrmsg::json msg += SEP_COMMA; msg += msg::usrmsg::FLD_EVENT; msg += SEP_COLON; - msg += msg::usrmsg::LEDGER_EVENT_SYNC_STATUS; + msg += msg::usrmsg::LEDGER_EVENT_VOTE_STATUS; msg += SEP_COMMA; - msg += msg::usrmsg::FLD_IN_SYNC; - msg += SEP_COLON_NOQUOTE; - msg += in_sync ? STR_TRUE : STR_FALSE; - msg += "}"; + msg += msg::usrmsg::FLD_VOTE_STATUS; + msg += SEP_COLON; + msg += msg::usrmsg::VOTE_STATUSES[vote_status]; + msg += "\"}"; } /** diff --git a/src/msg/json/usrmsg_json.hpp b/src/msg/json/usrmsg_json.hpp index d21189d3..06eb2ae5 100644 --- a/src/msg/json/usrmsg_json.hpp +++ b/src/msg/json/usrmsg_json.hpp @@ -31,7 +31,7 @@ namespace msg::usrmsg::json void create_ledger_created_notification(std::vector &msg, const ledger::ledger_record &ledger); - void create_sync_status_notification(std::vector &msg, const bool in_sync); + void create_vote_status_notification(std::vector &msg, const status::VOTE_STATUS vote_status); void create_health_notification(std::vector &msg, const status::health_event &ev); diff --git a/src/msg/usrmsg_common.hpp b/src/msg/usrmsg_common.hpp index 26f66265..dd548390 100644 --- a/src/msg/usrmsg_common.hpp +++ b/src/msg/usrmsg_common.hpp @@ -43,7 +43,7 @@ namespace msg::usrmsg constexpr const char *FLD_IS_FULL_HISTORY_NODE = "is_full_history_node"; constexpr const char *FLD_CURRENT_UNL = "current_unl"; constexpr const char *FLD_PEERS = "peers"; - constexpr const char *FLD_IN_SYNC = "in_sync"; + constexpr const char *FLD_VOTE_STATUS = "vote_status"; constexpr const char *FLD_ID = "id"; constexpr const char *FLD_REPLY_FOR = "reply_for"; constexpr const char *FLD_FILTER_BY = "filter_by"; @@ -110,8 +110,9 @@ namespace msg::usrmsg constexpr const char *QUERY_FILTER_BY_SEQ_NO = "seq_no"; constexpr const char *STR_TRUE = "true"; constexpr const char *STR_FALSE = "false"; + constexpr const char *VOTE_STATUSES[4] = {"unknown", "unreliable", "desync", "synced"}; constexpr const char *LEDGER_EVENT_LEDGER_CREATED = "ledger_created"; - constexpr const char *LEDGER_EVENT_SYNC_STATUS = "sync_status"; + constexpr const char *LEDGER_EVENT_VOTE_STATUS = "vote_status"; constexpr const char *HEALTH_EVENT_PROPOSAL = "proposal"; constexpr const char *HEALTH_EVENT_CONNECTIVITY = "connectivity"; diff --git a/src/msg/usrmsg_parser.cpp b/src/msg/usrmsg_parser.cpp index bd56d5ca..ba85be28 100644 --- a/src/msg/usrmsg_parser.cpp +++ b/src/msg/usrmsg_parser.cpp @@ -72,12 +72,12 @@ namespace msg::usrmsg busrmsg::create_ledger_created_notification(msg, ledger); } - void usrmsg_parser::create_sync_status_notification(std::vector &msg, const bool in_sync) const + void usrmsg_parser::create_vote_status_notification(std::vector &msg, const status::VOTE_STATUS vote_status) const { if (protocol == util::PROTOCOL::JSON) - jusrmsg::create_sync_status_notification(msg, in_sync); + jusrmsg::create_vote_status_notification(msg, vote_status); else - busrmsg::create_sync_status_notification(msg, in_sync); + busrmsg::create_vote_status_notification(msg, vote_status); } void usrmsg_parser::create_health_notification(std::vector &msg, const status::health_event &ev) const diff --git a/src/msg/usrmsg_parser.hpp b/src/msg/usrmsg_parser.hpp index e3012df9..0535e4f4 100644 --- a/src/msg/usrmsg_parser.hpp +++ b/src/msg/usrmsg_parser.hpp @@ -36,7 +36,7 @@ namespace msg::usrmsg void create_ledger_created_notification(std::vector &msg, const ledger::ledger_record &ledger) const; - void create_sync_status_notification(std::vector &msg, const bool in_sync) const; + void create_vote_status_notification(std::vector &msg, const status::VOTE_STATUS vote_status) const; void create_health_notification(std::vector &msg, const status::health_event &ev) const; diff --git a/src/status.cpp b/src/status.cpp index d45ddfd5..a44170aa 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -12,9 +12,8 @@ namespace status util::sequence_hash lcl_id; // Last ledger id/hash pair. ledger::ledger_record last_ledger; // Last ledger record that the node created. - // Indicates whether this node is in sync with other nodes or not. - // -1=unknown, 0=not-in-sync, 1=in-sync - std::atomic in_sync = -1; + // Indicates the current voting status. + std::atomic vote_status = VOTE_STATUS::UNKNOWN; std::shared_mutex unl_mutex; std::set unl; // List of last reported unl binary pubkeys. @@ -38,23 +37,18 @@ namespace status void ledger_created(const util::sequence_hash &ledger_id, const ledger::ledger_record &ledger) { - // If currently not-in-sync, report it as in-sync when a ledger is created. - if (in_sync.load() != 1) - sync_status_changed(true); - std::unique_lock lock(ledger_mutex); lcl_id = ledger_id; last_ledger = ledger; event_queue.try_enqueue(ledger_created_event{ledger}); } - void sync_status_changed(const bool new_in_sync) + void set_vote_status(const VOTE_STATUS new_status) { - const int new_value = new_in_sync ? 1 : 0; - if (new_value != in_sync.load()) + if (new_status != vote_status.load()) { - in_sync = new_value; - event_queue.try_enqueue(sync_status_change_event{new_in_sync}); + vote_status = new_status; + event_queue.try_enqueue(vote_status_change_event{new_status}); } } @@ -64,9 +58,9 @@ namespace status return lcl_id; } - const bool is_in_sync() + VOTE_STATUS get_vote_status() { - return in_sync.load() == 1; + return vote_status.load(); } const ledger::ledger_record get_last_ledger() @@ -119,7 +113,7 @@ namespace status return peers; } - const size_t get_peers_count() + size_t get_peers_count() { return peer_count.load(); } @@ -135,7 +129,7 @@ namespace status } } - const bool get_weakly_connected() + bool get_weakly_connected() { return weakly_connected.load(); } @@ -145,7 +139,7 @@ namespace status available_mesh_capacity = new_capacity; } - const int16_t get_available_mesh_capacity() + int16_t get_available_mesh_capacity() { return available_mesh_capacity.load(); } diff --git a/src/status.hpp b/src/status.hpp index 12304391..e1a2535a 100644 --- a/src/status.hpp +++ b/src/status.hpp @@ -9,6 +9,14 @@ namespace status { + enum VOTE_STATUS + { + UNKNOWN = 0, + UNRELIABLE = 1, + DESYNC = 2, + SYNCED = 3 + }; + struct unl_change_event { std::set unl; @@ -19,9 +27,9 @@ namespace status ledger::ledger_record ledger; }; - struct sync_status_change_event + struct vote_status_change_event { - bool in_sync = false; + VOTE_STATUS vote_status; }; struct proposal_health @@ -44,15 +52,15 @@ namespace status typedef std::variant health_event; // Represents any kind of change that has happened in the node. - typedef std::variant change_event; + typedef std::variant change_event; extern moodycamel::ConcurrentQueue event_queue; void init_ledger(const util::sequence_hash &ledger_id, const ledger::ledger_record &ledger); void ledger_created(const util::sequence_hash &ledger_id, const ledger::ledger_record &ledger); - void sync_status_changed(const bool in_sync); + void set_vote_status(const VOTE_STATUS new_status); const util::sequence_hash get_lcl_id(); - const bool is_in_sync(); + VOTE_STATUS get_vote_status(); const ledger::ledger_record get_last_ledger(); void init_unl(const std::set &init_unl); @@ -61,11 +69,11 @@ namespace status void set_peers(const std::set &updated_peers); const std::set get_peers(); - const size_t get_peers_count(); + size_t get_peers_count(); void set_weakly_connected(const bool is_weakly_connected); - const bool get_weakly_connected(); + bool get_weakly_connected(); void set_available_mesh_capacity(const int16_t new_capacity); - const int16_t get_available_mesh_capacity(); + int16_t get_available_mesh_capacity(); void report_proposal_batch(const std::list &proposals); void emit_proposal_health(); diff --git a/src/usr/usr.cpp b/src/usr/usr.cpp index 83551cca..0c1a4190 100644 --- a/src/usr/usr.cpp +++ b/src/usr/usr.cpp @@ -599,10 +599,10 @@ namespace usr const status::ledger_created_event &ledger_ev = std::get(ev); parser.create_ledger_created_notification(msg, ledger_ev.ledger); } - else if (ev.index() == 2) // Sync status chnge event. + else if (ev.index() == 2) // Vote status chnge event. { - const status::sync_status_change_event &sync_ev = std::get(ev); - parser.create_sync_status_notification(msg, sync_ev.in_sync); + const status::vote_status_change_event &vote_ev = std::get(ev); + parser.create_vote_status_notification(msg, vote_ev.vote_status); } } user.session.send(msg); diff --git a/src/util/version.hpp b/src/util/version.hpp index d9d24d31..e30afe2c 100644 --- a/src/util/version.hpp +++ b/src/util/version.hpp @@ -6,7 +6,7 @@ namespace version { // Hot Pocket version. Written to new configs and p2p/user messages. - constexpr const char *HP_VERSION = "0.5.1"; + constexpr const char *HP_VERSION = "0.6.0"; // Minimum compatible config version (this will be used to validate configs). constexpr const char *MIN_CONFIG_VERSION = "0.5.0"; diff --git a/test/docker/build.sh b/test/docker/build.sh index 7eab92e9..42151626 100755 --- a/test/docker/build.sh +++ b/test/docker/build.sh @@ -11,9 +11,10 @@ tmp=$(mktemp -d) cp $hpcoredir/build/{hpcore,appbill} $hpcoredir/test/bin/{hpfs,hpws,libblake3.so} $tmp/ strip $tmp/hpcore -hpversion=$($tmp/hpcore version | head -n 1) # Remove the revision component from hp version to make up the image version. -imgversion=$(echo "${hpversion%.*}") +# hpversion=$($tmp/hpcore version | head -n 1) +# imgversion=$(echo "${hpversion%.*}") +imgversion="latest" # Ubuntu base image docker build -t $img:$imgversion-ubt.20.04 -f ./$basefile $tmp/ diff --git a/test/vm-cluster/stream.js b/test/vm-cluster/stream.js index cfd56465..7a97ec52 100644 --- a/test/vm-cluster/stream.js +++ b/test/vm-cluster/stream.js @@ -232,7 +232,7 @@ async function establishClientConnection(node) { const lastLedger = await hpc.getLedgerBySeqNo(stat.ledgerSeqNo); node.failureCount = 0; - reportEvent(node, { event: "online", ledger: lastLedger }); + reportEvent(node, { event: "online", ledger: lastLedger, voteStatus: stat.voteStatus }); await hpc.subscribe(HotPocket.notificationChannels.ledgerEvent); } } @@ -272,14 +272,15 @@ async function reportEvent(node, ev) { node.status = 'in_sync'; node.lastLedger = ev.ledger; } - else if (ev.event == 'sync_status') { - node.status = ev.inSync ? 'in_sync' : 'desync'; + else if (ev.event == 'vote_status') { + // ev.voteStatus - possible values: 'unreliable', 'desync', 'synced' + node.status = ev.voteStatus == 'desync' ? 'desync' : 'in_sync'; if (synclog == "on") - await fs.appendFile("sync_ops.log", `${new Date(ts).toUTCString()}, Node${node.idx}, ${node.uri}, ${node.status}, at ${node.lastLedger.seqNo}\n`); + await fs.appendFile("sync_ops.log", `${new Date(ts).toUTCString()}, Node${node.idx}, ${node.uri}, ${ev.voteStatus}, at ${node.lastLedger.seqNo}\n`); } else if (ev.event == 'online') { - node.status = 'online'; + node.status = ev.voteStatus == 'desync' ? 'desync' : 'in_sync'; node.lastLedger = ev.ledger; } else if (ev.event == 'offline') {