diff --git a/chain-extensions/src/mock.rs b/chain-extensions/src/mock.rs index 45c7811adb..bb548b6cbd 100644 --- a/chain-extensions/src/mock.rs +++ b/chain-extensions/src/mock.rs @@ -7,13 +7,13 @@ use core::num::NonZeroU64; use frame_support::dispatch::DispatchResult; -use frame_support::traits::{Contains, Everything, InherentBuilder, InsideBoth}; +use frame_support::traits::{Contains, Everything, InsideBoth}; use frame_support::weights::Weight; use frame_support::weights::constants::RocksDbWeight; use frame_support::{PalletId, derive_impl}; use frame_support::{assert_ok, parameter_types, traits::PrivilegeCmp}; use frame_system as system; -use frame_system::{EnsureRoot, RawOrigin, limits, offchain::CreateTransactionBase}; +use frame_system::{EnsureRoot, RawOrigin, limits}; use pallet_contracts::HoldReason as ContractsHoldReason; use pallet_subtensor::*; use pallet_subtensor_proxy as pallet_proxy; @@ -603,28 +603,12 @@ where type RuntimeCall = RuntimeCall; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { - UncheckedExtrinsic::new_inherent(call) - } -} - -impl frame_system::offchain::CreateSignedTransaction for Test -where - RuntimeCall: From, -{ - fn create_signed_transaction< - C: frame_system::offchain::AppCrypto, - >( - call: >::RuntimeCall, - _public: Self::Public, - _account: Self::AccountId, - nonce: Self::Nonce, - ) -> Option { - Some(UncheckedExtrinsic::new_signed(call, nonce.into(), (), ())) + UncheckedExtrinsic::new_bare(call) } } diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 2d51ecf105..514e390e16 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -4,9 +4,9 @@ use core::num::NonZeroU64; use frame_support::{ PalletId, assert_ok, derive_impl, parameter_types, - traits::{Everything, Hooks, InherentBuilder, PrivilegeCmp}, + traits::{Everything, Hooks, PrivilegeCmp}, }; -use frame_system::{self as system, offchain::CreateTransactionBase}; +use frame_system::{self as system}; use frame_system::{EnsureRoot, limits}; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_consensus_grandpa::AuthorityList as GrandpaAuthorityList; @@ -455,28 +455,12 @@ where type RuntimeCall = RuntimeCall; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { - UncheckedExtrinsic::new_inherent(call) - } -} - -impl frame_system::offchain::CreateSignedTransaction for Test -where - RuntimeCall: From, -{ - fn create_signed_transaction< - C: frame_system::offchain::AppCrypto, - >( - call: >::RuntimeCall, - _public: Self::Public, - _account: Self::AccountId, - nonce: Self::Nonce, - ) -> Option { - Some(UncheckedExtrinsic::new_signed(call, nonce, (), ())) + UncheckedExtrinsic::new_bare(call) } } diff --git a/pallets/commitments/src/mock.rs b/pallets/commitments/src/mock.rs index 24e259b23c..f45e4bd2c2 100644 --- a/pallets/commitments/src/mock.rs +++ b/pallets/commitments/src/mock.rs @@ -3,9 +3,8 @@ use crate as pallet_commitments; use frame_support::{ derive_impl, pallet_prelude::{Get, TypeInfo}, - traits::{ConstU32, ConstU64, InherentBuilder}, + traits::{ConstU32, ConstU64}, }; -use frame_system::offchain::CreateTransactionBase; use sp_core::H256; use sp_runtime::{ BuildStorage, @@ -167,37 +166,12 @@ where type RuntimeCall = RuntimeCall; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { - UncheckedExtrinsic::new_inherent(call) - } -} - -impl frame_system::offchain::CreateSignedTransaction for Test -where - RuntimeCall: From, -{ - fn create_signed_transaction< - C: frame_system::offchain::AppCrypto, - >( - call: >::RuntimeCall, - _public: Self::Public, - _account: Self::AccountId, - nonce: Self::Nonce, - ) -> Option { - // Create a dummy sr25519 signature from a raw byte array - let dummy_raw = [0u8; 64]; - let dummy_signature = sp_core::sr25519::Signature::from(dummy_raw); - let signature = test_crypto::Signature::from(dummy_signature); - Some(UncheckedExtrinsic::new_signed( - call, - nonce.into(), - signature, - (), - )) + UncheckedExtrinsic::new_bare(call) } } diff --git a/pallets/drand/src/lib.rs b/pallets/drand/src/lib.rs index 8666781e56..9b8dd0d1d3 100644 --- a/pallets/drand/src/lib.rs +++ b/pallets/drand/src/lib.rs @@ -43,8 +43,7 @@ use codec::Encode; use frame_support::{pallet_prelude::*, traits::Randomness}; use frame_system::{ offchain::{ - AppCrypto, CreateInherent, CreateSignedTransaction, SendUnsignedTransaction, SignedPayload, - Signer, SigningTypes, + AppCrypto, CreateBare, SendUnsignedTransaction, SignedPayload, Signer, SigningTypes, }, pallet_prelude::BlockNumberFor, }; @@ -159,9 +158,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: - CreateSignedTransaction> + CreateInherent> + frame_system::Config - { + pub trait Config: CreateBare> + SigningTypes + frame_system::Config { /// The identifier type for an offchain worker. type AuthorityId: AppCrypto; /// something that knows how to verify beacon pulses diff --git a/pallets/drand/src/mock.rs b/pallets/drand/src/mock.rs index 0d1a13b77d..20f4886132 100644 --- a/pallets/drand/src/mock.rs +++ b/pallets/drand/src/mock.rs @@ -3,14 +3,14 @@ use crate::verifier::*; use crate::*; use frame_support::{ derive_impl, parameter_types, - traits::{ConstU16, ConstU64, InherentBuilder}, + traits::{ConstU16, ConstU64}, }; use sp_core::{H256, sr25519::Signature}; use sp_keystore::{KeystoreExt, testing::MemoryKeystore}; use sp_runtime::{ BuildStorage, testing::TestXt, - traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, + traits::{BlakeTwo256, IdentityLookup, Verify}, }; type Block = frame_system::mocking::MockBlock; @@ -52,7 +52,6 @@ impl frame_system::Config for Test { } type Extrinsic = TestXt; -type AccountId = <::Signer as IdentifyAccount>::AccountId; impl frame_system::offchain::SigningTypes for Test { type Public = ::Signer; @@ -67,28 +66,12 @@ where type Extrinsic = Extrinsic; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { fn create_bare(call: RuntimeCall) -> Self::Extrinsic { - Extrinsic::new_inherent(call) - } -} - -impl frame_system::offchain::CreateSignedTransaction for Test -where - RuntimeCall: From, -{ - fn create_signed_transaction< - C: frame_system::offchain::AppCrypto, - >( - call: RuntimeCall, - _public: ::Signer, - _account: AccountId, - nonce: u64, - ) -> Option { - Some(Extrinsic::new_signed(call, nonce, (), ())) + Extrinsic::new_bare(call) } } diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index 7af9420ba3..0efc6311ee 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -8,7 +8,7 @@ use core::num::NonZeroU64; use crate::utils::rate_limiting::TransactionType; use crate::*; -use frame_support::traits::{Contains, Everything, InherentBuilder, InsideBoth, InstanceFilter}; +use frame_support::traits::{Contains, Everything, InsideBoth, InstanceFilter}; use frame_support::weights::Weight; use frame_support::weights::constants::RocksDbWeight; use frame_support::{PalletId, derive_impl}; @@ -17,7 +17,7 @@ use frame_support::{ traits::{Hooks, PrivilegeCmp}, }; use frame_system as system; -use frame_system::{EnsureRoot, RawOrigin, limits, offchain::CreateTransactionBase}; +use frame_system::{EnsureRoot, RawOrigin, limits}; use pallet_subtensor_proxy as pallet_proxy; use pallet_subtensor_utility as pallet_utility; use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -542,28 +542,12 @@ where type RuntimeCall = RuntimeCall; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { - UncheckedExtrinsic::new_inherent(call) - } -} - -impl frame_system::offchain::CreateSignedTransaction for Test -where - RuntimeCall: From, -{ - fn create_signed_transaction< - C: frame_system::offchain::AppCrypto, - >( - call: >::RuntimeCall, - _public: Self::Public, - _account: Self::AccountId, - nonce: Self::Nonce, - ) -> Option { - Some(UncheckedExtrinsic::new_signed(call, nonce.into(), (), ())) + UncheckedExtrinsic::new_bare(call) } } diff --git a/pallets/transaction-fee/src/tests/mock.rs b/pallets/transaction-fee/src/tests/mock.rs index e4572bbfea..8870d07733 100644 --- a/pallets/transaction-fee/src/tests/mock.rs +++ b/pallets/transaction-fee/src/tests/mock.rs @@ -5,12 +5,10 @@ use core::num::NonZeroU64; use crate::TransactionFeeHandler; use frame_support::{ PalletId, assert_ok, derive_impl, parameter_types, - traits::{Everything, Hooks, InherentBuilder, PrivilegeCmp}, + traits::{Everything, Hooks, PrivilegeCmp}, weights::IdentityFee, }; -use frame_system::{ - self as system, EnsureRoot, RawOrigin, limits, offchain::CreateTransactionBase, -}; +use frame_system::{self as system, EnsureRoot, RawOrigin, limits}; pub use pallet_subtensor::*; pub use sp_core::U256; use sp_core::{ConstU64, H256}; @@ -506,39 +504,12 @@ where type RuntimeCall = RuntimeCall; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { - UncheckedExtrinsic::new_inherent(call) - } -} - -impl frame_system::offchain::CreateSignedTransaction for Test -where - RuntimeCall: From, -{ - fn create_signed_transaction< - C: frame_system::offchain::AppCrypto, - >( - call: >::RuntimeCall, - _public: Self::Public, - _account: Self::AccountId, - nonce: Self::Nonce, - ) -> Option { - let extra: TransactionExtensions = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(0), - ); - - Some(UncheckedExtrinsic::new_signed( - call, - nonce.into(), - (), - extra, - )) + UncheckedExtrinsic::new_bare(call) } } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 41a00e3f64..ebc249b04d 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -54,7 +54,6 @@ use sp_core::{ crypto::{ByteArray, KeyTypeId}, }; use sp_runtime::Cow; -use sp_runtime::generic::Era; use sp_runtime::{ AccountId32, ApplyExtrinsicResult, ConsensusEngineId, Percent, generic, impl_opaque_keys, traits::{ @@ -153,44 +152,6 @@ impl frame_system::offchain::CreateBare> for Runtime } } -impl frame_system::offchain::CreateSignedTransaction> for Runtime { - fn create_signed_transaction< - S: frame_system::offchain::AppCrypto, - >( - call: RuntimeCall, - public: Self::Public, - account: Self::AccountId, - nonce: Self::Nonce, - ) -> Option { - use sp_runtime::traits::StaticLookup; - - let address = ::Lookup::unlookup(account.clone()); - let extra: TransactionExtensions = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(Era::Immortal), - check_nonce::CheckNonce::::from(nonce).into(), - frame_system::CheckWeight::::new(), - ChargeTransactionPaymentWrapper::new( - pallet_transaction_payment::ChargeTransactionPayment::::from(0), - ), - SudoTransactionExtension::::new(), - pallet_subtensor::SubtensorTransactionExtension::::new(), - pallet_drand::drand_priority::DrandPriority::::new(), - frame_metadata_hash_extension::CheckMetadataHash::::new(true), - ); - - let raw_payload = SignedPayload::new(call.clone(), extra.clone()).ok()?; - let signature = raw_payload.using_encoded(|payload| S::sign(payload, public))?; - - Some(UncheckedExtrinsic::new_signed( - call, address, signature, extra, - )) - } -} - // Subtensor module pub use pallet_scheduler; pub use pallet_subtensor;