Skip to content

Commit 7b3f1d6

Browse files
gui1117github-actions[bot]
authored andcommitted
Introduce CreateBare, deprecated CreateInherent (#7597)
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`. --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent e3f4cea commit 7b3f1d6

39 files changed

Lines changed: 146 additions & 93 deletions

File tree

polkadot/runtime/common/src/assigned_slots/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,11 +676,11 @@ mod tests {
676676
type RuntimeCall = RuntimeCall;
677677
}
678678

679-
impl<C> frame_system::offchain::CreateInherent<C> for Test
679+
impl<C> frame_system::offchain::CreateBare<C> for Test
680680
where
681681
RuntimeCall: From<C>,
682682
{
683-
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
683+
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
684684
UncheckedExtrinsic::new_bare(call)
685685
}
686686
}

polkadot/runtime/common/src/integration_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ where
106106
type RuntimeCall = RuntimeCall;
107107
}
108108

109-
impl<C> frame_system::offchain::CreateInherent<C> for Test
109+
impl<C> frame_system::offchain::CreateBare<C> for Test
110110
where
111111
RuntimeCall: From<C>,
112112
{
113-
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
113+
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
114114
UncheckedExtrinsic::new_bare(call)
115115
}
116116
}

polkadot/runtime/common/src/paras_registrar/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ where
5757
type RuntimeCall = RuntimeCall;
5858
}
5959

60-
impl<C> frame_system::offchain::CreateInherent<C> for Test
60+
impl<C> frame_system::offchain::CreateBare<C> for Test
6161
where
6262
RuntimeCall: From<C>,
6363
{
64-
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
64+
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
6565
UncheckedExtrinsic::new_bare(call)
6666
}
6767
}

polkadot/runtime/parachains/src/disputes/slashing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ impl<I, R, L> Default for SlashingReportHandler<I, R, L> {
653653

654654
impl<T, R, L> HandleReports<T> for SlashingReportHandler<T::KeyOwnerIdentification, R, L>
655655
where
656-
T: Config + frame_system::offchain::CreateInherent<Call<T>>,
656+
T: Config + frame_system::offchain::CreateBare<Call<T>>,
657657
R: ReportOffence<
658658
T::AccountId,
659659
T::KeyOwnerIdentification,
@@ -685,7 +685,7 @@ where
685685
dispute_proof: DisputeProof,
686686
key_owner_proof: <T as Config>::KeyOwnerProof,
687687
) -> Result<(), sp_runtime::TryRuntimeError> {
688-
use frame_system::offchain::{CreateInherent, SubmitTransaction};
688+
use frame_system::offchain::{CreateBare, SubmitTransaction};
689689

690690
let session_index = dispute_proof.time_slot.session_index;
691691
let validator_index = dispute_proof.validator_index.0;
@@ -696,7 +696,7 @@ where
696696
key_owner_proof,
697697
};
698698

699-
let xt = <T as CreateInherent<Call<T>>>::create_inherent(call.into());
699+
let xt = <T as CreateBare<Call<T>>>::create_bare(call.into());
700700
match SubmitTransaction::<T, Call<T>>::submit_transaction(xt) {
701701
Ok(()) => {
702702
log::info!(

polkadot/runtime/parachains/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ where
9999
type RuntimeCall = RuntimeCall;
100100
}
101101

102-
impl<C> frame_system::offchain::CreateInherent<C> for Test
102+
impl<C> frame_system::offchain::CreateBare<C> for Test
103103
where
104104
RuntimeCall: From<C>,
105105
{
106-
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
106+
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
107107
UncheckedExtrinsic::new_bare(call)
108108
}
109109
}

polkadot/runtime/parachains/src/paras/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ pub mod pallet {
636636
frame_system::Config
637637
+ configuration::Config
638638
+ shared::Config
639-
+ frame_system::offchain::CreateInherent<Call<Self>>
639+
+ frame_system::offchain::CreateBare<Call<Self>>
640640
{
641641
#[allow(deprecated)]
642642
type RuntimeEvent: From<Event> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
@@ -2279,7 +2279,7 @@ impl<T: Config> Pallet<T> {
22792279
) {
22802280
use frame_system::offchain::SubmitTransaction;
22812281

2282-
let xt = T::create_inherent(Call::include_pvf_check_statement { stmt, signature }.into());
2282+
let xt = T::create_bare(Call::include_pvf_check_statement { stmt, signature }.into());
22832283
if let Err(e) = SubmitTransaction::<T, Call<T>>::submit_transaction(xt) {
22842284
log::error!(target: LOG_TARGET, "Error submitting pvf check statement: {:?}", e,);
22852285
}

polkadot/runtime/rococo/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,11 @@ where
707707
}
708708
}
709709

710-
impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
710+
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
711711
where
712712
RuntimeCall: From<LocalCall>,
713713
{
714-
fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic {
714+
fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic {
715715
UncheckedExtrinsic::new_bare(call)
716716
}
717717
}

polkadot/runtime/test-runtime/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ where
179179
type Extrinsic = UncheckedExtrinsic;
180180
}
181181

182-
impl<C> frame_system::offchain::CreateInherent<C> for Runtime
182+
impl<C> frame_system::offchain::CreateBare<C> for Runtime
183183
where
184184
RuntimeCall: From<C>,
185185
{
186-
fn create_inherent(call: Self::RuntimeCall) -> Self::Extrinsic {
186+
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
187187
UncheckedExtrinsic::new_bare(call)
188188
}
189189
}

polkadot/runtime/westend/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,11 +1065,11 @@ where
10651065
}
10661066
}
10671067

1068-
impl<LocalCall> frame_system::offchain::CreateInherent<LocalCall> for Runtime
1068+
impl<LocalCall> frame_system::offchain::CreateBare<LocalCall> for Runtime
10691069
where
10701070
RuntimeCall: From<LocalCall>,
10711071
{
1072-
fn create_inherent(call: RuntimeCall) -> UncheckedExtrinsic {
1072+
fn create_bare(call: RuntimeCall) -> UncheckedExtrinsic {
10731073
UncheckedExtrinsic::new_bare(call)
10741074
}
10751075
}

prdoc/pr_7597.prdoc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
title: 'Introduce CreateBare, deprecated CreateInherent'
2+
doc:
3+
- audience: Runtime Dev
4+
description: |
5+
Rename `CreateInherent` to `CreateBare`, add method `create_bare` and deprecate `create_inherent`.
6+
7+
Both unsigned transaction and inherent use the extrinsic type `Bare`.
8+
Before this PR `CreateInherent` trait was use to generate unsigned transaction, now unsigned transaction can be generated using a proper trait `CreateBare`.
9+
10+
How to upgrade:
11+
* Change usage of `CreateInherent` to `CreateBare` and `create_inherent` to `create_bare`.
12+
* Implement `CreateBare` for the runtime, the method `create_bare` is usually implemented using `Extrinsic::new_bare`.
13+
14+
crates:
15+
- name: frame-system
16+
bump: major
17+
- name: polkadot-runtime-common
18+
bump: major
19+
- name: polkadot-runtime-parachains
20+
bump: major
21+
- name: rococo-runtime
22+
bump: major
23+
- name: westend-runtime
24+
bump: major
25+
- name: pallet-babe
26+
bump: major
27+
- name: pallet-beefy
28+
bump: major
29+
- name: pallet-election-provider-multi-block
30+
bump: major
31+
- name: pallet-election-provider-multi-phase
32+
bump: major
33+
- name: pallet-grandpa
34+
bump: major
35+
- name: pallet-im-online
36+
bump: major
37+
- name: pallet-mixnet
38+
bump: major
39+
- name: pallet-offences-benchmarking
40+
bump: major

0 commit comments

Comments
 (0)