diff --git a/src/consensus.cpp b/src/consensus.cpp index 91b99769..a78d3d39 100644 --- a/src/consensus.cpp +++ b/src/consensus.cpp @@ -226,13 +226,13 @@ namespace consensus { conf::change_role(conf::ROLE::OBSERVER); + if (is_state_desync) + sc::contract_sync_worker.set_target_push_front(hpfs::sync_target{"state", majority_state_hash, sc::STATE_DIR_PATH, hpfs::BACKLOG_ITEM_TYPE::DIR}); + // Patch file sync is prioritized, Therefore it is set in the front of the sync target list. if (is_patch_desync) sc::contract_sync_worker.set_target_push_front(hpfs::sync_target{"patch", majority_patch_hash, sc::PATCH_FILE_PATH, hpfs::BACKLOG_ITEM_TYPE::FILE}); - if (is_state_desync) - sc::contract_sync_worker.set_target_push_back(hpfs::sync_target{"state", majority_state_hash, sc::STATE_DIR_PATH, hpfs::BACKLOG_ITEM_TYPE::DIR}); - // If ledger blob shard is desync, We first request the latest blob shard. if (is_last_blob_shard_desync) { @@ -348,7 +348,7 @@ namespace consensus const uint64_t now = util::get_epoch_milliseconds(); - // Rrounds are discreet windows of roundtime. + // Rounds are discreet windows of roundtime. if (ctx.stage == 0) { @@ -1094,6 +1094,8 @@ namespace consensus else { unl::update_unl_changes_from_patch(); + // Refresh values in consensus context to match newly synced roundtime from patch file. + refresh_roundtime(false); is_patch_update_pending = false; } } diff --git a/src/hpfs/hpfs_sync.cpp b/src/hpfs/hpfs_sync.cpp index 58f9e29e..984a33c6 100644 --- a/src/hpfs/hpfs_sync.cpp +++ b/src/hpfs/hpfs_sync.cpp @@ -90,6 +90,11 @@ namespace hpfs return; } + // Remove any previous sync targets for the same target vpath. + target_list.remove_if([&target](const hpfs::sync_target &element) { + return element.vpath == target.vpath; + }); + target_list.push_front(target); is_syncing = true; std::unique_lock lock(current_target_mutex); diff --git a/src/sc/contract_sync.cpp b/src/sc/contract_sync.cpp index 2246a3b8..874935d8 100644 --- a/src/sc/contract_sync.cpp +++ b/src/sc/contract_sync.cpp @@ -3,6 +3,7 @@ #include "../unl.hpp" #include "../hpfs/hpfs_mount.hpp" #include "contract_mount.hpp" +#include "../consensus.hpp" namespace sc { @@ -19,6 +20,7 @@ namespace sc else { unl::update_unl_changes_from_patch(); + consensus::refresh_roundtime(false); // Update global hash tracker with the new patch file hash. fs_mount->set_parent_hash(synced_target.vpath, synced_target.hash);