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

Allow multiple transaction extension version in UncheckedExtrinsic type. #7035

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

gui1117
Copy link
Contributor

@gui1117 gui1117 commented Jan 3, 2025

This PR enhance UncheckedExtrinsic type with a new optional generic: ExtensionOtherVersion.
This generic defaults to InvalidVersion meaning 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 TxExtLineAtVers and MultiVersion to define a transaction extension with multiple version:

pub type TransactionExtensionV0 = ();
pub type TransactionExtensionV4 = ();
pub type TransactionExtensionV7 = ();

pub type OtherVersions = MultiVersion<
	TxExtLineAtVers<4, TransactionExtensionV4>;
	TxExtLineAtVers<7, TransactionExtensionV7>;
>;

pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<
	AccountId,
	RuntimeCall,
	UintAuthorityId,
	TransactionExtensionV0, // The version 0, same as before
	OtherVersions, // The other versions.
>;

Breaking change

The types Preamble, CheckedExtrinsic and ExtrinsicFormat also have this new optional generic. Their type definition also have changed a bit, the General variant was 2 fields, the version and the extension, it is now only one field, the extension, and the version can be retrieve by calling extension.version()

The type inference for those types may fail because of this PR, to update the code, write some partial type: UncheckedExtrinsic<_, _, _, _>, Preamble<_, _, _>, ExtrinsicFormat<_, _> and CheckedExtrinsic<_, _, _>`.

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, CheckedExtrinsicV2 etc..

@gui1117 gui1117 marked this pull request as ready for review January 8, 2025 09:44
@gui1117 gui1117 requested a review from a team as a code owner January 8, 2025 09:44
@gui1117 gui1117 added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Jan 8, 2025
@gui1117 gui1117 added the T17-primitives Changes to primitives that are not covered by any other label. label Jan 8, 2025
@gui1117 gui1117 changed the title [Draft] allow multiple transaction extension version in UncheckedExtrinsic type. Allow multiple transaction extension version in UncheckedExtrinsic type. Jan 8, 2025
@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/12669168934
Failed job name: test-linux-stable

@gui1117 gui1117 marked this pull request as draft January 8, 2025 11:10
@gui1117 gui1117 force-pushed the gui-transaction-extension-multiple-version branch from 8e5bd74 to a59da7b Compare January 8, 2025 11:51
@gui1117 gui1117 marked this pull request as ready for review January 8, 2025 11:52
@gui1117
Copy link
Contributor Author

gui1117 commented Jan 10, 2025

PR is ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T1-FRAME This PR/Issue is related to core FRAME, the framework. T17-primitives Changes to primitives that are not covered by any other label.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant