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

Commit

Permalink
adds last bit of config
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Sep 13, 2023
1 parent 1187bc2 commit ddc9c9f
Showing 1 changed file with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom};
use polkadot_parachain::primitives::Sibling;
use snowbridge_outbound_queue;
use snowbridge_router_primitives::outbound::{AgentHashedDescription, EthereumBlobExporter};
use sp_core::Get;
use xcm::latest::prelude::*;
use xcm_builder::{
Expand Down Expand Up @@ -168,10 +170,10 @@ impl Contains<RuntimeCall> for SafeCallFilter {
// Allow to change dedicated storage items (called by governance-like)
match call {
RuntimeCall::System(frame_system::Call::set_storage { items })
if items.iter().any(|(k, _)| {
k.eq(&DeliveryRewardInBalance::key()) |
k.eq(&RequiredStakeForStakeAndSlash::key())
}) =>
if items.iter().any(|(k, _)| {
k.eq(&DeliveryRewardInBalance::key()) |
k.eq(&RequiredStakeForStakeAndSlash::key())
}) =>
return true,
_ => (),
};
Expand Down Expand Up @@ -205,7 +207,18 @@ impl Contains<RuntimeCall> for SafeCallFilter {
RuntimeCall::BridgeWococoGrandpa(pallet_bridge_grandpa::Call::<
Runtime,
BridgeGrandpaWococoInstance,
>::initialize { .. })
>::initialize { .. }) |
RuntimeCall::EthereumBeaconClient(
snowbridge_ethereum_beacon_client::Call::force_checkpoint { .. }
| snowbridge_ethereum_beacon_client::Call::set_owner { .. }
| snowbridge_ethereum_beacon_client::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumInboundQueue(
snowbridge_inbound_queue::Call::set_owner { .. }
| snowbridge_inbound_queue::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumOutboundQueue(
snowbridge_outbound_queue::Call::set_owner { .. } |
snowbridge_outbound_queue::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumControl(..)
)
}
}
Expand Down Expand Up @@ -257,7 +270,7 @@ impl xcm_executor::Config for XcmConfig {
MaxInstructions,
>;
type Trader =
UsingComponents<WeightToFee, RelayLocation, AccountId, Balances, ToStakingPot<Runtime>>;
UsingComponents<WeightToFee, RelayLocation, AccountId, Balances, ToStakingPot<Runtime>>;
type ResponseHandler = PolkadotXcm;
type AssetTrap = PolkadotXcm;
type AssetLocker = ();
Expand Down Expand Up @@ -331,6 +344,13 @@ impl cumulus_pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
}

pub type SnowbridgeExporter = EthereumBlobExporter<
UniversalLocation,
EthereumGatewayLocation,
snowbridge_outbound_queue::Pallet<Runtime>,
AgentHashedDescription
>;

/// Hacky switch implementation, because we have just one runtime for Rococo and Wococo BridgeHub,
/// so it means we have just one XcmConfig
pub struct BridgeHubRococoOrBridgeHubWococoSwitchExporter;
Expand All @@ -344,6 +364,7 @@ impl ExportXcm for BridgeHubRococoOrBridgeHubWococoSwitchExporter {
destination: &mut Option<InteriorMultiLocation>,
message: &mut Option<Xcm<()>>,
) -> SendResult<Self::Ticket> {
let relay: NetworkId = RelayNetwork::get();
match network {
Rococo => ToBridgeHubRococoHaulBlobExporter::validate(
network,
Expand All @@ -352,29 +373,44 @@ impl ExportXcm for BridgeHubRococoOrBridgeHubWococoSwitchExporter {
destination,
message,
)
.map(|result| ((Rococo, result.0), result.1)),
.map(|result| ((Rococo, result.0), result.1)),
Wococo => ToBridgeHubWococoHaulBlobExporter::validate(
network,
channel,
universal_source,
destination,
message,
)
.map(|result| ((Wococo, result.0), result.1)),
.map(|result| ((Wococo, result.0), result.1)),
location if location == EthereumNetwork::get() && relay == NetworkId::Rococo => {
SnowbridgeExporter::validate(
network,
channel,
universal_source,
destination,
message,
)
.map(|result| ((EthereumNetwork::get(), (result.0, XcmHash::default())), result.1))
},
_ => unimplemented!("Unsupported network: {:?}", network),
}
}

fn deliver(ticket: Self::Ticket) -> Result<XcmHash, SendError> {
let (network, ticket) = ticket;
let relay: NetworkId = RelayNetwork::get();
match network {
Rococo => ToBridgeHubRococoHaulBlobExporter::deliver(ticket),
Wococo => ToBridgeHubWococoHaulBlobExporter::deliver(ticket),
location if location == EthereumNetwork::get() && relay == NetworkId::Rococo => {
SnowbridgeExporter::deliver(ticket.0)
},
_ => unimplemented!("Unsupported network: {:?}", network),
}
}
}


/// [`Contains`] implementation that allows multiLocation from sibling chains only
pub struct AllowSiblingsOnly;
impl Contains<MultiLocation> for AllowSiblingsOnly {
Expand Down

0 comments on commit ddc9c9f

Please sign in to comment.