Skip to content

Commit

Permalink
Implement additional require primitives for dynamic fees directly for…
Browse files Browse the repository at this point in the history
… pallet-xcm-bridge-hub (#2261)

Xcm bridge hub router v2 (backport to master branch) (#2312)

* copy new pallet (palle-xcm-bridge-hub-router) from dynamic-fees-v1 branch

* added remaining traces of pallet-xcm-bridge-hub-router

* added comment about sharing delivery fee factor between all bridges, opened by this chain

* spelling

* clippy

Implement additional require primitives for dynamic fees directly for pallet-xcm-bridge-hub (#2261)

* added backoff mechanism to inbound bridge queue

* impl backpressure in the XcmBlobHaulerAdapter

* leave TODOs

* BridgeMessageProcessor prototype

* another TODO

* Revert "also temporary (?) remove BridgesByLocalOrigin because the storage format will likely change to be able to resume bridges from the on_iniitalize/on_idle"

This reverts commit bdd7ae11a8942b58c5db6ac6d4e7922aa28cece4.

* prototype for QueuePausedQuery

* implement ExportXcm and MessageDispatch for pallet-xcm-bridge-hub

* spelling

* flush

* small comments to myself

* more backports from dynamic-fees-v1

* use new pallet as exporter and dispatcher in Millau

* use new pallet as exporter and dispatcher in Rialto

* use new pallet as exporter and dispatcher in RialtoParachain

* flush

* fix remaining compilation issues

* warnings + fmt

* fix tests

* LocalXcmChannelManager

* change lane ids

* it works!

* remove bp-xcm-bridge-hub-router and use LocalXcmChannelManager everywhere

* removed commented code

* cleaning up

* cleaning up

* cleaning up

* - separated BridgeId and LaneId
- BridgeId now uses versioned universal locations
- added missing stuff to exporter.rs

* OnMessagesDelivered is back

* start using bp-xcm-bridge-hub as OnMessagesDelivered

* cleaning up

* spelling

* fix stupid issues

* Backport latest relevant dynamic fees changes from v1 to v2 (#2372)

* backport latest relevant dynamic fees changes from v1 to v2

* fix comment

Added remaining unit tests for pallet-xcm-bridge-hub (#2499)

* added backoff mechanism to inbound bridge queue

* impl backpressure in the XcmBlobHaulerAdapter

* leave TODOs

* BridgeMessageProcessor prototype

* another TODO

* Revert "also temporary (?) remove BridgesByLocalOrigin because the storage format will likely change to be able to resume bridges from the on_iniitalize/on_idle"

This reverts commit bdd7ae11a8942b58c5db6ac6d4e7922aa28cece4.

* prototype for QueuePausedQuery

* implement ExportXcm and MessageDispatch for pallet-xcm-bridge-hub

* spelling

* flush

* small comments to myself

* more backports from dynamic-fees-v1

* use new pallet as exporter and dispatcher in Millau

* use new pallet as exporter and dispatcher in Rialto

* use new pallet as exporter and dispatcher in RialtoParachain

* flush

* fix remaining compilation issues

* warnings + fmt

* fix tests

* LocalXcmChannelManager

* change lane ids

* it works!

* remove bp-xcm-bridge-hub-router and use LocalXcmChannelManager everywhere

* removed commented code

* cleaning up

* cleaning up

* cleaning up

* - separated BridgeId and LaneId
- BridgeId now uses versioned universal locations
- added missing stuff to exporter.rs

* OnMessagesDelivered is back

* start using bp-xcm-bridge-hub as OnMessagesDelivered

* cleaning up

* spelling

* fix stupid issues

* added remaining unit tests for pallet-xcm-bridge-hub

fixed benchmarks (#2504)

Remove pallet_xcm_bridge_hub::SuspendedBridges (#2505)

* remove pallet_xcm_bridge_hub::SuspendedBridges

* apply review suggestions
  • Loading branch information
svyatonik authored and bkontur committed Jun 4, 2024
1 parent fccc809 commit 53eab88
Show file tree
Hide file tree
Showing 23 changed files with 1,141 additions and 1,077 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 @@ -19,11 +19,8 @@
//! with calls that are: delivering new message and all necessary underlying headers
//! (parachain or relay chain).

use crate::{
messages_call_ext::{
CallHelper as MessagesCallHelper, CallInfo as MessagesCallInfo, MessagesCallSubType,
},
messages_xcm_extension::LaneIdFromChainId,
use crate::messages_call_ext::{
CallHelper as MessagesCallHelper, CallInfo as MessagesCallInfo, MessagesCallSubType,
};
use bp_messages::{ChainWithMessages, LaneId, MessageNonce};
use bp_relayers::{ExplicitOrAccountParams, RewardsAccountOwner, RewardsAccountParams};
Expand Down Expand Up @@ -95,15 +92,17 @@ pub trait RefundableMessagesLaneId {
}

/// Default implementation of `RefundableMessagesLaneId`.
pub struct RefundableMessagesLane<Runtime, Instance>(PhantomData<(Runtime, Instance)>);
pub struct RefundableMessagesLane<Runtime, Instance, Lane>(PhantomData<(Runtime, Instance, Lane)>);

impl<Runtime, Instance> RefundableMessagesLaneId for RefundableMessagesLane<Runtime, Instance>
impl<Runtime, Instance, Lane> RefundableMessagesLaneId
for RefundableMessagesLane<Runtime, Instance, Lane>
where
Runtime: MessagesConfig<Instance>,
Instance: 'static,
Lane: Get<LaneId>,
{
type Instance = Instance;
type Id = LaneIdFromChainId<Runtime, Instance>;
type Id = Lane;
}

/// Refund calculator.
Expand Down Expand Up @@ -982,13 +981,14 @@ pub(crate) mod tests {
TEST_BRIDGED_CHAIN_ID,
RewardsAccountOwner::BridgedChain,
);
pub TestLaneId: LaneId = test_lane_id();
}

bp_runtime::generate_static_str_provider!(TestExtension);

type TestMessagesExtensionProvider = RefundBridgedMessages<
TestRuntime,
RefundableMessagesLane<TestRuntime, ()>,
RefundableMessagesLane<TestRuntime, (), TestLaneId>,
ActualFeeRefund<TestRuntime>,
ConstU64<1>,
StrTestExtension,
Expand All @@ -997,7 +997,7 @@ pub(crate) mod tests {
type TestGrandpaExtensionProvider = RefundBridgedGrandpaMessages<
TestRuntime,
(),
RefundableMessagesLane<TestRuntime, ()>,
RefundableMessagesLane<TestRuntime, (), TestLaneId>,
ActualFeeRefund<TestRuntime>,
ConstU64<1>,
StrTestExtension,
Expand All @@ -1006,7 +1006,7 @@ pub(crate) mod tests {
type TestExtensionProvider = RefundBridgedParachainMessages<
TestRuntime,
RefundableParachain<(), BridgedUnderlyingParachain>,
RefundableMessagesLane<TestRuntime, ()>,
RefundableMessagesLane<TestRuntime, (), TestLaneId>,
ActualFeeRefund<TestRuntime>,
ConstU64<1>,
StrTestExtension,
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/runtime-common/src/integrity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ macro_rules! assert_bridge_messages_pallet_types(
// if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard
// configuration is used), or something has broke existing configuration (meaning that all bridged chains
// and relays will stop functioning)
use $crate::messages_xcm_extension::XcmAsPlainPayload;
use bp_messages::ChainWithMessages;
use bp_runtime::Chain;
use bp_xcm_bridge_hub::XcmAsPlainPayload;
use pallet_bridge_messages::Config as MessagesConfig;
use static_assertions::assert_type_eq_all;

Expand Down
3 changes: 0 additions & 3 deletions bridges/bin/runtime-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ pub mod extensions;
pub mod messages_api;
pub mod messages_benchmarking;
pub mod messages_call_ext;
pub mod messages_xcm_extension;
pub mod parachains_benchmarking;

mod mock;

#[cfg(feature = "integrity-test")]
pub mod integrity;

const LOG_TARGET_BRIDGE_DISPATCH: &str = "runtime::bridge-dispatch";
7 changes: 4 additions & 3 deletions bridges/bin/runtime-common/src/messages_call_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ impl<
return sp_runtime::transaction_validity::InvalidTransaction::Call.into()
},
Some(CallInfo::ReceiveMessagesProof(proof_info))
if proof_info.is_obsolete(T::MessageDispatch::is_active()) =>
if proof_info
.is_obsolete(T::MessageDispatch::is_active(proof_info.base.lane_id)) =>
{
log::trace!(
target: pallet_bridge_messages::LOG_TARGET,
Expand Down Expand Up @@ -486,12 +487,12 @@ mod tests {

#[test]
fn extension_reject_call_when_dispatcher_is_inactive() {
sp_io::TestExternalities::new(Default::default()).execute_with(|| {
run_test(|| {
// when current best delivered is message#10 and we're trying to deliver message 11..=15
// => tx is accepted, but we have inactive dispatcher, so...
deliver_message_10();

DummyMessageDispatch::deactivate();
DummyMessageDispatch::deactivate(test_lane_id());
assert!(!validate_message_delivery(11, 15));
});
}
Expand Down
Loading

0 comments on commit 53eab88

Please sign in to comment.