fix(contract): cancel in-flight rounds on vote_deactivate quorum (#186)#345
Open
jeffrey701 wants to merge 1 commit into
Open
fix(contract): cancel in-flight rounds on vote_deactivate quorum (#186)#345jeffrey701 wants to merge 1 commit into
jeffrey701 wants to merge 1 commit into
Conversation
…rius#186) When a miner is deactivated via quorum the closure only flips `miner_active` and emits the event. Any `REQ_ACTIVATE` / `REQ_RESERVE` / `REQ_INITIATE` round already in flight stays voteable, so a later vote reaching its own quorum can run its closure against a now-deactivated miner — most notably `do_initiate`, whose closure didn't re-check `miner_active`. - vote_deactivate closure now calls `clear_request` for each miner-keyed request type after deactivation. - REQ_INITIATE closure re-checks `miner_active` as defense in depth against a same-block race; returns `MinerNotActive` on miss. Closes entrius#186
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a miner is deactivated via quorum the closure only flips
miner_activeand emits the event. AnyREQ_ACTIVATE/REQ_RESERVE/REQ_INITIATEround already in flight stays voteable, so a later vote reaching its own quorum can run its closure against a now-deactivated miner.do_initiateis the most consequential one — its closure did not re-readminer_active.Two changes in
smart-contracts/ink/lib.rs:vote_deactivatequorum closure callsclear_request(miner, REQ_*)for each miner-keyed request type after deactivation, so any pending vote rounds for that miner stop being countable.REQ_INITIATEconsensus closure re-checksminer_activeat closure time and returnsError::MinerNotActiveon miss. Belt and suspenders against a same-block race where a deactivation and an initiate-quorum vote land in the same block.REQ_RESERVEalready gates at entry; the entry-point check is sufficient given the newclear_requestcall in vote_deactivate.Test plan
MinerNotActiveif deactivation lands first.Closes #186