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

General transactions in extrinsic format #84

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions text/0084-general-transaction-extrinsic-format.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# RFC-0084: General transactions in extrinsic format

| | |
| --------------- | ------------------------------------------------------------------------------------------- |
| **Start Date** | 12 March 2024 |
| **Description** | Support more extrinsic types by updating the extrinsic format |
| **Authors** | George Pisaltu |

## Summary

This RFC proposes the expansion of the extrinsic type identifier from the current most significant bit of the first byte of the encoded extrinsic to the two most significant bits of the first byte of the encoded extrinsic.
georgepisaltu marked this conversation as resolved.
Show resolved Hide resolved

## Motivation

In order to support transactions that use different authorization schemes than currently exist, a new extrinsic type must be introduced alongside the current signed and unsigned types. Currently, an encoded extrinsic's first byte indicate the type of extrinsic using the most significant bit - `0` for unsigned, `1` for signed - and the 7 following bits indicate the extrinsic format version, which has been equal to `4` for a long time.

By taking one bit from the extrinsic format version encoding, we can support 2 additional extrinsic types while also having a minimal impact on our capability to extend and change the extrinsic format in the future.
Copy link

Choose a reason for hiding this comment

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

Going a bit more in the details here. There is a reference below, but what would be good to have right at the RFC (in my opinion):

  1. What is the concrete usecase/what do we want to achieve and why? What benefits does it bring? "Different authorization" schemes is pretty generic ... what is wrong with the existing ones?
  2. What other ways of adding these different authorization schemes have been considered? E.g. Why are they not covered by "unsigned"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to answer your questions in the new iteration of Motivation. Let me know what you think.

Copy link

@eskimor eskimor Apr 5, 2024

Choose a reason for hiding this comment

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

Thank you! Better proxy accounts, meta data verification, ... - got it ;-) Now that's a good motivation!

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not really the motivation and more an explanation of the current format. Motivation would be more the introduction of the new general transaction and what this can bring. There you can bring the example of the new "meta transaction" that enables people paying for the transaction of other peoples.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the motivation. Let me know what you think.


## Stakeholders

Runtime users.
georgepisaltu marked this conversation as resolved.
Show resolved Hide resolved

## Explanation
Copy link
Contributor

Choose a reason for hiding this comment

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

You should mention that the transaction version is bumped to 5.

https://spec.polkadot.network/id-extrinsics#id-extrinsics-body also you could link to the description of the format somewhere here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


An extrinsic is currently encoded as one byte to identify the extrinsic type and version. This RFC aims to change the interpretation of this byte regarding the reserved bits for the extrinsic type and version. In the following explanation, bits represented using `T` make up the extrinsic type and bits represented using `V` make up the extrinsic version.

Currently, the bit allocation within the leading encoded byte is `0bTVVV_VVVV`. In practice in the Polkadot ecosystem, the leading byte would be `0bT000_0100` as the version has been equal to `4` for a long time.

This RFC proposes for the bit allocation to change to `0bTTVV_VVVV`. As a result, the extrinsic type bit representation would change as follows:

| bits | type |
|-------|-----------|
| 00 | unsigned |
| 10 | signed |
| 01 | reserved |
| 11 | reserved |

## Drawbacks

This change would reduce the maximum possible transaction version from the current `127` to `63`. In order to bypass the new, lower limit, the extrinsic format would have to change again.

## Testing, Security, and Privacy

There is no impact on testing, security or privacy.

## Performance, Ergonomics, and Compatibility

This change would allow Polkadot to support new types of transactions, with the specific "general" transaction type in mind at the time of writing this proposal.

### Performance

There is no performance impact.

### Ergonomics

The impact to developers and end-users is minimal as it would just be a bitmask update on their part for parsing the extrinsic type along with the version.

### Compatibility

This change breaks backwards compatiblity because any transaction that is neither signed nor unsigned, but a new transaction type, would be interpreted as having a future extrinsic format version.

## Prior Art and References

The original design was originally proposed in the [`TransactionExtension` PR](https://github.com/paritytech/polkadot-sdk/pull/2280), which is also the motivation behind this effort.

## Unresolved Questions

None.

## Future Directions and Related Material

Following this change, the "general" transaction type will be introduced as part of the [Extrinsic Horizon](https://github.com/paritytech/polkadot-sdk/issues/2415) effort, which will shape future work.