Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce CreateBare, deprecated CreateInherent #7597

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions polkadot/runtime/common/src/assigned_slots/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,11 @@ mod tests {
type RuntimeCall = RuntimeCall;
}

impl<C> frame_system::offchain::CreateInherent<C> for Test
impl<C> frame_system::offchain::CreateBare<C> for Test
where
RuntimeCall: From<C>,
{
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
UncheckedExtrinsic::new_bare(call)
}
}
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/common/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ where
type RuntimeCall = RuntimeCall;
}

impl<C> frame_system::offchain::CreateInherent<C> for Test
impl<C> frame_system::offchain::CreateBare<C> for Test
where
RuntimeCall: From<C>,
{
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
UncheckedExtrinsic::new_bare(call)
}
}
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/common/src/paras_registrar/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ where
type RuntimeCall = RuntimeCall;
}

impl<C> frame_system::offchain::CreateInherent<C> for Test
impl<C> frame_system::offchain::CreateBare<C> for Test
where
RuntimeCall: From<C>,
{
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
UncheckedExtrinsic::new_bare(call)
}
}
Expand Down
6 changes: 3 additions & 3 deletions polkadot/runtime/parachains/src/disputes/slashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ impl<I, R, L> Default for SlashingReportHandler<I, R, L> {

impl<T, R, L> HandleReports<T> for SlashingReportHandler<T::KeyOwnerIdentification, R, L>
where
T: Config + frame_system::offchain::CreateInherent<Call<T>>,
T: Config + frame_system::offchain::CreateBare<Call<T>>,
R: ReportOffence<
T::AccountId,
T::KeyOwnerIdentification,
Expand Down Expand Up @@ -685,7 +685,7 @@ where
dispute_proof: DisputeProof,
key_owner_proof: <T as Config>::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;
Expand All @@ -696,7 +696,7 @@ where
key_owner_proof,
};

let xt = <T as CreateInherent<Call<T>>>::create_inherent(call.into());
let xt = <T as CreateBare<Call<T>>>::create_bare(call.into());
match SubmitTransaction::<T, Call<T>>::submit_transaction(xt) {
Ok(()) => {
log::info!(
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ where
type RuntimeCall = RuntimeCall;
}

impl<C> frame_system::offchain::CreateInherent<C> for Test
impl<C> frame_system::offchain::CreateBare<C> for Test
where
RuntimeCall: From<C>,
{
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
UncheckedExtrinsic::new_bare(call)
}
}
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/parachains/src/paras/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ pub mod pallet {
frame_system::Config
+ configuration::Config
+ shared::Config
+ frame_system::offchain::CreateInherent<Call<Self>>
+ frame_system::offchain::CreateBare<Call<Self>>
{
type RuntimeEvent: From<Event> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

Expand Down Expand Up @@ -2188,7 +2188,7 @@ impl<T: Config> Pallet<T> {
) {
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::<T, Call<T>>::submit_transaction(xt) {
log::error!(target: LOG_TARGET, "Error submitting pvf check statement: {:?}", e,);
}
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,11 @@ where
}
}

impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic {
fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic {
UncheckedExtrinsic::new_bare(call)
}
}
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ where
type Extrinsic = UncheckedExtrinsic;
}

impl<C> frame_system::offchain::CreateInherent<C> for Runtime
impl<C> frame_system::offchain::CreateBare<C> for Runtime
where
RuntimeCall: From<C>,
{
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
UncheckedExtrinsic::new_bare(call)
}
}
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,11 +955,11 @@ where
}
}

impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic {
fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic {
UncheckedExtrinsic::new_bare(call)
}
}
Expand Down
40 changes: 40 additions & 0 deletions prdoc/pr_7597.prdoc
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1803,11 +1803,11 @@ where
}
}

impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic {
fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic {
generic::UncheckedExtrinsic::new_bare(call).into()
}
}
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/babe/src/equivocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<T, R, P, L>
OffenceReportSystem<Option<T::AccountId>, (EquivocationProof<HeaderFor<T>>, T::KeyOwnerProof)>
for EquivocationReportSystem<T, R, P, L>
where
T: Config + pallet_authorship::Config + frame_system::offchain::CreateInherent<Call<T>>,
T: Config + pallet_authorship::Config + frame_system::offchain::CreateBare<Call<T>>,
R: ReportOffence<
T::AccountId,
P::IdentificationTuple,
Expand All @@ -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::<T, Call<T>>::submit_transaction(xt);
match res {
Ok(_) => info!(target: LOG_TARGET, "Submitted equivocation report"),
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ where
type Extrinsic = TestXt<RuntimeCall, ()>;
}

impl<C> frame_system::offchain::CreateInherent<C> for Test
impl<C> frame_system::offchain::CreateBare<C> for Test
where
RuntimeCall: From<C>,
{
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
TestXt::new_bare(call)
}
}
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/beefy/src/equivocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl<T: Config> EquivocationEvidenceFor<T> {
impl<T, R, P, L> OffenceReportSystem<Option<T::AccountId>, EquivocationEvidenceFor<T>>
for EquivocationReportSystem<T, R, P, L>
where
T: Config + pallet_authorship::Config + frame_system::offchain::CreateInherent<Call<T>>,
T: Config + pallet_authorship::Config + frame_system::offchain::CreateBare<Call<T>>,
R: ReportOffence<
T::AccountId,
P::IdentificationTuple,
Expand All @@ -284,7 +284,7 @@ where
use frame_system::offchain::SubmitTransaction;

let call: Call<T> = evidence.into();
let xt = T::create_inherent(call.into());
let xt = T::create_bare(call.into());
let res = SubmitTransaction::<T, Call<T>>::submit_transaction(xt);
match res {
Ok(_) => info!(target: LOG_TARGET, "Submitted equivocation report."),
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ where
type Extrinsic = TestXt<RuntimeCall, ()>;
}

impl<C> frame_system::offchain::CreateInherent<C> for Test
impl<C> frame_system::offchain::CreateBare<C> for Test
where
RuntimeCall: From<C>,
{
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
TestXt::new_bare(call)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ where
type Extrinsic = Extrinsic;
}

impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
Extrinsic::new_bare(call)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ impl<T: Config> OffchainWorkerMiner<T> {
"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::<T, Call<T>>::submit_transaction(xt)
.map(|_| {
sublog!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand All @@ -104,7 +104,7 @@ mod pallet {

#[pallet::config]
#[pallet::disable_frame_system_supertrait_check]
pub trait Config: crate::Config + CreateInherent<Call<Self>> {
pub trait Config: crate::Config + CreateBare<Call<Self>> {
/// The repeat threshold of the offchain worker.
///
/// For example, if it is 5, that means that at least 5 blocks will elapse between attempts
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/election-provider-multi-phase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -612,7 +612,7 @@ pub mod pallet {
use sp_runtime::traits::Convert;

#[pallet::config]
pub trait Config: frame_system::Config + CreateInherent<Call<Self>> {
pub trait Config: frame_system::Config + CreateBare<Call<Self>> {
type RuntimeEvent: From<Event<Self>>
+ IsType<<Self as frame_system::Config>::RuntimeEvent>
+ TryInto<Event<Self>>;
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/election-provider-multi-phase/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@ where
type Extrinsic = Extrinsic;
}

impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
Extrinsic::new_bare(call)
}
}
Expand Down
6 changes: 3 additions & 3 deletions substrate/frame/election-provider-multi-phase/src/unsigned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use frame_support::{
BoundedVec,
};
use frame_system::{
offchain::{CreateInherent, SubmitTransaction},
offchain::{CreateBare, SubmitTransaction},
pallet_prelude::BlockNumberFor,
};
use scale_info::TypeInfo;
Expand Down Expand Up @@ -192,7 +192,7 @@ fn ocw_solution_exists<T: Config>() -> bool {
matches!(StorageValueRef::persistent(OFFCHAIN_CACHED_CALL).get::<Call<T>>(), Ok(Some(_)))
}

impl<T: Config + CreateInherent<Call<T>>> Pallet<T> {
impl<T: Config + CreateBare<Call<T>>> Pallet<T> {
/// Mine a new npos solution.
///
/// The Npos Solver type, `S`, must have the same AccountId and Error type as the
Expand Down Expand Up @@ -292,7 +292,7 @@ impl<T: Config + CreateInherent<Call<T>>> Pallet<T> {
fn submit_call(call: Call<T>) -> 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::<T, Call<T>>::submit_transaction(xt)
.map_err(|_| MinerError::PoolSubmissionFailed)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,11 @@ where
type Extrinsic = Extrinsic;
}

impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
Extrinsic::new_bare(call)
}
}
Expand Down
Loading
Loading