mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 16:21:02 +00:00
[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:
committed by
GitHub
parent
15a3483881
commit
0d3c67d96b
@@ -23,7 +23,7 @@ use bridge_hub_westend_runtime::{
|
||||
xcm_config::{RelayNetwork, WestendLocation, XcmConfig},
|
||||
AllPalletsWithoutSystem, BridgeRejectObsoleteHeadersAndMessages, Executive, ExistentialDeposit,
|
||||
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, SessionKeys, SignedExtra,
|
||||
UncheckedExtrinsic,
|
||||
TransactionPayment, UncheckedExtrinsic,
|
||||
};
|
||||
use bridge_to_rococo_config::{
|
||||
BridgeGrandpaRococoInstance, BridgeHubRococoChainId, BridgeParachainRococoInstance,
|
||||
@@ -31,7 +31,7 @@ use bridge_to_rococo_config::{
|
||||
XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO,
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::parameter_types;
|
||||
use frame_support::{dispatch::GetDispatchInfo, parameter_types};
|
||||
use frame_system::pallet_prelude::HeaderFor;
|
||||
use parachains_common::{westend::fee::WeightToFee, AccountId, AuraId, Balance};
|
||||
use sp_keyring::AccountKeyring::Alice;
|
||||
@@ -84,6 +84,13 @@ fn construct_and_apply_extrinsic(
|
||||
r.unwrap()
|
||||
}
|
||||
|
||||
fn construct_and_estimate_extrinsic_fee(batch: pallet_utility::Call<Runtime>) -> Balance {
|
||||
let batch_call = RuntimeCall::Utility(batch);
|
||||
let batch_info = batch_call.get_dispatch_info();
|
||||
let xt = construct_extrinsic(Alice, batch_call);
|
||||
TransactionPayment::compute_fee(xt.encoded_size() as _, &batch_info, 0)
|
||||
}
|
||||
|
||||
fn executive_init_block(header: &HeaderFor<Runtime>) {
|
||||
Executive::initialize_block(header)
|
||||
}
|
||||
@@ -182,7 +189,7 @@ fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() {
|
||||
XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO,
|
||||
Some((WestendLocation::get(), ExistentialDeposit::get()).into()),
|
||||
// value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer`
|
||||
Some((WestendLocation::get(), bp_asset_hub_westend::BridgeHubWestendBaseFeeInWnds::get()).into()),
|
||||
Some((WestendLocation::get(), bp_bridge_hub_westend::BridgeHubWestendBaseXcmFeeInWnds::get()).into()),
|
||||
|| (),
|
||||
)
|
||||
}
|
||||
@@ -275,11 +282,57 @@ pub fn can_calculate_weight_for_paid_export_message_with_reserve_transfer() {
|
||||
>();
|
||||
|
||||
// check if estimated value is sane
|
||||
let max_expected = bp_asset_hub_westend::BridgeHubWestendBaseFeeInWnds::get();
|
||||
let max_expected = bp_bridge_hub_westend::BridgeHubWestendBaseXcmFeeInWnds::get();
|
||||
assert!(
|
||||
estimated <= max_expected,
|
||||
"calculated: {:?}, max_expected: {:?}, please adjust `bp_asset_hub_westend::BridgeHubWestendBaseFeeInWnds` value",
|
||||
"calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_westend::BridgeHubWestendBaseXcmFeeInWnds` value",
|
||||
estimated,
|
||||
max_expected
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn can_calculate_fee_for_complex_message_delivery_transaction() {
|
||||
let estimated = bridge_hub_test_utils::test_cases::can_calculate_fee_for_complex_message_delivery_transaction::<
|
||||
Runtime,
|
||||
BridgeGrandpaRococoInstance,
|
||||
BridgeParachainRococoInstance,
|
||||
WithBridgeHubRococoMessagesInstance,
|
||||
WithBridgeHubRococoMessageBridge,
|
||||
>(
|
||||
collator_session_keys(),
|
||||
construct_and_estimate_extrinsic_fee
|
||||
);
|
||||
|
||||
// check if estimated value is sane
|
||||
let max_expected = bp_bridge_hub_westend::BridgeHubWestendBaseDeliveryFeeInWnds::get();
|
||||
assert!(
|
||||
estimated <= max_expected,
|
||||
"calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_westend::BridgeHubWestendBaseDeliveryFeeInWnds` value",
|
||||
estimated,
|
||||
max_expected
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn can_calculate_fee_for_complex_message_confirmation_transaction() {
|
||||
let estimated = bridge_hub_test_utils::test_cases::can_calculate_fee_for_complex_message_confirmation_transaction::<
|
||||
Runtime,
|
||||
BridgeGrandpaRococoInstance,
|
||||
BridgeParachainRococoInstance,
|
||||
WithBridgeHubRococoMessagesInstance,
|
||||
WithBridgeHubRococoMessageBridge,
|
||||
>(
|
||||
collator_session_keys(),
|
||||
construct_and_estimate_extrinsic_fee
|
||||
);
|
||||
|
||||
// check if estimated value is sane
|
||||
let max_expected = bp_bridge_hub_westend::BridgeHubWestendBaseConfirmationFeeInWnds::get();
|
||||
assert!(
|
||||
estimated <= max_expected,
|
||||
"calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_westend::BridgeHubWestendBaseConfirmationFeeInWnds` value",
|
||||
estimated,
|
||||
max_expected
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user