diff --git a/polkadot/runtime/common/src/assigned_slots/mod.rs b/polkadot/runtime/common/src/assigned_slots/mod.rs index dcde616392b8a..903597e220aff 100644 --- a/polkadot/runtime/common/src/assigned_slots/mod.rs +++ b/polkadot/runtime/common/src/assigned_slots/mod.rs @@ -675,11 +675,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 bb4ad8b75065c..9bfb61bc7d6c2 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 bb3728f0e12a0..d5171e4a2d09e 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 0ab2737640604..dde7f7b4c24dc 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 87744fc5ae3e1..27d5266abab6a 100644 --- a/polkadot/runtime/parachains/src/paras/mod.rs +++ b/polkadot/runtime/parachains/src/paras/mod.rs @@ -626,7 +626,7 @@ pub mod pallet { frame_system::Config + configuration::Config + shared::Config - + frame_system::offchain::CreateInherent> + + frame_system::offchain::CreateBare> { type RuntimeEvent: From + IsType<::RuntimeEvent>; @@ -2188,7 +2188,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 4123a6a1a3558..a10ade2d809d4 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -705,11 +705,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 fc489e3bc685e..2b72c60eb7250 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 5af67ad9bd70a..731e326d05185 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -955,11 +955,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 7e33f1feeca19..11d2486c6d2c3 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -1803,11 +1803,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 ea977a547fee8..f57bc8feec15f 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 294d64427ef8a..e008b0c4206ea 100644 --- a/substrate/frame/beefy/src/equivocation.rs +++ b/substrate/frame/beefy/src/equivocation.rs @@ -268,7 +268,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, @@ -284,7 +284,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 275bf18fe873d..3169962246ca9 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 5c68494f66b57..632c03e60fb2c 100644 --- a/substrate/frame/election-provider-multi-block/src/mock/mod.rs +++ b/substrate/frame/election-provider-multi-block/src/mock/mod.rs @@ -279,11 +279,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 cccfef1398358..2ad4609ecb23f 100644 --- a/substrate/frame/election-provider-multi-block/src/unsigned/miner.rs +++ b/substrate/frame/election-provider-multi-block/src/unsigned/miner.rs @@ -736,7 +736,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 ca6766efd9062..37f25b2dd3caa 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 c0e256c3e6525..6ab9942ca53d8 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}, @@ -612,7 +612,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> { type RuntimeEvent: From> + IsType<::RuntimeEvent> + TryInto>; diff --git a/substrate/frame/election-provider-multi-phase/src/mock.rs b/substrate/frame/election-provider-multi-phase/src/mock.rs index d244af0b40394..b9cf7f0beb9bf 100644 --- a/substrate/frame/election-provider-multi-phase/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/src/mock.rs @@ -451,11 +451,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 5aabc3454d4df..16fa3d2dbc5e5 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 120deff96a75e..e52ab56a651a6 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 @@ -349,11 +349,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 9976a5256afa9..6a2265ba9f495 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; @@ -511,7 +511,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 cc226714e6e9e..64f10139f18ae 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 482e767d32fc0..3b814b298636f 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 28d97489d9814..d02f61d795b8c 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 @@ -642,7 +642,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 4ccbde1931478..1cedaec257070 100644 --- a/substrate/frame/im-online/src/mock.rs +++ b/substrate/frame/im-online/src/mock.rs @@ -196,11 +196,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 63e440d9e0042..6c7dda7153036 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -168,11 +168,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/revive/rpc/build.rs b/substrate/frame/revive/rpc/build.rs index d2ea601211a00..a5c227150d184 100644 --- a/substrate/frame/revive/rpc/build.rs +++ b/substrate/frame/revive/rpc/build.rs @@ -33,12 +33,12 @@ fn main() { .join(""); let target = std::env::var("TARGET").unwrap_or_else(|_| "unknown".to_string()); - let repo = git2::Repository::open("../../../..").expect("should be a repository"); - let head = repo.head().expect("should have head"); - let commit = head.peel_to_commit().expect("should have commit"); - let branch = head.shorthand().unwrap_or("unknown").to_string(); - let id = &commit.id().to_string()[..7]; - println!("cargo:rustc-env=GIT_REVISION={branch}-{id}"); + // let repo = git2::Repository::open("../../../..").expect("should be a repository"); + // let head = repo.head().expect("should have head"); + // let commit = head.peel_to_commit().expect("should have commit"); + // let branch = head.shorthand().unwrap_or("unknown").to_string(); + // let id = &commit.id().to_string()[..7]; + println!("cargo:rustc-env=GIT_REVISION=no-0"); println!("cargo:rustc-env=RUSTC_VERSION={rustc_version}"); println!("cargo:rustc-env=TARGET={target}"); } diff --git a/substrate/frame/sassafras/src/lib.rs b/substrate/frame/sassafras/src/lib.rs index f6c409833e333..e18de167a88bb 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::{ @@ -131,7 +131,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; @@ -1020,7 +1020,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 d7e2fb63dc2f4..6800c1e94bada 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/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 bedfdded81835..9b010c28f729d 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,27 @@ pub trait CreateSignedTransaction: ) -> Option; } -/// Interface for creating an inherent. -pub trait CreateInherent: CreateTransactionBase { +/// Interface for creating an inherent; ⚠️ **Deprecated use [`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. @@ -571,7 +582,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. @@ -594,7 +605,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)) } } @@ -640,8 +651,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) } }