Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use evm foreign assets to pay XCM fees #2908

Merged
merged 33 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
84b1d32
create pallet xcm-weight-trader
librelois Aug 18, 2024
7c7212d
add rust unit tests for trader fix trader impl
librelois Aug 21, 2024
27b51cf
add functions for runtime api xcm-fee-payment
librelois Aug 22, 2024
3d9c721
add rust test scenario: unpause and edit asset price
librelois Aug 22, 2024
83157cd
add pallet-xcm-weight-trader to all runtimes & migrate assets fees data
librelois Aug 22, 2024
2499887
avoid div by zero
librelois Aug 23, 2024
2492d89
refactor moonbase rust tests to use new pallet xcm-weight-trader
librelois Aug 23, 2024
d6ff588
refactor moonbeam/moonriver rust tests to use new pallet xcm-weight-t…
RomarQ Aug 23, 2024
9532086
Merge branch 'master' into elois-evm-foreign-fees
RomarQ Aug 25, 2024
90537cb
fix pallet compilation with feature runtime-benchmark and tests
RomarQ Aug 26, 2024
9a399e3
fix rust tests
RomarQ Aug 26, 2024
1678021
add weight info for pallet_xcm_weight_trader
RomarQ Aug 26, 2024
a1e7004
fix migration formula
librelois Aug 26, 2024
fd30cb7
fix pallet tests
RomarQ Aug 26, 2024
af305a0
fix linting
RomarQ Aug 26, 2024
01c317d
fix typo
librelois Aug 28, 2024
87dd277
configure origins for xcmWeightTrader
librelois Aug 28, 2024
871626d
fix: edit asset should not unpause asset
librelois Aug 29, 2024
35f2b1b
Merge branch 'master' into elois-evm-foreign-fees
librelois Sep 2, 2024
0a70b3f
update registerOldForeignAssets to use xcmWeightTrader
pLabarta Sep 2, 2024
5788820
Merge branch 'pablo/evm-foreign-fees' into elois-evm-foreign-fees
pLabarta Sep 2, 2024
dff2a26
fix tests using setAssetUnitsPerSecond
pLabarta Sep 2, 2024
6d7be3b
Update pallets/xcm-weight-trader/src/lib.rs
librelois Sep 6, 2024
8fc6346
Merge branch 'master' into elois-evm-foreign-fees
librelois Sep 6, 2024
86f837e
fix rust compilation
librelois Sep 6, 2024
a6bdc47
benchmarks: use evm foreign assets for worst_case_holding
librelois Sep 6, 2024
0916c9d
Merge branch 'master' into elois-evm-foreign-fees
RomarQ Sep 10, 2024
7cd1b35
impl post-upgrade
librelois Sep 12, 2024
3c772e5
fix migration code
RomarQ Sep 12, 2024
dd9040e
Merge branch 'master' into elois-evm-foreign-fees
librelois Sep 12, 2024
58a5b40
fix rust test
librelois Sep 13, 2024
6c02815
rustfmt
librelois Sep 13, 2024
c8d8a7f
remove unused import
librelois Sep 13, 2024
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
26 changes: 26 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ members = [
"pallets/precompile-benchmarks",
"pallets/proxy-genesis-companion",
"pallets/xcm-transactor",
"pallets/xcm-weight-trader",
"precompiles/balances-erc20",
"precompiles/batch",
"precompiles/call-permit",
Expand Down Expand Up @@ -107,6 +108,7 @@ pallet-parachain-staking = { path = "pallets/parachain-staking", default-feature
pallet-precompile-benchmarks = { path = "pallets/precompile-benchmarks", default-features = false }
pallet-proxy-genesis-companion = { path = "pallets/proxy-genesis-companion", default-features = false }
pallet-xcm-transactor = { path = "pallets/xcm-transactor", default-features = false }
pallet-xcm-weight-trader = { path = "pallets/xcm-weight-trader", default-features = false }
precompile-foreign-asset-migrator = { path = "precompiles/foreign-asset-migrator", default-features = false }
xcm-primitives = { path = "primitives/xcm", default-features = false }

Expand Down Expand Up @@ -185,6 +187,7 @@ sp-runtime-interface = { git = "https://github.com/moonbeam-foundation/polkadot-
sp-session = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false }
sp-std = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false }
sp-state-machine = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false }
sp-tracing = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false }
sp-transaction-pool = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false }
sp-trie = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false }
sp-version = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.11.0", default-features = false }
Expand Down
75 changes: 0 additions & 75 deletions pallets/asset-manager/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,47 +36,7 @@ benchmarks! {
assert_eq!(Pallet::<T>::asset_id_type(asset_id), Some(asset_type));
}

set_asset_units_per_second {
// We make it dependent on the number of existing assets already
let x in 5..100;
for i in 0..x {
let asset_type: T::ForeignAssetType = Location::new(
0,
X1(GeneralIndex(i as u128))
).into();
let metadata = T::AssetRegistrarMetadata::default();
let amount = 1u32.into();
Pallet::<T>::register_foreign_asset(
RawOrigin::Root.into(),
asset_type.clone(),
metadata,
amount,
true
)?;
Pallet::<T>::set_asset_units_per_second(RawOrigin::Root.into(), asset_type.clone(), 1, i)?;
}

// does not really matter what we register, as long as it is different than the previous
let asset_type = T::ForeignAssetType::default();
let metadata = T::AssetRegistrarMetadata::default();
let amount = 1u32.into();
let asset_id: T::AssetId = asset_type.clone().into();
Pallet::<T>::register_foreign_asset(
RawOrigin::Root.into(),
asset_type.clone(),
metadata,
amount,
true
)?;

}: _(RawOrigin::Root, asset_type.clone(), 1, x)
verify {
assert!(Pallet::<T>::supported_fee_payment_assets().contains(&asset_type));
assert_eq!(Pallet::<T>::asset_type_units_per_second(asset_type), Some(1));
}

change_existing_asset_type {
// We make it dependent on the number of existing assets already
let x in 5..100;
for i in 0..x {
let asset_type: T::ForeignAssetType = Location::new(0, X1(GeneralIndex(i as u128))).into();
Expand All @@ -89,7 +49,6 @@ benchmarks! {
amount,
true
)?;
Pallet::<T>::set_asset_units_per_second(RawOrigin::Root.into(), asset_type.clone(), 1, i)?;
}

let new_asset_type = T::ForeignAssetType::default();
Expand All @@ -101,40 +60,9 @@ benchmarks! {
}: _(RawOrigin::Root, asset_id_to_be_changed, new_asset_type.clone(), x)
verify {
assert_eq!(Pallet::<T>::asset_id_type(asset_id_to_be_changed), Some(new_asset_type.clone()));
assert_eq!(Pallet::<T>::asset_type_units_per_second(&new_asset_type), Some(1));
assert!(Pallet::<T>::supported_fee_payment_assets().contains(&new_asset_type));
}

remove_supported_asset {
// We make it dependent on the number of existing assets already
let x in 5..100;
for i in 0..x {
let asset_type: T::ForeignAssetType = Location::new(0, X1(GeneralIndex(i as u128))).into();
let metadata = T::AssetRegistrarMetadata::default();
let amount = 1u32.into();
Pallet::<T>::register_foreign_asset(
RawOrigin::Root.into(),
asset_type.clone(),
metadata,
amount,
true
)?;
Pallet::<T>::set_asset_units_per_second(RawOrigin::Root.into(), asset_type.clone(), 1, i)?;
}
let asset_type_to_be_removed: T::ForeignAssetType = Location::new(
0,
X1(GeneralIndex((x-1) as u128))
).into();
// We try to remove the last asset type
}: _(RawOrigin::Root, asset_type_to_be_removed.clone(), x)
verify {
assert!(!Pallet::<T>::supported_fee_payment_assets().contains(&asset_type_to_be_removed));
assert_eq!(Pallet::<T>::asset_type_units_per_second(asset_type_to_be_removed), None);
}

remove_existing_asset_type {
// We make it dependent on the number of existing assets already
// Worst case is we need to remove it from SupportedAAssetsFeePayment too
let x in 5..100;
for i in 0..x {
let asset_type: T::ForeignAssetType = Location::new(0, X1(GeneralIndex(i as u128))).into();
Expand All @@ -147,7 +75,6 @@ benchmarks! {
amount,
true
)?;
Pallet::<T>::set_asset_units_per_second(RawOrigin::Root.into(), asset_type.clone(), 1, i)?;
}

let asset_type_to_be_removed: T::ForeignAssetType = Location::new(
Expand All @@ -158,8 +85,6 @@ benchmarks! {
}: _(RawOrigin::Root, asset_id, x)
verify {
assert!(Pallet::<T>::asset_id_type(asset_id).is_none());
assert!(Pallet::<T>::asset_type_units_per_second(&asset_type_to_be_removed).is_none());
assert!(!Pallet::<T>::supported_fee_payment_assets().contains(&asset_type_to_be_removed));
}
}

Expand Down
Loading
Loading