mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Fork condition detection fix. (#328)
This commit is contained in:
committed by
GitHub
parent
2093b2a61e
commit
38ada6f93e
@@ -161,6 +161,8 @@ namespace consensus
|
||||
// and we need to make the final vote status check after proper pruning rules are applied.
|
||||
|
||||
LOG_DEBUG << "Rechecking vote status after becoming in-sync.";
|
||||
// Reset the voter for the new votes.
|
||||
votes.reset();
|
||||
revise_candidate_proposals(true);
|
||||
new_sync_status = check_sync_status(unl_count, votes, lcl_id);
|
||||
}
|
||||
@@ -995,9 +997,13 @@ namespace consensus
|
||||
}
|
||||
}
|
||||
|
||||
// If winning last primary shard hash is not matched with our last primary shard hash, that means we are not on the consensus ledger.
|
||||
// If that's the case we should request shards straight away.
|
||||
if (ledger::ctx.get_last_primary_shard_id() != majority_primary_shard_id)
|
||||
const uint32_t min_wins_required = ceil(MAJORITY_THRESHOLD * ctx.candidate_proposals.size());
|
||||
if (winning_votes < min_wins_required)
|
||||
{
|
||||
LOG_INFO << "No consensus on last shard hash. Possible fork condition. won:" << winning_votes << " needed:" << min_wins_required;
|
||||
return false;
|
||||
}
|
||||
else if (ledger::ctx.get_last_primary_shard_id() != majority_primary_shard_id)
|
||||
{
|
||||
LOG_INFO << "We are not on the consensus ledger, we must request history from a peer.";
|
||||
is_desync = true;
|
||||
@@ -1005,19 +1011,9 @@ namespace consensus
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check wheher there are enough winning votes for the last shard to be reliable.
|
||||
const uint32_t min_wins_required = ceil(MAJORITY_THRESHOLD * ctx.candidate_proposals.size());
|
||||
if (winning_votes < min_wins_required)
|
||||
{
|
||||
LOG_INFO << "No consensus on last shard hash. Possible fork condition. won:" << winning_votes << " needed:" << min_wins_required;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reaching here means we have reliable amount of winning last shard hash votes and our last shard hash matches with majority last shard hash.
|
||||
is_desync = false;
|
||||
return true;
|
||||
}
|
||||
// Reaching here means we have reliable amount of winning last shard hash votes and our last shard hash matches with majority last shard hash.
|
||||
is_desync = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,20 @@ namespace consensus
|
||||
std::map<util::h32, uint32_t> patch_hash;
|
||||
std::map<util::sequence_hash, uint32_t> last_ledger_primary_shard;
|
||||
std::map<util::sequence_hash, uint32_t> last_ledger_raw_shard;
|
||||
|
||||
void reset()
|
||||
{
|
||||
time.clear();
|
||||
nonce.clear();
|
||||
lcl.clear();
|
||||
users.clear();
|
||||
inputs.clear();
|
||||
output_hash.clear();
|
||||
state_hash.clear();
|
||||
patch_hash.clear();
|
||||
last_ledger_primary_shard.clear();
|
||||
last_ledger_raw_shard.clear();
|
||||
}
|
||||
};
|
||||
|
||||
extern std::atomic<bool> is_patch_update_pending; // Keep track whether the patch file is changed by the SC and is not yet applied to runtime.
|
||||
|
||||
Reference in New Issue
Block a user