From 201c15eaa1cedd097bc5424cd02d604a3b022fc9 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:34:13 -0700 Subject: [PATCH 01/33] fix --- pallets/subtensor/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 61eb17f4a..9423f75ea 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2219,8 +2219,8 @@ where Err(InvalidTransaction::Call.into()) } } - Some(Call::set_root_weights { netuid, .. }) => { - if Self::check_weights_min_stake(who) { + Some(Call::set_root_weights { netuid, hotkey, .. }) => { + if Self::check_weights_min_stake(hotkey) { let priority: u64 = Self::get_priority_set_weights(who, *netuid); Ok(ValidTransaction { priority, From 7113573645d9a2e97e2bc95490e1ba669c9130c8 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:39:22 -0700 Subject: [PATCH 02/33] fix priority --- pallets/subtensor/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 9423f75ea..6fd979621 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2221,7 +2221,7 @@ where } Some(Call::set_root_weights { netuid, hotkey, .. }) => { if Self::check_weights_min_stake(hotkey) { - let priority: u64 = Self::get_priority_set_weights(who, *netuid); + let priority: u64 = Self::get_priority_set_weights(hotkey, *netuid); Ok(ValidTransaction { priority, longevity: 1, From 7408aca1dcf4ee7f4906f4d4c00ebc5a2811c433 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Thu, 13 Jun 2024 20:17:39 +0400 Subject: [PATCH 03/33] root weight dipatch test --- pallets/subtensor/tests/weights.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pallets/subtensor/tests/weights.rs b/pallets/subtensor/tests/weights.rs index bb7f11908..e07f32edd 100644 --- a/pallets/subtensor/tests/weights.rs +++ b/pallets/subtensor/tests/weights.rs @@ -37,7 +37,28 @@ fn test_set_weights_dispatch_info_ok() { assert_eq!(dispatch_info.pays_fee, Pays::No); }); } +#[test] +#[cfg(not(tarpaulin))] +fn test_set_rootweights_dispatch_info_ok() { + new_test_ext(0).execute_with(|| { + let dests = vec![1, 1]; + let weights = vec![1, 1]; + let netuid: u16 = 1; + let version_key: u64 = 0; + let hotkey: U256 = U256::from(1); // Add the hotkey field + let call = RuntimeCall::SubtensorModule(SubtensorCall::set_root_weights { + netuid, + dests, + weights, + version_key, + hotkey, // Include the hotkey field + }); + let dispatch_info = call.get_dispatch_info(); + assert_eq!(dispatch_info.class, DispatchClass::Normal); + assert_eq!(dispatch_info.pays_fee, Pays::No); + }); +} #[test] fn test_commit_weights_dispatch_info_ok() { new_test_ext(0).execute_with(|| { From e8b03cb4758fa2a8211512848462901accda35ae Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Thu, 13 Jun 2024 23:56:05 +0400 Subject: [PATCH 04/33] chore: bump spec version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index f9f8d599f..2364008fd 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -135,7 +135,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 151, + spec_version: 152, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From b52e2e56cc268cfb01ce2ab330e2566c0a10985b Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 01:12:47 +0400 Subject: [PATCH 05/33] update localnet script --- scripts/localnet.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/localnet.sh b/scripts/localnet.sh index ab564871b..65ca5c0a9 100755 --- a/scripts/localnet.sh +++ b/scripts/localnet.sh @@ -6,9 +6,24 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" # The base directory of the subtensor project BASE_DIR="$SCRIPT_DIR/.." -: "${CHAIN:=local}" -: "${BUILD_BINARY:=1}" -: "${FEATURES:="pow-faucet runtime-benchmarks fast-blocks"}" +# get parameters +# Get the value of fast_blocks from the first argument +fast_blocks=${1:-"True"} + +# Check the value of fast_blocks +if [ "$fast_blocks" == "False" ]; then + # Block of code to execute if fast_blocks is False + echo "fast_blocks is Off" + : "${CHAIN:=local}" + : "${BUILD_BINARY:=1}" + : "${FEATURES:="pow-faucet runtime-benchmarks"}" +else + # Block of code to execute if fast_blocks is not False + echo "fast_blocks is On" + : "${CHAIN:=local}" + : "${BUILD_BINARY:=1}" + : "${FEATURES:="pow-faucet runtime-benchmarks fast-blocks"}" +fi SPEC_PATH="${SCRIPT_DIR}/specs/" FULL_PATH="$SPEC_PATH$CHAIN.json" From 0a5368aed03124d7c52b8254e174610562c3d1b0 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 01:13:31 +0400 Subject: [PATCH 06/33] chore: run ci on every push --- .github/workflows/check-rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index 5b0d1519f..014bf8c0d 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -6,7 +6,7 @@ concurrency: on: push: - branches: [main, devnet-ready, devnet, testnet, finney] + # branches: [main, devnet-ready, devnet, testnet, finney] pull_request: From a2464b89478075372ff3e5298b4f0cfe88513385 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 01:59:53 +0400 Subject: [PATCH 07/33] fix : ci rust --- .github/workflows/check-rust.yml | 49 -------------------------------- 1 file changed, 49 deletions(-) diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index 014bf8c0d..5ca123394 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -160,55 +160,6 @@ jobs: - name: cargo clippy --workspace --all-targets --all-features -- -D warnings run: cargo clippy --workspace --all-targets --all-features -- -D warnings - - cargo-clippy-all-features: - name: cargo clippy --all-features - runs-on: SubtensorCI - strategy: - matrix: - rust-branch: - - nightly-2024-03-05 - rust-target: - - x86_64-unknown-linux-gnu - # - x86_64-apple-darwin - os: - - ubuntu-latest - # - macos-latest - include: - - os: ubuntu-latest - # - os: macos-latest - env: - RELEASE_NAME: development - # RUSTFLAGS: -A warnings - RUSTV: ${{ matrix.rust-branch }} - RUST_BACKTRACE: full - RUST_BIN_DIR: target/${{ matrix.rust-target }} - SKIP_WASM_BUILD: 1 - TARGET: ${{ matrix.rust-target }} - steps: - - name: Check-out repository under $GITHUB_WORKSPACE - uses: actions/checkout@v2 - - - name: Install dependencies - run: | - sudo apt-get update && - sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - - - name: Install Rust ${{ matrix.rust-branch }} - uses: actions-rs/toolchain@v1.0.6 - with: - toolchain: ${{ matrix.rust-branch }} - components: rustfmt, clippy - profile: minimal - - - name: Utilize Shared Rust Cache - uses: Swatinem/rust-cache@v2.2.1 - with: - key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} - - - name: cargo clippy --workspace --all-targets --all-features -- -D warnings - run: cargo clippy --workspace --all-targets --all-features -- -D warnings - # runs cargo test --workspace cargo-test: name: cargo test From dd78f0e168b1e03d58a5b9f37ee032a4c0f05f47 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 02:01:58 +0400 Subject: [PATCH 08/33] chore: uncomment push conditions --- .github/workflows/check-rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index 5ca123394..fe6595e5f 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -6,7 +6,7 @@ concurrency: on: push: - # branches: [main, devnet-ready, devnet, testnet, finney] + branches: [main, devnet-ready, devnet, testnet, finney] pull_request: From 768287584209b00071656737e773f58c8937b458 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 02:05:13 +0400 Subject: [PATCH 09/33] chore: lint --- pallets/subtensor/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 6fd979621..bdecf2c18 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2219,7 +2219,7 @@ where Err(InvalidTransaction::Call.into()) } } - Some(Call::set_root_weights { netuid, hotkey, .. }) => { + Some(Call::set_root_weights { netuid, hotkey, .. }) => { if Self::check_weights_min_stake(hotkey) { let priority: u64 = Self::get_priority_set_weights(hotkey, *netuid); Ok(ValidTransaction { From d237974a7a02411fe5d3995bba8e37c22bcd12c5 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 02:22:05 +0400 Subject: [PATCH 10/33] chore: silence clippy in tests --- pallets/subtensor/tests/block_step.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pallets/subtensor/tests/block_step.rs b/pallets/subtensor/tests/block_step.rs index eb97fe692..bb9893f31 100644 --- a/pallets/subtensor/tests/block_step.rs +++ b/pallets/subtensor/tests/block_step.rs @@ -1,3 +1,4 @@ + mod mock; use frame_support::assert_ok; use frame_system::Config; @@ -869,8 +870,10 @@ fn test_emission_based_on_registration_status() { n as usize ); + let block: u64 = 0; // drain the emission tuples for the subnet with registration on - SubtensorModule::drain_emission(next_block as u64); + #[allow(clippy::fn_to_numeric_cast)] + SubtensorModule::drain_emission( next_block as u64 ); // Turn on registration for the subnet with registration off SubtensorModule::set_network_registration_allowed(netuid_off, true); SubtensorModule::set_network_registration_allowed(netuid_on, false); From f9ff8d104cd4eafb1dd43ea9457d48979f7fe994 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 02:28:32 +0400 Subject: [PATCH 11/33] chore: fmt --- pallets/subtensor/tests/block_step.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pallets/subtensor/tests/block_step.rs b/pallets/subtensor/tests/block_step.rs index bb9893f31..cdf260300 100644 --- a/pallets/subtensor/tests/block_step.rs +++ b/pallets/subtensor/tests/block_step.rs @@ -1,4 +1,3 @@ - mod mock; use frame_support::assert_ok; use frame_system::Config; @@ -873,7 +872,7 @@ fn test_emission_based_on_registration_status() { let block: u64 = 0; // drain the emission tuples for the subnet with registration on #[allow(clippy::fn_to_numeric_cast)] - SubtensorModule::drain_emission( next_block as u64 ); + SubtensorModule::drain_emission(next_block as u64); // Turn on registration for the subnet with registration off SubtensorModule::set_network_registration_allowed(netuid_off, true); SubtensorModule::set_network_registration_allowed(netuid_on, false); From 398b8f5d5aef350e99d7b9e135464c50e2629e55 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 02:54:56 +0400 Subject: [PATCH 12/33] chore: use stable in ci --- .github/workflows/check-rust.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index fe6595e5f..1716bd454 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -71,7 +71,7 @@ jobs: strategy: matrix: rust-branch: - - nightly-2024-03-05 + - stable rust-target: - x86_64-unknown-linux-gnu # - x86_64-apple-darwin @@ -119,7 +119,7 @@ jobs: strategy: matrix: rust-branch: - - nightly-2024-03-05 + - stable rust-target: - x86_64-unknown-linux-gnu # - x86_64-apple-darwin @@ -167,7 +167,7 @@ jobs: strategy: matrix: rust-branch: - - nightly-2024-03-05 + - stable rust-target: - x86_64-unknown-linux-gnu # - x86_64-apple-darwin @@ -216,7 +216,7 @@ jobs: strategy: matrix: rust-branch: - - nightly-2024-03-05 + - stable rust-target: - x86_64-unknown-linux-gnu # - x86_64-apple-darwin @@ -265,7 +265,7 @@ jobs: strategy: matrix: rust-branch: - - nightly-2024-03-05 + - stable rust-target: - x86_64-unknown-linux-gnu # - x86_64-apple-darwin From 2bf5a35764271525a80368f16c755ac83f23c6e3 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 03:08:28 +0400 Subject: [PATCH 13/33] chore: comment out clippy --- .github/workflows/check-rust.yml | 190 +++++++++++++++---------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index 1716bd454..15b779935 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -65,101 +65,101 @@ jobs: - name: cargo fmt run: cargo fmt --check --all - cargo-clippy-default-features: - name: cargo clippy - runs-on: SubtensorCI - strategy: - matrix: - rust-branch: - - stable - rust-target: - - x86_64-unknown-linux-gnu - # - x86_64-apple-darwin - os: - - ubuntu-latest - # - macos-latest - include: - - os: ubuntu-latest - # - os: macos-latest - env: - RELEASE_NAME: development - # RUSTFLAGS: -A warnings - RUSTV: ${{ matrix.rust-branch }} - RUST_BACKTRACE: full - RUST_BIN_DIR: target/${{ matrix.rust-target }} - SKIP_WASM_BUILD: 1 - TARGET: ${{ matrix.rust-target }} - steps: - - name: Check-out repository under $GITHUB_WORKSPACE - uses: actions/checkout@v4 - - - name: Install dependencies - run: | - sudo apt-get update && - sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - - - name: Install Rust ${{ matrix.rust-branch }} - uses: actions-rs/toolchain@v1.0.6 - with: - toolchain: ${{ matrix.rust-branch }} - components: rustfmt, clippy - profile: minimal - - - name: Utilize Shared Rust Cache - uses: Swatinem/rust-cache@v2.2.1 - with: - key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} - - - name: cargo clippy --workspace --all-targets -- -D warnings - run: cargo clippy --workspace --all-targets -- -D warnings - - cargo-clippy-all-features: - name: cargo clippy --all-features - runs-on: SubtensorCI - strategy: - matrix: - rust-branch: - - stable - rust-target: - - x86_64-unknown-linux-gnu - # - x86_64-apple-darwin - os: - - ubuntu-latest - # - macos-latest - include: - - os: ubuntu-latest - # - os: macos-latest - env: - RELEASE_NAME: development - # RUSTFLAGS: -A warnings - RUSTV: ${{ matrix.rust-branch }} - RUST_BACKTRACE: full - RUST_BIN_DIR: target/${{ matrix.rust-target }} - SKIP_WASM_BUILD: 1 - TARGET: ${{ matrix.rust-target }} - steps: - - name: Check-out repository under $GITHUB_WORKSPACE - uses: actions/checkout@v2 - - - name: Install dependencies - run: | - sudo apt-get update && - sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - - - name: Install Rust ${{ matrix.rust-branch }} - uses: actions-rs/toolchain@v1.0.6 - with: - toolchain: ${{ matrix.rust-branch }} - components: rustfmt, clippy - profile: minimal - - - name: Utilize Shared Rust Cache - uses: Swatinem/rust-cache@v2.2.1 - with: - key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} - - - name: cargo clippy --workspace --all-targets --all-features -- -D warnings - run: cargo clippy --workspace --all-targets --all-features -- -D warnings + # cargo-clippy-default-features: + # name: cargo clippy + # runs-on: SubtensorCI + # strategy: + # matrix: + # rust-branch: + # - stable + # rust-target: + # - x86_64-unknown-linux-gnu + # # - x86_64-apple-darwin + # os: + # - ubuntu-latest + # # - macos-latest + # include: + # - os: ubuntu-latest + # # - os: macos-latest + # env: + # RELEASE_NAME: development + # # RUSTFLAGS: -A warnings + # RUSTV: ${{ matrix.rust-branch }} + # RUST_BACKTRACE: full + # RUST_BIN_DIR: target/${{ matrix.rust-target }} + # SKIP_WASM_BUILD: 1 + # TARGET: ${{ matrix.rust-target }} + # steps: + # - name: Check-out repository under $GITHUB_WORKSPACE + # uses: actions/checkout@v4 + + # - name: Install dependencies + # run: | + # sudo apt-get update && + # sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler + + # - name: Install Rust ${{ matrix.rust-branch }} + # uses: actions-rs/toolchain@v1.0.6 + # with: + # toolchain: ${{ matrix.rust-branch }} + # components: rustfmt, clippy + # profile: minimal + + # - name: Utilize Shared Rust Cache + # uses: Swatinem/rust-cache@v2.2.1 + # with: + # key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} + + # - name: cargo clippy --workspace --all-targets -- -D warnings + # run: cargo clippy --workspace --all-targets -- -D warnings + + # cargo-clippy-all-features: + # name: cargo clippy --all-features + # runs-on: SubtensorCI + # strategy: + # matrix: + # rust-branch: + # - stable + # rust-target: + # - x86_64-unknown-linux-gnu + # # - x86_64-apple-darwin + # os: + # - ubuntu-latest + # # - macos-latest + # include: + # - os: ubuntu-latest + # # - os: macos-latest + # env: + # RELEASE_NAME: development + # # RUSTFLAGS: -A warnings + # RUSTV: ${{ matrix.rust-branch }} + # RUST_BACKTRACE: full + # RUST_BIN_DIR: target/${{ matrix.rust-target }} + # SKIP_WASM_BUILD: 1 + # TARGET: ${{ matrix.rust-target }} + # steps: + # - name: Check-out repository under $GITHUB_WORKSPACE + # uses: actions/checkout@v2 + + # - name: Install dependencies + # run: | + # sudo apt-get update && + # sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler + + # - name: Install Rust ${{ matrix.rust-branch }} + # uses: actions-rs/toolchain@v1.0.6 + # with: + # toolchain: ${{ matrix.rust-branch }} + # components: rustfmt, clippy + # profile: minimal + + # - name: Utilize Shared Rust Cache + # uses: Swatinem/rust-cache@v2.2.1 + # with: + # key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} + + # - name: cargo clippy --workspace --all-targets --all-features -- -D warnings + # run: cargo clippy --workspace --all-targets --all-features -- -D warnings # runs cargo test --workspace cargo-test: name: cargo test From fc2bf27f96f29c9184346fda7b73dd7850c0c6b5 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Thu, 13 Jun 2024 21:00:22 -0400 Subject: [PATCH 14/33] add test for root weights transaction validation --- pallets/subtensor/tests/weights.rs | 83 ++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/tests/weights.rs b/pallets/subtensor/tests/weights.rs index e07f32edd..3ac7c20c1 100644 --- a/pallets/subtensor/tests/weights.rs +++ b/pallets/subtensor/tests/weights.rs @@ -1,13 +1,14 @@ mod mock; use frame_support::{ assert_err, assert_ok, - dispatch::{DispatchClass, DispatchResult, GetDispatchInfo, Pays}, + dispatch::{DispatchClass, DispatchInfo, DispatchResult, GetDispatchInfo, Pays}, + pallet_prelude::{InvalidTransaction, TransactionValidityError}, }; use mock::*; -use pallet_subtensor::Error; +use pallet_subtensor::{Error, Owner}; use sp_core::{H256, U256}; use sp_runtime::{ - traits::{BlakeTwo256, Hash}, + traits::{BlakeTwo256, DispatchInfoOf, Hash, SignedExtension}, DispatchError, }; use substrate_fixed::types::I32F32; @@ -59,6 +60,82 @@ fn test_set_rootweights_dispatch_info_ok() { assert_eq!(dispatch_info.pays_fee, Pays::No); }); } + +#[test] +fn test_set_rootweights_validate() { + // Testing the signed extension validate function + // correctly filters this transaction. + + new_test_ext(0).execute_with(|| { + let dests = vec![1, 1]; + let weights = vec![1, 1]; + let netuid: u16 = 1; + let version_key: u64 = 0; + let coldkey = U256::from(0); + let hotkey: U256 = U256::from(1); // Add the hotkey field + assert_ne!(hotkey, coldkey); // Ensure hotkey is NOT the same as coldkey !!! + + let who = coldkey; // The coldkey signs this transaction + + let call = RuntimeCall::SubtensorModule(SubtensorCall::set_root_weights { + netuid, + dests, + weights, + version_key, + hotkey, // Include the hotkey field + }); + + // Create netuid + add_network(netuid, 0, 0); + // Register the hotkey + SubtensorModule::append_neuron(netuid, &hotkey, 0); + Owner::::insert(hotkey, coldkey); + + let min_stake = 500_000_000_000; + // Set the minimum stake + SubtensorModule::set_weights_min_stake(min_stake); + + // Verify stake is less than minimum + assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) < min_stake); + let info: DispatchInfo = + DispatchInfoOf::<::RuntimeCall>::default(); + + let extension = pallet_subtensor::SubtensorSignedExtension::::new(); + // Submit to the signed extension validate function + let result_no_stake = extension.validate(&who, &call.clone().into(), &info, 10); + // Should fail + assert_err!( + // Should get an invalid transaction error + result_no_stake, + TransactionValidityError::Invalid(InvalidTransaction::Call,) + ); + + // Increase the stake to be equal to the minimum + SubtensorModule::increase_stake_on_hotkey_account(&hotkey, min_stake); + + // Verify stake is equal to minimum + assert_eq!( + SubtensorModule::get_total_stake_for_hotkey(&hotkey), + min_stake + ); + + // Submit to the signed extension validate function + let result_min_stake = extension.validate(&who, &call.clone().into(), &info, 10); + // Now the call should pass + assert_ok!(result_min_stake); + + // Try with more stake than minimum + SubtensorModule::increase_stake_on_hotkey_account(&hotkey, 1); + + // Verify stake is more than minimum + assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) > min_stake); + + let result_more_stake = extension.validate(&who, &call.clone().into(), &info, 10); + // The call should still pass + assert_ok!(result_more_stake); + }); +} + #[test] fn test_commit_weights_dispatch_info_ok() { new_test_ext(0).execute_with(|| { From 07cf0e067482726040af512827ea66aea202a620 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Thu, 13 Jun 2024 21:00:48 -0400 Subject: [PATCH 15/33] also test commit/reveal transaction validity check --- pallets/subtensor/tests/weights.rs | 152 +++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/pallets/subtensor/tests/weights.rs b/pallets/subtensor/tests/weights.rs index 3ac7c20c1..419343543 100644 --- a/pallets/subtensor/tests/weights.rs +++ b/pallets/subtensor/tests/weights.rs @@ -160,6 +160,82 @@ fn test_commit_weights_dispatch_info_ok() { }); } +#[test] +fn test_commit_weights_validate() { + // Testing the signed extension validate function + // correctly filters this transaction. + + new_test_ext(0).execute_with(|| { + let dests = vec![1, 1]; + let weights = vec![1, 1]; + let netuid: u16 = 1; + let salt: Vec = vec![1, 2, 3, 4, 5, 6, 7, 8]; + let version_key: u64 = 0; + let coldkey = U256::from(0); + let hotkey: U256 = U256::from(1); // Add the hotkey field + assert_ne!(hotkey, coldkey); // Ensure hotkey is NOT the same as coldkey !!! + + let who = hotkey; // The hotkey signs this transaction + + let commit_hash: H256 = + BlakeTwo256::hash_of(&(hotkey, netuid, dests, weights, salt, version_key)); + + let call = RuntimeCall::SubtensorModule(SubtensorCall::commit_weights { + netuid, + commit_hash, + }); + + // Create netuid + add_network(netuid, 0, 0); + // Register the hotkey + SubtensorModule::append_neuron(netuid, &hotkey, 0); + Owner::::insert(hotkey, coldkey); + + let min_stake = 500_000_000_000; + // Set the minimum stake + SubtensorModule::set_weights_min_stake(min_stake); + + // Verify stake is less than minimum + assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) < min_stake); + let info: DispatchInfo = + DispatchInfoOf::<::RuntimeCall>::default(); + + let extension = pallet_subtensor::SubtensorSignedExtension::::new(); + // Submit to the signed extension validate function + let result_no_stake = extension.validate(&who, &call.clone().into(), &info, 10); + // Should fail + assert_err!( + // Should get an invalid transaction error + result_no_stake, + TransactionValidityError::Invalid(InvalidTransaction::Call,) + ); + + // Increase the stake to be equal to the minimum + SubtensorModule::increase_stake_on_hotkey_account(&hotkey, min_stake); + + // Verify stake is equal to minimum + assert_eq!( + SubtensorModule::get_total_stake_for_hotkey(&hotkey), + min_stake + ); + + // Submit to the signed extension validate function + let result_min_stake = extension.validate(&who, &call.clone().into(), &info, 10); + // Now the call should pass + assert_ok!(result_min_stake); + + // Try with more stake than minimum + SubtensorModule::increase_stake_on_hotkey_account(&hotkey, 1); + + // Verify stake is more than minimum + assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) > min_stake); + + let result_more_stake = extension.validate(&who, &call.clone().into(), &info, 10); + // The call should still pass + assert_ok!(result_more_stake); + }); +} + #[test] fn test_reveal_weights_dispatch_info_ok() { new_test_ext(0).execute_with(|| { @@ -183,6 +259,82 @@ fn test_reveal_weights_dispatch_info_ok() { }); } +#[test] +fn test_reveal_weights_validate() { + // Testing the signed extension validate function + // correctly filters this transaction. + + new_test_ext(0).execute_with(|| { + let dests = vec![1, 1]; + let weights = vec![1, 1]; + let netuid: u16 = 1; + let salt: Vec = vec![1, 2, 3, 4, 5, 6, 7, 8]; + let version_key: u64 = 0; + let coldkey = U256::from(0); + let hotkey: U256 = U256::from(1); // Add the hotkey field + assert_ne!(hotkey, coldkey); // Ensure hotkey is NOT the same as coldkey !!! + + let who = hotkey; // The hotkey signs this transaction + + let call = RuntimeCall::SubtensorModule(SubtensorCall::reveal_weights { + netuid, + uids: dests, + values: weights, + salt, + version_key, + }); + + // Create netuid + add_network(netuid, 0, 0); + // Register the hotkey + SubtensorModule::append_neuron(netuid, &hotkey, 0); + Owner::::insert(hotkey, coldkey); + + let min_stake = 500_000_000_000; + // Set the minimum stake + SubtensorModule::set_weights_min_stake(min_stake); + + // Verify stake is less than minimum + assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) < min_stake); + let info: DispatchInfo = + DispatchInfoOf::<::RuntimeCall>::default(); + + let extension = pallet_subtensor::SubtensorSignedExtension::::new(); + // Submit to the signed extension validate function + let result_no_stake = extension.validate(&who, &call.clone().into(), &info, 10); + // Should fail + assert_err!( + // Should get an invalid transaction error + result_no_stake, + TransactionValidityError::Invalid(InvalidTransaction::Call,) + ); + + // Increase the stake to be equal to the minimum + SubtensorModule::increase_stake_on_hotkey_account(&hotkey, min_stake); + + // Verify stake is equal to minimum + assert_eq!( + SubtensorModule::get_total_stake_for_hotkey(&hotkey), + min_stake + ); + + // Submit to the signed extension validate function + let result_min_stake = extension.validate(&who, &call.clone().into(), &info, 10); + // Now the call should pass + assert_ok!(result_min_stake); + + // Try with more stake than minimum + SubtensorModule::increase_stake_on_hotkey_account(&hotkey, 1); + + // Verify stake is more than minimum + assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) > min_stake); + + let result_more_stake = extension.validate(&who, &call.clone().into(), &info, 10); + // The call should still pass + assert_ok!(result_more_stake); + }); +} + #[test] fn test_set_weights_is_root_error() { new_test_ext(0).execute_with(|| { From e42c10ad96cb9abafd14058c5ba72c98c02694e8 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 11:45:58 +0400 Subject: [PATCH 16/33] uncomment ci --- .github/workflows/check-rust.yml | 190 +++++++++++++++---------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index 15b779935..1716bd454 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -65,101 +65,101 @@ jobs: - name: cargo fmt run: cargo fmt --check --all - # cargo-clippy-default-features: - # name: cargo clippy - # runs-on: SubtensorCI - # strategy: - # matrix: - # rust-branch: - # - stable - # rust-target: - # - x86_64-unknown-linux-gnu - # # - x86_64-apple-darwin - # os: - # - ubuntu-latest - # # - macos-latest - # include: - # - os: ubuntu-latest - # # - os: macos-latest - # env: - # RELEASE_NAME: development - # # RUSTFLAGS: -A warnings - # RUSTV: ${{ matrix.rust-branch }} - # RUST_BACKTRACE: full - # RUST_BIN_DIR: target/${{ matrix.rust-target }} - # SKIP_WASM_BUILD: 1 - # TARGET: ${{ matrix.rust-target }} - # steps: - # - name: Check-out repository under $GITHUB_WORKSPACE - # uses: actions/checkout@v4 - - # - name: Install dependencies - # run: | - # sudo apt-get update && - # sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - - # - name: Install Rust ${{ matrix.rust-branch }} - # uses: actions-rs/toolchain@v1.0.6 - # with: - # toolchain: ${{ matrix.rust-branch }} - # components: rustfmt, clippy - # profile: minimal - - # - name: Utilize Shared Rust Cache - # uses: Swatinem/rust-cache@v2.2.1 - # with: - # key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} - - # - name: cargo clippy --workspace --all-targets -- -D warnings - # run: cargo clippy --workspace --all-targets -- -D warnings - - # cargo-clippy-all-features: - # name: cargo clippy --all-features - # runs-on: SubtensorCI - # strategy: - # matrix: - # rust-branch: - # - stable - # rust-target: - # - x86_64-unknown-linux-gnu - # # - x86_64-apple-darwin - # os: - # - ubuntu-latest - # # - macos-latest - # include: - # - os: ubuntu-latest - # # - os: macos-latest - # env: - # RELEASE_NAME: development - # # RUSTFLAGS: -A warnings - # RUSTV: ${{ matrix.rust-branch }} - # RUST_BACKTRACE: full - # RUST_BIN_DIR: target/${{ matrix.rust-target }} - # SKIP_WASM_BUILD: 1 - # TARGET: ${{ matrix.rust-target }} - # steps: - # - name: Check-out repository under $GITHUB_WORKSPACE - # uses: actions/checkout@v2 - - # - name: Install dependencies - # run: | - # sudo apt-get update && - # sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - - # - name: Install Rust ${{ matrix.rust-branch }} - # uses: actions-rs/toolchain@v1.0.6 - # with: - # toolchain: ${{ matrix.rust-branch }} - # components: rustfmt, clippy - # profile: minimal - - # - name: Utilize Shared Rust Cache - # uses: Swatinem/rust-cache@v2.2.1 - # with: - # key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} - - # - name: cargo clippy --workspace --all-targets --all-features -- -D warnings - # run: cargo clippy --workspace --all-targets --all-features -- -D warnings + cargo-clippy-default-features: + name: cargo clippy + runs-on: SubtensorCI + strategy: + matrix: + rust-branch: + - stable + rust-target: + - x86_64-unknown-linux-gnu + # - x86_64-apple-darwin + os: + - ubuntu-latest + # - macos-latest + include: + - os: ubuntu-latest + # - os: macos-latest + env: + RELEASE_NAME: development + # RUSTFLAGS: -A warnings + RUSTV: ${{ matrix.rust-branch }} + RUST_BACKTRACE: full + RUST_BIN_DIR: target/${{ matrix.rust-target }} + SKIP_WASM_BUILD: 1 + TARGET: ${{ matrix.rust-target }} + steps: + - name: Check-out repository under $GITHUB_WORKSPACE + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update && + sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler + + - name: Install Rust ${{ matrix.rust-branch }} + uses: actions-rs/toolchain@v1.0.6 + with: + toolchain: ${{ matrix.rust-branch }} + components: rustfmt, clippy + profile: minimal + + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2.2.1 + with: + key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} + + - name: cargo clippy --workspace --all-targets -- -D warnings + run: cargo clippy --workspace --all-targets -- -D warnings + + cargo-clippy-all-features: + name: cargo clippy --all-features + runs-on: SubtensorCI + strategy: + matrix: + rust-branch: + - stable + rust-target: + - x86_64-unknown-linux-gnu + # - x86_64-apple-darwin + os: + - ubuntu-latest + # - macos-latest + include: + - os: ubuntu-latest + # - os: macos-latest + env: + RELEASE_NAME: development + # RUSTFLAGS: -A warnings + RUSTV: ${{ matrix.rust-branch }} + RUST_BACKTRACE: full + RUST_BIN_DIR: target/${{ matrix.rust-target }} + SKIP_WASM_BUILD: 1 + TARGET: ${{ matrix.rust-target }} + steps: + - name: Check-out repository under $GITHUB_WORKSPACE + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt-get update && + sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler + + - name: Install Rust ${{ matrix.rust-branch }} + uses: actions-rs/toolchain@v1.0.6 + with: + toolchain: ${{ matrix.rust-branch }} + components: rustfmt, clippy + profile: minimal + + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2.2.1 + with: + key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} + + - name: cargo clippy --workspace --all-targets --all-features -- -D warnings + run: cargo clippy --workspace --all-targets --all-features -- -D warnings # runs cargo test --workspace cargo-test: name: cargo test From c638e597b84d70417457fc06e5f910810c400f31 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 12:00:32 +0400 Subject: [PATCH 17/33] chore: clippy --- pallets/subtensor/tests/weights.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pallets/subtensor/tests/weights.rs b/pallets/subtensor/tests/weights.rs index 419343543..5cd3bf7c2 100644 --- a/pallets/subtensor/tests/weights.rs +++ b/pallets/subtensor/tests/weights.rs @@ -102,7 +102,7 @@ fn test_set_rootweights_validate() { let extension = pallet_subtensor::SubtensorSignedExtension::::new(); // Submit to the signed extension validate function - let result_no_stake = extension.validate(&who, &call.clone().into(), &info, 10); + let result_no_stake = extension.validate(&who, &call.clone(), &info, 10); // Should fail assert_err!( // Should get an invalid transaction error @@ -120,7 +120,7 @@ fn test_set_rootweights_validate() { ); // Submit to the signed extension validate function - let result_min_stake = extension.validate(&who, &call.clone().into(), &info, 10); + let result_min_stake = extension.validate(&who, &call.clone(), &info, 10); // Now the call should pass assert_ok!(result_min_stake); @@ -130,7 +130,7 @@ fn test_set_rootweights_validate() { // Verify stake is more than minimum assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) > min_stake); - let result_more_stake = extension.validate(&who, &call.clone().into(), &info, 10); + let result_more_stake = extension.validate(&who, &call.clone(), &info, 10); // The call should still pass assert_ok!(result_more_stake); }); @@ -202,7 +202,7 @@ fn test_commit_weights_validate() { let extension = pallet_subtensor::SubtensorSignedExtension::::new(); // Submit to the signed extension validate function - let result_no_stake = extension.validate(&who, &call.clone().into(), &info, 10); + let result_no_stake = extension.validate(&who, &call.clone(), &info, 10); // Should fail assert_err!( // Should get an invalid transaction error @@ -220,7 +220,7 @@ fn test_commit_weights_validate() { ); // Submit to the signed extension validate function - let result_min_stake = extension.validate(&who, &call.clone().into(), &info, 10); + let result_min_stake = extension.validate(&who, &call.clone(), &info, 10); // Now the call should pass assert_ok!(result_min_stake); @@ -230,7 +230,7 @@ fn test_commit_weights_validate() { // Verify stake is more than minimum assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) > min_stake); - let result_more_stake = extension.validate(&who, &call.clone().into(), &info, 10); + let result_more_stake = extension.validate(&who, &call.clone(), &info, 10); // The call should still pass assert_ok!(result_more_stake); }); @@ -301,7 +301,7 @@ fn test_reveal_weights_validate() { let extension = pallet_subtensor::SubtensorSignedExtension::::new(); // Submit to the signed extension validate function - let result_no_stake = extension.validate(&who, &call.clone().into(), &info, 10); + let result_no_stake = extension.validate(&who, &call.clone(), &info, 10); // Should fail assert_err!( // Should get an invalid transaction error @@ -319,7 +319,7 @@ fn test_reveal_weights_validate() { ); // Submit to the signed extension validate function - let result_min_stake = extension.validate(&who, &call.clone().into(), &info, 10); + let result_min_stake = extension.validate(&who, &call.clone(), &info, 10); // Now the call should pass assert_ok!(result_min_stake); @@ -329,7 +329,7 @@ fn test_reveal_weights_validate() { // Verify stake is more than minimum assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) > min_stake); - let result_more_stake = extension.validate(&who, &call.clone().into(), &info, 10); + let result_more_stake = extension.validate(&who, &call.clone(), &info, 10); // The call should still pass assert_ok!(result_more_stake); }); From 98ed1522cd92c06e9ae0c3bc052940df00db9157 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 14 Jun 2024 16:36:32 +0800 Subject: [PATCH 18/33] fix clippy --- pallets/commitments/src/lib.rs | 2 +- pallets/subtensor/src/root.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 6e252ecea..6ac70c8cd 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -234,7 +234,7 @@ where pub fn get_priority_vanilla() -> u64 { // Return high priority so that every extrinsic except set_weights function will // have a higher priority than the set_weights call - u64::max_value() + u64::MAX() } } diff --git a/pallets/subtensor/src/root.rs b/pallets/subtensor/src/root.rs index 42c783c3b..ac3ae3579 100644 --- a/pallets/subtensor/src/root.rs +++ b/pallets/subtensor/src/root.rs @@ -1009,12 +1009,12 @@ impl Pallet { NetworkRegisteredAt::::remove(netuid); // --- 8. Remove incentive mechanism memory. - let _ = Uids::::clear_prefix(netuid, u32::max_value(), None); - let _ = Keys::::clear_prefix(netuid, u32::max_value(), None); - let _ = Bonds::::clear_prefix(netuid, u32::max_value(), None); + let _ = Uids::::clear_prefix(netuid, u32::MAX(), None); + let _ = Keys::::clear_prefix(netuid, u32::MAX(), None); + let _ = Bonds::::clear_prefix(netuid, u32::MAX(), None); // --- 8. Removes the weights for this subnet (do not remove). - let _ = Weights::::clear_prefix(netuid, u32::max_value(), None); + let _ = Weights::::clear_prefix(netuid, u32::MAX(), None); // --- 9. Iterate over stored weights and fill the matrix. for (uid_i, weights_i) in From 673d619bbdb7724255342400c8b09e5198f66f78 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 14 Jun 2024 16:38:16 +0800 Subject: [PATCH 19/33] fix clippy --- pallets/commitments/src/lib.rs | 2 +- pallets/subtensor/src/root.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 6ac70c8cd..d9fbc6fcf 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -234,7 +234,7 @@ where pub fn get_priority_vanilla() -> u64 { // Return high priority so that every extrinsic except set_weights function will // have a higher priority than the set_weights call - u64::MAX() + u64::MAX } } diff --git a/pallets/subtensor/src/root.rs b/pallets/subtensor/src/root.rs index ac3ae3579..a09957924 100644 --- a/pallets/subtensor/src/root.rs +++ b/pallets/subtensor/src/root.rs @@ -1009,12 +1009,12 @@ impl Pallet { NetworkRegisteredAt::::remove(netuid); // --- 8. Remove incentive mechanism memory. - let _ = Uids::::clear_prefix(netuid, u32::MAX(), None); - let _ = Keys::::clear_prefix(netuid, u32::MAX(), None); - let _ = Bonds::::clear_prefix(netuid, u32::MAX(), None); + let _ = Uids::::clear_prefix(netuid, u32::MAX, None); + let _ = Keys::::clear_prefix(netuid, u32::MAX, None); + let _ = Bonds::::clear_prefix(netuid, u32::MAX, None); // --- 8. Removes the weights for this subnet (do not remove). - let _ = Weights::::clear_prefix(netuid, u32::MAX(), None); + let _ = Weights::::clear_prefix(netuid, u32::MAX, None); // --- 9. Iterate over stored weights and fill the matrix. for (uid_i, weights_i) in From 3656126e591a488af1ac449cac0c49f7e2f7e989 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 14 Jun 2024 16:45:08 +0800 Subject: [PATCH 20/33] fix clippy --- pallets/subtensor/src/lib.rs | 4 ++-- pallets/subtensor/src/weights.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index bdecf2c18..bcd78a6fa 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2063,7 +2063,7 @@ pub mod pallet { let current_block_number: u64 = Self::get_current_block_as_u64(); let default_priority: u64 = current_block_number - Self::get_last_update_for_uid(netuid, uid); - return default_priority + u32::max_value() as u64; + return default_priority + u32::MAX as u64; } 0 } @@ -2141,7 +2141,7 @@ where pub fn get_priority_vanilla() -> u64 { // Return high priority so that every extrinsic except set_weights function will // have a higher priority than the set_weights call - u64::max_value() + u64::MAX } pub fn get_priority_set_weights(who: &T::AccountId, netuid: u16) -> u64 { diff --git a/pallets/subtensor/src/weights.rs b/pallets/subtensor/src/weights.rs index 72c811f80..548bc30af 100644 --- a/pallets/subtensor/src/weights.rs +++ b/pallets/subtensor/src/weights.rs @@ -405,7 +405,7 @@ impl Pallet { return weights; } weights.iter_mut().for_each(|x| { - *x = (*x as u64 * u16::max_value() as u64 / sum) as u16; + *x = (*x as u64 * u16::MAX as u64 / sum) as u16; }); weights } From 530b05db6926b850cdd4912ab4a8d3e165011e0a Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 14 Jun 2024 16:51:41 +0800 Subject: [PATCH 21/33] fix clippy --- pallets/subtensor/tests/epoch.rs | 2 +- runtime/src/check_nonce.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/tests/epoch.rs b/pallets/subtensor/tests/epoch.rs index 0bfd11ba4..fe247fd32 100644 --- a/pallets/subtensor/tests/epoch.rs +++ b/pallets/subtensor/tests/epoch.rs @@ -38,7 +38,7 @@ fn normalize_weights(mut weights: Vec) -> Vec { return weights; } weights.iter_mut().for_each(|x| { - *x = (*x as u64 * u16::max_value() as u64 / sum) as u16; + *x = (*x as u64 * u16::MAX as u64 / sum) as u16; }); weights } diff --git a/runtime/src/check_nonce.rs b/runtime/src/check_nonce.rs index e6e992ccf..d9948f9b6 100644 --- a/runtime/src/check_nonce.rs +++ b/runtime/src/check_nonce.rs @@ -120,7 +120,7 @@ where priority: 0, requires, provides, - longevity: TransactionLongevity::max_value(), + longevity: TransactionLongevity::MAX, propagate: true, }) } From 7173614f66e7a2831c14caf1825f3d5c827607f2 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 14 Jun 2024 16:53:29 +0800 Subject: [PATCH 22/33] fix clippy --- pallets/registry/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/registry/src/lib.rs b/pallets/registry/src/lib.rs index 026c03260..e32b1fc5f 100644 --- a/pallets/registry/src/lib.rs +++ b/pallets/registry/src/lib.rs @@ -3,7 +3,6 @@ #[cfg(test)] mod tests; -#[cfg(feature = "runtime-benchmarks")] mod benchmarking; pub mod types; pub mod weights; From 8445ab7dd2aaa15659552b40456cf356b6b0ac9e Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 14 Jun 2024 17:29:18 +0800 Subject: [PATCH 23/33] fix clippy --- node/src/rpc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 511fb74c3..ff07467f9 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -42,7 +42,7 @@ pub struct FullDeps { /// Grandpa block import setup. pub grandpa: GrandpaDeps, /// Backend used by the node. - pub backend: Arc, + pub _backend: Arc, } /// Instantiate all full RPC extensions. From cecdf02f2a05e8c1a5c18ead390db8e5d75782fb Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 14 Jun 2024 17:32:47 +0800 Subject: [PATCH 24/33] fix clippy --- node/src/rpc.rs | 2 +- node/src/service.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/src/rpc.rs b/node/src/rpc.rs index ff07467f9..54f82447f 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -74,7 +74,7 @@ where pool, deny_unsafe, grandpa, - backend: _, + _backend: _, } = deps; // Custom RPC methods for Paratensor diff --git a/node/src/service.rs b/node/src/service.rs index 284edb52a..9a19ae354 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -266,7 +266,7 @@ pub fn new_full(config: Configuration) -> Result { subscription_executor: subscription_executor.clone(), finality_provider: finality_proof_provider.clone(), }, - backend: rpc_backend.clone(), + _backend: rpc_backend.clone(), }; crate::rpc::create_full(deps).map_err(Into::into) }, From edce0dd59ddac6503db342c279e311d5845f3831 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 14 Jun 2024 17:44:07 +0800 Subject: [PATCH 25/33] fix clippy --- pallets/subtensor/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index bcd78a6fa..b590781f5 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -29,7 +29,6 @@ use sp_std::marker::PhantomData; // ============================ // ==== Benchmark Imports ===== // ============================ -#[cfg(feature = "runtime-benchmarks")] mod benchmarks; // ========================= From 2b07546f022c5f4cbd03af3f2faf348b106a9908 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 14 Jun 2024 17:45:02 +0800 Subject: [PATCH 26/33] fix clippy --- pallets/commitments/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index d9fbc6fcf..dec9177d2 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -1,11 +1,9 @@ #![cfg_attr(not(feature = "std"), no_std)] +mod benchmarking; #[cfg(test)] mod tests; -#[cfg(feature = "runtime-benchmarks")] -mod benchmarking; - pub mod types; pub mod weights; From 6cccfb58d7833162b1690b16de5bb4835c2c7725 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 14 Jun 2024 17:52:34 +0800 Subject: [PATCH 27/33] fix clippy --- pallets/admin-utils/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 61c29efff..47799f30d 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -7,7 +7,6 @@ pub use weights::WeightInfo; use sp_runtime::DispatchError; use sp_runtime::{traits::Member, RuntimeAppPublic}; -#[cfg(feature = "runtime-benchmarks")] mod benchmarking; #[deny(missing_docs)] From ef4b241a0718796fa71002a436852291df0d208b Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 17:52:24 +0400 Subject: [PATCH 28/33] fix: fast blocks false --- .github/workflows/e2e-bittensor-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-bittensor-tests.yml b/.github/workflows/e2e-bittensor-tests.yml index 773edb566..0ae492805 100644 --- a/.github/workflows/e2e-bittensor-tests.yml +++ b/.github/workflows/e2e-bittensor-tests.yml @@ -82,4 +82,4 @@ jobs: run: | pwd ls - LOCALNET_SH_PATH="${{ github.workspace }}/scripts/localnet.sh" pytest tests/e2e_tests/ -s + LOCALNET_SH_PATH="${{ github.workspace }}/scripts/localnet.sh False" pytest tests/e2e_tests/ -s From eba20c2050fdc62c918c0f0ab40a450461dc64e5 Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Fri, 14 Jun 2024 20:09:40 +0400 Subject: [PATCH 29/33] chore: remove hard coded false --- .github/workflows/e2e-bittensor-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-bittensor-tests.yml b/.github/workflows/e2e-bittensor-tests.yml index 0ae492805..773edb566 100644 --- a/.github/workflows/e2e-bittensor-tests.yml +++ b/.github/workflows/e2e-bittensor-tests.yml @@ -82,4 +82,4 @@ jobs: run: | pwd ls - LOCALNET_SH_PATH="${{ github.workspace }}/scripts/localnet.sh False" pytest tests/e2e_tests/ -s + LOCALNET_SH_PATH="${{ github.workspace }}/scripts/localnet.sh" pytest tests/e2e_tests/ -s From d16970ad308078c9f84ba6115c723ecfecbafad8 Mon Sep 17 00:00:00 2001 From: distributedstatemachine <112424909+distributedstatemachine@users.noreply.github.com> Date: Fri, 14 Jun 2024 20:45:27 +0400 Subject: [PATCH 30/33] Update pallets/subtensor/tests/block_step.rs Co-authored-by: Cameron Fairchild --- pallets/subtensor/tests/block_step.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/tests/block_step.rs b/pallets/subtensor/tests/block_step.rs index cdf260300..cbc2fe630 100644 --- a/pallets/subtensor/tests/block_step.rs +++ b/pallets/subtensor/tests/block_step.rs @@ -872,7 +872,7 @@ fn test_emission_based_on_registration_status() { let block: u64 = 0; // drain the emission tuples for the subnet with registration on #[allow(clippy::fn_to_numeric_cast)] - SubtensorModule::drain_emission(next_block as u64); + SubtensorModule::drain_emission(block as u64); // Turn on registration for the subnet with registration off SubtensorModule::set_network_registration_allowed(netuid_off, true); SubtensorModule::set_network_registration_allowed(netuid_on, false); From 5a40b75c6c944464a16e8002a05667e03eebd131 Mon Sep 17 00:00:00 2001 From: distributedstatemachine <112424909+distributedstatemachine@users.noreply.github.com> Date: Fri, 14 Jun 2024 20:58:17 +0400 Subject: [PATCH 31/33] Update pallets/subtensor/tests/block_step.rs Co-authored-by: Cameron Fairchild --- pallets/subtensor/tests/block_step.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/subtensor/tests/block_step.rs b/pallets/subtensor/tests/block_step.rs index cbc2fe630..660fc7c52 100644 --- a/pallets/subtensor/tests/block_step.rs +++ b/pallets/subtensor/tests/block_step.rs @@ -871,7 +871,6 @@ fn test_emission_based_on_registration_status() { let block: u64 = 0; // drain the emission tuples for the subnet with registration on - #[allow(clippy::fn_to_numeric_cast)] SubtensorModule::drain_emission(block as u64); // Turn on registration for the subnet with registration off SubtensorModule::set_network_registration_allowed(netuid_off, true); From 87e47c5b0d319d388ef1459ae99d6ada2106f817 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Fri, 14 Jun 2024 12:59:39 -0400 Subject: [PATCH 32/33] clippy: just block --- pallets/subtensor/tests/block_step.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/tests/block_step.rs b/pallets/subtensor/tests/block_step.rs index 660fc7c52..5df173906 100644 --- a/pallets/subtensor/tests/block_step.rs +++ b/pallets/subtensor/tests/block_step.rs @@ -871,7 +871,7 @@ fn test_emission_based_on_registration_status() { let block: u64 = 0; // drain the emission tuples for the subnet with registration on - SubtensorModule::drain_emission(block as u64); + SubtensorModule::drain_emission(block); // Turn on registration for the subnet with registration off SubtensorModule::set_network_registration_allowed(netuid_off, true); SubtensorModule::set_network_registration_allowed(netuid_on, false); From 65423b4cdc0d137c55d921e91fb2a437d94c0e82 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 14 Jun 2024 18:12:10 -0400 Subject: [PATCH 33/33] only apply devnet-pass/testnet-pass label check to PRs on main --- .github/workflows/devnet-labels.yml | 1 + .github/workflows/testnet-labels.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/devnet-labels.yml b/.github/workflows/devnet-labels.yml index 0fe409d1d..85d9e7eed 100644 --- a/.github/workflows/devnet-labels.yml +++ b/.github/workflows/devnet-labels.yml @@ -2,6 +2,7 @@ name: Tested on Devnet on: pull_request: types: [opened, labeled, unlabeled, synchronize] + branches: [main] jobs: check-labels: runs-on: ubuntu-latest diff --git a/.github/workflows/testnet-labels.yml b/.github/workflows/testnet-labels.yml index f471f9991..b4aabd958 100644 --- a/.github/workflows/testnet-labels.yml +++ b/.github/workflows/testnet-labels.yml @@ -2,6 +2,7 @@ name: Tested on Testnet on: pull_request: types: [opened, labeled, unlabeled, synchronize] + branches: [main] jobs: check-labels: runs-on: ubuntu-latest