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

[asset-hubs/bridge-hubs] Bridging Polkadot Asset Hub <-> Kusama Asset Hub to enable asset transfer of KSMs/DOTs #1352

Closed
wants to merge 22 commits into from

Conversation

bkontur
Copy link
Contributor

@bkontur bkontur commented Sep 1, 2023

Summary

Adding bridging capabilities to the Polkadot and Kusama Bridge Hub runtimes and XCM routing configuration for bridging between Polkadot Asset Hub <-> Kusama Asset Hub in order to allow asset transfer between Asset Hubs.

Motivation

Main goal of these changes is to setup bridge between system parachains Kusama Asset Hub vs Polkadot Asset Hub. We explicitly allow only reserve based transfer for KSM/DOT to cross-consensus AssetHubs and nothing else at first (start defensively). We can later allow whatever (ETH, TrustBackedAssets, ForeignAssets, PoolAssets ...).

Explanation

Please, check first four commits with detailed description

Testing

Adds tests for simulation:

  • limited_reserve_transfer_assets with pallet_xcm both ways
  • handling ReserveAssetDeposisted on both sides
  • handling ExportMessage on both sides
  • handling message dispatch and routing to target on both side
  • relayer can submit proofs with submit_finality_proof / submit_parachain_heads and relay messages with receive_messages_proof

Adds local zombienet run for:

  • reserve based transfer of KSMs from AHK to AHP
  • reserve based transfer of DOTs from AHP to AHK

(check parachains/runtimes/bridge-hubs/README.md in this PR)

Future Directions and Related Material

Next stage will be focused on adding support to allow bridging between arbitrary parachains More about Bridges V2.

More about dynamic fees and back-preasure for v1 can be found here.

This is a migration (without commit history) of original PRs in cumulus:

TODO

@bkontur bkontur self-assigned this Sep 1, 2023
@bkontur bkontur added T6-XCM This PR/Issue is related to XCM. T9-cumulus This PR/Issue is related to cumulus. T15-bridges This PR/Issue is related to bridges. labels Sep 1, 2023
@bkontur bkontur force-pushed the bko-bridging-kusama-polkadot-assets branch 4 times, most recently from a8a89fc to 1da09f0 Compare September 4, 2023 11:44
@bkontur bkontur force-pushed the bko-bridging-kusama-polkadot-assets branch 5 times, most recently from d7f71a3 to fd705a8 Compare September 5, 2023 11:13
@bkontur bkontur force-pushed the bko-bridging-kusama-polkadot-assets branch 3 times, most recently from b66e64e to bd94e75 Compare September 5, 2023 11:44
acatangiu and others added 5 commits September 5, 2023 14:39
Add xcm routing configuration for bridging between
	Polkadot Asset Hub <-> Kusama Asset Hub.

We explicitly allow only reserve based transfer for KSM/DOT to
cross-consensus AssetHubs and nothing else at first (start defensively).
We can later allow whatever (ETH, TrustBackedAssets, ForeignAssets,
PoolAssets ...).

Add tests for simulation:
- `limited_reserve_transfer_assets` with `pallet_xcm` both ways
- handling `ReserveAssetDeposisted` on both sides

Add local zomienet run for:
- reserve based transfer of KSMs from AHK to AHP
- reserve based transfer of DOTs from AHP to AHK
(check parachains/runtimes/bridge-hubs/README.md in this PR)

Signed-off-by: Branislav Kontur <bkontur@gmail.com>
Signed-off-by: Adrian Catangiu <adrian@parity.io>
Change XCM routing configuration for bridging from unpaid to paid version.

Paid version means that origin (besides extrinsic fees) pays delivery fees at source Asset Hub
and also Asset Hub sovereign account pays for execution of `ExportMessage` instruction at local Bridge Hub.

Change XCM bridging router from `UnpaidRemoteExporter` to `ToPolkadotXcmRouter` and `ToKusamaXcmRouter`
which are pallet instances of new module `pallet-xcm-bridge-hub-router`.

The main thing that the pallet `pallet-xcm-bridge-hub-router` offers is the dynamic message fee,
that is computed based on the bridge queues state. It starts exponentially increasing
if the queue between this chain and the sibling/child bridge hub is congested.

More about dynamic fees and back-preasure for v1 can be found [here](paritytech/parity-bridges-common#2294).

Signed-off-by: Branislav Kontur <bkontur@gmail.com>
Signed-off-by: Adrian Catangiu <adrian@parity.io>
Signed-off-by: Svyatoslav Nikolsky <svyatonik@gmail.com>

Co-authored-by: Adrian Catangiu <adrian@parity.io>
Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
…lay, para) chains

Add bridging pallets to Bridge Hub runtime configuration:
- `pallet-bridge-grandpa` is an on-chain GRANDPA light client, used for verifying GRANDPA finality proofs on-chain.
- `pallet-bridge-parachains` is a Parachain finality module.
- `pallet-bridge-messages` module that allows sending and receiving messages using lane concept.
- `pallet-bridge-relayers` module that is used to store relayer rewards.

Kusma Bridge Hub and Polkadot Bridge Hub runtimes are configred with those pallets in the way that:
- allows to verify bridged relay chain GRANDPA finality proofs, e.g. Kusama Bridge Hub can track and verify Polkadot relay chain GRANDPA proofs and Polkadot Bridge Hub can track and verify Kusama relay chain GRANDPA proofs.
- allows to verify bridged parachain finality proofs e.g. Kusama Bridge Hub can track and verify Polkadot Bridge Hub proofs and vice versa.
- allows to relay messages between them which can be verified with mentioned finality modules.

Add tests for simulation:
- handling `ExportMessage` on both sides
- handling message dispatch and routing to target on both side
- relayer can submit proofs with `submit_finality_proof` / `submit_parachain_heads` and relay messages with `receive_messages_proof`

To the lane concept mentioned above, actual bridging configuration allows to send/relay/receive messages only with one hard-coded lane `[0, 0, 0, 0]`,
which is dedicated lane for Kusama Asset Hub and Polkadot Asset Hub communication.

Next stage will be focused on adding support to allow bridging between arbitrary parachains.
More about [Bridges V2](https://github.com/paritytech/parity-bridges-common/milestone/17).

Signed-off-by: Branislav Kontur <bkontur@gmail.com>
Signed-off-by: Adrian Catangiu <adrian@parity.io>
Signed-off-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
Signed-off-by: Serban Iorga <serban@parity.io>

Co-authored-by: Adrian Catangiu <adrian@parity.io>
Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
Co-authored-by: Serban Iorga <serban@parity.io>
…upport

Add congestion detection to the Bridge Hub runtimes and report congestion status to the sending chain.

Bridge Hub's `ExportMessage` handling is extended with check if outbound message queue is congested,
if so then `CongestedMessage` signal is sent to the sending chain's relevant `pallet-xcm-bridge-hub-router` pallet instance,
where dynamic fees factor is processed.
When then same Bridge Hub receives message delivery confirmation, there is a another check is outbound queue is still congested,
if not then `UncongestedMessage` signal is sent to the sending chain's relevant `pallet-xcm-bridge-hub-router` pallet instance.

`pallet-bridge-messages`'s `receive_messages_proof` does another check for congestion or back-preassure
with checking status of underlaying XCMP queue (`cumulus_pallet_xcmp_queue::bridging::OutboundXcmpChannelCongestionStatusProvider`).
If we cannot deliver a message to the target, then `receive_messages_proof` returns error and Bridge Hub does not allow to receive new bridged messages.

More about congestion detection [here](paritytech/parity-bridges-common#2318).

Signed-off-by: Branislav Kontur <bkontur@gmail.com>
Signed-off-by: Adrian Catangiu <adrian@parity.io>
Signed-off-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
Signed-off-by: Serban Iorga <serban@parity.io>

Co-authored-by: Adrian Catangiu <adrian@parity.io>
Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
Co-authored-by: Serban Iorga <serban@parity.io>
Update cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/bridge_hub_config.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/bridge_hub_config.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/bridge_hub_config.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/common/src/matching.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/common/src/matching.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/common/src/matching.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/common/src/matching.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/common/src/matching.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/common/src/matching.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/common/src/matching.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Update cumulus/parachains/runtimes/assets/common/src/matching.rs

Co-authored-by: Adrian Catangiu <adrian@parity.io>

Fmt + one any to all

Co-authored-by: Adrian Catangiu <adrian@parity.io>
@acatangiu
Copy link
Contributor

closing in favor of polkadot-fellows/runtimes#108

@acatangiu acatangiu closed this Jan 3, 2024
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
serban300 pushed a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
…ubmit transactions (paritytech#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
bkchr pushed a commit that referenced this pull request Apr 10, 2024
…ubmit transactions (#1352)

* CheckBridgedBlockNumber signed extension to reject duplicate header submit transactions

* fix depends_on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T6-XCM This PR/Issue is related to XCM. T9-cumulus This PR/Issue is related to cumulus. T15-bridges This PR/Issue is related to bridges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants