Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Make base fee configurable from storage #68

Merged
merged 3 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,14 @@ impl Contains<RuntimeCall> for SafeCallFilter {
// Allow to change dedicated storage items (called by governance-like)
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())) =>
return true,
if items.iter().all(|(k, _)| {
k.eq(&bridging::XcmBridgeHubRouterByteFee::key()) |
k.eq(&bridging::XcmBridgeHubRouterBaseFee::key()) |
k.eq(&bridging::to_ethereum::BridgeHubEthereumBaseFee::key())
}) =>
{
return true
},
_ => (),
};

Expand Down Expand Up @@ -857,7 +860,8 @@ pub mod bridging {
/// (initially was calculated by test `OutboundQueue::calculate_fees` - ETH/ROC 1/400 and fee_per_gas 20 GWEI = 2200698000000 + *25%)
/// Needs to be more than fee calculated from DefaultFeeConfig FeeConfigRecord in snowbridge:parachain/pallets/outbound-queue/src/lib.rs
/// Polkadot uses 10 decimals, Kusama and Rococo 12 decimals.
pub const BridgeHubEthereumBaseFeeInROC: u128 = 2_750_872_500_000;
pub const DefaultBridgeHubEthereumBaseFee: u128 = 2_750_872_500_000;
pub storage BridgeHubEthereumBaseFee: u128 = DefaultBridgeHubEthereumBaseFee::get();
pub SiblingBridgeHubWithEthereumInboundQueueInstance: MultiLocation = MultiLocation::new(
1,
X2(
Expand All @@ -877,7 +881,7 @@ pub mod bridging {
SiblingBridgeHub::get(),
Some((
XcmBridgeHubRouterFeeAssetId::get(),
BridgeHubEthereumBaseFeeInROC::get(),
BridgeHubEthereumBaseFee::get(),
).into())
),
];
Expand Down
52 changes: 52 additions & 0 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,3 +865,55 @@ fn change_xcm_bridge_hub_router_byte_fee_by_governance_works() {
},
)
}

#[test]
fn change_xcm_bridge_hub_router_base_fee_by_governance_works() {
asset_test_utils::test_cases::change_storage_constant_by_governance_works::<
Runtime,
bridging::XcmBridgeHubRouterBaseFee,
Balance,
>(
collator_session_keys(),
1000,
Box::new(|call| RuntimeCall::System(call).encode()),
|| {
(
bridging::XcmBridgeHubRouterBaseFee::key().to_vec(),
bridging::XcmBridgeHubRouterBaseFee::get(),
)
},
|old_value| {
if let Some(new_value) = old_value.checked_add(1) {
new_value
} else {
old_value.checked_sub(1).unwrap()
}
},
)
}

#[test]
fn change_xcm_bridge_hub_ethereum_base_fee_by_governance_works() {
asset_test_utils::test_cases::change_storage_constant_by_governance_works::<
Runtime,
bridging::to_ethereum::BridgeHubEthereumBaseFee,
Balance,
>(
collator_session_keys(),
1000,
Box::new(|call| RuntimeCall::System(call).encode()),
|| {
(
bridging::to_ethereum::BridgeHubEthereumBaseFee::key().to_vec(),
bridging::to_ethereum::BridgeHubEthereumBaseFee::get(),
)
},
|old_value| {
if let Some(new_value) = old_value.checked_add(1) {
new_value
} else {
old_value.checked_sub(1).unwrap()
}
},
)
}
Loading