Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nits for Snowbridge + stuff moving around #3

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ asset-hub-kusama-runtime = { path = "../../../../../system-parachains/asset-hubs
integration-tests-helpers = { path = "../../../helpers" }
kusama-polkadot-system-emulated-network = { path = "../../../networks/kusama-polkadot-system" }
kusama-system-emulated-network = { path = "../../../networks/kusama-system" }
system-parachains-constants = { path = "../../../../../system-parachains/constants" }

# Snowbridge
snowbridge-beacon-primitives = { version = "0.1.0" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// 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;
use bp_bridge_hub_kusama::snowbridge::{
CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance,
use asset_hub_kusama_runtime::xcm_config::bridging::to_ethereum::{
BridgeHubEthereumBaseFee, EthereumNetwork,
};
use bp_bridge_hub_kusama::snowbridge::CreateAssetCall;
use bridge_hub_kusama_runtime::{
EthereumBeaconClient, EthereumGatewayAddress, EthereumInboundQueue, Runtime, RuntimeOrigin,
};
Expand Down Expand Up @@ -46,7 +46,7 @@ use snowbridge_router_primitives::inbound::{
};
use sp_core::{H160, H256};
use sp_runtime::{DispatchError::Token, FixedU128, TokenError::FundsUnavailable};
use system_parachains_constants::kusama::{currency::UNITS, snowbridge::EthereumNetwork};
use system_parachains_constants::kusama::currency::UNITS;

const INITIAL_FUND: u128 = 5_000_000_000 * KUSAMA_ED;
const CHAIN_ID: u64 = 1;
Expand Down Expand Up @@ -664,26 +664,6 @@ fn asset_hub_foreign_assets_pallet_is_configured_correctly_in_bridge_hub() {
);
}

/// Tests that the EthereumInboundQueue CreateAssetDeposit on BridgeHub is larger than the
/// ForeignAssets AssetDeposit config on AssetHub.
#[test]
fn bridge_hub_inbound_queue_deposit_config_is_equal_to_asset_hub_foreign_asset_pallet_deposit() {
let asset_deposit = asset_hub_kusama_runtime::ForeignAssetsAssetDeposit::get();

let bridge_hub_inbound_queue_asset_deposit = CreateAssetDeposit::get();

assert_eq!(bridge_hub_inbound_queue_asset_deposit, asset_deposit);
}

/// Tests the EthereumInboundQueue pallet index matches the pallet constant.
#[test]
fn bridge_hub_inbound_queue_pallet_index_is_correct() {
let inbound_queue_inbound_queue_pallet_index =
<BridgeHubKusama as BridgeHubKusamaPallet>::EthereumInboundQueue::index();

assert_eq!(inbound_queue_inbound_queue_pallet_index as u8, InboundQueuePalletInstance::get());
}

fn ethereum_sovereign_account() -> AccountId {
let origin_location = (Parent, Parent, EthereumNetwork::get()).into();
GlobalConsensusEthereumConvertsFor::<AccountId>::convert_location(&origin_location).unwrap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ asset-hub-polkadot-runtime = { path = "../../../../../system-parachains/asset-hu
integration-tests-helpers = { path = "../../../helpers" }
kusama-polkadot-system-emulated-network = { path = "../../../networks/kusama-polkadot-system" }
polkadot-system-emulated-network = { path = "../../../networks/polkadot-system" }
system-parachains-constants = { path = "../../../../../system-parachains/constants" }

# Snowbridge
snowbridge-beacon-primitives = { version = "0.1.0" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
use asset_hub_polkadot_runtime::xcm_config::bridging::to_ethereum::BridgeHubEthereumBaseFee;
use bp_bridge_hub_polkadot::snowbridge::{
CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance,
use asset_hub_polkadot_runtime::xcm_config::bridging::to_ethereum::{
BridgeHubEthereumBaseFee, EthereumNetwork,
};
use bp_bridge_hub_polkadot::snowbridge::CreateAssetCall;
use bridge_hub_polkadot_runtime::{
EthereumBeaconClient, EthereumGatewayAddress, EthereumInboundQueue, Runtime, RuntimeOrigin,
};
Expand Down Expand Up @@ -46,7 +46,7 @@ use snowbridge_router_primitives::inbound::{
};
use sp_core::{H160, H256};
use sp_runtime::{DispatchError::Token, FixedU128, TokenError::FundsUnavailable};
use system_parachains_constants::polkadot::{currency::UNITS, snowbridge::EthereumNetwork};
use system_parachains_constants::polkadot::currency::UNITS;

const INITIAL_FUND: u128 = 5_000_000_000 * POLKADOT_ED;
const CHAIN_ID: u64 = 1;
Expand Down Expand Up @@ -668,26 +668,6 @@ fn asset_hub_foreign_assets_pallet_is_configured_correctly_in_bridge_hub() {
);
}

/// Tests that the EthereumInboundQueue CreateAssetDeposit on BridgeHub is larger than the
/// ForeignAssets AssetDeposit config on AssetHub.
#[test]
fn bridge_hub_inbound_queue_deposit_config_is_equal_to_asset_hub_foreign_asset_pallet_deposit() {
let asset_deposit = asset_hub_polkadot_runtime::ForeignAssetsAssetDeposit::get();

let bridge_hub_inbound_queue_asset_deposit = CreateAssetDeposit::get();

assert_eq!(bridge_hub_inbound_queue_asset_deposit, asset_deposit);
}

/// Tests the EthereumInboundQueue pallet index matches the pallet constant.
#[test]
fn bridge_hub_inbound_queue_pallet_index_is_correct() {
let inbound_queue_inbound_queue_pallet_index =
<BridgeHubPolkadot as BridgeHubPolkadotPallet>::EthereumInboundQueue::index();

assert_eq!(inbound_queue_inbound_queue_pallet_index as u8, InboundQueuePalletInstance::get());
}

fn ethereum_sovereign_account() -> AccountId {
let origin_location = (Parent, Parent, EthereumNetwork::get()).into();
GlobalConsensusEthereumConvertsFor::<AccountId>::convert_location(&origin_location).unwrap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ license.workspace = true
codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }

# Local
system-parachains-constants = { path = "../../../constants", default-features = false }

# Bridge Dependencies
bp-xcm-bridge-hub-router = { default-features = false , version = "0.7.0" }

Expand All @@ -29,5 +32,6 @@ std = [
"frame-support/std",
"scale-info/std",
"sp-std/std",
"system-parachains-constants/std",
"xcm/std"
]
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use xcm::prelude::*;

pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall;

use system_parachains_constants::kusama::currency::UNITS;

/// `AssetHubKusama` Runtime `Call` enum.
///
/// The enum represents a subset of possible `Call`s we can send to `AssetHubKusama` chain.
Expand All @@ -48,6 +50,9 @@ frame_support::parameter_types! {
pub CongestedMessage: Xcm<()> = build_congestion_message(true).into();
/// Message that is sent to the sibling Kusama Asset Hub when the with-Polkadot bridge becomes uncongested.
pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into();

/// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub.
pub const CreateForeignAssetDeposit: u128 = UNITS / 10;
}

fn build_congestion_message(is_congested: bool) -> sp_std::vec::Vec<Instruction<()>> {
Expand Down
16 changes: 14 additions & 2 deletions system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ use parachains_common::{
use sp_runtime::RuntimeDebug;
pub use system_parachains_constants::SLOT_DURATION;
use system_parachains_constants::{
kusama::{consensus::*, currency::*, fee::WeightToFee, snowbridge::EthereumNetwork},
kusama::{consensus::*, currency::*, fee::WeightToFee},
AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO,
};
use xcm::latest::prelude::{AssetId, BodyId};
Expand Down Expand Up @@ -398,7 +398,11 @@ impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
type CreateOrigin = ForeignCreators<
(
FromSiblingParachain<parachain_info::Pallet<Runtime>, xcm::v3::Location>,
FromNetwork<xcm_config::UniversalLocation, EthereumNetwork, xcm::v3::Location>,
FromNetwork<
xcm_config::UniversalLocation,
xcm_config::bridging::to_ethereum::EthereumNetwork,
xcm::v3::Location,
>,
),
ForeignCreatorsSovereignAccountOf,
AccountId,
Expand Down Expand Up @@ -1760,4 +1764,12 @@ mod tests {
let parachain_tbf = TransactionByteFee::get();
assert_eq!(relay_tbf / 10, parachain_tbf);
}

#[test]
fn create_foreign_asset_deposit_is_equal_to_asset_hub_foreign_asset_pallet_deposit() {
assert_eq!(
bp_asset_hub_kusama::CreateForeignAssetDeposit::get(),
ForeignAssetsAssetDeposit::get()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use assets_common::{
matching::{FromNetwork, FromSiblingParachain, IsForeignConcreteAsset},
TrustBackedAssetsAsLocation,
};
use bp_bridge_hub_kusama::snowbridge::InboundQueuePalletInstance;
use frame_support::{
parameter_types,
traits::{
Expand All @@ -44,7 +43,7 @@ use parachains_common::{
use polkadot_parachain_primitives::primitives::Sibling;
use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor;
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
use system_parachains_constants::{kusama::snowbridge::EthereumNetwork, TREASURY_PALLET_ID};
use system_parachains_constants::TREASURY_PALLET_ID;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
Expand Down Expand Up @@ -801,6 +800,8 @@ 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 ERC20 token transfer back to Ethereum.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
// limitations under the License.

use asset_hub_kusama_runtime::xcm_config::bridging::{
to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable},
to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork},
SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId,
};
use sp_core::H160;
use sp_std::prelude::*;
use system_parachains_constants::kusama::snowbridge::EthereumNetwork;
use xcm::prelude::*;
use xcm_builder::{ExporterFor, NetworkExportTable};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ license.workspace = true
codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }

# Local
system-parachains-constants = { path = "../../../constants", default-features = false }

# Bridge Dependencies
bp-xcm-bridge-hub-router = { default-features = false , version = "0.7.0" }

Expand All @@ -29,5 +32,6 @@ std = [
"frame-support/std",
"scale-info/std",
"sp-std/std",
"system-parachains-constants/std",
"xcm/std"
]
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use xcm::prelude::*;

pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall;

use system_parachains_constants::polkadot::currency::UNITS;

/// `AssetHubPolkadot` Runtime `Call` enum.
///
/// The enum represents a subset of possible `Call`s we can send to `AssetHubPolkadot` chain.
Expand All @@ -48,6 +50,9 @@ frame_support::parameter_types! {
pub CongestedMessage: Xcm<()> = build_congestion_message(true).into();
/// Message that is sent to the sibling Kusama Asset Hub when the with-Polkadot bridge becomes uncongested.
pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into();

/// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub.
pub const CreateForeignAssetDeposit: u128 = 10 * UNITS;
}

fn build_congestion_message(is_congested: bool) -> sp_std::vec::Vec<Instruction<()>> {
Expand Down
16 changes: 14 additions & 2 deletions system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ use parachains_common::{
use sp_runtime::RuntimeDebug;
pub use system_parachains_constants::SLOT_DURATION;
use system_parachains_constants::{
polkadot::{consensus::*, currency::*, fee::WeightToFee, snowbridge::EthereumNetwork},
polkadot::{consensus::*, currency::*, fee::WeightToFee},
AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO,
};
use xcm::latest::prelude::{AssetId, BodyId};
Expand Down Expand Up @@ -328,7 +328,11 @@ impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
type CreateOrigin = ForeignCreators<
(
FromSiblingParachain<parachain_info::Pallet<Runtime>, xcm::v3::Location>,
FromNetwork<xcm_config::UniversalLocation, EthereumNetwork, xcm::v3::Location>,
FromNetwork<
xcm_config::UniversalLocation,
xcm_config::bridging::to_ethereum::EthereumNetwork,
xcm::v3::Location,
>,
),
ForeignCreatorsSovereignAccountOf,
AccountId,
Expand Down Expand Up @@ -1717,4 +1721,12 @@ mod tests {
let parachain_tbf = TransactionByteFee::get();
assert_eq!(relay_tbf / 10, parachain_tbf);
}

#[test]
fn create_foreign_asset_deposit_is_equal_to_asset_hub_foreign_asset_pallet_deposit() {
assert_eq!(
bp_asset_hub_polkadot::CreateForeignAssetDeposit::get(),
ForeignAssetsAssetDeposit::get()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use assets_common::{
matching::{FromNetwork, FromSiblingParachain, IsForeignConcreteAsset},
TrustBackedAssetsAsLocation,
};
use bp_bridge_hub_polkadot::snowbridge::InboundQueuePalletInstance;
use frame_support::{
parameter_types,
traits::{
Expand All @@ -45,7 +44,7 @@ use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_constants::system_parachain;
use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor;
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
use system_parachains_constants::{polkadot::snowbridge::EthereumNetwork, TREASURY_PALLET_ID};
use system_parachains_constants::TREASURY_PALLET_ID;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
Expand Down Expand Up @@ -795,6 +794,8 @@ pub mod bridging {

pub mod to_ethereum {
use super::*;
pub use bp_bridge_hub_polkadot::snowbridge::EthereumNetwork;
use bp_bridge_hub_polkadot::snowbridge::InboundQueuePalletInstance;

parameter_types! {
/// User fee for ERC20 token transfer back to Ethereum.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
// limitations under the License.

use asset_hub_polkadot_runtime::xcm_config::bridging::{
to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable},
to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork},
SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId,
};
use sp_core::H160;
use sp_std::prelude::*;
use system_parachains_constants::polkadot::snowbridge::EthereumNetwork;
use xcm::prelude::*;
use xcm_builder::{ExporterFor, NetworkExportTable};

Expand Down
Loading
Loading