Skip to content

Commit

Permalink
initial modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
programskillforverification committed Aug 16, 2024
1 parent 843c4db commit 1cfe2ca
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 deletions.
7 changes: 5 additions & 2 deletions bridges/modules/xcm-bridge-hub/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ use sp_runtime::{
AccountId32, BuildStorage, StateVersion,
};
use sp_std::cell::RefCell;
use xcm::prelude::*;
use xcm::{latest::ROCOCO_GENESIS_HASH, prelude::*};
use xcm_builder::{
AllowUnpaidExecutionFrom, FixedWeightBounds, InspectMessageQueues, NetworkExportTable,
NetworkExportTableItem,
};
use xcm_executor::XcmExecutor;

// const ROCOCO_GENESIS_HASH: [u8; 32] =
// hex!["6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e"];

pub type AccountId = AccountId32;
pub type Balance = u64;

Expand Down Expand Up @@ -158,7 +161,7 @@ parameter_types! {
pub BridgedRelayNetworkLocation: Location = (Parent, GlobalConsensus(BridgedRelayNetwork::get())).into();
pub BridgedRelativeDestination: InteriorLocation = [Parachain(BRIDGED_ASSET_HUB_ID)].into();
pub BridgedUniversalDestination: InteriorLocation = [GlobalConsensus(BridgedRelayNetwork::get()), Parachain(BRIDGED_ASSET_HUB_ID)].into();
pub const NonBridgedRelayNetwork: NetworkId = NetworkId::Rococo;
pub const NonBridgedRelayNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);

pub const BridgeDeposit: Balance = 100_000;
pub const Penalty: Balance = 1_000;
Expand Down
4 changes: 2 additions & 2 deletions bridges/snowbridge/pallets/system/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use sp_runtime::{
traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, Keccak256},
AccountId32, BuildStorage, FixedU128,
};
use xcm::prelude::*;
use xcm::{latest::ROCOCO_GENESIS_HASH, prelude::*};

#[cfg(feature = "runtime-benchmarks")]
use crate::BenchmarkHelper;
Expand Down Expand Up @@ -177,7 +177,7 @@ pub const DOT: u128 = 10_000_000_000;
parameter_types! {
pub TreasuryAccount: AccountId = PalletId(*b"py/trsry").into_account_truncating();
pub Fee: u64 = 1000;
pub const RococoNetwork: NetworkId = NetworkId::Rococo;
pub const RococoNetwork: NetworkId = NetworkId::ByGenesis(ROCOCO_GENESIS_HASH);
pub const InitialFunding: u128 = 1_000_000_000_000;
pub AssetHubParaId: ParaId = ParaId::new(1000);
pub TestParaId: u32 = 2000;
Expand Down
9 changes: 6 additions & 3 deletions cumulus/parachains/runtimes/assets/common/src/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ impl<AssetsAllowedNetworks: Contains<Location>, OriginLocation: Get<Location>>
mod tests {
use super::*;
use frame_support::parameter_types;
use xcm::latest::ROCOCO_GENESIS_HASH;

parameter_types! {
pub UniversalLocation: InteriorLocation = [GlobalConsensus(Rococo), Parachain(1000)].into();
pub UniversalLocation: InteriorLocation = [GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(1000)].into();
pub ExpectedNetworkId: NetworkId = Wococo;
}

Expand All @@ -156,13 +157,15 @@ mod tests {
let asset: Location = (
Parent,
Parent,
GlobalConsensus(Rococo),
GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)),
Parachain(1000),
PalletInstance(1),
GeneralIndex(1),
)
.into();
let origin: Location = (Parent, Parent, GlobalConsensus(Rococo), Parachain(1000)).into();
let origin: Location =
(Parent, Parent, GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(1000))
.into();
assert!(!FromNetwork::<UniversalLocation, ExpectedNetworkId>::contains(&asset, &origin));

// asset and origin from here fails
Expand Down
2 changes: 1 addition & 1 deletion polkadot/xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ serde = { features = ["alloc", "derive", "rc"], workspace = true }
schemars = { default-features = true, optional = true, workspace = true }
xcm-procedural = { workspace = true, default-features = true }
environmental = { workspace = true }
hex-literal = { workspace = true, default-features = true }

[dev-dependencies]
sp-io = { workspace = true, default-features = true }
hex = { workspace = true, default-features = true }
hex-literal = { workspace = true, default-features = true }

[features]
default = ["std"]
Expand Down
6 changes: 0 additions & 6 deletions polkadot/xcm/src/v3/junction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ pub enum NetworkId {
Polkadot,
/// The Kusama canary-net Relay-chain.
Kusama,
/// The Westend testnet Relay-chain.
Westend,
/// The Rococo testnet Relay-chain.
Rococo,
/// The Wococo testnet Relay-chain.
Wococo,
/// An Ethereum network specified by its chain ID.
Expand Down Expand Up @@ -118,8 +114,6 @@ impl From<NewNetworkId> for NetworkId {
ByFork { block_number, block_hash } => Self::ByFork { block_number, block_hash },
Polkadot => Self::Polkadot,
Kusama => Self::Kusama,
Westend => Self::Westend,
Rococo => Self::Rococo,
Wococo => Self::Wococo,
Ethereum { chain_id } => Self::Ethereum { chain_id },
BitcoinCore => Self::BitcoinCore,
Expand Down
13 changes: 7 additions & 6 deletions polkadot/xcm/src/v4/junction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::{
};
use bounded_collections::{BoundedSlice, BoundedVec, ConstU32};
use codec::{self, Decode, Encode, MaxEncodedLen};
use hex_literal::hex;
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -103,6 +104,12 @@ pub enum Junction {
GlobalConsensus(NetworkId),
}

pub const WESTEND_GENESIS_HASH: [u8; 32] =
hex!["e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e"];

pub const ROCOCO_GENESIS_HASH: [u8; 32] =
hex!["6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e"];

/// A global identifier of a data structure existing within consensus.
///
/// Maintenance note: Networks with global consensus and which are practically bridgeable within the
Expand Down Expand Up @@ -131,10 +138,6 @@ pub enum NetworkId {
Polkadot,
/// The Kusama canary-net Relay-chain.
Kusama,
/// The Westend testnet Relay-chain.
Westend,
/// The Rococo testnet Relay-chain.
Rococo,
/// The Wococo testnet Relay-chain.
Wococo,
/// An Ethereum network specified by its chain ID.
Expand Down Expand Up @@ -165,8 +168,6 @@ impl From<OldNetworkId> for NetworkId {
ByFork { block_number, block_hash } => Self::ByFork { block_number, block_hash },
Polkadot => Self::Polkadot,
Kusama => Self::Kusama,
Westend => Self::Westend,
Rococo => Self::Rococo,
Wococo => Self::Wococo,
Ethereum { chain_id } => Self::Ethereum { chain_id },
BitcoinCore => Self::BitcoinCore,
Expand Down
4 changes: 3 additions & 1 deletion polkadot/xcm/src/v4/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ pub use asset::{
Asset, AssetFilter, AssetId, AssetInstance, Assets, Fungibility, WildAsset, WildFungibility,
MAX_ITEMS_IN_ASSETS,
};
pub use junction::{BodyId, BodyPart, Junction, NetworkId};
pub use junction::{
BodyId, BodyPart, Junction, NetworkId, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH,
};
pub use junctions::Junctions;
pub use location::{Ancestor, AncestorThen, InteriorLocation, Location, Parent, ParentThen};
pub use traits::{
Expand Down
4 changes: 2 additions & 2 deletions polkadot/xcm/xcm-runtime-apis/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use frame_support::{
};
use frame_system::{EnsureRoot, RawOrigin as SystemRawOrigin};
use pallet_xcm::TestWeightInfo;
use xcm::{prelude::*, Version as XcmVersion};
use xcm::{latest::WESTEND_GENESIS_HASH, prelude::*, Version as XcmVersion};
use xcm_builder::{
AllowTopLevelPaidExecutionFrom, ConvertedConcreteId, EnsureXcmOrigin, FixedRateOfFungible,
FixedWeightBounds, FungibleAdapter, FungiblesAdapter, IsConcrete, MintLocation, NoChecking,
Expand Down Expand Up @@ -136,7 +136,7 @@ parameter_types! {
pub const BaseXcmWeight: Weight = Weight::from_parts(100, 10); // Random value.
pub const MaxInstructions: u32 = 100;
pub const NativeTokenPerSecondPerByte: (AssetId, u128, u128) = (AssetId(HereLocation::get()), 1, 1);
pub UniversalLocation: InteriorLocation = [GlobalConsensus(NetworkId::Westend), Parachain(2000)].into();
pub UniversalLocation: InteriorLocation = [GlobalConsensus(NetworkId::ByGenesis(WESTEND_GENESIS_HASH)), Parachain(2000)].into();
pub static AdvertisedXcmVersion: XcmVersion = 4;
pub const HereLocation: Location = Location::here();
pub const RelayLocation: Location = Location::parent();
Expand Down

0 comments on commit 1cfe2ca

Please sign in to comment.