Skip to content

Add EnsureBoth origin combinator, conviction-voting empty entry cleanup, and weight inheritance docs#12087

Open
BenWhiteJam wants to merge 3 commits into
paritytech:masterfrom
BenWhiteJam:fix/ensure-both-conviction-cleanup-weight-docs
Open

Add EnsureBoth origin combinator, conviction-voting empty entry cleanup, and weight inheritance docs#12087
BenWhiteJam wants to merge 3 commits into
paritytech:masterfrom
BenWhiteJam:fix/ensure-both-conviction-cleanup-weight-docs

Conversation

@BenWhiteJam
Copy link
Copy Markdown
Contributor

Summary

  • EnsureBoth origin combinator: Adds an "AND gate" for origins — requires two independent origin checks to both pass. Implements EnsureOrigin and EnsureOriginWithArg for a tuple (LeftOrigin, RightOrigin).
  • Conviction-voting empty entry cleanup: When all votes are removed and locks expire, empty VotingFor entries can linger in storage. This adds a cleanup_empty_votes dispatchable (callable by any signed origin) plus automatic cleanup after vote removal to prevent storage bloat.
  • Weight inheritance docs: Improved #[pallet::weight] attribute docs to clarify how weight inheritance from $WeightInfo works at compile time.

Changes

  • frame/support/src/traits/dispatch.rs — new EnsureBoth<L, R> struct with full trait impls + doc tests
  • frame/support/src/traits.rs — re-export EnsureBoth
  • frame/support/src/lib.rs — expanded weight inheritance docs
  • frame/conviction-voting/src/lib.rscleanup_empty_votes dispatchable + auto-cleanup after vote removal + remove_empty_entries helper
  • frame/conviction-voting/src/vote.rsVoting::is_empty() helper
  • frame/conviction-voting/src/weights.rs — weight function for cleanup_empty_votes

Test plan

  • cargo test -p pallet-conviction-voting
  • cargo test -p frame-support
  • Verify EnsureBoth doc test passes

🤖 Generated with Claude Code

… cleanup, and weight inheritance docs

- Add EnsureBoth<L, R> "AND gate" combinator for EnsureOrigin that requires both
  origin checks to pass (closes paritytech#369)
- Add cleanup_empty_votes extrinsic to conviction-voting pallet and preventive
  cleanup in update_lock to remove zero-value VotingFor storage entries (closes paritytech#7458)
- Document inherited weight resolution mechanism in #[pallet::weight] docs (closes paritytech#4766)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@BenWhiteJam BenWhiteJam requested a review from a team as a code owner May 16, 2026 17:09
@cla-bot-2021
Copy link
Copy Markdown

cla-bot-2021 Bot commented May 16, 2026

User @claude, please sign the CLA here.

Copy link
Copy Markdown
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey RoboBen, could you please split this pull request into two pull requests :)

Can you please also provide tests for both changes.

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