Proto/AI: forbid delegate upon denunciation
What
Always forbid a delegate from taking part in the consensus process as soon as a valid denunciation about them has been witnessed, instead of only when recent and future slashes sum to at least 51%.
Unforbid a delegate at the end of a cycle only when no slashes are pending and their current frozen deposits at least match the frozen stakes that were associated with the rights computed for the next cycle.
Part of #6781.
Why
This change is a prerequisite for Adaptive Slashing: we won't necessarily know the percentage of slashing at the time we witness a denunciation, so we can no longer use the "slashed at least 51% recently, including the current denunciation" criterion to decide whether to forbid the delegate.
Moreover, this change is positive for the bakers: always forbidding a denounced delegate protects them from incurring further penalties in the near future if a faulty configuration causes them to misbehave, giving them some time to fix it. Therefore, we have decided to do this change independently from the Adaptive Slashing feature flag.
How
The new forbidding semantics is straightforward to implement and much simpler than before, allowing me to remove functions and variables which are no longer needed.
The unforbidding changes are also rather simple, but they rely on understanding exactly what the current_frozen_deposits and frozen values represent, so I added comments to a few related functions.
Remark
We could make the forbidden_delegate field in Double_<signing>_evidence_result non-optional now, but I don't think it's worth a breaking change in the results, and the current option leaves room for future flexibility in the forbidding semantics.
Manually testing the MR
CI
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR