Skip to content

Commit e3865cf

Browse files
RomarQgui1117shawntabrizibkontur
authored
Deprecate ValidateUnsigned trait and #[pallet::validate_unsigned] attribute (#10150)
Part of #2415 Closes #2436 Related: #6325 #6326 ## Summary Deprecates the `ValidateUnsigned` trait and `#[pallet::validate_unsigned]` attribute in favor of the new `TransactionExtension` API. This is a non-breaking change that adds deprecation warnings to guide users toward the modern transaction validation approach. ## Motivation The `ValidateUnsigned` trait was the legacy approach for validating unsigned transactions in FRAME pallets. The newer `TransactionExtension` trait provides a more flexible and composable way to handle transaction validation, including both signed and unsigned transactions. ## Changes ### Deprecated APIs - ✅ Added `#[deprecated]` attribute to `ValidateUnsigned` trait - ✅ Added deprecation warning to `#[pallet::validate_unsigned]` macro attribute ### Migration (Using `TransactionExtensions`) https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/transaction_extensions ## Impact - **Non-breaking:** Existing code continues to work with deprecation warnings - **Compiler warnings:** Users will see deprecation notices guiding them to migrate - **Timeline:** Full removal planned for a future major release (TBD) ## Review Notes - The `#[pallet::validate_unsigned]` deprecation warning might be redundant since it's always used together with `ValidateUnsigned`, but both are included for completeness and clarity. ## Follow-up Tasks The following pallets and crates need to be migrated to `TransactionExtension` in subsequent PRs: **Runtime crates:** - [ ] `polkadot-runtime-common` - [ ] `polkadot-runtime-parachains` **FRAME pallets:** - [ ] `pallet-babe` - [ ] `pallet-beefy` - [ ] `pallet-election-provider-multi-block` - [ ] `pallet-grandpa` - [x] `pallet-im-online` #11235 - [x] `pallet-mixnet` #11010 **Core:** - [ ] `frame-executive` - [ ] `frame-system` **Examples:** - [x] `pallet-example-offchain-worker` #10716 **Testing:** - [ ] `substrate-test-runtime` ## Open Question Should we remove the `ValidateUnsigned` bound from the type parameter `V` in the `Applyable` trait? --------- Co-authored-by: Guillaume Thiolliere <guillaume.thiolliere@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Branislav Kontur <bkontur@gmail.com>
1 parent 5c97c0f commit e3865cf

40 files changed

Lines changed: 171 additions & 33 deletions

File tree

cumulus/pallets/parachain-system/src/block_weight/mock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ pub mod test_pallet {
194194
}
195195
}
196196

197+
#[allow(deprecated)]
197198
#[pallet::validate_unsigned]
198199
impl<T: Config> sp_runtime::traits::ValidateUnsigned for Pallet<T> {
199200
type Call = Call<T>;

polkadot/runtime/common/src/claims/benchmarking.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ use frame_support::{
2626
};
2727
use frame_system::RawOrigin;
2828
use secp_utils::*;
29-
use sp_runtime::{
30-
traits::{DispatchTransaction, ValidateUnsigned},
31-
DispatchResult,
32-
};
29+
use sp_runtime::{traits::DispatchTransaction, DispatchResult};
3330

3431
const SEED: u32 = 0;
3532

@@ -74,6 +71,9 @@ fn create_claim_attest<T: Config>(input: u32) -> DispatchResult {
7471
mod benchmarks {
7572
use super::*;
7673

74+
#[allow(deprecated)]
75+
use sp_runtime::traits::ValidateUnsigned;
76+
7777
// Benchmark `claim` including `validate_unsigned` logic.
7878
#[benchmark]
7979
fn claim() -> Result<(), BenchmarkError> {
@@ -104,6 +104,7 @@ mod benchmarks {
104104
{
105105
let call = <Call<T> as Decode>::decode(&mut &*call_enc)
106106
.expect("call is encoded above, encoding must be correct");
107+
#[allow(deprecated)]
107108
super::Pallet::<T>::validate_unsigned(source, &call)
108109
.map_err(|e| -> &'static str { e.into() })?;
109110
call.dispatch_bypass_filter(RawOrigin::None.into())?;
@@ -168,6 +169,7 @@ mod benchmarks {
168169
{
169170
let call = <Call<T> as Decode>::decode(&mut &*call_enc)
170171
.expect("call is encoded above, encoding must be correct");
172+
#[allow(deprecated)]
171173
super::Pallet::<T>::validate_unsigned(source, &call)
172174
.map_err(|e| -> &'static str { e.into() })?;
173175
call.dispatch_bypass_filter(RawOrigin::None.into())?;

polkadot/runtime/common/src/claims/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ pub mod pallet {
496496
}
497497
}
498498

499+
#[allow(deprecated)]
499500
#[pallet::validate_unsigned]
500501
impl<T: Config> ValidateUnsigned for Pallet<T> {
501502
type Call = Call<T>;

polkadot/runtime/common/src/claims/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ fn real_eth_sig_works() {
564564
}
565565

566566
#[test]
567+
#[allow(deprecated)]
567568
fn validate_unsigned_works() {
568569
use sp_runtime::traits::ValidateUnsigned;
569570
let source = sp_runtime::transaction_validity::TransactionSource::External;

polkadot/runtime/parachains/src/disputes/slashing.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ pub mod pallet {
531531
}
532532
}
533533

534+
#[allow(deprecated)]
534535
#[pallet::validate_unsigned]
535536
impl<T: Config> ValidateUnsigned for Pallet<T> {
536537
type Call = Call<T>;

polkadot/runtime/parachains/src/paras/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,7 @@ pub mod pallet {
13651365
}
13661366
}
13671367

1368+
#[allow(deprecated)]
13681369
#[pallet::validate_unsigned]
13691370
impl<T: Config> ValidateUnsigned for Pallet<T> {
13701371
type Call = Call<T>;

polkadot/runtime/parachains/src/paras/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ fn pvf_check_submit_vote() {
14571457

14581458
let call =
14591459
Call::include_pvf_check_statement { stmt: stmt.clone(), signature: signature.clone() };
1460+
#[allow(deprecated)]
14601461
let validate_unsigned =
14611462
<Paras as ValidateUnsigned>::validate_unsigned(TransactionSource::InBlock, &call)
14621463
.map(|_| ());
@@ -2263,6 +2264,7 @@ fn apply_authorized_force_set_current_code_works() {
22632264
code: ValidationCode|
22642265
-> (Result<_, _>, DispatchResultWithPostInfo) {
22652266
let call = Call::apply_authorized_force_set_current_code { para, new_code: code.clone() };
2267+
#[allow(deprecated)]
22662268
let validate_unsigned =
22672269
<Paras as ValidateUnsigned>::validate_unsigned(TransactionSource::InBlock, &call)
22682270
.map(|_| ());

prdoc/pr_10150.prdoc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
title: Deprecate `ValidateUnsigned` trait and `#[pallet::validate_unsigned]` attribute.
2+
3+
doc:
4+
- audience: [Runtime Dev, Runtime User]
5+
description: |
6+
Deprecate the `ValidateUnsigned` trait and `#[pallet::validate_unsigned]` attribute as part of phase 2 of Extrinsic Horizon.
7+
8+
crates:
9+
- name: sp-runtime
10+
bump: minor
11+
- name: frame-system
12+
bump: patch
13+
- name: frame-support
14+
bump: patch
15+
- name: frame-support-procedural
16+
bump: patch
17+
- name: polkadot-runtime-common
18+
bump: patch
19+
- name: polkadot-runtime-parachains
20+
bump: patch
21+
- name: pallet-babe
22+
bump: patch
23+
- name: pallet-beefy
24+
bump: patch
25+
- name: pallet-election-provider-multi-phase
26+
bump: patch
27+
- name: pallet-election-provider-multi-block
28+
bump: patch
29+
- name: frame-executive
30+
bump: patch
31+
- name: pallet-grandpa
32+
bump: patch
33+
- name: pallet-im-online
34+
bump: patch
35+
- name: pallet-mixnet
36+
bump: patch
37+
- name: cumulus-pallet-parachain-system
38+
bump: patch
39+
- name: substrate-test-runtime
40+
bump: patch

substrate/frame/babe/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ pub mod pallet {
476476
}
477477
}
478478

479+
#[allow(deprecated)]
479480
#[pallet::validate_unsigned]
480481
impl<T: Config> ValidateUnsigned for Pallet<T> {
481482
type Call = Call<T>;

substrate/frame/babe/src/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ fn report_equivocation_invalid_equivocation_proof() {
717717
}
718718

719719
#[test]
720+
#[allow(deprecated)]
720721
fn report_equivocation_validate_unsigned_prevents_duplicates() {
721722
use sp_runtime::transaction_validity::{
722723
InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity,

0 commit comments

Comments
 (0)