-
Notifications
You must be signed in to change notification settings - Fork 57
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
XCM Absolute Location Account Derivation #34
Open
arrudagates
wants to merge
4
commits into
polkadot-fellows:main
Choose a base branch
from
arrudagates:rfc-34
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3d0d7e4
RFC-34: Introduce Tinkernet XCM configs to Kusama and Asset Hub
arrudagates 345f18e
Rewrite RFC-34 as a generic solution
arrudagates a6484c4
Update text/0034-xcm-absolute-location-account-derivation.md
arrudagates 5829c60
Update RFC-34
arrudagates File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# RFC-34: XCM Absolute Location Account Derivation | ||
|
||
| | | | ||
| --------------- | ------------------------------------------------------------------------------------------- | | ||
| **Start Date** | 05 October 2023 | | ||
| **Description** | XCM Absolute Location Account Derivation | | ||
| **Authors** | Gabriel Facco de Arruda | | ||
|
||
## Summary | ||
|
||
This RFC proposes changes that enable the use of absolute locations in AccountId derivations, which allows protocols built using XCM to have static account derivations in any runtime, regardless of its position in the family hierarchy. | ||
|
||
## Motivation | ||
|
||
These changes would allow protocol builders to leverage absolute locations to maintain the exact same derived account address across all networks in the ecosystem, thus enhancing user experience. | ||
|
||
One such protocol, that is the original motivation for this proposal, is InvArch's Saturn Multisig, which gives users a unifying multisig and DAO experience across all XCM connected chains. | ||
|
||
## Stakeholders | ||
|
||
- Ecosystem developers | ||
|
||
## Explanation | ||
|
||
This proposal aims to make it possible to derive accounts for absolute locations, enabling protocols that require the ability to maintain the same derived account in any runtime. This is done by deriving accounts from the hash of described absolute locations, which are static across different destinations. | ||
|
||
The same location can be represented in relative form and absolute form like so: | ||
```rust | ||
// Relative location (from own perspective) | ||
{ | ||
parents: 0, | ||
interior: Here | ||
} | ||
|
||
// Relative location (from perspective of parent) | ||
{ | ||
parents: 0, | ||
interior: [Parachain(1000)] | ||
} | ||
|
||
// Relative location (from perspective of sibling) | ||
{ | ||
parents: 1, | ||
interior: [Parachain(1000)] | ||
} | ||
|
||
// Absolute location | ||
[GlobalConsensus(Kusama), Parachain(1000)] | ||
``` | ||
|
||
Using `DescribeFamily`, the above relative locations would be described like so: | ||
```rust | ||
// Relative location (from own perspective) | ||
// Not possible. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be manageable with |
||
|
||
// Relative location (from perspective of parent) | ||
(b"ChildChain", Compact::<u32>::from(*index)).encode() | ||
|
||
// Relative location (from perspective of sibling) | ||
(b"SiblingChain", Compact::<u32>::from(*index)).encode() | ||
|
||
``` | ||
|
||
The proposed description for absolute location would follow the same pattern, like so: | ||
```rust | ||
( | ||
b"GlobalConsensus", | ||
network_id, | ||
b"Parachain", | ||
Compact::<u32>::from(para_id), | ||
tail | ||
).encode() | ||
``` | ||
|
||
This proposal requires the modification of two XCM types defined in the `xcm-builder` crate: The `WithComputedOrigin` barrier and the `DescribeFamily` MultiLocation descriptor. | ||
|
||
#### WithComputedOrigin | ||
|
||
The `WtihComputedOrigin` barrier serves as a wrapper around other barriers, consuming origin modification instructions and applying them to the message origin before passing to the inner barriers. One of the origin modifying instructions is `UniversalOrigin`, which serves the purpose of signaling that the origin should be a Universal Origin that represents the location as an absolute path prefixed by the `GlobalConsensus` junction. | ||
|
||
In it's current state the barrier transforms locations with the `UniversalOrigin` instruction into relative locations, so the proposed changes aim to make it return absolute locations instead. | ||
|
||
#### DescribeFamily | ||
|
||
The `DescribeFamily` location descriptor is part of the `HashedDescription` MultiLocation hashing system and exists to describe locations in an easy format for encoding and hashing, so that an AccountId can be derived from this MultiLocation. | ||
|
||
This implementation contains a match statement that does not match against absolute locations, so changes to it involve matching against absolute locations and providing appropriate descriptions for hashing. | ||
|
||
## Drawbacks | ||
|
||
No drawbacks have been identified with this proposal. | ||
|
||
## Testing, Security, and Privacy | ||
|
||
Tests can be done using simple unit tests, as this is not a change to XCM itself but rather to types defined in `xcm-builder`. | ||
|
||
Security considerations should be taken with the implementation to make sure no unwanted behavior is introduced. | ||
|
||
This proposal does not introduce any privacy considerations. | ||
|
||
## Performance, Ergonomics, and Compatibility | ||
|
||
### Performance | ||
|
||
Depending on the final implementation, this proposal should not introduce much overhead to performance. | ||
|
||
### Ergonomics | ||
|
||
The ergonomics of this proposal depend on the final implementation details. | ||
|
||
### Compatibility | ||
|
||
Backwards compatibility should remain unchanged, although that depend on the final implementation. | ||
|
||
## Prior Art and References | ||
|
||
- `DescirbeFamily` type: https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/xcm/xcm-builder/src/location_conversion.rs#L122 | ||
- `WithComputedOrigin` type: https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/xcm/xcm-builder/src/barriers.rs#L153 | ||
|
||
## Unresolved Questions | ||
|
||
Implementation details and overall code is still up to discussion. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 only makes sense to say when the local location (in terms of the universal origin) is defined.
Edit: I see now it is defined below. I'd move it up here instead.