Skip to content

Migrate pallet-mixnet from the deprecated ValidateUnsigned trait to #[pallet::authorize]#11010

Open
RomarQ wants to merge 17 commits intoparitytech:masterfrom
RomarQ:romarq/migrate-pallet-mixnet-to-tx-extension
Open

Migrate pallet-mixnet from the deprecated ValidateUnsigned trait to #[pallet::authorize]#11010
RomarQ wants to merge 17 commits intoparitytech:masterfrom
RomarQ:romarq/migrate-pallet-mixnet-to-tx-extension

Conversation

@RomarQ
Copy link
Copy Markdown
Contributor

@RomarQ RomarQ commented Feb 7, 2026

Summary

Part of #2415 (follow-up to #10150)

Migrate pallet-mixnet from the deprecated ValidateUnsigned trait to #[pallet::authorize], following the pattern established in #10716.

Changes

  • Replace ValidateUnsigned impl with #[pallet::authorize] on the register call. The validation logic (session index, authority index bounds, authority existence, duplicate registration, signature) is unchanged, just moved inline.
  • Change Config bound from CreateBare<Call<Self>> to CreateAuthorizedTransaction<Call<Self>>.
  • ensure_noneensure_authorized, create_barecreate_authorized_transaction.
  • Add #[pallet::weight_of_authorize].
  • Add tests covering all authorize validation paths and dispatch with RawOrigin::Authorized.

Migration

The Config trait now requires CreateAuthorizedTransaction<Call<Self>> instead of CreateBare<Call<Self>>. Runtimes with a blanket impl<C> CreateAuthorizedTransaction<C> for Runtime (like kitchensink) need no changes.

This commit migrates pallet-mixnet from the deprecated ValidateUnsigned
trait to the modern TransactionExtension API using the #[pallet::authorize]
attribute.

Changes:
- Added TransactionValidityWithRefund import from sp_runtime
- Replaced #[pallet::validate_unsigned] implementation with
  #[pallet::authorize] attribute on the register call
- Moved all validation logic into the authorize attribute:
  * Session index validation (not future/stale)
  * Authority index bounds checking
  * Authority ID existence verification
  * Duplicate registration prevention
  * Signature verification
- Changed ensure_none to ensure_authorized in the register call
- Updated debug assertions to reflect validation is now in authorize
- Simplified authorize closure using .map() for cleaner code

The validation logic and security properties remain identical to the previous
implementation, ensuring no behavioral changes while adopting the modern API.

This serves as a reference for other authority-based pallets migrating from
ValidateUnsigned.
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