Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
use ethereum network from snowbridge rococo common crate
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Nov 30, 2023
1 parent 90c2783 commit a5b1964
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 10 deletions.
13 changes: 13 additions & 0 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 @@ -49,3 +49,4 @@ snowbridge-router-primitives = { path = "../../../../../../../../parachain/primi
snowbridge-control = { path = "../../../../../../../../parachain/pallets/control", default-features = false }
snowbridge-inbound-queue = { path = "../../../../../../../../parachain/pallets/inbound-queue", default-features = false }
snowbridge-outbound-queue = { path = "../../../../../../../../parachain/pallets/outbound-queue", default-features = false }
snowbridge-rococo-common = { path = "../../../../../../../../parachain/runtime/rococo-common", default-features = false }
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use hex_literal::hex;
use snowbridge_control;
use snowbridge_core::outbound::OperatingMode;
use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage};
use snowbridge_rococo_common::EthereumNetwork;
use sp_core::H256;

const INITIAL_FUND: u128 = 5_000_000_000 * ROCOCO_ED;
Expand Down Expand Up @@ -244,7 +245,7 @@ fn send_token_to_penpal() {
]);

let weth_asset_location: MultiLocation =
(Parent, Parent, Ethereum { chain_id: 15 }, AccountKey20 { network: None, key: WETH })
(Parent, Parent, EthereumNetwork::get(), AccountKey20 { network: None, key: WETH })
.into();
let weth_asset_id = weth_asset_location.into();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ parachain-info = { package = "staging-parachain-info", path = "../../../pallets/
parachains-common = { path = "../../../common", default-features = false }
assets-common = { path = "../common", default-features = false }
snowbridge-router-primitives = { path = "../../../../../../parachain/primitives/router", default-features = false }
snowbridge-rococo-common = { path = "../../../../../../parachain/runtime/rococo-common", default-features = false }

# Bridges
pallet-xcm-bridge-hub-router = { path = "../../../../../bridges/modules/xcm-bridge-hub-router", default-features = false }
Expand Down Expand Up @@ -230,6 +231,7 @@ std = [
"rococo-runtime-constants/std",
"scale-info/std",
"snowbridge-router-primitives/std",
"snowbridge-rococo-common/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ impl pallet_xcm_bridge_hub_router::Config<ToEthereumXcmRouterInstance> for Runti
type WeightInfo = weights::pallet_xcm_bridge_hub_router::WeightInfo<Runtime>;

type UniversalLocation = xcm_config::UniversalLocation;
type BridgedNetworkId = xcm_config::bridging::to_ethereum::EthereumNetwork;
type BridgedNetworkId = snowbridge_rococo_common::EthereumNetwork;
type Bridges = xcm_config::bridging::NetworkExportTable;

#[cfg(not(feature = "runtime-benchmarks"))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use rococo_runtime_constants::system_parachain;
use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor;
use snowbridge_rococo_common::EthereumNetwork;
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
use xcm::latest::prelude::*;
use xcm_builder::{
Expand Down Expand Up @@ -848,7 +849,6 @@ pub mod bridging {
use super::*;

parameter_types! {
pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 15 };
pub EthereumLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(EthereumNetwork::get())));

/// User fee for ERC20 token transfer back to Ethereum.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ snowbridge-outbound-queue = { path = "../../../../../../parachain/pallets/outbou
snowbridge-outbound-queue-runtime-api = { path = "../../../../../../parachain/pallets/outbound-queue/runtime-api", default-features = false }
snowbridge-router-primitives = { path = "../../../../../../parachain/primitives/router", default-features = false }
snowbridge-runtime-common = { path = "../../../../../../parachain/runtime/runtime-common", default-features = false }
snowbridge-rococo-common = { path = "../../../../../../parachain/runtime/rococo-common", default-features = false }

bridge-hub-common = { path = "../common", default-features = false }

Expand Down Expand Up @@ -200,6 +201,7 @@ std = [
"snowbridge-outbound-queue/std",
"snowbridge-router-primitives/std",
"snowbridge-runtime-common/std",
"snowbridge-rococo-common/std",
"substrate-wasm-builder",
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{
xcm_config::{AgentIdOf, EthereumNetwork, UniversalLocation},
xcm_config::{AgentIdOf, UniversalLocation},
Runtime,
};
use snowbridge_router_primitives::outbound::EthereumBlobExporter;
use snowbridge_rococo_common::EthereumNetwork;

pub type SnowbridgeExporter = EthereumBlobExporter<
UniversalLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use rococo_runtime_constants::system_parachain;
use snowbridge_core::DescribeHere;
use snowbridge_runtime_common::XcmExportFeeToSibling;
use snowbridge_rococo_common::EthereumNetwork;
use sp_core::{Get, H256};
use sp_runtime::traits::AccountIdConversion;
use sp_std::marker::PhantomData;
Expand Down Expand Up @@ -70,9 +71,6 @@ parameter_types! {
pub const MaxAssetsIntoHolding: u32 = 64;
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();

// Network and location for the local Ethereum testnet.
pub const EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 15 };
}

/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
Expand Down Expand Up @@ -469,8 +467,8 @@ impl<WaivedLocations: Contains<MultiLocation>, FeeHandler: HandleFee> FeeManager
{
fn is_waived(origin: Option<&MultiLocation>, fee_reason: FeeReason) -> bool {
let Some(loc) = origin else { return false };
if let Export { network: Ethereum { chain_id: 15 }, destination: Here } = fee_reason {
return false
if let Export { network, destination: Here } = fee_reason {
return !(network == EthereumNetwork::get());
}
WaivedLocations::contains(loc)
}
Expand Down
2 changes: 2 additions & 0 deletions cumulus/parachains/runtimes/testing/penpal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d
parachain-info = { package = "staging-parachain-info", path = "../../../pallets/parachain-info", default-features = false }
parachains-common = { path = "../../../common", default-features = false }
assets-common = { path = "../../assets/common", default-features = false }
snowbridge-rococo-common = { path = "../../../../../../parachain/runtime/rococo-common", default-features = false }

[features]
default = [ "std" ]
Expand Down Expand Up @@ -116,6 +117,7 @@ std = [
"polkadot-parachain-primitives/std",
"polkadot-primitives/std",
"polkadot-runtime-common/std",
"snowbridge-rococo-common/std",
"scale-info/std",
"sp-api/std",
"sp-block-builder/std",
Expand Down
3 changes: 2 additions & 1 deletion cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use pallet_assets::Instance1;
use pallet_xcm::XcmPassthrough;
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::impls::ToAuthor;
use snowbridge_rococo_common::EthereumNetwork;
use sp_runtime::traits::Zero;
use xcm::latest::prelude::*;
use xcm_builder::{
Expand Down Expand Up @@ -271,7 +272,7 @@ parameter_types! {
pub SystemAssetHubAssetsPalletLocation: MultiLocation =
MultiLocation::new(1, X2(Parachain(1000), PalletInstance(50)));
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
pub EthereumLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(Ethereum { chain_id: 15 })));
pub EthereumLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(EthereumNetwork::get())));
}

pub type Reserves = (
Expand Down

0 comments on commit a5b1964

Please sign in to comment.