Skip to content

Commit

Permalink
BACKPORT-CONFLICT
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur authored and github-actions[bot] committed Dec 10, 2024
1 parent ed1932e commit 5cf5bcc
Show file tree
Hide file tree
Showing 25 changed files with 2,252 additions and 2 deletions.
62 changes: 62 additions & 0 deletions Cargo.lock

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

15 changes: 15 additions & 0 deletions bridges/chains/chain-asset-hub-rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,21 @@ workspace = true
[dependencies]
codec = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
<<<<<<< HEAD
frame-support.workspace = true
bp-xcm-bridge-hub-router.workspace = true
=======

# Substrate Dependencies
frame-support = { workspace = true }
sp-core = { workspace = true }

# Bridge Dependencies
bp-xcm-bridge-hub-router = { workspace = true }
>>>>>>> 8f4b99c (Bridges - revert-back congestion mechanism (#6781))

# Polkadot dependencies
xcm = { workspace = true }

[features]
default = ["std"]
Expand All @@ -23,4 +36,6 @@ std = [
"codec/std",
"frame-support/std",
"scale-info/std",
"sp-core/std",
"xcm/std",
]
25 changes: 25 additions & 0 deletions bridges/chains/chain-asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

use codec::{Decode, Encode};
use scale_info::TypeInfo;

pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall;
use xcm::latest::prelude::*;

/// `AssetHubRococo` Runtime `Call` enum.
///
Expand All @@ -44,5 +47,27 @@ frame_support::parameter_types! {
pub const XcmBridgeHubRouterTransactCallMaxWeight: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(200_000_000, 6144);
}

/// Builds an (un)congestion XCM program with the `report_bridge_status` call for
/// `ToWestendXcmRouter`.
pub fn build_congestion_message<RuntimeCall>(
bridge_id: sp_core::H256,
is_congested: bool,
) -> alloc::vec::Vec<Instruction<RuntimeCall>> {
alloc::vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
Transact {
origin_kind: OriginKind::Xcm,
fallback_max_weight: Some(XcmBridgeHubRouterTransactCallMaxWeight::get()),
call: Call::ToWestendXcmRouter(XcmBridgeHubRouterCall::report_bridge_status {
bridge_id,
is_congested,
})
.encode()
.into(),
},
ExpectTransactStatus(MaybeErrorCode::Success),
]
}

/// Identifier of AssetHubRococo in the Rococo relay chain.
pub const ASSET_HUB_ROCOCO_PARACHAIN_ID: u32 = 1000;
15 changes: 15 additions & 0 deletions bridges/chains/chain-asset-hub-westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,21 @@ workspace = true
[dependencies]
codec = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
<<<<<<< HEAD
frame-support.workspace = true
bp-xcm-bridge-hub-router.workspace = true
=======

# Substrate Dependencies
frame-support = { workspace = true }
sp-core = { workspace = true }

# Bridge Dependencies
bp-xcm-bridge-hub-router = { workspace = true }
>>>>>>> 8f4b99c (Bridges - revert-back congestion mechanism (#6781))

# Polkadot dependencies
xcm = { workspace = true }

[features]
default = ["std"]
Expand All @@ -23,4 +36,6 @@ std = [
"codec/std",
"frame-support/std",
"scale-info/std",
"sp-core/std",
"xcm/std",
]
25 changes: 25 additions & 0 deletions bridges/chains/chain-asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

use codec::{Decode, Encode};
use scale_info::TypeInfo;

pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall;
use xcm::latest::prelude::*;

/// `AssetHubWestend` Runtime `Call` enum.
///
Expand All @@ -44,5 +47,27 @@ frame_support::parameter_types! {
pub const XcmBridgeHubRouterTransactCallMaxWeight: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(200_000_000, 6144);
}

/// Builds an (un)congestion XCM program with the `report_bridge_status` call for
/// `ToRococoXcmRouter`.
pub fn build_congestion_message<RuntimeCall>(
bridge_id: sp_core::H256,
is_congested: bool,
) -> alloc::vec::Vec<Instruction<RuntimeCall>> {
alloc::vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
Transact {
origin_kind: OriginKind::Xcm,
fallback_max_weight: Some(XcmBridgeHubRouterTransactCallMaxWeight::get()),
call: Call::ToRococoXcmRouter(XcmBridgeHubRouterCall::report_bridge_status {
bridge_id,
is_congested,
})
.encode()
.into(),
},
ExpectTransactStatus(MaybeErrorCode::Success),
]
}

/// Identifier of AssetHubWestend in the Westend relay chain.
pub const ASSET_HUB_WESTEND_PARACHAIN_ID: u32 = 1000;
10 changes: 10 additions & 0 deletions bridges/modules/xcm-bridge-hub-router/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
#![cfg(feature = "runtime-benchmarks")]

<<<<<<< HEAD
use crate::{Bridge, Call};

use bp_xcm_bridge_hub_router::{BridgeState, MINIMAL_DELIVERY_FEE_FACTOR};
=======
use crate::{Bridge, BridgeState, Call, MINIMAL_DELIVERY_FEE_FACTOR};
>>>>>>> 8f4b99c (Bridges - revert-back congestion mechanism (#6781))
use frame_benchmarking::{benchmarks_instance_pallet, BenchmarkError};
use frame_support::traits::{EnsureOrigin, Get, Hooks, UnfilteredDispatchable};
use sp_runtime::traits::Zero;
Expand Down Expand Up @@ -60,7 +64,10 @@ benchmarks_instance_pallet! {
is_congested: false,
delivery_fee_factor: MINIMAL_DELIVERY_FEE_FACTOR + MINIMAL_DELIVERY_FEE_FACTOR,
});
<<<<<<< HEAD

=======
>>>>>>> 8f4b99c (Bridges - revert-back congestion mechanism (#6781))
let _ = T::ensure_bridged_target_destination()?;
T::make_congested();
}: {
Expand All @@ -79,6 +86,7 @@ benchmarks_instance_pallet! {
verify {
assert!(Bridge::<T, I>::get().is_congested);
}
<<<<<<< HEAD

send_message {
let dest = T::ensure_bridged_target_destination()?;
Expand All @@ -92,4 +100,6 @@ benchmarks_instance_pallet! {
verify {
assert!(Bridge::<T, I>::get().delivery_fee_factor > MINIMAL_DELIVERY_FEE_FACTOR);
}
=======
>>>>>>> 8f4b99c (Bridges - revert-back congestion mechanism (#6781))
}
Loading

0 comments on commit 5cf5bcc

Please sign in to comment.