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

v16: ExtrinsicMetadata extensions #86

Merged
merged 11 commits into from
Nov 12, 2024
Merged

v16: ExtrinsicMetadata extensions #86

merged 11 commits into from
Nov 12, 2024

Conversation

lexnv
Copy link
Contributor

@lexnv lexnv commented Nov 6, 2024

This PR adds the following to the v16 metadata:

  • remove ExtrinsicMetadata::call_ty as it can be found in the other enums field of the metadata
  • remove ExtrinsicMetadata::extra_ty as it can be found in the tx extensions
  • rename TransactionExtensionMetadata::additional_signed to TransactionExtensionMetadata::implicit
  • add TransactionExtensionMetadata::version u8 for versioning extensions

cc @paritytech/subxt-team

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv self-assigned this Nov 6, 2024
@@ -223,22 +217,25 @@ impl IntoPortable for ExtrinsicMetadata {
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
)]
pub struct TransactionExtensionMetadata<T: Form = MetaForm> {
/// Extension version.
pub version: u8,
Copy link
Contributor Author

@lexnv lexnv Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved the version here, instead of having pub transaction_extensions: Vec<(u8, TransactionExtensionMetadata<T>)>.

Wdyt? // cc @jsdw @niklasad1 🙏

@@ -223,22 +217,25 @@ impl IntoPortable for ExtrinsicMetadata {
serde(bound(serialize = "T::Type: Serialize, T::String: Serialize"))
)]
pub struct TransactionExtensionMetadata<T: Form = MetaForm> {
/// Extension version.
pub version: u8,
Copy link
Contributor

@jsdw jsdw Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In V5 transactions we'll have a single u8 version denoting the set of transaction extensions to use. So while we could use this approach and have eg:

vec![
   // v0 extensions
   TransactionExtensionMetadata { version: 0, identifier: "Foo", ty: 123, implicit: 456 },
   TransactionExtensionMetadata { version: 0, identifier: "Bar", ty: 124, implicit: 457 },
   // v1 extensions
   TransactionExtensionMetadata { version: 1, identifier: "Foo", ty: 123, implicit: 456 },
   TransactionExtensionMetadata { version: 1, identifier: "Bar", ty: 124, implicit: 457 },
   TransactionExtensionMetadata { version: 1, identifier: "Wibble", ty: 124, implicit: 457 },
   // ...
]

(noting that the order of extensions within each version is important)

It perhaps makes more sense to avoid the repetition and represent extensions something like:

// For each supported version number, list the indexes, in order, of the extensions used:
versions: Map<u8, Vec<u32>> {
    0: [0,1],
    1: [0,1,2]
},
// All of the extensions used. The above refers to these by index:
extensions: vec![
   TransactionExtensionMetadata { identifier: "Foo", ty: 123, implicit: 456 },
   TransactionExtensionMetadata { identifier: "Bar", ty: 124, implicit: 457 },
   TransactionExtensionMetadata { identifier: "Foo", ty: 123, implicit: 456 },
   TransactionExtensionMetadata { identifier: "Bar", ty: 124, implicit: 457 },
   TransactionExtensionMetadata { identifier: "Wibble", ty: 124, implicit: 457 },
]

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
frame-metadata/src/v16.rs Outdated Show resolved Hide resolved
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
frame-metadata/src/v16.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@jsdw jsdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM!

Co-authored-by: James Wilson <james@jsdw.me>
/// The type of the additional transaction data, with the data to be included in the signed payload.
pub additional_signed: T::Type,
/// The type of the implicit data, with the data to be included in the signed payload.
pub implicit: T::Type,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, missed that this has been renamed good to know

@lexnv lexnv merged commit 547bd14 into main Nov 12, 2024
9 checks passed
@lexnv lexnv deleted the lexnv/extensions-v16 branch November 12, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants