From 0dce6fb6aa7864516bb58574e78c9f2a3029b505 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Tue, 30 Jul 2024 17:21:47 +0300 Subject: [PATCH] Remove unused Kusama Snowbridge code Kusama does not have Ethereum Snowbridge deployed. This commit removes all that unused code. If we decide to deploy Kusama<>Ethereum bridge, we can bring it back. Signed-off-by: Adrian Catangiu --- CHANGELOG.md | 1 + Cargo.lock | 1 - .../bridges/bridge-hub-kusama/src/genesis.rs | 5 - .../bridges/bridge-hub-kusama/src/lib.rs | 3 - .../bridge-hub-kusama/src/tests/mod.rs | 1 - .../bridge-hub-kusama/src/tests/snowbridge.rs | 829 ------------------ .../asset-hubs/asset-hub-kusama/Cargo.toml | 3 - .../asset-hubs/asset-hub-kusama/src/lib.rs | 16 +- .../asset-hub-kusama/src/xcm_config.rs | 83 +- .../asset-hub-kusama/tests/snowbridge.rs | 76 -- .../asset-hub-kusama/tests/tests.rs | 26 - .../bridge-hub-kusama/primitives/src/lib.rs | 39 - .../src/bridge_to_ethereum_config.rs | 221 ----- .../src/genesis_config_presets.rs | 5 - .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 74 +- .../bridge-hub-kusama/src/weights/mod.rs | 4 - .../snowbridge_pallet_ethereum_client.rs | 119 --- .../snowbridge_pallet_inbound_queue.rs | 76 -- .../snowbridge_pallet_outbound_queue.rs | 95 -- .../src/weights/snowbridge_pallet_system.rs | 271 ------ .../bridge-hub-kusama/src/xcm_config.rs | 53 +- .../bridge-hub-kusama/tests/snowbridge.rs | 273 ------ .../bridge-hub-polkadot/src/lib.rs | 3 + 23 files changed, 49 insertions(+), 2228 deletions(-) delete mode 100644 integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs delete mode 100644 system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs delete mode 100644 system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_ethereum_config.rs delete mode 100644 system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_ethereum_client.rs delete mode 100644 system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_inbound_queue.rs delete mode 100644 system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_outbound_queue.rs delete mode 100644 system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_system.rs delete mode 100644 system-parachains/bridge-hubs/bridge-hub-kusama/tests/snowbridge.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b4c08f5c0..bba6fd3a07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Polkadot chains: allow arbitrary XCM execution ([polkadot-fellows/runtimes#345](https://github.com/polkadot-fellows/runtimes/pull/345)). - Bounties: Remove payout delay ([polkadot-fellows/runtimes#386](https://github.com/polkadot-fellows/runtimes/pull/386)). - Polkadot System Chains: Reduce the base transaction fee by half ([polkadot-fellows/runtimes#398](https://github.com/polkadot-fellows/runtimes/pull/398)). +- Kusama: Remove unused Snowbridge code and configs ([polkadot-fellows/runtimes#411](https://github.com/polkadot-fellows/runtimes/pull/411). #### From [#322](https://github.com/polkadot-fellows/runtimes/pull/322): diff --git a/Cargo.lock b/Cargo.lock index 46e250e527..82c90035b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -682,7 +682,6 @@ dependencies = [ "primitive-types", "scale-info", "serde_json", - "snowbridge-router-primitives", "sp-api", "sp-block-builder", "sp-consensus-aura", diff --git a/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/genesis.rs b/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/genesis.rs index f835a319c6..085f8e86a7 100644 --- a/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/genesis.rs +++ b/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/genesis.rs @@ -65,11 +65,6 @@ pub fn genesis() -> Storage { owner: Some(get_account_id_from_seed::(accounts::BOB)), ..Default::default() }, - ethereum_system: bridge_hub_kusama_runtime::EthereumSystemConfig { - para_id: PARA_ID.into(), - asset_hub_para_id: ASSET_HUB_PARA_ID.into(), - ..Default::default() - }, ..Default::default() }; diff --git a/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/lib.rs b/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/lib.rs index 038b6e7a44..808c2fb894 100644 --- a/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/lib.rs +++ b/integration-tests/emulated/chains/parachains/bridges/bridge-hub-kusama/src/lib.rs @@ -41,9 +41,6 @@ decl_test_parachains! { pallets = { PolkadotXcm: bridge_hub_kusama_runtime::PolkadotXcm, Balances: bridge_hub_kusama_runtime::Balances, - EthereumSystem: bridge_hub_kusama_runtime::EthereumSystem, - EthereumInboundQueue: bridge_hub_kusama_runtime::EthereumInboundQueue, - EthereumOutboundQueue: bridge_hub_kusama_runtime::EthereumOutboundQueue, } }, } diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/mod.rs b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/mod.rs index fee51267b6..811ebeb200 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/mod.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/mod.rs @@ -18,7 +18,6 @@ use crate::*; mod asset_transfers; mod claim_assets; mod send_xcm; -mod snowbridge; mod teleport; pub(crate) fn asset_hub_polkadot_location() -> Location { diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs deleted file mode 100644 index 90d9d92537..0000000000 --- a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs +++ /dev/null @@ -1,829 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -use crate::*; -use asset_hub_kusama_runtime::xcm_config::{ - bridging::to_ethereum::{BridgeHubEthereumBaseFee, EthereumNetwork}, - RelayTreasuryPalletAccount, -}; -use bp_bridge_hub_kusama::snowbridge::CreateAssetCall; -use bridge_hub_kusama_runtime::{ - bridge_to_ethereum_config::EthereumGatewayAddress, EthereumBeaconClient, EthereumInboundQueue, - Runtime, RuntimeOrigin, -}; -use codec::{Decode, Encode}; -use emulated_integration_tests_common::xcm_emulator::ConvertLocation; -use frame_support::pallet_prelude::TypeInfo; -use hex_literal::hex; -use kusama_system_emulated_network::{ - penpal_emulated_chain::CustomizableAssetFromSystemAssetHub, - BridgeHubKusamaParaSender as BridgeHubKusamaSender, -}; -use snowbridge_beacon_primitives::{ - types::deneb, AncestryProof, BeaconHeader, ExecutionProof, VersionedExecutionPayloadHeader, -}; -use snowbridge_core::{ - gwei, - inbound::{InboundQueueFixture, Log, Message, Proof}, - meth, - outbound::OperatingMode, - Rewards, -}; -use snowbridge_pallet_system::PricingParametersOf; -use snowbridge_router_primitives::inbound::{ - Command, Destination, GlobalConsensusEthereumConvertsFor, MessageV1, VersionedMessage, -}; -use sp_core::{H160, H256, U256}; -use sp_runtime::{DispatchError::Token, FixedU128, TokenError::FundsUnavailable}; -use system_parachains_constants::kusama::currency::UNITS; - -const INITIAL_FUND: u128 = 5_000_000_000 * KUSAMA_ED; -const CHAIN_ID: u64 = 1; -const WETH: [u8; 20] = hex!("87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d"); -const ETHEREUM_DESTINATION_ADDRESS: [u8; 20] = hex!("44a57ee2f2FCcb85FDa2B0B18EBD0D8D2333700e"); -const GATEWAY_ADDRESS: [u8; 20] = hex!("EDa338E4dC46038493b885327842fD3E301CaB39"); -const INSUFFICIENT_XCM_FEE: u128 = 1000; -const XCM_FEE: u128 = 4_000_000_000; -const WETH_AMOUNT: u128 = 1_000_000_000; - -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -pub enum ControlCall { - #[codec(index = 3)] - CreateAgent, - #[codec(index = 4)] - CreateChannel { mode: OperatingMode }, -} - -#[allow(clippy::large_enum_variant)] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -pub enum SnowbridgeControl { - #[codec(index = 83)] - Control(ControlCall), -} - -pub fn send_inbound_message(fixture: InboundQueueFixture) -> DispatchResult { - EthereumBeaconClient::store_finalized_header( - fixture.finalized_header, - fixture.block_roots_root, - ) - .unwrap(); - - EthereumInboundQueue::submit( - RuntimeOrigin::signed(BridgeHubKusamaSender::get()), - fixture.message, - ) -} - -/// Create an agent on Ethereum. An agent is a representation of an entity in the Polkadot -/// ecosystem (like a parachain) on Ethereum. -#[test] -fn create_agent() { - let origin_para: u32 = 1001; - // Fund the origin parachain sovereign account so that it can pay execution fees. - BridgeHubKusama::fund_para_sovereign(origin_para.into(), INITIAL_FUND); - // Fund Treasury account with ED so that when create agent fees are paid to treasury, - // the treasury account may exist. - BridgeHubKusama::fund_accounts(vec![(RelayTreasuryPalletAccount::get(), INITIAL_FUND)]); - - let sudo_origin = ::RuntimeOrigin::root(); - let destination = Kusama::child_location_of(BridgeHubKusama::para_id()).into(); - - let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {}); - // Construct XCM to create an agent for para 1001 - let remote_xcm = VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - DescendOrigin(Parachain(origin_para).into()), - Transact { - require_weight_at_most: 3000000000.into(), - origin_kind: OriginKind::Xcm, - call: create_agent_call.encode().into(), - }, - ])); - - // Kusama Global Consensus - // Send XCM message from Relay Chain to Bridge Hub source Parachain - Kusama::execute_with(|| { - assert_ok!(::XcmPallet::send( - sudo_origin, - bx!(destination), - bx!(remote_xcm), - )); - - type RuntimeEvent = ::RuntimeEvent; - // Check that the Transact message was sent - assert_expected_events!( - Kusama, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - BridgeHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - // Check that a message was sent to Ethereum to create the agent - assert_expected_events!( - BridgeHubKusama, - vec![ - RuntimeEvent::EthereumSystem(snowbridge_pallet_system::Event::CreateAgent { - .. - }) => {}, - ] - ); - }); -} - -/// Create a channel for a consensus system. A channel is a bidirectional messaging channel -/// between BridgeHub and Ethereum. -#[test] -fn create_channel() { - let origin_para: u32 = 1001; - // Fund AssetHub sovereign account so that it can pay execution fees. - BridgeHubKusama::fund_para_sovereign(origin_para.into(), INITIAL_FUND); - // Fund Treasury account with ED so that when create agent fees are paid to treasury, - // the treasury account may exist. - BridgeHubKusama::fund_accounts(vec![(RelayTreasuryPalletAccount::get(), INITIAL_FUND)]); - - let sudo_origin = ::RuntimeOrigin::root(); - let destination: VersionedLocation = - Kusama::child_location_of(BridgeHubKusama::para_id()).into(); - - let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {}); - // Construct XCM to create an agent for para 1001 - let create_agent_xcm = VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - DescendOrigin(Parachain(origin_para).into()), - Transact { - require_weight_at_most: 3000000000.into(), - origin_kind: OriginKind::Xcm, - call: create_agent_call.encode().into(), - }, - ])); - - let create_channel_call = - SnowbridgeControl::Control(ControlCall::CreateChannel { mode: OperatingMode::Normal }); - // Construct XCM to create a channel for para 1001 - let create_channel_xcm = VersionedXcm::from(Xcm(vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - DescendOrigin(Parachain(origin_para).into()), - Transact { - require_weight_at_most: 3000000000.into(), - origin_kind: OriginKind::Xcm, - call: create_channel_call.encode().into(), - }, - ])); - - // Kusama Global Consensus - // Send XCM message from Relay Chain to Bridge Hub source Parachain - Kusama::execute_with(|| { - assert_ok!(::XcmPallet::send( - sudo_origin.clone(), - bx!(destination.clone()), - bx!(create_agent_xcm), - )); - - assert_ok!(::XcmPallet::send( - sudo_origin, - bx!(destination), - bx!(create_channel_xcm), - )); - - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - Kusama, - vec![ - RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, - ] - ); - }); - - BridgeHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - // Check that the Channel was created - assert_expected_events!( - BridgeHubKusama, - vec![ - RuntimeEvent::EthereumSystem(snowbridge_pallet_system::Event::CreateChannel { - .. - }) => {}, - ] - ); - }); -} - -/// Tests the registering of a token as an asset on AssetHub. -#[test] -fn register_weth_token_from_ethereum_to_asset_hub() { - // Fund AH sovereign account on BH so that it can pay execution fees. - BridgeHubKusama::fund_para_sovereign(AssetHubKusama::para_id(), INITIAL_FUND); - // Fund ethereum sovereign account on AssetHub. - AssetHubKusama::fund_accounts(vec![(ethereum_sovereign_account(), INITIAL_FUND)]); - - BridgeHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_ok!(::System::set_storage( - ::RuntimeOrigin::root(), - vec![(EthereumGatewayAddress::key().to_vec(), H160(GATEWAY_ADDRESS).encode())], - )); - // Construct RegisterToken message and sent to inbound queue - let message_id: H256 = [1; 32].into(); - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::RegisterToken { token: WETH.into(), fee: XCM_FEE }, - }); - // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubKusama::para_id()).unwrap(); - - assert_expected_events!( - BridgeHubKusama, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - AssetHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - AssetHubKusama, - vec![ - RuntimeEvent::ForeignAssets(pallet_assets::Event::Created { .. }) => {}, - ] - ); - }); -} - -/// Tests sending a token to a 3rd party parachain, called PenPal. The token reserve is -/// still located on AssetHub. -#[test] -fn send_token_from_ethereum_to_penpal() { - let asset_hub_sovereign = BridgeHubKusama::sovereign_account_id_of(Location::new( - 1, - [Parachain(AssetHubKusama::para_id().into())], - )); - - // The Weth asset location, identified by the contract address on Ethereum - let weth_asset_location: Location = - (Parent, Parent, EthereumNetwork::get(), AccountKey20 { network: None, key: WETH }).into(); - // Converts the Weth asset location into an asset ID - let weth_asset_id: v3::Location = weth_asset_location.clone().try_into().unwrap(); - - // Fund ethereum sovereign on AssetHub - AssetHubKusama::fund_accounts(vec![(ethereum_sovereign_account(), INITIAL_FUND)]); - - // Create asset on the Penpal parachain. - PenpalA::execute_with(|| { - // Set the trusted asset location from AH, in this case, Ethereum. - assert_ok!(::System::set_storage( - ::RuntimeOrigin::root(), - vec![( - CustomizableAssetFromSystemAssetHub::key().to_vec(), - Location::new(2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })]).encode(), - )], - )); - - assert_ok!(::ForeignAssets::create( - ::RuntimeOrigin::signed(PenpalASender::get()), - weth_asset_location.clone(), - asset_hub_sovereign.clone().into(), - 1000, - )); - - assert!(::ForeignAssets::asset_exists(weth_asset_location)); - }); - - AssetHubKusama::execute_with(|| { - assert_ok!(::ForeignAssets::force_create( - ::RuntimeOrigin::root(), - weth_asset_id, - asset_hub_sovereign.clone().into(), - true, - 1000, - )); - - assert!(::ForeignAssets::asset_exists( - weth_asset_id - )); - }); - - BridgeHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - type RuntimeOrigin = ::RuntimeOrigin; - - // Fund AssetHub sovereign account so it can pay execution fees for the asset transfer - assert_ok!(::Balances::force_set_balance( - RuntimeOrigin::root(), - asset_hub_sovereign.clone().into(), - INITIAL_FUND, - )); - - let message_id: H256 = [1; 32].into(); - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::SendToken { - token: WETH.into(), - destination: Destination::ForeignAccountId32 { - para_id: PenpalA::para_id().into(), - id: PenpalAReceiver::get().into(), - fee: 40_000_000_000, - }, - amount: 1_000_000, - fee: 40_000_000_000, - }, - }); - // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubKusama::para_id()).unwrap(); - - assert_expected_events!( - BridgeHubKusama, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - AssetHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - // Check that the assets were issued on AssetHub - assert_expected_events!( - AssetHubKusama, - vec![ - RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - PenpalA::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - // Check that the assets were issued on PenPal - assert_expected_events!( - PenpalA, - vec![ - RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, - ] - ); - }); -} - -/// Tests the registering of a token as an asset on AssetHub, and then subsequently sending -/// a token from Ethereum to AssetHub. -#[test] -fn send_token_from_ethereum_to_asset_hub() { - BridgeHubKusama::fund_para_sovereign(AssetHubKusama::para_id(), INITIAL_FUND); - // Fund ethereum sovereign account on AssetHub. - AssetHubKusama::fund_accounts(vec![(ethereum_sovereign_account(), INITIAL_FUND)]); - - BridgeHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_ok!(::System::set_storage( - ::RuntimeOrigin::root(), - vec![(EthereumGatewayAddress::key().to_vec(), H160(GATEWAY_ADDRESS).encode())], - )); - - // Construct RegisterToken message and sent to inbound queue - let message_id: H256 = [1; 32].into(); - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::RegisterToken { token: WETH.into(), fee: XCM_FEE }, - }); - // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubKusama::para_id()).unwrap(); - - assert_expected_events!( - BridgeHubKusama, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - - // Construct SendToken message and sent to inbound queue - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::SendToken { - token: WETH.into(), - destination: Destination::AccountId32 { id: AssetHubKusamaReceiver::get().into() }, - amount: WETH_AMOUNT, - fee: XCM_FEE, - }, - }); - // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubKusama::para_id()).unwrap(); - - // Check that the message was sent - assert_expected_events!( - BridgeHubKusama, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - AssetHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - // Check that the token was received and issued as a foreign asset on AssetHub - assert_expected_events!( - AssetHubKusama, - vec![ - RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, - ] - ); - }); -} - -/// Tests the full cycle of token transfers: -/// - registering a token on AssetHub -/// - sending a token to AssetHub -/// - returning the token to Ethereum -#[test] -fn send_weth_asset_from_asset_hub_to_ethereum() { - let assethub_sovereign = BridgeHubKusama::sovereign_account_id_of(Location::new( - 1, - [Parachain(AssetHubKusama::para_id().into())], - )); - - AssetHubKusama::force_default_xcm_version(Some(XCM_VERSION)); - BridgeHubKusama::force_default_xcm_version(Some(XCM_VERSION)); - AssetHubKusama::force_xcm_version( - Location::new(2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })]), - XCM_VERSION, - ); - - BridgeHubKusama::fund_accounts(vec![ - (assethub_sovereign.clone(), INITIAL_FUND), - (RelayTreasuryPalletAccount::get(), INITIAL_FUND), - ]); - AssetHubKusama::fund_accounts(vec![ - (AssetHubKusamaReceiver::get(), INITIAL_FUND), - (ethereum_sovereign_account(), INITIAL_FUND), - ]); - - let base_fee = 2_750_872_500_000u128; - - AssetHubKusama::execute_with(|| { - assert_ok!(::System::set_storage( - ::RuntimeOrigin::root(), - vec![(BridgeHubEthereumBaseFee::key().to_vec(), base_fee.encode())], - )); - }); - - BridgeHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_ok!( - ::EthereumSystem::set_pricing_parameters( - ::RuntimeOrigin::root(), - PricingParametersOf:: { - exchange_rate: FixedU128::from_rational(1, 75), - fee_per_gas: gwei(20), - rewards: Rewards { - local: (UNITS / 100), // 0.01 KSM - remote: meth(1), - }, - multiplier: FixedU128::from_rational(1, 1), - } - ) - ); - - assert_ok!(::System::set_storage( - ::RuntimeOrigin::root(), - vec![(EthereumGatewayAddress::key().to_vec(), H160(GATEWAY_ADDRESS).encode())], - )); - - let message_id: H256 = [1; 32].into(); - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::RegisterToken { token: WETH.into(), fee: XCM_FEE }, - }); - // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubKusama::para_id()).unwrap(); - - // Check that the register token message was sent using xcm - assert_expected_events!( - BridgeHubKusama, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - - // Construct SendToken message and sent to inbound queue - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::SendToken { - token: WETH.into(), - destination: Destination::AccountId32 { id: AssetHubKusamaReceiver::get().into() }, - amount: WETH_AMOUNT, - fee: XCM_FEE, - }, - }); - // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubKusama::para_id()).unwrap(); - - // Check that the send token message was sent using xcm - assert_expected_events!( - BridgeHubKusama, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - // check treasury account balance on BH before - let treasury_account_before = BridgeHubKusama::execute_with(|| { - <::Balances as frame_support::traits::fungible::Inspect<_>>::balance(&RelayTreasuryPalletAccount::get()) - }); - - AssetHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type RuntimeOrigin = ::RuntimeOrigin; - - // Check that AssetHub has issued the foreign asset - assert_expected_events!( - AssetHubKusama, - vec![ - RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, - ] - ); - let assets = vec![Asset { - id: AssetId(Location::new( - 2, - [ - GlobalConsensus(Ethereum { chain_id: CHAIN_ID }), - AccountKey20 { network: None, key: WETH }, - ], - )), - fun: Fungible(WETH_AMOUNT), - }]; - let multi_assets = VersionedAssets::from(Assets::from(assets)); - - let destination = VersionedLocation::from(Location::new( - 2, - [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })], - )); - - let beneficiary = VersionedLocation::from(Location::new( - 0, - [AccountKey20 { network: None, key: ETHEREUM_DESTINATION_ADDRESS }], - )); - - let free_balance_before = ::Balances::free_balance( - AssetHubKusamaReceiver::get(), - ); - // Send the Weth back to Ethereum - assert_ok!( - ::PolkadotXcm::limited_reserve_transfer_assets( - RuntimeOrigin::signed(AssetHubKusamaReceiver::get()), - Box::new(destination), - Box::new(beneficiary), - Box::new(multi_assets), - 0, - Unlimited, - ) - ); - - let free_balance_after = ::Balances::free_balance( - AssetHubKusamaReceiver::get(), - ); - // Assert at least DefaultBridgeHubEthereumBaseFee charged from the sender - let free_balance_diff = free_balance_before - free_balance_after; - assert!(free_balance_diff > base_fee); - }); - - BridgeHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - // Check that the transfer token back to Ethereum message was queue in the Ethereum - // Outbound Queue - assert_expected_events!( - BridgeHubKusama, - vec![ - RuntimeEvent::EthereumOutboundQueue(snowbridge_pallet_outbound_queue::Event::MessageQueued {..}) => {}, - ] - ); - - // check treasury account balance on BH after (should receive some fees) - let treasury_account_after = <::Balances as frame_support::traits::fungible::Inspect<_>>::balance(&RelayTreasuryPalletAccount::get()); - let local_fee = treasury_account_after - treasury_account_before; - - let events = BridgeHubKusama::events(); - // Check that the local fee was credited to the Snowbridge sovereign account - assert!( - events.iter().any(|event| matches!( - event, - RuntimeEvent::Balances(pallet_balances::Event::Minted { who, amount }) - if *who == RelayTreasuryPalletAccount::get() && *amount == local_fee - )), - "Snowbridge sovereign takes local fee." - ); - // Check that the remote delivery fee was credited to the AssetHub sovereign account - assert!( - events.iter().any(|event| matches!( - event, - RuntimeEvent::Balances(pallet_balances::Event::Minted { who, .. }) - if *who == assethub_sovereign, - )), - "AssetHub sovereign takes remote fee." - ); - }); -} - -#[test] -fn register_weth_token_in_asset_hub_fail_for_insufficient_fee() { - BridgeHubKusama::fund_para_sovereign(AssetHubKusama::para_id(), INITIAL_FUND); - - BridgeHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_ok!(::System::set_storage( - ::RuntimeOrigin::root(), - vec![(EthereumGatewayAddress::key().to_vec(), H160(GATEWAY_ADDRESS).encode())], - )); - - let message_id: H256 = [1; 32].into(); - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::RegisterToken { token: WETH.into(), fee: INSUFFICIENT_XCM_FEE }, - }); - // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubKusama::para_id()).unwrap(); - - assert_expected_events!( - BridgeHubKusama, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - AssetHubKusama::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - AssetHubKusama, - vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success:false, .. }) => {}, - ] - ); - }); -} - -#[test] -fn send_token_from_ethereum_to_asset_hub_fail_for_insufficient_fund() { - // Insufficient fund - BridgeHubKusama::fund_para_sovereign(AssetHubKusama::para_id(), 1_000); - - BridgeHubKusama::execute_with(|| { - assert_ok!(::System::set_storage( - ::RuntimeOrigin::root(), - vec![(EthereumGatewayAddress::key().to_vec(), H160(GATEWAY_ADDRESS).encode())], - )); - - assert_err!(send_inbound_message(make_register_token_message()), Token(FundsUnavailable)); - }); -} - -/// Tests that the EthereumInboundQueue CreateAssetCall parameter on BridgeHub matches -/// the ForeignAssets::create call on AssetHub. -#[test] -fn asset_hub_foreign_assets_pallet_is_configured_correctly_in_bridge_hub() { - let assethub_sovereign = BridgeHubKusama::sovereign_account_id_of(Location::new( - 1, - [Parachain(AssetHubKusama::para_id().into())], - )); - - let call_create_foreign_assets = - ::RuntimeCall::ForeignAssets(pallet_assets::Call::< - ::Runtime, - pallet_assets::Instance2, - >::create { - id: v3::Location::default(), - min_balance: ASSET_MIN_BALANCE, - admin: assethub_sovereign.into(), - }) - .encode(); - - let bridge_hub_inbound_queue_assets_pallet_call_index = CreateAssetCall::get(); - - assert!( - call_create_foreign_assets.starts_with(&bridge_hub_inbound_queue_assets_pallet_call_index) - ); -} - -fn ethereum_sovereign_account() -> AccountId { - let origin_location = (Parent, Parent, EthereumNetwork::get()).into(); - GlobalConsensusEthereumConvertsFor::::convert_location(&origin_location).unwrap() -} - -fn make_register_token_message() -> InboundQueueFixture { - InboundQueueFixture{ - message: Message { - event_log: Log{ - address: hex!("eda338e4dc46038493b885327842fd3e301cab39").into(), - topics: vec![ - hex!("7153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84f").into(), - hex!("c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539").into(), - hex!("5f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0").into(), - ], - data: hex!("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002e0001000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00e40b54020000000000000000000000000000000000000000000000000000000000").into(), - }, - proof: Proof { - receipt_proof: (vec![ - hex!("4a98e45a319168b0fc6005ce6b744ee9bf54338e2c0784b976a8578d241ced0f").to_vec(), - ], vec![ - hex!("f9028c30b9028802f90284018301d205b9010000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000000000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000040004000000000000002000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000200000000000010f90179f85894eda338e4dc46038493b885327842fd3e301cab39e1a0f78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7ea000000000000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7df9011c94eda338e4dc46038493b885327842fd3e301cab39f863a07153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84fa0c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539a05f7060e971b0dc81e63f0aa41831091847d97c1a4693ac450cc128c7214e65e0b8a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002e0001000000000000000087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00e40b54020000000000000000000000000000000000000000000000000000000000").to_vec(), - ]), - execution_proof: ExecutionProof { - header: BeaconHeader { - slot: 393, - proposer_index: 4, - parent_root: hex!("6545b47a614a1dd4cad042a0cdbbf5be347e8ffcdc02c6c64540d5153acebeef").into(), - state_root: hex!("b62ac34a8cb82497be9542fe2114410c9f6021855b766015406101a1f3d86434").into(), - body_root: hex!("308e4c20194c0c77155c65a2d2c7dcd0ec6a7b20bdeb002c065932149fe0aa1b").into(), - }, - ancestry_proof: Some(AncestryProof { - header_branch: vec![ - hex!("6545b47a614a1dd4cad042a0cdbbf5be347e8ffcdc02c6c64540d5153acebeef").into(), - hex!("fa84cc88ca53a72181599ff4eb07d8b444bce023fe2347c3b4f51004c43439d3").into(), - hex!("cadc8ae211c6f2221c9138e829249adf902419c78eb4727a150baa4d9a02cc9d").into(), - hex!("33a89962df08a35c52bd7e1d887cd71fa7803e68787d05c714036f6edf75947c").into(), - hex!("2c9760fce5c2829ef3f25595a703c21eb22d0186ce223295556ed5da663a82cf").into(), - hex!("e1aa87654db79c8a0ecd6c89726bb662fcb1684badaef5cd5256f479e3c622e1").into(), - hex!("aa70d5f314e4a1fbb9c362f3db79b21bf68b328887248651fbd29fc501d0ca97").into(), - hex!("160b6c235b3a1ed4ef5f80b03ee1c76f7bf3f591c92fca9d8663e9221b9f9f0f").into(), - hex!("f68d7dcd6a07a18e9de7b5d2aa1980eb962e11d7dcb584c96e81a7635c8d2535").into(), - hex!("1d5f912dfd6697110dd1ecb5cb8e77952eef57d85deb373572572df62bb157fc").into(), - hex!("ffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b").into(), - hex!("6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220").into(), - hex!("b7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f").into(), - ], - finalized_block_root: hex!("751414cd97c0624f922b3e80285e9f776b08fa22fd5f87391f2ed7ef571a8d46").into(), - }), - execution_header: VersionedExecutionPayloadHeader::Deneb(deneb::ExecutionPayloadHeader { - parent_hash: hex!("8092290aa21b7751576440f77edd02a94058429ce50e63a92d620951fb25eda2").into(), - fee_recipient: hex!("0000000000000000000000000000000000000000").into(), - state_root: hex!("96a83e9ddf745346fafcb0b03d57314623df669ed543c110662b21302a0fae8b").into(), - receipts_root: hex!("62d13e9a073dc7cf609005b5531bb208c8686f18f7c8ae02d76232d83ae41a21").into(), - logs_bloom: hex!("00000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000080000000400000000000000000000004000000000080000000000000000000000000000000000010100000000000000000000000000000000020000000000000000000000000000000000080000000000000000000000000000040004000000000000002002002000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000080000000000000000000000000000000000100000000000000000200000200000010").into(), - prev_randao: hex!("62e309d4f5119d1f5c783abc20fc1a549efbab546d8d0b25ff1cfd58be524e67").into(), - block_number: 393, - gas_limit: 54492273, - gas_used: 199644, - timestamp: 1710552813, - extra_data: hex!("d983010d0b846765746888676f312e32312e368664617277696e").into(), - base_fee_per_gas: U256::from(7u64), - block_hash: hex!("6a9810efb9581d30c1a5c9074f27c68ea779a8c1ae31c213241df16225f4e131").into(), - transactions_root: hex!("2cfa6ed7327e8807c7973516c5c32a68ef2459e586e8067e113d081c3bd8c07d").into(), - withdrawals_root: hex!("792930bbd5baac43bcc798ee49aa8185ef76bb3b44ba62b91d86ae569e4bb535").into(), - blob_gas_used: 0, - excess_blob_gas: 0, - }), - execution_branch: vec![ - hex!("a6833fa629f3286b6916c6e50b8bf089fc9126bee6f64d0413b4e59c1265834d").into(), - hex!("b46f0c01805fe212e15907981b757e6c496b0cb06664224655613dcec82505bb").into(), - hex!("db56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71").into(), - hex!("d3af7c05c516726be7505239e0b9c7cb53d24abce6b91cdb3b3995f0164a75da").into(), - ], - } - } - }, - finalized_header: BeaconHeader { - slot: 864, - proposer_index: 4, - parent_root: hex!("614e7672f991ac268cd841055973f55e1e42228831a211adef207bb7329be614").into(), - state_root: hex!("5fa8dfca3d760e4242ab46d529144627aa85348a19173b6e081172c701197a4a").into(), - body_root: hex!("0f34c083b1803666bb1ac5e73fa71582731a2cf37d279ff0a3b0cad5a2ff371e").into(), - }, - block_roots_root: hex!("3adb5c78afd49ef17160ca7fc38b47228cbb13a317709c86bb6f51d799ba9ab6").into(), - } -} diff --git a/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml b/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml index 341f0cbc86..ea73728a97 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml +++ b/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml @@ -103,7 +103,6 @@ assets-common = { workspace = true } # Bridges pallet-xcm-bridge-hub-router = { workspace = true } -snowbridge-router-primitives = { workspace = true } [dev-dependencies] asset-test-utils = { workspace = true } @@ -155,7 +154,6 @@ runtime-benchmarks = [ "parachains-common/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", "polkadot-runtime-common/runtime-benchmarks", - "snowbridge-router-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", @@ -256,7 +254,6 @@ std = [ "primitive-types/std", "scale-info/std", "serde_json/std", - "snowbridge-router-primitives/std", "sp-api/std", "sp-block-builder/std", "sp-consensus-aura/std", diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs index bbae7cb48f..d4a9334749 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs @@ -33,7 +33,7 @@ pub mod xcm_config; use assets_common::{ foreign_creators::ForeignCreators, local_and_foreign_assets::{LocalFromLeft, TargetFromLeft}, - matching::{FromNetwork, FromSiblingParachain}, + matching::FromSiblingParachain, AssetIdForTrustBackedAssetsConvert, }; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; @@ -464,14 +464,7 @@ impl pallet_assets::Config for Runtime { type AssetIdParameter = xcm::v3::Location; type Currency = Balances; type CreateOrigin = ForeignCreators< - ( - FromSiblingParachain, xcm::v3::Location>, - FromNetwork< - xcm_config::UniversalLocation, - xcm_config::bridging::to_ethereum::EthereumNetwork, - xcm::v3::Location, - >, - ), + FromSiblingParachain, xcm::v3::Location>, ForeignCreatorsSovereignAccountOf, AccountId, xcm::v3::Location, @@ -735,9 +728,8 @@ impl pallet_message_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::pallet_message_queue::WeightInfo; #[cfg(feature = "runtime-benchmarks")] - type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor< - cumulus_primitives_core::AggregateMessageOrigin, - >; + type MessageProcessor = + pallet_message_queue::mock_helpers::NoopMessageProcessor; #[cfg(not(feature = "runtime-benchmarks"))] type MessageProcessor = xcm_builder::ProcessXcmMessage< AggregateMessageOrigin, diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs index 3816c9d020..b043a9874e 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs @@ -21,7 +21,7 @@ use super::{ }; use crate::{ForeignAssets, ForeignAssetsInstance}; use assets_common::{ - matching::{FromNetwork, FromSiblingParachain, IsForeignConcreteAsset}, + matching::{FromSiblingParachain, IsForeignConcreteAsset}, TrustBackedAssetsAsLocation, }; use frame_support::{ @@ -38,7 +38,6 @@ use parachains_common::xcm_config::{ ParentRelayOrSiblingParachains, RelayOrOtherSystemParachains, }; use polkadot_parachain_primitives::primitives::Sibling; -use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor; use sp_runtime::traits::{AccountIdConversion, ConvertInto}; use system_parachains_constants::TREASURY_PALLET_ID; use xcm::latest::prelude::*; @@ -49,10 +48,9 @@ use xcm_builder::{ FungibleAdapter, FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription, IsConcrete, LocalMint, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignPaidRemoteExporter, SovereignSignedViaLocation, StartsWith, - StartsWithExplicitGlobalConsensus, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, - WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents, - XcmFeeToAccount, + SignedToAccountId32, SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, + TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, + WithUniqueTopic, XcmFeeManagerFromComponents, XcmFeeToAccount, }; use xcm_executor::{traits::ConvertLocation, XcmExecutor}; @@ -101,9 +99,6 @@ pub type LocationToAccountId = ( // Different global consensus parachain sovereign account. // (Used for over-bridge transfers and reserve processing) GlobalConsensusParachainConvertsFor, - // Ethereum contract sovereign account. - // (Used to get convert ethereum contract locations to sovereign account) - GlobalConsensusEthereumConvertsFor, ); /// Means for transacting the native currency on this chain. @@ -307,12 +302,8 @@ impl xcm_executor::Config for XcmConfig { type OriginConverter = XcmOriginToTransactDispatchOrigin; // Asset Hub trusts only particular, pre-configured bridged locations from a different consensus // as reserve locations (we trust the Bridge Hub to relay the message that a reserve is being - // held). Asset Hub may _act_ as a reserve location for KSM and assets created - // under `pallet-assets`. Users must use teleport where allowed (e.g. KSM with the Relay Chain). - type IsReserve = ( - bridging::to_polkadot::IsTrustedBridgedReserveLocationForConcreteAsset, - bridging::to_ethereum::IsTrustedBridgedReserveLocationForForeignAsset, - ); + // held). Kusama Asset Hub accepts PolkadotAssetHub as a reserve location for DOT. + type IsReserve = (bridging::to_polkadot::IsTrustedBridgedReserveLocationForConcreteAsset,); type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; @@ -387,8 +378,7 @@ impl xcm_executor::Config for XcmConfig { XcmFeeToAccount, >; type MessageExporter = (); - type UniversalAliases = - (bridging::to_polkadot::UniversalAliases, bridging::to_ethereum::UniversalAliases); + type UniversalAliases = (bridging::to_polkadot::UniversalAliases,); type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; type Aliasers = Nothing; @@ -419,13 +409,6 @@ pub type XcmRouter = WithUniqueTopic<( // Router which wraps and sends xcm to BridgeHub to be delivered to the Polkadot // GlobalConsensus ToPolkadotXcmRouter, - // Router which wraps and sends xcm to BridgeHub to be delivered to the Ethereum - // GlobalConsensus - SovereignPaidRemoteExporter< - xcm_builder::NetworkExportTable, - XcmpQueue, - UniversalLocation, - >, )>; impl pallet_xcm::Config for Runtime { @@ -469,7 +452,6 @@ pub type ForeignCreatorsSovereignAccountOf = ( SiblingParachainConvertsVia, AccountId32Aliases, ParentIsPreset, - GlobalConsensusEthereumConvertsFor, ); /// Simple conversion of `u32` into an `AssetId` for use in benchmarking. @@ -583,57 +565,6 @@ pub mod bridging { >; } - pub mod to_ethereum { - use super::*; - pub use bp_bridge_hub_kusama::snowbridge::EthereumNetwork; - use bp_bridge_hub_kusama::snowbridge::InboundQueuePalletInstance; - - parameter_types! { - /// User fee for transfers from Kusama to Ethereum. - /// The fee is set to max Balance to disable the bridge until a fee is set by - /// governance. - pub const DefaultBridgeHubEthereumBaseFee: Balance = Balance::MAX; - pub storage BridgeHubEthereumBaseFee: Balance = DefaultBridgeHubEthereumBaseFee::get(); - pub SiblingBridgeHubWithEthereumInboundQueueInstance: Location = Location::new( - 1, - [ - Parachain(SiblingBridgeHubParaId::get()), - PalletInstance(InboundQueuePalletInstance::get()), - ] - ); - - /// Set up exporters configuration. - /// `Option` represents static "base fee" which is used for total delivery fee calculation. - pub BridgeTable: sp_std::vec::Vec = sp_std::vec![ - NetworkExportTableItem::new( - EthereumNetwork::get(), - Some(sp_std::vec![Junctions::Here]), - SiblingBridgeHub::get(), - Some(( - XcmBridgeHubRouterFeeAssetId::get(), - BridgeHubEthereumBaseFee::get(), - ).into()) - ), - ]; - - /// Universal aliases - pub UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter( - sp_std::vec![ - (SiblingBridgeHubWithEthereumInboundQueueInstance::get(), GlobalConsensus(EthereumNetwork::get())), - ] - ); - } - - pub type IsTrustedBridgedReserveLocationForForeignAsset = - matching::IsForeignConcreteAsset>; - - impl Contains<(Location, Junction)> for UniversalAliases { - fn contains(alias: &(Location, Junction)) -> bool { - UniversalAliases::get().contains(alias) - } - } - } - /// Benchmarks helper for bridging configuration. #[cfg(feature = "runtime-benchmarks")] pub struct BridgingBenchmarksHelper; diff --git a/system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs b/system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs deleted file mode 100644 index 756001a9aa..0000000000 --- a/system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs +++ /dev/null @@ -1,76 +0,0 @@ -// This file is part of Cumulus. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use asset_hub_kusama_runtime::xcm_config::bridging::{ - to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork}, - SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId, -}; -use sp_core::H160; -use sp_std::prelude::*; -use xcm::prelude::*; -use xcm_builder::{ExporterFor, NetworkExportTable}; - -#[test] -fn network_export_table_works() { - sp_io::TestExternalities::default().execute_with(|| { - #[allow(clippy::type_complexity)] - let test_data: Vec<(NetworkId, InteriorLocation, Option<(Location, Option)>)> = vec![ - // From Ethereum (from GlobalConsensus(Ethereum) is routed to BridgeHub, with a fee, - // matched. - ( - EthereumNetwork::get(), - Junctions::Here, - Some(( - SiblingBridgeHub::get(), - Some(Asset { - id: XcmBridgeHubRouterFeeAssetId::get(), - fun: Fungible(BridgeHubEthereumBaseFee::get()), - }), - )), - ), - // From Ethereum with a random parachain ID filter, not matched. - (EthereumNetwork::get(), [Parachain(4321)].into(), None), - // From Ethereum with a account ID added to the Ethereum Network, not matched. - ( - EthereumNetwork::get(), - [ - GlobalConsensus(EthereumNetwork::get()), - AccountKey20 { network: None, key: H160::random().into() }, - ] - .into(), - None, - ), - // From Ethereum with the Sepolia chain ID instead of Mainnet, not matched. - (NetworkId::Ethereum { chain_id: 11155111 }, Junctions::Here, None), - ]; - - for (network, remote_location, expected_result) in test_data { - assert_eq!( - NetworkExportTable::::exporter_for( - &network, - &remote_location, - &Xcm::default() - ), - expected_result, - "expected_result: {:?} not matched for network: {:?} and remote_location: {:?}", - expected_result, - network, - remote_location, - ) - } - }); -} diff --git a/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs b/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs index b839b1f5d3..9e3e2ded06 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs @@ -706,29 +706,3 @@ fn treasury_pallet_account_not_none() { LocationToAccountId::convert_location(&RelayTreasuryLocation::get()).unwrap() ) } - -#[test] -fn change_xcm_bridge_hub_ethereum_base_fee_by_governance_works() { - asset_test_utils::test_cases::change_storage_constant_by_governance_works::< - Runtime, - bridging::to_ethereum::BridgeHubEthereumBaseFee, - Balance, - >( - collator_session_keys(), - 1000, - Box::new(|call| RuntimeCall::System(call).encode()), - || { - ( - bridging::to_ethereum::BridgeHubEthereumBaseFee::key().to_vec(), - bridging::to_ethereum::BridgeHubEthereumBaseFee::get(), - ) - }, - |old_value| { - if let Some(new_value) = old_value.checked_add(1) { - new_value - } else { - old_value.checked_sub(1).unwrap() - } - }, - ) -} diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs index b3c243a732..9d7981d46b 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs @@ -159,45 +159,6 @@ fn convert_from_udot_to_uksm(price_in_udot: Balance) -> Balance { FixedU128::DIV } -pub mod snowbridge { - use crate::Balance; - use frame_support::parameter_types; - use snowbridge_core::{PricingParameters, Rewards, U256}; - use sp_runtime::FixedU128; - use xcm::latest::NetworkId; - - parameter_types! { - /// Should match the `ForeignAssets::create` index on Asset Hub. - pub const CreateAssetCall: [u8;2] = [53, 0]; - /// The pallet index of the Ethereum inbound queue pallet in the Bridge Hub runtime. - pub const InboundQueuePalletInstance: u8 = 80; - /// Default pricing parameters used to calculate bridging fees. Initialized to unit values, - /// as it is intended that these parameters should be updated with more - /// accurate values prior to bridge activation. This can be performed - /// using the `EthereumSystem::set_pricing_parameters` governance extrinsic. - pub Parameters: PricingParameters = PricingParameters { - // ETH/DOT exchange rate - exchange_rate: FixedU128::from_rational(1, 1), - // Ether fee per gas unit - fee_per_gas: U256::one(), - // Relayer rewards - rewards: Rewards { - // Reward for submitting a message to BridgeHub - local: 1, - // Reward for submitting a message to the Gateway contract on Ethereum - remote: U256::one(), - }, - // Safety factor to cover unfavourable fluctuations in the ETH/DOT exchange rate. - multiplier: FixedU128::from_rational(1, 1), - }; - /// Network and location for the Ethereum chain. On Kusama, the Ethereum chain bridged - /// to is the Ethereum Main network, with chain ID 1. - /// - /// - pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 1 }; - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_ethereum_config.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_ethereum_config.rs deleted file mode 100644 index 7a7c2909c3..0000000000 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_ethereum_config.rs +++ /dev/null @@ -1,221 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . - -use crate::{ - xcm_config, - xcm_config::{RelayTreasuryPalletAccount, UniversalLocation}, - Balances, EthereumInboundQueue, EthereumOutboundQueue, EthereumSystem, MessageQueue, Runtime, - RuntimeEvent, TransactionByteFee, -}; -pub use bp_bridge_hub_kusama::snowbridge::EthereumNetwork; -use bp_bridge_hub_kusama::snowbridge::{CreateAssetCall, InboundQueuePalletInstance, Parameters}; -use frame_support::{parameter_types, weights::ConstantMultiplier}; -use pallet_xcm::EnsureXcm; -use parachains_common::{AccountId, Balance}; -use snowbridge_beacon_primitives::{Fork, ForkVersions}; -use snowbridge_core::AllowSiblingsOnly; -use snowbridge_router_primitives::{inbound::MessageToXcm, outbound::EthereumBlobExporter}; -use sp_core::H160; -use sp_runtime::traits::{ConstU32, ConstU8, Keccak256}; -use system_parachains_constants::kusama::fee::WeightToFee; - -/// Exports message to the Ethereum Gateway contract. -pub type SnowbridgeExporter = EthereumBlobExporter< - UniversalLocation, - EthereumNetwork, - snowbridge_pallet_outbound_queue::Pallet, - snowbridge_core::AgentIdOf, ->; - -parameter_types! { - // The gateway address is set by governance. - pub storage EthereumGatewayAddress: H160 = H160::zero(); -} - -impl snowbridge_pallet_inbound_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Verifier = snowbridge_pallet_ethereum_client::Pallet; - type Token = Balances; - #[cfg(not(feature = "runtime-benchmarks"))] - type XcmSender = xcm_config::XcmRouter; - #[cfg(feature = "runtime-benchmarks")] - type XcmSender = benchmark_helpers::DoNothingRouter; - type ChannelLookup = EthereumSystem; - type GatewayAddress = EthereumGatewayAddress; - #[cfg(feature = "runtime-benchmarks")] - type Helper = Runtime; - type MessageConverter = MessageToXcm< - CreateAssetCall, - bp_asset_hub_kusama::CreateForeignAssetDeposit, - InboundQueuePalletInstance, - AccountId, - Balance, - >; - type WeightToFee = WeightToFee; - type LengthToFee = ConstantMultiplier; - type MaxMessageSize = ConstU32<2048>; - type WeightInfo = crate::weights::snowbridge_pallet_inbound_queue::WeightInfo; - type PricingParameters = EthereumSystem; - type AssetTransactor = ::AssetTransactor; -} - -impl snowbridge_pallet_outbound_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Hashing = Keccak256; - type MessageQueue = MessageQueue; - type Decimals = ConstU8<12>; - type MaxMessagePayloadSize = ConstU32<2048>; - type MaxMessagesPerBlock = ConstU32<32>; - type GasMeter = snowbridge_core::outbound::ConstantGasMeter; - type Balance = Balance; - type WeightToFee = WeightToFee; - type WeightInfo = crate::weights::snowbridge_pallet_outbound_queue::WeightInfo; - type PricingParameters = EthereumSystem; - type Channels = EthereumSystem; -} - -#[cfg(not(any(feature = "std", feature = "runtime-benchmarks", test)))] -parameter_types! { - pub const ChainForkVersions: ForkVersions = ForkVersions { - genesis: Fork { - version: [0, 0, 0, 0], // 0x00000000 - epoch: 0, - }, - altair: Fork { - version: [1, 0, 0, 0], // 0x01000000 - epoch: 74240, - }, - bellatrix: Fork { - version: [2, 0, 0, 0], // 0x02000000 - epoch: 144896, - }, - capella: Fork { - version: [3, 0, 0, 0], // 0x03000000 - epoch: 194048, - }, - deneb: Fork { - version: [4, 0, 0, 0], // 0x04000000 - epoch: 269568, - }, - }; -} - -#[cfg(any(feature = "std", feature = "runtime-benchmarks", test))] -parameter_types! { - pub const ChainForkVersions: ForkVersions = ForkVersions { - genesis: Fork { - version: [0, 0, 0, 0], // 0x00000000 - epoch: 0, - }, - altair: Fork { - version: [1, 0, 0, 0], // 0x01000000 - epoch: 0, - }, - bellatrix: Fork { - version: [2, 0, 0, 0], // 0x02000000 - epoch: 0, - }, - capella: Fork { - version: [3, 0, 0, 0], // 0x03000000 - epoch: 0, - }, - deneb: Fork { - version: [4, 0, 0, 0], // 0x04000000 - epoch: 0, - } - }; -} - -impl snowbridge_pallet_ethereum_client::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type ForkVersions = ChainForkVersions; - type WeightInfo = crate::weights::snowbridge_pallet_ethereum_client::WeightInfo; -} - -impl snowbridge_pallet_system::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OutboundQueue = EthereumOutboundQueue; - type SiblingOrigin = EnsureXcm; - type AgentIdOf = snowbridge_core::AgentIdOf; - type TreasuryAccount = RelayTreasuryPalletAccount; - type Token = Balances; - type WeightInfo = crate::weights::snowbridge_pallet_system::WeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type Helper = Runtime; - type DefaultPricingParameters = Parameters; - type InboundDeliveryCost = EthereumInboundQueue; -} - -#[cfg(feature = "runtime-benchmarks")] -pub mod benchmark_helpers { - use super::{EthereumGatewayAddress, RelayTreasuryPalletAccount, Runtime}; - use crate::{Balances, EthereumBeaconClient, ExistentialDeposit, RuntimeOrigin}; - use codec::Encode; - use frame_support::traits::fungible; - use hex_literal::hex; - use snowbridge_beacon_primitives::BeaconHeader; - use snowbridge_pallet_inbound_queue::BenchmarkHelper; - use sp_core::H256; - use xcm::latest::{Assets, Location, SendError, SendResult, SendXcm, Xcm, XcmHash}; - - impl BenchmarkHelper for Runtime { - fn initialize_storage(beacon_header: BeaconHeader, block_roots_root: H256) { - EthereumBeaconClient::store_finalized_header(beacon_header, block_roots_root).unwrap(); - EthereumGatewayAddress::set(&hex!["EDa338E4dC46038493b885327842fD3E301CaB39"].into()); - } - } - - pub struct DoNothingRouter; - impl SendXcm for DoNothingRouter { - type Ticket = Xcm<()>; - - fn validate( - _dest: &mut Option, - xcm: &mut Option>, - ) -> SendResult { - Ok((xcm.clone().unwrap(), Assets::new())) - } - fn deliver(xcm: Xcm<()>) -> Result { - let hash = xcm.using_encoded(sp_io::hashing::blake2_256); - Ok(hash) - } - } - - impl snowbridge_pallet_system::BenchmarkHelper for Runtime { - fn make_xcm_origin(location: Location) -> RuntimeOrigin { - // Drip ED to the `TreasuryAccount` - >::set_balance( - &RelayTreasuryPalletAccount::get(), - ExistentialDeposit::get(), - ); - - RuntimeOrigin::from(pallet_xcm::Origin::Xcm(location)) - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn bridge_hub_inbound_queue_pallet_index_is_correct() { - assert_eq!( - InboundQueuePalletInstance::get(), - ::index() as u8 - ); - } -} diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs index a57100ce0c..24f1a87143 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/genesis_config_presets.rs @@ -59,11 +59,6 @@ fn bridge_hub_kusama_genesis( "polkadotXcm": { "safeXcmVersion": Some(SAFE_XCM_VERSION), }, - "ethereumSystem": EthereumSystemConfig { - para_id: id, - asset_hub_para_id: kusama_runtime_constants::system_parachain::ASSET_HUB_ID.into(), - ..Default::default() - }, // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. `aura: Default::default()` }) diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs index 8f79c19a0c..9d2f7de698 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -22,7 +22,6 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); -pub mod bridge_to_ethereum_config; pub mod bridge_to_polkadot_config; // Genesis preset configurations. pub mod genesis_config_presets; @@ -34,10 +33,6 @@ use bridge_hub_common::message_queue::{ }; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use cumulus_primitives_core::ParaId; -use snowbridge_core::{ - outbound::{Command, Fee}, - AgentId, PricingParameters, -}; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; @@ -141,14 +136,32 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; parameter_types! { - pub DmpQueueName: &'static str = "DmpQueue"; + pub EthereumInboundQueueName: &'static str = "EthereumInboundQueue"; + pub EthereumOutboundQueueName: &'static str = "EthereumOutboundQueue"; + pub EthereumBeaconClientName: &'static str = "EthereumBeaconClient"; + pub EthereumSystemName: &'static str = "EthereumSystem"; } /// Migrations to apply on runtime upgrade. pub type Migrations = ( - frame_support::migrations::RemovePallet, pallet_collator_selection::migration::v2::MigrationToV2, cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, + frame_support::migrations::RemovePallet< + EthereumInboundQueueName, + ::DbWeight, + >, + frame_support::migrations::RemovePallet< + EthereumOutboundQueueName, + ::DbWeight, + >, + frame_support::migrations::RemovePallet< + EthereumBeaconClientName, + ::DbWeight, + >, + frame_support::migrations::RemovePallet< + EthereumSystemName, + ::DbWeight, + >, // permanent pallet_xcm::migration::MigrateToLatestXcmVersion, ); @@ -347,10 +360,9 @@ type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook< impl parachain_info::Config for Runtime {} parameter_types! { - /// Amount of weight that can be spent per block to service messages. This was increased - /// from 35% to 60% of the max block weight to accommodate the Ethereum beacon light client - /// extrinsics. The `force_checkpoint` and `submit` extrinsics (for submit, optionally) includes - /// the sync committee's pubkeys (512 x 48 bytes). + /// Amount of weight that can be spent per block to service messages. Bridge Hub is a + /// specialized chain for moving messages between sibling parachains and external ecosystems. + /// As such, most of the block weight is expected to be consumed by the Message Queue. pub MessageQueueServiceWeight: Weight = Perbill::from_percent(60) * RuntimeBlockWeights::get().max_block; pub MessageQueueIdleServiceWeight: Weight = Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block; } @@ -366,13 +378,10 @@ impl pallet_message_queue::Config for Runtime { type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor; #[cfg(not(all(not(feature = "std"), feature = "runtime-benchmarks")))] - type MessageProcessor = bridge_hub_common::BridgeHubMessageRouter< - xcm_builder::ProcessXcmMessage< - AggregateMessageOrigin, - xcm_executor::XcmExecutor, - RuntimeCall, - >, - EthereumOutboundQueue, + type MessageProcessor = xcm_builder::ProcessXcmMessage< + AggregateMessageOrigin, + xcm_executor::XcmExecutor, + RuntimeCall, >; type Size = u32; // The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin: @@ -554,13 +563,7 @@ construct_runtime!( BridgePolkadotMessages: pallet_bridge_messages:: = 53, XcmOverBridgeHubPolkadot: pallet_xcm_bridge_hub:: = 54, - // Ethereum bridge pallets. - EthereumInboundQueue: snowbridge_pallet_inbound_queue = 80, - EthereumOutboundQueue: snowbridge_pallet_outbound_queue = 81, - EthereumBeaconClient: snowbridge_pallet_ethereum_client = 82, - EthereumSystem: snowbridge_pallet_system = 83, - - // Message Queue. Importantly, it is registered after Snowbridge pallets + // Message Queue. Importantly, it is registered after bridge pallets // so that messages are processed after the `on_initialize` hooks of bridging pallets. MessageQueue: pallet_message_queue = 175, } @@ -590,11 +593,6 @@ mod benches { [pallet_bridge_grandpa, PolkadotFinality] [pallet_bridge_parachains, PolkadotParachains] [pallet_bridge_messages, PolkadotMessages] - // Ethereum Bridge - [snowbridge_pallet_inbound_queue, EthereumInboundQueue] - [snowbridge_pallet_outbound_queue, EthereumOutboundQueue] - [snowbridge_pallet_system, EthereumSystem] - [snowbridge_pallet_ethereum_client, EthereumBeaconClient] ); } @@ -865,22 +863,6 @@ impl_runtime_apis! { } } - impl snowbridge_outbound_queue_runtime_api::OutboundQueueApi for Runtime { - fn prove_message(leaf_index: u64) -> Option { - snowbridge_pallet_outbound_queue::api::prove_message::(leaf_index) - } - - fn calculate_fee(command: Command, parameters: Option>) -> Fee { - snowbridge_pallet_outbound_queue::api::calculate_fee::(command, parameters) - } - } - - impl snowbridge_system_runtime_api::ControlApi for Runtime { - fn agent_id(location: VersionedLocation) -> Option { - snowbridge_pallet_system::api::agent_id::(location) - } - } - #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/mod.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/mod.rs index 7cf0227732..cb36b653a7 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/mod.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/mod.rs @@ -43,10 +43,6 @@ pub mod pallet_utility; pub mod pallet_xcm; pub mod paritydb_weights; pub mod rocksdb_weights; -pub mod snowbridge_pallet_ethereum_client; -pub mod snowbridge_pallet_inbound_queue; -pub mod snowbridge_pallet_outbound_queue; -pub mod snowbridge_pallet_system; pub mod xcm; pub use block_weights::constants::BlockExecutionWeight; diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_ethereum_client.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_ethereum_client.rs deleted file mode 100644 index 6211433d7f..0000000000 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_ethereum_client.rs +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md -// for a list of specific contributors. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Autogenerated weights for `snowbridge_pallet_ethereum_client` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-07-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./bridge-hub-kusama-chain-spec.json")`, DB CACHE: 1024 - -// Executed Command: -// ./target/production/polkadot -// benchmark -// pallet -// --chain=./bridge-hub-kusama-chain-spec.json -// --steps=50 -// --repeat=20 -// --pallet=snowbridge_pallet_ethereum_client -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./bridge-hub-kusama-weights/ -// --header=./file_header.txt - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `snowbridge_pallet_ethereum_client`. -pub struct WeightInfo(PhantomData); -impl snowbridge_pallet_ethereum_client::WeightInfo for WeightInfo { - /// Storage: `EthereumBeaconClient::FinalizedBeaconStateIndex` (r:1 w:1) - /// Proof: `EthereumBeaconClient::FinalizedBeaconStateIndex` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::FinalizedBeaconStateMapping` (r:1 w:1) - /// Proof: `EthereumBeaconClient::FinalizedBeaconStateMapping` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::NextSyncCommittee` (r:0 w:1) - /// Proof: `EthereumBeaconClient::NextSyncCommittee` (`max_values`: Some(1), `max_size`: Some(92372), added: 92867, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::InitialCheckpointRoot` (r:0 w:1) - /// Proof: `EthereumBeaconClient::InitialCheckpointRoot` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::ValidatorsRoot` (r:0 w:1) - /// Proof: `EthereumBeaconClient::ValidatorsRoot` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::LatestFinalizedBlockRoot` (r:0 w:1) - /// Proof: `EthereumBeaconClient::LatestFinalizedBlockRoot` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::CurrentSyncCommittee` (r:0 w:1) - /// Proof: `EthereumBeaconClient::CurrentSyncCommittee` (`max_values`: Some(1), `max_size`: Some(92372), added: 92867, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::FinalizedBeaconState` (r:0 w:1) - /// Proof: `EthereumBeaconClient::FinalizedBeaconState` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - fn force_checkpoint() -> Weight { - // Proof Size summary in bytes: - // Measured: `42` - // Estimated: `3501` - // Minimum execution time: 121_589_655_000 picoseconds. - Weight::from_parts(122_147_489_000, 0) - .saturating_add(Weight::from_parts(0, 3501)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(8)) - } - /// Storage: `EthereumBeaconClient::OperatingMode` (r:1 w:0) - /// Proof: `EthereumBeaconClient::OperatingMode` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::LatestFinalizedBlockRoot` (r:1 w:0) - /// Proof: `EthereumBeaconClient::LatestFinalizedBlockRoot` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::FinalizedBeaconState` (r:1 w:0) - /// Proof: `EthereumBeaconClient::FinalizedBeaconState` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::NextSyncCommittee` (r:1 w:0) - /// Proof: `EthereumBeaconClient::NextSyncCommittee` (`max_values`: Some(1), `max_size`: Some(92372), added: 92867, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::CurrentSyncCommittee` (r:1 w:0) - /// Proof: `EthereumBeaconClient::CurrentSyncCommittee` (`max_values`: Some(1), `max_size`: Some(92372), added: 92867, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::ValidatorsRoot` (r:1 w:0) - /// Proof: `EthereumBeaconClient::ValidatorsRoot` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - fn submit() -> Weight { - // Proof Size summary in bytes: - // Measured: `92715` - // Estimated: `93857` - // Minimum execution time: 31_625_954_000 picoseconds. - Weight::from_parts(31_669_815_000, 0) - .saturating_add(Weight::from_parts(0, 93857)) - .saturating_add(T::DbWeight::get().reads(6)) - } - /// Storage: `EthereumBeaconClient::OperatingMode` (r:1 w:0) - /// Proof: `EthereumBeaconClient::OperatingMode` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::LatestFinalizedBlockRoot` (r:1 w:0) - /// Proof: `EthereumBeaconClient::LatestFinalizedBlockRoot` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::FinalizedBeaconState` (r:1 w:0) - /// Proof: `EthereumBeaconClient::FinalizedBeaconState` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::NextSyncCommittee` (r:1 w:1) - /// Proof: `EthereumBeaconClient::NextSyncCommittee` (`max_values`: Some(1), `max_size`: Some(92372), added: 92867, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::CurrentSyncCommittee` (r:1 w:0) - /// Proof: `EthereumBeaconClient::CurrentSyncCommittee` (`max_values`: Some(1), `max_size`: Some(92372), added: 92867, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::ValidatorsRoot` (r:1 w:0) - /// Proof: `EthereumBeaconClient::ValidatorsRoot` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - fn submit_with_sync_committee() -> Weight { - // Proof Size summary in bytes: - // Measured: `92715` - // Estimated: `93857` - // Minimum execution time: 153_268_539_000 picoseconds. - Weight::from_parts(153_784_773_000, 0) - .saturating_add(Weight::from_parts(0, 93857)) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(1)) - } -} diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_inbound_queue.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_inbound_queue.rs deleted file mode 100644 index 09484022da..0000000000 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_inbound_queue.rs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md -// for a list of specific contributors. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Autogenerated weights for `snowbridge_pallet_inbound_queue` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-07-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./bridge-hub-kusama-chain-spec.json")`, DB CACHE: 1024 - -// Executed Command: -// ./target/production/polkadot -// benchmark -// pallet -// --chain=./bridge-hub-kusama-chain-spec.json -// --steps=50 -// --repeat=20 -// --pallet=snowbridge_pallet_inbound_queue -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./bridge-hub-kusama-weights/ -// --header=./file_header.txt - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `snowbridge_pallet_inbound_queue`. -pub struct WeightInfo(PhantomData); -impl snowbridge_pallet_inbound_queue::WeightInfo for WeightInfo { - /// Storage: `EthereumInboundQueue::OperatingMode` (r:1 w:0) - /// Proof: `EthereumInboundQueue::OperatingMode` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::LatestFinalizedBlockRoot` (r:1 w:0) - /// Proof: `EthereumBeaconClient::LatestFinalizedBlockRoot` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) - /// Storage: `EthereumBeaconClient::FinalizedBeaconState` (r:1 w:0) - /// Proof: `EthereumBeaconClient::FinalizedBeaconState` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `MaxEncodedLen`) - /// Storage: UNKNOWN KEY `0xaed97c7854d601808b98ae43079dafb3` (r:1 w:0) - /// Proof: UNKNOWN KEY `0xaed97c7854d601808b98ae43079dafb3` (r:1 w:0) - /// Storage: `EthereumSystem::Channels` (r:1 w:0) - /// Proof: `EthereumSystem::Channels` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`) - /// Storage: `EthereumInboundQueue::Nonce` (r:1 w:1) - /// Proof: `EthereumInboundQueue::Nonce` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:1 w:0) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn submit() -> Weight { - // Proof Size summary in bytes: - // Measured: `697` - // Estimated: `4162` - // Minimum execution time: 175_181_000 picoseconds. - Weight::from_parts(177_031_000, 0) - .saturating_add(Weight::from_parts(0, 4162)) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(2)) - } -} diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_outbound_queue.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_outbound_queue.rs deleted file mode 100644 index f0f033caae..0000000000 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_outbound_queue.rs +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md -// for a list of specific contributors. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//! Autogenerated weights for `snowbridge_pallet_outbound_queue` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-03-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `ggwpez-ref-hw`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./bridge-hub-kusama-chain-spec.json")`, DB CACHE: 1024 - -// Executed Command: -// ./target/production/polkadot -// benchmark -// pallet -// --chain=./bridge-hub-kusama-chain-spec.json -// --steps=50 -// --repeat=20 -// --pallet=snowbridge_pallet_outbound_queue -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./bridge-hub-kusama-weights/ -// --header=./file_header.txt - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `snowbridge_pallet_outbound_queue`. -pub struct WeightInfo(PhantomData); -impl snowbridge_pallet_outbound_queue::WeightInfo for WeightInfo { - /// Storage: `EthereumOutboundQueue::MessageLeaves` (r:1 w:1) - /// Proof: `EthereumOutboundQueue::MessageLeaves` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `EthereumOutboundQueue::Nonce` (r:1 w:1) - /// Proof: `EthereumOutboundQueue::Nonce` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:1 w:0) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `EthereumOutboundQueue::Messages` (r:1 w:1) - /// Proof: `EthereumOutboundQueue::Messages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - fn do_process_message() -> Weight { - // Proof Size summary in bytes: - // Measured: `117` - // Estimated: `3513` - // Minimum execution time: 28_906_000 picoseconds. - Weight::from_parts(29_566_000, 0) - .saturating_add(Weight::from_parts(0, 3513)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `EthereumOutboundQueue::MessageLeaves` (r:1 w:0) - /// Proof: `EthereumOutboundQueue::MessageLeaves` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `System::Digest` (r:1 w:1) - /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - fn commit() -> Weight { - // Proof Size summary in bytes: - // Measured: `1094` - // Estimated: `2579` - // Minimum execution time: 28_306_000 picoseconds. - Weight::from_parts(28_826_000, 0) - .saturating_add(Weight::from_parts(0, 2579)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `EthereumOutboundQueue::MessageLeaves` (r:1 w:0) - /// Proof: `EthereumOutboundQueue::MessageLeaves` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `System::Digest` (r:1 w:1) - /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - fn commit_single() -> Weight { - // Proof Size summary in bytes: - // Measured: `101` - // Estimated: `1586` - // Minimum execution time: 8_435_000 picoseconds. - Weight::from_parts(9_127_000, 0) - .saturating_add(Weight::from_parts(0, 1586)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } -} diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_system.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_system.rs deleted file mode 100644 index d6f4364c8d..0000000000 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/snowbridge_pallet_system.rs +++ /dev/null @@ -1,271 +0,0 @@ -// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md -// for a list of specific contributors. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//! Autogenerated weights for `snowbridge_pallet_system` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-03-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `ggwpez-ref-hw`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./bridge-hub-kusama-chain-spec.json")`, DB CACHE: 1024 - -// Executed Command: -// ./target/production/polkadot -// benchmark -// pallet -// --chain=./bridge-hub-kusama-chain-spec.json -// --steps=50 -// --repeat=20 -// --pallet=snowbridge_pallet_system -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./bridge-hub-kusama-weights/ -// --header=./file_header.txt - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `snowbridge_pallet_system`. -pub struct WeightInfo(PhantomData); -impl snowbridge_pallet_system::WeightInfo for WeightInfo { - /// Storage: `EthereumSystem::Channels` (r:1 w:0) - /// Proof: `EthereumSystem::Channels` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:1 w:0) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::BookStateFor` (r:1 w:1) - /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(136), added: 2611, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::ServiceHead` (r:1 w:1) - /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::Pages` (r:0 w:1) - /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65613), added: 68088, mode: `MaxEncodedLen`) - fn upgrade() -> Weight { - // Proof Size summary in bytes: - // Measured: `219` - // Estimated: `3601` - // Minimum execution time: 32_350_000 picoseconds. - Weight::from_parts(32_886_000, 0) - .saturating_add(Weight::from_parts(0, 3601)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `EthereumSystem::Channels` (r:1 w:0) - /// Proof: `EthereumSystem::Channels` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:1 w:0) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::BookStateFor` (r:1 w:1) - /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(136), added: 2611, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::ServiceHead` (r:1 w:1) - /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::Pages` (r:0 w:1) - /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65613), added: 68088, mode: `MaxEncodedLen`) - fn set_operating_mode() -> Weight { - // Proof Size summary in bytes: - // Measured: `219` - // Estimated: `3601` - // Minimum execution time: 24_485_000 picoseconds. - Weight::from_parts(25_102_000, 0) - .saturating_add(Weight::from_parts(0, 3601)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `EthereumSystem::Channels` (r:1 w:0) - /// Proof: `EthereumSystem::Channels` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::BookStateFor` (r:1 w:1) - /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(136), added: 2611, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::ServiceHead` (r:1 w:1) - /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::Pages` (r:0 w:1) - /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65613), added: 68088, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:0 w:1) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - fn set_pricing_parameters() -> Weight { - // Proof Size summary in bytes: - // Measured: `219` - // Estimated: `3601` - // Minimum execution time: 28_966_000 picoseconds. - Weight::from_parts(29_583_000, 0) - .saturating_add(Weight::from_parts(0, 3601)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: `EthereumSystem::Agents` (r:1 w:1) - /// Proof: `EthereumSystem::Agents` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::Channels` (r:1 w:0) - /// Proof: `EthereumSystem::Channels` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:1 w:0) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `EthereumOutboundQueue::OperatingMode` (r:1 w:0) - /// Proof: `EthereumOutboundQueue::OperatingMode` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::BookStateFor` (r:1 w:1) - /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(136), added: 2611, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::ServiceHead` (r:1 w:1) - /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::Pages` (r:0 w:1) - /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65613), added: 68088, mode: `MaxEncodedLen`) - fn create_agent() -> Weight { - // Proof Size summary in bytes: - // Measured: `521` - // Estimated: `6196` - // Minimum execution time: 64_420_000 picoseconds. - Weight::from_parts(65_684_000, 0) - .saturating_add(Weight::from_parts(0, 6196)) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(6)) - } - /// Storage: `EthereumSystem::Agents` (r:1 w:0) - /// Proof: `EthereumSystem::Agents` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::Channels` (r:2 w:1) - /// Proof: `EthereumSystem::Channels` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:1 w:0) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `EthereumOutboundQueue::OperatingMode` (r:1 w:0) - /// Proof: `EthereumOutboundQueue::OperatingMode` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::BookStateFor` (r:1 w:1) - /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(136), added: 2611, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::Pages` (r:1 w:1) - /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65613), added: 68088, mode: `MaxEncodedLen`) - fn create_channel() -> Weight { - // Proof Size summary in bytes: - // Measured: `966` - // Estimated: `69078` - // Minimum execution time: 77_855_000 picoseconds. - Weight::from_parts(79_653_000, 0) - .saturating_add(Weight::from_parts(0, 69078)) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(5)) - } - /// Storage: `EthereumSystem::Channels` (r:1 w:0) - /// Proof: `EthereumSystem::Channels` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:1 w:0) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `EthereumOutboundQueue::OperatingMode` (r:1 w:0) - /// Proof: `EthereumOutboundQueue::OperatingMode` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::BookStateFor` (r:2 w:2) - /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(136), added: 2611, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::ServiceHead` (r:1 w:0) - /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::Pages` (r:0 w:1) - /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65613), added: 68088, mode: `MaxEncodedLen`) - fn update_channel() -> Weight { - // Proof Size summary in bytes: - // Measured: `752` - // Estimated: `6212` - // Minimum execution time: 71_879_000 picoseconds. - Weight::from_parts(73_752_000, 0) - .saturating_add(Weight::from_parts(0, 6212)) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(5)) - } - /// Storage: `EthereumSystem::Channels` (r:2 w:0) - /// Proof: `EthereumSystem::Channels` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:1 w:0) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::BookStateFor` (r:2 w:2) - /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(136), added: 2611, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::ServiceHead` (r:1 w:0) - /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::Pages` (r:0 w:1) - /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65613), added: 68088, mode: `MaxEncodedLen`) - fn force_update_channel() -> Weight { - // Proof Size summary in bytes: - // Measured: `548` - // Estimated: `6212` - // Minimum execution time: 37_237_000 picoseconds. - Weight::from_parts(37_679_000, 0) - .saturating_add(Weight::from_parts(0, 6212)) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `EthereumSystem::Agents` (r:1 w:0) - /// Proof: `EthereumSystem::Agents` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::Channels` (r:1 w:0) - /// Proof: `EthereumSystem::Channels` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:1 w:0) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `EthereumOutboundQueue::OperatingMode` (r:1 w:0) - /// Proof: `EthereumOutboundQueue::OperatingMode` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::BookStateFor` (r:2 w:2) - /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(136), added: 2611, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::ServiceHead` (r:1 w:0) - /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::Pages` (r:0 w:1) - /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65613), added: 68088, mode: `MaxEncodedLen`) - fn transfer_native_from_agent() -> Weight { - // Proof Size summary in bytes: - // Measured: `851` - // Estimated: `6212` - // Minimum execution time: 78_361_000 picoseconds. - Weight::from_parts(79_626_000, 0) - .saturating_add(Weight::from_parts(0, 6212)) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(5)) - } - /// Storage: `EthereumSystem::Agents` (r:1 w:0) - /// Proof: `EthereumSystem::Agents` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::Channels` (r:1 w:0) - /// Proof: `EthereumSystem::Channels` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:1 w:0) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::BookStateFor` (r:2 w:2) - /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(136), added: 2611, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::ServiceHead` (r:1 w:0) - /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::Pages` (r:0 w:1) - /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65613), added: 68088, mode: `MaxEncodedLen`) - fn force_transfer_native_from_agent() -> Weight { - // Proof Size summary in bytes: - // Measured: `570` - // Estimated: `6212` - // Minimum execution time: 41_021_000 picoseconds. - Weight::from_parts(42_200_000, 0) - .saturating_add(Weight::from_parts(0, 6212)) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `EthereumSystem::Channels` (r:1 w:0) - /// Proof: `EthereumSystem::Channels` (`max_values`: None, `max_size`: Some(76), added: 2551, mode: `MaxEncodedLen`) - /// Storage: `EthereumSystem::PricingParameters` (r:1 w:0) - /// Proof: `EthereumSystem::PricingParameters` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::BookStateFor` (r:1 w:1) - /// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(136), added: 2611, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::ServiceHead` (r:1 w:1) - /// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`) - /// Storage: `MessageQueue::Pages` (r:0 w:1) - /// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(65613), added: 68088, mode: `MaxEncodedLen`) - fn set_token_transfer_fees() -> Weight { - // Proof Size summary in bytes: - // Measured: `219` - // Estimated: `3601` - // Minimum execution time: 26_505_000 picoseconds. - Weight::from_parts(27_327_000, 0) - .saturating_add(Weight::from_parts(0, 3601)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) - } -} diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 4308e55adc..b95d9b6ef1 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -15,7 +15,6 @@ // along with Cumulus. If not, see . use super::{ - bridge_to_ethereum_config::EthereumNetwork, bridge_to_polkadot_config::ToBridgeHubPolkadotHaulBlobExporter, AccountId, AllPalletsWithSystem, Balances, CollatorSelection, ParachainInfo, ParachainSystem, PolkadotXcm, PriceForParentDelivery, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, @@ -32,25 +31,20 @@ use parachains_common::xcm_config::{ RelayOrOtherSystemParachains, }; use polkadot_parachain_primitives::primitives::Sibling; -use snowbridge_runtime_common::XcmExportFeeToSibling; use sp_runtime::traits::AccountIdConversion; -use sp_std::marker::PhantomData; use system_parachains_constants::TREASURY_PALLET_ID; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor, - FungibleAdapter, HandleFee, HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, + FungibleAdapter, HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, - XcmFeeToAccount, -}; -use xcm_executor::{ - traits::{ConvertLocation, FeeManager, FeeReason, FeeReason::Export}, - XcmExecutor, + XcmFeeManagerFromComponents, XcmFeeToAccount, }; +use xcm_executor::{traits::ConvertLocation, XcmExecutor}; parameter_types! { pub const KsmRelayLocation: Location = Location::parent(); @@ -205,22 +199,11 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type AssetLocker = (); type AssetExchanger = (); - type FeeManager = XcmFeeManagerFromComponentsBridgeHub< + type FeeManager = XcmFeeManagerFromComponents< WaivedLocations, - ( - XcmExportFeeToSibling< - bp_kusama::Balance, - AccountId, - KsmRelayLocation, - EthereumNetwork, - Self::AssetTransactor, - crate::EthereumOutboundQueue, - >, - XcmFeeToAccount, - ), + XcmFeeToAccount, >; - type MessageExporter = - (ToBridgeHubPolkadotHaulBlobExporter, crate::bridge_to_ethereum_config::SnowbridgeExporter); + type MessageExporter = ToBridgeHubPolkadotHaulBlobExporter; type UniversalAliases = Nothing; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; @@ -281,30 +264,6 @@ impl cumulus_pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; } -/// A `FeeManager` implementation that forces fees for any message delivered to Ethereum. -/// Otherwise, it permits the specified `WaivedLocations` to not pay for fees and uses the provided -/// `HandleFee` implementation. -pub struct XcmFeeManagerFromComponentsBridgeHub( - PhantomData<(WaivedLocations, HandleFee)>, -); -impl, FeeHandler: HandleFee> FeeManager - for XcmFeeManagerFromComponentsBridgeHub -{ - fn is_waived(origin: Option<&Location>, fee_reason: FeeReason) -> bool { - let Some(loc) = origin else { return false }; - if let Export { network, destination: Here } = fee_reason { - if network == EthereumNetwork::get() { - return false - } - } - WaivedLocations::contains(loc) - } - - fn handle_fee(fee: Assets, context: Option<&XcmContext>, reason: FeeReason) { - FeeHandler::handle_fee(fee, context, reason); - } -} - #[test] fn treasury_pallet_account_not_none() { assert_eq!( diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/tests/snowbridge.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/tests/snowbridge.rs deleted file mode 100644 index 20b3b28dbd..0000000000 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/tests/snowbridge.rs +++ /dev/null @@ -1,273 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . - -#![cfg(test)] - -use bp_polkadot_core::Signature; -use bridge_hub_kusama_runtime::{ - bridge_to_ethereum_config::{EthereumGatewayAddress, EthereumNetwork}, - bridge_to_polkadot_config::RefundBridgeHubPolkadotMessages, - xcm_config::{XcmConfig, XcmFeeManagerFromComponentsBridgeHub}, - AllPalletsWithoutSystem, BridgeRejectObsoleteHeadersAndMessages, Executive, - MessageQueueServiceWeight, Runtime, RuntimeCall, RuntimeEvent, SessionKeys, SignedExtra, - UncheckedExtrinsic, -}; -use codec::{Decode, Encode}; -use cumulus_primitives_core::XcmError::{FailedToTransactAsset, TooExpensive}; -use frame_support::{parameter_types, traits::Contains}; -use parachains_common::{AccountId, AuraId, Balance}; -pub use parachains_runtimes_test_utils::test_cases::change_storage_constant_by_governance_works; -use snowbridge_pallet_ethereum_client::WeightInfo; -use sp_core::H160; -use sp_keyring::AccountKeyring::Alice; -use sp_runtime::{ - generic::{Era, SignedPayload}, - AccountId32, -}; -use xcm::latest::prelude::*; -use xcm_builder::HandleFee; -use xcm_executor::traits::{FeeManager, FeeReason}; - -parameter_types! { - pub const DefaultBridgeHubEthereumBaseFee: Balance = 2_750_872_500_000; -} - -fn collator_session_keys() -> bridge_hub_test_utils::CollatorSessionKeys { - bridge_hub_test_utils::CollatorSessionKeys::new( - AccountId::from(Alice), - AccountId::from(Alice), - SessionKeys { aura: AuraId::from(Alice.public()) }, - ) -} - -#[test] -pub fn transfer_token_to_ethereum_works() { - snowbridge_runtime_test_common::send_transfer_token_message_success::( - 1, - collator_session_keys(), - 1013, - 1000, - H160::random(), - H160::random(), - DefaultBridgeHubEthereumBaseFee::get(), - Box::new(|runtime_event_encoded: Vec| { - match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { - Ok(RuntimeEvent::EthereumOutboundQueue(event)) => Some(event), - _ => None, - } - }), - ) -} - -#[test] -pub fn unpaid_transfer_token_to_ethereum_fails_with_barrier() { - snowbridge_runtime_test_common::send_unpaid_transfer_token_message::( - 11155111, - collator_session_keys(), - 1013, - 1000, - H160::random(), - H160::random(), - ) -} - -#[test] -pub fn transfer_token_to_ethereum_fee_not_enough() { - snowbridge_runtime_test_common::send_transfer_token_message_failure::( - 1, - collator_session_keys(), - 1013, - 1000, - DefaultBridgeHubEthereumBaseFee::get() + 1_000_000_000, - H160::random(), - H160::random(), - // fee not enough - 1_000_000, - TooExpensive, - ) -} - -#[test] -pub fn transfer_token_to_ethereum_insufficient_fund() { - snowbridge_runtime_test_common::send_transfer_token_message_failure::( - 1, - collator_session_keys(), - 1013, - 1000, - 1_000_000_000, - H160::random(), - H160::random(), - DefaultBridgeHubEthereumBaseFee::get(), - FailedToTransactAsset("Funds are unavailable"), - ) -} - -#[test] -fn change_ethereum_gateway_by_governance_works() { - change_storage_constant_by_governance_works::( - collator_session_keys(), - bp_bridge_hub_kusama::BRIDGE_HUB_KUSAMA_PARACHAIN_ID, - Box::new(|call| RuntimeCall::System(call).encode()), - || (EthereumGatewayAddress::key().to_vec(), EthereumGatewayAddress::get()), - |_| [1; 20].into(), - ) -} - -/// Fee is not waived when origin is none. -#[test] -fn test_xcm_fee_manager_from_components_bh_origin_none() { - assert!(!TestXcmFeeManager::is_waived(None, FeeReason::ChargeFees)); -} - -/// Fee is not waived when origin is not in waived location. -#[test] -fn test_xcm_fee_manager_from_components_bh_origin_not_in_waived_locations() { - assert!(!TestXcmFeeManager::is_waived( - Some(&Location::new(1, [Parachain(1)])), - FeeReason::DepositReserveAsset - )); -} - -/// Fee is waived when origin is in waived location. -#[test] -fn test_xcm_fee_manager_from_components_bh_origin_in_waived_locations() { - assert!(TestXcmFeeManager::is_waived( - Some(&Location::new(1, [Parachain(2)])), - FeeReason::DepositReserveAsset - )); -} - -/// Fee is waived when origin is in waived location with Export message, but not to Ethereum. -#[test] -fn test_xcm_fee_manager_from_components_bh_origin_in_waived_locations_with_export_to_polkadot_reason( -) { - assert!(TestXcmFeeManager::is_waived( - Some(&Location::new(1, [Parachain(2)])), - FeeReason::Export { network: Polkadot, destination: Here } - )); -} - -/// Fee is not waived when origin is in waived location but exported to Ethereum. -#[test] -fn test_xcm_fee_manager_from_components_bh_in_waived_locations_with_export_to_ethereum_reason() { - assert!(!TestXcmFeeManager::is_waived( - Some(&Location::new(1, [Parachain(1)])), - FeeReason::Export { network: EthereumNetwork::get(), destination: Here } - )); -} - -struct MockWaivedLocations; -impl Contains for MockWaivedLocations { - fn contains(loc: &Location) -> bool { - loc == &Location::new(1, [Parachain(2)]) - } -} - -struct MockFeeHandler; -impl HandleFee for MockFeeHandler { - fn handle_fee(fee: Assets, _context: Option<&XcmContext>, _reason: FeeReason) -> Assets { - fee - } -} - -type TestXcmFeeManager = XcmFeeManagerFromComponentsBridgeHub; - -#[test] -fn max_message_queue_service_weight_is_more_than_beacon_extrinsic_weights() { - let max_message_queue_weight = MessageQueueServiceWeight::get(); - let force_checkpoint = - ::WeightInfo::force_checkpoint(); - let submit_checkpoint = - ::WeightInfo::submit(); - max_message_queue_weight.all_gt(force_checkpoint); - max_message_queue_weight.all_gt(submit_checkpoint); -} - -#[test] -fn ethereum_client_consensus_extrinsics_work() { - snowbridge_runtime_test_common::ethereum_extrinsic( - collator_session_keys(), - 1013, - construct_and_apply_extrinsic, - ); -} - -#[test] -fn ethereum_to_polkadot_message_extrinsics_work() { - snowbridge_runtime_test_common::ethereum_to_polkadot_message_extrinsics_work( - collator_session_keys(), - 1013, - construct_and_apply_extrinsic, - ); -} - -#[test] -fn ethereum_outbound_queue_processes_messages_before_message_queue_works() { - snowbridge_runtime_test_common::ethereum_outbound_queue_processes_messages_before_message_queue_works::< - Runtime, - XcmConfig, - AllPalletsWithoutSystem, - >( - 1, - collator_session_keys(), - 1013, - 1000, - H160::random(), - H160::random(), - DefaultBridgeHubEthereumBaseFee::get(), - Box::new(|runtime_event_encoded: Vec| { - match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { - Ok(RuntimeEvent::EthereumOutboundQueue(event)) => Some(event), - _ => None, - } - }), - ) -} - -fn construct_extrinsic( - sender: sp_keyring::AccountKeyring, - call: RuntimeCall, -) -> UncheckedExtrinsic { - let account_id = AccountId32::from(sender.public()); - let extra: 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( - frame_system::Pallet::::account(&account_id).nonce, - ), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(0), - BridgeRejectObsoleteHeadersAndMessages, - (RefundBridgeHubPolkadotMessages::default()), - frame_metadata_hash_extension::CheckMetadataHash::::new(false), - cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim::::new(), - ); - let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap(); - let signature = payload.using_encoded(|e| sender.sign(e)); - UncheckedExtrinsic::new_signed(call, account_id.into(), Signature::Sr25519(signature), extra) -} - -fn construct_and_apply_extrinsic( - origin: sp_keyring::AccountKeyring, - call: RuntimeCall, -) -> sp_runtime::DispatchOutcome { - let xt = construct_extrinsic(origin, call); - let r = Executive::apply_extrinsic(xt); - r.unwrap() -} diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 7daf3bccca..b970e77524 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -359,6 +359,9 @@ parameter_types! { /// from 35% to 60% of the max block weight to accommodate the Ethereum beacon light client /// extrinsics. The `force_checkpoint` and `submit` extrinsics (for submit, optionally) includes /// the sync committee's pubkeys (512 x 48 bytes). + /// Furthermore, Bridge Hub is a specialized chain for moving messages between sibling + /// parachains and external ecosystems. As such, most of the block weight is expected to be + /// consumed by the Message Queue. pub MessageQueueServiceWeight: Weight = Perbill::from_percent(60) * RuntimeBlockWeights::get().max_block; pub MessageQueueIdleServiceWeight: Weight = Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block; }