Skip to content

Migrate pallet-example-offchain-worker to TransactionExtension API#1

Closed
RomarQ wants to merge 1 commit intomasterfrom
romarq/migrate-offchain-worker-to-tx-extension
Closed

Migrate pallet-example-offchain-worker to TransactionExtension API#1
RomarQ wants to merge 1 commit intomasterfrom
romarq/migrate-offchain-worker-to-tx-extension

Conversation

@RomarQ
Copy link
Copy Markdown
Owner

@RomarQ RomarQ commented Dec 30, 2025

Summary

Part of paritytech#2415

This PR is a focused extraction from the larger PR paritytech#10150, specifically migrating only pallet-example-offchain-worker to use the modern TransactionExtension API.

Changes

This PR migrates pallet-example-offchain-worker from the deprecated ValidateUnsigned trait to the TransactionExtension API using the #[pallet::authorize] attribute.

Changes include:

  • ✅ Replaced #[pallet::validate_unsigned] implementation with #[pallet::authorize] attributes
  • ✅ Updated submit_price_unsigned to use the authorization attribute with proper validation
  • ✅ Updated submit_price_unsigned_with_signed_payload to include signature verification in the authorization
  • ✅ Changed ensure_none to ensure_authorized in unsigned transaction handlers
  • ✅ Updated documentation to explain the new unsigned transaction validation approach
  • ✅ Added comprehensive documentation section about unsigned transaction validation

Why Split from paritytech#10150?

The original PR was quite large, touching many pallets and core functionality. Splitting it into smaller, focused PRs makes it:

  • Easier to review
  • Faster to merge
  • Lower risk of conflicts
  • Better for incremental migration

Testing

The pallet serves as an example and demonstrates the recommended pattern for validating unsigned transactions. This will serve as a reference for migrating other pallets.

Related PRs

This is the first in a series of PRs to migrate away from ValidateUnsigned:

  • pallet-example-offchain-worker (this PR)
  • Other pallets to follow...

@RomarQ RomarQ force-pushed the romarq/migrate-offchain-worker-to-tx-extension branch from ce7b45a to a9a6166 Compare December 30, 2025 21:30
This commit migrates `pallet-example-offchain-worker` from the deprecated
`ValidateUnsigned` trait to the modern `TransactionExtension` API using the
`#[pallet::authorize]` attribute.

Changes:
- Replaced `#[pallet::validate_unsigned]` implementation with
  `#[pallet::authorize]` attributes on unsigned transaction calls
- Updated `submit_price_unsigned` to use authorization attribute
- Updated `submit_price_unsigned_with_signed_payload` to use authorization
  with signature verification
- Changed `ensure_none` to `ensure_authorized` in unsigned transaction handlers
- Updated documentation to reflect the new validation approach
- Added comprehensive documentation about unsigned transaction validation

This change demonstrates the recommended pattern for validating unsigned
transactions and serves as a reference for other pallets migrating away
from `ValidateUnsigned`.
@RomarQ RomarQ force-pushed the romarq/migrate-offchain-worker-to-tx-extension branch from a9a6166 to 05a3080 Compare December 31, 2025 14:37
@RomarQ RomarQ closed this Dec 31, 2025
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.

1 participant