Unverified Commit 7658274d authored by asynchronous rob's avatar asynchronous rob Committed by GitHub
Browse files

impose minimum limitation on explicit votes too (#3181)

parent d729d4a1
Pipeline #140775 passed with stages
in 33 minutes and 46 seconds
......@@ -172,30 +172,44 @@ impl<B> grandpa::VotingRule<PolkadotBlock, B> for ApprovalCheckingVotingRule
checking_lag.set(approval_checking_subsystem_lag as _);
}
tracing::trace!(
target: "parachain::approval-voting",
"GRANDPA: voting on {:?}. Approval-checking lag behind best is {}",
approval_checking_subsystem_vote,
approval_checking_subsystem_lag,
);
let min_vote = {
let diff = best_number.saturating_sub(base_number);
if diff >= MAX_APPROVAL_CHECKING_FINALITY_LAG {
// Catch up to the best, with some extra lag.
find_target(best_number - MAX_APPROVAL_CHECKING_FINALITY_LAG, &best_header)
.filter(|vote| vote.1 <= current_number)
} else {
Some((base_hash, base_number))
}
};
match approval_checking_vote_to_grandpa_vote(
let vote = match approval_checking_vote_to_grandpa_vote(
approval_checking_subsystem_vote,
current_number,
) {
ParachainVotingRuleTarget::Explicit(vote) => Some(vote),
ParachainVotingRuleTarget::Current => Some((current_hash, current_number)),
ParachainVotingRuleTarget::Base => {
let diff = best_number.saturating_sub(base_number);
if diff >= MAX_APPROVAL_CHECKING_FINALITY_LAG {
// Catch up to the best, with some extra lag.
find_target(best_number - MAX_APPROVAL_CHECKING_FINALITY_LAG, &best_header)
.filter(|vote| vote.1 <= current_number)
ParachainVotingRuleTarget::Explicit(vote) => {
if min_vote.as_ref().map_or(false, |min| min.1 > vote.1) {
min_vote
} else {
Some((base_hash, base_number))
Some(vote)
}
}
}
ParachainVotingRuleTarget::Current => Some((current_hash, current_number)),
ParachainVotingRuleTarget::Base => min_vote.or(Some((base_hash, base_number))),
};
tracing::trace!(
target: "parachain::approval-voting",
?vote,
?approval_checking_subsystem_vote,
approval_checking_subsystem_lag,
current_number,
best_number,
base_number,
"GRANDPA: voting based on approved ancestor.",
);
vote
})
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment