From ef8952aa1efbc5699d1bed00e801a2b8a68ca2ae Mon Sep 17 00:00:00 2001 From: Lumir Mrkva Date: Thu, 8 Jun 2023 00:02:44 +0200 Subject: [PATCH 1/4] increased test stability --- pallets/xyk/src/benchmarking.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/pallets/xyk/src/benchmarking.rs b/pallets/xyk/src/benchmarking.rs index 6190075658..970434f4a8 100644 --- a/pallets/xyk/src/benchmarking.rs +++ b/pallets/xyk/src/benchmarking.rs @@ -103,7 +103,6 @@ benchmarks! { }: _(RawOrigin::Signed(caller.clone()), asset_a, asset_b, amount, min_bought, discount) verify{ assert_eq!(T::Currency::free_balance(asset_a, &caller), 999999000000000); - assert_eq!(T::Currency::free_balance(asset_b, &caller), 1000002988011991); } buy { @@ -122,7 +121,6 @@ benchmarks! { }: _(RawOrigin::Signed(caller.clone()), asset_a, asset_b, amount, max_sold, discount) verify{ assert_eq!(T::Currency::free_balance(asset_a, &caller), 1000001000000000); - assert_eq!(T::Currency::free_balance(asset_b, &caller), 999996987987987); } } From 7e8b10042ce467ddab1f571111e9c136b4899689 Mon Sep 17 00:00:00 2001 From: Lumir Mrkva Date: Thu, 8 Jun 2023 00:02:59 +0200 Subject: [PATCH 2/4] nft weights fixed again --- integration-tests/src/fees.rs | 30 ++++++++++++------------------ runtime/common/src/weights/nft.rs | 6 ++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/integration-tests/src/fees.rs b/integration-tests/src/fees.rs index 7fb75f290e..8446f5ad2f 100644 --- a/integration-tests/src/fees.rs +++ b/integration-tests/src/fees.rs @@ -9,20 +9,20 @@ use xcm_emulator::TestExt; macro_rules! assert_eq_approx { ( $x:expr, $y:expr, $z:expr, $r:expr) => {{ - let diff = if $x >= $y { $x - $y } else { $y - $x }; - if diff > $z { - panic!("\n{} not equal\nleft: {:?}\nright: {:?}\n", $r, $x, $y); + let d = if $x >= $y { $x - $y } else { $y - $x }; + if d > $z { + panic!("\n{}\nleft: {:?}\nright: {:?}\nallowed diff: {:?}\nactual diff: {:?}\n", $r, $x, $y, $z, d); } }}; } -//NOTE: rust encoded call size is differen from UI encoded call size that's why we have asserts for 2 fees. +//NOTE: rust encoded call size is different from UI encoded call size that's why we have asserts for 2 fees. + +const DIFF: u128 = 100 * UNITS; #[test] fn transaction_fees_should_be_as_expected_when_transfer_happen() { Basilisk::execute_with(|| { - let diff = UNITS / 100; //0.01 - let expected_rust_encoded_fees = 4_705 * UNITS / 100; //47.05 let expected_ui_fees = 4_804 * UNITS / 100; //48.04 @@ -64,17 +64,14 @@ fn transaction_fees_should_be_as_expected_when_transfer_happen() { format_num(min_multiplier_rust_fees * 10_000 / UNITS, 4), ); - assert_eq_approx!(rust_encoded_fees, expected_rust_encoded_fees, diff, "rust fees changed"); - assert_eq_approx!(ui_fees, expected_ui_fees, diff, "ui fees changed"); + assert_eq_approx!(rust_encoded_fees, expected_rust_encoded_fees, DIFF, "rust fees changed"); + assert_eq_approx!(ui_fees, expected_ui_fees, DIFF, "ui fees changed"); }); } #[test] fn transaction_fees_should_be_as_expected_when_nft_is_minted() { Basilisk::execute_with(|| { - //NOTE: Price showed by polkadotAPPS is changing at second decimal place between runs. - let diff = UNITS / 10; //0.1 - let expected_rust_encoded_fees = 48_619 * UNITS / 100; //486.19 let expected_ui_fees = 48_724 * UNITS / 100; //487.24 @@ -120,17 +117,14 @@ fn transaction_fees_should_be_as_expected_when_nft_is_minted() { format_num(min_multiplier_rust_fees * 10_000 / UNITS, 4), ); - assert_eq_approx!(rust_encoded_fees, expected_rust_encoded_fees, diff, "rust fees changed"); - assert_eq_approx!(ui_fees, expected_ui_fees, diff, "ui fees changed"); + assert_eq_approx!(rust_encoded_fees, expected_rust_encoded_fees, DIFF, "rust fees difference too large"); + assert_eq_approx!(ui_fees, expected_ui_fees, DIFF, "ui fees difference too large"); }); } #[test] fn transaction_fees_should_be_as_expected_when_nft_collection_is_created() { Basilisk::execute_with(|| { - //NOTE: Price showed by polkadotAPPS is changing at second decimal place between runs. - let diff = UNITS / 10; //0.1 - let expected_rust_encoded_fees = 45_584 * UNITS / 100; //455.84 let expected_ui_fees = 45_689 * UNITS / 100; //456.89 @@ -176,8 +170,8 @@ fn transaction_fees_should_be_as_expected_when_nft_collection_is_created() { format_num(min_multiplier_rust_fees * 10_000 / UNITS, 4), ); - assert_eq_approx!(rust_encoded_fees, expected_rust_encoded_fees, diff, "rust fees changed"); - assert_eq_approx!(ui_fees, expected_ui_fees, diff, "ui fees changed"); + assert_eq_approx!(rust_encoded_fees, expected_rust_encoded_fees, DIFF, "rust fees changed"); + assert_eq_approx!(ui_fees, expected_ui_fees, DIFF, "ui fees changed"); }); } diff --git a/runtime/common/src/weights/nft.rs b/runtime/common/src/weights/nft.rs index a680c03fa1..a2134c896d 100644 --- a/runtime/common/src/weights/nft.rs +++ b/runtime/common/src/weights/nft.rs @@ -49,6 +49,10 @@ use pallet_nft::weights::WeightInfo; pub struct BasiliskWeight(PhantomData); +//This consts are here to make `create_collection()` and `mint()` more expensive. +const CREATE_COLLECTION_OFFSET: u64 = 180 * 2; +const MINT_OFFSET: u64 = 140 * 2; + impl WeightInfo for BasiliskWeight { // Storage: Uniques Class (r:1 w:1) // Proof: Uniques Class (max_values: None, max_size: Some(190), added: 2665, mode: MaxEncodedLen) @@ -63,6 +67,7 @@ impl WeightInfo for BasiliskWeight { fn create_collection() -> Weight { // Minimum execution time: 19_500 nanoseconds. Weight::from_ref_time(19_928_000 as u64) + .saturating_mul(CREATE_COLLECTION_OFFSET) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -85,6 +90,7 @@ impl WeightInfo for BasiliskWeight { fn mint() -> Weight { // Minimum execution time: 31_625 nanoseconds. Weight::from_ref_time(32_251_000 as u64) + .saturating_mul(MINT_OFFSET) .saturating_add(T::DbWeight::get().reads(6 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } From dfab6d694b9c5e7c06235963a96f34dda7af1b81 Mon Sep 17 00:00:00 2001 From: Lumir Mrkva Date: Thu, 8 Jun 2023 00:07:12 +0200 Subject: [PATCH 3/4] runtime 101 --- Cargo.lock | 8 ++++---- integration-tests/Cargo.toml | 2 +- pallets/xyk/Cargo.toml | 2 +- runtime/basilisk/Cargo.toml | 2 +- runtime/basilisk/src/lib.rs | 2 +- runtime/common/Cargo.toml | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e18c06c1f7..37d91b1f3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -613,7 +613,7 @@ dependencies = [ [[package]] name = "basilisk-runtime" -version = "100.0.0" +version = "101.0.0" dependencies = [ "common-runtime", "cumulus-pallet-aura-ext", @@ -1304,7 +1304,7 @@ dependencies = [ [[package]] name = "common-runtime" -version = "2.3.13" +version = "2.3.14" dependencies = [ "cumulus-pallet-xcmp-queue", "frame-support", @@ -7224,7 +7224,7 @@ dependencies = [ [[package]] name = "pallet-xyk" -version = "6.2.7" +version = "6.2.8" dependencies = [ "frame-benchmarking", "frame-support", @@ -9778,7 +9778,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "0.9.10" +version = "0.9.11" dependencies = [ "basilisk-runtime", "cumulus-pallet-aura-ext", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 79675b0f44..4a9ff8243b 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "0.9.10" +version = "0.9.11" description = "Integration tests" authors = ["GalacticCouncil"] edition = "2021" diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index d3259123c0..b52484ef82 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-xyk' -version = "6.2.7" +version = "6.2.8" description = 'XYK automated market maker' authors = ['GalacticCouncil'] edition = '2021' diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index c4fb75b00f..dc15a65fa8 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "basilisk-runtime" -version = "100.0.0" +version = "101.0.0" authors = ["GalacticCouncil"] edition = "2021" homepage = "https://github.com/galacticcouncil/Basilisk-node" diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index fa0ebc85b5..d39a2c21ca 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -113,7 +113,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("basilisk"), impl_name: create_runtime_str!("basilisk"), authoring_version: 1, - spec_version: 100, + spec_version: 101, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 93549f2a82..65740bfd2c 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "common-runtime" -version = "2.3.13" +version = "2.3.14" authors = ["GalacticCouncil"] edition = "2021" homepage = "https://github.com/galacticcouncil/Basilisk-node" From 7f211fcda99424161bdbf972a52b247df97becd6 Mon Sep 17 00:00:00 2001 From: Lumir Mrkva Date: Thu, 8 Jun 2023 00:12:28 +0200 Subject: [PATCH 4/4] fmt --- integration-tests/src/fees.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/integration-tests/src/fees.rs b/integration-tests/src/fees.rs index 8446f5ad2f..3e03212299 100644 --- a/integration-tests/src/fees.rs +++ b/integration-tests/src/fees.rs @@ -11,7 +11,10 @@ macro_rules! assert_eq_approx { ( $x:expr, $y:expr, $z:expr, $r:expr) => {{ let d = if $x >= $y { $x - $y } else { $y - $x }; if d > $z { - panic!("\n{}\nleft: {:?}\nright: {:?}\nallowed diff: {:?}\nactual diff: {:?}\n", $r, $x, $y, $z, d); + panic!( + "\n{}\nleft: {:?}\nright: {:?}\nallowed diff: {:?}\nactual diff: {:?}\n", + $r, $x, $y, $z, d + ); } }}; } @@ -117,7 +120,12 @@ fn transaction_fees_should_be_as_expected_when_nft_is_minted() { format_num(min_multiplier_rust_fees * 10_000 / UNITS, 4), ); - assert_eq_approx!(rust_encoded_fees, expected_rust_encoded_fees, DIFF, "rust fees difference too large"); + assert_eq_approx!( + rust_encoded_fees, + expected_rust_encoded_fees, + DIFF, + "rust fees difference too large" + ); assert_eq_approx!(ui_fees, expected_ui_fees, DIFF, "ui fees difference too large"); }); }