Skip to content

Plug request_votes storage leak#149

Merged
anderdc merged 2 commits intotestfrom
fix/request-votes-storage-leak
Apr 21, 2026
Merged

Plug request_votes storage leak#149
anderdc merged 2 commits intotestfrom
fix/request-votes-storage-leak

Conversation

@LandynDev
Copy link
Copy Markdown
Collaborator

Summary

  • clear_request_data only ever removed the scalar request metadata (vote count / created block / hash) — the per-(request_id, validator) entries in request_votes were never cleared, so every quorum round leaked validator_count trie entries forever.
  • Replaced request_votes: Mapping<(u64, AccountId), bool> + request_vote_count: Mapping<u64, u32> with a single request_voters: Mapping<u64, Vec<AccountId>>. record_vote scans/pushes; clear_request_data drops the whole vec in one op.
  • get_pending_reserve_vote_count reads vec.len(). Its selector (0x3781315a) is unchanged, so contract_client.py needs no update.
  • Metadata regenerated (selectors stable; only type IDs shifted from the dropped fields).

Note: this is a storage-layout change, so it only applies cleanly to a fresh deploy. Any in-flight consensus round at upgrade time will be lost — halt first if upgrading a live instance.

Test plan

  • cargo contract build --release passes (48.4K optimized wasm)
  • cargo test --lib passes (no unit tests present)
  • E2E suite 02 against a redeployed contract

LandynDev and others added 2 commits April 21, 2026 10:06
Fold request_votes + request_vote_count into request_voters:
Mapping<u64, Vec<AccountId>>. clear_request_data now removes the
whole round in one op, where the old (request_id, validator) keyed
mapping leaked validator_count trie entries per quorum forever.
@anderdc anderdc merged commit 6bb6bb2 into test Apr 21, 2026
3 checks passed
@anderdc anderdc deleted the fix/request-votes-storage-leak branch April 21, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants