Skip to content

fix(contract): cancel in-flight rounds on vote_deactivate quorum (#186)#345

Open
jeffrey701 wants to merge 1 commit into
entrius:testfrom
jeffrey701:fix/vote-deactivate-clear-inflight-186
Open

fix(contract): cancel in-flight rounds on vote_deactivate quorum (#186)#345
jeffrey701 wants to merge 1 commit into
entrius:testfrom
jeffrey701:fix/vote-deactivate-clear-inflight-186

Conversation

@jeffrey701
Copy link
Copy Markdown

Summary

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. do_initiate is the most consequential one — its closure did not re-read miner_active.

Two changes in smart-contracts/ink/lib.rs:

  1. vote_deactivate quorum closure calls clear_request(miner, REQ_*) for each miner-keyed request type after deactivation, so any pending vote rounds for that miner stop being countable.
  2. The REQ_INITIATE consensus closure re-checks miner_active at closure time and returns Error::MinerNotActive on miss. Belt and suspenders against a same-block race where a deactivation and an initiate-quorum vote land in the same block.

REQ_RESERVE already gates at entry; the entry-point check is sufficient given the new clear_request call in vote_deactivate.

Test plan

  • Existing contract tests pass
  • Manual: vote_deactivate quorum followed by a delayed vote on a pre-existing REQ_INITIATE round — the late vote should not find the request (cleared) and the closure should never run.
  • Manual: same-block race — a REQ_INITIATE quorum vote and a vote_deactivate quorum vote land in the same block — initiate closure returns MinerNotActive if deactivation lands first.

Closes #186

…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
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vote_deactivate quorum doesn't cancel in-flight miner-keyed rounds

1 participant