Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic fees v1: report congestion status to sending chain #2318

Merged
merged 14 commits into from
Aug 4, 2023
Merged
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ impl pallet_bridge_messages::Config<WithRialtoMessagesInstance> for Runtime {
WithRialtoMessagesInstance,
frame_support::traits::ConstU64<100_000>,
>;
type OnMessagesDelivered = ();

type SourceHeaderChain = crate::rialto_messages::RialtoAsSourceHeaderChain;
type MessageDispatch = crate::rialto_messages::FromRialtoMessageDispatch;
Expand Down Expand Up @@ -496,6 +497,7 @@ impl pallet_bridge_messages::Config<WithRialtoParachainMessagesInstance> for Run
WithRialtoParachainMessagesInstance,
frame_support::traits::ConstU64<100_000>,
>;
type OnMessagesDelivered = ();

type SourceHeaderChain = crate::rialto_parachain_messages::RialtoParachainAsSourceHeaderChain;
type MessageDispatch = crate::rialto_parachain_messages::FromRialtoParachainMessageDispatch;
Expand Down Expand Up @@ -558,6 +560,7 @@ impl pallet_xcm_bridge_hub_router::Config for Runtime {
type BridgedNetworkId = xcm_config::RialtoNetwork;
type Bridges = NetworkExportTable<BridgeTable>;

type BridgeHubOrigin = frame_system::EnsureRoot<AccountId>;
type ToBridgeHubSender = xcm_config::XcmRouter;
type WithBridgeHubChannel = xcm_config::EmulatedSiblingXcmpChannel;

Expand Down
13 changes: 11 additions & 2 deletions bin/millau/runtime/src/rialto_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ parameter_types! {
pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE;
/// Lane used by the with-Rialto bridge.
pub RialtoSenderAndLane: SenderAndLane = SenderAndLane::new(Here.into(), XCM_LANE);

/// Dummy message used in configuration.
pub DummyXcmMessage: Xcm<()> = Xcm::new();
}

/// Message payload for Millau -> Rialto messages.
Expand Down Expand Up @@ -126,10 +129,16 @@ pub type ToRialtoBlobExporter = HaulBlobExporter<
pub struct ToRialtoXcmBlobHauler;

impl XcmBlobHauler for ToRialtoXcmBlobHauler {
type MessageSender = pallet_bridge_messages::Pallet<Runtime, WithRialtoMessagesInstance>;
type MessageSenderOrigin = RuntimeOrigin;
type Runtime = Runtime;
type MessagesInstance = WithRialtoMessagesInstance;
type SenderAndLane = RialtoSenderAndLane;

type ToSendingChainSender = crate::xcm_config::XcmRouter;
type CongestedMessage = DummyXcmMessage;
type UncongestedMessage = DummyXcmMessage;

type MessageSenderOrigin = RuntimeOrigin;

fn message_sender_origin() -> RuntimeOrigin {
pallet_xcm::Origin::from(MultiLocation::new(1, crate::xcm_config::UniversalLocation::get()))
.into()
Expand Down
14 changes: 11 additions & 3 deletions bin/millau/runtime/src/rialto_parachain_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ parameter_types! {
pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE;
/// Lane used by the with-RialtoParachain bridge.
pub RialtoParachainSenderAndLane: SenderAndLane = SenderAndLane::new(Here.into(), XCM_LANE);

/// Dummy message used in configuration.
pub DummyXcmMessage: Xcm<()> = Xcm::new();
}

/// Message payload for Millau -> RialtoParachain messages.
Expand Down Expand Up @@ -126,11 +129,16 @@ pub type ToRialtoParachainBlobExporter = HaulBlobExporter<
pub struct ToRialtoParachainXcmBlobHauler;

impl XcmBlobHauler for ToRialtoParachainXcmBlobHauler {
type MessageSender =
pallet_bridge_messages::Pallet<Runtime, WithRialtoParachainMessagesInstance>;
type MessageSenderOrigin = RuntimeOrigin;
type Runtime = Runtime;
type MessagesInstance = WithRialtoParachainMessagesInstance;
type SenderAndLane = RialtoParachainSenderAndLane;

type ToSendingChainSender = crate::xcm_config::XcmRouter;
type CongestedMessage = DummyXcmMessage;
type UncongestedMessage = DummyXcmMessage;

type MessageSenderOrigin = RuntimeOrigin;

fn message_sender_origin() -> RuntimeOrigin {
pallet_xcm::Origin::from(MultiLocation::new(1, crate::xcm_config::UniversalLocation::get()))
.into()
Expand Down
21 changes: 18 additions & 3 deletions bin/millau/runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ parameter_types! {
}

/// The XCM router. We are not sending messages to sibling/parent/child chains here.
pub type XcmRouter = ();
pub type XcmRouter = EmulatedSiblingXcmpChannel;

/// The barriers one of which must be passed for an XCM message to be executed.
pub type Barrier = (
Expand Down Expand Up @@ -241,6 +241,21 @@ impl ExportXcm for ToRialtoOrRialtoParachainSwitchExporter {
/// so we have to provide at least something to be able to run benchmarks.
pub struct EmulatedSiblingXcmpChannel;

impl SendXcm for EmulatedSiblingXcmpChannel {
type Ticket = ();

fn validate(
_destination: &mut Option<MultiLocation>,
_message: &mut Option<Xcm<()>>,
) -> SendResult<Self::Ticket> {
Ok(((), Default::default()))
}

fn deliver(_ticket: Self::Ticket) -> Result<XcmHash, SendError> {
Ok(XcmHash::default())
}
}

impl EmulatedSiblingXcmpChannel {
/// Start emulating congested channel.
pub fn make_congested() {
Expand Down Expand Up @@ -376,7 +391,7 @@ mod tests {
let dispatch_result = FromRialtoMessageDispatch::dispatch(incoming_message);
assert!(matches!(
dispatch_result.dispatch_level_result,
XcmBlobMessageDispatchResult::NotDispatched(_),
XcmBlobMessageDispatchResult::Dispatched,
));
}

Expand All @@ -389,7 +404,7 @@ mod tests {
let dispatch_result = FromRialtoMessageDispatch::dispatch(incoming_message);
assert!(matches!(
dispatch_result.dispatch_level_result,
XcmBlobMessageDispatchResult::NotDispatched(_),
XcmBlobMessageDispatchResult::Dispatched,
));
}
}
1 change: 1 addition & 0 deletions bin/rialto-parachain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
WithMillauMessagesInstance,
frame_support::traits::ConstU128<100_000>,
>;
type OnMessagesDelivered = ();

type SourceHeaderChain = crate::millau_messages::MillauAsSourceHeaderChain;
type MessageDispatch = crate::millau_messages::FromMillauMessageDispatch;
Expand Down
13 changes: 11 additions & 2 deletions bin/rialto-parachain/runtime/src/millau_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ parameter_types! {
pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE;
/// Lane used by the with-Millau bridge.
pub MullauSenderAndLane: SenderAndLane = SenderAndLane::new(Here.into(), XCM_LANE);

/// Dummy message used in configuration.
pub DummyXcmMessage: Xcm<()> = Xcm::new();
}

/// Message payload for RialtoParachain -> Millau messages.
Expand Down Expand Up @@ -126,10 +129,16 @@ pub type ToMillauBlobExporter =
pub struct ToMillauXcmBlobHauler;

impl XcmBlobHauler for ToMillauXcmBlobHauler {
type MessageSender = pallet_bridge_messages::Pallet<Runtime, WithMillauMessagesInstance>;
type MessageSenderOrigin = RuntimeOrigin;
type Runtime = Runtime;
type MessagesInstance = WithMillauMessagesInstance;
type SenderAndLane = MullauSenderAndLane;

type ToSendingChainSender = crate::XcmRouter;
type CongestedMessage = DummyXcmMessage;
type UncongestedMessage = DummyXcmMessage;

type MessageSenderOrigin = RuntimeOrigin;

fn message_sender_origin() -> RuntimeOrigin {
pallet_xcm::Origin::from(MultiLocation::new(1, crate::UniversalLocation::get())).into()
}
Expand Down
1 change: 1 addition & 0 deletions bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
WithMillauMessagesInstance,
frame_support::traits::ConstU128<100_000>,
>;
type OnMessagesDelivered = ();

type SourceHeaderChain = crate::millau_messages::MillauAsSourceHeaderChain;
type MessageDispatch = crate::millau_messages::FromMillauMessageDispatch;
Expand Down
13 changes: 11 additions & 2 deletions bin/rialto/runtime/src/millau_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ parameter_types! {
pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE;
/// Lane used by the with-Millau bridge.
pub MullauSenderAndLane: SenderAndLane = SenderAndLane::new(Here.into(), XCM_LANE);

/// Dummy message used in configuration.
pub DummyXcmMessage: Xcm<()> = Xcm::new();
}

/// Message payload for Rialto -> Millau messages.
Expand Down Expand Up @@ -125,10 +128,16 @@ pub type ToMillauBlobExporter = HaulBlobExporter<
pub struct ToMillauXcmBlobHauler;

impl XcmBlobHauler for ToMillauXcmBlobHauler {
type MessageSender = pallet_bridge_messages::Pallet<Runtime, WithMillauMessagesInstance>;
type MessageSenderOrigin = RuntimeOrigin;
type Runtime = Runtime;
type MessagesInstance = WithMillauMessagesInstance;
type SenderAndLane = MullauSenderAndLane;

type ToSendingChainSender = crate::xcm_config::XcmRouter;
type CongestedMessage = DummyXcmMessage;
type UncongestedMessage = DummyXcmMessage;

type MessageSenderOrigin = RuntimeOrigin;
svyatonik marked this conversation as resolved.
Show resolved Hide resolved

fn message_sender_origin() -> RuntimeOrigin {
pallet_xcm::Origin::from(MultiLocation::new(1, crate::xcm_config::UniversalLocation::get()))
.into()
Expand Down
Loading