-
Notifications
You must be signed in to change notification settings - Fork 838
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
base: master
Are you sure you want to change the base?
Conversation
@@ -489,8 +489,14 @@ pub trait CreateSignedTransaction<LocalCall>: | |||
} | |||
|
|||
/// Interface for creating an inherent. | |||
/// | |||
/// It can also be used to create an unsigned transaction as they are both the same extrinsic | |||
/// variant: `Bare`. Unsigned transaction are deprecated in favor of general transaction. | |||
pub trait CreateInherent<LocalCall>: CreateTransactionBase<LocalCall> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming is still just wrong and trying to fix this via docs is not making it better. As I already said in the original pr, the name of the trait is wrong.
I would propose we introduce a new CreateBare
with proper docs and tag this trait deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the PR: deprecate CreateInherent
, introduce CreateBare
and replace all usage in polkadot-sdk.
It is a breaking change so I am not sure I can backport anything to 2412, but I will backport it to 2503.
I acknowledge my mistake in transaction extension review, also overall I underestimated the stability and the pace of new feature in polkadot-sdk in 2024.
As a side note I think offchain traits could be improved as well:
- we could remove
LocalCall
everywhere, people can boundRuntimeCall: From<Call>
in their config CreateTransactionBase
could simply boundframe_system::Config
as supertrait instead of having a duplicated associated typeRuntimeCall
that bring name conflict. (We do boundConfig
as supertrait forSigningTypes
).
But better not to break them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the offchain trait refactor, but it's probably best to do it after phase 2 of Extrinsic Horizon is done.
@@ -571,7 +576,7 @@ pub trait SendSignedTransaction< | |||
} | |||
|
|||
/// Submit an unsigned transaction onchain with a signed payload | |||
pub trait SendUnsignedTransaction<T: SigningTypes + CreateInherent<LocalCall>, LocalCall> { | |||
pub trait SendUnsignedTransaction<T: SigningTypes + CreateBare<LocalCall>, LocalCall> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change this, it basically means that people may have CreateInherent
implemented, but it will not be used by anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically also resulting in compile errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do this, runtime will have to implement CreateInherent
with the intention of creating a bare extrinsic.
It is ok to me, and the least breaking change, but it keeps the faulty trait usage: CreateInherent
, I will also add in the doc of CreateInherent
the intention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the code:
CreateInherent
has a new methodcreate_bare
with default implementation. User can override it to specify the behavior. (not ideal but not a breaking change.)CreateBare
is introduced, automatically implemented forCreateInherent
usingCreateInherent::create_bare
.CreateBare
is used instead ofCreateInherent
forSendUnsignedTransaction
and it implementation forSigner
.- pallets such as beefy are not using
CreateBare
in their trait bound to avoid any breaking change. - User are expected to implement
CreateInherent
for their runtime in order to keep pallet's usage. - User are expected to use
CreateBare
in their pallet, the idiomatic trait to create a bare extrinsic.
Possible alternative design: slightly more breaking, but provides a path forward:
- I considered deprecated
CreateInherent
and useCreateBare
in polkadot-sdk pallets. That would be a breaking change: e.g. if a pallets bounds beefy config and useT::create_inherent
method then their code then it won't compile. They have to usecreate_bare
and importCreateBase
trait in scope. (note: we could introduceCreateBare::create_inherent
so that rustc give some hint to import the trait in scope.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok as it is right now, fixes the name and helps the dev a bit with the default impl.
/cmd fmt |
@@ -489,9 +483,37 @@ pub trait CreateSignedTransaction<LocalCall>: | |||
} | |||
|
|||
/// Interface for creating an inherent. | |||
/// | |||
/// Implement this trait for the runtime but use `CreateBare` instead. | |||
/// This trait is defined to avoid a breaking change, and it automatically implements `CreateBare`. | |||
pub trait CreateInherent<LocalCall>: CreateTransactionBase<LocalCall> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub trait CreateInherent<LocalCall>: CreateTransactionBase<LocalCall> { | |
#[deprecated(note = "Please use `CreateBare` instead")] | |
pub trait CreateInherent<LocalCall>: CreateTransactionBase<LocalCall> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I will also change usage of CreateInherent
to CreateBare
in pokadot-sdk, in pallets (and runtime but this is less important).
EDIT: otherwise runtime implementing only CreateBare
won't be able to use like election-solution
pallet which uses CreateInherent
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDIT: otherwise runtime implementing only
CreateBare
won't be able to use likeelection-solution
pallet which usesCreateInherent
.
I mean you can still implement CreateInherent
, just with a allow(deprecated)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it only took a couple of months before full adoption of the new interface, this trait would eventually end up only being used to create inherents. We expected the transition period to be much shorter than what it seems it will be, which is a miss on my end definitely.
In order to prevent similar situations in the future, we should push to get out of this "limbo" stage where the feature is partially complete and unsigned extrinsics are still around but so are bare extrinsics and inherents. We should start by delivering phase 2 of Extrinsic Horizon, implemented in #6324 #6325 #6326, to finally get rid of unsigned transactions and become consistent again regarding the terminology we use.
@@ -489,8 +489,14 @@ pub trait CreateSignedTransaction<LocalCall>: | |||
} | |||
|
|||
/// Interface for creating an inherent. | |||
/// | |||
/// It can also be used to create an unsigned transaction as they are both the same extrinsic | |||
/// variant: `Bare`. Unsigned transaction are deprecated in favor of general transaction. | |||
pub trait CreateInherent<LocalCall>: CreateTransactionBase<LocalCall> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the offchain trait refactor, but it's probably best to do it after phase 2 of Extrinsic Horizon is done.
@@ -571,7 +576,7 @@ pub trait SendSignedTransaction< | |||
} | |||
|
|||
/// Submit an unsigned transaction onchain with a signed payload | |||
pub trait SendUnsignedTransaction<T: SigningTypes + CreateInherent<LocalCall>, LocalCall> { | |||
pub trait SendUnsignedTransaction<T: SigningTypes + CreateBare<LocalCall>, LocalCall> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok as it is right now, fixes the name and helps the dev a bit with the default impl.
It doesn't work either, because
So instead I just renamed the trait The deprecation of a reexport doesn't work in rust, but the doc show the rename so if people use an IDE they will see the trait is renamed. |
Rename
CreateInherent
toCreateBare
, add methodcreate_bare
and deprecatecreate_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 traitCreateBare
.How to upgrade:
CreateInherent
toCreateBare
andcreate_inherent
tocreate_bare
.CreateBare
for the runtime, the methodcreate_bare
is usually implemented usingExtrinsic::new_bare
.