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

Upgrade to Polkadot-SDK v1.7.0 #1262

Merged
merged 7 commits into from
Jun 12, 2024
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
1,365 changes: 700 additions & 665 deletions Cargo.lock

Large diffs are not rendered by default.

316 changes: 158 additions & 158 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ copy-genesis-config-release:

.PHONY: format # cargo fmt
format:
cargo +nightly fmt --all -- --check
cargo +nightly fmt --all

.PHONY: clippy # cargo clippy
clippy:
Expand Down
65 changes: 28 additions & 37 deletions pallets/asset-registry/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ use bifrost_primitives::{CurrencyId, TokenSymbol};
use frame_benchmarking::{benchmarks, v1::BenchmarkError};
use frame_support::{assert_ok, traits::UnfilteredDispatchable};
use sp_runtime::traits::UniqueSaturatedFrom;
use xcm::v3::prelude::*;

benchmarks! {
register_native_asset {
let origin = T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let v3_location = VersionedMultiLocation::V3(MultiLocation::from(X1(Junction::Parachain(1000))));
let versioned_location = VersionedLocation::V4(Location::from([Parachain(1000)]));

let call = Call::<T>::register_native_asset {
currency_id: CurrencyId::Token(TokenSymbol::DOT),
location: Box::new(v3_location.clone()),
currency_id: Token(TokenSymbol::DOT),
location: Box::new(versioned_location.clone()),
metadata: Box::new(AssetMetadata {
name: b"Token Name".to_vec(),
symbol: b"TN".to_vec(),
Expand All @@ -44,7 +43,7 @@ benchmarks! {
}: {call.dispatch_bypass_filter(origin)?}
verify {
assert_eq!(
AssetMetadatas::<T>::get(AssetIds::NativeAssetId(CurrencyId::Token(
AssetMetadatas::<T>::get(AssetIds::NativeAssetId(Token(
TokenSymbol::DOT
))),
Some(AssetMetadata {
Expand All @@ -58,12 +57,12 @@ benchmarks! {

update_native_asset {
let origin = T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let v3_location = VersionedMultiLocation::V3(MultiLocation::from(X1(Junction::Parachain(1000))));
let versioned_location = VersionedLocation::V4(Location::from([Parachain(1000)]));

assert_ok!(AssetRegistry::<T>::register_native_asset(
origin.clone(),
CurrencyId::Token(TokenSymbol::DOT),
Box::new(v3_location.clone()),
Token(TokenSymbol::DOT),
Box::new(versioned_location.clone()),
Box::new(AssetMetadata {
name: b"Token Name".to_vec(),
symbol: b"TN".to_vec(),
Expand All @@ -73,8 +72,8 @@ benchmarks! {
));

let call = Call::<T>::update_native_asset {
currency_id: CurrencyId::Token(TokenSymbol::DOT),
location: Box::new(v3_location.clone()),
currency_id: Token(TokenSymbol::DOT),
location: Box::new(versioned_location.clone()),
metadata: Box::new(AssetMetadata {
name: b"Token Name".to_vec(),
symbol: b"TN".to_vec(),
Expand All @@ -85,7 +84,7 @@ benchmarks! {
}: {call.dispatch_bypass_filter(origin)?}
verify {
assert_eq!(
AssetMetadatas::<T>::get(AssetIds::NativeAssetId(CurrencyId::Token(
AssetMetadatas::<T>::get(AssetIds::NativeAssetId(Token(
TokenSymbol::DOT
))),
Some(AssetMetadata {
Expand All @@ -111,7 +110,7 @@ benchmarks! {
};
}: {call.dispatch_bypass_filter(origin)?}
verify {
assert_eq!(CurrencyMetadatas::<T>::get(CurrencyId::Token2(0)), Some(metadata.clone()))
assert_eq!(CurrencyMetadatas::<T>::get(Token2(0)), Some(metadata.clone()))
}

register_vtoken_metadata {
Expand Down Expand Up @@ -208,69 +207,61 @@ benchmarks! {
)
}

register_multilocation {
register_location {
let origin = T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let metadata = AssetMetadata {
name: b"Bifrost Native Coin".to_vec(),
symbol: b"BNC".to_vec(),
decimals: 12,
minimal_balance: BalanceOf::<T>::unique_saturated_from(0u128),
};
// v3
let location = VersionedMultiLocation::V3(MultiLocation {
parents: 1,
interior: Junctions::X1(Parachain(2001)),
});
let versioned_location = VersionedLocation::V4(Location::new(1, [Parachain(2001)]));

let multi_location: MultiLocation = location.clone().try_into().unwrap();
let location: xcm::v3::Location = versioned_location.clone().try_into().unwrap();

assert_ok!(AssetRegistry::<T>::register_token_metadata(
origin.clone(),
Box::new(metadata.clone())
));

let call = Call::<T>::register_multilocation {
currency_id: CurrencyId::Token2(0),
location:Box::new(location.clone()),
let call = Call::<T>::register_location {
currency_id: Token2(0),
location:Box::new(versioned_location.clone()),
weight:Weight::from_parts(2000_000_000, u64::MAX),
};
}: {call.dispatch_bypass_filter(origin)?}
verify {
assert_eq!(
LocationToCurrencyIds::<T>::get(multi_location.clone()),
Some(CurrencyId::Token2(0))
LocationToCurrencyIds::<T>::get(location.clone()),
Some(Token2(0))
);
assert_eq!(
CurrencyIdToLocations::<T>::get(CurrencyId::Token2(0)),
Some(multi_location.clone())
CurrencyIdToLocations::<T>::get(Token2(0)),
Some(location.clone())
);
assert_eq!(CurrencyIdToWeights::<T>::get(CurrencyId::Token2(0)), Some(Weight::from_parts(2000_000_000, u64::MAX)));
assert_eq!(CurrencyIdToWeights::<T>::get(Token2(0)), Some(Weight::from_parts(2000_000_000, u64::MAX)));
}

force_set_multilocation {
force_set_location {
let origin = T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let metadata = AssetMetadata {
name: b"Bifrost Native Coin".to_vec(),
symbol: b"BNC".to_vec(),
decimals: 12,
minimal_balance: BalanceOf::<T>::unique_saturated_from(0u128),
};
// v3
let location = VersionedMultiLocation::V3(MultiLocation {
parents: 1,
interior: Junctions::X1(Parachain(2001)),
});
let versioned_location = VersionedLocation::V4(Location::new(1, [Parachain(2001)]));

let multi_location: MultiLocation = location.clone().try_into().unwrap();
let location: xcm::v3::Location = versioned_location.clone().try_into().unwrap();

assert_ok!(AssetRegistry::<T>::register_token_metadata(
origin.clone(),
Box::new(metadata.clone())
));

let call = Call::<T>::force_set_multilocation {
currency_id: CurrencyId::Token2(0),
location:Box::new(location.clone()),
let call = Call::<T>::force_set_location {
currency_id: Token2(0),
location:Box::new(versioned_location.clone()),
weight:Weight::from_parts(2000_000_000, u64::MAX),
};
}: {call.dispatch_bypass_filter(origin)?}
Expand Down
Loading