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

Commit

Permalink
latest updates and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Nov 10, 2023
1 parent 3c9d59a commit 0cfbc39
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 41 deletions.
2 changes: 2 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 @@ -17,8 +17,8 @@ use super::{
AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, BaseDeliveryFee,
FeeAssetId, ForeignAssets, ForeignAssetsInstance, ParachainInfo, ParachainSystem, PolkadotXcm,
PoolAssets, Runtime, RuntimeCall, RuntimeEvent, RuntimeFlavor, RuntimeOrigin,
ToRococoXcmRouter, ToWestendXcmRouter, ToWococoXcmRouter, TransactionByteFee,
TrustBackedAssetsInstance, WeightToFee, XcmpQueue, ToEthereumXcmRouter,
ToEthereumXcmRouter, ToRococoXcmRouter, ToWestendXcmRouter, ToWococoXcmRouter,
TransactionByteFee, TrustBackedAssetsInstance, WeightToFee, XcmpQueue,
};
use assets_common::{
local_and_foreign_assets::MatchesLocalAndForeignAssetsMultiLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ use sp_std::prelude::*;
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use bridge_hub_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
AggregateMessageOrigin,
};
use cumulus_primitives_core::ParaId;
use bridge_hub_common::{AggregateMessageOrigin, message_queue::{NarrowOriginToSibling, ParaIdToSibling}};
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ use sp_std::prelude::*;
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use bridge_hub_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
AggregateMessageOrigin,
};
use cumulus_primitives_core::ParaId;
use bridge_hub_common::{AggregateMessageOrigin, message_queue::{NarrowOriginToSibling, ParaIdToSibling}};
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

use crate::{
bridge_common_config::{BridgeParachainRococoInstance, DeliveryRewardInBalance},
weights, AccountId, BridgeRococoMessages, ParachainInfo, Runtime, RuntimeEvent, RuntimeOrigin,
weights,
xcm_config::{AgentIdOf, EthereumNetwork, UniversalLocation},
AccountId, BridgeRococoMessages, ParachainInfo, Runtime, RuntimeEvent, RuntimeOrigin,
XcmRouter,
};
use bp_messages::LaneId;
Expand All @@ -40,16 +42,13 @@ use bridge_runtime_common::{
};
use codec::Encode;
use frame_support::{parameter_types, traits::PalletInfoAccess};
use snowbridge_router_primitives::outbound::EthereumBlobExporter;
use sp_runtime::RuntimeDebug;
use xcm::{
latest::prelude::*,
prelude::{InteriorMultiLocation, NetworkId},
};
use xcm_builder::{BridgeBlobDispatcher, HaulBlobExporter};
use snowbridge_router_primitives::outbound::EthereumBlobExporter;
use crate::xcm_config::EthereumNetwork;
use crate::xcm_config::AgentIdOf;
use crate::xcm_config::UniversalLocation;

parameter_types! {
pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ use pallet_xcm::EnsureXcm;
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm::VersionedMultiLocation;
use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin, XcmRouter};
use xcm_config::{XcmOriginToTransactDispatchOrigin, XcmRouter};

use bp_runtime::HeaderId;
use bridge_hub_common::{AggregateMessageOrigin, BridgeHubMessageRouter, message_queue::{NarrowOriginToSibling, ParaIdToSibling}};
use bridge_hub_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
AggregateMessageOrigin, BridgeHubMessageRouter,
};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand All @@ -99,7 +102,6 @@ use parachains_common::{
AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO,
HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
use xcm_executor::XcmExecutor;

#[cfg(feature = "runtime-benchmarks")]
use crate::xcm_config::benchmark_helper::DoNothingRouter;
Expand Down Expand Up @@ -388,9 +390,8 @@ impl pallet_message_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
AggregateMessageOrigin,
>;
type MessageProcessor =
pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>;
#[cfg(not(feature = "runtime-benchmarks"))]
type MessageProcessor = BridgeHubMessageRouter<
xcm_builder::ProcessXcmMessage<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use parachains_common::{
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use rococo_runtime_constants::system_parachain::SystemParachains;
use snowbridge_router_primitives::outbound::EthereumBlobExporter;
use sp_core::{Get, H256};
use sp_runtime::traits::AccountIdConversion;
use sp_std::marker::PhantomData;
Expand Down Expand Up @@ -222,8 +221,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
) | RuntimeCall::EthereumInboundQueue(
snowbridge_inbound_queue::Call::set_operating_mode { .. },
) /* | RuntimeCall::EthereumOutboundQueue(
snowbridge_outbound_queue::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumControl(..) */
snowbridge_outbound_queue::Call::set_operating_mode { .. },
) | RuntimeCall::EthereumControl(..) */
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ pub mod bridge_to_rococo_config;
mod weights;
pub mod xcm_config;

use bridge_hub_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
AggregateMessageOrigin,
};
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_primitives_core::ParaId;
use bridge_hub_common::{AggregateMessageOrigin, message_queue::{NarrowOriginToSibling, ParaIdToSibling}};
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
Expand Down
3 changes: 1 addition & 2 deletions cumulus/parachains/runtimes/bridge-hubs/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@

pub mod message_queue;

pub use message_queue::{AggregateMessageOrigin, SnowbridgeMessageOrigin, BridgeHubMessageRouter};

pub use message_queue::{AggregateMessageOrigin, BridgeHubMessageRouter, SnowbridgeMessageOrigin};
39 changes: 19 additions & 20 deletions cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Runtime configuration for MessageQueue pallet
use sp_std::{prelude::*, marker::PhantomData};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{weights::WeightMeter, traits::{ProcessMessage, ProcessMessageError}};
use scale_info::TypeInfo;
use cumulus_primitives_core::ParaId;
use xcm::v3::{MultiLocation, Junction};
use frame_support::traits::{QueueFootprint, QueuePausedQuery};
use frame_support::{
traits::{ProcessMessage, ProcessMessageError, QueueFootprint, QueuePausedQuery},
weights::WeightMeter,
};
use pallet_message_queue::OnQueueChanged;
use scale_info::TypeInfo;
use sp_std::{marker::PhantomData, prelude::*};
use xcm::v3::{Junction, MultiLocation};

/// The aggregate origin of an inbound message.
/// This is specialized for BridgeHub, as the snowbridge-outbound-queue pallet is also using
Expand Down Expand Up @@ -55,8 +57,7 @@ impl From<AggregateMessageOrigin> for MultiLocation {
match origin {
Here => MultiLocation::here(),
Parent => MultiLocation::parent(),
Sibling(id) =>
MultiLocation::new(1, Junction::Parachain(id.into())),
Sibling(id) => MultiLocation::new(1, Junction::Parachain(id.into())),
// NOTE: We don't need this conversion for Snowbridge. However we have to
// implement it anyway as xcm_builder::ProcessXcmMessage requires it.
Snowbridge(_) => MultiLocation::default(),
Expand All @@ -76,21 +77,18 @@ impl From<u32> for AggregateMessageOrigin {
}

/// Routes messages to either the XCMP or Snowbridge processor.
pub struct BridgeHubMessageRouter<XcmpProcessor, SnowbridgeProcessor>(PhantomData<(XcmpProcessor, SnowbridgeProcessor)>)
pub struct BridgeHubMessageRouter<XcmpProcessor, SnowbridgeProcessor>(
PhantomData<(XcmpProcessor, SnowbridgeProcessor)>,
)
where
XcmpProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
SnowbridgeProcessor: ProcessMessage<Origin = AggregateMessageOrigin>;

impl<
XcmpProcessor,
SnowbridgeProcessor
> ProcessMessage for BridgeHubMessageRouter<
XcmpProcessor,
SnowbridgeProcessor
>
impl<XcmpProcessor, SnowbridgeProcessor> ProcessMessage
for BridgeHubMessageRouter<XcmpProcessor, SnowbridgeProcessor>
where
XcmpProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
SnowbridgeProcessor: ProcessMessage<Origin = AggregateMessageOrigin>
SnowbridgeProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
{
type Origin = AggregateMessageOrigin;

Expand All @@ -102,15 +100,16 @@ where
) -> Result<bool, ProcessMessageError> {
use AggregateMessageOrigin::*;
match origin {
Here | Parent | Sibling(_) => XcmpProcessor::process_message(message, origin, meter, id),
Snowbridge(_) => SnowbridgeProcessor::process_message(message, origin, meter, id)
Here | Parent | Sibling(_) =>
XcmpProcessor::process_message(message, origin, meter, id),
Snowbridge(_) => SnowbridgeProcessor::process_message(message, origin, meter, id),
}
}
}

pub struct NarrowOriginToSibling<Inner>(PhantomData<Inner>);
impl<Inner: QueuePausedQuery<ParaId>> QueuePausedQuery<AggregateMessageOrigin>
for NarrowOriginToSibling<Inner>
for NarrowOriginToSibling<Inner>
{
fn is_paused(origin: &AggregateMessageOrigin) -> bool {
match origin {
Expand All @@ -121,7 +120,7 @@ for NarrowOriginToSibling<Inner>
}

impl<Inner: OnQueueChanged<ParaId>> OnQueueChanged<AggregateMessageOrigin>
for NarrowOriginToSibling<Inner>
for NarrowOriginToSibling<Inner>
{
fn on_queue_changed(origin: AggregateMessageOrigin, fp: QueueFootprint) {
if let AggregateMessageOrigin::Sibling(id) = origin {
Expand Down

0 comments on commit 0cfbc39

Please sign in to comment.