[testnet] Allow governance to control fees for Rococo <> Westend bridge (#2139)

Right now governance could only control byte-fee component of Rococo <>
Westend message fees (paid at Asset Hubs). This PR changes it a bit:
1) governance now allowed to control both fee components - byte fee and
base fee;
2) base fee now includes cost of "default" delivery and confirmation
transactions, in addition to `ExportMessage` instruction cost.
This commit is contained in:
Svyatoslav Nikolsky
2023-11-03 11:32:41 +03:00
committed by GitHub
parent 15a3483881
commit 0d3c67d96b
16 changed files with 803 additions and 133 deletions
@@ -88,6 +88,7 @@ bp-asset-hub-westend = { path = "../../../../../bridges/primitives/chain-asset-h
bp-asset-hub-wococo = { path = "../../../../../bridges/primitives/chain-asset-hub-wococo", default-features = false }
bp-bridge-hub-rococo = { path = "../../../../../bridges/primitives/chain-bridge-hub-rococo", default-features = false }
bp-bridge-hub-wococo = { path = "../../../../../bridges/primitives/chain-bridge-hub-wococo", default-features = false }
bp-bridge-hub-westend = { path = "../../../../../bridges/primitives/chain-bridge-hub-westend", default-features = false }
[dev-dependencies]
asset-test-utils = { path = "../test-utils" }
@@ -177,6 +178,7 @@ std = [
"bp-asset-hub-wococo/std",
"bp-bridge-hub-rococo/std",
"bp-bridge-hub-wococo/std",
"bp-bridge-hub-westend/std",
"codec/std",
"cumulus-pallet-aura-ext/std",
"cumulus-pallet-dmp-queue/std",
@@ -283,6 +283,9 @@ impl Contains<RuntimeCall> for SafeCallFilter {
match call {
RuntimeCall::System(frame_system::Call::set_storage { items })
if items.iter().all(|(k, _)| k.eq(&bridging::XcmBridgeHubRouterByteFee::key())) ||
items
.iter()
.all(|(k, _)| k.eq(&bridging::XcmBridgeHubRouterBaseFee::key())) ||
items.iter().all(|(k, _)| k.eq(&Flavor::key())) =>
return true,
_ => (),
@@ -760,6 +763,25 @@ pub mod bridging {
// common/shared parameters for Wococo/Rococo
parameter_types! {
/// Base price of every byte of the Rococo -> Westend message. Can be adjusted via
/// governance `set_storage` call.
///
/// Default value is our estimation of the:
///
/// 1) an approximate cost of XCM execution (`ExportMessage` and surroundings) at Rococo bridge hub;
///
/// 2) the approximate cost of Rococo -> Westend message delivery transaction on Westend Bridge Hub,
/// converted into ROCs using 1:1 conversion rate;
///
/// 3) the approximate cost of Rococo -> Westend message confirmation transaction on Rococo Bridge Hub.
pub storage XcmBridgeHubRouterBaseFee: Balance =
bp_bridge_hub_rococo::BridgeHubRococoBaseXcmFeeInRocs::get()
.saturating_add(bp_bridge_hub_westend::BridgeHubWestendBaseDeliveryFeeInWnds::get())
.saturating_add(bp_bridge_hub_rococo::BridgeHubRococoBaseConfirmationFeeInRocs::get());
/// Price of every byte of the Rococo -> Westend message. Can be adjusted via
/// governance `set_storage` call.
pub storage XcmBridgeHubRouterByteFee: Balance = TransactionByteFee::get();
pub SiblingBridgeHubParaId: u32 = match Flavor::get() {
RuntimeFlavor::Rococo => bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
RuntimeFlavor::Wococo => bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID,
@@ -768,8 +790,6 @@ pub mod bridging {
/// Router expects payment with this `AssetId`.
/// (`AssetId` has to be aligned with `BridgeTable`)
pub XcmBridgeHubRouterFeeAssetId: AssetId = TokenLocation::get().into();
/// Price per byte - can be adjusted via governance `set_storage` call.
pub storage XcmBridgeHubRouterByteFee: Balance = TransactionByteFee::get();
pub BridgeTable: sp_std::vec::Vec<NetworkExportTableItem> =
sp_std::vec::Vec::new().into_iter()
@@ -814,7 +834,7 @@ pub mod bridging {
// base delivery fee to local `BridgeHub`
Some((
XcmBridgeHubRouterFeeAssetId::get(),
bp_asset_hub_rococo::BridgeHubRococoBaseFeeInRocs::get(),
XcmBridgeHubRouterBaseFee::get(),
).into())
)
];
@@ -890,7 +910,7 @@ pub mod bridging {
// base delivery fee to local `BridgeHub`
Some((
XcmBridgeHubRouterFeeAssetId::get(),
bp_asset_hub_rococo::BridgeHubRococoBaseFeeInRocs::get(),
XcmBridgeHubRouterBaseFee::get(),
).into())
)
];
@@ -966,7 +986,7 @@ pub mod bridging {
// base delivery fee to local `BridgeHub`
Some((
XcmBridgeHubRouterFeeAssetId::get(),
bp_asset_hub_wococo::BridgeHubWococoBaseFeeInWocs::get(),
XcmBridgeHubRouterBaseFee::get(),
).into())
)
];