Skip to content

Commit

Permalink
Xcm hooks (#13)
Browse files Browse the repository at this point in the history
* add hooks

* hack weights

* fix weights

* reset weights

* Revert "hack weights"

This reverts commit a339a15.

* hack weights

* re-use the same configured network

* rustfmt

* revert weight hacks

* updated cargo lock

* removed benchmark
  • Loading branch information
alistair-singh authored May 11, 2023
1 parent 13c048e commit d80db53
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 3 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 @@ -551,7 +551,7 @@ impl pallet_bridge_relayers::Config for Runtime {
use snowbridge_router_primitives::InboundMessageConverter;

parameter_types! {
pub const EthereumNetwork: xcm::v3::NetworkId = xcm::v3::NetworkId::Ethereum { chain_id: 1};
pub const EthereumNetwork: xcm::v3::NetworkId = xcm::v3::NetworkId::Ethereum { chain_id: 1 };
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::{
};
use crate::{
bridge_hub_rococo_config::ToBridgeHubWococoHaulBlobExporter,
bridge_hub_wococo_config::ToBridgeHubRococoHaulBlobExporter,
bridge_hub_wococo_config::ToBridgeHubRococoHaulBlobExporter, EthereumNetwork,
};
use frame_support::{
match_types, parameter_types,
Expand Down Expand Up @@ -305,6 +305,8 @@ impl cumulus_pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
}

use cumulus_primitives_core::SendError::Unroutable;

/// 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;
impl ExportXcm for BridgeHubRococoOrBridgeHubWococoSwitchExporter {
Expand All @@ -317,6 +319,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 @@ -334,15 +337,20 @@ impl ExportXcm for BridgeHubRococoOrBridgeHubWococoSwitchExporter {
message,
)
.map(|result| ((Wococo, result.0), result.1)),
location if location == EthereumNetwork::get() && relay == NetworkId::Rococo =>
Err(Unroutable),
_ => 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 =>
Err(Unroutable),
_ => unimplemented!("Unsupported network: {:?}", network),
}
}
Expand Down

0 comments on commit d80db53

Please sign in to comment.