diff --git a/polkadot/runtime/common/src/assigned_slots/mod.rs b/polkadot/runtime/common/src/assigned_slots/mod.rs index 71bd85ec20a7d..6e96904a54b17 100644 --- a/polkadot/runtime/common/src/assigned_slots/mod.rs +++ b/polkadot/runtime/common/src/assigned_slots/mod.rs @@ -676,11 +676,11 @@ mod tests { type RuntimeCall = RuntimeCall; } - impl frame_system::offchain::CreateInherent for Test + impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { UncheckedExtrinsic::new_bare(call) } } diff --git a/polkadot/runtime/common/src/integration_tests.rs b/polkadot/runtime/common/src/integration_tests.rs index 8c45a3b58d594..a477ef05f59ac 100644 --- a/polkadot/runtime/common/src/integration_tests.rs +++ b/polkadot/runtime/common/src/integration_tests.rs @@ -106,11 +106,11 @@ where type RuntimeCall = RuntimeCall; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { UncheckedExtrinsic::new_bare(call) } } diff --git a/polkadot/runtime/common/src/paras_registrar/mock.rs b/polkadot/runtime/common/src/paras_registrar/mock.rs index c1c2618b3c13c..44b3a7b679e74 100644 --- a/polkadot/runtime/common/src/paras_registrar/mock.rs +++ b/polkadot/runtime/common/src/paras_registrar/mock.rs @@ -57,11 +57,11 @@ where type RuntimeCall = RuntimeCall; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { UncheckedExtrinsic::new_bare(call) } } diff --git a/polkadot/runtime/parachains/src/disputes/slashing.rs b/polkadot/runtime/parachains/src/disputes/slashing.rs index 95dbf2ba42bb9..59c4e9f5f926d 100644 --- a/polkadot/runtime/parachains/src/disputes/slashing.rs +++ b/polkadot/runtime/parachains/src/disputes/slashing.rs @@ -653,7 +653,7 @@ impl Default for SlashingReportHandler { impl HandleReports for SlashingReportHandler where - T: Config + frame_system::offchain::CreateInherent>, + T: Config + frame_system::offchain::CreateBare>, R: ReportOffence< T::AccountId, T::KeyOwnerIdentification, @@ -685,7 +685,7 @@ where dispute_proof: DisputeProof, key_owner_proof: ::KeyOwnerProof, ) -> Result<(), sp_runtime::TryRuntimeError> { - use frame_system::offchain::{CreateInherent, SubmitTransaction}; + use frame_system::offchain::{CreateBare, SubmitTransaction}; let session_index = dispute_proof.time_slot.session_index; let validator_index = dispute_proof.validator_index.0; @@ -696,7 +696,7 @@ where key_owner_proof, }; - let xt = >>::create_inherent(call.into()); + let xt = >>::create_bare(call.into()); match SubmitTransaction::>::submit_transaction(xt) { Ok(()) => { log::info!( diff --git a/polkadot/runtime/parachains/src/mock.rs b/polkadot/runtime/parachains/src/mock.rs index 74c17d690310a..60606242679bc 100644 --- a/polkadot/runtime/parachains/src/mock.rs +++ b/polkadot/runtime/parachains/src/mock.rs @@ -99,11 +99,11 @@ where type RuntimeCall = RuntimeCall; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { UncheckedExtrinsic::new_bare(call) } } diff --git a/polkadot/runtime/parachains/src/paras/mod.rs b/polkadot/runtime/parachains/src/paras/mod.rs index b31eb5d9967df..c747d02d1d605 100644 --- a/polkadot/runtime/parachains/src/paras/mod.rs +++ b/polkadot/runtime/parachains/src/paras/mod.rs @@ -636,7 +636,7 @@ pub mod pallet { frame_system::Config + configuration::Config + shared::Config - + frame_system::offchain::CreateInherent> + + frame_system::offchain::CreateBare> { #[allow(deprecated)] type RuntimeEvent: From + IsType<::RuntimeEvent>; @@ -2279,7 +2279,7 @@ impl Pallet { ) { use frame_system::offchain::SubmitTransaction; - let xt = T::create_inherent(Call::include_pvf_check_statement { stmt, signature }.into()); + let xt = T::create_bare(Call::include_pvf_check_statement { stmt, signature }.into()); if let Err(e) = SubmitTransaction::>::submit_transaction(xt) { log::error!(target: LOG_TARGET, "Error submitting pvf check statement: {:?}", e,); } diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 68d1b9f1710aa..3362be0c071ea 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -707,11 +707,11 @@ where } } -impl frame_system::offchain::CreateInherent for Runtime +impl frame_system::offchain::CreateBare for Runtime where RuntimeCall: From, { - fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic { + fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic { UncheckedExtrinsic::new_bare(call) } } diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 4d32146c215c1..5aef006ee3d5b 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -179,11 +179,11 @@ where type Extrinsic = UncheckedExtrinsic; } -impl frame_system::offchain::CreateInherent for Runtime +impl frame_system::offchain::CreateBare for Runtime where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { UncheckedExtrinsic::new_bare(call) } } diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 07b63441298f1..86be11d5335cc 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -1065,11 +1065,11 @@ where } } -impl frame_system::offchain::CreateInherent for Runtime +impl frame_system::offchain::CreateBare for Runtime where RuntimeCall: From, { - fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic { + fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic { UncheckedExtrinsic::new_bare(call) } } diff --git a/prdoc/pr_7597.prdoc b/prdoc/pr_7597.prdoc new file mode 100644 index 0000000000000..50bc9c3787d02 --- /dev/null +++ b/prdoc/pr_7597.prdoc @@ -0,0 +1,40 @@ +title: 'Introduce CreateBare, deprecated CreateInherent' +doc: +- audience: Runtime Dev + description: | + Rename `CreateInherent` to `CreateBare`, add method `create_bare` and deprecate `create_inherent`. + + Both unsigned transaction and inherent use the extrinsic type `Bare`. + Before this PR `CreateInherent` trait was use to generate unsigned transaction, now unsigned transaction can be generated using a proper trait `CreateBare`. + + How to upgrade: + * Change usage of `CreateInherent` to `CreateBare` and `create_inherent` to `create_bare`. + * Implement `CreateBare` for the runtime, the method `create_bare` is usually implemented using `Extrinsic::new_bare`. + +crates: +- name: frame-system + bump: major +- name: polkadot-runtime-common + bump: major +- name: polkadot-runtime-parachains + bump: major +- name: rococo-runtime + bump: major +- name: westend-runtime + bump: major +- name: pallet-babe + bump: major +- name: pallet-beefy + bump: major +- name: pallet-election-provider-multi-block + bump: major +- name: pallet-election-provider-multi-phase + bump: major +- name: pallet-grandpa + bump: major +- name: pallet-im-online + bump: major +- name: pallet-mixnet + bump: major +- name: pallet-offences-benchmarking + bump: major diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index e3a400b257349..a67d4c422cee0 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -1571,11 +1571,11 @@ where } } -impl frame_system::offchain::CreateInherent for Runtime +impl frame_system::offchain::CreateBare for Runtime where RuntimeCall: From, { - fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic { + fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic { generic::UncheckedExtrinsic::new_bare(call).into() } } diff --git a/substrate/frame/babe/src/equivocation.rs b/substrate/frame/babe/src/equivocation.rs index 524ad23e58ee1..26279be897fdd 100644 --- a/substrate/frame/babe/src/equivocation.rs +++ b/substrate/frame/babe/src/equivocation.rs @@ -110,7 +110,7 @@ impl OffenceReportSystem, (EquivocationProof>, T::KeyOwnerProof)> for EquivocationReportSystem where - T: Config + pallet_authorship::Config + frame_system::offchain::CreateInherent>, + T: Config + pallet_authorship::Config + frame_system::offchain::CreateBare>, R: ReportOffence< T::AccountId, P::IdentificationTuple, @@ -132,7 +132,7 @@ where equivocation_proof: Box::new(equivocation_proof), key_owner_proof, }; - let xt = T::create_inherent(call.into()); + let xt = T::create_bare(call.into()); let res = SubmitTransaction::>::submit_transaction(xt); match res { Ok(_) => info!(target: LOG_TARGET, "Submitted equivocation report"), diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index dcfcee25e7b88..c620c3eb62fef 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -76,11 +76,11 @@ where type Extrinsic = TestXt; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { TestXt::new_bare(call) } } diff --git a/substrate/frame/beefy/src/equivocation.rs b/substrate/frame/beefy/src/equivocation.rs index 4f25cbb015f10..12fc34a6cbf81 100644 --- a/substrate/frame/beefy/src/equivocation.rs +++ b/substrate/frame/beefy/src/equivocation.rs @@ -282,7 +282,7 @@ impl EquivocationEvidenceFor { impl OffenceReportSystem, EquivocationEvidenceFor> for EquivocationReportSystem where - T: Config + pallet_authorship::Config + frame_system::offchain::CreateInherent>, + T: Config + pallet_authorship::Config + frame_system::offchain::CreateBare>, R: ReportOffence< T::AccountId, P::IdentificationTuple, @@ -298,7 +298,7 @@ where use frame_system::offchain::SubmitTransaction; let call: Call = evidence.into(); - let xt = T::create_inherent(call.into()); + let xt = T::create_bare(call.into()); let res = SubmitTransaction::>::submit_transaction(xt); match res { Ok(_) => info!(target: LOG_TARGET, "Submitted equivocation report."), diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index b069a62b1180e..a7d717e0b1b00 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -81,11 +81,11 @@ where type Extrinsic = TestXt; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { TestXt::new_bare(call) } } diff --git a/substrate/frame/election-provider-multi-block/src/mock/mod.rs b/substrate/frame/election-provider-multi-block/src/mock/mod.rs index 1a208c8bb46a7..0513e01270141 100644 --- a/substrate/frame/election-provider-multi-block/src/mock/mod.rs +++ b/substrate/frame/election-provider-multi-block/src/mock/mod.rs @@ -309,11 +309,11 @@ where type Extrinsic = Extrinsic; } -impl frame_system::offchain::CreateInherent for Runtime +impl frame_system::offchain::CreateBare for Runtime where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { Extrinsic::new_bare(call) } } diff --git a/substrate/frame/election-provider-multi-block/src/unsigned/miner.rs b/substrate/frame/election-provider-multi-block/src/unsigned/miner.rs index 946952ca8c232..bef8f86cfa1bc 100644 --- a/substrate/frame/election-provider-multi-block/src/unsigned/miner.rs +++ b/substrate/frame/election-provider-multi-block/src/unsigned/miner.rs @@ -785,7 +785,7 @@ impl OffchainWorkerMiner { "unsigned::ocw-miner", "miner submitting a solution as an unsigned transaction" ); - let xt = T::create_inherent(call.into()); + let xt = T::create_bare(call.into()); frame_system::offchain::SubmitTransaction::>::submit_transaction(xt) .map(|_| { sublog!( diff --git a/substrate/frame/election-provider-multi-block/src/unsigned/mod.rs b/substrate/frame/election-provider-multi-block/src/unsigned/mod.rs index 18ba2370683ce..5ab23b9e965f8 100644 --- a/substrate/frame/election-provider-multi-block/src/unsigned/mod.rs +++ b/substrate/frame/election-provider-multi-block/src/unsigned/mod.rs @@ -89,7 +89,7 @@ mod pallet { CommonError, }; use frame_support::pallet_prelude::*; - use frame_system::{offchain::CreateInherent, pallet_prelude::*}; + use frame_system::{offchain::CreateBare, pallet_prelude::*}; use sp_runtime::traits::SaturatedConversion; use sp_std::prelude::*; @@ -104,7 +104,7 @@ mod pallet { #[pallet::config] #[pallet::disable_frame_system_supertrait_check] - pub trait Config: crate::Config + CreateInherent> { + pub trait Config: crate::Config + CreateBare> { /// The repeat threshold of the offchain worker. /// /// For example, if it is 5, that means that at least 5 blocks will elapse between attempts diff --git a/substrate/frame/election-provider-multi-phase/src/lib.rs b/substrate/frame/election-provider-multi-phase/src/lib.rs index 68a452e5d798e..f657475780bd9 100644 --- a/substrate/frame/election-provider-multi-phase/src/lib.rs +++ b/substrate/frame/election-provider-multi-phase/src/lib.rs @@ -257,7 +257,7 @@ use frame_support::{ weights::Weight, DefaultNoBound, EqNoBound, PartialEqNoBound, }; -use frame_system::{ensure_none, offchain::CreateInherent, pallet_prelude::BlockNumberFor}; +use frame_system::{ensure_none, offchain::CreateBare, pallet_prelude::BlockNumberFor}; use scale_info::TypeInfo; use sp_arithmetic::{ traits::{CheckedAdd, Zero}, @@ -615,7 +615,7 @@ pub mod pallet { use sp_runtime::traits::Convert; #[pallet::config] - pub trait Config: frame_system::Config + CreateInherent> { + pub trait Config: frame_system::Config + CreateBare> { #[allow(deprecated)] type RuntimeEvent: From> + IsType<::RuntimeEvent> diff --git a/substrate/frame/election-provider-multi-phase/src/mock.rs b/substrate/frame/election-provider-multi-phase/src/mock.rs index c23d226f84780..c3ae993a7c5b8 100644 --- a/substrate/frame/election-provider-multi-phase/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/src/mock.rs @@ -459,11 +459,11 @@ where type Extrinsic = Extrinsic; } -impl frame_system::offchain::CreateInherent for Runtime +impl frame_system::offchain::CreateBare for Runtime where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { Extrinsic::new_bare(call) } } diff --git a/substrate/frame/election-provider-multi-phase/src/unsigned.rs b/substrate/frame/election-provider-multi-phase/src/unsigned.rs index 84f948d556b8f..f78589c4dd2ad 100644 --- a/substrate/frame/election-provider-multi-phase/src/unsigned.rs +++ b/substrate/frame/election-provider-multi-phase/src/unsigned.rs @@ -32,7 +32,7 @@ use frame_support::{ BoundedVec, }; use frame_system::{ - offchain::{CreateInherent, SubmitTransaction}, + offchain::{CreateBare, SubmitTransaction}, pallet_prelude::BlockNumberFor, }; use scale_info::TypeInfo; @@ -192,7 +192,7 @@ fn ocw_solution_exists() -> bool { matches!(StorageValueRef::persistent(OFFCHAIN_CACHED_CALL).get::>(), Ok(Some(_))) } -impl>> Pallet { +impl>> Pallet { /// Mine a new npos solution. /// /// The Npos Solver type, `S`, must have the same AccountId and Error type as the @@ -292,7 +292,7 @@ impl>> Pallet { fn submit_call(call: Call) -> Result<(), MinerError> { log!(debug, "miner submitting a solution as an unsigned transaction"); - let xt = T::create_inherent(call.into()); + let xt = T::create_bare(call.into()); SubmitTransaction::>::submit_transaction(xt) .map_err(|_| MinerError::PoolSubmissionFailed) } diff --git a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index 88224f68edd45..292ade8b3f8c3 100644 --- a/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -350,11 +350,11 @@ where type Extrinsic = Extrinsic; } -impl frame_system::offchain::CreateInherent for Runtime +impl frame_system::offchain::CreateBare for Runtime where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { Extrinsic::new_bare(call) } } diff --git a/substrate/frame/examples/offchain-worker/src/lib.rs b/substrate/frame/examples/offchain-worker/src/lib.rs index 92215f49bd8bc..ee0a52eea4451 100644 --- a/substrate/frame/examples/offchain-worker/src/lib.rs +++ b/substrate/frame/examples/offchain-worker/src/lib.rs @@ -59,7 +59,7 @@ use frame_support::traits::Get; use frame_system::{ self as system, offchain::{ - AppCrypto, CreateInherent, CreateSignedTransaction, SendSignedTransaction, + AppCrypto, CreateBare, CreateSignedTransaction, SendSignedTransaction, SendUnsignedTransaction, SignedPayload, Signer, SigningTypes, SubmitTransaction, }, pallet_prelude::BlockNumberFor, @@ -131,7 +131,7 @@ pub mod pallet { /// This pallet's configuration trait #[pallet::config] pub trait Config: - CreateSignedTransaction> + CreateInherent> + frame_system::Config + CreateSignedTransaction> + CreateBare> + frame_system::Config { /// The identifier type for an offchain worker. type AuthorityId: AppCrypto; @@ -508,7 +508,7 @@ impl Pallet { // implement unsigned validation logic, as any mistakes can lead to opening DoS or spam // attack vectors. See validation logic docs for more details. // - let xt = T::create_inherent(call.into()); + let xt = T::create_bare(call.into()); SubmitTransaction::>::submit_transaction(xt) .map_err(|()| "Unable to submit unsigned transaction.")?; diff --git a/substrate/frame/examples/offchain-worker/src/tests.rs b/substrate/frame/examples/offchain-worker/src/tests.rs index a8af7d2e31147..230873a2dca57 100644 --- a/substrate/frame/examples/offchain-worker/src/tests.rs +++ b/substrate/frame/examples/offchain-worker/src/tests.rs @@ -121,11 +121,11 @@ where } } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { Extrinsic::new_bare(call) } } diff --git a/substrate/frame/examples/tasks/src/lib.rs b/substrate/frame/examples/tasks/src/lib.rs index 7d51617497d65..6b3b4adbacfaa 100644 --- a/substrate/frame/examples/tasks/src/lib.rs +++ b/substrate/frame/examples/tasks/src/lib.rs @@ -19,7 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::dispatch::DispatchResult; -use frame_system::offchain::CreateInherent; +use frame_system::offchain::CreateBare; #[cfg(feature = "experimental")] use frame_system::offchain::SubmitTransaction; // Re-export pallet items so that they can be accessed from the crate namespace. @@ -77,7 +77,7 @@ pub mod pallet { let call = frame_system::Call::::do_task { task: runtime_task.into() }; // Submit the task as an unsigned transaction - let xt = >>::create_inherent(call.into()); + let xt = >>::create_bare(call.into()); let res = SubmitTransaction::>::submit_transaction(xt); match res { Ok(_) => log::info!(target: LOG_TARGET, "Submitted the task."), @@ -91,7 +91,7 @@ pub mod pallet { } #[pallet::config] - pub trait Config: CreateInherent> + frame_system::Config { + pub trait Config: CreateBare> + frame_system::Config { type RuntimeTask: frame_support::traits::Task + IsType<::RuntimeTask> + From>; diff --git a/substrate/frame/examples/tasks/src/mock.rs b/substrate/frame/examples/tasks/src/mock.rs index 3dc9153c94a06..e6053dfe56dff 100644 --- a/substrate/frame/examples/tasks/src/mock.rs +++ b/substrate/frame/examples/tasks/src/mock.rs @@ -48,11 +48,11 @@ where type Extrinsic = Extrinsic; } -impl frame_system::offchain::CreateInherent for Runtime +impl frame_system::offchain::CreateBare for Runtime where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { Extrinsic::new_bare(call) } } diff --git a/substrate/frame/grandpa/src/equivocation.rs b/substrate/frame/grandpa/src/equivocation.rs index 4ebdbc1eecd30..029540d2aeacf 100644 --- a/substrate/frame/grandpa/src/equivocation.rs +++ b/substrate/frame/grandpa/src/equivocation.rs @@ -122,7 +122,7 @@ impl (EquivocationProof>, T::KeyOwnerProof), > for EquivocationReportSystem where - T: Config + pallet_authorship::Config + frame_system::offchain::CreateInherent>, + T: Config + pallet_authorship::Config + frame_system::offchain::CreateBare>, R: ReportOffence< T::AccountId, P::IdentificationTuple, @@ -144,7 +144,7 @@ where equivocation_proof: Box::new(equivocation_proof), key_owner_proof, }; - let xt = T::create_inherent(call.into()); + let xt = T::create_bare(call.into()); let res = SubmitTransaction::>::submit_transaction(xt); match res { Ok(_) => info!(target: LOG_TARGET, "Submitted equivocation report"), diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index 034858c70e167..bf1b05ec11c36 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -80,11 +80,11 @@ where type Extrinsic = TestXt; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { TestXt::new_bare(call) } } diff --git a/substrate/frame/im-online/src/lib.rs b/substrate/frame/im-online/src/lib.rs index 3eb9d5cc57b0a..6358fc600a36b 100644 --- a/substrate/frame/im-online/src/lib.rs +++ b/substrate/frame/im-online/src/lib.rs @@ -95,7 +95,7 @@ use frame_support::{ BoundedSlice, WeakBoundedVec, }; use frame_system::{ - offchain::{CreateInherent, SubmitTransaction}, + offchain::{CreateBare, SubmitTransaction}, pallet_prelude::*, }; pub use pallet::*; @@ -261,7 +261,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: CreateInherent> + frame_system::Config { + pub trait Config: CreateBare> + frame_system::Config { /// The identifier type for an authority. type AuthorityId: Member + Parameter @@ -643,7 +643,7 @@ impl Pallet { call, ); - let xt = T::create_inherent(call.into()); + let xt = T::create_bare(call.into()); SubmitTransaction::>::submit_transaction(xt) .map_err(|_| OffchainErr::SubmitTransaction)?; diff --git a/substrate/frame/im-online/src/mock.rs b/substrate/frame/im-online/src/mock.rs index 11f5e1548101f..80834c68a216b 100644 --- a/substrate/frame/im-online/src/mock.rs +++ b/substrate/frame/im-online/src/mock.rs @@ -197,11 +197,11 @@ where type Extrinsic = Extrinsic; } -impl frame_system::offchain::CreateInherent for Runtime +impl frame_system::offchain::CreateBare for Runtime where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { Extrinsic::new_bare(call) } } diff --git a/substrate/frame/mixnet/src/lib.rs b/substrate/frame/mixnet/src/lib.rs index 7e728b8fba3fd..401f42fc8b08f 100644 --- a/substrate/frame/mixnet/src/lib.rs +++ b/substrate/frame/mixnet/src/lib.rs @@ -179,7 +179,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + CreateInherent> { + pub trait Config: frame_system::Config + CreateBare> { /// The maximum number of authorities per session. #[pallet::constant] type MaxAuthorities: Get; @@ -532,7 +532,7 @@ impl Pallet { return false; }; let call = Call::register { registration, signature }; - let xt = T::create_inherent(call.into()); + let xt = T::create_bare(call.into()); match SubmitTransaction::>::submit_transaction(xt) { Ok(()) => true, Err(()) => { diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index 031cf81cef987..61a8cf53533a9 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -169,11 +169,11 @@ where type RuntimeCall = RuntimeCall; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { UncheckedExtrinsic::new_bare(call) } } diff --git a/substrate/frame/sassafras/src/lib.rs b/substrate/frame/sassafras/src/lib.rs index 35539fd35f22c..94a8125112ea3 100644 --- a/substrate/frame/sassafras/src/lib.rs +++ b/substrate/frame/sassafras/src/lib.rs @@ -61,7 +61,7 @@ use frame_support::{ BoundedVec, WeakBoundedVec, }; use frame_system::{ - offchain::{CreateInherent, SubmitTransaction}, + offchain::{CreateBare, SubmitTransaction}, pallet_prelude::BlockNumberFor, }; use sp_consensus_sassafras::{ @@ -128,7 +128,7 @@ pub mod pallet { /// Configuration parameters. #[pallet::config] - pub trait Config: frame_system::Config + CreateInherent> { + pub trait Config: frame_system::Config + CreateBare> { /// Amount of slots that each epoch should last. #[pallet::constant] type EpochLength: Get; @@ -1001,7 +1001,7 @@ impl Pallet { pub fn submit_tickets_unsigned_extrinsic(tickets: Vec) -> bool { let tickets = BoundedVec::truncate_from(tickets); let call = Call::submit_tickets { tickets }; - let xt = T::create_inherent(call.into()); + let xt = T::create_bare(call.into()); match SubmitTransaction::>::submit_transaction(xt) { Ok(_) => true, Err(e) => { diff --git a/substrate/frame/sassafras/src/mock.rs b/substrate/frame/sassafras/src/mock.rs index aa190a8ce5039..db20f3a5bd243 100644 --- a/substrate/frame/sassafras/src/mock.rs +++ b/substrate/frame/sassafras/src/mock.rs @@ -56,11 +56,11 @@ where type Extrinsic = frame_system::mocking::MockUncheckedExtrinsic; } -impl frame_system::offchain::CreateInherent for Test +impl frame_system::offchain::CreateBare for Test where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { frame_system::mocking::MockUncheckedExtrinsic::::new_bare(call) } } diff --git a/substrate/frame/staking-async/ahm-test/src/ah/mock.rs b/substrate/frame/staking-async/ahm-test/src/ah/mock.rs index ab3c5d0392887..9f0054f67a1c3 100644 --- a/substrate/frame/staking-async/ahm-test/src/ah/mock.rs +++ b/substrate/frame/staking-async/ahm-test/src/ah/mock.rs @@ -195,11 +195,11 @@ where type Extrinsic = Extrinsic; } -impl frame_system::offchain::CreateInherent for Runtime +impl frame_system::offchain::CreateBare for Runtime where RuntimeCall: From, { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { Extrinsic::new_bare(call) } } diff --git a/substrate/frame/staking-async/runtimes/parachain/src/staking.rs b/substrate/frame/staking-async/runtimes/parachain/src/staking.rs index d1f2a71015e15..d57a6ee31b282 100644 --- a/substrate/frame/staking-async/runtimes/parachain/src/staking.rs +++ b/substrate/frame/staking-async/runtimes/parachain/src/staking.rs @@ -470,7 +470,7 @@ impl frame_system::offchain::CreateInherent for Runtime where RuntimeCall: From, { - fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic { + fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic { UncheckedExtrinsic::new_bare(call) } } diff --git a/substrate/frame/staking-async/runtimes/rc/src/lib.rs b/substrate/frame/staking-async/runtimes/rc/src/lib.rs index d7e8002b3b253..5bf9cf1e0f954 100644 --- a/substrate/frame/staking-async/runtimes/rc/src/lib.rs +++ b/substrate/frame/staking-async/runtimes/rc/src/lib.rs @@ -1049,7 +1049,7 @@ impl frame_system::offchain::CreateInherent for Runtime where RuntimeCall: From, { - fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic { + fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic { UncheckedExtrinsic::new_bare(call) } } diff --git a/substrate/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr b/substrate/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr index 9608fa58e3c98..362c02f1ab3e0 100644 --- a/substrate/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr +++ b/substrate/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr @@ -33,7 +33,7 @@ error[E0599]: no function or associated item named `create_inherent` found for s | = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `create_inherent`, perhaps you need to implement one of them: - candidate #1: `CreateInherent` + candidate #1: `CreateBare` candidate #2: `ProvideInherent` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/substrate/frame/system/src/offchain.rs b/substrate/frame/system/src/offchain.rs index 36504a81125af..64ba3df24ac0f 100644 --- a/substrate/frame/system/src/offchain.rs +++ b/substrate/frame/system/src/offchain.rs @@ -273,11 +273,8 @@ impl< } } -impl< - T: SigningTypes + CreateInherent, - C: AppCrypto, - LocalCall, - > SendUnsignedTransaction for Signer +impl, C: AppCrypto, LocalCall> + SendUnsignedTransaction for Signer { type Result = Option<(Account, Result<(), ()>)>; @@ -299,11 +296,8 @@ impl< } } -impl< - T: SigningTypes + CreateInherent, - C: AppCrypto, - LocalCall, - > SendUnsignedTransaction for Signer +impl, C: AppCrypto, LocalCall> + SendUnsignedTransaction for Signer { type Result = Vec<(Account, Result<(), ()>)>; @@ -488,10 +482,29 @@ pub trait CreateSignedTransaction: ) -> Option; } -/// Interface for creating an inherent. -pub trait CreateInherent: CreateTransactionBase { +/// Interface for creating an inherent; ⚠️ **Deprecated use [`CreateBare`]**. +/// +/// This is a deprecated type alias for [`CreateBare`]. +/// +/// Doc for [`CreateBare`]: +#[deprecated(note = "Use `CreateBare` instead")] +#[doc(inline)] +pub use CreateBare as CreateInherent; + +/// Interface for creating a bare extrinsic. +/// +/// Bare extrinsic are used for inherent extrinsic and unsigned transaction. +pub trait CreateBare: CreateTransactionBase { + /// Create a bare extrinsic. + /// + /// Bare extrinsic are used for inherent extrinsic and unsigned transaction. + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic; + /// Create an inherent. - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic; + #[deprecated(note = "Use `create_bare` instead")] + fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + Self::create_bare(call) + } } /// A message signer. @@ -594,7 +607,7 @@ pub trait SendSignedTransaction< } /// Submit an unsigned transaction onchain with a signed payload -pub trait SendUnsignedTransaction, LocalCall> { +pub trait SendUnsignedTransaction, LocalCall> { /// A submission result. /// /// Should contain the submission result and the account(s) that signed the payload. @@ -617,7 +630,7 @@ pub trait SendUnsignedTransaction, L /// Submits an unsigned call to the transaction pool. fn submit_unsigned_transaction(&self, call: LocalCall) -> Option> { - let xt = T::create_inherent(call.into()); + let xt = T::create_bare(call.into()); Some(SubmitTransaction::::submit_transaction(xt)) } } @@ -663,8 +676,8 @@ mod tests { type RuntimeCall = RuntimeCall; } - impl CreateInherent for TestRuntime { - fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic { + impl CreateBare for TestRuntime { + fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic { Extrinsic::new_bare(call) } }