-
Notifications
You must be signed in to change notification settings - Fork 64
Extrinsic v5 definition and specification #124
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
380bdbb
01bc758
f2f4f19
dd9e353
e13f615
0ac87df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,156 @@ | ||||||||
| # RFC-0124: Extrinsic version 5 | ||||||||
|
|
||||||||
| | | | | ||||||||
| | --------------- | ------------------------------------------------------------------------------------------- | | ||||||||
| | **Start Date** | 18 October 2024 | | ||||||||
| | **Description** | Definition and specification of version 5 extrinsics | | ||||||||
| | **Authors** | George Pisaltu | | ||||||||
|
|
||||||||
| ## Summary | ||||||||
|
|
||||||||
| This RFC proposes the definition of version 5 extrinsics along with changes to the specification and encoding from version 4. | ||||||||
|
|
||||||||
| ## Motivation | ||||||||
|
|
||||||||
| [RFC84](https://github.com/polkadot-fellows/RFCs/blob/main/text/0084-general-transaction-extrinsic-format.md) introduced the specification of `General` transactions, a new type of extrinsic besides the `Signed` and `Unsigned` variants available previously in version 4. Additionally, [RFC99](https://github.com/polkadot-fellows/RFCs/blob/main/text/0099-transaction-extension-version.md) introduced versioning of transaction extensions through an extra byte in the extrinsic encoding. Both of these changes require an extrinsic format version bump as both the semantics around extensions as well as the actual encoding of extrinsics need to change to accommodate these new features. | ||||||||
|
|
||||||||
| ## Stakeholders | ||||||||
|
|
||||||||
| - Runtime users | ||||||||
| - Runtime devs | ||||||||
| - Wallet devs | ||||||||
|
|
||||||||
| ## Explanation | ||||||||
|
|
||||||||
| ### Changes to extrinsic authorization | ||||||||
|
|
||||||||
| The introduction of `General` transactions allows the authorization of any and all origins through | ||||||||
| extensions. This means that, with the appropriate extension, `General` transactions can replicate | ||||||||
| the same behavior present-day v4 `Signed` transactions. Specifically for Polkadot chains, an example | ||||||||
| implementation for such an extension is | ||||||||
| [`VerifySignature`](https://github.com/paritytech/polkadot-sdk/tree/master/substrate/frame/verify-signature), | ||||||||
| introduced in the Transaction Extension | ||||||||
| [PR3685](https://github.com/paritytech/polkadot-sdk/pull/3685). Other extensions can be inserted | ||||||||
| into the extension pipeline to authorize different custom origins. Therefore, a `Signed` extrinsic | ||||||||
| variant is redundant to a `General` one strictly in terms of user functionality and could eventually | ||||||||
| be deprecated and removed. | ||||||||
|
|
||||||||
| ### Encoding format for version 5 | ||||||||
|
|
||||||||
| As with version 4, the encoded extrinsic v5 is a SCALE encoded vector of bytes (`u8`), therefore | ||||||||
| starting with the encoded length of the following bytes in compact format. The leading byte after | ||||||||
| the length determines the version and type of extrinsic, as specified by | ||||||||
| [RFC84](https://github.com/polkadot-fellows/RFCs/blob/main/text/0084-general-transaction-extrinsic-format.md). | ||||||||
| For reasons mentioned above, this RFC removes the `Signed` variant for v5 extrinsics. | ||||||||
|
|
||||||||
| NOTE: For `Bare` extrinsics, the following bytes will just be the encoded call and nothing else. | ||||||||
|
|
||||||||
| For `General` transactions, as stated in | ||||||||
| [RFC99](https://github.com/polkadot-fellows/RFCs/blob/main/text/0099-transaction-extension-version.md), | ||||||||
| an extension version byte must be added in the next extrinsic version. This byte should allow | ||||||||
| runtimes to expose more than one set of extensions which can be used for a transaction. As far as | ||||||||
| the v5 extrinsic encoding is concerned, this extension byte should be encoded immediately after the | ||||||||
| leading encoding byte. The extension version byte should be included in payloads to be signed by all | ||||||||
| extensions configured by runtime devs to ensure a user's extension version choice cannot be altered | ||||||||
| by third parties. | ||||||||
|
|
||||||||
| After the extension version byte, the extensions will be encoded next, followed by the call itself. | ||||||||
|
|
||||||||
| A quick visualization of the encoding: | ||||||||
|
|
||||||||
| - `Bare` extrinsics: `(extrinsic_encoded_len, 0b0000_0101, call)` | ||||||||
| - `General` transactions: `(extrinsic_encoded_len, , 0b0100_0101, extension_version_byte, extension, call)` | ||||||||
georgepisaltu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||
| - `General` transactions: `(extrinsic_encoded_len, , 0b0100_0101, extension_version_byte, extension, call)` | |
| - `General` transactions: `(extrinsic_encoded_len, , 0b0100_0101, extensions_version_byte, extensions, call)` |
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 extension itself is usually a tuple of multiple extensions, generally referred to as the extension pipeline. Technically it's only one extension, the TxExtension commonly defined in runtimes, but that is always a tuple of extensions like CheckNonce, CheckWeight, ChargeTransactionPayment etc., so it would be only one extension version, as it is the version of the tuple, but there are multiple extensions in the pipeline.
Outdated
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.
dumb Q: would it not be possible to use a set of extensions that ultimately behave differently than classic "Signed Origins Extension", but still have one extension responsible for authorizing Signed origins within this set?
Respectively, I'm not sure this "alternative" sentence is correct.
| with a provided signature. Alternatively, if users want to use some other origin, they should create | |
| the transaction with this particular extension disabled. | |
| with a provided signature. |
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.
To your question, yes it is entirely possible and, in fact, what I expect to be implemented in most runtimes. The "alternative" wasn't helpful so I removed it.
georgepisaltu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
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.
This is not a drawback IMO. Metadata v15 should show v4 and metadata v16 and ahead have a vector of extrinsic versions.
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.
It is something extra to support in the metadata for both the runtime and users, is this not a drawback?
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.
it is both a drawback and an improvement - the new metadata support is an improvement, but having to do this enhancement to the metadata is a drawback to this RFC 😛
maybe add another line explicitly calling out that adding this metadata enhancement is ultimately a good thing that should be useful for potential future scenarios too
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.
Added the explanation.
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.
This is not true. Signature schemes and addresses were configurable by runtime devs through rust generics. For example, Moonbeam uses only ECDSA signatures with EVM-like addresses.
Besides that, I wouldn't mention VerifySignature since it should be RFC-ed anyways.
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.
Your statement about configurable signature schemes is true. However, I still consider my statement to be true because:
- The signing payload generation algorithm was hardcoded; this is not the case anymore as any extension can take the inherited implication and add or subtract any data to it and mutate it in any way (such as hashing it - or not) before actually creating a signature.
- There are now multiple ways of ending up with a
Signedorigin variant, with arbitrary logic in anyTransactionExtensionbeing able to authorize that origin; before, a user HAD to provide a transaction signed by a specific account.
All of this static logic is now moved to extensions. The extensions receive the inherited implication, the generation of which is still hardcoded and handled in this RFC, but is not in any way mandatory to be used in any signing scheme.
I'd agree though that the phrasing isn't clear, but I'm not sure how to improve it.
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 the phrasing is fine as it is. The point is to highlight the increase in configurability, which it does.
Uh oh!
There was an error while loading. Please reload this page.