diff --git a/Cargo.lock b/Cargo.lock index 5521aa08cacf60cf0388c79671a1bae54a6d88f2..08dade11fdbe63dfff9e2a26abed249db320e828 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30929,6 +30929,7 @@ dependencies = [ "pallet-transaction-payment-rpc-runtime-api 28.0.0", "pallet-treasury 27.0.0", "pallet-utility 28.0.0", + "pallet-verify-signature", "pallet-vesting 28.0.0", "pallet-whitelist 27.0.0", "pallet-xcm 7.0.0", diff --git a/polkadot/runtime/westend/Cargo.toml b/polkadot/runtime/westend/Cargo.toml index b5e78506d3f474b1deea4d898c91c76ba555ca57..e75b646506e45867912b2383ec39a65688a0b7a0 100644 --- a/polkadot/runtime/westend/Cargo.toml +++ b/polkadot/runtime/westend/Cargo.toml @@ -97,6 +97,7 @@ pallet-transaction-payment = { workspace = true } pallet-transaction-payment-rpc-runtime-api = { workspace = true } pallet-treasury = { workspace = true } pallet-utility = { workspace = true } +pallet-verify-signature = { workspace = true } pallet-vesting = { workspace = true } pallet-whitelist = { workspace = true } pallet-xcm = { workspace = true } diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 8afaed10c4aaf7ed448d1c87038bc4b1202b8ce2..6417de829665c92cd81dca41d0383e1efa90d5ad 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -1588,6 +1588,8 @@ impl OnSwap for SwapLeases { } pub type MetaTxExtension = ( + pallet_verify_signature::VerifySignature<Runtime>, + pallet_meta_tx::MetaTxMarker<Runtime>, frame_system::CheckNonZeroSender<Runtime>, frame_system::CheckSpecVersion<Runtime>, frame_system::CheckTxVersion<Runtime>, diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 6043daffef1d158f06eb0fe0c4ff8514f03a1d8c..b05102ddde45a0cc570d44dc8b730bfed55a2033 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -2357,6 +2357,8 @@ impl pallet_parameters::Config for Runtime { } pub type MetaTxExtension = ( + pallet_verify_signature::VerifySignature<Runtime>, + pallet_meta_tx::MetaTxMarker<Runtime>, frame_system::CheckNonZeroSender<Runtime>, frame_system::CheckSpecVersion<Runtime>, frame_system::CheckTxVersion<Runtime>, diff --git a/substrate/frame/meta-tx/src/extension.rs b/substrate/frame/meta-tx/src/extension.rs new file mode 100644 index 0000000000000000000000000000000000000000..86635e9d39ff45df4a67e1c5dc74e626b48596ca --- /dev/null +++ b/substrate/frame/meta-tx/src/extension.rs @@ -0,0 +1,49 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; +use sp_runtime::impl_tx_ext_default; + +/// This type serves as a marker extension to differentiate meta-transactions from regular +/// transactions. It implements the `TransactionExtension` trait and carries constant implicit data +/// ("_meta_tx"). +#[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo, DebugNoBound)] +#[scale_info(skip_type_params(T))] +pub struct MetaTxMarker<T> { + _phantom: core::marker::PhantomData<T>, +} + +impl<T> MetaTxMarker<T> { + /// Creates new `TransactionExtension` with implicit meta tx marked. + pub fn new() -> Self { + Self { _phantom: Default::default() } + } +} + +impl<T: Config + Send + Sync> TransactionExtension<T::RuntimeCall> for MetaTxMarker<T> { + const IDENTIFIER: &'static str = "MetaTxMarker"; + type Implicit = [u8; 8]; + type Val = (); + type Pre = (); + fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> { + Ok(*b"_meta_tx") + } + fn weight(&self, _: &T::RuntimeCall) -> Weight { + Weight::zero() + } + impl_tx_ext_default!(T::RuntimeCall; validate prepare); +} diff --git a/substrate/frame/meta-tx/src/lib.rs b/substrate/frame/meta-tx/src/lib.rs index ef012e2d9cc2d2620866e9c5fc317d4907a9a9cc..ca4ccf3362618df4d55b519e2c00b18f330fcc5e 100644 --- a/substrate/frame/meta-tx/src/lib.rs +++ b/substrate/frame/meta-tx/src/lib.rs @@ -62,6 +62,8 @@ pub mod weights; pub use benchmarking::types::WeightlessExtension; pub use pallet::*; pub use weights::WeightInfo; +mod extension; +pub use extension::MetaTxMarker; use core::ops::Add; use frame_support::{ diff --git a/substrate/frame/meta-tx/src/mock.rs b/substrate/frame/meta-tx/src/mock.rs index b3d66c7eeb10436d2500334a810bfbaa1dc0e495..c361fcceca181ad82c1c26b66886a46a9aa02075 100644 --- a/substrate/frame/meta-tx/src/mock.rs +++ b/substrate/frame/meta-tx/src/mock.rs @@ -76,6 +76,7 @@ mod tx_ext { /// /// Helper type used to decode the part of the extension which should be signed. pub type MetaTxBareExtension = ( + MetaTxMarker<Runtime>, frame_system::CheckNonZeroSender<Runtime>, frame_system::CheckSpecVersion<Runtime>, frame_system::CheckTxVersion<Runtime>, diff --git a/substrate/frame/meta-tx/src/tests.rs b/substrate/frame/meta-tx/src/tests.rs index 4500ad9798d51a621f896e3f8dcdee486100fa84..bde1de2f6091bcfb2f5674e1f5ea572b3107529a 100644 --- a/substrate/frame/meta-tx/src/tests.rs +++ b/substrate/frame/meta-tx/src/tests.rs @@ -45,6 +45,7 @@ fn create_tx_bare_ext(account: AccountId) -> TxBareExtension { pub fn create_meta_tx_bare_ext(account: AccountId) -> MetaTxBareExtension { ( + MetaTxMarker::new(), frame_system::CheckNonZeroSender::<Runtime>::new(), frame_system::CheckSpecVersion::<Runtime>::new(), frame_system::CheckTxVersion::<Runtime>::new(),