XCM: Properly set the pricing for the DMP router (#6843)

* Properly set the pricing for the DMP router

* Publicize price types

* Use FixedU128 instead of Percent

* Add sp-arithmetic as a dependency for rococo runtime

* Add sp-arithmetic as a dependency to all runtimes

* Remove duplicate import

* Add missing import

* Fix tests

* Create an appropriate QueueDownwardMessageError variant

* Recalculate delivery fee factor based on past queue sizes

* Remove unused error variant

* Fixes

* Fixes

* Remove unused imports

* Rewrite fee factor update mechanism

* Remove unused imports

* Fixes

* Update runtime/parachains/src/dmp.rs

Co-authored-by: Squirrel <gilescope@gmail.com>

* Make DeliveryFeeFactor be a StorageMap keyed on ParaIds

* Fixes

* introduce limit for fee increase on dmp queue

* add message_size based fee factor to increment_fee_factor

* change message_size fee rate to correct value

* fix div by 0 error

* bind limit to variable

* fix message_size_factor and add DeliveryFeeFactor test

* add test for ExponentialPrice implementation

* make test formula based

* make delivery fee factor test formula based

* add max value test for DeliveryFeeFactor and move limit to config

* change threshold back to dynamic value and fix tests

* fmt

* suggested changes and fmt

* small stylistic change

* fmt

* change to tokenlocation

* small fixes

* fmt

* remove sp_arithmetic dependency

* Update runtime/parachains/src/dmp.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

---------

Co-authored-by: Squirrel <gilescope@gmail.com>
Co-authored-by: Just van Stam <just.van.stam@gmail.com>
Co-authored-by: Just van Stam <vstam1@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Keith Yeung
2023-04-20 19:04:33 +08:00
committed by GitHub
parent b3e2153f2f
commit 023d459857
18 changed files with 351 additions and 45 deletions
+6 -6
View File
@@ -349,7 +349,7 @@ fn teleport_assets_works() {
(ParaId::from(PARA_ID).into_account_truncating(), INITIAL_BALANCE),
];
new_test_ext_with_balances(balances).execute_with(|| {
let weight = BaseXcmWeight::get() * 2;
let weight = BaseXcmWeight::get() * 3;
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into();
assert_ok!(XcmPallet::teleport_assets(
@@ -392,7 +392,7 @@ fn limited_teleport_assets_works() {
(ParaId::from(PARA_ID).into_account_truncating(), INITIAL_BALANCE),
];
new_test_ext_with_balances(balances).execute_with(|| {
let weight = BaseXcmWeight::get() * 2;
let weight = BaseXcmWeight::get() * 3;
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into();
assert_ok!(XcmPallet::limited_teleport_assets(
@@ -436,7 +436,7 @@ fn unlimited_teleport_assets_works() {
(ParaId::from(PARA_ID).into_account_truncating(), INITIAL_BALANCE),
];
new_test_ext_with_balances(balances).execute_with(|| {
let weight = BaseXcmWeight::get() * 2;
let weight = BaseXcmWeight::get() * 3;
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into();
assert_ok!(XcmPallet::limited_teleport_assets(
@@ -478,7 +478,7 @@ fn reserve_transfer_assets_works() {
(ParaId::from(PARA_ID).into_account_truncating(), INITIAL_BALANCE),
];
new_test_ext_with_balances(balances).execute_with(|| {
let weight = BaseXcmWeight::get();
let weight = BaseXcmWeight::get() * 2;
let dest: MultiLocation = Junction::AccountId32 { network: None, id: ALICE.into() }.into();
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
assert_ok!(XcmPallet::reserve_transfer_assets(
@@ -525,7 +525,7 @@ fn limited_reserve_transfer_assets_works() {
(ParaId::from(PARA_ID).into_account_truncating(), INITIAL_BALANCE),
];
new_test_ext_with_balances(balances).execute_with(|| {
let weight = BaseXcmWeight::get();
let weight = BaseXcmWeight::get() * 2;
let dest: MultiLocation = Junction::AccountId32 { network: None, id: ALICE.into() }.into();
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
assert_ok!(XcmPallet::limited_reserve_transfer_assets(
@@ -573,7 +573,7 @@ fn unlimited_reserve_transfer_assets_works() {
(ParaId::from(PARA_ID).into_account_truncating(), INITIAL_BALANCE),
];
new_test_ext_with_balances(balances).execute_with(|| {
let weight = BaseXcmWeight::get();
let weight = BaseXcmWeight::get() * 2;
let dest: MultiLocation = Junction::AccountId32 { network: None, id: ALICE.into() }.into();
assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE);
assert_ok!(XcmPallet::limited_reserve_transfer_assets(