@@ -16,7 +16,7 @@ use parachains_common::{
1616 xcm_config:: ParentRelayOrSiblingParachains ,
1717} ;
1818use polkadot_parachain_primitives:: primitives:: Sibling ;
19- use polkadot_runtime_common:: xcm_sender:: NoPriceForMessageDelivery ;
19+ use polkadot_runtime_common:: xcm_sender:: ExponentialPrice ;
2020use sp_runtime:: { traits:: AccountIdConversion , Vec } ;
2121use xcm:: latest:: prelude:: * ;
2222use xcm_builder:: {
@@ -31,10 +31,16 @@ use xcm_builder::{
3131use xcm_executor:: XcmExecutor ;
3232
3333use crate :: {
34- config:: { governance:: SudoAddress , monetary:: fee:: WeightToFee , system:: RuntimeBlockWeights } ,
35- AccountId , AllPalletsWithSystem , Balances , ParachainInfo , ParachainSystem ,
36- PolkadotXcm , Runtime , RuntimeCall , RuntimeEvent , RuntimeOrigin ,
37- XcmpQueue , Perbill ,
34+ config:: {
35+ monetary:: {
36+ fee:: { WeightToFee , CENTS } ,
37+ TransactionByteFee ,
38+ } ,
39+ system:: RuntimeBlockWeights ,
40+ } ,
41+ AccountId , AllPalletsWithSystem , Balances , MessageQueue , PalletId , ParachainInfo ,
42+ ParachainSystem , Perbill , PolkadotXcm , Runtime , RuntimeCall , RuntimeEvent , RuntimeOrigin ,
43+ XcmpQueue ,
3844} ;
3945
4046parameter_types ! {
@@ -46,6 +52,7 @@ parameter_types! {
4652 pub MessageQueueIdleServiceWeight : Weight = Perbill :: from_percent( 20 ) * RuntimeBlockWeights :: get( ) . max_block;
4753 pub MessageQueueServiceWeight : Weight = Perbill :: from_percent( 35 ) * RuntimeBlockWeights :: get( ) . max_block;
4854 pub TreasuryAccount : AccountId = PalletId ( * b"treasury" ) . into_account_truncating( ) ;
55+ pub const BaseDeliveryFee : u128 = CENTS . saturating_mul( 3 ) ;
4956}
5057
5158impl pallet_message_queue:: Config for Runtime {
@@ -261,7 +268,8 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
261268 // Limit the number of HRMP channels.
262269 // note: https://github.com/polkadot-fellows/runtimes/blob/76d1fa680d00c3e447e40199e7b2250862ad4bfa/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs#L692C2-L693C90
263270 type MaxPageSize = ConstU32 < { 103 * 1024 } > ;
264- type PriceForSiblingDelivery = NoPriceForMessageDelivery < ParaId > ;
271+ type PriceForSiblingDelivery =
272+ ExponentialPrice < RelayLocation , BaseDeliveryFee , TransactionByteFee , XcmpQueue > ;
265273 type RuntimeEvent = RuntimeEvent ;
266274 type VersionWrapper = PolkadotXcm ;
267275 type WeightInfo = cumulus_pallet_xcmp_queue:: weights:: SubstrateWeight < Runtime > ;
@@ -273,9 +281,19 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
273281mod tests {
274282 use std:: any:: TypeId ;
275283
284+ use polkadot_runtime_common:: xcm_sender:: * ;
285+ use polkadot_runtime_parachains:: FeeTracker ;
286+ use sp_runtime:: FixedPointNumber ;
276287 use xcm_executor:: traits:: { FeeManager , FeeReason } ;
277288
278289 use super :: * ;
290+ use crate :: System ;
291+
292+ fn new_test_ext ( ) -> sp_io:: TestExternalities {
293+ let mut ext = sp_io:: TestExternalities :: new_empty ( ) ;
294+ ext. execute_with ( || System :: set_block_number ( 1 ) ) ;
295+ ext
296+ }
279297
280298 mod reserves_config {
281299 use super :: * ;
@@ -338,6 +356,7 @@ mod tests {
338356 ) ) ;
339357 }
340358 }
359+
341360 mod message_queue {
342361 use super :: * ;
343362
@@ -1038,13 +1057,35 @@ mod tests {
10381057 }
10391058
10401059 #[ test]
1041- #[ ignore]
10421060 fn price_for_sibling_delivery ( ) {
10431061 assert_eq ! (
10441062 TypeId :: of:: <<Runtime as cumulus_pallet_xcmp_queue:: Config >:: PriceForSiblingDelivery >(
10451063 ) ,
1046- TypeId :: of:: <NoPriceForMessageDelivery <ParaId >>( )
1064+ TypeId :: of:: <
1065+ ExponentialPrice <RelayLocation , BaseDeliveryFee , TransactionByteFee , XcmpQueue >,
1066+ >( )
10471067 ) ;
1068+
1069+ new_test_ext ( ) . execute_with ( || {
1070+ type ExponentialDeliveryPrice =
1071+ ExponentialPrice < RelayLocation , BaseDeliveryFee , TransactionByteFee , XcmpQueue > ;
1072+ let id: ParaId = 420 . into ( ) ;
1073+ let b: u128 = BaseDeliveryFee :: get ( ) ;
1074+ let m: u128 = TransactionByteFee :: get ( ) ;
1075+
1076+ // F * (B + msg_length * M)
1077+ // A: RelayLocation
1078+ // B: BaseDeliveryFee
1079+ // M: TransactionByteFee
1080+ // F: XcmpQueue
1081+ //
1082+ // message_length = 1
1083+ let result: u128 = XcmpQueue :: get_fee_factor ( id) . saturating_mul_int ( b + m) ;
1084+ assert_eq ! (
1085+ ExponentialDeliveryPrice :: price_for_delivery( id, & Xcm ( vec![ ] ) ) ,
1086+ ( RelayLocation :: get( ) , result) . into( )
1087+ ) ;
1088+ } )
10481089 }
10491090
10501091 #[ test]
0 commit comments