paritytech / subxt

Interact with Substrate based nodes in Rust or WebAssembly
Other
425 stars 248 forks source link

`TransactionExtension`: Update naming and support new transaction type. #1468

Open jsdw opened 8 months ago

jsdw commented 8 months ago

See eg https://github.com/paritytech/polkadot-sdk/pull/2280 and my comment here links to the bit showing the new encoding: https://github.com/paritytech/polkadot-sdk/pull/2280#discussion_r1481193578 (though note that the actual extrinsic version will change to 5 for the new type based on latest comments).

Essentially right now we have:

We'll add:

We are also renaming SignedExtensions to TransactionExtensions and changing the traits in Substrate a bit for how they work.

On the Subxt side we should do something along the lines of:

  1. Rename our SignedExtensions to TransactionExtensions (updating the other naming around these as appropriate, eg I think "additional signed" becomes "implicit"). 2 Rename our tx client methods to match the update, eg create_unsigned becomes create_bare.
  2. Introduce a new method, maybe on the offline side of the tx client which can construct such an extrinsic (maybe create_general).
jsdw commented 1 month ago

An update on this with some changes and more detail:

The high level PR in PolkadotSDK is now (the above one was closed):

https://github.com/paritytech/polkadot-sdk/pull/3685

A couple of RFCs around this:

https://polkadot-fellows.github.io/RFCs/approved/0084-general-transaction-extrinsic-format.html https://polkadot-fellows.github.io/RFCs/approved/0099-transaction-extension-version.html

Basic summary from client PoV as I understand it:

Previously, we had Signed and Unsigned transactions.

Transactions are basically encoded by concatenating a "preamble + call_data".

The preamble starts with a single byte which can be inspected to see what type of transaction we'll need to decode.

These stay the same (although "unsigned transactions" are renamed to "Bare" transactions), but we'll now have two new types of transaction:

Existing transactions stay the same and can be encoded and decoded the same way, but to encode/decode the new style transactions, we will look at the first byte and use that to know that we are dealing with new transactions and decode/encode them accordingly.

See https://github.com/paritytech/polkadot-sdk/pull/3685/files#diff-7be1730dfe08652baee2cb237c2d33df42c5eb85408639864c6a4a9223f0ca32R99-R133 for more on how the preamble is encoded/decoded

Another change is that "SignedExtension"s will be renamed to "TransactionExtension"s. These are the things like CheckMetadataHash,CheckMortality etc. The format for them doesn't change AFAIK, but we rename a couple of terms around them (eg "additional_signed" in the metadata will become "implicit" in metadata V16: https://github.com/paritytech/polkadot-sdk/pull/3685/files#diff-da22df55e2e056a2b6230692383b8cef27777ede1e9aea39d237b558816d35d3R85).