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
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4617ffa
asset-hubs: transfer assets via bridge using pallet-xcm
acatangiu Aug 28, 2023
a517420
Transfer reserve asset with dynamic fees and back-pressure.
bkontur Sep 3, 2023
945ea7f
Kusama/Polkadot BridgeHub allows bridging between Kusama/Polkadot (re…
bkontur Sep 4, 2023
4af6519
Extended Kusama/Polkadot BridgeHub with dynamic fees and congestion s…
bkontur Sep 4, 2023
867321c
Update review comments from Adrian
bkontur Sep 5, 2023
11e0931
Merge branch 'master' into bko-bridging-kusama-polkadot-assets
bkontur Sep 7, 2023
a3d1264
Fixed local run for AssetHubKusama/AssetHubPolkadot asset transfer (K…
bkontur Sep 11, 2023
0aeb13a
Merge remote-tracking branch 'origin/master' into bko-bridging-kusama…
bkontur Sep 19, 2023
c20f3e4
Zombienet nits
bkontur Sep 19, 2023
80964f9
Merge remote-tracking branch 'origin/master' into bko-bridging-kusama…
bkontur Sep 19, 2023
6fe8678
Merge remote-tracking branch 'origin/master' into bko-bridging-kusama…
bkontur Sep 19, 2023
b2015dc
Fix benchmarks
bkontur Sep 19, 2023
1fd7aaa
Fix benchmarks
bkontur Sep 19, 2023
791d6dd
Backporting nits from https://github.com/paritytech/polkadot-sdk/pull…
bkontur Sep 21, 2023
2cd5e55
Merge remote-tracking branch 'origin/master' into bko-bridging-kusama…
bkontur Sep 21, 2023
344e0b0
ParaIds as constants to primitives
bkontur Sep 21, 2023
d42e481
Fix
bkontur Sep 21, 2023
76ca00b
Fix
bkontur Sep 21, 2023
03511e0
ensure_configuration -> prepare_configuration
bkontur Sep 22, 2023
fc9727c
Constants nit
bkontur Sep 22, 2023
534c718
Deps
bkontur Sep 22, 2023
58d6319
Cargo.lock
bkontur Sep 22, 2023
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
Prev Previous commit
Next Next commit
Zombienet nits
  • Loading branch information
bkontur committed Sep 19, 2023
commit c20f3e4f6131200b0327333b289568ddef5d3a83
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ fn receive_reserve_asset_deposited_dot_from_asset_hub_polkadot_works() {
AccountId::from([73; 32]),
AccountId::from(BLOCK_AUTHOR_ACCOUNT),
// receiving DOTs
(MultiLocation { parents: 2, interior: X1(GlobalConsensus(Polkadot)) }, 1000000000000, 1_000_000_000),
(MultiLocation { parents: 2, interior: X1(GlobalConsensus(Polkadot)) }, 1000000000000, 1_00_000_000),
bridging_to_asset_hub_polkadot,
(X1(PalletInstance(53)), GlobalConsensus(Polkadot), X1(Parachain(1000)))
)
Expand Down
26 changes: 9 additions & 17 deletions cumulus/parachains/runtimes/bridge-hubs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ Copy the apropriate binary (zombienet-linux) from the latest release to ~/local_
# 2. Build polkadot binary

# If you want to test Kusama/Polkadot bridge, we need "sudo pallet + fast-runtime",
# so we need to use sudoif in polkadot directory.
# so we need to use sudofi in polkadot directory.
#
# Install sudoif: (skip if already installed)
# Install sudofi: (skip if already installed)
# cd <somewhere-outside-polkadot-sdk-git-repo-dir>
# git clone https://github.com/paritytech/parachain-utils.git
# cd parachain-utils # -> this is <parachain-utils-git-repo-dir>
# cargo build --release --bin sudofi
#
# cd <polkadot-sdk-git-repo-dir>/pokladot
# <parachain-utils-git-repo-dir>/target/release/sudoif
# cd <polkadot-sdk-git-repo-dir>/polkadot
# <parachain-utils-git-repo-dir>/target/release/sudofi

cd <polkadot-sdk-git-repo-dir>
cargo build --release --features fast-runtime --bin polkadot
Expand All @@ -68,6 +68,7 @@ cp target/release/polkadot-prepare-worker ~/local_bridge_testing/bin/polkadot-pr
cargo build --release --features fast-runtime --bin polkadot-execute-worker
cp target/release/polkadot-execute-worker ~/local_bridge_testing/bin/polkadot-execute-worker


---
# 3. Build substrate-relay binary
git clone https://github.com/paritytech/parity-bridges-common.git
Expand All @@ -87,21 +88,12 @@ cp target/release/substrate-relay ~/local_bridge_testing/bin/substrate-relay
# 4. Build cumulus polkadot-parachain binary
cd <polkadot-sdk-git-repo-dir>

# checkout desired branch or use master:
# git checkout -b master --track origin/master

cargo build --release --locked --bin polkadot-parachain
cargo build --release -p polkadot-parachain-bin
cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain
cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain-asset-hub

# For Rococo/Wococo local bridge testing: (obsolete)
#
# build AssetHubs (polkadot-parachain-asset-hub) from branch:
# git checkout -b bko-transfer-asset-via-bridge-pallet-xcm-ro-wo --track origin/bko-transfer-asset-via-bridge-pallet-xcm-ro-wo
# cargo build --release --locked --bin polkadot-parachain
# cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain-asset-hub
```


## How to test local Rococo <-> Wococo bridge

### Run chains (Rococo + BridgeHub + AssetHub, Wococo + BridgeHub + AssetHub) with zombienet
Expand Down Expand Up @@ -278,13 +270,13 @@ Do (asset) transfers:
```
cd <polkadot-sdk-git-repo-dir>

# KSMs from Kusama's Asset Hub to Polkadot's.
# 2.5 KSMs from Kusama's Asset Hub to Polkadot's.
./cumulus/scripts/bridges_kusama_polkadot.sh reserve-transfer-assets-from-asset-hub-kusama-local
```
```
cd <polkadot-sdk-git-repo-dir>

# DOTs from Polkadot's Asset Hub to Kusama's.
# 30 DOTs from Polkadot's Asset Hub to Kusama's.
./cumulus/scripts/bridges_kusama_polkadot.sh reserve-transfer-assets-from-asset-hub-polkadot-local
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ impl ThisChainWithMessages for ThisChain {
pub type BridgeRefundBridgeHubPolkadotMessages = RefundBridgedParachainMessages<
Runtime,
RefundableParachain<BridgeParachainPolkadotInstance, BridgeHubPolkadot>,
RefundableMessagesLane<WithBridgeHubPolkadotMessagesInstance, StatemineToStatemintMessageLane>,
RefundableMessagesLane<
WithBridgeHubPolkadotMessagesInstance,
AssetHubKusamaToAssetHubPolkadotMessageLane,
>,
ActualFeeRefund<Runtime>,
PriorityBoostPerMessage,
StrBridgeRefundBridgeHubPolkadotMessages,
Expand All @@ -173,7 +176,7 @@ bp_runtime::generate_static_str_provider!(BridgeRefundBridgeHubPolkadotMessages)
pub const ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT_LANE_ID: LaneId = LaneId([0, 0, 0, 0]);
parameter_types! {
pub ActiveOutboundLanesToBridgeHubPolkadot: &'static [bp_messages::LaneId] = &[ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT_LANE_ID];
pub const StatemineToStatemintMessageLane: bp_messages::LaneId = ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT_LANE_ID;
pub const AssetHubKusamaToAssetHubPolkadotMessageLane: bp_messages::LaneId = ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT_LANE_ID;
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1078,36 +1078,45 @@ cumulus_pallet_parachain_system::register_validate_block! {
#[cfg(test)]
mod tests {
use super::*;
use bp_runtime::TransactionEra;
use bridge_hub_test_utils::test_header;
use codec::Encode;

pub type TestBlockHeader =
generic::Header<bp_polkadot_core::BlockNumber, bp_polkadot_core::Hasher>;
use sp_runtime::{
generic::Era,
traits::{SignedExtension, Zero},
};

#[test]
fn ensure_signed_extension_definition_is_compatible_with_relay() {
let payload: SignedExtra = (
frame_system::CheckNonZeroSender::new(),
frame_system::CheckSpecVersion::new(),
frame_system::CheckTxVersion::new(),
frame_system::CheckGenesis::new(),
frame_system::CheckEra::from(sp_runtime::generic::Era::Immortal),
frame_system::CheckNonce::from(10),
frame_system::CheckWeight::new(),
pallet_transaction_payment::ChargeTransactionPayment::from(10),
BridgeRejectObsoleteHeadersAndMessages::default(),
BridgeRefundBridgeHubPolkadotMessages::default(),
);
use bp_bridge_hub_kusama::BridgeHubSignedExtension;
let bh_indirect_payload = bp_bridge_hub_kusama::SignedExtension::from_params(
10,
10,
TransactionEra::Immortal,
test_header::<TestBlockHeader>(1).hash(),
10,
10,
);
assert_eq!(payload.encode(), bh_indirect_payload.encode());
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;

sp_io::TestExternalities::default().execute_with(|| {
frame_system::BlockHash::<Runtime>::insert(BlockNumber::zero(), Hash::default());
let payload: SignedExtra = (
frame_system::CheckNonZeroSender::new(),
frame_system::CheckSpecVersion::new(),
frame_system::CheckTxVersion::new(),
frame_system::CheckGenesis::new(),
frame_system::CheckEra::from(Era::Immortal),
frame_system::CheckNonce::from(10),
frame_system::CheckWeight::new(),
pallet_transaction_payment::ChargeTransactionPayment::from(10),
BridgeRejectObsoleteHeadersAndMessages,
BridgeRefundBridgeHubPolkadotMessages::default(),
);

let bh_indirect_payload = bp_bridge_hub_polkadot::SignedExtension::from_params(
VERSION.spec_version,
VERSION.transaction_version,
bp_runtime::TransactionEra::Immortal,
System::block_hash(BlockNumber::zero()),
10,
10,
(((), ()), ((), ())),
);
assert_eq!(payload.encode(), bh_indirect_payload.encode());
assert_eq!(
payload.additional_signed().unwrap().encode(),
bh_indirect_payload.additional_signed().unwrap().encode()
);
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ impl ThisChainWithMessages for ThisChain {
pub type BridgeRefundBridgeHubKusamaMessages = RefundBridgedParachainMessages<
Runtime,
RefundableParachain<BridgeParachainKusamaInstance, BridgeHubKusama>,
RefundableMessagesLane<WithBridgeHubKusamaMessagesInstance, StatemintToStatemineMessageLane>,
RefundableMessagesLane<
WithBridgeHubKusamaMessagesInstance,
AssetHubPolkadotToAssetHubKusamaMessageLane,
>,
ActualFeeRefund<Runtime>,
PriorityBoostPerMessage,
StrBridgeRefundBridgeHubKusamaMessages,
Expand All @@ -172,7 +175,7 @@ bp_runtime::generate_static_str_provider!(BridgeRefundBridgeHubKusamaMessages);
pub const ASSET_HUB_POLKADOT_TO_ASSET_HUB_KUSAMA_LANE_ID: LaneId = LaneId([0, 0, 0, 0]);
parameter_types! {
pub ActiveOutboundLanesToBridgeHubKusama: &'static [bp_messages::LaneId] = &[ASSET_HUB_POLKADOT_TO_ASSET_HUB_KUSAMA_LANE_ID];
pub const StatemintToStatemineMessageLane: bp_messages::LaneId = ASSET_HUB_POLKADOT_TO_ASSET_HUB_KUSAMA_LANE_ID;
pub const AssetHubPolkadotToAssetHubKusamaMessageLane: bp_messages::LaneId = ASSET_HUB_POLKADOT_TO_ASSET_HUB_KUSAMA_LANE_ID;
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,36 +1079,45 @@ cumulus_pallet_parachain_system::register_validate_block! {
#[cfg(test)]
mod tests {
use super::*;
use bp_runtime::TransactionEra;
use bridge_hub_test_utils::test_header;
use codec::Encode;

pub type TestBlockHeader =
generic::Header<bp_polkadot_core::BlockNumber, bp_polkadot_core::Hasher>;
use sp_runtime::{
generic::Era,
traits::{SignedExtension, Zero},
};

#[test]
fn ensure_signed_extension_definition_is_compatible_with_relay() {
let payload: SignedExtra = (
frame_system::CheckNonZeroSender::new(),
frame_system::CheckSpecVersion::new(),
frame_system::CheckTxVersion::new(),
frame_system::CheckGenesis::new(),
frame_system::CheckEra::from(sp_runtime::generic::Era::Immortal),
frame_system::CheckNonce::from(10),
frame_system::CheckWeight::new(),
pallet_transaction_payment::ChargeTransactionPayment::from(10),
BridgeRejectObsoleteHeadersAndMessages::default(),
BridgeRefundBridgeHubKusamaMessages::default(),
);
use bp_bridge_hub_polkadot::BridgeHubSignedExtension;
let bh_indirect_payload = bp_bridge_hub_polkadot::SignedExtension::from_params(
10,
10,
TransactionEra::Immortal,
test_header::<TestBlockHeader>(1).hash(),
10,
10,
);
assert_eq!(payload.encode(), bh_indirect_payload.encode());
use bp_polkadot_core::SuffixedCommonSignedExtensionExt;

sp_io::TestExternalities::default().execute_with(|| {
frame_system::BlockHash::<Runtime>::insert(BlockNumber::zero(), Hash::default());
let payload: SignedExtra = (
frame_system::CheckNonZeroSender::new(),
frame_system::CheckSpecVersion::new(),
frame_system::CheckTxVersion::new(),
frame_system::CheckGenesis::new(),
frame_system::CheckEra::from(Era::Immortal),
frame_system::CheckNonce::from(10),
frame_system::CheckWeight::new(),
pallet_transaction_payment::ChargeTransactionPayment::from(10),
BridgeRejectObsoleteHeadersAndMessages,
BridgeRefundBridgeHubKusamaMessages::default(),
);

let bh_indirect_payload = bp_bridge_hub_polkadot::SignedExtension::from_params(
VERSION.spec_version,
VERSION.transaction_version,
bp_runtime::TransactionEra::Immortal,
System::block_hash(BlockNumber::zero()),
10,
10,
(((), ()), ((), ())),
);
assert_eq!(payload.encode(), bh_indirect_payload.encode());
assert_eq!(
payload.additional_signed().unwrap().encode(),
bh_indirect_payload.additional_signed().unwrap().encode()
);
})
}
}
11 changes: 6 additions & 5 deletions cumulus/scripts/bridges_kusama_polkadot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ ASSET_HUB_POLKADOT_ACCOUNT_ADDRESS_FOR_LOCAL="5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNe
#
# Generated by:
#
# #[test]
# fn generate_sovereign_accounts() {
# #[test]
# fn generate_sovereign_accounts() {
# use sp_core::crypto::Ss58Codec;
# use polkadot_parachain_primitives::primitives::Sibling;
#
# parameter_types! {
# pub UniversalLocationAHK: InteriorMultiLocation = X2(GlobalConsensus(Kusama), Parachain(1000));
Expand Down Expand Up @@ -142,7 +143,7 @@ case "$1" in
"ws://127.0.0.1:9910" \
"$(jq --null-input '{ "parents": 2, "interior": { "X1": { "GlobalConsensus": "Polkadot" } } }')" \
"$GLOBAL_CONSENSUS_POLKADOT_SOVEREIGN_ACCOUNT" \
1000000000 \
100000000 \
true
# drip SA which holds reserves
transfer_balance \
Expand Down Expand Up @@ -213,7 +214,7 @@ case "$1" in
"//Alice" \
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Polkadot" }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 1, "interior": "Here" } }, "fun": { "Fungible": 200000000000 } } ] }')" \
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 1, "interior": "Here" } }, "fun": { "Fungible": 2500000000000 } } ] }')" \
0 \
"Unlimited"
;;
Expand All @@ -225,7 +226,7 @@ case "$1" in
"//Alice" \
"$(jq --null-input '{ "V3": { "parents": 2, "interior": { "X2": [ { "GlobalConsensus": "Kusama" }, { "Parachain": 1000 } ] } } }')" \
"$(jq --null-input '{ "V3": { "parents": 0, "interior": { "X1": { "AccountId32": { "id": [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] } } } } }')" \
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 1, "interior": "Here" } }, "fun": { "Fungible": 3000000000 } } ] }')" \
"$(jq --null-input '{ "V3": [ { "id": { "Concrete": { "parents": 1, "interior": "Here" } }, "fun": { "Fungible": 300000000000 } } ] }')" \
0 \
"Unlimited"
;;
Expand Down
Loading