From 55e97c5679f3c1a58aba5ca79e6fcc53bab7d3d6 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Mon, 4 Mar 2024 10:48:59 +0300 Subject: [PATCH] Fix default bridge byte fee to use TransactionByteFee of the bridged chain (#174) This PR does two things: 1) (tiny refactoring) adds `TRANSACTION_BYTE_FEE` constant to `system-parachains-constants` crate. We are using the same value (`1 * MILLICENTS`) across all chains, so it makes sense to move it there; 2) changes default value of governance-controlled `XcmBridgeHubRouterByteFee` constant (which is used to cover the cost of message delivery within the remote consensus) to use `TRANSACTION_BYTE_FEE` of the bridged chain (also does 1:5/5:1 conversion). Since governance has not set value of this constant yet, we are changing the default value here, in the code. ~The failing test is fixed by the #137, so it makes sense to merge this PR only after #137~ Updated --------- Co-authored-by: Branislav Kontur Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ Cargo.lock | 2 ++ relay/kusama/constants/src/lib.rs | 3 +++ relay/kusama/src/lib.rs | 2 +- relay/polkadot/constants/src/lib.rs | 3 +++ relay/polkadot/src/lib.rs | 2 +- .../asset-hubs/asset-hub-kusama/src/lib.rs | 9 ++++++++- .../asset-hub-kusama/src/xcm_config.rs | 6 +++--- .../asset-hubs/asset-hub-polkadot/src/lib.rs | 9 ++++++++- .../asset-hub-polkadot/src/xcm_config.rs | 6 +++--- .../bridge-hub-kusama/primitives/Cargo.toml | 6 ++++-- .../bridge-hub-kusama/primitives/src/lib.rs | 12 ++++++++++++ .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 14 +++++++++++++- .../bridge-hub-polkadot/primitives/Cargo.toml | 6 ++++-- .../bridge-hub-polkadot/primitives/src/lib.rs | 12 ++++++++++++ .../bridge-hubs/bridge-hub-polkadot/src/lib.rs | 14 +++++++++++++- .../collectives-polkadot/src/lib.rs | 9 ++++++++- system-parachains/constants/src/kusama.rs | 5 +++++ system-parachains/constants/src/polkadot.rs | 5 +++++ system-parachains/encointer/src/lib.rs | 18 +++++++++++++++++- 20 files changed, 129 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b85931cf27..c0485d37eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Removed the `SafeCallFilter` from the Relay Chain XCM config ([polkadot-fellows/runtimes#172](https://github.com/polkadot-fellows/runtimes/pull/172)). - Removed the `ImOnline` pallet ([polkadot-fellows/runtimes#178](https://github.com/polkadot-fellows/runtimes/pull/178)) +### Fixed + +- Fixed the cost of a single byte, sent over bridge to use the `TransactionByteFee` constant of the bridged chain [polkadot-fellows/runtimes#174](https://github.com/polkadot-fellows/runtimes/pull/174). + ### Based on Polkadot-SDK - Upgrade dependencies to the [polkadot-sdk@1.5.0](https://github.com/paritytech/polkadot-sdk/releases/tag/polkadot-v1.5.0) release ([polkadot-fellows/runtimes#137](https://github.com/polkadot-fellows/runtimes/pull/137)) diff --git a/Cargo.lock b/Cargo.lock index adda6b521d..d8377fd3b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1116,6 +1116,7 @@ dependencies = [ "sp-api", "sp-runtime", "sp-std", + "system-parachains-constants", ] [[package]] @@ -1131,6 +1132,7 @@ dependencies = [ "sp-api", "sp-runtime", "sp-std", + "system-parachains-constants", ] [[package]] diff --git a/relay/kusama/constants/src/lib.rs b/relay/kusama/constants/src/lib.rs index 68cad9c3b6..a5936fa21c 100644 --- a/relay/kusama/constants/src/lib.rs +++ b/relay/kusama/constants/src/lib.rs @@ -70,6 +70,9 @@ pub mod fee { /// The block saturation level. Fees will be updates based on this value. pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); + /// Cost of every transaction byte at Kusama relay chain. + pub const TRANSACTION_BYTE_FEE: Balance = 10 * super::currency::MILLICENTS; + /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the /// node's balance type. /// diff --git a/relay/kusama/src/lib.rs b/relay/kusama/src/lib.rs index 1a5e6ced2f..034f956abd 100644 --- a/relay/kusama/src/lib.rs +++ b/relay/kusama/src/lib.rs @@ -413,7 +413,7 @@ impl pallet_beefy_mmr::Config for Runtime { } parameter_types! { - pub const TransactionByteFee: Balance = 10 * MILLICENTS; + pub const TransactionByteFee: Balance = kusama_runtime_constants::fee::TRANSACTION_BYTE_FEE; /// This value increases the priority of `Operational` transactions by adding /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`. pub const OperationalFeeMultiplier: u8 = 5; diff --git a/relay/polkadot/constants/src/lib.rs b/relay/polkadot/constants/src/lib.rs index e2f413bbbd..f47d9e6a97 100644 --- a/relay/polkadot/constants/src/lib.rs +++ b/relay/polkadot/constants/src/lib.rs @@ -72,6 +72,9 @@ pub mod fee { /// The block saturation level. Fees will be updates based on this value. pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); + /// Cost of every transaction byte at Kusama relay chain. + pub const TRANSACTION_BYTE_FEE: Balance = 10 * super::currency::MILLICENTS; + /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the /// node's balance type. /// diff --git a/relay/polkadot/src/lib.rs b/relay/polkadot/src/lib.rs index 41ef405a89..182390ef31 100644 --- a/relay/polkadot/src/lib.rs +++ b/relay/polkadot/src/lib.rs @@ -400,7 +400,7 @@ impl pallet_beefy_mmr::Config for Runtime { } parameter_types! { - pub const TransactionByteFee: Balance = 10 * MILLICENTS; + pub const TransactionByteFee: Balance = polkadot_runtime_constants::fee::TRANSACTION_BYTE_FEE; /// This value increases the priority of `Operational` transactions by adding /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`. pub const OperationalFeeMultiplier: u8 = 5; diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs index c4b1dafa94..02e8e149ee 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs @@ -235,7 +235,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = MILLICENTS; + pub const TransactionByteFee: Balance = system_parachains_constants::kusama::fee::TRANSACTION_BYTE_FEE; } impl pallet_transaction_payment::Config for Runtime { @@ -1709,4 +1709,11 @@ mod tests { let time_o_proof = time_fee.checked_div(proof_fee).unwrap_or_default(); assert!(time_o_proof <= 30, "{} should be at most 30", time_o_proof); } + + #[test] + fn test_transasction_byte_fee_is_one_tenth_of_relay() { + let relay_tbf = kusama_runtime_constants::fee::TRANSACTION_BYTE_FEE; + let parachain_tbf = TransactionByteFee::get(); + assert_eq!(relay_tbf / 10, parachain_tbf); + } } diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs index 3820d5c793..15087c6978 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs @@ -16,8 +16,8 @@ use super::{ AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, PoolAssets, PriceForParentDelivery, Runtime, RuntimeCall, - RuntimeEvent, RuntimeOrigin, ToPolkadotXcmRouter, TransactionByteFee, - TrustBackedAssetsInstance, WeightToFee, XcmpQueue, + RuntimeEvent, RuntimeOrigin, ToPolkadotXcmRouter, TrustBackedAssetsInstance, WeightToFee, + XcmpQueue, }; use crate::{ForeignAssets, ForeignAssetsInstance}; use assets_common::matching::{FromSiblingParachain, IsForeignConcreteAsset}; @@ -660,7 +660,7 @@ pub mod bridging { ); /// Price of every byte of the Kusama -> Polkadot message. Can be adjusted via /// governance `set_storage` call. - pub storage XcmBridgeHubRouterByteFee: Balance = TransactionByteFee::get(); + pub storage XcmBridgeHubRouterByteFee: Balance = bp_bridge_hub_kusama::estimate_kusama_to_polkadot_byte_fee(); pub SiblingBridgeHubParaId: u32 = bp_bridge_hub_kusama::BRIDGE_HUB_KUSAMA_PARACHAIN_ID; pub SiblingBridgeHub: MultiLocation = MultiLocation::new(1, X1(Parachain(SiblingBridgeHubParaId::get()))); diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs index fe10cdb4c8..5164b307ae 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs @@ -248,7 +248,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = MILLICENTS; + pub const TransactionByteFee: Balance = system_parachains_constants::polkadot::fee::TRANSACTION_BYTE_FEE; } impl pallet_transaction_payment::Config for Runtime { @@ -1537,4 +1537,11 @@ mod tests { let time_o_proof = time_fee.checked_div(proof_fee).unwrap_or_default(); assert!(time_o_proof <= 30, "{} should be at most 30", time_o_proof); } + + #[test] + fn test_transasction_byte_fee_is_one_tenth_of_relay() { + let relay_tbf = polkadot_runtime_constants::fee::TRANSACTION_BYTE_FEE; + let parachain_tbf = TransactionByteFee::get(); + assert_eq!(relay_tbf / 10, parachain_tbf); + } } diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs index 6b50feb0d3..d7c113eebb 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs @@ -16,8 +16,8 @@ use super::{ AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, ForeignAssets, ParachainInfo, ParachainSystem, PolkadotXcm, PriceForParentDelivery, Runtime, RuntimeCall, - RuntimeEvent, RuntimeOrigin, ToKusamaXcmRouter, TransactionByteFee, TrustBackedAssetsInstance, - WeightToFee, XcmpQueue, + RuntimeEvent, RuntimeOrigin, ToKusamaXcmRouter, TrustBackedAssetsInstance, WeightToFee, + XcmpQueue, }; use crate::ForeignAssetsInstance; use assets_common::matching::{FromSiblingParachain, IsForeignConcreteAsset}; @@ -604,7 +604,7 @@ pub mod bridging { ); /// Price of every byte of the Polkadot -> Kusama message. Can be adjusted via /// governance `set_storage` call. - pub storage XcmBridgeHubRouterByteFee: Balance = TransactionByteFee::get(); + pub storage XcmBridgeHubRouterByteFee: Balance = bp_bridge_hub_polkadot::estimate_polkadot_to_kusama_byte_fee(); pub SiblingBridgeHubParaId: u32 = bp_bridge_hub_polkadot::BRIDGE_HUB_POLKADOT_PARACHAIN_ID; pub SiblingBridgeHub: MultiLocation = MultiLocation::new(1, X1(Parachain(SiblingBridgeHubParaId::get()))); diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/Cargo.toml b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/Cargo.toml index f45a93f2ec..7304479c9e 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/Cargo.toml +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/Cargo.toml @@ -10,8 +10,9 @@ license.workspace = true [dependencies] # Local -kusama-runtime-constants = { path = "../../../../relay/kusama/constants", default-features = false} -polkadot-runtime-constants = { path = "../../../../relay/polkadot/constants", default-features = false} +kusama-runtime-constants = { path = "../../../../relay/kusama/constants", default-features = false } +polkadot-runtime-constants = { path = "../../../../relay/polkadot/constants", default-features = false } +system-parachains-constants = { path = "../../../constants", default-features = false } # Bridge Dependencies bp-bridge-hub-cumulus = { default-features = false , version = "0.7.0" } @@ -36,4 +37,5 @@ std = [ "sp-api/std", "sp-runtime/std", "sp-std/std", + "system-parachains-constants/std", ] diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs index d1faa0e11a..cf53caceea 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs @@ -118,6 +118,18 @@ pub fn estimate_kusama_to_polkadot_message_fee( .saturating_add(BridgeHubKusamaBaseConfirmationFeeInKsms::get()) } +/// Compute the per-byte fee that needs to be paid in KSMs by the sender when sending +/// message from Kusama Bridge Hub to Polkadot Bridge Hub. +pub fn estimate_kusama_to_polkadot_byte_fee() -> Balance { + // the sender pays for the same byte twice: + // 1) the first part comes from the HRMP, when message travels from Kusama Asset Hub to Kusama + // Bridge Hub; + // 2) the second part is the payment for bytes of the message delivery transaction, which is + // "mined" at Polkadot Bridge Hub. Hence, we need to use byte fees from that chain and + // convert it to KSMs here. + convert_from_udot_to_uksm(system_parachains_constants::polkadot::fee::TRANSACTION_BYTE_FEE) +} + /// Convert from uDOTs to uKSMs. fn convert_from_udot_to_uksm(price_in_udot: Balance) -> Balance { // assuming exchange rate is 5 DOTs for 1 KSM diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs index f7c004c661..2c62efda01 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -274,7 +274,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = MILLICENTS; + pub const TransactionByteFee: Balance = system_parachains_constants::kusama::fee::TRANSACTION_BYTE_FEE; } impl pallet_transaction_payment::Config for Runtime { @@ -1116,3 +1116,15 @@ cumulus_pallet_parachain_system::register_validate_block! { Runtime = Runtime, BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_transasction_byte_fee_is_one_tenth_of_relay() { + let relay_tbf = kusama_runtime_constants::fee::TRANSACTION_BYTE_FEE; + let parachain_tbf = TransactionByteFee::get(); + assert_eq!(relay_tbf / 10, parachain_tbf); + } +} diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/Cargo.toml b/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/Cargo.toml index 773ff5bca6..8eab46925c 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/Cargo.toml +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/Cargo.toml @@ -10,8 +10,9 @@ license.workspace = true [dependencies] # Local -kusama-runtime-constants = { path = "../../../../relay/kusama/constants", default-features = false} -polkadot-runtime-constants = { path = "../../../../relay/polkadot/constants", default-features = false} +kusama-runtime-constants = { path = "../../../../relay/kusama/constants", default-features = false } +polkadot-runtime-constants = { path = "../../../../relay/polkadot/constants", default-features = false } +system-parachains-constants = { path = "../../../constants", default-features = false } # Bridge Dependencies bp-bridge-hub-cumulus = { default-features = false , version = "0.7.0" } @@ -36,4 +37,5 @@ std = [ "sp-api/std", "sp-runtime/std", "sp-std/std", + "system-parachains-constants/std", ] diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/src/lib.rs index 50c7713549..361d7cda6d 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/src/lib.rs @@ -109,6 +109,18 @@ pub fn estimate_polkadot_to_kusama_message_fee( .saturating_add(BridgeHubPolkadotBaseConfirmationFeeInDots::get()) } +/// Compute the per-byte fee that needs to be paid in DOTs by the sender when sending +/// message from Polkadot Bridge Hub to Kusama Bridge Hub. +pub fn estimate_polkadot_to_kusama_byte_fee() -> Balance { + // the sender pays for the same byte twice: + // 1) the first part comes from the HRMP, when message travels from Polkadot Asset Hub to + // Polkadot Bridge Hub; + // 2) the second part is the payment for bytes of the message delivery transaction, which is + // "mined" at Kusama Bridge Hub. Hence, we need to use byte fees from that chain and convert + // it to DOTs here. + convert_from_uksm_to_udot(system_parachains_constants::kusama::fee::TRANSACTION_BYTE_FEE) +} + /// Convert from uKSMs to uDOTs. fn convert_from_uksm_to_udot(price_in_uksm: Balance) -> Balance { // assuming exchange rate is 5 DOTs for 1 KSM diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 6b712213a9..2b18d032cc 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -274,7 +274,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = MILLICENTS; + pub const TransactionByteFee: Balance = system_parachains_constants::polkadot::fee::TRANSACTION_BYTE_FEE; } impl pallet_transaction_payment::Config for Runtime { @@ -1116,3 +1116,15 @@ cumulus_pallet_parachain_system::register_validate_block! { Runtime = Runtime, BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_transasction_byte_fee_is_one_tenth_of_relay() { + let relay_tbf = polkadot_runtime_constants::fee::TRANSACTION_BYTE_FEE; + let parachain_tbf = TransactionByteFee::get(); + assert_eq!(relay_tbf / 10, parachain_tbf); + } +} diff --git a/system-parachains/collectives/collectives-polkadot/src/lib.rs b/system-parachains/collectives/collectives-polkadot/src/lib.rs index 962a29652c..0145fb3659 100644 --- a/system-parachains/collectives/collectives-polkadot/src/lib.rs +++ b/system-parachains/collectives/collectives-polkadot/src/lib.rs @@ -222,7 +222,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = MILLICENTS; + pub const TransactionByteFee: Balance = system_parachains_constants::polkadot::fee::TRANSACTION_BYTE_FEE; } impl pallet_transaction_payment::Config for Runtime { @@ -1061,3 +1061,10 @@ fn test_ed_is_one_tenth_of_relay() { let collectives_ed = ExistentialDeposit::get(); assert_eq!(relay_ed / 10, collectives_ed); } + +#[test] +fn test_transasction_byte_fee_is_one_tenth_of_relay() { + let relay_tbf = polkadot_runtime_constants::fee::TRANSACTION_BYTE_FEE; + let parachain_tbf = TransactionByteFee::get(); + assert_eq!(relay_tbf / 10, parachain_tbf); +} diff --git a/system-parachains/constants/src/kusama.rs b/system-parachains/constants/src/kusama.rs index 428059794b..97ef0f189b 100644 --- a/system-parachains/constants/src/kusama.rs +++ b/system-parachains/constants/src/kusama.rs @@ -64,6 +64,11 @@ pub mod fee { /// The block saturation level. Fees will be updates based on this value. pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); + /// Cost of every transaction byte at Kusama system parachains. + /// + /// It is the Relay Chain (Kusama) `TransactionByteFee` / 10. + pub const TRANSACTION_BYTE_FEE: Balance = super::currency::MILLICENTS; + /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the /// node's balance type. /// diff --git a/system-parachains/constants/src/polkadot.rs b/system-parachains/constants/src/polkadot.rs index 932cf2c341..028784270c 100644 --- a/system-parachains/constants/src/polkadot.rs +++ b/system-parachains/constants/src/polkadot.rs @@ -86,6 +86,11 @@ pub mod fee { /// The block saturation level. Fees will be updates based on this value. pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); + /// Cost of every transaction byte at Polkadot system parachains. + /// + /// It is the Relay Chain (Polkadot) `TransactionByteFee` / 10. + pub const TRANSACTION_BYTE_FEE: Balance = super::currency::MILLICENTS; + /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the /// node's balance type. /// diff --git a/system-parachains/encointer/src/lib.rs b/system-parachains/encointer/src/lib.rs index 4a68f33fce..c93278a7d8 100644 --- a/system-parachains/encointer/src/lib.rs +++ b/system-parachains/encointer/src/lib.rs @@ -316,7 +316,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10, same as statemine - pub const TransactionByteFee: Balance = MILLICENTS; + pub const TransactionByteFee: Balance = system_parachains_constants::kusama::fee::TRANSACTION_BYTE_FEE; pub const OperationalFeeMultiplier: u8 = 5; } @@ -1116,6 +1116,10 @@ fn test_constants_compatiblity() { ::system_parachains_constants::kusama::currency::system_para_deposit(5, 3), system_parachains_constants::kusama::currency::system_para_deposit(5, 3) ); + assert_eq!( + ::system_parachains_constants::kusama::fee::TRANSACTION_BYTE_FEE, + system_parachains_constants::kusama::fee::TRANSACTION_BYTE_FEE + ); assert_eq!( ::system_parachains_constants::kusama::fee::calculate_weight_to_fee( &::system_parachains_constants::MAXIMUM_BLOCK_WEIGHT @@ -1126,6 +1130,13 @@ fn test_constants_compatiblity() { ); } +#[test] +fn test_transasction_byte_fee_is_one_tenth_of_relay() { + let relay_tbf = ::kusama_runtime_constants::fee::TRANSACTION_BYTE_FEE; + let parachain_tbf = TransactionByteFee::get(); + assert_eq!(relay_tbf / 10, parachain_tbf); +} + // The Encointer pallets do not have compatible versions with `polkadot-sdk`, making it difficult // for us to reuse the `system-parachains-constants` module. Therefore, we have copies of it here // with `test_constants_compatiblity`. @@ -1209,6 +1220,11 @@ mod system_parachains_constants { use smallvec::smallvec; pub use sp_runtime::Perbill; + /// Cost of every transaction byte at Kusama system parachains. + /// + /// It is the Relay Chain (Kusama) `TransactionByteFee` / 10. + pub const TRANSACTION_BYTE_FEE: Balance = super::currency::MILLICENTS; + /// Handles converting a weight scalar to a fee value, based on the scale and /// granularity of the node's balance type. ///