Migrate pallet-example-offchain-worker to TransactionExtension API#1
Closed
Migrate pallet-example-offchain-worker to TransactionExtension API#1
Conversation
ce7b45a to
a9a6166
Compare
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`.
a9a6166 to
05a3080
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of paritytech#2415
This PR is a focused extraction from the larger PR paritytech#10150, specifically migrating only
pallet-example-offchain-workerto use the modernTransactionExtensionAPI.Changes
This PR migrates
pallet-example-offchain-workerfrom the deprecatedValidateUnsignedtrait to theTransactionExtensionAPI using the#[pallet::authorize]attribute.Changes include:
#[pallet::validate_unsigned]implementation with#[pallet::authorize]attributessubmit_price_unsignedto use the authorization attribute with proper validationsubmit_price_unsigned_with_signed_payloadto include signature verification in the authorizationensure_nonetoensure_authorizedin unsigned transaction handlersWhy Split from paritytech#10150?
The original PR was quite large, touching many pallets and core functionality. Splitting it into smaller, focused PRs makes it:
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: