From 105619872bd49db504a72e336d9a603777461a2a Mon Sep 17 00:00:00 2001 From: Hector Bulgarini Date: Wed, 16 Aug 2023 12:24:15 +0200 Subject: [PATCH] Fixing benchmarks and removing cargo order --- .github/workflows/rust.yml | 2 -- Cargo.toml | 5 +++-- rpc/runtime-api/Cargo.toml | 2 +- src/benchmarking.rs | 14 +++++++------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a173524..919407f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -30,7 +30,5 @@ jobs: - uses: actions/checkout@v1 - run: > cargo fmt --all -- --check - && cargo install cargo-sort - && cargo sort --workspace --check --grouped && cargo clippy --workspace --tests -- -Dwarnings && cargo test --workspace --features runtime-benchmarks diff --git a/Cargo.toml b/Cargo.toml index c2fd068..f26f0f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,8 +19,9 @@ frame-system = { default-features = false, git = "https://github.com/paritytech/ pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } + [dev-dependencies] pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } @@ -33,8 +34,8 @@ default = ["std"] std = [ "codec/std", "scale-info/std", - "sp-std/std", "sp-runtime/std", + "sp-std/std", "frame-benchmarking/std", "frame-support/std", "frame-system/std", diff --git a/rpc/runtime-api/Cargo.toml b/rpc/runtime-api/Cargo.toml index a596683..471cde4 100644 --- a/rpc/runtime-api/Cargo.toml +++ b/rpc/runtime-api/Cargo.toml @@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -pallet-dex = { version = "0.0.2", default-features = false, path = "../.." } +pallet-dex = { version = "0.0.1", default-features = false, path = "../.." } sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } diff --git a/src/benchmarking.rs b/src/benchmarking.rs index 0d04e19..149a08b 100644 --- a/src/benchmarking.rs +++ b/src/benchmarking.rs @@ -16,7 +16,7 @@ const LIQ_TOKEN_B: u32 = 12; fn prepare_exchange(asset_id: u32, liquidity_token_id: u32) -> DispatchResult where - T: frame_system::Config, + frame_system::pallet_prelude::BlockNumberFor: From, T: Config, T::Currency: Currency, Balance = u128>, T::Assets: Create> + Mutate>, @@ -38,7 +38,7 @@ where benchmarks! { where_clause { where - T: frame_system::Config, + frame_system::pallet_prelude::BlockNumberFor: From, T: Config, T::Currency: Currency, Balance = u128>, T::Assets: Create> + Mutate>, @@ -58,7 +58,7 @@ benchmarks! { prepare_exchange::(ASSET_A, LIQ_TOKEN_A)?; let caller: T::AccountId = whitelisted_caller(); // Token amount is 2, not 1 because of the `+1` in liquidity added formula - }: _(RawOrigin::Signed(caller), ASSET_A, 1, 1, 2, 1) + }: _(RawOrigin::Signed(caller), ASSET_A, 1, 1, 2, 1.into()) verify { let exchange = Pallet::::exchanges(ASSET_A).unwrap(); assert_eq!(exchange.currency_reserve, INIT_LIQUIDITY + 1); @@ -68,7 +68,7 @@ benchmarks! { remove_liquidity { prepare_exchange::(ASSET_A, LIQ_TOKEN_A)?; let caller: T::AccountId = whitelisted_caller(); - }: _(RawOrigin::Signed(caller), ASSET_A, 1, 1, 1, 1) + }: _(RawOrigin::Signed(caller), ASSET_A, 1, 1, 1, 1.into()) verify { let exchange = Pallet::::exchanges(ASSET_A).unwrap(); assert_eq!(exchange.currency_reserve, INIT_LIQUIDITY - 1); @@ -80,7 +80,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let input_amount = 500; let min_output = 498; // sold amount (500) - provider fee (0.3%) should be ~498 - }: _(RawOrigin::Signed(caller), ASSET_A, TradeAmount::FixedInput{input_amount, min_output}, 1, None) + }: _(RawOrigin::Signed(caller), ASSET_A, TradeAmount::FixedInput{input_amount, min_output}, 1.into(), None) verify { let exchange = Pallet::::exchanges(ASSET_A).unwrap(); assert_eq!(exchange.currency_reserve, INIT_LIQUIDITY + input_amount); @@ -92,7 +92,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let input_amount = 500; let min_output = 498; // sold amount (500) - provider fee (0.3%) should be ~498 - }: _(RawOrigin::Signed(caller), ASSET_A, TradeAmount::FixedInput{input_amount, min_output}, 1, None) + }: _(RawOrigin::Signed(caller), ASSET_A, TradeAmount::FixedInput{input_amount, min_output}, 1.into(), None) verify { let exchange = Pallet::::exchanges(ASSET_A).unwrap(); assert_eq!(exchange.currency_reserve, INIT_LIQUIDITY - min_output); @@ -106,7 +106,7 @@ benchmarks! { let input_amount = 500; let currency_amount = 498; // sold amount (500) - provider fee (0.3%) should be ~498 let min_output = 496; // currency amount (498) - provider fee (0.3%) should be ~496 - }: _(RawOrigin::Signed(caller), ASSET_A, ASSET_B, TradeAmount::FixedInput{input_amount, min_output}, 1, None) + }: _(RawOrigin::Signed(caller), ASSET_A, ASSET_B, TradeAmount::FixedInput{input_amount, min_output}, 1.into(), None) verify { let exchange_a = Pallet::::exchanges(ASSET_A).unwrap(); assert_eq!(exchange_a.currency_reserve, INIT_LIQUIDITY - currency_amount);