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

Added Polkadot <> Kusama bridge configuration #108

Merged
merged 76 commits into from
Jan 8, 2024

Conversation

svyatonik
Copy link
Contributor

This PR adds bridge configuration to allow exchanging assets between Polkadot and Kusama Asset Hubs. So far we only support sending KSM from Kusama Asset Hub to Polkadot Asset Hub as wKSM + DOT from Polkadot Asset Hub to Kusama Asset Hub as wDOT. Other assets may be added later.

The opposite direction is also supported, though it'll need dependencies upgrade to >= v1.4.


Similar Rococo <> Westend bridge is also active on live chains. You may read docs on how to play with it here: https://github.com/paritytech/polkadot-sdk/blob/master/cumulus/parachains/runtimes/bridge-hubs/README.md

For Polkadot <> Kusama bridge we have a dedicated branch for local zombienet tests: https://github.com/svyatonik/runtimes/tree/sv-pk-bridge-with-zombienet-tests. You may run autotests (exchanging assets) there - see https://github.com/svyatonik/runtimes/blob/sv-pk-bridge-with-zombienet-tests/system-parachains/bridge-hubs/zombienet/README.md for details. You may do manual tests by spawning local chains using those scripts and use https://github.com/svyatonik/runtimes/blob/sv-pk-bridge-with-zombienet-tests/system-parachains/bridge-hubs/zombienet/scripts/bridges_kusama_polkadot.sh script to run various commands - i.e. send assets manually. Polkadot js apps is also supported.

svyatonik and others added 30 commits November 30, 2023 08:45
…00_000_000. Otherwise msg is treated as overweight by target AH and is not autodispatched. Need to check that before release
…k pallet --chain bh-polkadot-local-raw.json --pallet pallet-bridge-grandpa --extrinsic "*" --output=system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights --no-median-slopes --no-min-squares
…k pallet --chain bh-polkadot-local-raw.json --pallet pallet-bridge-relayers --extrinsic "*" --output=system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights --no-median-slopes --no-min-squares
…k pallet --chain bh-polkadot-local-raw.json --pallet pallet-bridge-parachains --extrinsic "*" --output=system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights --no-median-slopes --no-min-squares
…k pallet --chain bh-polkadot-local-raw.json --pallet pallet-bridge-messages --extrinsic "*" --output=system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights --no-median-slopes --no-min-squares
…k pallet --chain bh-polkadot-local-raw.json --pallet pallet-xcm-benchmarks:: --extrinsic "report_holding,buy_execution,query_response,transact,refund_surplus,set_error_handler,set_appendix,clear_error,descend_origin,clear_origin,report_error,claim_asset,trap,subscribe_version,unsubscribe_version,burn_asset,expect_asset,expect_origin,expect_error,expect_transact_status,query_pallet,report_transact_status,clear_transact_status,set_topic,clear_topic,export_message,set_fees_mode,unpaid_execution" --output=system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights/xcm --no-median-slopes --no-min-squares

+ manually add expect_pallet benchmark results
…k pallet --chain bh-polkadot-local-raw.json --pallet pallet-xcm-benchmarks::fungible --extrinsic "*" --output=system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights/xcm --no-median-slopes --no-min-squares
…k pallet --chain bh-kusama-local-raw.json --pallet pallet-bridge-grandpa --extrinsic "*" --output=system-parachains/bridge-hubs/bridge-hub-kusama/src/weights --no-median-slopes --no-min-squares
…k pallet --chain bh-kusama-local-raw.json --pallet pallet-bridge-relayers --extrinsic "*" --output=system-parachains/bridge-hubs/bridge-hub-kusama/src/weights --no-median-slopes --no-min-squares
…k pallet --chain bh-kusama-local-raw.json --pallet pallet-bridge-parachains --extrinsic "*" --output=system-parachains/bridge-hubs/bridge-hub-kusama/src/weights --no-median-slopes --no-min-squares
…k pallet --chain bh-kusama-local-raw.json --pallet pallet-bridge-messages --extrinsic "*" --output=system-parachains/bridge-hubs/bridge-hub-kusama/src/weights --no-median-slopes --no-min-squares
…k pallet --chain bh-kusama-local-raw.json --pallet pallet-xcm-benchmarks::generic --extrinsic "report_holding,buy_execution,query_response,transact,refund_surplus,set_error_handler,set_appendix,clear_error,descend_origin,clear_origin,report_error,claim_asset,trap,subscribe_version,unsubscribe_version,burn_asset,expect_asset,expect_origin,expect_error,expect_transact_status,query_pallet,report_transact_status,clear_transact_status,set_topic,clear_topic,export_message,set_fees_mode,unpaid_execution" --output=system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/xcm --no-median-slopes --no-min-squares
…k pallet --chain bh-kusama-local-raw.json --pallet pallet-xcm-benchmarks::fungible --extrinsic "*" --output=system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/xcm --no-median-slopes --no-min-squares
…k pallet --chain ah-polkadot-local-raw.json --pallet pallet-xcm-benchmarks::generic --extrinsic "report_holding,buy_execution,query_response,transact,refund_surplus,set_error_handler,set_appendix,clear_error,descend_origin,clear_origin,report_error,claim_asset,trap,subscribe_version,unsubscribe_version,burn_asset,expect_asset,expect_origin,expect_error,expect_transact_status,query_pallet,report_transact_status,clear_transact_status,set_topic,clear_topic,export_message,set_fees_mode,unpaid_execution" --output=system-parachains/asset-hubs/asset-hub-polkadot/src/weights/xcm --no-median-slopes --no-min-squares
…k pallet --chain ah-polkadot-local-raw.json --pallet pallet-xcm-benchmarks::fungible --extrinsic "*" --output=system-parachains/asset-hubs/asset-hub-polkadot/src/weights/xcm --no-median-slopes --no-min-squares
@acatangiu
Copy link
Contributor

@KiChjang @muharem please help with reviews of this PR which is mostly XCM and System Chains changes.

@@ -258,6 +262,17 @@ impl Contains<RuntimeCall> for SafeCallFilter {
}
}

// Allow to change dedicated storage items (called by governance-like)
match call {
RuntimeCall::System(frame_system::Call::set_storage { items })
Copy link
Contributor

Choose a reason for hiding this comment

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

this does breaks the third rule described above in the docs for SafeCallFilter. However, it's worth checking whether those rules can be removed, if these changes included in the current release - paritytech/polkadot-sdk#1246

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only reads affect proof size and set_storage makes no any reads. Also we use .iter().all(), comparing with just two keys, so it won't make more than two writes, so this vec is kinda bounded.

pub const WITH_BRIDGE_HUB_KUSAMA_RELAYERS_PALLET_NAME: &str = "BridgeRelayers";

/// Pallet index of `BridgePolkadotMessages: pallet_bridge_messages::<Instance1>`.
pub const WITH_BRIDGE_KUSAMA_TO_POLKADOT_MESSAGES_PALLET_INDEX: u8 = 53;
Copy link
Contributor

Choose a reason for hiding this comment

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

these look like constants, not primitives. wont block PR because of this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It declares some primitives as well - e.g. it reexports hashers, block numbers and etc. So it is both consts and primitives.

Copy link
Contributor

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Left some comments. Clearly did not read every detail of the pr, but looking good from what I can say.

system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +85 to +89
pub const BridgeHubPolkadotBaseDeliveryFeeInDots: Balance = 16_954_899_613;

/// Transaction fee that is paid at the Polkadot BridgeHub for delivering single outbound message confirmation.
/// (initially was calculated by test `BridgeHubPolkadot::can_calculate_fee_for_complex_message_confirmation_transaction` + `33%`)
pub const BridgeHubPolkadotBaseConfirmationFeeInDots: Balance = 16_183_099_613;
Copy link
Contributor

Choose a reason for hiding this comment

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

1.6DOT? is that correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

@bkontur any idea about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes this is the current cost

/// Number of Kusama Bridge Hub headers to keep in the runtime storage.
///
/// Note that we are keeping only required header information, not the whole header itself. Roughly, it
/// is the 2 hours of real time (assuming that every header is submitted).
Copy link
Contributor

Choose a reason for hiding this comment

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

But 1 hour are 600 blocks, so shouldn't this be 1200 for keeping 2 hours?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, RelayChainHeadersToKeep is correct. I assume this still assumes that there are only a parachain block every 12 seconds? If yes, this is not correct anymore and we should update this as well to 1200.

///
/// Note that we are keeping only required header information, not the whole header itself. Roughly, it
/// is the 2 hours of real time (assuming that every header is submitted).
pub const ParachainHeadsToKeep: u32 = 600;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as for Polkadot.

@bkchr
Copy link
Contributor

bkchr commented Jan 8, 2024

@svyatonik @acatangiu can you please merge master and fix the merge conflicts?

@bkontur
Copy link
Contributor

bkontur commented Jan 8, 2024

@svyatonik @acatangiu can you please merge master and fix the merge conflicts?

I think both are ooo, I will try

@bkchr
Copy link
Contributor

bkchr commented Jan 8, 2024

Ty!

# Conflicts:
#	relay/kusama/src/weights/pallet_xcm_benchmarks_generic.rs
#	system-parachains/asset-hubs/asset-hub-kusama/src/weights/pallet_xcm_benchmarks_fungible.rs
#	system-parachains/asset-hubs/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
#	system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
#	system-parachains/asset-hubs/asset-hub-polkadot/src/weights/pallet_xcm_benchmarks_fungible.rs
#	system-parachains/asset-hubs/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
#	system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/pallet_xcm_benchmarks_fungible.rs
#	system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
#	system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs
#	system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_xcm_benchmarks_fungible.rs
#	system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
#	system-parachains/bridge-hubs/bridge-hub-polkadot/tests/tests.rs
@bkchr
Copy link
Contributor

bkchr commented Jan 8, 2024

/merge

@fellowship-merge-bot fellowship-merge-bot bot merged commit 98872cb into polkadot-fellows:main Jan 8, 2024
15 checks passed
@fellowship-merge-bot
Copy link
Contributor

Enabled auto-merge in Pull Request

Available commands
  • /merge: Enables auto-merge for Pull Request
  • /merge cancel: Cancels auto-merge for Pull Request
  • /merge help: Shows this menu

For more information see the documentation

fellowship-merge-bot bot pushed a commit that referenced this pull request Mar 21, 2024
- [x] Adds asset hub and bridge hub to Kusama and Polkadot runtimes
- [x] based off #108 -
needs to be merged first
- [x] snowbridge crates needs to be published on crates.io - depends on
`polkadot-sdk 1.7.0`
- [x] MessageQueue Pallet is not configured on Kusama and Polkadot asset
hub - added in #137
- [x] `FeeManager` `handle_fee` misses reason, crate needs to be updated
I think

cc @vgeddes @alistair-singh @yrong @musnit

---------

Signed-off-by: Adrian Catangiu <adrian@parity.io>
Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: Ross Bulat <ross@parity.io>
Co-authored-by: claravanstaden <Cats 4 life!>
Co-authored-by: Alain Brenzikofer <alain@integritee.network>
Co-authored-by: eskimor <eskimor@no-such-url.com>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
Co-authored-by: brenzi <brenzi@users.noreply.github.com>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
Co-authored-by: ron <yrong1997@gmail.com>
Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
Co-authored-by: Vincent Geddes <vincent.geddes@hey.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants