Allow multiple transaction extension version in UncheckedExtrinsic type.#7035
Conversation
…ension-multiple-version
…ension-multiple-version
…ension-multiple-version
bkchr
left a comment
There was a problem hiding this comment.
Great work!
It would be ultra nice to have some proper example. Maybe as part of the guide here in the repo. This way it would be easier to replicate the stuff.
| /// For the transaction extension pipeline used for the signed extrinsics it is defined as the | ||
| /// version 0, if defined. |
There was a problem hiding this comment.
I don't really know if this trait should specify it but the idea is that in extrinsic v4, for signed extrinsics, there no version. So to get the pipeline used you need to fetch the version 0.
I rewrote saying extrinsic v4, pipeline version 0 is used, and for extrinsic v5, for bare extrinsics pipeline version 0 is used: 1a81f0a
| /// The generic `ExtensionOtherVersions` must not re-define a transaction extension pipeline for the | ||
| /// version 0, it will be ignored and overwritten by `ExtensionV0`. |
There was a problem hiding this comment.
I don't get what you mean by this.
There was a problem hiding this comment.
I tried to reword here: 22f7bcc
The thing is that if ExtensionOtherVersions also define a pipeline for the version 0 then this version is just ignored.
The version 0 is the one defined by ExtensionV0.
| pub trait PipelineVersion { | ||
| /// Return the version for the given versioned transaction extension pipeline. | ||
| fn version(&self) -> u8; | ||
| } |
There was a problem hiding this comment.
This makes sense to be its own trait, because it doesn't require the Call parameter, but PipelineWeight still makes no sense to have it separate?
There was a problem hiding this comment.
I implemented here: 2abb369
The main issue is that the function extension_weight for UncheckedExtrinsic and CheckedExtrinsic and the dispatch info stuff doesn't bound the trait DispatchTransaction. But if I put the pipeline weight inside the pipeline trait, then I now need to bound the trait DispatchTransaction to access the weight on those type and in the dispatch info. Overall it is fine, it is just about adding a few bounds here and there. But this is the reason why I made it separate before.
| /// An old-school transaction extrinsic which includes a signature of some hard-coded crypto. | ||
| /// Available only on extrinsic version 4. | ||
| Signed(Address, Signature, Extension), | ||
| Signed(Address, Signature, ExtensionV0), |
There was a problem hiding this comment.
Yeah you are right, if we don't support this any more with version 5, it will not be important.
| /// | ||
| /// Types of extrinsics: | ||
| /// - **Bare**: An extrinsic without a signature or any additional data. After being checked, bare | ||
| /// extrinsics can be applied, the apply logic is extended with `ExtensionV0`. |
There was a problem hiding this comment.
ExtensionV0 is only used for the deprecated unsigned transactions or?
There was a problem hiding this comment.
It is also used for inherents. Inherents still use transaction extension like CheckWeight to register the used weight.
|
|
||
| /// A type implements [`DecodeWithVersion`] where inner decoding is implementing | ||
| /// [`codec::DecodeWithMemTracking`]. | ||
| pub trait DecodeWithVersionWithMemTracking: DecodeWithVersion {} |
There was a problem hiding this comment.
Answering myself DecodeWithMemTracking requires Decode as super trait.
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
…ension-multiple-version
I will write it then, but if we merge it before it is also good and I will do in a follow-up PR. |
I will do in a follow-up. |
pgherveou
left a comment
There was a problem hiding this comment.
for contracts team.
all changes under Revive seems mostly mechanical, if Build / CI pass that's good for me
PR #7035 added new TypeInfo implementors, pushing rustc past its diagnostic threshold for emitting `consider using --verbose` on the TypeInfo/StorageEntryMetadataBuilder error.
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This PR enhance
UncheckedExtrinsictype with a new optional generic:ExtensionOtherVersion.This generic defaults to
InvalidVersionmeaning there is not other version than the regular version 0. This is the same behavior as before this PR.New feature
To use this new feature, you can use the new types
TxExtLineAtVersandMultiVersionto define a transaction extension with multiple version:Breaking change
The types
Preamble,CheckedExtrinsicandExtrinsicFormatalso have this new optional generic. Their type definition also have changed a bit, theGeneralvariant was 2 fields, the version and the extension, it is now only one field, the extension, and the version can be retrieve by callingextension.version()The type inference for those types may fail because of this PR, to update the code, write some partial type:
UncheckedExtrinsic<_, _, _, _>,Preamble<_, _, _>,ExtrinsicFormat<_, _> andCheckedExtrinsic<_, _, _>`.Alternative implementation
This PR breaks the types a bit, I think it is very minimal and fine, but if this is annoying we can still keep the old types and write new types such as
UncheckedExtrinsicV2,CheckedExtrinsicV2etc..