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

Bifrost v0.10.1 #1256

Closed
wants to merge 14 commits into from
Closed
1,416 changes: 750 additions & 666 deletions Cargo.lock

Large diffs are not rendered by default.

319 changes: 161 additions & 158 deletions Cargo.toml

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ copy-genesis-config-release:

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

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

.PHONY: clippy # cargo clippy
clippy:
clippy: format-check
SKIP_WASM_BUILD= cargo clippy --all --all-targets --features=with-all-runtime -- -D warnings

.PHONY: benchmarking-staking # benchmarking staking pallet
Expand Down
2 changes: 1 addition & 1 deletion node/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bifrost-cli"
version = "0.10.0"
version = "0.10.1"
authors = ["Liebi Technologies <[email protected]>"]
description = "Bifrost Parachain Node"
build = "build.rs"
Expand Down
99 changes: 62 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,73 +207,99 @@ 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)?}

update_currency_metadata {
let origin = T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;

assert_ok!(AssetRegistry::<T>::register_token_metadata(
origin.clone(),
Box::new(AssetMetadata {
name: b"Old Token Name".to_vec(),
symbol: b"OTN".to_vec(),
decimals: 10,
minimal_balance: BalanceOf::<T>::unique_saturated_from(1u128),
})
));

let call = Call::<T>::update_currency_metadata {
currency_id: CurrencyId::Token2(0),
asset_name: Some(b"Token Name".to_vec()),
asset_symbol: Some(b"TN".to_vec()),
asset_decimals : Some(12),
asset_minimal_balance : Some(BalanceOf::<T>::unique_saturated_from(1000u128)),
};

}: {call.dispatch_bypass_filter(origin)?}
verify {
assert_eq!(
CurrencyMetadatas::<T>::get(CurrencyId::Token2(0)),
Some(AssetMetadata {
name: b"Token Name".to_vec(),
symbol: b"TN".to_vec(),
decimals: 12,
minimal_balance: BalanceOf::<T>::unique_saturated_from(1000u128),
})
);
}

impl_benchmark_test_suite!(
AssetRegistry,
crate::mock::ExtBuilder::default().build(),
Expand Down
Loading