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

Transfer Polkadot-native assets to Ethereum #5546

Merged
merged 115 commits into from
Sep 13, 2024

Conversation

yrong
Copy link
Contributor

@yrong yrong commented Sep 2, 2024

Description

Adding support for send polkadot native assets(PNA) to Ethereum network through snowbridge. Asset with location in view of AH Including:

  • Relay token (1,Here)
  • Native asset (0,[PalletInstance(instance),GenereIndex(index)]) managed by Assets Pallet
  • Native asset of Parachain (1,[Parachain(paraId)]) managed by Foreign Assets Pallet

The original PR in Snowfork#128 which has been internally reviewed by Snowbridge team.

Notes

  • This feature depends on the companion solidity change in Asset from polkadot Snowfork/snowbridge#1155. Currently register PNA is only allowed from sudo, so it's actually not enabled. Will require another runtime upgrade to make the call permissionless together with upgrading the Gateway contract.

  • To make things easy multi-hop transfer(i.e. sending PNA from Ethereum through AH to Destination chain) is not support ed in this PR. For this case user can switch to 2-phases transfer instead.

yrong and others added 3 commits September 2, 2024 18:15
* Register token from polkadot

* Extract AssetRegistrarMetadata

* ReserveTransfer from AssetHub

* Transfer DOT back to AssetHub

* Fix breaking tests

* Fix register token

* Increase dispatch_gas to cover the actual cost for register token

* Add ConvertAssetId to outbound router

* Rename to SendForeignToken

* Update cost

* Move Command.RegisterToken to top level

* Use VersionedLocation for storage

* Use versioned location

* TokenIdOf follow the same pattern as AgentIdOf

* Rename MintToken to TransferNativeToken

* Rename as SendNativeToken

* More refactoring

* Remove AgentExecuteCommand

* Remove TokenExists check

* Update cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs

Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>

* Benchmark register_token

* More checks for the events

* More tests for send native token

* More tests describe tokenID

* More asset identifiers

* Add LocationToToken & Always use VersionedLocation

* Fix breaking tests

* Update gas cost for registering polkadot token

* Add AgentExecuteCommand back for compatibility

* Split into 2 tests each covers one direction

* Revert the change on AH

* Switch to native token on penpal for the integration

* Make fee asset as configuration parameter of the Channel

* Revert fee_asset_id as channel property

* Short epoch

* Fix integration tests

* Fix format

* Cleanup

* Register relay token

* Use relay token as fee asset

* Fix clippy

* Fix missing dependency

* Remove reanchored prefix from asset_id

* Fix test

* Fix the instruction

* Fix test

* Multi hop transfer

* Fix tests

* allow bridge hub assets

* Register token from BH directly and remove force_register_token

* Decrease gas estimation for PNA

* Cleanup

* Store Location rather than VersionedLocation

* Fix test

* Add more tests

* Revamp reanchor logic

* Improve reanchor & Fix tests

* Use secondary governance channel to register PNA

* Rename as asset location

* Use BoundVec limit size of name&symbol

* Describe location of PNA & more tests

* Add test

* Fix taplo

* More tests

* Cleanup

* Format code

* Batch rename token command

* Remove agent_id

* Rename as AssetMetadata

* Add test for penpal native token

---------

Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>
Co-authored-by: Alistair Singh <alistair.singh7@gmail.com>
@yrong yrong marked this pull request as ready for review September 3, 2024 00:57
@paritytech-review-bot paritytech-review-bot bot requested a review from a team September 3, 2024 00:58
@yrong yrong changed the title Polkadot native assets Transfer Polkadot-native assets to Ethereum Sep 3, 2024
bridges/snowbridge/pallets/system/src/lib.rs Outdated Show resolved Hide resolved
bridges/snowbridge/pallets/system/src/lib.rs Outdated Show resolved Hide resolved
bridges/snowbridge/pallets/system/src/lib.rs Outdated Show resolved Hide resolved
bridges/snowbridge/pallets/system/src/lib.rs Outdated Show resolved Hide resolved
bridges/snowbridge/pallets/system/src/lib.rs Outdated Show resolved Hide resolved
bridges/snowbridge/pallets/system/src/lib.rs Outdated Show resolved Hide resolved
bridges/snowbridge/primitives/core/src/lib.rs Show resolved Hide resolved
bridges/snowbridge/primitives/core/src/lib.rs Outdated Show resolved Hide resolved
bridges/snowbridge/primitives/core/src/lib.rs Outdated Show resolved Hide resolved
bridges/snowbridge/primitives/core/src/lib.rs Outdated Show resolved Hide resolved
@franciscoaguirre franciscoaguirre added this pull request to the merge queue Sep 13, 2024
Merged via the queue into paritytech:master with commit fb7300c Sep 13, 2024
201 of 204 checks passed
vgeddes added a commit to Snowfork/polkadot-sdk that referenced this pull request Sep 13, 2024
# Description

Adding support for send polkadot native assets(PNA) to Ethereum network
through snowbridge. Asset with location in view of AH Including:

- Relay token `(1,Here)`
- Native asset `(0,[PalletInstance(instance),GenereIndex(index)])`
managed by Assets Pallet
- Native asset of Parachain `(1,[Parachain(paraId)])` managed by Foreign
Assets Pallet

The original PR in #128
which has been internally reviewed by Snowbridge team.

# Notes

- This feature depends on the companion solidity change in
Snowfork/snowbridge#1155. Currently register PNA
is only allowed from
[sudo](https://github.com/Snowfork/polkadot-sdk/blob/46cb3528cd8cd1394af2335a6907d7ab8647717a/bridges/snowbridge/pallets/system/src/lib.rs#L621),
so it's actually not enabled. Will require another runtime upgrade to
make the call permissionless together with upgrading the Gateway
contract.

- To make things easy multi-hop transfer(i.e. sending PNA from Ethereum
through AH to Destination chain) is not support ed in this PR. For this
case user can switch to 2-phases transfer instead.

---------

Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>
Co-authored-by: Alistair Singh <alistair.singh7@gmail.com>
Co-authored-by: Vincent Geddes <117534+vgeddes@users.noreply.github.com>
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
acatangiu added a commit that referenced this pull request Sep 13, 2024
Co-authored-by: Ron <yrong1997@gmail.com>
Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>
Co-authored-by: Alistair Singh <alistair.singh7@gmail.com>
Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T15-bridges This PR/Issue is related to bridges.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants