From 5073ade602c367471f5124329b9d7ccf8e972d69 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 24 Feb 2025 17:40:00 -0500 Subject: [PATCH] mainnet deploy 2/24/2025 (#1340) * fix migration test * cargo fmt * fix root * cargo fmt * add moving price to metagraph * use correct min burn init (#1265) * use correct min brun init * fmt * no into * no into 2 * bump spec * cargo update to fix cargo audit vulnerabilities * bump spec version * moving price init from emission * cargo fmt * bump spec version * commit Cargo.lock * cargo clippy * cargo fmt * DefaultMinimumPoolLiquidity and tempos in rao migration * update readme of support of M series macs * bump runtime version * add tao_emission to stakeinfo runtime * Refactor staking and neuron precompile with precompile-utils * remove call from coinbase. already in block_step * add negation for pow-reg-allowed * only root can set min pow diff * oops * dont let ck-in-swap-sched move any stake/register * add tests for validation filter * add transfer stake to call nontransfer proxy filter * also add proxy filters for new calls * update staking priority * bump spec * use get_priority_staking for all stake operations * bump spec * clippy * Remove ownership check from transition stake validation * Fix number conversion issues in staking precompile * max the price for EMA calc at 1.0 * uncommitted lockfile change * bump spec version * fix merge conflicts * add CI action that requires clean merges between all named branches * Refactor neuron precompil - introduce PrecompileHandle and Precompile trait extensions * fix * fixes * try again * fix again * fix * fix * stop needless wasting of CI hours with on push triggers we don't need * Refactor metagraph precompile * fix try runtime endpoints * fix * provide an identity for github action to prevent failure * bump CI * only run non-devnet try runtime if we are targeting devnet/testnet/main * tweak * Add serve_axon extrinsic validation * Bump spec version * Check IP validity in serve_axon validation first * make set diff only root * add test for set diff no owner * add migration for min diff * bump spec * only allow top-stake SN owner hk to stay immune * add tests * only allow replace non-top-stake owner hk * bump spec * add tests using SubnetOwnerHotkey * add impl for replace neuron * add swap test * add neuron prune impl * add swap hotkey impl * clippy * clippy * mistake in test * add some tests * add stake ext test * add move_stake tests * cargo lock * bump spec * clpy * use bool return type * clpy * add higher liquidity on mvoe stake tests * Refactor subnet precompile * Reformat * Update spec version * Fix commit_hash type in Neuron::commit_weights precompile * Prevent precision errors in share pool * Fix unstaking 99.999% and add tests * Fix event and logging in unstake_from_subnet * only update tx rate limit *after* ensure * add test and sn-owner-chk impl * Fix build * use is ok and * Bump spec version * Update primitives/share-pool/src/lib.rs Co-authored-by: Cameron Fairchild * Update pallets/subtensor/src/tests/staking.rs Co-authored-by: Cameron Fairchild * Remove unused variable * Add test_get_shares_per_update * try it again * use latest rust-cache version * improve spec version check cache performance * try busting cache * it worked :fire: * use better rust cache throughout CI + clean up CI * install rust nightly for cargo fmt * whoops * fix * try re-enabling finney try truntime * Update pallets/subtensor/src/tests/staking.rs Co-authored-by: Cameron Fairchild * fix * add get value using current_shares arg * make delegate info useful again * return different format for get delegated * remove CODEOWNERS file so we can do green merges * bump CI * Set initial tempo to 360 * set equal in mock * add test for weights rate limit v tempo * make fields pub for testing * sub out root divs to get alpha divs * bump spec version to 241 * const fixes * cargo clippy * Add dest hotkey check and test * Remove the commented test * Bump spec version * use rust 1.85.0 * upgrade to Rust 2024 Edition :tada: * whitelist clippy useless conversion warning * cargo fmt * passes clippy * Remove in/out peers args from docker compose * fix test * Update chainspecs * Remove Stake map - in progress (tests broken) * become delegate on every add_stake op * bump spec * Fix tests * Fix clippy * add root set sn moving alpha * fmt * fix test * fixes GH #1330 * bump spec * add a rate limit-set on decrease take (avoids close increase) * add test * add call to associate hk * update comment from PR1335 * bump spec version --------- Co-authored-by: unconst Co-authored-by: Unconst <32490803+unconst@users.noreply.github.com> Co-authored-by: Cameron Fairchild Co-authored-by: Greg Zaitsev Co-authored-by: Prakash Co-authored-by: open-junius Co-authored-by: ibraheem-opentensor Co-authored-by: Aliaksandr Tsurko Co-authored-by: John Reed <87283488+JohnReedV@users.noreply.github.com> Co-authored-by: camfairchild Co-authored-by: gztensor <166415444+gztensor@users.noreply.github.com> Co-authored-by: camfairchild <24501463+camfairchild@users.noreply.github.com> --- .github/workflows/cargo-audit.yml | 5 + .github/workflows/check-devnet.yml | 11 +- .github/workflows/check-finney.yml | 11 +- .github/workflows/check-rust.yml | 151 +- .github/workflows/check-testnet.yml | 11 +- .github/workflows/e2e-bittensor-tests.yml | 29 +- .github/workflows/try-runtime.yml | 22 +- .github/workflows/update-chainspec.yml | 12 +- CODEOWNERS | 1 - Cargo.lock | 1890 +++++++---------- Cargo.toml | 3 +- docker-compose.yml | 4 - docs/rust-setup.md | 2 +- node/Cargo.toml | 2 +- node/src/chain_spec/mod.rs | 4 +- node/src/client.rs | 2 +- node/src/command.rs | 10 +- node/src/ethereum.rs | 10 +- node/src/rpc.rs | 2 +- node/src/service.rs | 16 +- pallets/admin-utils/Cargo.toml | 2 +- pallets/admin-utils/src/lib.rs | 32 +- pallets/admin-utils/src/tests/mock.rs | 6 +- pallets/admin-utils/src/tests/mod.rs | 21 +- pallets/collective/Cargo.toml | 2 +- pallets/collective/src/lib.rs | 44 +- pallets/collective/src/tests.rs | 4 +- pallets/commitments/Cargo.toml | 2 +- pallets/commitments/src/lib.rs | 2 +- pallets/commitments/src/types.rs | 24 +- pallets/drand/Cargo.toml | 2 +- pallets/drand/src/bls12_381.rs | 2 +- pallets/drand/src/lib.rs | 12 +- pallets/drand/src/mock.rs | 6 +- pallets/drand/src/tests.rs | 6 +- pallets/drand/src/utils.rs | 6 +- pallets/drand/src/verifier.rs | 2 +- pallets/registry/Cargo.toml | 2 +- pallets/registry/src/lib.rs | 4 +- pallets/registry/src/types.rs | 31 +- pallets/subtensor/Cargo.toml | 2 +- pallets/subtensor/rpc/Cargo.toml | 2 +- pallets/subtensor/rpc/src/lib.rs | 8 +- pallets/subtensor/runtime-api/Cargo.toml | 2 +- pallets/subtensor/runtime-api/src/lib.rs | 2 +- pallets/subtensor/src/coinbase/block_step.rs | 5 +- pallets/subtensor/src/coinbase/root.rs | 12 +- .../subtensor/src/coinbase/run_coinbase.rs | 61 +- pallets/subtensor/src/epoch/run_epoch.rs | 8 +- pallets/subtensor/src/lib.rs | 31 +- pallets/subtensor/src/macros/config.rs | 10 +- pallets/subtensor/src/macros/dispatches.rs | 27 +- pallets/subtensor/src/macros/hooks.rs | 10 +- .../src/migrations/migrate_chain_identity.rs | 2 +- .../migrations/migrate_commit_reveal_v2.rs | 2 +- .../migrate_fix_total_coldkey_stake.rs | 91 - .../migrate_populate_staking_hotkeys.rs | 83 - .../subtensor/src/migrations/migrate_rao.rs | 48 +- .../migrations/migrate_remove_stake_map.rs | 62 + .../src/migrations/migrate_total_issuance.rs | 13 +- pallets/subtensor/src/migrations/mod.rs | 3 +- .../subtensor/src/rpc_info/delegate_info.rs | 95 +- pallets/subtensor/src/staking/account.rs | 13 + pallets/subtensor/src/staking/add_stake.rs | 9 +- .../subtensor/src/staking/decrease_take.rs | 6 +- pallets/subtensor/src/staking/helpers.rs | 18 +- .../subtensor/src/staking/increase_take.rs | 4 +- pallets/subtensor/src/staking/mod.rs | 1 + pallets/subtensor/src/staking/move_stake.rs | 5 + pallets/subtensor/src/staking/set_children.rs | 22 +- pallets/subtensor/src/staking/stake_utils.rs | 56 +- pallets/subtensor/src/subnets/registration.rs | 16 +- pallets/subtensor/src/subnets/weights.rs | 2 +- pallets/subtensor/src/swap/swap_coldkey.rs | 10 +- pallets/subtensor/src/swap/swap_hotkey.rs | 22 - pallets/subtensor/src/tests/children.rs | 399 ++-- pallets/subtensor/src/tests/coinbase.rs | 80 +- pallets/subtensor/src/tests/delegate_info.rs | 144 +- pallets/subtensor/src/tests/epoch.rs | 2 +- pallets/subtensor/src/tests/math.rs | 4 +- pallets/subtensor/src/tests/migration.rs | 397 ++-- pallets/subtensor/src/tests/mock.rs | 12 +- pallets/subtensor/src/tests/move_stake.rs | 119 +- pallets/subtensor/src/tests/networks.rs | 17 + pallets/subtensor/src/tests/registration.rs | 14 +- pallets/subtensor/src/tests/senate.rs | 26 +- pallets/subtensor/src/tests/serving.rs | 10 +- pallets/subtensor/src/tests/staking.rs | 387 ++-- pallets/subtensor/src/tests/staking2.rs | 83 +- pallets/subtensor/src/tests/swap_coldkey.rs | 73 +- pallets/subtensor/src/tests/swap_hotkey.rs | 152 +- pallets/subtensor/src/tests/uids.rs | 26 +- pallets/subtensor/src/tests/weights.rs | 6 +- pallets/subtensor/src/utils/misc.rs | 2 +- primitives/safe-math/Cargo.toml | 2 +- primitives/safe-math/src/lib.rs | 8 +- primitives/share-pool/Cargo.toml | 2 +- primitives/share-pool/src/lib.rs | 228 +- runtime/Cargo.toml | 4 +- runtime/src/check_nonce.rs | 2 +- runtime/src/lib.rs | 25 +- runtime/src/precompiles/balance_transfer.rs | 64 +- runtime/src/precompiles/ed25519.rs | 14 +- runtime/src/precompiles/metagraph.rs | 419 +--- runtime/src/precompiles/mod.rs | 235 +- runtime/src/precompiles/neuron.rs | 702 ++---- runtime/src/precompiles/solidity/neuron.abi | 6 +- runtime/src/precompiles/solidity/neuron.sol | 4 +- runtime/src/precompiles/solidity/subnet.abi | 46 +- runtime/src/precompiles/solidity/subnet.sol | 20 +- runtime/src/precompiles/staking.rs | 191 +- runtime/src/precompiles/subnet.rs | 1579 ++++---------- runtime/tests/pallet_proxy.rs | 2 +- rust-toolchain.toml | 2 +- scripts/run/subtensor.sh | 2 +- support/linting/Cargo.toml | 2 +- support/linting/src/forbid_as_primitive.rs | 2 +- support/linting/src/forbid_keys_remove.rs | 4 +- support/linting/src/pallet_index.rs | 2 +- support/linting/src/require_freeze_struct.rs | 4 +- support/macros/Cargo.toml | 2 +- support/macros/src/lib.rs | 14 +- support/tools/Cargo.toml | 2 +- 123 files changed, 3672 insertions(+), 5043 deletions(-) delete mode 100644 CODEOWNERS delete mode 100644 pallets/subtensor/src/migrations/migrate_fix_total_coldkey_stake.rs delete mode 100644 pallets/subtensor/src/migrations/migrate_populate_staking_hotkeys.rs create mode 100644 pallets/subtensor/src/migrations/migrate_remove_stake_map.rs create mode 100644 pallets/subtensor/src/staking/account.rs diff --git a/.github/workflows/cargo-audit.yml b/.github/workflows/cargo-audit.yml index 14e2d9449..aa8fb7c9f 100644 --- a/.github/workflows/cargo-audit.yml +++ b/.github/workflows/cargo-audit.yml @@ -24,6 +24,11 @@ jobs: sudo apt-get update && sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2 + with: + key: "cargo-audit" + - name: Install cargo-audit run: cargo install --force cargo-audit diff --git a/.github/workflows/check-devnet.yml b/.github/workflows/check-devnet.yml index 13ebf89cc..b6c20beee 100644 --- a/.github/workflows/check-devnet.yml +++ b/.github/workflows/check-devnet.yml @@ -20,12 +20,17 @@ jobs: sudo apt-get install -y curl clang curl libssl-dev llvm \ libudev-dev protobuf-compiler - - name: Install substrate-spec-version - run: cargo install substrate-spec-version - - name: Check-out repository under $GITHUB_WORKSPACE uses: actions/checkout@v4 + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2 + with: + key: "spec-version" + + - name: Install substrate-spec-version + run: cargo install substrate-spec-version + - name: Check that spec_version has been bumped run: | spec_version=$(PATH=$PATH:$HOME/.cargo/.bin substrate-spec-version wss://dev.chain.opentensor.ai:443 | tr -d '\n') diff --git a/.github/workflows/check-finney.yml b/.github/workflows/check-finney.yml index 98f90fc8e..448e53ee1 100644 --- a/.github/workflows/check-finney.yml +++ b/.github/workflows/check-finney.yml @@ -20,12 +20,17 @@ jobs: sudo apt-get install -y curl clang curl libssl-dev llvm \ libudev-dev protobuf-compiler - - name: Install substrate-spec-version - run: cargo install substrate-spec-version - - name: Check-out repository under $GITHUB_WORKSPACE uses: actions/checkout@v4 + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2 + with: + key: "spec-version" + + - name: Install substrate-spec-version + run: cargo install substrate-spec-version + - name: Check that spec_version has been bumped run: | spec_version=$(PATH=$PATH:$HOME/.cargo/.bin substrate-spec-version wss://entrypoint-finney.opentensor.ai:443 | tr -d '\n') diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index cdee05bfa..0fae77fa3 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -24,25 +24,8 @@ jobs: cargo-fmt: name: cargo fmt 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 RUST_BACKTRACE: full - SKIP_WASM_BUILD: 1 - TARGET: ${{ matrix.rust-target }} steps: - name: Check-out repository under $GITHUB_WORKSPACE uses: actions/checkout@v4 @@ -51,38 +34,22 @@ jobs: run: sudo apt-get update && sudo apt-get install -y build-essential - name: Install Rust Nightly - uses: actions-rs/toolchain@v1.0.6 - with: - toolchain: nightly - components: rustfmt - profile: minimal + run: | + rustup install nightly + rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt + + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2 - name: cargo fmt - run: cargo fmt --check --all + run: cargo +nightly 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 RUST_BACKTRACE: full SKIP_WASM_BUILD: 1 - TARGET: ${{ matrix.rust-target }} - RUST_BIN_DIR: target/${{ matrix.rust-target }} steps: - name: Check-out repository under $GITHUB_WORKSPACE uses: actions/checkout@v4 @@ -93,9 +60,7 @@ jobs: sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - name: Utilize Shared Rust Cache - uses: Swatinem/rust-cache@v2.2.1 - with: - key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} + uses: Swatinem/rust-cache@v2 - name: cargo clippy --workspace --all-targets -- -D warnings run: cargo clippy --workspace --all-targets -- -D warnings @@ -103,23 +68,10 @@ jobs: cargo-check-lints: name: check custom lints runs-on: SubtensorCI - strategy: - matrix: - rust-branch: - - stable - rust-target: - - x86_64-unknown-linux-gnu - # - x86_64-apple-darwin - os: - - ubuntu-latest - # - macos-latest env: - RELEASE_NAME: development RUSTFLAGS: -D warnings RUST_BACKTRACE: full SKIP_WASM_BUILD: 1 - TARGET: ${{ matrix.rust-target }} - RUST_BIN_DIR: target/${{ matrix.rust-target }} steps: - name: Check-out repository under $GITHUB_WORKSPACE uses: actions/checkout@v4 @@ -129,17 +81,8 @@ jobs: 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 }} + uses: Swatinem/rust-cache@v2 - name: check lints run: | @@ -150,27 +93,12 @@ jobs: cargo-clippy-all-features: name: cargo clippy --all-features runs-on: SubtensorCI - strategy: - matrix: - 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 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 + uses: actions/checkout@v4 - name: Install dependencies run: | @@ -178,35 +106,18 @@ jobs: sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - name: Utilize Shared Rust Cache - uses: Swatinem/rust-cache@v2.2.1 - with: - key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} + uses: Swatinem/rust-cache@v2 - name: cargo clippy --workspace --all-targets --all-features -- -D warnings run: cargo clippy --workspace --all-targets --all-features -- -D warnings - # runs cargo test --workspace + # runs cargo test --workspace --all-features cargo-test: name: cargo test runs-on: SubtensorCI - strategy: - matrix: - 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 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 @@ -216,10 +127,8 @@ jobs: sudo apt-get update && sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - - name: Utilize Rust shared cached - uses: Swatinem/rust-cache@v2.2.1 - with: - key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2 - name: cargo test --workspace --all-features run: cargo test --workspace --all-features @@ -228,26 +137,9 @@ jobs: cargo-fix: name: cargo fix 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 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 @@ -257,10 +149,8 @@ jobs: sudo apt-get update && sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - - name: Utilize Rust shared cached - uses: Swatinem/rust-cache@v2.2.1 - with: - key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }} + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2 - name: cargo fix --workspace run: | @@ -280,13 +170,16 @@ jobs: runs-on: SubtensorCI steps: - - name: Install Zepter - run: cargo install --locked -q zepter && zepter --version - - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 # Dont clone historic commits. + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Install Zepter + run: cargo install --locked -q zepter && zepter --version + - name: Check features run: zepter run check diff --git a/.github/workflows/check-testnet.yml b/.github/workflows/check-testnet.yml index 7c8532ec5..8a59036d9 100644 --- a/.github/workflows/check-testnet.yml +++ b/.github/workflows/check-testnet.yml @@ -20,12 +20,17 @@ jobs: sudo apt-get install -y curl clang curl libssl-dev llvm \ libudev-dev protobuf-compiler - - name: Install substrate-spec-version - run: cargo install substrate-spec-version - - name: Check-out repository under $GITHUB_WORKSPACE uses: actions/checkout@v4 + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2 + with: + key: "spec-version" + + - name: Install substrate-spec-version + run: cargo install substrate-spec-version + - name: Check that spec_version has been bumped run: | spec_version=$(PATH=$PATH:$HOME/.cargo/.bin substrate-spec-version wss://test.finney.opentensor.ai:443 | tr -d '\n') diff --git a/.github/workflows/e2e-bittensor-tests.yml b/.github/workflows/e2e-bittensor-tests.yml index 851c30a6d..5be78c2ec 100644 --- a/.github/workflows/e2e-bittensor-tests.yml +++ b/.github/workflows/e2e-bittensor-tests.yml @@ -22,41 +22,20 @@ env: jobs: run: 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 - RUSTV: ${{ matrix.rust-branch }} RUST_BACKTRACE: full - RUST_BIN_DIR: target/${{ matrix.rust-target }} - TARGET: ${{ matrix.rust-target }} steps: - name: Check-out repository under $GITHUB_WORKSPACE - uses: actions/checkout@v2 + uses: actions/checkout@v4 + + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@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 - profile: minimal - - name: Clone bittensor repo run: git clone https://github.com/opentensor/bittensor.git diff --git a/.github/workflows/try-runtime.yml b/.github/workflows/try-runtime.yml index 89a28c5c6..c3b54a351 100644 --- a/.github/workflows/try-runtime.yml +++ b/.github/workflows/try-runtime.yml @@ -2,8 +2,6 @@ name: Try Runtime on: pull_request: - branches: [main, devnet-ready, devnet, testnet, finney] - types: [labeled, unlabeled, synchronize] env: CARGO_TERM_COLOR: always @@ -16,6 +14,11 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2 + with: + key: "try-runtime" + - name: Run Try Runtime Checks uses: "paritytech/try-runtime-gha@v0.1.0" with: @@ -26,25 +29,38 @@ jobs: check-testnet: name: check testnet + # if: github.base_ref == 'testnet' || github.base_ref == 'devnet' || github.base_ref == 'main' runs-on: SubtensorCI steps: - name: Checkout sources uses: actions/checkout@v4 + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2 + with: + key: "try-runtime" + - name: Run Try Runtime Checks uses: "paritytech/try-runtime-gha@v0.1.0" with: runtime-package: "node-subtensor-runtime" - node-uri: "wss://test.chain.opentensor.ai:443" + node-uri: "wss://test-archive.dev.opentensor.ai:443" checks: "all" extra-args: "--disable-spec-version-check --no-weight-warnings" check-finney: name: check finney + if: github.base_ref == 'testnet' || github.base_ref == 'devnet' || github.base_ref == 'main' runs-on: SubtensorCI steps: - name: Checkout sources uses: actions/checkout@v4 + + - name: Utilize Shared Rust Cache + uses: Swatinem/rust-cache@v2 + with: + key: "try-runtime" + - name: Run Try Runtime Checks uses: "paritytech/try-runtime-gha@v0.1.0" with: diff --git a/.github/workflows/update-chainspec.yml b/.github/workflows/update-chainspec.yml index bf7cc5588..1aedfeaa4 100644 --- a/.github/workflows/update-chainspec.yml +++ b/.github/workflows/update-chainspec.yml @@ -29,14 +29,6 @@ jobs: github.event.pull_request.head.ref != 'testnet' && github.event.pull_request.head.ref != 'main' - strategy: - matrix: - rust-target: - - x86_64-unknown-linux-gnu - os: - - ubuntu-latest - include: - - os: ubuntu-latest env: RUST_BACKTRACE: full steps: @@ -49,9 +41,7 @@ jobs: sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler - name: Utilize Shared Rust Cache - uses: Swatinem/rust-cache@v2.2.1 - with: - key: ubuntu-latest-target/x86_64-unknown-linux-gnu + uses: Swatinem/rust-cache@v2 - name: Build chainspecs run: ./scripts/build_all_chainspecs.sh diff --git a/CODEOWNERS b/CODEOWNERS deleted file mode 100644 index ffc01511b..000000000 --- a/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @unconst diff --git a/Cargo.lock b/Cargo.lock index ed3b5ae45..70dcd3d37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,11 +23,11 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.24.2" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ - "gimli 0.31.1", + "gimli 0.31.0", ] [[package]] @@ -77,7 +77,7 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom 0.2.15", + "getrandom", "once_cell", "version_check", ] @@ -89,7 +89,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "getrandom 0.2.15", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -106,9 +106,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.21" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "android-tzdata" @@ -127,9 +127,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.18" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -142,44 +142,43 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.10" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.6" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.2" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.7" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", - "once_cell", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "approx" @@ -201,7 +200,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -568,7 +567,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror 1.0.69", + "thiserror", "time", ] @@ -584,7 +583,7 @@ dependencies = [ "nom", "num-traits", "rusticata-macros", - "thiserror 1.0.69", + "thiserror", "time", ] @@ -608,7 +607,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", "synstructure 0.13.1", ] @@ -631,7 +630,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -653,9 +652,9 @@ dependencies = [ [[package]] name = "async-io" -version = "2.4.0" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" +checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" dependencies = [ "async-lock", "cfg-if", @@ -664,7 +663,7 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix 0.38.44", + "rustix 0.38.37", "slab", "tracing", "windows-sys 0.59.0", @@ -676,20 +675,20 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ - "event-listener 5.4.0", + "event-listener 5.3.1", "event-listener-strategy", "pin-project-lite", ] [[package]] name = "async-trait" -version = "0.1.85" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -733,13 +732,13 @@ dependencies = [ [[package]] name = "auto_impl" -version = "1.2.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12882f59de5360c748c4cbf569a042d5fb0eb515f7bea9c1f470b47f6ffbd73" +checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -754,11 +753,11 @@ version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ - "addr2line 0.24.2", + "addr2line 0.24.1", "cfg-if", "libc", "miniz_oxide", - "object 0.36.7", + "object 0.36.4", "rustc-demangle", "windows-targets 0.52.6", ] @@ -820,13 +819,13 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.29", + "prettyplease 0.2.22", "proc-macro2", "quote", "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -853,9 +852,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitvec" @@ -914,9 +913,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.5" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ee0c1824c4dea5b5f81736aff91bae041d2c07ee1192bec91054e10e3e601e" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" dependencies = [ "arrayref", "arrayvec", @@ -945,9 +944,9 @@ dependencies = [ [[package]] name = "bounded-collections" -version = "0.2.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d077619e9c237a5d1875166f5e8033e8f6bff0c96f8caf81e1c2d7738c431bf" +checksum = "d32385ecb91a31bddaf908e8dcf4a15aef1bcd3913cc03ebfad02ff6d568abc1" dependencies = [ "log", "parity-scale-codec", @@ -981,9 +980,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.17.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byte-slice-cast" @@ -999,9 +998,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.21.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" [[package]] name = "byteorder" @@ -1011,9 +1010,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.9.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "bzip2-sys" @@ -1047,9 +1046,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.9" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" dependencies = [ "serde", ] @@ -1062,17 +1061,23 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.25", + "semver 1.0.23", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", ] +[[package]] +name = "case" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c" + [[package]] name = "cc" -version = "1.2.10" +version = "1.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" +checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" dependencies = [ "jobserver", "libc", @@ -1145,9 +1150,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.39" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -1217,9 +1222,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.27" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796" +checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" dependencies = [ "clap_builder", "clap_derive", @@ -1227,9 +1232,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.27" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" +checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" dependencies = [ "anstream", "anstyle", @@ -1240,21 +1245,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.24" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "clap_lex" -version = "0.7.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "codespan-reporting" @@ -1263,14 +1268,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ "termcolor", - "unicode-width 0.1.14", + "unicode-width", ] [[package]] name = "colorchoice" -version = "1.0.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "combine" @@ -1284,13 +1289,13 @@ dependencies = [ [[package]] name = "comfy-table" -version = "7.1.3" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24f165e7b643266ea80cb858aed492ad9280e3e05ce24d4a99d7d7b889b6a4d9" +checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" dependencies = [ "strum 0.26.3", "strum_macros 0.26.4", - "unicode-width 0.2.0", + "unicode-width", ] [[package]] @@ -1310,15 +1315,15 @@ dependencies = [ [[package]] name = "console" -version = "0.15.10" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", + "lazy_static", "libc", - "once_cell", - "unicode-width 0.2.0", - "windows-sys 0.59.0", + "unicode-width", + "windows-sys 0.52.0", ] [[package]] @@ -1342,7 +1347,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "getrandom 0.2.15", + "getrandom", "once_cell", "tiny-keccak", ] @@ -1401,9 +1406,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.17" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -1532,9 +1537,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -1560,15 +1565,15 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.21" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crunchy" -version = "0.2.3" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" @@ -1646,66 +1651,51 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "cxx" -version = "1.0.137" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc894913dccfed0f84106062c284fa021c3ba70cb1d78797d6f5165d4492e45" +checksum = "54ccead7d199d584d139148b04b4a368d1ec7556a1d9ea2548febb1b9d49f9a4" dependencies = [ "cc", - "cxxbridge-cmd", "cxxbridge-flags", "cxxbridge-macro", - "foldhash", "link-cplusplus", ] [[package]] name = "cxx-build" -version = "1.0.137" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "503b2bfb6b3e8ce7f95d865a67419451832083d3186958290cee6c53e39dfcfe" +checksum = "c77953e99f01508f89f55c494bfa867171ef3a6c8cea03d26975368f2121a5c1" dependencies = [ "cc", "codespan-reporting", + "once_cell", "proc-macro2", "quote", "scratch", - "syn 2.0.96", -] - -[[package]] -name = "cxxbridge-cmd" -version = "1.0.137" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0d2cb64a95b4b5a381971482235c4db2e0208302a962acdbe314db03cbbe2fb" -dependencies = [ - "clap", - "codespan-reporting", - "proc-macro2", - "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "cxxbridge-flags" -version = "1.0.137" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f797b0206463c9c2a68ed605ab28892cca784f1ef066050f4942e3de26ad885" +checksum = "65777e06cc48f0cb0152024c77d6cf9e4bdb4408e7b48bea993d42fa0f5b02b6" [[package]] name = "cxxbridge-macro" -version = "1.0.137" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79010a2093848e65a3e0f7062d3f02fb2ef27f866416dfe436fccfa73d3bb59" +checksum = "98532a60dedaebc4848cb2cba5023337cc9ea3af16a5b062633fabfd9f18fb60" dependencies = [ "proc-macro2", "quote", - "rustversion", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -1729,7 +1719,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -1740,7 +1730,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -1758,15 +1748,15 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.7.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e60eed09d8c01d3cee5b7d30acb059b76614c918fa0f992e0dd6eeb10daad6f" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "data-encoding-macro" -version = "0.1.16" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b16d9d0d88a5273d830dac8b78ceb217ffc9b1d5404e5597a3542515329405b" +checksum = "f1559b6cba622276d6d63706db152618eeb15b89b3e4041446b05876e352e639" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -1774,9 +1764,9 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.14" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145d32e826a7748b69ee8fc62d3e6355ff7f1051df53141e7048162fc90481b" +checksum = "332d754c0af53bc87c108fed664d121ecf59207ec4196041f04d6ab9002ad33f" dependencies = [ "data-encoding", "syn 1.0.109", @@ -1849,7 +1839,7 @@ checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -1862,27 +1852,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.96", -] - -[[package]] -name = "derive_more" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -1971,23 +1941,23 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "docify" -version = "0.2.9" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a772b62b1837c8f060432ddcc10b17aae1453ef17617a99bc07789252d2a5896" +checksum = "43a2f138ad521dc4a2ced1a4576148a6a610b4c5923933b062a263130a6802ce" dependencies = [ "docify_macros", ] [[package]] name = "docify_macros" -version = "0.2.9" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e6be249b0a462a14784a99b19bf35a667bb5e09de611738bb7362fa4c95ff7" +checksum = "1a081e51fb188742f5a7a1164ad752121abcb22874b21e2c3b0dd040c515fdad" dependencies = [ "common-path", "derive-syn-parse", @@ -1995,7 +1965,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.96", + "syn 2.0.90", "termcolor", "toml 0.8.19", "walkdir", @@ -2021,9 +1991,9 @@ checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" [[package]] name = "dyn-clonable" -version = "0.9.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a36efbb9bfd58e1723780aa04b61aba95ace6a05d9ffabfdb0b43672552f0805" +checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" dependencies = [ "dyn-clonable-impl", "dyn-clone", @@ -2031,13 +2001,13 @@ dependencies = [ [[package]] name = "dyn-clonable-impl" -version = "0.9.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8671d54058979a37a26f3511fbf8d198ba1aa35ffb202c42587d918d77213a" +checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 1.0.109", ] [[package]] @@ -2132,9 +2102,9 @@ dependencies = [ [[package]] name = "encode_unicode" -version = "1.0.0" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "enum-as-inner" @@ -2157,27 +2127,27 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "enumflags2" -version = "0.7.11" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147" +checksum = "d232db7f5956f3f14313dc2f87985c58bd2c695ce124c8cdd984e08e15ac133d" dependencies = [ "enumflags2_derive", ] [[package]] name = "enumflags2_derive" -version = "0.7.11" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79" +checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -2207,12 +2177,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -2223,9 +2193,9 @@ checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" dependencies = [ "crunchy", "fixed-hash", - "impl-codec 0.6.0", + "impl-codec", "impl-rlp", - "impl-serde 0.4.0", + "impl-serde", "scale-info", "tiny-keccak", ] @@ -2256,12 +2226,12 @@ checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" dependencies = [ "ethbloom", "fixed-hash", - "impl-codec 0.6.0", + "impl-codec", "impl-rlp", - "impl-serde 0.4.0", - "primitive-types 0.12.2", + "impl-serde", + "primitive-types", "scale-info", - "uint 0.9.5", + "uint", ] [[package]] @@ -2272,9 +2242,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "5.4.0" +version = "5.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" dependencies = [ "concurrent-queue", "parking", @@ -2283,11 +2253,11 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.3" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ - "event-listener 5.4.0", + "event-listener 5.3.1", "pin-project-lite", ] @@ -2305,7 +2275,7 @@ dependencies = [ "evm-runtime", "log", "parity-scale-codec", - "primitive-types 0.12.2", + "primitive-types", "rlp", "scale-info", "serde", @@ -2319,7 +2289,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d1da6cedc5cedb4208e59467106db0d1f50db01b920920589f8e672c02fdc04f" dependencies = [ "parity-scale-codec", - "primitive-types 0.12.2", + "primitive-types", "scale-info", "serde", ] @@ -2333,7 +2303,7 @@ dependencies = [ "environmental", "evm-core", "evm-runtime", - "primitive-types 0.12.2", + "primitive-types", ] [[package]] @@ -2345,7 +2315,7 @@ dependencies = [ "auto_impl", "environmental", "evm-core", - "primitive-types 0.12.2", + "primitive-types", "sha3", ] @@ -2367,10 +2337,10 @@ dependencies = [ "blake2 0.10.6", "file-guard", "fs-err", - "prettyplease 0.2.29", + "prettyplease 0.2.22", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -2387,9 +2357,9 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" [[package]] name = "fastrand" -version = "2.3.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fc-api" @@ -2416,7 +2386,7 @@ dependencies = [ "sp-block-builder", "sp-consensus", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -2522,7 +2492,7 @@ dependencies = [ "sp-storage 21.0.0", "sp-timestamp", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", "tokio", ] @@ -2565,7 +2535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e182f7dbc2ef73d9ef67351c5fbbea084729c48362d3ce9dd44c28e32e277fe5" dependencies = [ "libc", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -2678,9 +2648,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.4" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" [[package]] name = "foreign-types" @@ -2721,7 +2691,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835f84f38484cc86f110a805655697908257fb9a7af005234060891557198e9" dependencies = [ "nonempty", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -2730,7 +2700,7 @@ version = "1.0.0-dev" source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" dependencies = [ "hex", - "impl-serde 0.4.0", + "impl-serde", "libsecp256k1", "log", "parity-scale-codec", @@ -2894,7 +2864,7 @@ dependencies = [ "sp-storage 21.0.0", "sp-trie", "sp-wasm-interface 21.0.1", - "thiserror 1.0.69", + "thiserror", "thousands", ] @@ -3001,7 +2971,7 @@ dependencies = [ "proc-macro2", "quote", "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -3014,7 +2984,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -3026,7 +2996,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -3037,7 +3007,7 @@ checksum = "68672b9ec6fe72d259d3879dc212c5e42e977588cdac830c76f54d9f492aeb58" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -3047,7 +3017,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -3202,9 +3172,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.6.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ "futures-core", "pin-project-lite", @@ -3218,7 +3188,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -3314,19 +3284,7 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.13.3+wasi-0.2.2", - "windows-targets 0.52.6", + "wasi", ] [[package]] @@ -3372,15 +3330,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.1" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "glob" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "governor" @@ -3425,7 +3383,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.7.1", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -3434,17 +3392,17 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.7" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "http 1.2.0", - "indexmap 2.7.1", + "http 1.1.0", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -3468,7 +3426,7 @@ dependencies = [ "pest_derive", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -3536,11 +3494,11 @@ dependencies = [ [[package]] name = "hashlink" -version = "0.10.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" dependencies = [ - "hashbrown 0.15.2", + "hashbrown 0.14.5", ] [[package]] @@ -3629,11 +3587,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.11" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -3660,9 +3618,9 @@ dependencies = [ [[package]] name = "http" -version = "1.2.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", @@ -3687,7 +3645,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.2.0", + "http 1.1.0", ] [[package]] @@ -3698,16 +3656,16 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.2.0", + "http 1.1.0", "http-body 1.0.1", "pin-project-lite", ] [[package]] name = "httparse" -version = "1.10.0" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d708df4e7140240a16cd6ab0ab65c972d7433ab77819ea693fde9c43811e2a" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -3723,9 +3681,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.32" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -3738,7 +3696,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.8", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -3747,15 +3705,15 @@ dependencies = [ [[package]] name = "hyper" -version = "1.6.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.7", - "http 1.2.0", + "h2 0.4.6", + "http 1.1.0", "http-body 1.0.1", "httparse", "httpdate", @@ -3773,7 +3731,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.32", + "hyper 0.14.30", "log", "rustls 0.21.12", "rustls-native-certs", @@ -3789,9 +3747,9 @@ checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" dependencies = [ "bytes", "futures-util", - "http 1.2.0", + "http 1.1.0", "http-body 1.0.1", - "hyper 1.6.0", + "hyper 1.5.0", "pin-project-lite", "tokio", "tower-service", @@ -3820,124 +3778,6 @@ dependencies = [ "cc", ] -[[package]] -name = "icu_collections" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locid" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_locid_transform" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" - -[[package]] -name = "icu_normalizer" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" - -[[package]] -name = "icu_properties" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid_transform", - "icu_properties_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" - -[[package]] -name = "icu_provider" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "tinystr", - "writeable", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_provider_macros" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.96", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -3967,23 +3807,12 @@ dependencies = [ [[package]] name = "idna" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" -dependencies = [ - "idna_adapter", - "smallvec", - "utf8_iter", -] - -[[package]] -name = "idna_adapter" -version = "1.2.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "icu_normalizer", - "icu_properties", + "unicode-bidi", + "unicode-normalization", ] [[package]] @@ -3998,9 +3827,9 @@ dependencies = [ [[package]] name = "if-watch" -version = "3.2.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf9d64cfcf380606e64f9a0bcf493616b65331199f984151a6fa11a7b3cde38" +checksum = "d6b0422c86d7ce0e97169cc42e04ae643caf278874a7a3c87b8150a220dc7e1e" dependencies = [ "async-io", "core-foundation", @@ -4009,10 +3838,6 @@ dependencies = [ "if-addrs", "ipnet", "log", - "netlink-packet-core", - "netlink-packet-route", - "netlink-proto", - "netlink-sys", "rtnetlink", "system-configuration", "tokio", @@ -4030,7 +3855,7 @@ dependencies = [ "bytes", "futures", "http 0.2.12", - "hyper 0.14.32", + "hyper 0.14.30", "log", "rand", "tokio", @@ -4047,26 +3872,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-codec" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67aa010c1e3da95bf151bd8b4c059b2ed7e75387cdb969b4f8f2723a43f9941" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-num-traits" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "803d15461ab0dcc56706adf266158acbc44ccf719bf7d0af30705f58b90a4b8c" -dependencies = [ - "integer-sqrt", - "num-traits", - "uint 0.10.0", -] - [[package]] name = "impl-rlp" version = "0.3.0" @@ -4085,24 +3890,15 @@ dependencies = [ "serde", ] -[[package]] -name = "impl-serde" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a143eada6a1ec4aefa5049037a26a6d597bfd64f8c026d07b77133e02b7dd0b" -dependencies = [ - "serde", -] - [[package]] name = "impl-trait-for-tuples" -version = "0.2.3" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 1.0.109", ] [[package]] @@ -4137,9 +3933,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", "hashbrown 0.15.2", @@ -4195,7 +3991,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.5.8", + "socket2 0.5.7", "widestring", "windows-sys 0.48.0", "winreg", @@ -4203,19 +3999,19 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.11.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "is-terminal" -version = "0.4.15" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" dependencies = [ "hermit-abi 0.4.0", "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -4253,9 +4049,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" @@ -4268,19 +4064,18 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ - "once_cell", "wasm-bindgen", ] [[package]] name = "jsonrpsee" -version = "0.24.8" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "834af00800e962dee8f7bfc0f60601de215e73e78e5497d733a2919da837d3c8" +checksum = "c5c71d8c1a731cc4227c2f698d377e7848ca12c8a48866fc5e6951c43a4db843" dependencies = [ "jsonrpsee-core", "jsonrpsee-proc-macros", @@ -4292,51 +4087,51 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.24.8" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76637f6294b04e747d68e69336ef839a3493ca62b35bf488ead525f7da75c5bb" +checksum = "f2882f6f8acb9fdaec7cefc4fd607119a9bd709831df7d7672a1d3b644628280" dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.2.0", + "http 1.1.0", "http-body 1.0.1", "http-body-util", "jsonrpsee-types", "parking_lot 0.12.3", "rand", - "rustc-hash 2.1.0", + "rustc-hash 2.0.0", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", ] [[package]] name = "jsonrpsee-proc-macros" -version = "0.24.8" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fcae0c6c159e11541080f1f829873d8f374f81eda0abc67695a13fc8dc1a580" +checksum = "c06c01ae0007548e73412c08e2285ffe5d723195bf268bce67b1b77c3bb2a14d" dependencies = [ "heck 0.5.0", "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "jsonrpsee-server" -version = "0.24.8" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b7a3df90a1a60c3ed68e7ca63916b53e9afa928e33531e87f61a9c8e9ae87b" +checksum = "82ad8ddc14be1d4290cd68046e7d1d37acd408efed6d3ca08aefcc3ad6da069c" dependencies = [ "futures-util", - "http 1.2.0", + "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.6.0", + "hyper 1.5.0", "hyper-util", "jsonrpsee-core", "jsonrpsee-types", @@ -4345,7 +4140,7 @@ dependencies = [ "serde", "serde_json", "soketto", - "thiserror 1.0.69", + "thiserror", "tokio", "tokio-stream", "tokio-util", @@ -4355,14 +4150,14 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.24.8" +version = "0.24.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddb81adb1a5ae9182df379e374a79e24e992334e7346af4d065ae5b2acb8d4c6" +checksum = "a178c60086f24cc35bb82f57c651d0d25d99c4742b4d335de04e97fa1f08a8a1" dependencies = [ - "http 1.2.0", + "http 1.1.0", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -4441,15 +4236,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libloading" -version = "0.8.6" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", "windows-targets 0.52.6", @@ -4457,9 +4252,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.11" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libp2p" @@ -4471,7 +4266,7 @@ dependencies = [ "either", "futures", "futures-timer", - "getrandom 0.2.15", + "getrandom", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -4495,7 +4290,7 @@ dependencies = [ "multiaddr 0.18.2", "pin-project", "rw-stream-sink", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -4536,7 +4331,7 @@ dependencies = [ "libp2p-identity", "log", "multiaddr 0.18.2", - "multihash 0.19.3", + "multihash 0.19.2", "multistream-select", "once_cell", "parking_lot 0.12.3", @@ -4545,7 +4340,7 @@ dependencies = [ "rand", "rw-stream-sink", "smallvec", - "thiserror 1.0.69", + "thiserror", "unsigned-varint 0.7.2", "void", ] @@ -4585,24 +4380,24 @@ dependencies = [ "quick-protobuf", "quick-protobuf-codec", "smallvec", - "thiserror 1.0.69", + "thiserror", "void", ] [[package]] name = "libp2p-identity" -version = "0.2.10" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "257b5621d159b32282eac446bed6670c39c7dc68a200a992d8f056afa0066f6d" +checksum = "55cca1eb2bc1fd29f099f3daaab7effd01e1a54b7c577d0ed082521034d912e8" dependencies = [ "bs58 0.5.1", "ed25519-dalek", "hkdf", - "multihash 0.19.3", + "multihash 0.19.2", "quick-protobuf", "rand", "sha2 0.10.8", - "thiserror 1.0.69", + "thiserror", "tracing", "zeroize", ] @@ -4630,8 +4425,8 @@ dependencies = [ "rand", "sha2 0.10.8", "smallvec", - "thiserror 1.0.69", - "uint 0.9.5", + "thiserror", + "uint", "unsigned-varint 0.7.2", "void", ] @@ -4651,7 +4446,7 @@ dependencies = [ "log", "rand", "smallvec", - "socket2 0.5.8", + "socket2 0.5.7", "tokio", "trust-dns-proto 0.22.0", "void", @@ -4687,14 +4482,14 @@ dependencies = [ "libp2p-identity", "log", "multiaddr 0.18.2", - "multihash 0.19.3", + "multihash 0.19.2", "once_cell", "quick-protobuf", "rand", "sha2 0.10.8", "snow", "static_assertions", - "thiserror 1.0.69", + "thiserror", "x25519-dalek", "zeroize", ] @@ -4736,8 +4531,8 @@ dependencies = [ "rand", "ring 0.16.20", "rustls 0.21.12", - "socket2 0.5.8", - "thiserror 1.0.69", + "socket2 0.5.7", + "thiserror", "tokio", ] @@ -4792,7 +4587,7 @@ dependencies = [ "proc-macro-warning 0.4.2", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -4808,7 +4603,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "log", - "socket2 0.5.8", + "socket2 0.5.7", "tokio", ] @@ -4826,7 +4621,7 @@ dependencies = [ "ring 0.16.20", "rustls 0.21.12", "rustls-webpki", - "thiserror 1.0.69", + "thiserror", "x509-parser 0.15.1", "yasna", ] @@ -4877,7 +4672,7 @@ dependencies = [ "pin-project-lite", "rw-stream-sink", "soketto", - "thiserror 1.0.69", + "thiserror", "url", "webpki-roots", ] @@ -4891,7 +4686,7 @@ dependencies = [ "futures", "libp2p-core", "log", - "thiserror 1.0.69", + "thiserror", "yamux", ] @@ -4901,9 +4696,9 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.6.0", "libc", - "redox_syscall 0.5.8", + "redox_syscall 0.5.7", ] [[package]] @@ -4982,9 +4777,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.21" +version = "1.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df9b68e50e6e0b26f672573834882eb57759f6db9b3be2ea3c35c91188bb4eaa" +checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" dependencies = [ "cc", "pkg-config", @@ -5008,18 +4803,18 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linked_hash_set" -version = "0.1.5" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae85b5be22d9843c80e5fc80e9b64c8a3b1f98f867c709956eca3efff4e92e2" +checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588" dependencies = [ "linked-hash-map", ] [[package]] name = "linregress" -version = "0.5.4" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9eda9dcf4f2a99787827661f312ac3219292549c2ee992bf9a6248ffb066bf7" +checksum = "4de04dcecc58d366391f9920245b85ffa684558a5ef6e7736e754347c3aea9c2" dependencies = [ "nalgebra", ] @@ -5032,9 +4827,9 @@ checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "linux-raw-sys" -version = "0.4.15" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lioness" @@ -5048,12 +4843,6 @@ dependencies = [ "keystream", ] -[[package]] -name = "litemap" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" - [[package]] name = "litep2p" version = "0.6.2" @@ -5068,7 +4857,7 @@ dependencies = [ "futures", "futures-timer", "hex-literal", - "indexmap 2.7.1", + "indexmap 2.6.0", "libc", "mockall 0.12.1", "multiaddr 0.17.1", @@ -5089,17 +4878,17 @@ dependencies = [ "simple-dns", "smallvec", "snow", - "socket2 0.5.8", + "socket2 0.5.7", "static_assertions", "str0m", - "thiserror 1.0.69", + "thiserror", "tokio", "tokio-stream", "tokio-tungstenite", "tokio-util", "tracing", "trust-dns-resolver", - "uint 0.9.5", + "uint", "unsigned-varint 0.8.0", "url", "webpki", @@ -5121,9 +4910,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.25" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" @@ -5154,9 +4943,9 @@ dependencies = [ [[package]] name = "lz4" -version = "1.28.1" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20b523e860d03443e98350ceaac5e71c6ba89aea7d960769ec3ce37f4de5af4" +checksum = "4d1febb2b4a79ddd1980eede06a8f7902197960aa0383ffcfdd62fe723036725" dependencies = [ "lz4-sys", ] @@ -5189,7 +4978,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -5203,7 +4992,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -5214,7 +5003,7 @@ checksum = "b02abfe41815b5bd98dbd4260173db2c116dda171dc0fe7838cb206333b83308" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -5225,7 +5014,7 @@ checksum = "73ea28ee64b88876bf45277ed9a5817c1817df061a74f2b988971a12570e5869" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -5271,7 +5060,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.44", + "rustix 0.38.37", ] [[package]] @@ -5344,21 +5133,22 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ "adler2", ] [[package]] name = "mio" -version = "1.0.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ + "hermit-abi 0.3.9", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.52.0", ] @@ -5383,7 +5173,7 @@ dependencies = [ "rand_chacha", "rand_distr", "subtle 2.6.1", - "thiserror 1.0.69", + "thiserror", "zeroize", ] @@ -5413,7 +5203,7 @@ dependencies = [ "fragile", "lazy_static", "mockall_derive 0.12.1", - "predicates 3.1.3", + "predicates 3.1.2", "predicates-tree", ] @@ -5438,7 +5228,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -5471,7 +5261,7 @@ dependencies = [ "data-encoding", "libp2p-identity", "multibase", - "multihash 0.19.3", + "multihash 0.19.2", "percent-encoding", "serde", "static_assertions", @@ -5526,9 +5316,9 @@ dependencies = [ [[package]] name = "multihash" -version = "0.19.3" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b430e7953c29dd6a09afc29ff0bb69c6e306329ee6794700aee27b76a1aea8d" +checksum = "cc41f430805af9d1cf4adae4ed2149c759b877b01d909a1f40256188d09345d2" dependencies = [ "core2", "unsigned-varint 0.8.0", @@ -5554,12 +5344,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" -[[package]] -name = "multimap" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" - [[package]] name = "multistream-select" version = "0.13.0" @@ -5576,12 +5360,13 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.33.2" +version = "0.32.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26aecdf64b707efd1310e3544d709c5c0ac61c13756046aaaba41be5c4f66a3b" +checksum = "7b5c17de023a86f59ed79891b2e5d5a94c705dbe904a5b5c9c952ea6221b03e4" dependencies = [ "approx", "matrixmultiply", + "nalgebra-macros", "num-complex", "num-rational", "num-traits", @@ -5589,6 +5374,17 @@ dependencies = [ "typenum 1.17.0", ] +[[package]] +name = "nalgebra-macros" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "names" version = "0.14.0" @@ -5600,9 +5396,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.13" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dab59f8e050d5df8e4dd87d9206fb6f65a483e20ac9fda365ade4fab353196c" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ "libc", "log", @@ -5630,20 +5426,21 @@ dependencies = [ [[package]] name = "netlink-packet-core" -version = "0.7.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72724faf704479d67b388da142b186f916188505e7e0b26719019c525882eda4" +checksum = "345b8ab5bd4e71a2986663e88c56856699d060e78e152e6e9d7966fcd5491297" dependencies = [ "anyhow", "byteorder", + "libc", "netlink-packet-utils", ] [[package]] name = "netlink-packet-route" -version = "0.17.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053998cea5a306971f88580d0829e90f270f940befd7cf928da179d4187a5a66" +checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", "bitflags 1.3.2", @@ -5662,28 +5459,29 @@ dependencies = [ "anyhow", "byteorder", "paste", - "thiserror 1.0.69", + "thiserror", ] [[package]] name = "netlink-proto" -version = "0.11.5" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72452e012c2f8d612410d89eea01e2d9b56205274abb35d53f60200b2ec41d60" +checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6" dependencies = [ "bytes", "futures", "log", "netlink-packet-core", "netlink-sys", - "thiserror 2.0.11", + "thiserror", + "tokio", ] [[package]] name = "netlink-sys" -version = "0.8.7" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16c903aa70590cb93691bf97a767c8d1d6122d2cc9070433deb3bbf36ce8bd23" +checksum = "416060d346fbaf1f23f9512963e3e878f1a78e707cb699ba9215761754244307" dependencies = [ "bytes", "futures", @@ -5700,15 +5498,15 @@ checksum = "a4a43439bf756eed340bdf8feba761e2d50c7d47175d87545cd5cbe4a137c4d1" dependencies = [ "cc", "libc", - "thiserror 1.0.69", + "thiserror", "winapi", ] [[package]] name = "nix" -version = "0.26.4" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ "bitflags 1.3.2", "cfg-if", @@ -5799,7 +5597,7 @@ dependencies = [ "substrate-prometheus-endpoint", "subtensor-custom-rpc", "subtensor-custom-rpc-runtime-api", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -5821,7 +5619,7 @@ dependencies = [ "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", - "getrandom 0.2.15", + "getrandom", "hex", "log", "pallet-admin-utils", @@ -5854,6 +5652,7 @@ dependencies = [ "pallet-transaction-payment-rpc-runtime-api", "pallet-utility", "parity-scale-codec", + "precompile-utils", "rand_chacha", "scale-info", "serde_json", @@ -6043,7 +5842,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -6069,9 +5868,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.7" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -6096,9 +5895,12 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "opaque-debug" @@ -6118,7 +5920,7 @@ version = "0.10.70" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61cfb4e166a8bb8c9b55c500bc2308550148ece889be90f609377e58140f42c6" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.6.0", "cfg-if", "foreign-types", "libc", @@ -6135,20 +5937,20 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "openssl-probe" -version = "0.1.6" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.4.1+3.4.0" +version = "300.4.0+3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faa4eac4138c62414b5622d1b31c5c304f34b406b013c079c2bbc652fdd6678c" +checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" dependencies = [ "cc", ] @@ -6814,7 +6616,7 @@ dependencies = [ "lru 0.8.1", "parity-util-mem-derive", "parking_lot 0.12.3", - "primitive-types 0.12.2", + "primitive-types", "smallvec", "winapi", ] @@ -6885,7 +6687,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.8", + "redox_syscall 0.5.7", "smallvec", "windows-targets 0.52.6", ] @@ -6946,20 +6748,20 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.15" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" +checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" dependencies = [ "memchr", - "thiserror 2.0.11", + "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.7.15" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816518421cfc6887a0d62bf441b6ffb4536fcc926395a69e1a85852d4363f57e" +checksum = "4d3a6e3394ec80feb3b6393c725571754c6188490265c61aaf260810d6b95aa0" dependencies = [ "pest", "pest_generator", @@ -6967,22 +6769,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.15" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d1396fd3a870fc7838768d171b4616d5c91f6cc25e377b673d714567d99377b" +checksum = "94429506bde1ca69d1b5601962c73f4172ab4726571a59ea95931218cb0e930e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "pest_meta" -version = "2.7.15" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e58089ea25d717bfd31fb534e4f3afcc2cc569c70de3e239778991ea3b7dea" +checksum = "ac8a071862e93690b6e34e9a5fb8e33ff3734473ac0245b27232222c4906a33f" dependencies = [ "once_cell", "pest", @@ -6996,34 +6798,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.7.1", + "indexmap 2.6.0", ] [[package]] name = "pin-project" -version = "1.1.8" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.8" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "pin-project-lite" -version = "0.2.16" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -7056,7 +6858,7 @@ dependencies = [ "libc", "log", "polkavm-assembler", - "polkavm-common 0.9.0", + "polkavm-common", "polkavm-linux-raw", ] @@ -7078,72 +6880,35 @@ dependencies = [ "log", ] -[[package]] -name = "polkavm-common" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31ff33982a807d8567645d4784b9b5d7ab87bcb494f534a57cadd9012688e102" - [[package]] name = "polkavm-derive" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae8c4bea6f3e11cd89bb18bcdddac10bd9a24015399bd1c485ad68a985a19606" dependencies = [ - "polkavm-derive-impl-macro 0.9.0", -] - -[[package]] -name = "polkavm-derive" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2eb703f3b6404c13228402e98a5eae063fd16b8f58afe334073ec105ee4117e" -dependencies = [ - "polkavm-derive-impl-macro 0.18.0", -] - -[[package]] -name = "polkavm-derive-impl" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4fdfc49717fb9a196e74a5d28e0bc764eb394a2c803eb11133a31ac996c60c" -dependencies = [ - "polkavm-common 0.9.0", - "proc-macro2", - "quote", - "syn 2.0.96", -] - -[[package]] -name = "polkavm-derive-impl" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f2116a92e6e96220a398930f4c8a6cda1264206f3e2034fc9982bfd93f261f7" -dependencies = [ - "polkavm-common 0.18.0", - "proc-macro2", - "quote", - "syn 2.0.96", + "polkavm-derive-impl-macro", ] [[package]] -name = "polkavm-derive-impl-macro" +name = "polkavm-derive-impl" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" +checksum = "5c4fdfc49717fb9a196e74a5d28e0bc764eb394a2c803eb11133a31ac996c60c" dependencies = [ - "polkavm-derive-impl 0.9.0", - "syn 2.0.96", + "polkavm-common", + "proc-macro2", + "quote", + "syn 2.0.90", ] [[package]] name = "polkavm-derive-impl-macro" -version = "0.18.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c16669ddc7433e34c1007d31080b80901e3e8e523cb9d4b441c3910cf9294b" +checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" dependencies = [ - "polkavm-derive-impl 0.18.1", - "syn 2.0.96", + "polkavm-derive-impl", + "syn 2.0.90", ] [[package]] @@ -7156,7 +6921,7 @@ dependencies = [ "hashbrown 0.14.5", "log", "object 0.32.2", - "polkavm-common 0.9.0", + "polkavm-common", "regalloc2 0.9.3", "rustc-demangle", ] @@ -7169,15 +6934,15 @@ checksum = "26e85d3456948e650dff0cfc85603915847faf893ed1e66b020bb82ef4557120" [[package]] name = "polling" -version = "3.7.4" +version = "3.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" +checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi 0.4.0", "pin-project-lite", - "rustix 0.38.44", + "rustix 0.38.37", "tracing", "windows-sys 0.59.0", ] @@ -7207,9 +6972,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.10.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" @@ -7226,6 +6991,44 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "precompile-utils" +version = "0.1.0" +source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +dependencies = [ + "environmental", + "evm", + "fp-evm", + "frame-support", + "frame-system", + "hex", + "impl-trait-for-tuples", + "log", + "num_enum", + "pallet-evm", + "parity-scale-codec", + "precompile-utils-macro", + "sp-core", + "sp-io", + "sp-runtime", + "sp-weights", + "staging-xcm", +] + +[[package]] +name = "precompile-utils-macro" +version = "0.1.0" +source = "git+https://github.com/opentensor/frontier?rev=635bdac882#635bdac882333afed827053f31ef56ab739f7a2e" +dependencies = [ + "case", + "num_enum", + "prettyplease 0.2.22", + "proc-macro2", + "quote", + "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", + "syn 1.0.109", +] + [[package]] name = "predicates" version = "2.1.5" @@ -7242,9 +7045,9 @@ dependencies = [ [[package]] name = "predicates" -version = "3.1.3" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" +checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" dependencies = [ "anstyle", "predicates-core", @@ -7252,15 +7055,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.9" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" +checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" [[package]] name = "predicates-tree" -version = "1.0.12" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" +checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" dependencies = [ "predicates-core", "termtree", @@ -7278,12 +7081,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.29" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6924ced06e1f7dfe3fa48d57b9f74f55d8915f5036121bef647ef4b204895fac" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -7293,23 +7096,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", - "impl-codec 0.6.0", + "impl-codec", "impl-rlp", - "impl-serde 0.4.0", + "impl-serde", "scale-info", - "uint 0.9.5", -] - -[[package]] -name = "primitive-types" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d15600a7d856470b7d278b3fe0e311fe28c2526348549f8ef2ff7db3299c87f5" -dependencies = [ - "fixed-hash", - "impl-codec 0.7.0", - "impl-num-traits", - "uint 0.10.0", + "uint", ] [[package]] @@ -7318,7 +7109,7 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ - "thiserror 1.0.69", + "thiserror", "toml 0.5.11", ] @@ -7363,7 +7154,7 @@ checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -7374,14 +7165,14 @@ checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -7402,7 +7193,7 @@ dependencies = [ "quote", "regex", "sp-crypto-hashing 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -7416,7 +7207,7 @@ dependencies = [ "lazy_static", "memchr", "parking_lot 0.12.3", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -7439,7 +7230,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -7473,7 +7264,7 @@ dependencies = [ "itertools 0.10.5", "lazy_static", "log", - "multimap 0.8.3", + "multimap", "petgraph", "prettyplease 0.1.25", "prost 0.11.9", @@ -7494,14 +7285,14 @@ dependencies = [ "heck 0.5.0", "itertools 0.12.1", "log", - "multimap 0.10.0", + "multimap", "once_cell", "petgraph", - "prettyplease 0.2.29", + "prettyplease 0.2.22", "prost 0.12.6", "prost-types 0.12.6", "regex", - "syn 2.0.96", + "syn 2.0.90", "tempfile", ] @@ -7528,7 +7319,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -7551,24 +7342,24 @@ dependencies = [ [[package]] name = "psm" -version = "0.1.24" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810" +checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" dependencies = [ "cc", ] [[package]] name = "quanta" -version = "0.12.5" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bd1fe6824cea6538803de3ff1bc0cf3949024db3d43c9643024bfb33a807c0e" +checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5" dependencies = [ "crossbeam-utils", "libc", "once_cell", "raw-cpuid", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "web-sys", "winapi", ] @@ -7597,7 +7388,7 @@ dependencies = [ "asynchronous-codec", "bytes", "quick-protobuf", - "thiserror 1.0.69", + "thiserror", "unsigned-varint 0.7.2", ] @@ -7613,7 +7404,7 @@ dependencies = [ "quinn-udp 0.3.2", "rustc-hash 1.1.0", "rustls 0.20.9", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", "webpki", @@ -7632,7 +7423,7 @@ dependencies = [ "quinn-udp 0.4.1", "rustc-hash 1.1.0", "rustls 0.21.12", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", ] @@ -7649,7 +7440,7 @@ dependencies = [ "rustc-hash 1.1.0", "rustls 0.20.9", "slab", - "thiserror 1.0.69", + "thiserror", "tinyvec", "tracing", "webpki", @@ -7667,7 +7458,7 @@ dependencies = [ "rustc-hash 1.1.0", "rustls 0.21.12", "slab", - "thiserror 1.0.69", + "thiserror", "tinyvec", "tracing", ] @@ -7693,16 +7484,16 @@ checksum = "055b4e778e8feb9f93c4e439f71dc2156ef13360b432b799e179a8c4cdf0b1d7" dependencies = [ "bytes", "libc", - "socket2 0.5.8", + "socket2 0.5.7", "tracing", "windows-sys 0.48.0", ] [[package]] name = "quote" -version = "1.0.38" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -7740,7 +7531,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.15", + "getrandom", ] [[package]] @@ -7764,11 +7555,11 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "11.3.0" +version = "11.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6928fa44c097620b706542d428957635951bade7143269085389d42c8a4927e" +checksum = "1ab240315c661615f2ee9f0f2cd32d5a7343a84d5ebcccb99d46e6637565e7b0" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.6.0", ] [[package]] @@ -7820,11 +7611,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.6.0", ] [[package]] @@ -7833,9 +7624,9 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom 0.2.15", + "getrandom", "libredox", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -7855,7 +7646,7 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -7885,13 +7676,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.9", + "regex-automata 0.4.8", "regex-syntax 0.8.5", ] @@ -7906,9 +7697,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -7970,7 +7761,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.15", + "getrandom", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -8037,19 +7828,16 @@ dependencies = [ [[package]] name = "rtnetlink" -version = "0.13.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a552eb82d19f38c3beed3f786bd23aa434ceb9ac43ab44419ca6d67a7e186c0" +checksum = "322c53fd76a18698f1c27381d58091de3a043d356aa5bd0d510608b565f469a0" dependencies = [ "futures", "log", - "netlink-packet-core", "netlink-packet-route", - "netlink-packet-utils", "netlink-proto", - "netlink-sys", "nix", - "thiserror 1.0.69", + "thiserror", "tokio", ] @@ -8077,9 +7865,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc-hash" -version = "2.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustc-hex" @@ -8102,7 +7890,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "semver 1.0.25", + "semver 1.0.23", ] [[package]] @@ -8130,15 +7918,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.44" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.6.0", "errno", "libc", - "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", + "linux-raw-sys 0.4.14", + "windows-sys 0.52.0", ] [[package]] @@ -8197,9 +7985,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.19" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "rw-stream-sink" @@ -8214,9 +8002,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "safe-math" @@ -8238,9 +8026,9 @@ dependencies = [ [[package]] name = "safe_arch" -version = "0.7.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b02de82ddbe1b636e6170c21be622223aea188ef2e139be0a5b219ec215323" +checksum = "c3460605018fdc9612bce72735cba0d27efbcd9904780d44c7e3a9948f96148a" dependencies = [ "bytemuck", ] @@ -8262,7 +8050,7 @@ dependencies = [ "log", "sp-core", "sp-wasm-interface 21.0.1", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8337,7 +8125,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -8377,7 +8165,7 @@ dependencies = [ "sp-panic-handler", "sp-runtime", "sp-version", - "thiserror 1.0.69", + "thiserror", "tokio", ] @@ -8455,7 +8243,7 @@ dependencies = [ "sp-runtime", "sp-state-machine", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8484,7 +8272,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8520,7 +8308,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8577,7 +8365,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8597,7 +8385,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8632,7 +8420,7 @@ dependencies = [ "sp-runtime", "sp-timestamp", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8690,7 +8478,7 @@ dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", "sp-wasm-interface 21.0.1", - "thiserror 1.0.69", + "thiserror", "wasm-instrument", ] @@ -8751,7 +8539,7 @@ dependencies = [ "sp-application-crypto", "sp-core", "sp-keystore", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8780,7 +8568,7 @@ dependencies = [ "sp-keystore", "sp-mixnet", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8825,7 +8613,7 @@ dependencies = [ "sp-core", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", "tokio", "tokio-stream", "unsigned-varint 0.7.2", @@ -8889,7 +8677,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -8924,7 +8712,7 @@ dependencies = [ "sp-core", "sp-runtime", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", "tokio", "tokio-stream", ] @@ -8959,9 +8747,9 @@ dependencies = [ "litep2p", "log", "multiaddr 0.18.2", - "multihash 0.19.3", + "multihash 0.19.2", "rand", - "thiserror 1.0.69", + "thiserror", "zeroize", ] @@ -8975,7 +8763,7 @@ dependencies = [ "fnv", "futures", "futures-timer", - "hyper 0.14.32", + "hyper 0.14.30", "hyper-rustls", "log", "num_cpus", @@ -9057,7 +8845,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-version", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -9069,9 +8857,9 @@ dependencies = [ "forwarded-header-value", "futures", "governor", - "http 1.2.0", + "http 1.1.0", "http-body-util", - "hyper 1.6.0", + "hyper 1.5.0", "ip_network", "jsonrpsee", "log", @@ -9111,7 +8899,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-version", - "thiserror 1.0.69", + "thiserror", "tokio", "tokio-stream", ] @@ -9174,7 +8962,7 @@ dependencies = [ "static_init", "substrate-prometheus-endpoint", "tempfile", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", "tracing-futures", @@ -9196,7 +8984,7 @@ name = "sc-sysinfo" version = "38.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "derive_more 0.99.18", + "derive_more", "futures", "libc", "log", @@ -9228,7 +9016,7 @@ dependencies = [ "sc-utils", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", "wasm-timer", ] @@ -9255,10 +9043,10 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-tracing 17.0.1", - "thiserror 1.0.69", + "thiserror", "tracing", "tracing-log", - "tracing-subscriber 0.3.19", + "tracing-subscriber 0.3.18", ] [[package]] @@ -9269,7 +9057,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -9296,7 +9084,7 @@ dependencies = [ "sp-tracing 17.0.1", "sp-transaction-pool", "substrate-prometheus-endpoint", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -9312,7 +9100,7 @@ dependencies = [ "sp-blockchain", "sp-core", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -9346,7 +9134,7 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e98f3262c250d90e700bb802eb704e1f841e03331c2eb815e46516c4edbf5b27" dependencies = [ - "derive_more 0.99.18", + "derive_more", "parity-scale-codec", "scale-bits", "scale-type-resolver", @@ -9355,13 +9143,13 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.6" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "bitvec", "cfg-if", - "derive_more 1.0.0", + "derive_more", "parity-scale-codec", "scale-info-derive", "serde", @@ -9369,14 +9157,14 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.6" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6630024bf739e2179b91fb424b28898baf819414262c5d376677dbff1fe7ebf" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 1.0.109", ] [[package]] @@ -9387,18 +9175,18 @@ checksum = "f0cded6518aa0bd6c1be2b88ac81bf7044992f0f154bfbabd5ad34f43512abcb" [[package]] name = "schannel" -version = "0.1.27" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ "windows-sys 0.59.0", ] [[package]] name = "schnellru" -version = "0.2.4" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356285bbf17bea63d9e52e96bd18f039672ac92b55b8cb997d6162a2a37d1649" +checksum = "c9a8ef13a93c54d20580de1e5c413e624e53121d42fc7e2c11d10ef7f8b02367" dependencies = [ "ahash 0.8.11", "cfg-if", @@ -9458,7 +9246,7 @@ dependencies = [ "log", "rand", "slab", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -9509,7 +9297,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -9518,9 +9306,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.14.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -9546,9 +9334,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.25" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] @@ -9567,9 +9355,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] @@ -9604,20 +9392,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -9671,7 +9459,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -9795,9 +9583,9 @@ dependencies = [ [[package]] name = "simba" -version = "0.9.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a386a501cd104797982c15ae17aafe8b9261315b5d07e3ec803f2ea26be0fa" +checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" dependencies = [ "approx", "num-complex", @@ -9812,7 +9600,7 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cae9a3fcdadafb6d97f4c0e007e4247b114ee0f119f650c3cbf3a8b3a1479694" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.6.0", ] [[package]] @@ -9883,9 +9671,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.8" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -9893,14 +9681,14 @@ dependencies = [ [[package]] name = "soketto" -version = "0.8.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e859df029d160cb88608f5d7df7fb4753fd20fdfb4de5644f3d8b8440841721" +checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" dependencies = [ "base64 0.22.1", "bytes", "futures", - "http 1.2.0", + "http 1.1.0", "httparse", "log", "rand", @@ -9926,7 +9714,7 @@ dependencies = [ "sp-state-machine", "sp-trie", "sp-version", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -9940,7 +9728,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -10003,7 +9791,7 @@ dependencies = [ "sp-database", "sp-runtime", "sp-state-machine", - "thiserror 1.0.69", + "thiserror", "tracing", ] @@ -10019,7 +9807,7 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -10099,7 +9887,7 @@ dependencies = [ "futures", "hash-db", "hash256-std-hasher", - "impl-serde 0.4.0", + "impl-serde", "itertools 0.11.0", "k256", "libsecp256k1", @@ -10109,7 +9897,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.3", "paste", - "primitive-types 0.12.2", + "primitive-types", "rand", "scale-info", "schnorrkel", @@ -10124,7 +9912,7 @@ dependencies = [ "sp-storage 21.0.0", "ss58-registry", "substrate-bip39", - "thiserror 1.0.69", + "thiserror", "tracing", "w3f-bls", "zeroize", @@ -10133,7 +9921,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/paritytech/polkadot-sdk#80e30ec3cdccae8e9099bd67840ff8737b043496" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -10204,7 +9992,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "quote", "sp-crypto-hashing 0.1.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -10223,23 +10011,23 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#80e30ec3cdccae8e9099bd67840ff8737b043496" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/paritytech/polkadot-sdk#80e30ec3cdccae8e9099bd67840ff8737b043496" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "environmental", "parity-scale-codec", @@ -10278,7 +10066,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -10292,7 +10080,7 @@ dependencies = [ "libsecp256k1", "log", "parity-scale-codec", - "polkavm-derive 0.9.1", + "polkavm-derive", "rustversion", "secp256k1", "sp-core", @@ -10333,7 +10121,7 @@ name = "sp-maybe-compressed-blob" version = "11.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "thiserror 1.0.69", + "thiserror", "zstd 0.12.4", ] @@ -10417,13 +10205,13 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#80e30ec3cdccae8e9099bd67840ff8737b043496" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec", - "polkavm-derive 0.18.0", - "primitive-types 0.13.1", + "polkavm-derive", + "primitive-types", "sp-externalities 0.25.0", "sp-runtime-interface-proc-macro 17.0.0", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk)", @@ -10441,8 +10229,8 @@ dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec", - "polkavm-derive 0.9.1", - "primitive-types 0.12.2", + "polkavm-derive", + "primitive-types", "sp-externalities 0.29.0", "sp-runtime-interface-proc-macro 18.0.0", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", @@ -10455,14 +10243,14 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#80e30ec3cdccae8e9099bd67840ff8737b043496" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "Inflector", "expander", "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -10475,7 +10263,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -10520,7 +10308,7 @@ dependencies = [ "sp-externalities 0.29.0", "sp-panic-handler", "sp-trie", - "thiserror 1.0.69", + "thiserror", "tracing", "trie-db", ] @@ -10545,7 +10333,7 @@ dependencies = [ "sp-externalities 0.29.0", "sp-runtime", "sp-runtime-interface 28.0.0", - "thiserror 1.0.69", + "thiserror", "x25519-dalek", ] @@ -10557,14 +10345,14 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#80e30ec3cdccae8e9099bd67840ff8737b043496" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#80e30ec3cdccae8e9099bd67840ff8737b043496" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ - "impl-serde 0.5.0", + "impl-serde", "parity-scale-codec", "ref-cast", "serde", @@ -10576,7 +10364,7 @@ name = "sp-storage" version = "21.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "impl-serde 0.4.0", + "impl-serde", "parity-scale-codec", "ref-cast", "serde", @@ -10592,18 +10380,18 @@ dependencies = [ "parity-scale-codec", "sp-inherents", "sp-runtime", - "thiserror 1.0.69", + "thiserror", ] [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#80e30ec3cdccae8e9099bd67840ff8737b043496" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "parity-scale-codec", "tracing", "tracing-core", - "tracing-subscriber 0.3.19", + "tracing-subscriber 0.3.18", ] [[package]] @@ -10614,7 +10402,7 @@ dependencies = [ "parity-scale-codec", "tracing", "tracing-core", - "tracing-subscriber 0.3.19", + "tracing-subscriber 0.3.18", ] [[package]] @@ -10657,7 +10445,7 @@ dependencies = [ "schnellru", "sp-core", "sp-externalities 0.29.0", - "thiserror 1.0.69", + "thiserror", "tracing", "trie-db", "trie-root", @@ -10668,7 +10456,7 @@ name = "sp-version" version = "37.0.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ - "impl-serde 0.4.0", + "impl-serde", "parity-scale-codec", "parity-wasm", "scale-info", @@ -10677,7 +10465,7 @@ dependencies = [ "sp-runtime", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409)", "sp-version-proc-macro", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -10688,13 +10476,13 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#80e30ec3cdccae8e9099bd67840ff8737b043496" +source = "git+https://github.com/paritytech/polkadot-sdk#8614dc0e055d06de4a3774ac1da0a422b33f34e2" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -10762,11 +10550,21 @@ dependencies = [ "der", ] +[[package]] +name = "sqlformat" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bba3a93db0cc4f7bdece8bb09e77e2e785c20bfebf79eb8340ed80708048790" +dependencies = [ + "nom", + "unicode_categories", +] + [[package]] name = "sqlx" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4410e73b3c0d8442c5f99b425d7a435b5ee0ae4167b3196771dd3f7a01be745f" +checksum = "93334716a037193fac19df402f8571269c84a00852f6a7066b5d2616dcd64d3e" dependencies = [ "sqlx-core", "sqlx-macros", @@ -10775,31 +10573,37 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a007b6936676aa9ab40207cde35daab0a04b823be8ae004368c0793b96a61e0" +checksum = "d4d8060b456358185f7d50c55d9b5066ad956956fddec42ee2e8567134a8936e" dependencies = [ + "atoi", + "byteorder", "bytes", "crc", "crossbeam-queue", "either", - "event-listener 5.4.0", + "event-listener 5.3.1", + "futures-channel", "futures-core", "futures-intrusive", "futures-io", "futures-util", - "hashbrown 0.15.2", - "hashlink 0.10.0", - "indexmap 2.7.1", + "hashbrown 0.14.5", + "hashlink 0.9.1", + "hex", + "indexmap 2.6.0", "log", "memchr", "native-tls", "once_cell", + "paste", "percent-encoding", "serde", "sha2 0.10.8", "smallvec", - "thiserror 2.0.11", + "sqlformat", + "thiserror", "tokio", "tokio-stream", "tracing", @@ -10808,22 +10612,22 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3112e2ad78643fef903618d78cf0aec1cb3134b019730edb039b69eaf531f310" +checksum = "cac0692bcc9de3b073e8d747391827297e075c7710ff6276d9f7a1f3d58c6657" dependencies = [ "proc-macro2", "quote", "sqlx-core", "sqlx-macros-core", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "sqlx-macros-core" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9f90acc5ab146a99bf5061a7eb4976b573f560bc898ef3bf8435448dd5e7ad" +checksum = "1804e8a7c7865599c9c79be146dc8a9fd8cc86935fa641d3ea58e5f0688abaa5" dependencies = [ "dotenvy", "either", @@ -10837,7 +10641,7 @@ dependencies = [ "sha2 0.10.8", "sqlx-core", "sqlx-sqlite", - "syn 2.0.96", + "syn 2.0.90", "tempfile", "tokio", "url", @@ -10845,9 +10649,9 @@ dependencies = [ [[package]] name = "sqlx-sqlite" -version = "0.8.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f85ca71d3a5b24e64e1d08dd8fe36c6c95c339a896cc33068148906784620540" +checksum = "d5b2cf34a45953bfd3daaf3db0f7a7878ab9b7a6b91b422d24a7a9e4c857b680" dependencies = [ "atoi", "flume", @@ -10868,9 +10672,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.51.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19409f13998e55816d1c728395af0b52ec066206341d939e22e7766df9b494b8" +checksum = "43fce22ed1df64d04b262351c8f9d5c6da4f76f79f25ad15529792f893fad25d" dependencies = [ "Inflector", "num-format", @@ -10929,9 +10733,9 @@ dependencies = [ [[package]] name = "static_init_macro" -version = "1.0.4" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1389c88ddd739ec6d3f8f83343764a0e944cd23cfbf126a9796a714b0b6edd6f" +checksum = "70a2595fc3aa78f2d0e45dd425b22282dd863273761cc77780914b2cf3003acf" dependencies = [ "cfg_aliases", "memchr", @@ -10956,7 +10760,7 @@ dependencies = [ "sctp-proto", "serde", "sha-1", - "thiserror 1.0.69", + "thiserror", "tracing", ] @@ -11004,7 +10808,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -11061,11 +10865,11 @@ version = "0.17.0" source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2409#87971b3e92721bdf10bf40b410eaae779d494ca0" dependencies = [ "http-body-util", - "hyper 1.6.0", + "hyper 1.5.0", "hyper-util", "log", "prometheus", - "thiserror 1.0.69", + "thiserror", "tokio", ] @@ -11108,7 +10912,7 @@ dependencies = [ "quote", "rayon", "subtensor-linting", - "syn 2.0.96", + "syn 2.0.90", "walkdir", ] @@ -11146,7 +10950,7 @@ dependencies = [ "proc-macro2", "procedural-fork", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -11156,7 +10960,7 @@ dependencies = [ "ahash 0.8.11", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -11165,7 +10969,7 @@ version = "0.1.0" dependencies = [ "anyhow", "clap", - "semver 1.0.25", + "semver 1.0.23", "toml_edit", ] @@ -11194,9 +10998,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.96" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -11223,25 +11027,25 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "system-configuration" -version = "0.6.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 2.8.0", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" dependencies = [ "core-foundation-sys", "libc", @@ -11261,15 +11065,14 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.16.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", - "getrandom 0.3.1", "once_cell", - "rustix 0.38.44", + "rustix 0.38.37", "windows-sys 0.59.0", ] @@ -11284,58 +11087,38 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9" +checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" dependencies = [ - "rustix 0.38.44", + "rustix 0.38.37", "windows-sys 0.59.0", ] [[package]] name = "termtree" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" - -[[package]] -name = "thiserror" -version = "1.0.69" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl 1.0.69", -] +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "2.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" -dependencies = [ - "thiserror-impl 2.0.11", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.96", + "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -11375,9 +11158,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.37" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -11396,9 +11179,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.19" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -11413,21 +11196,11 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", - "zerovec", -] - [[package]] name = "tinyvec" -version = "1.8.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -11468,9 +11241,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.43.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -11479,20 +11252,20 @@ dependencies = [ "parking_lot 0.12.3", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.8", + "socket2 0.5.7", "tokio-macros", "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.5.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] @@ -11507,9 +11280,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.17" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -11534,9 +11307,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.13" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -11582,7 +11355,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.7.1", + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -11610,9 +11383,9 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.6.0", "bytes", - "http 1.2.0", + "http 1.1.0", "http-body 1.0.1", "http-body-util", "pin-project-lite", @@ -11634,9 +11407,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "log", "pin-project-lite", @@ -11646,20 +11419,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.28" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -11697,9 +11470,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.19" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -11755,7 +11528,7 @@ dependencies = [ "rand", "smallvec", "socket2 0.4.10", - "thiserror 1.0.69", + "thiserror", "tinyvec", "tokio", "tracing", @@ -11780,7 +11553,7 @@ dependencies = [ "once_cell", "rand", "smallvec", - "thiserror 1.0.69", + "thiserror", "tinyvec", "tokio", "tracing", @@ -11802,7 +11575,7 @@ dependencies = [ "rand", "resolv-conf", "smallvec", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", "trust-dns-proto 0.23.2", @@ -11835,7 +11608,7 @@ dependencies = [ "rand", "rustls 0.21.12", "sha1", - "thiserror 1.0.69", + "thiserror", "url", "utf-8", ] @@ -11885,29 +11658,17 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "uint" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909988d098b2f738727b161a106cfc7cab00c539c2687a8836f8e565976fb53e" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-bidi" -version = "0.3.18" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" @@ -11924,18 +11685,18 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" -[[package]] -name = "unicode-width" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" - [[package]] name = "unicode-xid" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + [[package]] name = "universal-hash" version = "0.5.1" @@ -11982,12 +11743,12 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.4" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", - "idna 1.0.3", + "idna 0.5.0", "percent-encoding", ] @@ -11997,18 +11758,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "utf8parse" version = "0.2.2" @@ -12017,9 +11766,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "valuable" -version = "0.1.1" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "vcpkg" @@ -12059,7 +11808,7 @@ dependencies = [ "rand_core", "sha2 0.10.8", "sha3", - "thiserror 1.0.69", + "thiserror", "zeroize", ] @@ -12088,59 +11837,49 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasi" -version = "0.13.3+wasi-0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" -dependencies = [ - "wit-bindgen-rt", -] - [[package]] name = "wasm-bindgen" -version = "0.2.100" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", "once_cell", - "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.100" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", + "once_cell", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.50" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", - "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12148,25 +11887,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" -dependencies = [ - "unicode-ident", -] +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-instrument" @@ -12188,7 +11924,7 @@ dependencies = [ "strum 0.24.1", "strum_macros 0.24.3", "tempfile", - "thiserror 1.0.69", + "thiserror", "wasm-opt-cxx-sys", "wasm-opt-sys", ] @@ -12315,7 +12051,7 @@ dependencies = [ "log", "object 0.30.4", "target-lexicon", - "thiserror 1.0.69", + "thiserror", "wasmparser", "wasmtime-cranelift-shared", "wasmtime-environ", @@ -12350,7 +12086,7 @@ dependencies = [ "object 0.30.4", "serde", "target-lexicon", - "thiserror 1.0.69", + "thiserror", "wasmparser", "wasmtime-types", ] @@ -12433,15 +12169,15 @@ checksum = "a4f6fffd2a1011887d57f07654dd112791e872e3ff4a2e626aee8059ee17f06f" dependencies = [ "cranelift-entity", "serde", - "thiserror 1.0.69", + "thiserror", "wasmparser", ] [[package]] name = "web-sys" -version = "0.3.77" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", @@ -12472,14 +12208,14 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.44", + "rustix 0.38.37", ] [[package]] name = "wide" -version = "0.7.32" +version = "0.7.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b5576b9a81633f3e8df296ce0063042a73507636cbe956c61133dd7034ab22" +checksum = "b828f995bf1e9622031f8009f8481a85406ce1f4d4588ff746d872043e855690" dependencies = [ "bytemuck", "safe_arch", @@ -12524,38 +12260,28 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.53.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efc5cf48f83140dcaab716eeaea345f9e93d0018fb81162753a3f76c3397b538" +checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ - "windows-core 0.53.0", - "windows-targets 0.52.6", + "windows-core 0.51.1", + "windows-targets 0.48.5", ] [[package]] name = "windows-core" -version = "0.52.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] name = "windows-core" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dcc5b895a6377f1ab9fa55acedab1fd5ac0db66ad1e6c7f47e28a22e446a5dd" -dependencies = [ - "windows-result", - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-result" -version = "0.1.2" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ "windows-targets 0.52.6", ] @@ -12791,9 +12517,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.25" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad699df48212c6cc6eb4435f35500ac6fd3b9913324f938aea302022ce19d310" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -12808,27 +12534,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "wit-bindgen-rt" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" -dependencies = [ - "bitflags 2.8.0", -] - -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" - [[package]] name = "wyz" version = "0.5.1" @@ -12863,7 +12568,7 @@ dependencies = [ "nom", "oid-registry 0.6.1", "rusticata-macros", - "thiserror 1.0.69", + "thiserror", "time", ] @@ -12880,7 +12585,7 @@ dependencies = [ "nom", "oid-registry 0.7.1", "rusticata-macros", - "thiserror 1.0.69", + "thiserror", "time", ] @@ -12892,14 +12597,14 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] name = "xml-rs" -version = "0.8.25" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5b940ebc25896e71dd073bad2dbaa2abfe97b0a391415e22ad1326d9c54e3c4" +checksum = "af4e2e2f7cba5a093896c1e150fbfe177d1883e7448200efb81d40b9d339ef26" [[package]] name = "xmltree" @@ -12934,30 +12639,6 @@ dependencies = [ "time", ] -[[package]] -name = "yoke" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.96", - "synstructure 0.13.1", -] - [[package]] name = "zerocopy" version = "0.7.35" @@ -12976,28 +12657,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", -] - -[[package]] -name = "zerofrom" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.96", - "synstructure 0.13.1", + "syn 2.0.90", ] [[package]] @@ -13017,29 +12677,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", -] - -[[package]] -name = "zerovec" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.96", + "syn 2.0.90", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0e723d6ae..ef5d64b0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" description = "Implementation of the bittensor blockchain" authors = ["Substrate DevHub "] homepage = "https://substrate.io/" -edition = "2021" +edition = "2024" license = "Unlicense" publish = false repository = "https://github.com/opentensor/subtensor" @@ -46,6 +46,7 @@ arithmetic-side-effects = "deny" type_complexity = "allow" unwrap-used = "deny" manual_inspect = "allow" +useless_conversion = "allow" # until polkadot is patched [workspace.dependencies] async-trait = "0.1" diff --git a/docker-compose.yml b/docker-compose.yml index 09638c174..74fd8abd2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,7 +41,6 @@ services: --chain raw_spec_finney.json \ --rpc-external --rpc-cors all \ --no-mdns \ - --in-peers 500 --out-peers 500 \ --bootnodes /dns/bootnode.finney.chain.opentensor.ai/tcp/30333/ws/p2p/12D3KooWRwbMb85RWnT8DSXSYMWQtuDwh4LJzndoRrTDotTR5gDC \ --sync warp @@ -59,7 +58,6 @@ services: --chain raw_spec_finney.json \ --rpc-external --rpc-cors all \ --no-mdns \ - --in-peers 500 --out-peers 500 \ --bootnodes /dns/bootnode.finney.chain.opentensor.ai/tcp/30333/ws/p2p/12D3KooWRwbMb85RWnT8DSXSYMWQtuDwh4LJzndoRrTDotTR5gDC \ --pruning=archive @@ -77,7 +75,6 @@ services: --chain raw_spec_testfinney.json \ --rpc-external --rpc-cors all \ --no-mdns \ - --in-peers 500 --out-peers 500 \ --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr \ --sync warp --reserved-nodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr \ @@ -97,7 +94,6 @@ services: --chain raw_spec_testfinney.json \ --rpc-external --rpc-cors all \ --no-mdns \ - --in-peers 500 --out-peers 500 \ --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr \ --pruning=archive --reserved-nodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr \ diff --git a/docs/rust-setup.md b/docs/rust-setup.md index 1527d5b8b..346b424a0 100644 --- a/docs/rust-setup.md +++ b/docs/rust-setup.md @@ -24,7 +24,7 @@ Use a terminal shell to execute the following commands: ```bash sudo apt update # May prompt for location information -sudo apt install -y git clang curl libssl-dev llvm libudev-dev +sudo apt install -y git clang curl libssl-dev llvm libudev-dev make pkg-config protobuf-compiler ``` ### Arch Linux diff --git a/node/Cargo.toml b/node/Cargo.toml index 9599e1905..f97425ba9 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -4,7 +4,7 @@ version = "4.0.0-dev" description = "A fresh FRAME-based Substrate node, ready for hacking." authors = ["Substrate DevHub "] homepage = "https://substrate.io/" -edition = "2021" +edition = "2024" license = "Unlicense" publish = false repository = "https://github.com/opentensor/subtensor" diff --git a/node/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs index 5d908430a..25942658d 100644 --- a/node/src/chain_spec/mod.rs +++ b/node/src/chain_spec/mod.rs @@ -12,9 +12,9 @@ use sc_service::ChainType; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_consensus_grandpa::AuthorityId as GrandpaId; use sp_core::crypto::Ss58Codec; -use sp_core::{bounded_vec, sr25519, Pair, Public, H256}; -use sp_runtime::traits::{IdentifyAccount, Verify}; +use sp_core::{H256, Pair, Public, bounded_vec, sr25519}; use sp_runtime::AccountId32; +use sp_runtime::traits::{IdentifyAccount, Verify}; use std::collections::HashSet; use std::env; use std::str::FromStr; diff --git a/node/src/client.rs b/node/src/client.rs index 0ee39d51d..1c2503f21 100644 --- a/node/src/client.rs +++ b/node/src/client.rs @@ -1,4 +1,4 @@ -use node_subtensor_runtime::{opaque::Block, RuntimeApi}; +use node_subtensor_runtime::{RuntimeApi, opaque::Block}; use sc_executor::WasmExecutor; /// Full backend. diff --git a/node/src/command.rs b/node/src/command.rs index 7b6d6982b..5b88e03f9 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -4,14 +4,14 @@ use crate::{ ethereum::db_config_dir, service, }; -use fc_db::{kv::frontier_database_dir, DatabaseSource}; +use fc_db::{DatabaseSource, kv::frontier_database_dir}; use futures::TryFutureExt; use node_subtensor_runtime::Block; use sc_cli::SubstrateCli; use sc_service::{ - config::{ExecutorConfiguration, RpcConfiguration}, Configuration, + config::{ExecutorConfiguration, RpcConfiguration}, }; impl SubstrateCli for Cli { @@ -115,7 +115,7 @@ pub fn run() -> sc_cli::Result<()> { "Cannot purge `{:?}` database", config.database ) - .into()) + .into()); } }; cmd.run(frontier_database_config)?; @@ -134,7 +134,7 @@ pub fn run() -> sc_cli::Result<()> { "Cannot purge `{:?}` database: {:?}", db_path, err, ) - .into()) + .into()); } }; } @@ -157,7 +157,7 @@ pub fn run() -> sc_cli::Result<()> { #[cfg(feature = "runtime-benchmarks")] Some(Subcommand::Benchmark(cmd)) => { use crate::benchmarking::{ - inherent_benchmark_data, RemarkBuilder, TransferKeepAliveBuilder, + RemarkBuilder, TransferKeepAliveBuilder, inherent_benchmark_data, }; use frame_benchmarking_cli::{ BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE, diff --git a/node/src/ethereum.rs b/node/src/ethereum.rs index 44ab48926..158bd8480 100644 --- a/node/src/ethereum.rs +++ b/node/src/ethereum.rs @@ -1,21 +1,21 @@ pub use fc_consensus::FrontierBlockImport; use fc_rpc::{ - pending::AuraConsensusDataProvider, Debug, DebugApiServer, Eth, EthApiServer, EthConfig, - EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub, EthPubSubApiServer, EthSigner, EthTask, - Net, NetApiServer, Web3, Web3ApiServer, + Debug, DebugApiServer, Eth, EthApiServer, EthConfig, EthDevSigner, EthFilter, + EthFilterApiServer, EthPubSub, EthPubSubApiServer, EthSigner, EthTask, Net, NetApiServer, Web3, + Web3ApiServer, pending::AuraConsensusDataProvider, }; pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; /// Frontier DB backend type. pub use fc_storage::{StorageOverride, StorageOverrideHandler}; use fp_rpc::ConvertTransaction; -use futures::future; use futures::StreamExt; +use futures::future; use jsonrpsee::RpcModule; use node_subtensor_runtime::opaque::Block; use sc_client_api::client::BlockchainEvents; use sc_network_sync::SyncingService; use sc_rpc::SubscriptionTaskExecutor; -use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; +use sc_service::{Configuration, TaskManager, error::Error as ServiceError}; use sc_transaction_pool::ChainApi; use sc_transaction_pool_api::TransactionPool; use sp_inherents::CreateInherentDataProviders; diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 3b4729c71..39a63c602 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -13,8 +13,8 @@ pub use fc_rpc::EthBlockDataCacheTask; pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; use fc_storage::StorageOverride; use jsonrpsee::RpcModule; -use node_subtensor_runtime::opaque::Block; use node_subtensor_runtime::Hash; +use node_subtensor_runtime::opaque::Block; use sc_consensus_manual_seal::EngineCommand; use sc_network::service::traits::NetworkService; use sc_network_sync::SyncingService; diff --git a/node/src/service.rs b/node/src/service.rs index 9f0f240dc..a0b7cb1c6 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -1,9 +1,9 @@ //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. -use fp_consensus::{ensure_log, FindLogError}; +use fp_consensus::{FindLogError, ensure_log}; use fp_rpc::EthereumRuntimeRPCApi; -use futures::{channel::mpsc, future, FutureExt}; -use node_subtensor_runtime::{opaque::Block, RuntimeApi, TransactionConverter}; +use futures::{FutureExt, channel::mpsc, future}; +use node_subtensor_runtime::{RuntimeApi, TransactionConverter, opaque::Block}; use sc_client_api::{Backend as BackendT, BlockBackend}; use sc_consensus::{ BasicQueue, BlockCheckParams, BlockImport, BlockImportParams, BoxBlockImport, ImportResult, @@ -11,8 +11,8 @@ use sc_consensus::{ use sc_consensus_grandpa::BlockNumberOps; use sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging; use sc_network_sync::strategy::warp::{WarpSyncConfig, WarpSyncProvider}; -use sc_service::{error::Error as ServiceError, Configuration, PartialComponents, TaskManager}; -use sc_telemetry::{log, Telemetry, TelemetryHandle, TelemetryWorker}; +use sc_service::{Configuration, PartialComponents, TaskManager, error::Error as ServiceError}; +use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, log}; use sc_transaction_pool::FullPool; use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sp_api::ProvideRuntimeApi; @@ -27,9 +27,9 @@ use substrate_prometheus_endpoint::Registry; use crate::cli::Sealing; use crate::client::{FullBackend, FullClient, HostFunctions, RuntimeExecutor}; use crate::ethereum::{ - db_config_dir, new_frontier_partial, spawn_frontier_tasks, BackendType, EthConfiguration, - FrontierBackend, FrontierBlockImport, FrontierPartialComponents, StorageOverride, - StorageOverrideHandler, + BackendType, EthConfiguration, FrontierBackend, FrontierBlockImport, FrontierPartialComponents, + StorageOverride, StorageOverrideHandler, db_config_dir, new_frontier_partial, + spawn_frontier_tasks, }; /// The minimum period of blocks on which justifications will be diff --git a/pallets/admin-utils/Cargo.toml b/pallets/admin-utils/Cargo.toml index ec14c1768..b3c1410cc 100644 --- a/pallets/admin-utils/Cargo.toml +++ b/pallets/admin-utils/Cargo.toml @@ -4,7 +4,7 @@ version = "4.0.0-dev" description = "FRAME pallet for extending admin utilities." authors = ["Bittensor Nucleus Team"] homepage = "https://bittensor.com" -edition = "2021" +edition = "2024" license = "Unlicense" publish = false repository = "https://github.com/opentensor/subtensor" diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 0d3232d89..7bc9e986e 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -12,7 +12,7 @@ use frame_system::pallet_prelude::BlockNumberFor; // - we could use a type parameter for `AuthorityId`, but there is // no sense for this as GRANDPA's `AuthorityId` is not a parameter -- it's always the same use sp_consensus_grandpa::AuthorityList; -use sp_runtime::{traits::Member, DispatchResult, RuntimeAppPublic}; +use sp_runtime::{DispatchResult, RuntimeAppPublic, traits::Member}; mod benchmarking; @@ -29,6 +29,7 @@ pub mod pallet { use frame_system::pallet_prelude::*; use pallet_evm_chain_id::{self, ChainId}; use sp_runtime::BoundedVec; + use substrate_fixed::types::I96F32; /// The main data structure of the module. #[pallet::pallet] @@ -586,10 +587,10 @@ pub mod pallet { target_registrations_per_interval, ); log::debug!( - "RegistrationPerIntervalSet( netuid: {:?} target_registrations_per_interval: {:?} ) ", - netuid, - target_registrations_per_interval - ); + "RegistrationPerIntervalSet( netuid: {:?} target_registrations_per_interval: {:?} ) ", + netuid, + target_registrations_per_interval + ); Ok(()) } @@ -1377,6 +1378,27 @@ pub mod pallet { } Ok(()) } + + /// + /// + /// # Arguments + /// * `origin` - The origin of the call, which must be the root account. + /// * `alpha` - The new moving alpha value for the SubnetMovingAlpha. + /// + /// # Errors + /// * `BadOrigin` - If the caller is not the root account. + /// + /// # Weight + /// Weight is handled by the `#[pallet::weight]` attribute. + #[pallet::call_index(63)] + #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + pub fn sudo_set_subnet_moving_alpha(origin: OriginFor, alpha: I96F32) -> DispatchResult { + ensure_root(origin)?; + pallet_subtensor::SubnetMovingAlpha::::set(alpha); + + log::debug!("SubnetMovingAlphaSet( alpha: {:?} )", alpha); + Ok(()) + } } } diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 048bf9960..40e29e54d 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -6,15 +6,15 @@ use frame_support::{ weights, }; use frame_system as system; -use frame_system::{limits, EnsureNever, EnsureRoot}; +use frame_system::{EnsureNever, EnsureRoot, limits}; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_consensus_grandpa::AuthorityList as GrandpaAuthorityList; use sp_core::U256; use sp_core::{ConstU64, H256}; use sp_runtime::{ + BuildStorage, KeyTypeId, Perbill, testing::TestXt, traits::{BlakeTwo256, ConstU32, IdentityLookup}, - BuildStorage, KeyTypeId, Perbill, }; use sp_std::cmp::Ordering; use sp_weights::Weight; @@ -326,8 +326,8 @@ pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"test"); mod test_crypto { use super::KEY_TYPE; - use sp_core::sr25519::{Public as Sr25519Public, Signature as Sr25519Signature}; use sp_core::U256; + use sp_core::sr25519::{Public as Sr25519Public, Signature as Sr25519Signature}; use sp_runtime::{ app_crypto::{app_crypto, sr25519}, traits::IdentifyAccount, diff --git a/pallets/admin-utils/src/tests/mod.rs b/pallets/admin-utils/src/tests/mod.rs index 1bf2209ec..6c879635e 100644 --- a/pallets/admin-utils/src/tests/mod.rs +++ b/pallets/admin-utils/src/tests/mod.rs @@ -9,10 +9,11 @@ use pallet_subtensor::Error as SubtensorError; // use pallet_subtensor::{migrations, Event}; use pallet_subtensor::Event; use sp_consensus_grandpa::AuthorityId as GrandpaId; -use sp_core::{ed25519, Pair, U256}; +use sp_core::{Pair, U256, ed25519}; +use substrate_fixed::types::I96F32; -use crate::pallet::PrecompileEnable; use crate::Error; +use crate::pallet::PrecompileEnable; use mock::*; mod mock; @@ -1449,3 +1450,19 @@ fn test_sudo_toggle_evm_precompile() { assert!(final_enabled); }); } + +#[test] +fn test_sudo_root_sets_subnet_moving_alpha() { + new_test_ext().execute_with(|| { + let alpha: I96F32 = I96F32::saturating_from_num(0.5); + let initial = pallet_subtensor::SubnetMovingAlpha::::get(); + assert!(initial != alpha); + + assert_ok!(AdminUtils::sudo_set_subnet_moving_alpha( + <::RuntimeOrigin>::root(), + alpha + )); + + assert_eq!(pallet_subtensor::SubnetMovingAlpha::::get(), alpha); + }); +} diff --git a/pallets/collective/Cargo.toml b/pallets/collective/Cargo.toml index cf311f404..11ab2a9cb 100644 --- a/pallets/collective/Cargo.toml +++ b/pallets/collective/Cargo.toml @@ -2,7 +2,7 @@ name = "pallet-collective" version = "4.0.0-dev" authors = ["Parity Technologies , Opentensor Technologies"] -edition = "2021" +edition = "2024" license = "Apache-2.0" homepage = "https://bittensor.com" repository = "https://github.com/opentensor/subtensor" diff --git a/pallets/collective/src/lib.rs b/pallets/collective/src/lib.rs index 6a89c53b8..03d84b063 100644 --- a/pallets/collective/src/lib.rs +++ b/pallets/collective/src/lib.rs @@ -54,7 +54,7 @@ use frame_support::{ use scale_info::TypeInfo; use sp_io::storage; use sp_runtime::traits::Dispatchable; -use sp_runtime::{traits::Hash, RuntimeDebug, Saturating}; +use sp_runtime::{RuntimeDebug, Saturating, traits::Hash}; use sp_std::{marker::PhantomData, prelude::*, result}; #[cfg(test)] @@ -1107,10 +1107,10 @@ where pub struct EnsureMember(PhantomData<(AccountId, I)>); impl< - O: Into, O>> + From>, - I, - AccountId: Decode, - > EnsureOrigin for EnsureMember + O: Into, O>> + From>, + I, + AccountId: Decode, +> EnsureOrigin for EnsureMember { type Success = AccountId; fn try_origin(o: O) -> Result { @@ -1131,11 +1131,11 @@ impl< pub struct EnsureMembers(PhantomData<(AccountId, I)>); impl< - O: Into, O>> + From>, - AccountId, - I, - const N: u32, - > EnsureOrigin for EnsureMembers + O: Into, O>> + From>, + AccountId, + I, + const N: u32, +> EnsureOrigin for EnsureMembers { type Success = (MemberCount, MemberCount); fn try_origin(o: O) -> Result { @@ -1155,12 +1155,12 @@ pub struct EnsureProportionMoreThan, ); impl< - O: Into, O>> + From>, - AccountId, - I, - const N: u32, - const D: u32, - > EnsureOrigin for EnsureProportionMoreThan + O: Into, O>> + From>, + AccountId, + I, + const N: u32, + const D: u32, +> EnsureOrigin for EnsureProportionMoreThan { type Success = (); fn try_origin(o: O) -> Result { @@ -1180,12 +1180,12 @@ pub struct EnsureProportionAtLeast, ); impl< - O: Into, O>> + From>, - AccountId, - I, - const N: u32, - const D: u32, - > EnsureOrigin for EnsureProportionAtLeast + O: Into, O>> + From>, + AccountId, + I, + const N: u32, + const D: u32, +> EnsureOrigin for EnsureProportionAtLeast { type Success = (); fn try_origin(o: O) -> Result { diff --git a/pallets/collective/src/tests.rs b/pallets/collective/src/tests.rs index afe9a69e5..ae3ad69c8 100644 --- a/pallets/collective/src/tests.rs +++ b/pallets/collective/src/tests.rs @@ -20,14 +20,14 @@ use super::{Event as CollectiveEvent, *}; use crate as pallet_collective; use frame_support::{ - assert_noop, assert_ok, derive_impl, parameter_types, traits::ConstU64, Hashable, + Hashable, assert_noop, assert_ok, derive_impl, parameter_types, traits::ConstU64, }; use frame_system::{EnsureRoot, EventRecord, Phase}; use sp_core::H256; use sp_runtime::{ + BuildStorage, testing::Header, traits::{BlakeTwo256, IdentityLookup}, - BuildStorage, }; pub type Block = sp_runtime::generic::Block; diff --git a/pallets/commitments/Cargo.toml b/pallets/commitments/Cargo.toml index 1cff429d5..7fb22aa1f 100644 --- a/pallets/commitments/Cargo.toml +++ b/pallets/commitments/Cargo.toml @@ -4,7 +4,7 @@ version = "4.0.0-dev" description = "Add the ability to commit generic hashed data for network participants." authors = ["Bittensor Nucleus Team"] homepage = "https://bittensor.com" -edition = "2021" +edition = "2024" license = "Unlicense" publish = false repository = "https://github.com/opentensor/subtensor" diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 7e862a593..ba11dbe52 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -13,7 +13,7 @@ pub use types::*; pub use weights::WeightInfo; use frame_support::traits::Currency; -use sp_runtime::{traits::Zero, Saturating}; +use sp_runtime::{Saturating, traits::Zero}; use sp_std::boxed::Box; type BalanceOf = diff --git a/pallets/commitments/src/types.rs b/pallets/commitments/src/types.rs index 06bafcaac..bc0531ece 100644 --- a/pallets/commitments/src/types.rs +++ b/pallets/commitments/src/types.rs @@ -17,16 +17,16 @@ use codec::{Codec, Decode, Encode, MaxEncodedLen}; use frame_support::{ - traits::{ConstU32, Get}, BoundedVec, CloneNoBound, PartialEqNoBound, RuntimeDebugNoBound, + traits::{ConstU32, Get}, }; use scale_info::{ - build::{Fields, Variants}, Path, Type, TypeInfo, + build::{Fields, Variants}, }; use sp_runtime::{ - traits::{AppendZerosInput, AtLeast32BitUnsigned}, RuntimeDebug, + traits::{AppendZerosInput, AtLeast32BitUnsigned}, }; use sp_std::{fmt::Debug, iter::once, prelude::*}; use subtensor_macros::freeze_struct; @@ -86,16 +86,16 @@ impl Encode for Data { fn encode(&self) -> Vec { match self { Data::None => vec![0u8; 1], - Data::Raw(ref x) => { + Data::Raw(x) => { let l = x.len().min(128) as u8; let mut r = vec![l.saturating_add(1)]; r.extend_from_slice(&x[..]); r } - Data::BlakeTwo256(ref h) => once(130).chain(h.iter().cloned()).collect(), - Data::Sha256(ref h) => once(131).chain(h.iter().cloned()).collect(), - Data::Keccak256(ref h) => once(132).chain(h.iter().cloned()).collect(), - Data::ShaThree256(ref h) => once(133).chain(h.iter().cloned()).collect(), + Data::BlakeTwo256(h) => once(130).chain(h.iter().cloned()).collect(), + Data::Sha256(h) => once(131).chain(h.iter().cloned()).collect(), + Data::Keccak256(h) => once(132).chain(h.iter().cloned()).collect(), + Data::ShaThree256(h) => once(133).chain(h.iter().cloned()).collect(), } } } @@ -331,10 +331,10 @@ pub struct Registration< // } impl< - Balance: Encode + Decode + MaxEncodedLen + Copy + Clone + Debug + Eq + PartialEq, - MaxFields: Get, - Block: Codec + Clone + Ord + Eq + AtLeast32BitUnsigned + MaxEncodedLen + Debug, - > Decode for Registration + Balance: Encode + Decode + MaxEncodedLen + Copy + Clone + Debug + Eq + PartialEq, + MaxFields: Get, + Block: Codec + Clone + Ord + Eq + AtLeast32BitUnsigned + MaxEncodedLen + Debug, +> Decode for Registration { fn decode(input: &mut I) -> sp_std::result::Result { let (deposit, block, info) = Decode::decode(&mut AppendZerosInput::new(input))?; diff --git a/pallets/drand/Cargo.toml b/pallets/drand/Cargo.toml index 82aeab66b..3f4b5e4c3 100644 --- a/pallets/drand/Cargo.toml +++ b/pallets/drand/Cargo.toml @@ -4,7 +4,7 @@ description = "FRAME pallet for briding to drand." authors = ["Tony Riemer "] version = "0.0.1" license = "MIT-0" -edition = "2021" +edition = "2024" homepage = "https://www.idealabs.network" publish = false diff --git a/pallets/drand/src/bls12_381.rs b/pallets/drand/src/bls12_381.rs index 9db5695bd..1415613ef 100644 --- a/pallets/drand/src/bls12_381.rs +++ b/pallets/drand/src/bls12_381.rs @@ -15,7 +15,7 @@ */ use ark_ec::pairing::Pairing; -use ark_std::{ops::Neg, Zero}; +use ark_std::{Zero, ops::Neg}; use sp_ark_bls12_381::{ Bls12_381 as Bls12_381Opt, G1Affine as G1AffineOpt, G2Affine as G2AffineOpt, }; diff --git a/pallets/drand/src/lib.rs b/pallets/drand/src/lib.rs index a7cc036b8..40bf7ccb9 100644 --- a/pallets/drand/src/lib.rs +++ b/pallets/drand/src/lib.rs @@ -52,9 +52,9 @@ use scale_info::prelude::cmp; use sha2::{Digest, Sha256}; use sp_core::blake2_256; use sp_runtime::{ + KeyTypeId, Saturating, traits::{Hash, One}, transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction}, - KeyTypeId, Saturating, }; pub mod bls12_381; @@ -110,9 +110,9 @@ pub mod crypto { use super::KEY_TYPE; use sp_core::sr25519::Signature as Sr25519Signature; use sp_runtime::{ + MultiSignature, MultiSigner, app_crypto::{app_crypto, sr25519}, traits::Verify, - MultiSignature, MultiSigner, }; app_crypto!(sr25519, KEY_TYPE); @@ -277,8 +277,8 @@ pub mod pallet { fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { match call { Call::set_beacon_config { - config_payload: ref payload, - ref signature, + config_payload: payload, + signature, } => { let signature = signature.as_ref().ok_or(InvalidTransaction::BadSigner)?; Self::validate_signature_and_parameters( @@ -289,8 +289,8 @@ pub mod pallet { ) } Call::write_pulse { - pulses_payload: ref payload, - ref signature, + pulses_payload: payload, + signature, } => { let signature = signature.as_ref().ok_or(InvalidTransaction::BadSigner)?; Self::validate_signature_and_parameters( diff --git a/pallets/drand/src/mock.rs b/pallets/drand/src/mock.rs index b656e33a8..ba9e16e6f 100644 --- a/pallets/drand/src/mock.rs +++ b/pallets/drand/src/mock.rs @@ -5,12 +5,12 @@ use frame_support::{ derive_impl, parameter_types, traits::{ConstU16, ConstU64}, }; -use sp_core::{sr25519::Signature, H256}; -use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; +use sp_core::{H256, sr25519::Signature}; +use sp_keystore::{KeystoreExt, testing::MemoryKeystore}; use sp_runtime::{ + BuildStorage, testing::TestXt, traits::{BlakeTwo256, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, Verify}, - BuildStorage, }; type Block = frame_system::mocking::MockBlock; diff --git a/pallets/drand/src/tests.rs b/pallets/drand/src/tests.rs index 3fcf8a9b0..e12653aeb 100644 --- a/pallets/drand/src/tests.rs +++ b/pallets/drand/src/tests.rs @@ -15,8 +15,8 @@ */ use crate::{ - mock::*, BeaconConfig, BeaconConfigurationPayload, BeaconInfoResponse, Call, DrandResponseBody, - Error, Pulse, Pulses, PulsesPayload, ENDPOINTS, QUICKNET_CHAIN_HASH, + BeaconConfig, BeaconConfigurationPayload, BeaconInfoResponse, Call, DrandResponseBody, + ENDPOINTS, Error, Pulse, Pulses, PulsesPayload, QUICKNET_CHAIN_HASH, mock::*, }; use codec::Encode; use frame_support::{ @@ -26,8 +26,8 @@ use frame_support::{ use frame_system::RawOrigin; use sp_runtime::{ offchain::{ - testing::{PendingRequest, TestOffchainExt}, OffchainWorkerExt, + testing::{PendingRequest, TestOffchainExt}, }, traits::ValidateUnsigned, }; diff --git a/pallets/drand/src/utils.rs b/pallets/drand/src/utils.rs index cc9408744..809efddac 100644 --- a/pallets/drand/src/utils.rs +++ b/pallets/drand/src/utils.rs @@ -20,7 +20,7 @@ use crate::verifier::ArkScale; use ark_ec::AffineRepr; use ark_scale::hazmat::ArkScaleProjective; use ark_serialize::{CanonicalSerialize, Compress}; -use ark_std::{test_rng, vec, vec::Vec, UniformRand}; +use ark_std::{UniformRand, test_rng, vec, vec::Vec}; pub type ScalarFieldFor = ::ScalarField; // `words_count` is the scalar length in words, with 1 word assumed to be 64 bits. @@ -54,8 +54,8 @@ pub fn make_scalar_args_projective( (make_base::().into(), make_scalar(words_count).into()) } -pub fn make_pairing_args( -) -> (ArkScale, ArkScale) { +pub fn make_pairing_args() +-> (ArkScale, ArkScale) { (make_base::().into(), make_base::().into()) } diff --git a/pallets/drand/src/verifier.rs b/pallets/drand/src/verifier.rs index 7c7acdb9c..bdaafcec5 100644 --- a/pallets/drand/src/verifier.rs +++ b/pallets/drand/src/verifier.rs @@ -23,7 +23,7 @@ use crate::{ types::{BeaconConfiguration, Pulse, RoundNumber}, }; use alloc::{format, string::String, vec::Vec}; -use ark_ec::{hashing::HashToCurve, AffineRepr}; +use ark_ec::{AffineRepr, hashing::HashToCurve}; use ark_serialize::CanonicalSerialize; use codec::Decode; use sha2::{Digest, Sha256}; diff --git a/pallets/registry/Cargo.toml b/pallets/registry/Cargo.toml index e6aca55f6..006c5a753 100644 --- a/pallets/registry/Cargo.toml +++ b/pallets/registry/Cargo.toml @@ -4,7 +4,7 @@ version = "4.0.0-dev" description = "Simplified identity system for network participants." authors = ["Bittensor Nucleus Team"] homepage = "https://bittensor.com" -edition = "2021" +edition = "2024" license = "Unlicense" publish = false repository = "https://github.com/opentensor/subtensor" diff --git a/pallets/registry/src/lib.rs b/pallets/registry/src/lib.rs index bb1518768..e4e99e445 100644 --- a/pallets/registry/src/lib.rs +++ b/pallets/registry/src/lib.rs @@ -12,10 +12,10 @@ pub use types::*; pub use weights::WeightInfo; use frame_support::traits::tokens::{ - fungible::{self, MutateHold as _}, Precision, + fungible::{self, MutateHold as _}, }; -use sp_runtime::{traits::Zero, Saturating}; +use sp_runtime::{Saturating, traits::Zero}; use sp_std::boxed::Box; type BalanceOf = diff --git a/pallets/registry/src/types.rs b/pallets/registry/src/types.rs index 58cc5ed19..5e1b52c0d 100644 --- a/pallets/registry/src/types.rs +++ b/pallets/registry/src/types.rs @@ -16,18 +16,19 @@ // limitations under the License. use codec::{Decode, Encode, MaxEncodedLen}; -use enumflags2::{bitflags, BitFlags}; +use enumflags2::{BitFlags, bitflags}; use frame_support::{ - traits::{ConstU32, Get}, BoundedVec, CloneNoBound, PartialEqNoBound, RuntimeDebugNoBound, + traits::{ConstU32, Get}, }; use scale_info::{ + Path, Type, TypeInfo, TypeParameter, build::{Fields, Variants}, - meta_type, Path, Type, TypeInfo, TypeParameter, + meta_type, }; use sp_runtime::{ - traits::{AppendZerosInput, Zero}, RuntimeDebug, + traits::{AppendZerosInput, Zero}, }; use sp_std::{fmt::Debug, iter::once, ops::Add, prelude::*}; use subtensor_macros::freeze_struct; @@ -87,16 +88,16 @@ impl Encode for Data { fn encode(&self) -> Vec { match self { Data::None => vec![0u8; 1], - Data::Raw(ref x) => { + Data::Raw(x) => { let l = x.len().min(64) as u8; let mut r = vec![l.saturating_add(1)]; r.extend_from_slice(&x[..]); r } - Data::BlakeTwo256(ref h) => once(66u8).chain(h.iter().cloned()).collect(), - Data::Sha256(ref h) => once(67u8).chain(h.iter().cloned()).collect(), - Data::Keccak256(ref h) => once(68u8).chain(h.iter().cloned()).collect(), - Data::ShaThree256(ref h) => once(69u8).chain(h.iter().cloned()).collect(), + Data::BlakeTwo256(h) => once(66u8).chain(h.iter().cloned()).collect(), + Data::Sha256(h) => once(67u8).chain(h.iter().cloned()).collect(), + Data::Keccak256(h) => once(68u8).chain(h.iter().cloned()).collect(), + Data::ShaThree256(h) => once(69u8).chain(h.iter().cloned()).collect(), } } } @@ -385,9 +386,9 @@ pub struct Registration< } impl< - Balance: Encode + Decode + MaxEncodedLen + Copy + Clone + Debug + Eq + PartialEq + Zero + Add, - MaxAdditionalFields: Get, - > Registration + Balance: Encode + Decode + MaxEncodedLen + Copy + Clone + Debug + Eq + PartialEq + Zero + Add, + MaxAdditionalFields: Get, +> Registration { pub(crate) fn total_deposit(&self) -> Balance { self.deposit @@ -395,9 +396,9 @@ impl< } impl< - Balance: Encode + Decode + MaxEncodedLen + Copy + Clone + Debug + Eq + PartialEq, - MaxAdditionalFields: Get, - > Decode for Registration + Balance: Encode + Decode + MaxEncodedLen + Copy + Clone + Debug + Eq + PartialEq, + MaxAdditionalFields: Get, +> Decode for Registration { fn decode(input: &mut I) -> sp_std::result::Result { let (deposit, info) = Decode::decode(&mut AppendZerosInput::new(input))?; diff --git a/pallets/subtensor/Cargo.toml b/pallets/subtensor/Cargo.toml index f22f855fc..f240245c4 100644 --- a/pallets/subtensor/Cargo.toml +++ b/pallets/subtensor/Cargo.toml @@ -4,7 +4,7 @@ version = "4.0.0-dev" description = "FRAME pallet for runtime logic of Subtensor Blockchain." authors = ["Bittensor Nucleus Team"] homepage = "https://bittensor.com" -edition = "2021" +edition = "2024" license = "Unlicense" publish = false repository = "https://github.com/opentensor/subtensor" diff --git a/pallets/subtensor/rpc/Cargo.toml b/pallets/subtensor/rpc/Cargo.toml index c2d631e1a..6a2807268 100644 --- a/pallets/subtensor/rpc/Cargo.toml +++ b/pallets/subtensor/rpc/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "subtensor-custom-rpc" version = "0.0.2" -edition = "2021" +edition = "2024" authors = ['Cameron Fairchild '] repository = 'https://github.com/opentensor/subtensor' description = "A pallet that adds custom RPC calls to subtensor" diff --git a/pallets/subtensor/rpc/src/lib.rs b/pallets/subtensor/rpc/src/lib.rs index 7233a16c7..776ab15b4 100644 --- a/pallets/subtensor/rpc/src/lib.rs +++ b/pallets/subtensor/rpc/src/lib.rs @@ -4,10 +4,10 @@ use codec::{Decode, Encode}; use jsonrpsee::{ core::RpcResult, proc_macros::rpc, - types::{error::ErrorObject, ErrorObjectOwned}, + types::{ErrorObjectOwned, error::ErrorObject}, }; use sp_blockchain::HeaderBackend; -use sp_runtime::{traits::Block as BlockT, AccountId32}; +use sp_runtime::{AccountId32, traits::Block as BlockT}; use std::sync::Arc; use sp_api::ProvideRuntimeApi; @@ -138,7 +138,7 @@ where Err(e) => { return Err( Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into(), - ) + ); } }; match api.get_delegate(at, delegate_account) { @@ -162,7 +162,7 @@ where Err(e) => { return Err( Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into(), - ) + ); } }; match api.get_delegated(at, delegatee_account) { diff --git a/pallets/subtensor/runtime-api/Cargo.toml b/pallets/subtensor/runtime-api/Cargo.toml index a5300d759..0812d076d 100644 --- a/pallets/subtensor/runtime-api/Cargo.toml +++ b/pallets/subtensor/runtime-api/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "subtensor-custom-rpc-runtime-api" version = "0.0.2" -edition = "2021" +edition = "2024" authors = ['Cameron Fairchild '] repository = 'https://github.com/opentensor/subtensor' description = "A pallet that adds a custom runtime API to Subtensor" diff --git a/pallets/subtensor/runtime-api/src/lib.rs b/pallets/subtensor/runtime-api/src/lib.rs index 9f6d96040..c6665bcd9 100644 --- a/pallets/subtensor/runtime-api/src/lib.rs +++ b/pallets/subtensor/runtime-api/src/lib.rs @@ -19,7 +19,7 @@ sp_api::decl_runtime_apis! { pub trait DelegateInfoRuntimeApi { fn get_delegates() -> Vec>; fn get_delegate( delegate_account: AccountId32 ) -> Option>; - fn get_delegated( delegatee_account: AccountId32 ) -> Vec<(DelegateInfo, Compact)>; + fn get_delegated( delegatee_account: AccountId32 ) -> Vec<(DelegateInfo, (Compact, Compact))>; } pub trait NeuronInfoRuntimeApi { diff --git a/pallets/subtensor/src/coinbase/block_step.rs b/pallets/subtensor/src/coinbase/block_step.rs index f9dc0022d..669f8e09d 100644 --- a/pallets/subtensor/src/coinbase/block_step.rs +++ b/pallets/subtensor/src/coinbase/block_step.rs @@ -1,7 +1,7 @@ use super::*; use frame_support::storage::IterableStorageMap; use safe_math::*; -use substrate_fixed::types::{I110F18, I96F32}; +use substrate_fixed::types::{I96F32, I110F18}; impl Pallet { /// Executes the necessary operations for each block. @@ -43,7 +43,8 @@ impl Pallet { let last_adjustment_block: u64 = Self::get_last_adjustment_block(netuid); let adjustment_interval: u16 = Self::get_adjustment_interval(netuid); let current_block: u64 = Self::get_current_block_as_u64(); - log::debug!("netuid: {:?} last_adjustment_block: {:?} adjustment_interval: {:?} current_block: {:?}", + log::debug!( + "netuid: {:?} last_adjustment_block: {:?} adjustment_interval: {:?} current_block: {:?}", netuid, last_adjustment_block, adjustment_interval, diff --git a/pallets/subtensor/src/coinbase/root.rs b/pallets/subtensor/src/coinbase/root.rs index c8d2a43a9..d36602bbb 100644 --- a/pallets/subtensor/src/coinbase/root.rs +++ b/pallets/subtensor/src/coinbase/root.rs @@ -633,8 +633,16 @@ impl Pallet { lock_cost = min_lock; } - log::debug!( "last_lock: {:?}, min_lock: {:?}, last_lock_block: {:?}, lock_reduction_interval: {:?}, current_block: {:?}, mult: {:?} lock_cost: {:?}", - last_lock, min_lock, last_lock_block, lock_reduction_interval, current_block, mult, lock_cost); + log::debug!( + "last_lock: {:?}, min_lock: {:?}, last_lock_block: {:?}, lock_reduction_interval: {:?}, current_block: {:?}, mult: {:?} lock_cost: {:?}", + last_lock, + min_lock, + last_lock_block, + lock_reduction_interval, + current_block, + mult, + lock_cost + ); lock_cost } diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 9b119f178..50c691819 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -72,10 +72,10 @@ impl Pallet { .unwrap_or(asfloat!(0.0)); log::debug!("tao_in_i: {:?}", tao_in_i); // Get alpha_emission total - let alpha_emission_i: I96F32 = asfloat!(Self::get_block_emission_for_issuance( - Self::get_alpha_issuance(*netuid_i) - ) - .unwrap_or(0)); + let alpha_emission_i: I96F32 = asfloat!( + Self::get_block_emission_for_issuance(Self::get_alpha_issuance(*netuid_i)) + .unwrap_or(0) + ); log::debug!("alpha_emission_i: {:?}", alpha_emission_i); // Get initial alpha_in let alpha_in_i: I96F32 = tao_in_i @@ -176,7 +176,7 @@ impl Pallet { let root_alpha: I96F32 = root_proportion .saturating_mul(alpha_out_i) // Total alpha emission per block remaining. .saturating_mul(asfloat!(0.5)); // 50% to validators. - // Remove root alpha from alpha_out. + // Remove root alpha from alpha_out. log::debug!("root_alpha: {:?}", root_alpha); // Get pending alpha as original alpha_out - root_alpha. let pending_alpha: I96F32 = alpha_out_i.saturating_sub(root_alpha); @@ -318,12 +318,14 @@ impl Pallet { let root_prop: I96F32 = root_alpha.checked_div(total_alpha).unwrap_or(zero); // Compute root dividends let root_divs: I96F32 = dividend.saturating_mul(root_prop); - // Record the root dividends. + // Compute alpha dividends + let alpha_divs: I96F32 = dividend.saturating_sub(root_divs); + // Record the alpha dividends. alpha_dividends .entry(hotkey.clone()) - .and_modify(|e| *e = e.saturating_add(dividend)) - .or_insert(dividend); - // Record the alpha_dividends. + .and_modify(|e| *e = e.saturating_add(alpha_divs)) + .or_insert(alpha_divs); + // Record the root dividends. root_dividends .entry(hotkey.clone()) .and_modify(|e| *e = e.saturating_add(root_divs)) @@ -682,11 +684,11 @@ impl Pallet { Ok(c) => c, Err(e) => { log::warn!( - "Failed to reveal commit for subnet {} submitted by {:?} due to error deserializing the commit: {:?}", - netuid, - who, - e - ); + "Failed to reveal commit for subnet {} submitted by {:?} due to error deserializing the commit: {:?}", + netuid, + who, + e + ); continue; } }; @@ -698,8 +700,8 @@ impl Pallet { // Round number used was not found on the chain. Skip this commit. log::warn!( "Failed to reveal commit for subnet {} submitted by {:?} due to missing round number {} at time of reveal.", - netuid, - who, + netuid, + who, round_number ); continue; @@ -718,11 +720,11 @@ impl Pallet { Ok(s) => s, Err(e) => { log::error!( - "Failed to reveal commit for subnet {} submitted by {:?} due to error deserializing signature from drand pallet: {:?}", - netuid, - who, - e - ); + "Failed to reveal commit for subnet {} submitted by {:?} due to error deserializing signature from drand pallet: {:?}", + netuid, + who, + e + ); continue; } }; @@ -733,11 +735,11 @@ impl Pallet { Ok(d) => d, Err(e) => { log::warn!( - "Failed to reveal commit for subnet {} submitted by {:?} due to error decrypting the commit: {:?}", - netuid, - who, - e - ); + "Failed to reveal commit for subnet {} submitted by {:?} due to error decrypting the commit: {:?}", + netuid, + who, + e + ); continue; } }; @@ -747,7 +749,12 @@ impl Pallet { let payload: WeightsTlockPayload = match Decode::decode(&mut reader) { Ok(w) => w, Err(e) => { - log::warn!("Failed to reveal commit for subnet {} submitted by {:?} due to error deserializing WeightsPayload: {:?}", netuid, who, e); + log::warn!( + "Failed to reveal commit for subnet {} submitted by {:?} due to error deserializing WeightsPayload: {:?}", + netuid, + who, + e + ); continue; } }; diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 9a7e4f6ab..a53c8d562 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -390,7 +390,7 @@ impl Pallet { .iter() .map(|updated| updated.saturating_add(activity_cutoff) < current_block) .collect(); - log::trace!("Inactive: {:?}", inactive.clone()); + log::debug!("Inactive: {:?}", inactive.clone()); // Logical negation of inactive. let active: Vec = inactive.iter().map(|&b| !b).collect(); @@ -406,14 +406,14 @@ impl Pallet { let hotkeys: Vec<(u16, T::AccountId)> = as IterableStorageDoubleMap>::iter_prefix(netuid) .collect(); - log::trace!("hotkeys: {:?}", &hotkeys); + log::debug!("hotkeys: {:?}", &hotkeys); // Access network stake as normalized vector. let (mut total_stake, _alpha_stake, _tao_stake): (Vec, Vec, Vec) = Self::get_stake_weights_for_network(netuid); inplace_normalize_64(&mut total_stake); let stake: Vec = vec_fixed64_to_fixed32(total_stake); - log::trace!("Normalised Stake: {:?}", &stake); + log::debug!("Normalised Stake: {:?}", &stake); // ======================= // == Validator permits == @@ -448,7 +448,7 @@ impl Pallet { // Normalize active stake. inplace_normalize(&mut active_stake); - log::trace!("Active Stake:\n{:?}\n", &active_stake); + log::debug!("Active Stake:\n{:?}\n", &active_stake); // ============= // == Weights == diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 7242575ef..0ef0029f9 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -12,7 +12,7 @@ use frame_support::{ dispatch::{self, DispatchInfo, DispatchResult, DispatchResultWithPostInfo, PostDispatchInfo}, ensure, pallet_macros::import_section, - traits::{tokens::fungible, IsSubType}, + traits::{IsSubType, tokens::fungible}, }; use codec::{Decode, Encode}; @@ -23,9 +23,9 @@ use pallet_balances::Call as BalancesCall; use scale_info::TypeInfo; use sp_core::Get; use sp_runtime::{ + DispatchError, traits::{DispatchInfoOf, Dispatchable, PostDispatchInfoOf, SignedExtension}, transaction_validity::{TransactionValidity, TransactionValidityError}, - DispatchError, }; use sp_std::marker::PhantomData; @@ -68,12 +68,12 @@ pub const MAX_CRV3_COMMIT_SIZE_BYTES: u32 = 5000; pub mod pallet { use crate::migrations; use frame_support::{ + BoundedVec, dispatch::GetDispatchInfo, pallet_prelude::{DispatchResult, StorageMap, ValueQuery, *}, traits::{ - tokens::fungible, OriginTrait, QueryPreimage, StorePreimage, UnfilteredDispatchable, + OriginTrait, QueryPreimage, StorePreimage, UnfilteredDispatchable, tokens::fungible, }, - BoundedVec, }; use frame_system::pallet_prelude::*; use pallet_drand::types::RoundNumber; @@ -337,11 +337,6 @@ pub mod pallet { 0 } #[pallet::type_value] - /// Default value for max tempo - pub fn DefaultMaxTempo() -> u16 { - 30 // 1 hour. - } - #[pallet::type_value] /// Default value for global weight. pub fn DefaultTaoWeight() -> u64 { T::InitialTaoWeight::get() @@ -753,14 +748,12 @@ pub mod pallet { #[pallet::type_value] /// Default minimum stake. - /// 500k rao matches $0.25 at $500/TAO pub fn DefaultMinStake() -> u64 { 500_000 } #[pallet::type_value] /// Default staking fee. - /// 500k rao matches $0.25 at $500/TAO pub fn DefaultStakingFee() -> u64 { 50_000 } @@ -1005,18 +998,6 @@ pub mod pallet { #[pallet::storage] // --- MAP ( cold ) --> Vec | Returns the vector of hotkeys controlled by this coldkey. pub type OwnedHotkeys = StorageMap<_, Blake2_128Concat, T::AccountId, Vec, ValueQuery>; - #[pallet::storage] - /// (DEPRECATED) DMAP ( hot, cold ) --> stake | Returns the stake under a coldkey prefixed by hotkey. - pub type Stake = StorageDoubleMap< - _, - Blake2_128Concat, - T::AccountId, - Identity, - T::AccountId, - u64, - ValueQuery, - DefaultZeroU64, - >; #[pallet::storage] // --- DMAP ( cold ) --> () | Maps coldkey to if a coldkey swap is scheduled. pub type ColdkeySwapScheduled = @@ -1127,10 +1108,6 @@ pub mod pallet { /// ================= /// ==== Tempos ===== /// ================= - #[pallet::storage] // --- ITEM( max_tempo ) - pub type AvgTempo = StorageValue<_, u16, ValueQuery, DefaultTempo>; - #[pallet::storage] // --- ITEM( max_tempo ) - pub type MaxTempo = StorageValue<_, u16, ValueQuery, DefaultMaxTempo>; #[pallet::storage] // --- MAP ( netuid ) --> tempo pub type Tempo = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultTempo>; diff --git a/pallets/subtensor/src/macros/config.rs b/pallets/subtensor/src/macros/config.rs index 49bb44dc1..72a4c5f0d 100644 --- a/pallets/subtensor/src/macros/config.rs +++ b/pallets/subtensor/src/macros/config.rs @@ -38,11 +38,11 @@ mod config { /// The scheduler type used for scheduling delayed calls. type Scheduler: ScheduleAnon< - BlockNumberFor, - LocalCallOf, - PalletsOriginOf, - Hasher = Self::Hashing, - >; + BlockNumberFor, + LocalCallOf, + PalletsOriginOf, + Hasher = Self::Hashing, + >; /// the preimage to store the call data. type Preimages: QueryPreimage + StorePreimage; diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index a6c6ed9eb..bbd52e00d 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -6,8 +6,8 @@ use frame_support::pallet_macros::pallet_section; /// This can later be imported into the pallet using [`import_section`]. #[pallet_section] mod dispatches { - use frame_support::traits::schedule::v3::Anon as ScheduleAnon; use frame_support::traits::schedule::DispatchTime; + use frame_support::traits::schedule::v3::Anon as ScheduleAnon; use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::traits::Saturating; @@ -1882,5 +1882,30 @@ mod dispatches { allow_partial, ) } + + /// Attempts to associate a hotkey with a coldkey. + /// + /// # Arguments + /// * `origin` - The origin of the transaction, which must be signed by the coldkey that owns the `hotkey`. + /// * `hotkey` - The hotkey to associate with the coldkey. + /// + /// # Note + /// Will charge based on the weight even if the hotkey is already associated with a coldkey. + #[pallet::call_index(91)] + #[pallet::weight(( + Weight::from_parts(3_000_000, 0).saturating_add(T::DbWeight::get().reads_writes(3, 3)), + DispatchClass::Operational, + Pays::Yes + ))] + pub fn try_associate_hotkey( + origin: T::RuntimeOrigin, + hotkey: T::AccountId, + ) -> DispatchResult { + let coldkey = ensure_signed(origin)?; + + let _ = Self::do_try_associate_hotkey(&coldkey, &hotkey); + + Ok(()) + } } } diff --git a/pallets/subtensor/src/macros/hooks.rs b/pallets/subtensor/src/macros/hooks.rs index 3a0a0ecb1..812b840f5 100644 --- a/pallets/subtensor/src/macros/hooks.rs +++ b/pallets/subtensor/src/macros/hooks.rs @@ -63,12 +63,6 @@ mod hooks { // Populate OwnedHotkeys map for coldkey swap. Doesn't update storage vesion. // Storage version v6 -> v7 .saturating_add(migrations::migrate_populate_owned_hotkeys::migrate_populate_owned::()) - // Populate StakingHotkeys map for coldkey swap. Doesn't update storage vesion. - // Storage version v7 -> v8 - .saturating_add(migrations::migrate_populate_staking_hotkeys::migrate_populate_staking_hotkeys::()) - // Fix total coldkey stake. - // Storage version v8 -> v9 - .saturating_add(migrations::migrate_fix_total_coldkey_stake::migrate_fix_total_coldkey_stake::()) // Migrate Delegate Ids on chain .saturating_add(migrations::migrate_chain_identity::migrate_set_hotkey_identities::()) // Migrate Commit-Reval 2.0 @@ -83,7 +77,9 @@ mod hooks { // Set the min burn across all subnets to a new minimum .saturating_add(migrations::migrate_set_min_burn::migrate_set_min_burn::()) // Set the min difficulty across all subnets to a new minimum - .saturating_add(migrations::migrate_set_min_difficulty::migrate_set_min_difficulty::()); + .saturating_add(migrations::migrate_set_min_difficulty::migrate_set_min_difficulty::()) + // Remove Stake map entries + .saturating_add(migrations::migrate_remove_stake_map::migrate_remove_stake_map::()); weight } diff --git a/pallets/subtensor/src/migrations/migrate_chain_identity.rs b/pallets/subtensor/src/migrations/migrate_chain_identity.rs index 06ee5dd3f..d3aec202b 100644 --- a/pallets/subtensor/src/migrations/migrate_chain_identity.rs +++ b/pallets/subtensor/src/migrations/migrate_chain_identity.rs @@ -2,7 +2,7 @@ use crate::alloc::borrow::ToOwned; use codec::Decode; use scale_info::prelude::{string::String, vec::Vec}; use serde::Deserialize; -use sp_core::{crypto::Ss58Codec, ConstU32}; +use sp_core::{ConstU32, crypto::Ss58Codec}; use sp_runtime::{AccountId32, BoundedVec}; use super::*; diff --git a/pallets/subtensor/src/migrations/migrate_commit_reveal_v2.rs b/pallets/subtensor/src/migrations/migrate_commit_reveal_v2.rs index b8b831b61..792a60cc9 100644 --- a/pallets/subtensor/src/migrations/migrate_commit_reveal_v2.rs +++ b/pallets/subtensor/src/migrations/migrate_commit_reveal_v2.rs @@ -2,7 +2,7 @@ use super::*; use crate::HasMigrationRun; use frame_support::{traits::Get, weights::Weight}; use scale_info::prelude::string::String; -use sp_io::{hashing::twox_128, storage::clear_prefix, KillStorageResult}; +use sp_io::{KillStorageResult, hashing::twox_128, storage::clear_prefix}; pub fn migrate_commit_reveal_2() -> Weight { let migration_name = b"migrate_commit_reveal_2_v2".to_vec(); diff --git a/pallets/subtensor/src/migrations/migrate_fix_total_coldkey_stake.rs b/pallets/subtensor/src/migrations/migrate_fix_total_coldkey_stake.rs deleted file mode 100644 index cf9701f5e..000000000 --- a/pallets/subtensor/src/migrations/migrate_fix_total_coldkey_stake.rs +++ /dev/null @@ -1,91 +0,0 @@ -use super::*; -use alloc::string::String; -use frame_support::{ - pallet_prelude::{Identity, OptionQuery}, - storage_alias, - traits::{Get, StorageVersion}, - weights::Weight, -}; -use sp_std::vec::Vec; - -// TODO (camfairchild): TEST MIGRATION -pub mod deprecated_loaded_emission_format { - use super::*; - - #[storage_alias] - pub(super) type LoadedEmission = - StorageMap, Identity, u16, Vec<(AccountIdOf, u64)>, OptionQuery>; -} - -/// Migrates and fixes the total coldkey stake. -/// -/// This function iterates through all staking hotkeys, calculates the total stake for each coldkey, -/// and updates the `TotalColdkeyStake` storage accordingly. The migration is only performed if the -/// on-chain storage version is 6. -/// -/// # Returns -/// The weight of the migration process. -pub fn do_migrate_fix_total_coldkey_stake() -> Weight { - // Initialize the weight with one read operation. - let mut weight = T::DbWeight::get().reads(1); - - // Iterate through all staking hotkeys. - for (coldkey, hotkey_vec) in StakingHotkeys::::iter() { - // Init the zero value. - let mut coldkey_stake_sum: u64 = 0; - weight = weight.saturating_add(T::DbWeight::get().reads(1)); - - // Calculate the total stake for the current coldkey. - for hotkey in hotkey_vec { - // Cant fail on retrieval. - coldkey_stake_sum = - coldkey_stake_sum.saturating_add(Stake::::get(hotkey, coldkey.clone())); - weight = weight.saturating_add(T::DbWeight::get().reads(1)); - } - // Update the `TotalColdkeyStake` storage with the calculated stake sum. - // Cant fail on insert. - // TotalColdkeyStake::::insert(coldkey.clone(), coldkey_stake_sum); - // weight = weight.saturating_add(T::DbWeight::get().writes(1)); - } - weight -} -// Public migrate function to be called by Lib.rs on upgrade. -pub fn migrate_fix_total_coldkey_stake() -> Weight { - let migration_name = b"fix_total_coldkey_stake_v7".to_vec(); - - // Initialize the weight with one read operation. - let mut weight = T::DbWeight::get().reads(1); - - // Check if the migration has already run - if HasMigrationRun::::get(&migration_name) { - log::info!( - "Migration '{:?}' has already run. Skipping.", - migration_name - ); - return Weight::zero(); - } - - log::info!( - "Running migration '{}'", - String::from_utf8_lossy(&migration_name) - ); - - // Run the migration - weight = weight.saturating_add(do_migrate_fix_total_coldkey_stake::()); - - // Mark the migration as completed - HasMigrationRun::::insert(&migration_name, true); - weight = weight.saturating_add(T::DbWeight::get().writes(1)); - - // Set the storage version to 7 - StorageVersion::new(7).put::>(); - weight = weight.saturating_add(T::DbWeight::get().writes(1)); - - log::info!( - "Migration '{:?}' completed. Storage version set to 7.", - String::from_utf8_lossy(&migration_name) - ); - - // Return the migration weight. - weight -} diff --git a/pallets/subtensor/src/migrations/migrate_populate_staking_hotkeys.rs b/pallets/subtensor/src/migrations/migrate_populate_staking_hotkeys.rs deleted file mode 100644 index 0245ae3c9..000000000 --- a/pallets/subtensor/src/migrations/migrate_populate_staking_hotkeys.rs +++ /dev/null @@ -1,83 +0,0 @@ -use super::*; -use frame_support::{ - pallet_prelude::{Identity, OptionQuery}, - storage_alias, - traits::Get, - weights::Weight, -}; -use log::info; -use sp_std::vec::Vec; -const LOG_TARGET_1: &str = "migrate_populate_owned"; - -/// Module containing deprecated storage format for LoadedEmission -pub mod deprecated_loaded_emission_format { - use super::*; - - #[storage_alias] - pub(super) type LoadedEmission = - StorageMap, Identity, u16, Vec<(AccountIdOf, u64)>, OptionQuery>; -} - -/// Populate the StakingHotkeys map from Stake map -pub fn migrate_populate_staking_hotkeys() -> Weight { - // Setup migration weight - let mut weight = T::DbWeight::get().reads(1); - let migration_name = "Populate StakingHotkeys map"; - - // Check if this migration is needed (if StakingHotkeys map is empty) - let migrate = StakingHotkeys::::iter().next().is_none(); - - // Only runs if the migration is needed - if migrate { - info!(target: LOG_TARGET_1, ">>> Starting Migration: {}", migration_name); - - let mut longest_hotkey_vector: usize = 0; - let mut longest_coldkey: Option = None; - let mut keys_touched: u64 = 0; - let mut storage_reads: u64 = 0; - let mut storage_writes: u64 = 0; - - // Iterate through all Owner entries - Stake::::iter().for_each(|(hotkey, coldkey, stake)| { - storage_reads = storage_reads.saturating_add(1); // Read from Owner storage - if stake > 0 { - let mut hotkeys = StakingHotkeys::::get(&coldkey); - storage_reads = storage_reads.saturating_add(1); // Read from StakingHotkeys storage - - // Add the hotkey if it's not already in the vector - if !hotkeys.contains(&hotkey) { - hotkeys.push(hotkey); - keys_touched = keys_touched.saturating_add(1); - - // Update longest hotkey vector info - if longest_hotkey_vector < hotkeys.len() { - longest_hotkey_vector = hotkeys.len(); - longest_coldkey = Some(coldkey.clone()); - } - - // Update the StakingHotkeys storage - StakingHotkeys::::insert(&coldkey, hotkeys); - storage_writes = storage_writes.saturating_add(1); // Write to StakingHotkeys storage - } - - // Accrue weight for reads and writes - weight = weight.saturating_add(T::DbWeight::get().reads_writes(2, 1)); - } - }); - - // Log migration results - info!( - target: LOG_TARGET_1, - "Migration {} finished. Keys touched: {}, Longest hotkey vector: {}, Storage reads: {}, Storage writes: {}", - migration_name, keys_touched, longest_hotkey_vector, storage_reads, storage_writes - ); - if let Some(c) = longest_coldkey { - info!(target: LOG_TARGET_1, "Longest hotkey vector is controlled by: {:?}", c); - } - - weight - } else { - info!(target: LOG_TARGET_1, "Migration {} already done!", migration_name); - Weight::zero() - } -} diff --git a/pallets/subtensor/src/migrations/migrate_rao.rs b/pallets/subtensor/src/migrations/migrate_rao.rs index 09201dbc4..3b2de079e 100644 --- a/pallets/subtensor/src/migrations/migrate_rao.rs +++ b/pallets/subtensor/src/migrations/migrate_rao.rs @@ -4,7 +4,6 @@ use frame_support::IterableStorageMap; use frame_support::{traits::Get, weights::Weight}; use sp_runtime::format; use substrate_fixed::types::I96F32; -use substrate_fixed::types::U64F64; use super::*; @@ -36,29 +35,30 @@ pub fn migrate_rao() -> Weight { DynamicBlock::::set(Pallet::::get_current_block_as_u64()); // Migrate all TAO to root. - Stake::::iter().for_each(|(hotkey, coldkey, stake)| { - // Increase SubnetTAO on root. - SubnetTAO::::mutate(0, |total| { - *total = total.saturating_add(stake); - }); - // Increase SubnetAlphaOut on root. - SubnetAlphaOut::::mutate(0, |total| { - *total = total.saturating_add(stake); - }); - // Set all the stake on root 0 subnet. - Alpha::::mutate((hotkey.clone(), coldkey.clone(), 0), |total| { - *total = total.saturating_add(U64F64::saturating_from_num(stake)) - }); - TotalHotkeyShares::::mutate(hotkey.clone(), 0, |total| { - *total = total.saturating_add(U64F64::saturating_from_num(stake)) - }); - // Set the total stake on the hotkey - TotalHotkeyAlpha::::mutate(hotkey.clone(), 0, |total| { - *total = total.saturating_add(stake) - }); - // 6 reads and 6 writes. - weight = weight.saturating_add(T::DbWeight::get().reads_writes(6, 6)); - }); + // This migration has already run, leaving this only for reference for now, since this is a recent migration + // Stake::::iter().for_each(|(hotkey, coldkey, stake)| { + // // Increase SubnetTAO on root. + // SubnetTAO::::mutate(0, |total| { + // *total = total.saturating_add(stake); + // }); + // // Increase SubnetAlphaOut on root. + // SubnetAlphaOut::::mutate(0, |total| { + // *total = total.saturating_add(stake); + // }); + // // Set all the stake on root 0 subnet. + // Alpha::::mutate((hotkey.clone(), coldkey.clone(), 0), |total| { + // *total = total.saturating_add(U64F64::saturating_from_num(stake)) + // }); + // TotalHotkeyShares::::mutate(hotkey.clone(), 0, |total| { + // *total = total.saturating_add(U64F64::saturating_from_num(stake)) + // }); + // // Set the total stake on the hotkey + // TotalHotkeyAlpha::::mutate(hotkey.clone(), 0, |total| { + // *total = total.saturating_add(stake) + // }); + // // 6 reads and 6 writes. + // weight = weight.saturating_add(T::DbWeight::get().reads_writes(6, 6)); + // }); // Convert subnets and give them lock. // Set global weight to 18% from the start diff --git a/pallets/subtensor/src/migrations/migrate_remove_stake_map.rs b/pallets/subtensor/src/migrations/migrate_remove_stake_map.rs new file mode 100644 index 000000000..650c47a66 --- /dev/null +++ b/pallets/subtensor/src/migrations/migrate_remove_stake_map.rs @@ -0,0 +1,62 @@ +use super::*; +use crate::HasMigrationRun; +use frame_support::{traits::Get, weights::Weight}; +use scale_info::prelude::string::String; +use sp_io::{KillStorageResult, hashing::twox_128, storage::clear_prefix}; + +pub fn migrate_remove_stake_map() -> Weight { + let migration_name = b"migrate_remove_stake_map".to_vec(); + let mut weight = T::DbWeight::get().reads(1); + + if HasMigrationRun::::get(&migration_name) { + log::info!( + "Migration '{:?}' has already run. Skipping.", + migration_name + ); + return weight; + } + + log::info!( + "Running migration '{}'", + String::from_utf8_lossy(&migration_name) + ); + + // ------------------------------ + // Step 1: Remove Stake entries + // ------------------------------ + + let mut stake_prefix = Vec::new(); + stake_prefix.extend_from_slice(&twox_128("SubtensorModule".as_bytes())); + stake_prefix.extend_from_slice(&twox_128("Stake".as_bytes())); + + let removal_results = clear_prefix(&stake_prefix, Some(u32::MAX)); + + let removed_entries_count = match removal_results { + KillStorageResult::AllRemoved(removed) => removed as u64, + KillStorageResult::SomeRemaining(removed) => { + log::info!("Failed To Remove Some Items During {:?}", migration_name); + removed as u64 + } + }; + + weight = weight.saturating_add(T::DbWeight::get().writes(removed_entries_count)); + + log::info!( + "Removed {:?} entries from Stake map.", + removed_entries_count + ); + + // ------------------------------ + // Step 2: Mark Migration as Completed + // ------------------------------ + + HasMigrationRun::::insert(&migration_name, true); + weight = weight.saturating_add(T::DbWeight::get().writes(1)); + + log::info!( + "Migration '{:?}' completed successfully.", + String::from_utf8_lossy(&migration_name) + ); + + weight +} diff --git a/pallets/subtensor/src/migrations/migrate_total_issuance.rs b/pallets/subtensor/src/migrations/migrate_total_issuance.rs index 9a4085379..c00bb916b 100644 --- a/pallets/subtensor/src/migrations/migrate_total_issuance.rs +++ b/pallets/subtensor/src/migrations/migrate_total_issuance.rs @@ -3,7 +3,7 @@ use frame_support::pallet_prelude::OptionQuery; use frame_support::{ pallet_prelude::Identity, storage_alias, - traits::{fungible::Inspect, Get, GetStorageVersion, StorageVersion}, + traits::{Get, GetStorageVersion, StorageVersion, fungible::Inspect}, weights::Weight, }; use sp_std::vec::Vec; @@ -43,10 +43,13 @@ pub fn migrate_total_issuance(test: bool) -> Weight { // Execute migration if the current storage version is 5 or if in test mode if Pallet::::on_chain_storage_version() == StorageVersion::new(5) || test { // Calculate the sum of all stake values - let stake_sum: u64 = - Stake::::iter().fold(0, |acc, (_, _, stake)| acc.saturating_add(stake)); - // Add weight for reading all stake entries - weight = weight.saturating_add(T::DbWeight::get().reads(Stake::::iter().count() as u64)); + let stake_sum: u64 = Owner::::iter() + .map(|(hotkey, _coldkey)| Pallet::::get_total_stake_for_hotkey(&hotkey)) + .fold(0, |acc, stake| acc.saturating_add(stake)); + // Add weight for reading all Owner and TotalHotkeyStake entries + weight = weight.saturating_add( + T::DbWeight::get().reads((Owner::::iter().count() as u64).saturating_mul(2)), + ); // Calculate the sum of all locked subnet values let locked_sum: u64 = diff --git a/pallets/subtensor/src/migrations/mod.rs b/pallets/subtensor/src/migrations/mod.rs index e16adf46a..b8754c07b 100644 --- a/pallets/subtensor/src/migrations/mod.rs +++ b/pallets/subtensor/src/migrations/mod.rs @@ -5,12 +5,11 @@ pub mod migrate_create_root_network; pub mod migrate_delete_subnet_21; pub mod migrate_delete_subnet_3; pub mod migrate_fix_is_network_member; -pub mod migrate_fix_total_coldkey_stake; pub mod migrate_identities_v2; pub mod migrate_init_total_issuance; pub mod migrate_populate_owned_hotkeys; -pub mod migrate_populate_staking_hotkeys; pub mod migrate_rao; +pub mod migrate_remove_stake_map; pub mod migrate_set_min_burn; pub mod migrate_set_min_difficulty; pub mod migrate_stake_threshold; diff --git a/pallets/subtensor/src/rpc_info/delegate_info.rs b/pallets/subtensor/src/rpc_info/delegate_info.rs index acfe28b43..f0a2447e4 100644 --- a/pallets/subtensor/src/rpc_info/delegate_info.rs +++ b/pallets/subtensor/src/rpc_info/delegate_info.rs @@ -1,23 +1,23 @@ use super::*; +use frame_support::IterableStorageMap; use frame_support::pallet_prelude::{Decode, Encode}; -use frame_support::storage::IterableStorageMap; -use frame_support::IterableStorageDoubleMap; use safe_math::*; use substrate_fixed::types::U64F64; extern crate alloc; +use alloc::collections::BTreeMap; use codec::Compact; -#[freeze_struct("66105c2cfec0608d")] +#[freeze_struct("7cd21f57627d2d0d")] #[derive(Decode, Encode, PartialEq, Eq, Clone, Debug, TypeInfo)] pub struct DelegateInfo { - delegate_ss58: AccountId, - take: Compact, - nominators: Vec<(AccountId, Compact)>, // map of nominator_ss58 to stake amount - owner_ss58: AccountId, - registrations: Vec>, // Vec of netuid this delegate is registered on - validator_permits: Vec>, // Vec of netuid this delegate has validator permit on - return_per_1000: Compact, // Delegators current daily return per 1000 TAO staked minus take fee - total_daily_return: Compact, // Delegators current daily return + pub delegate_ss58: AccountId, + pub take: Compact, + pub nominators: Vec<(AccountId, Vec<(Compact, Compact)>)>, // map of nominator_ss58 to netuid and stake amount + pub owner_ss58: AccountId, + pub registrations: Vec>, // Vec of netuid this delegate is registered on + pub validator_permits: Vec>, // Vec of netuid this delegate has validator permit on + pub return_per_1000: Compact, // Delegators current daily return per 1000 TAO staked minus take fee + pub total_daily_return: Compact, // Delegators current daily return } impl Pallet { @@ -49,19 +49,38 @@ impl Pallet { Self::return_per_1000_tao(take, total_stake, emissions_per_day) } - fn get_delegate_by_existing_account(delegate: AccountIdOf) -> DelegateInfo { - let mut nominators = Vec::<(T::AccountId, Compact)>::new(); + fn get_delegate_by_existing_account( + delegate: AccountIdOf, + skip_nominators: bool, + ) -> DelegateInfo { + let mut nominators = Vec::<(T::AccountId, Vec<(Compact, Compact)>)>::new(); + let mut nominator_map = BTreeMap::, Compact)>>::new(); + + if !skip_nominators { + let mut alpha_share_pools = vec![]; + for netuid in Self::get_all_subnet_netuids() { + let alpha_share_pool = Self::get_alpha_share_pool(delegate.clone(), netuid); + alpha_share_pools.push(alpha_share_pool); + } + + for ((nominator, netuid), alpha_stake) in Alpha::::iter_prefix((delegate.clone(),)) { + if alpha_stake == 0 { + continue; + } + + if let Some(alpha_share_pool) = alpha_share_pools.get(netuid as usize) { + let coldkey_stake = alpha_share_pool.get_value_from_shares(alpha_stake); - for (nominator, stake) in - as IterableStorageDoubleMap>::iter_prefix( - delegate.clone(), - ) - { - if stake == 0 { - continue; + nominator_map + .entry(nominator.clone()) + .or_insert(Vec::new()) + .push((netuid.into(), coldkey_stake.into())); + } + } + + for (nominator, stakes) in nominator_map { + nominators.push((nominator, stakes)); } - // Only add nominators with stake - nominators.push((nominator.clone(), stake.into())); } let registrations = Self::get_registered_networks_for_hotkey(&delegate.clone()); @@ -112,7 +131,7 @@ impl Pallet { return None; } - let delegate_info = Self::get_delegate_by_existing_account(delegate.clone()); + let delegate_info = Self::get_delegate_by_existing_account(delegate.clone(), false); Some(delegate_info) } @@ -121,7 +140,7 @@ impl Pallet { pub fn get_delegates() -> Vec> { let mut delegates = Vec::>::new(); for delegate in as IterableStorageMap>::iter_keys() { - let delegate_info = Self::get_delegate_by_existing_account(delegate.clone()); + let delegate_info = Self::get_delegate_by_existing_account(delegate.clone(), false); delegates.push(delegate_info); } @@ -132,20 +151,24 @@ impl Pallet { /// pub fn get_delegated( delegatee: T::AccountId, - ) -> Vec<(DelegateInfo, Compact)> { - let mut delegates: Vec<(DelegateInfo, Compact)> = Vec::new(); + ) -> Vec<(DelegateInfo, (Compact, Compact))> { + let mut delegates: Vec<(DelegateInfo, (Compact, Compact))> = + Vec::new(); for delegate in as IterableStorageMap>::iter_keys() { // Staked to this delegate, so add to list - let delegate_info = Self::get_delegate_by_existing_account(delegate.clone()); - delegates.push(( - delegate_info, - Self::get_stake_for_hotkey_and_coldkey_on_subnet( - &delegatee, - &delegate, - Self::get_root_netuid(), - ) - .into(), - )); + for (netuid, _) in Alpha::::iter_prefix((delegate.clone(), delegatee.clone())) { + let delegate_info = Self::get_delegate_by_existing_account(delegate.clone(), true); + delegates.push(( + delegate_info, + ( + netuid.into(), + Self::get_stake_for_hotkey_and_coldkey_on_subnet( + &delegate, &delegatee, netuid, + ) + .into(), + ), + )); + } } delegates diff --git a/pallets/subtensor/src/staking/account.rs b/pallets/subtensor/src/staking/account.rs new file mode 100644 index 000000000..20a6ff303 --- /dev/null +++ b/pallets/subtensor/src/staking/account.rs @@ -0,0 +1,13 @@ +use super::*; + +impl Pallet { + pub fn do_try_associate_hotkey( + coldkey: &T::AccountId, + hotkey: &T::AccountId, + ) -> DispatchResult { + // Ensure the hotkey is not already associated with a coldkey + Self::create_account_if_non_existent(coldkey, hotkey); + + Ok(()) + } +} diff --git a/pallets/subtensor/src/staking/add_stake.rs b/pallets/subtensor/src/staking/add_stake.rs index 2291de748..ed607eec5 100644 --- a/pallets/subtensor/src/staking/add_stake.rs +++ b/pallets/subtensor/src/staking/add_stake.rs @@ -142,10 +142,15 @@ impl Pallet { allow_partial, )?; - // 4. Ensure the remove operation from the coldkey is a success. + // 4. If the coldkey is not the owner, make the hotkey a delegate. + if Self::get_owning_coldkey_for_hotkey(&hotkey) != coldkey { + Self::maybe_become_delegate(&hotkey); + } + + // 5. Ensure the remove operation from the coldkey is a success. let tao_staked: u64 = Self::remove_balance_from_coldkey_account(&coldkey, possible_stake)?; - // 5. Swap the stake into alpha on the subnet and increase counters. + // 6. Swap the stake into alpha on the subnet and increase counters. // Emit the staking event. let fee = DefaultStakingFee::::get(); Self::stake_into_subnet(&hotkey, &coldkey, netuid, tao_staked, fee); diff --git a/pallets/subtensor/src/staking/decrease_take.rs b/pallets/subtensor/src/staking/decrease_take.rs index 8742f809d..c227aad8a 100644 --- a/pallets/subtensor/src/staking/decrease_take.rs +++ b/pallets/subtensor/src/staking/decrease_take.rs @@ -57,7 +57,11 @@ impl Pallet { // --- 4. Set the new take value. Delegates::::insert(hotkey.clone(), take); - // --- 5. Emit the take value. + // --- 5. Set last block for rate limiting + let block: u64 = Self::get_current_block_as_u64(); + Self::set_last_tx_block_delegate_take(&hotkey, block); + + // --- 6. Emit the take value. log::debug!( "TakeDecreased( coldkey:{:?}, hotkey:{:?}, take:{:?} )", coldkey, diff --git a/pallets/subtensor/src/staking/helpers.rs b/pallets/subtensor/src/staking/helpers.rs index c83e303c7..5aff56ea2 100644 --- a/pallets/subtensor/src/staking/helpers.rs +++ b/pallets/subtensor/src/staking/helpers.rs @@ -2,11 +2,11 @@ use super::*; use substrate_fixed::types::I96F32; use frame_support::traits::{ + Imbalance, tokens::{ - fungible::{Balanced as _, Inspect as _}, Fortitude, Precision, Preservation, + fungible::{Balanced as _, Inspect as _}, }, - Imbalance, }; impl Pallet { @@ -63,10 +63,12 @@ impl Pallet { .iter() .map(|hotkey| { let mut total_stake: u64 = 0; - for (netuid, alpha) in Alpha::::iter_prefix((hotkey, coldkey)) { + for (netuid, _) in Alpha::::iter_prefix((hotkey, coldkey)) { + let alpha_stake = + Self::get_stake_for_hotkey_and_coldkey_on_subnet(hotkey, coldkey, netuid); let tao_price: I96F32 = Self::get_alpha_price(netuid); total_stake = total_stake.saturating_add( - I96F32::saturating_from_num(alpha) + I96F32::saturating_from_num(alpha_stake) .saturating_mul(tao_price) .saturating_to_num::(), ); @@ -80,7 +82,6 @@ impl Pallet { // pub fn create_account_if_non_existent(coldkey: &T::AccountId, hotkey: &T::AccountId) { if !Self::hotkey_account_exists(hotkey) { - Stake::::insert(hotkey, coldkey, 0); // This is the way to index coldkeys by a hotkey Owner::::insert(hotkey, coldkey); // Update OwnedHotkeys map @@ -99,6 +100,13 @@ impl Pallet { } } + //// If the hotkey is not a delegate, make it a delegate. + pub fn maybe_become_delegate(hotkey: &T::AccountId) { + if !Self::hotkey_is_delegate(hotkey) { + Self::delegate_hotkey(hotkey, Self::get_hotkey_take(hotkey)); + } + } + /// Returns the coldkey owning this hotkey. This function should only be called for active accounts. /// /// # Arguments diff --git a/pallets/subtensor/src/staking/increase_take.rs b/pallets/subtensor/src/staking/increase_take.rs index 021818447..349f86e7c 100644 --- a/pallets/subtensor/src/staking/increase_take.rs +++ b/pallets/subtensor/src/staking/increase_take.rs @@ -61,14 +61,14 @@ impl Pallet { let block: u64 = Self::get_current_block_as_u64(); ensure!( !Self::exceeds_tx_delegate_take_rate_limit( - Self::get_last_tx_block_delegate_take(&coldkey), + Self::get_last_tx_block_delegate_take(&hotkey), block ), Error::::DelegateTxRateLimitExceeded ); // Set last block for rate limiting - Self::set_last_tx_block_delegate_take(&coldkey, block); + Self::set_last_tx_block_delegate_take(&hotkey, block); // --- 6. Set the new take value. Delegates::::insert(hotkey.clone(), take); diff --git a/pallets/subtensor/src/staking/mod.rs b/pallets/subtensor/src/staking/mod.rs index 2b222036c..ecf8fb881 100644 --- a/pallets/subtensor/src/staking/mod.rs +++ b/pallets/subtensor/src/staking/mod.rs @@ -1,4 +1,5 @@ use super::*; +pub mod account; pub mod add_stake; pub mod decrease_take; pub mod helpers; diff --git a/pallets/subtensor/src/staking/move_stake.rs b/pallets/subtensor/src/staking/move_stake.rs index fe5fbd45c..9620664b5 100644 --- a/pallets/subtensor/src/staking/move_stake.rs +++ b/pallets/subtensor/src/staking/move_stake.rs @@ -344,6 +344,11 @@ impl Pallet { // Because of the fee, the tao_unstaked may be too low if initial stake is low. In that case, // do not restake. if tao_unstaked >= DefaultMinStake::::get().saturating_add(fee) { + // If the coldkey is not the owner, make the hotkey a delegate. + if Self::get_owning_coldkey_for_hotkey(destination_hotkey) != *destination_coldkey { + Self::maybe_become_delegate(destination_hotkey); + } + Self::stake_into_subnet( destination_hotkey, destination_coldkey, diff --git a/pallets/subtensor/src/staking/set_children.rs b/pallets/subtensor/src/staking/set_children.rs index c47dfa0ca..12b6bf852 100644 --- a/pallets/subtensor/src/staking/set_children.rs +++ b/pallets/subtensor/src/staking/set_children.rs @@ -59,15 +59,6 @@ impl Pallet { Error::::TxRateLimitExceeded ); - // Set last transaction block - let current_block = Self::get_current_block_as_u64(); - Self::set_last_transaction_block_on_subnet( - &hotkey, - netuid, - &TransactionType::SetChildren, - current_block, - ); - // Check that this delegation is not on the root network. Child hotkeys are not valid on root. ensure!( netuid != Self::get_root_netuid(), @@ -115,10 +106,21 @@ impl Pallet { // grandparent stake in this case) ensure!( children.is_empty() - || Self::get_total_stake_for_hotkey(&hotkey) >= StakeThreshold::::get(), + || Self::get_total_stake_for_hotkey(&hotkey) >= StakeThreshold::::get() + || SubnetOwnerHotkey::::try_get(netuid) + .is_ok_and(|owner_hotkey| owner_hotkey.eq(&hotkey)), Error::::NotEnoughStakeToSetChildkeys ); + // Set last transaction block + let current_block = Self::get_current_block_as_u64(); + Self::set_last_transaction_block_on_subnet( + &hotkey, + netuid, + &TransactionType::SetChildren, + current_block, + ); + // Calculate cool-down block let cooldown_block = Self::get_current_block_as_u64().saturating_add(DefaultPendingCooldown::::get()); diff --git a/pallets/subtensor/src/staking/stake_utils.rs b/pallets/subtensor/src/staking/stake_utils.rs index 07be25171..0a3659b6a 100644 --- a/pallets/subtensor/src/staking/stake_utils.rs +++ b/pallets/subtensor/src/staking/stake_utils.rs @@ -2,7 +2,7 @@ use super::*; use safe_math::*; use share_pool::{SharePool, SharePoolDataOperations}; use sp_std::ops::Neg; -use substrate_fixed::types::{I110F18, I64F64, I96F32, U64F64}; +use substrate_fixed::types::{I64F64, I96F32, I110F18, U64F64}; impl Pallet { /// Retrieves the total alpha issuance for a given subnet. @@ -167,7 +167,7 @@ impl Pallet { } }) .collect(); - log::trace!("alpha_stake: {:?}", alpha_stake); + log::debug!("alpha_stake: {:?}", alpha_stake); // Step 3: Calculate the global tao stake vector. // Initialize a vector to store global tao stakes for each neuron. @@ -322,7 +322,7 @@ impl Pallet { // Step 1: Retrieve the initial total stake (alpha) for the hotkey on the specified subnet. let initial_alpha: I96F32 = I96F32::saturating_from_num(Self::get_stake_for_hotkey_on_subnet(hotkey, netuid)); - log::trace!( + log::debug!( "Initial alpha for hotkey {:?} on subnet {}: {:?}", hotkey, netuid, @@ -339,13 +339,13 @@ impl Pallet { // Step 2: Retrieve the lists of parents and children for the hotkey on the subnet. let parents: Vec<(u64, T::AccountId)> = Self::get_parents(hotkey, netuid); let children: Vec<(u64, T::AccountId)> = Self::get_children(hotkey, netuid); - log::trace!( + log::debug!( "Parents for hotkey {:?} on subnet {}: {:?}", hotkey, netuid, parents ); - log::trace!( + log::debug!( "Children for hotkey {:?} on subnet {}: {:?}", hotkey, netuid, @@ -370,7 +370,7 @@ impl Pallet { // Add this child's allocation to the total alpha allocated to children. alpha_to_children = alpha_to_children.saturating_add(alpha_proportion_to_child); } - log::trace!("Total alpha allocated to children: {:?}", alpha_to_children); + log::debug!("Total alpha allocated to children: {:?}", alpha_to_children); // Step 4: Calculate the total alpha inherited from parents. for (proportion, parent) in parents { @@ -403,7 +403,7 @@ impl Pallet { // Add this parent's contribution to the total alpha inherited from parents. alpha_from_parents = alpha_from_parents.saturating_add(alpha_proportion_from_parent); } - log::trace!( + log::debug!( "Total alpha inherited from parents: {:?}", alpha_from_parents ); @@ -544,9 +544,10 @@ impl Pallet { coldkey: &T::AccountId, netuid: u16, amount: u64, - ) { + ) -> u64 { let mut alpha_share_pool = Self::get_alpha_share_pool(hotkey.clone(), netuid); - alpha_share_pool.update_value_for_one(coldkey, amount as i64); + let actual_alpha = alpha_share_pool.update_value_for_one(coldkey, amount as i64); + actual_alpha.unsigned_abs() } pub fn try_increase_stake_for_hotkey_and_coldkey_on_subnet( @@ -573,13 +574,16 @@ impl Pallet { coldkey: &T::AccountId, netuid: u16, amount: u64, - ) { + ) -> u64 { let mut alpha_share_pool = Self::get_alpha_share_pool(hotkey.clone(), netuid); + let mut actual_alpha = 0; if let Ok(value) = alpha_share_pool.try_get_value(coldkey) { if value >= amount { - alpha_share_pool.update_value_for_one(coldkey, (amount as i64).neg()); + actual_alpha = + alpha_share_pool.update_value_for_one(coldkey, (amount as i64).neg()); } } + actual_alpha.unsigned_abs() } /// Calculates Some(Alpha) returned from pool by staking operation @@ -735,11 +739,12 @@ impl Pallet { alpha: u64, fee: u64, ) -> u64 { - // Step 1: Swap the alpha for TAO. - let tao: u64 = Self::swap_alpha_for_tao(netuid, alpha); + // Step 1: Decrease alpha on subneet + let actual_alpha_decrease = + Self::decrease_stake_for_hotkey_and_coldkey_on_subnet(hotkey, coldkey, netuid, alpha); - // Step 2: Decrease alpha on subneet - Self::decrease_stake_for_hotkey_and_coldkey_on_subnet(hotkey, coldkey, netuid, alpha); + // Step 2: Swap the alpha for TAO. + let tao: u64 = Self::swap_alpha_for_tao(netuid, actual_alpha_decrease); // Step 3: Update StakingHotkeys if the hotkey's total alpha, across all subnets, is zero // TODO const: fix. @@ -765,7 +770,7 @@ impl Pallet { coldkey.clone(), hotkey.clone(), tao_unstaked, - alpha, + actual_alpha_decrease, netuid, )); log::info!( @@ -773,7 +778,7 @@ impl Pallet { coldkey.clone(), hotkey.clone(), tao_unstaked, - alpha, + actual_alpha_decrease, netuid ); @@ -799,9 +804,12 @@ impl Pallet { // Step 2. Swap the tao to alpha. let alpha: u64 = Self::swap_tao_for_alpha(netuid, tao_staked); + let mut actual_alpha = 0; if (tao_staked > 0) && (alpha > 0) { // Step 3: Increase the alpha on the hotkey account. - Self::increase_stake_for_hotkey_and_coldkey_on_subnet(hotkey, coldkey, netuid, alpha); + actual_alpha = Self::increase_stake_for_hotkey_and_coldkey_on_subnet( + hotkey, coldkey, netuid, alpha, + ); // Step 4: Update the list of hotkeys staking for this coldkey let mut staking_hotkeys = StakingHotkeys::::get(coldkey); @@ -825,7 +833,7 @@ impl Pallet { coldkey.clone(), hotkey.clone(), tao_staked, - alpha, + actual_alpha, netuid, )); log::info!( @@ -833,12 +841,12 @@ impl Pallet { coldkey.clone(), hotkey.clone(), tao_staked, - alpha, + actual_alpha, netuid ); // Step 7: Return the amount of alpha staked - alpha + actual_alpha } pub fn get_alpha_share_pool( @@ -979,6 +987,12 @@ impl Pallet { Error::::HotKeyAccountNotExists ); + // Ensure that the destination hotkey account exists + ensure!( + Self::hotkey_account_exists(destination_hotkey), + Error::::HotKeyAccountNotExists + ); + // Ensure there is enough stake in the origin subnet. let origin_alpha = Self::get_stake_for_hotkey_and_coldkey_on_subnet( origin_hotkey, diff --git a/pallets/subtensor/src/subnets/registration.rs b/pallets/subtensor/src/subnets/registration.rs index bcde11994..121f38b33 100644 --- a/pallets/subtensor/src/subnets/registration.rs +++ b/pallets/subtensor/src/subnets/registration.rs @@ -568,16 +568,16 @@ impl Pallet { let seal_hash: H256 = H256::from_slice(&keccak_256_seal_hash_vec); log::trace!( - "\n hotkey:{:?} \nblock_number: {:?}, \nnonce_u64: {:?}, \nblock_hash: {:?}, \nfull_bytes: {:?}, \nsha256_seal_hash_vec: {:?}, \nkeccak_256_seal_hash_vec: {:?}, \nseal_hash: {:?}", - hotkey, + "\n hotkey:{:?} \nblock_number: {:?}, \nnonce_u64: {:?}, \nblock_hash: {:?}, \nfull_bytes: {:?}, \nsha256_seal_hash_vec: {:?}, \nkeccak_256_seal_hash_vec: {:?}, \nseal_hash: {:?}", + hotkey, block_number_u64, - nonce_u64, - block_hash_at_number, - full_bytes, - sha256_seal_hash_vec, + nonce_u64, + block_hash_at_number, + full_bytes, + sha256_seal_hash_vec, keccak_256_seal_hash_vec, - seal_hash - ); + seal_hash + ); seal_hash } diff --git a/pallets/subtensor/src/subnets/weights.rs b/pallets/subtensor/src/subnets/weights.rs index ad868c52d..a122e7b98 100644 --- a/pallets/subtensor/src/subnets/weights.rs +++ b/pallets/subtensor/src/subnets/weights.rs @@ -4,8 +4,8 @@ use codec::Compact; use safe_math::*; use sp_core::{ConstU32, H256}; use sp_runtime::{ - traits::{BlakeTwo256, Hash}, BoundedVec, + traits::{BlakeTwo256, Hash}, }; use sp_std::{collections::vec_deque::VecDeque, vec}; diff --git a/pallets/subtensor/src/swap/swap_coldkey.rs b/pallets/subtensor/src/swap/swap_coldkey.rs index b505cd58e..7047a204e 100644 --- a/pallets/subtensor/src/swap/swap_coldkey.rs +++ b/pallets/subtensor/src/swap/swap_coldkey.rs @@ -157,16 +157,8 @@ impl Pallet { } // 3. Swap Stake. - // Stake: MAP ( hotkey, coldkey ) --> u64 | Stake of the hotkey for the coldkey. + // StakingHotkeys: MAP ( coldkey ) --> Vec( hotkey ) for hotkey in StakingHotkeys::::get(old_coldkey) { - // Get the stake on the old (hot,coldkey) account. - let old_stake: u64 = Stake::::get(&hotkey, old_coldkey); - // Get the stake on the new (hot,coldkey) account. - let new_stake: u64 = Stake::::get(&hotkey, new_coldkey); - // Add the stake to new account. - Stake::::insert(&hotkey, new_coldkey, new_stake.saturating_add(old_stake)); - // Remove the value from the old account. - Stake::::remove(&hotkey, old_coldkey); // 3.1 Swap Alpha for netuid in Self::get_all_subnet_netuids() { // Get the stake on the old (hot,coldkey) account. diff --git a/pallets/subtensor/src/swap/swap_hotkey.rs b/pallets/subtensor/src/swap/swap_hotkey.rs index ffe9dca8d..74070faac 100644 --- a/pallets/subtensor/src/swap/swap_hotkey.rs +++ b/pallets/subtensor/src/swap/swap_hotkey.rs @@ -333,28 +333,6 @@ impl Pallet { } } - // 11. Swap Stake. - // Stake( hotkey, coldkey ) -> stake -- the stake that the hotkey controls on behalf of the coldkey. - let stakes: Vec<(T::AccountId, u64)> = Stake::::iter_prefix(old_hotkey).collect(); - // Clear the entire old prefix here. - let _ = Stake::::clear_prefix(old_hotkey, stakes.len() as u32, None); - // Iterate over all the staking rows and insert them into the new hotkey. - for (coldkey, old_stake_amount) in stakes { - weight.saturating_accrue(T::DbWeight::get().reads(1)); - - // Swap Stake value - // Stake( hotkey, coldkey ) -> stake -- the stake that the hotkey controls on behalf of the coldkey. - // Get the new stake value. - let new_stake_value: u64 = Stake::::get(new_hotkey, &coldkey); - // Insert the new stake value. - Stake::::insert( - new_hotkey, - &coldkey, - new_stake_value.saturating_add(old_stake_amount), - ); - weight.saturating_accrue(T::DbWeight::get().writes(1)); - } - // 12. Swap ChildKeys. // ChildKeys( parent, netuid ) --> Vec<(proportion,child)> -- the child keys of the parent. for netuid in Self::get_all_subnet_netuids() { diff --git a/pallets/subtensor/src/tests/children.rs b/pallets/subtensor/src/tests/children.rs index b6181e03c..b16836e8f 100644 --- a/pallets/subtensor/src/tests/children.rs +++ b/pallets/subtensor/src/tests/children.rs @@ -4,7 +4,7 @@ use super::mock::*; use approx::assert_abs_diff_eq; use frame_support::{assert_err, assert_noop, assert_ok}; -use substrate_fixed::types::I96F32; +use substrate_fixed::types::{I64F64, I96F32}; use crate::{utils::rate_limiting::TransactionType, *}; use sp_core::U256; @@ -453,7 +453,7 @@ fn test_do_set_empty_children_network_does_not_exist() { let coldkey = U256::from(1); let hotkey = U256::from(2); let netuid: u16 = 999; // Non-existent network - // Attempt to revoke child + // Attempt to revoke child assert_err!( SubtensorModule::do_schedule_children( RuntimeOrigin::signed(coldkey), @@ -1180,7 +1180,7 @@ fn test_do_revoke_children_multiple_network_does_not_exist() { let child1 = U256::from(3); let child2 = U256::from(4); let netuid: u16 = 999; // Non-existent network - // Attempt to revoke children + // Attempt to revoke children assert_err!( SubtensorModule::do_schedule_children( RuntimeOrigin::signed(coldkey), @@ -2852,13 +2852,23 @@ fn test_set_weights_no_parent() { let values: Vec = vec![u16::MAX]; // Use maximum value for u16 let version_key = SubtensorModule::get_weights_version_key(netuid); - // Set the min stake very high - SubtensorModule::set_stake_threshold(stake_to_give_child * 5); + // Check the stake weight + let curr_stake_weight = + SubtensorModule::get_stake_weights_for_hotkey_on_subnet(&hotkey, netuid).0; - // Check the key has less stake than required + // Set the min stake very high, above the stake weight of the key + SubtensorModule::set_stake_threshold( + curr_stake_weight + .saturating_mul(I64F64::saturating_from_num(5)) + .saturating_to_num::(), + ); + + let curr_stake_threshold = SubtensorModule::get_stake_threshold(); assert!( - SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey, netuid) - < SubtensorModule::get_stake_threshold() + curr_stake_weight < curr_stake_threshold, + "{:?} is not less than {:?} ", + curr_stake_weight, + curr_stake_threshold ); // Check the hotkey cannot set weights @@ -2876,12 +2886,21 @@ fn test_set_weights_no_parent() { assert!(!SubtensorModule::check_weights_min_stake(&hotkey, netuid)); // Set a minimum stake to set weights - SubtensorModule::set_stake_threshold(stake_to_give_child - 5); + SubtensorModule::set_stake_threshold( + curr_stake_weight + .saturating_sub(I64F64::saturating_from_num(5)) + .saturating_to_num::(), + ); // Check if the stake for the hotkey is above + let new_stake_weight = + SubtensorModule::get_stake_weights_for_hotkey_on_subnet(&hotkey, netuid).0; + let new_stake_threshold = SubtensorModule::get_stake_threshold(); assert!( - SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey, netuid) - >= SubtensorModule::get_stake_threshold() + new_stake_weight >= new_stake_threshold, + "{:?} is not greater than or equal to {:?} ", + new_stake_weight, + new_stake_threshold ); // Check the hotkey can set weights @@ -2897,210 +2916,120 @@ fn test_set_weights_no_parent() { }); } -/// Test that drain_hotkey_emission sends childkey take fully to the childkey. +/// Test that drain_pending_emission sends childkey take fully to the nominators if childkey +/// doesn't have its own stake, independently of parent hotkey take. #[allow(clippy::assertions_on_constants)] #[test] fn test_childkey_take_drain() { - new_test_ext(1).execute_with(|| { - let subnet_owner_coldkey = U256::from(1001); - let subnet_owner_hotkey = U256::from(1002); - let coldkey = U256::from(1); - let parent = U256::from(2); - let child = U256::from(3); - let nominator = U256::from(4); - let root_id: u16 = 0; - let subnet_tempo = 10; - let stake = 100_000_000_000; - let proportion: u64 = u64::MAX; - - // Add network, register hotkeys, and setup network parameters - add_network(root_id, subnet_tempo, 0); - let netuid: u16 = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); - crate::Tempo::::set(netuid, subnet_tempo); - register_ok_neuron(netuid, child, coldkey, 0); - register_ok_neuron(netuid, parent, coldkey, 1); - - // Set children - mock_set_children(&coldkey, &parent, netuid, &[(proportion, child)]); - - SubtensorModule::add_balance_to_coldkey_account( - &coldkey, - stake + ExistentialDeposit::get(), - ); - SubtensorModule::add_balance_to_coldkey_account( - &nominator, - stake + ExistentialDeposit::get(), - ); - SubtensorModule::set_weights_set_rate_limit(netuid, 0); - SubtensorModule::set_max_allowed_validators(netuid, 2); - step_block(subnet_tempo); - crate::SubnetOwnerCut::::set(0); - - // Set 20% childkey take - let max_take: u16 = 0xFFFF / 5; - SubtensorModule::set_max_childkey_take(max_take); - assert_ok!(SubtensorModule::set_childkey_take( - RuntimeOrigin::signed(coldkey), - child, - netuid, - max_take - )); - - // Set zero hotkey take for childkey - SubtensorModule::set_min_delegate_take(0); - - // Setup stakes: - // Stake from parent - // Stake from nominator to childkey - // Give 100% of parent stake to childkey - assert_ok!(SubtensorModule::add_stake( - RuntimeOrigin::signed(coldkey), - parent, - netuid, - stake - )); - assert_ok!(SubtensorModule::add_stake( - RuntimeOrigin::signed(nominator), - child, - netuid, - stake - )); + // Test cases: parent_hotkey_take + [0_u16, u16::MAX / 5].iter().for_each(|parent_hotkey_take| { + new_test_ext(1).execute_with(|| { + let parent_coldkey = U256::from(1); + let parent_hotkey = U256::from(3); + let child_coldkey = U256::from(2); + let child_hotkey = U256::from(4); + let miner_coldkey = U256::from(5); + let miner_hotkey = U256::from(6); + let nominator = U256::from(7); + let netuid: u16 = 1; + let subnet_tempo = 10; + let stake = 100_000_000_000; + let proportion: u64 = u64::MAX / 2; + + // Add network, register hotkeys, and setup network parameters + add_network(netuid, subnet_tempo, 0); + register_ok_neuron(netuid, child_hotkey, child_coldkey, 0); + register_ok_neuron(netuid, parent_hotkey, parent_coldkey, 1); + register_ok_neuron(netuid, miner_hotkey, miner_coldkey, 1); + SubtensorModule::add_balance_to_coldkey_account( + &parent_coldkey, + stake + ExistentialDeposit::get(), + ); + SubtensorModule::add_balance_to_coldkey_account( + &nominator, + stake + ExistentialDeposit::get(), + ); + SubtensorModule::set_weights_set_rate_limit(netuid, 0); + SubtensorModule::set_max_allowed_validators(netuid, 2); + step_block(subnet_tempo); + SubnetOwnerCut::::set(0); - // Setup YUMA so that it creates emissions: - // Parent and child both set weights - // Parent and child register on root and - // Set root weights - crate::Weights::::insert(netuid, 0, vec![(0, 0xFFFF), (1, 0xFFFF)]); - crate::Weights::::insert(netuid, 1, vec![(0, 0xFFFF), (1, 0xFFFF)]); - assert_ok!(SubtensorModule::do_root_register( - RuntimeOrigin::signed(coldkey), - parent, - )); - assert_ok!(SubtensorModule::do_root_register( - RuntimeOrigin::signed(coldkey), - child, - )); - crate::Weights::::insert(root_id, 0, vec![(0, 0xFFFF), (1, 0xFFFF)]); - crate::Weights::::insert(root_id, 1, vec![(0, 0xFFFF), (1, 0xFFFF)]); - - // Verify how emission is split between keys - // - Child stake increased by its child key take only (20% * 50% = 10% of total emission) - // - Parent stake increased by 40% of total emission - // - Nominator stake increased by 50% of total emission - let child_emission = crate::Stake::::get(child, coldkey); - let parent_emission = crate::Stake::::get(parent, coldkey).saturating_sub(stake); - let nominator_emission = crate::Stake::::get(child, nominator).saturating_sub(stake); - let total_emission = child_emission + parent_emission + nominator_emission; - - assert_abs_diff_eq!(child_emission, total_emission / 10, epsilon = 500); - assert_abs_diff_eq!(parent_emission, total_emission / 10 * 4, epsilon = 500); - assert_abs_diff_eq!(nominator_emission, total_emission / 2, epsilon = 500); - }); -} + // Set children + mock_set_children_no_epochs(netuid, &parent_hotkey, &[(proportion, child_hotkey)]); -/// Test that drain_hotkey_emission sends childkey take fully to the childkey with validator take enabled. -#[test] -fn test_childkey_take_drain_validator_take() { - new_test_ext(1).execute_with(|| { - let coldkey = U256::from(1); - let parent = U256::from(2); - let child = U256::from(3); - let nominator = U256::from(4); - let netuid: u16 = 1; - let root_id: u16 = 0; - let subnet_tempo = 10; - let hotkey_tempo = 20; - let stake = 100_000_000_000; - let proportion: u64 = u64::MAX; - - // Add network, register hotkeys, and setup network parameters - add_network(root_id, subnet_tempo, 0); - add_network(netuid, subnet_tempo, 0); - register_ok_neuron(netuid, child, coldkey, 0); - register_ok_neuron(netuid, parent, coldkey, 1); - SubtensorModule::add_balance_to_coldkey_account( - &coldkey, - stake + ExistentialDeposit::get(), - ); - SubtensorModule::add_balance_to_coldkey_account( - &nominator, - stake + ExistentialDeposit::get(), - ); - SubtensorModule::set_weights_set_rate_limit(netuid, 0); - SubtensorModule::set_max_allowed_validators(netuid, 2); - step_block(subnet_tempo); - crate::SubnetOwnerCut::::set(0); - - // Set children - mock_set_children(&coldkey, &parent, netuid, &[(proportion, child)]); + // Set 20% childkey take + let max_take: u16 = 0xFFFF / 5; + SubtensorModule::set_max_childkey_take(max_take); + assert_ok!(SubtensorModule::set_childkey_take( + RuntimeOrigin::signed(child_coldkey), + child_hotkey, + netuid, + max_take + )); - // Set 20% childkey take - let max_take: u16 = 0xFFFF / 5; - SubtensorModule::set_max_childkey_take(max_take); - assert_ok!(SubtensorModule::set_childkey_take( - RuntimeOrigin::signed(coldkey), - child, - netuid, - max_take - )); + // Set hotkey take for parent + SubtensorModule::set_max_delegate_take(*parent_hotkey_take); + Delegates::::insert(parent_hotkey, *parent_hotkey_take); - // Set 20% hotkey take for childkey - // Set 20% hotkey take for parent - SubtensorModule::set_max_delegate_take(max_take); + // Set 0% for childkey-as-a-delegate take + Delegates::::insert(child_hotkey, 0); - // Setup stakes: - // Stake from parent - // Stake from nominator to childkey - // Give 100% of parent stake to childkey - assert_ok!(SubtensorModule::add_stake( - RuntimeOrigin::signed(coldkey), - parent, - netuid, - stake - )); - assert_ok!(SubtensorModule::add_stake( - RuntimeOrigin::signed(nominator), - child, - netuid, - stake - )); + // Setup stakes: + // Stake from parent + // Stake from nominator to childkey + // Parent gives 50% of stake to childkey + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(parent_coldkey), + parent_hotkey, + netuid, + stake + )); + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(nominator), + child_hotkey, + netuid, + stake + )); - // Setup YUMA so that it creates emissions: - // Parent and child both set weights - // Parent and child register on root and - // Set root weights - crate::Weights::::insert(netuid, 0, vec![(0, 0xFFFF), (1, 0xFFFF)]); - crate::Weights::::insert(netuid, 1, vec![(0, 0xFFFF), (1, 0xFFFF)]); - assert_ok!(SubtensorModule::do_root_register( - RuntimeOrigin::signed(coldkey), - parent, - )); - assert_ok!(SubtensorModule::do_root_register( - RuntimeOrigin::signed(coldkey), - child, - )); - crate::Weights::::insert(root_id, 0, vec![(0, 0xFFFF), (1, 0xFFFF)]); - crate::Weights::::insert(root_id, 1, vec![(0, 0xFFFF), (1, 0xFFFF)]); - - // Prevent further subnet epochs - crate::Tempo::::set(netuid, u16::MAX); - crate::Tempo::::set(root_id, u16::MAX); - - // Run run_coinbase until PendingHotkeyEmission is drained for both child and parent - step_block((hotkey_tempo * 2) as u16); - - // Verify how emission is split between keys - // - Child stake increased by its child key take (20% * 50% = 10% of total emission) plus childkey's delegate take (10%) - // - Parent stake increased by 40% of total emission - // - Nominator stake increased by 40% of total emission - let child_emission = crate::Stake::::get(child, coldkey); - let parent_emission = crate::Stake::::get(parent, coldkey).saturating_sub(stake); - let nominator_emission = crate::Stake::::get(child, nominator).saturating_sub(stake); - let total_emission = child_emission + parent_emission + nominator_emission; - - assert_abs_diff_eq!(child_emission, total_emission / 5, epsilon = 500); - assert_abs_diff_eq!(parent_emission, total_emission / 10 * 4, epsilon = 500); - assert_abs_diff_eq!(nominator_emission, total_emission / 10 * 4, epsilon = 500); + // Setup YUMA so that it creates emissions + Weights::::insert(netuid, 0, vec![(2, 0xFFFF)]); + Weights::::insert(netuid, 1, vec![(2, 0xFFFF)]); + BlockAtRegistration::::set(netuid, 0, 1); + BlockAtRegistration::::set(netuid, 1, 1); + BlockAtRegistration::::set(netuid, 2, 1); + LastUpdate::::set(netuid, vec![2, 2, 2]); + Kappa::::set(netuid, u16::MAX / 5); + ActivityCutoff::::set(netuid, u16::MAX); // makes all stake active + ValidatorPermit::::insert(netuid, vec![true, true, false]); + + // Run run_coinbase to hit subnet epoch + let child_stake_before = SubtensorModule::get_total_stake_for_coldkey(&child_coldkey); + let parent_stake_before = SubtensorModule::get_total_stake_for_coldkey(&parent_coldkey); + let nominator_stake_before = SubtensorModule::get_total_stake_for_coldkey(&nominator); + + step_block(subnet_tempo); + + // Verify how emission is split between keys + // - Child stake remains 0 + // - Childkey take is 20% of its total emission that rewards both inherited from + // parent stake and nominated stake, which all goes to nominators. Because child + // validator emission is 50% of total emission, 20% of it is 10% of total emission + // and it all goes to nominator. If childkey take was 0%, then only 5% would go to + // the nominator, so the final solit is: + // - Parent stake increases by 45% of total emission + // - Nominator stake increases by 55% of total emission + let child_emission = + SubtensorModule::get_total_stake_for_coldkey(&child_coldkey) - child_stake_before; + let parent_emission = + SubtensorModule::get_total_stake_for_coldkey(&parent_coldkey) - parent_stake_before; + let nominator_emission = + SubtensorModule::get_total_stake_for_coldkey(&nominator) - nominator_stake_before; + let total_emission = child_emission + parent_emission + nominator_emission; + + assert_abs_diff_eq!(child_emission, 0, epsilon = 10); + assert_abs_diff_eq!(parent_emission, total_emission * 9 / 20, epsilon = 10); + assert_abs_diff_eq!(nominator_emission, total_emission * 11 / 20, epsilon = 10); + }); }); } @@ -3423,7 +3352,7 @@ fn test_parent_child_chain_epoch() { // Verify emissions match expected from CHK arrangements let em_eps: I96F32 = I96F32::from_num(1e-4); // 4 decimal places - // A's pending emission: + // A's pending emission: assert!( ((I96F32::from_num(hotkey_emission[0].2) / total_emission) - I96F32::from_num(2_f64 / 3_f64 * 1_f64 / 2_f64)).abs() // 2/3 * 1/2 = 1/3; 50% -> B @@ -3554,7 +3483,7 @@ fn test_dividend_distribution_with_children() { // Verify emissions match expected from CHK arrangements let em_eps: I96F32 = I96F32::from_num(1e-4); // 4 decimal places - // A's pending emission: + // A's pending emission: assert!( ((I96F32::from_num(hotkey_emission[0].2) / total_emission) - I96F32::from_num(2_f64 / 3_f64 * 1_f64 / 2_f64)).abs() // 2/3 * 1/2 = 1/3; 50% -> B @@ -3923,3 +3852,57 @@ fn test_dynamic_parent_child_relationships() { // Child2 stake (874,826) > Child1 stake (778,446) }); } + +#[test] +fn test_do_set_child_as_sn_owner_not_enough_stake() { + new_test_ext(1).execute_with(|| { + let coldkey = U256::from(1); + let sn_owner_hotkey = U256::from(4); + + let child_coldkey = U256::from(2); + let child_hotkey = U256::from(5); + + let threshold = 10_000; + SubtensorModule::set_stake_threshold(threshold); + + let proportion: u64 = 1000; + + let netuid: u16 = add_dynamic_network(&sn_owner_hotkey, &coldkey); + register_ok_neuron(netuid, child_hotkey, child_coldkey, 0); + + // Verify stake of sn_owner_hotkey is NOT enough + assert!( + SubtensorModule::get_total_stake_for_hotkey(&sn_owner_hotkey) + < StakeThreshold::::get() + ); + + // Verify that we can set child as sn owner, even though sn_owner_hotkey has insufficient stake + assert_ok!(SubtensorModule::do_schedule_children( + RuntimeOrigin::signed(coldkey), + sn_owner_hotkey, + netuid, + vec![(proportion, child_hotkey)] + )); + + // Make new hotkey from owner coldkey + let other_sn_owner_hotkey = U256::from(6); + register_ok_neuron(netuid, other_sn_owner_hotkey, coldkey, 1234); + + // Verify stake of other_sn_owner_hotkey is NOT enough + assert!( + SubtensorModule::get_total_stake_for_hotkey(&other_sn_owner_hotkey) + < StakeThreshold::::get() + ); + + // Can't set child as sn owner, because it is not in SubnetOwnerHotkey map + assert_noop!( + SubtensorModule::do_schedule_children( + RuntimeOrigin::signed(coldkey), + other_sn_owner_hotkey, + netuid, + vec![(proportion, child_hotkey)] + ), + Error::::NotEnoughStakeToSetChildkeys + ); + }); +} diff --git a/pallets/subtensor/src/tests/coinbase.rs b/pallets/subtensor/src/tests/coinbase.rs index 66332654a..94cb786e4 100644 --- a/pallets/subtensor/src/tests/coinbase.rs +++ b/pallets/subtensor/src/tests/coinbase.rs @@ -19,6 +19,23 @@ fn close(value: u64, target: u64, eps: u64) { ) } +// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::coinbase::test_hotkey_take --exact --show-output --nocapture +#[test] +fn test_hotkey_take() { + new_test_ext(1).execute_with(|| { + let hotkey = U256::from(1); + Delegates::::insert(hotkey, u16::MAX / 2); + log::info!( + "expected: {:?}", + SubtensorModule::get_hotkey_take_float(&hotkey) + ); + log::info!( + "expected: {:?}", + SubtensorModule::get_hotkey_take_float(&hotkey) + ); + }); +} + // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::coinbase::test_dynamic_function_various_values --exact --show-output --nocapture #[test] fn test_dynamic_function_various_values() { @@ -300,7 +317,7 @@ fn test_coinbase_alpha_issuance_with_cap_trigger() { SubnetAlphaIn::::insert(netuid1, initial_alpha); // Make price extremely low. SubnetTAO::::insert(netuid2, initial); SubnetAlphaIn::::insert(netuid2, initial_alpha); // Make price extremely low. - // Set subnet prices. + // Set subnet prices. SubnetMovingPrice::::insert(netuid1, I96F32::from_num(1)); SubnetMovingPrice::::insert(netuid2, I96F32::from_num(2)); // Run coinbase @@ -341,10 +358,10 @@ fn test_coinbase_alpha_issuance_with_cap_trigger_and_block_emission() { SubnetAlphaIn::::insert(netuid1, initial_alpha); // Make price extremely low. SubnetTAO::::insert(netuid2, initial); SubnetAlphaIn::::insert(netuid2, initial_alpha); // Make price extremely low. - // Set issuance to greater than 21M + // Set issuance to greater than 21M SubnetAlphaOut::::insert(netuid1, 22_000_000_000_000_000); // Set issuance above 21M SubnetAlphaOut::::insert(netuid2, 22_000_000_000_000_000); // Set issuance above 21M - // Set subnet prices. + // Set subnet prices. SubnetMovingPrice::::insert(netuid1, I96F32::from_num(1)); SubnetMovingPrice::::insert(netuid2, I96F32::from_num(2)); // Run coinbase @@ -476,6 +493,7 @@ fn test_drain_base_with_subnet_with_single_staker_registered_root_weight() { let stake_before: u64 = 1_000_000_000; // register_ok_neuron(root, hotkey, coldkey, 0); register_ok_neuron(netuid, hotkey, coldkey, 0); + Delegates::::insert(hotkey, 0); SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1.0 SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( &hotkey, @@ -496,7 +514,7 @@ fn test_drain_base_with_subnet_with_single_staker_registered_root_weight() { SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid); let root_after = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, root); - close(stake_before + pending_alpha, stake_after, 10); // Registered gets all alpha emission. + close(stake_before + pending_alpha / 2, stake_after, 10); // Registered gets all alpha emission. close(stake_before + pending_tao, root_after, 10); // Registered gets all tao emission }); } @@ -549,6 +567,8 @@ fn test_drain_base_with_subnet_with_two_stakers_registered_and_root() { let stake_before: u64 = 1_000_000_000; register_ok_neuron(netuid, hotkey1, coldkey, 0); register_ok_neuron(netuid, hotkey2, coldkey, 0); + Delegates::::insert(hotkey1, 0); + Delegates::::insert(hotkey2, 0); SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1.0 SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( &hotkey1, @@ -585,8 +605,8 @@ fn test_drain_base_with_subnet_with_two_stakers_registered_and_root() { SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey2, &coldkey, netuid); let root_after2 = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey2, &coldkey, root); - close(stake_before + pending_alpha / 2, stake_after1, 10); // Registered gets 1/2 emission - close(stake_before + pending_alpha / 2, stake_after2, 10); // Registered gets 1/2 emission. + close(stake_before + pending_alpha / 4, stake_after1, 10); // Registered gets 1/2 emission + close(stake_before + pending_alpha / 4, stake_after2, 10); // Registered gets 1/2 emission. close(stake_before + pending_tao / 2, root_after1, 10); // Registered gets 1/2 tao emission close(stake_before + pending_tao / 2, root_after2, 10); // Registered gets 1/2 tao emission }); @@ -603,6 +623,8 @@ fn test_drain_base_with_subnet_with_two_stakers_registered_and_root_different_am let hotkey2 = U256::from(2); let coldkey = U256::from(3); let stake_before: u64 = 1_000_000_000; + Delegates::::insert(hotkey1, 0); + Delegates::::insert(hotkey2, 0); register_ok_neuron(netuid, hotkey1, coldkey, 0); register_ok_neuron(netuid, hotkey2, coldkey, 0); SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1.0 @@ -642,10 +664,14 @@ fn test_drain_base_with_subnet_with_two_stakers_registered_and_root_different_am let root_after2 = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey2, &coldkey, root); let expected_stake = I96F32::from_num(stake_before) - + I96F32::from_num(pending_alpha) * I96F32::from_num(3.0 / 5.0); + + (I96F32::from_num(pending_alpha) + * I96F32::from_num(3.0 / 5.0) + * I96F32::from_num(1.0 / 3.0)); close(expected_stake.to_num::(), stake_after1, 10); // Registered gets 60% of emission let expected_stake2 = I96F32::from_num(stake_before) - + I96F32::from_num(pending_alpha) * I96F32::from_num(2.0 / 5.0); + + I96F32::from_num(pending_alpha) + * I96F32::from_num(2.0 / 5.0) + * I96F32::from_num(1.0 / 2.0); close(expected_stake2.to_num::(), stake_after2, 10); // Registered gets 40% emission let expected_root1 = I96F32::from_num(2 * stake_before) + I96F32::from_num(pending_tao) * I96F32::from_num(2.0 / 3.0); @@ -658,8 +684,8 @@ fn test_drain_base_with_subnet_with_two_stakers_registered_and_root_different_am // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::coinbase::test_drain_base_with_subnet_with_two_stakers_registered_and_root_different_amounts_half_tao_weight --exact --show-output --nocapture #[test] -fn test_drain_base_with_subnet_with_two_stakers_registered_and_root_different_amounts_half_tao_weight( -) { +fn test_drain_base_with_subnet_with_two_stakers_registered_and_root_different_amounts_half_tao_weight() + { new_test_ext(1).execute_with(|| { let root: u16 = 0; let netuid: u16 = 1; @@ -668,6 +694,8 @@ fn test_drain_base_with_subnet_with_two_stakers_registered_and_root_different_am let hotkey2 = U256::from(2); let coldkey = U256::from(3); let stake_before: u64 = 1_000_000_000; + Delegates::::insert(hotkey1, 0); + Delegates::::insert(hotkey2, 0); register_ok_neuron(netuid, hotkey1, coldkey, 0); register_ok_neuron(netuid, hotkey2, coldkey, 0); SubtensorModule::set_tao_weight(u64::MAX / 2); // Set TAO weight to 0.5 @@ -708,11 +736,15 @@ fn test_drain_base_with_subnet_with_two_stakers_registered_and_root_different_am SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey2, &coldkey, root); // hotkey 1 has (1 + (2 * 0.5))/( 1 + 1*0.5 + 1 + (2 * 0.5)) = 0.5714285714 of the hotkey emission. let expected_stake = I96F32::from_num(stake_before) - + I96F32::from_num(pending_alpha) * I96F32::from_num(0.5714285714); + + I96F32::from_num(pending_alpha) + * I96F32::from_num(0.5714285714) + * I96F32::from_num(1.0 / 2.0); close(expected_stake.to_num::(), stake_after1, 10); // hotkey 2 has (1 + 1*0.5)/( 1 + 1*0.5 + 1 + (2 * 0.5)) = 0.4285714286 of the hotkey emission. let expected_stake2 = I96F32::from_num(stake_before) - + I96F32::from_num(pending_alpha) * I96F32::from_num(0.4285714286); + + I96F32::from_num(pending_alpha) + * I96F32::from_num(0.4285714286) + * I96F32::from_num(2.0 / 3.0); close(expected_stake2.to_num::(), stake_after2, 10); // hotkey 1 has 2 / 3 root tao let expected_root1 = I96F32::from_num(2 * stake_before) @@ -901,7 +933,7 @@ fn test_get_root_children_drain() { add_network(alpha, 1, 0); // Set TAO weight to 1. SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1. - // Create keys. + // Create keys. let cold = U256::from(0); let alice = U256::from(1); let bob = U256::from(2); @@ -970,11 +1002,11 @@ fn test_get_root_children_drain() { // Alice and Bob both made half of the dividends. assert_eq!( SubtensorModule::get_stake_for_hotkey_on_subnet(&alice, alpha), - alice_alpha_stake + pending_alpha / 2 + alice_alpha_stake + pending_alpha / 4 ); assert_eq!( SubtensorModule::get_stake_for_hotkey_on_subnet(&bob, alpha), - bob_alpha_stake + pending_alpha / 2 + bob_alpha_stake + pending_alpha / 4 ); // Lets drain @@ -1006,7 +1038,7 @@ fn test_get_root_children_drain() { // Bob makes it all. assert_eq!( AlphaDividendsPerSubnet::::get(alpha, bob), - pending_alpha + (I96F32::from_num(pending_alpha) * I96F32::from_num(1.0 - 0.495412844)).to_num::() ); assert_eq!(TaoDividendsPerSubnet::::get(alpha, bob), pending_root); }); @@ -1023,7 +1055,7 @@ fn test_get_root_children_drain_half_proportion() { add_network(alpha, 1, 0); // Set TAO weight to 1. SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1. - // Create keys. + // Create keys. let cold = U256::from(0); let alice = U256::from(1); let bob = U256::from(2); @@ -1083,12 +1115,12 @@ fn test_get_root_children_drain_half_proportion() { // Alice and Bob make the same amount. close( AlphaDividendsPerSubnet::::get(alpha, alice), - pending_alpha / 2, + pending_alpha / 4, 10, ); close( AlphaDividendsPerSubnet::::get(alpha, bob), - pending_alpha / 2, + pending_alpha / 4, 10, ); }); @@ -1105,7 +1137,7 @@ fn test_get_root_children_drain_with_take() { add_network(alpha, 1, 0); // Set TAO weight to 1. SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1. - // Create keys. + // Create keys. let cold = U256::from(0); let alice = U256::from(1); let bob = U256::from(2); @@ -1165,7 +1197,7 @@ fn test_get_root_children_drain_with_take() { close(AlphaDividendsPerSubnet::::get(alpha, alice), 0, 10); close( AlphaDividendsPerSubnet::::get(alpha, bob), - pending_alpha, + pending_alpha / 2, 10, ); }); @@ -1182,7 +1214,7 @@ fn test_get_root_children_drain_with_half_take() { add_network(alpha, 1, 0); // Set TAO weight to 1. SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1. - // Create keys. + // Create keys. let cold = U256::from(0); let alice = U256::from(1); let bob = U256::from(2); @@ -1241,12 +1273,12 @@ fn test_get_root_children_drain_with_half_take() { // Alice and Bob make the same amount. close( AlphaDividendsPerSubnet::::get(alpha, alice), - pending_alpha / 4, + pending_alpha / 8, 10000, ); close( AlphaDividendsPerSubnet::::get(alpha, bob), - 3 * (pending_alpha / 4), + 3 * (pending_alpha / 8), 10000, ); }); diff --git a/pallets/subtensor/src/tests/delegate_info.rs b/pallets/subtensor/src/tests/delegate_info.rs index 0dcb69d78..6fbcbbfb8 100644 --- a/pallets/subtensor/src/tests/delegate_info.rs +++ b/pallets/subtensor/src/tests/delegate_info.rs @@ -1,8 +1,11 @@ +use super::mock::*; + use codec::Compact; +use frame_support::assert_ok; +use scale_info::prelude::collections::HashMap; +use sp_core::U256; use substrate_fixed::types::U64F64; -use super::mock::*; - #[test] fn test_return_per_1000_tao() { let take = // 18% take to the Validator @@ -31,3 +34,140 @@ fn test_return_per_1000_tao() { eps ); } + +#[test] +fn test_get_delegated() { + new_test_ext(1).execute_with(|| { + let sn_owner_0 = U256::from(0); + let sn_owner_1 = U256::from(1); + + // Delegates + let owner_0 = U256::from(100); + let owner_1 = U256::from(1 + 100); + let delegate_0 = U256::from(200); + let delegate_1 = U256::from(1 + 200); + + // Create 2 networks + let netuid_0 = add_dynamic_network(&sn_owner_0, &sn_owner_0); + let netuid_1 = add_dynamic_network(&sn_owner_1, &sn_owner_1); + + // Create delegate hotkey 0 on both networks + register_ok_neuron(netuid_0, delegate_0, owner_0, 0); + register_ok_neuron(netuid_1, delegate_0, owner_0, 1); + + // Create delegate hotkey 1 on both networks + register_ok_neuron(netuid_0, delegate_1, owner_1, 2); + register_ok_neuron(netuid_1, delegate_1, owner_1, 3); + + // Stake to both hotkeys on both networks with delegatee_0 + let delegatee_0 = U256::from(300); + let to_stake_0 = vec![ + (netuid_0, Some(delegate_0), 1_000_000_000), + (netuid_1, Some(delegate_0), 2_000_000_000), + (netuid_0, Some(delegate_1), 1_000_000_000), + (netuid_1, Some(delegate_1), 2_000_000_000), + ]; + + // Stake to both hotkeys on only one network with delegatee_1 + let delegatee_1 = U256::from(1 + 300); + let to_stake_1 = vec![ + (netuid_0, Some(delegate_0), 1_000_000_000), + (netuid_0, Some(delegate_1), 2_000_000_000), + ]; + + // Stake to both hotkey on either network with delegatee_2 + let delegatee_2 = U256::from(2 + 300); + let to_stake_2 = vec![ + (netuid_0, Some(delegate_0), 1_000_000_000), + (netuid_0, None, 0), + (netuid_1, None, 0), + (netuid_1, Some(delegate_1), 2_000_000_000), + ]; + + // Stake to one hotkey on one network with delegatee_3 + let delegatee_3 = U256::from(3 + 300); + let to_stake_3 = vec![ + (netuid_0, Some(delegate_0), 1_000_000_000), + (netuid_0, None, 0), + (netuid_1, None, 0), + (netuid_1, None, 0), + ]; + + // Stake to no hotkeys with delegatee_4 + let delegatee_4 = U256::from(4 + 300); + let to_stake_4 = vec![ + (netuid_0, None, 0), + (netuid_0, None, 0), + (netuid_1, None, 0), + (netuid_1, None, 0), + ]; + + // Run staking for each delegatee + let coldkeys = vec![ + delegatee_0, + delegatee_1, + delegatee_2, + delegatee_3, + delegatee_4, + ]; + let to_stakes = [to_stake_0, to_stake_1, to_stake_2, to_stake_3, to_stake_4]; + let mut expected_stake_map: HashMap>> = + HashMap::new(); + + for (i, to_stake) in to_stakes.iter().enumerate() { + let delegatee = coldkeys.get(i).expect("Delegatee not found"); + for (netuid, delegate, amount) in to_stake { + let Some(delegate) = delegate else { + continue; + }; + SubtensorModule::add_balance_to_coldkey_account(delegatee, *amount + 500_000); + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(*delegatee), + *delegate, + *netuid, + *amount + )); + let expected_stake = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( + delegate, delegatee, *netuid, + ); + let stakes = expected_stake_map + .entry(*delegatee) + .or_default() + .entry(*delegate) + .or_default(); + stakes.insert(*netuid, expected_stake); + } + } + + // Check delegated info for each coldkey + for coldkey in coldkeys { + let delegated = SubtensorModule::get_delegated(coldkey); + + for (delegate_info, (netuid, staked)) in delegated.iter() { + if let Some(coldkey_stakes_map) = expected_stake_map.get(&coldkey) { + if let Some(expected_under_delegate) = + coldkey_stakes_map.get(&delegate_info.delegate_ss58) + { + if let Some(expected_stake) = + expected_under_delegate.get(&u16::from(*netuid)) + { + assert_eq!(u64::from(*staked), *expected_stake); + } else { + panic!( + "Netuid {} not found in expected stake map", + u16::from(*netuid) + ); + }; + } else { + panic!( + "Delegate {} not found in expected stake map", + delegate_info.delegate_ss58 + ); + }; + } else { + panic!("Coldkey {} not found in expected stake map", coldkey); + } + } + } + }); +} diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index a353ee5b9..4c24769c2 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -11,7 +11,7 @@ use crate::*; use frame_support::{assert_err, assert_ok}; // use frame_system::Config; -use rand::{distributions::Uniform, rngs::StdRng, seq::SliceRandom, thread_rng, Rng, SeedableRng}; +use rand::{Rng, SeedableRng, distributions::Uniform, rngs::StdRng, seq::SliceRandom, thread_rng}; use sp_core::{Get, U256}; // use sp_runtime::DispatchError; use std::time::Instant; diff --git a/pallets/subtensor/src/tests/math.rs b/pallets/subtensor/src/tests/math.rs index 59d826ab3..19bab75b4 100644 --- a/pallets/subtensor/src/tests/math.rs +++ b/pallets/subtensor/src/tests/math.rs @@ -6,10 +6,10 @@ use substrate_fixed::types::{I32F32, I64F64}; use crate::epoch::math::*; -use rand::{seq::SliceRandom, thread_rng, Rng}; +use rand::{Rng, seq::SliceRandom, thread_rng}; use substrate_fixed::{ transcendental::exp, - types::{I110F18, I96F32}, + types::{I96F32, I110F18}, }; fn assert_float_compare(a: I32F32, b: I32F32, epsilon: I32F32) { diff --git a/pallets/subtensor/src/tests/migration.rs b/pallets/subtensor/src/tests/migration.rs index 6d45cbe0b..2b2feae4b 100644 --- a/pallets/subtensor/src/tests/migration.rs +++ b/pallets/subtensor/src/tests/migration.rs @@ -4,18 +4,17 @@ use super::mock::*; use crate::*; use codec::{Decode, Encode}; use frame_support::{ - assert_ok, + StorageHasher, Twox64Concat, assert_ok, storage::unhashed::{get, get_raw, put, put_raw}, traits::{StorageInstance, StoredMap}, weights::Weight, - StorageHasher, Twox64Concat, }; use frame_system::Config; -use sp_core::{crypto::Ss58Codec, H256, U256}; +use sp_core::{H256, U256, crypto::Ss58Codec}; use sp_io::hashing::twox_128; use sp_runtime::traits::Zero; -use substrate_fixed::types::extra::U2; use substrate_fixed::types::I96F32; +use substrate_fixed::types::extra::U2; #[allow(clippy::arithmetic_side_effects)] fn close(value: u64, target: u64, eps: u64) { @@ -99,21 +98,6 @@ fn test_migration_delete_subnet_21() { }) } -fn run_migration_and_check(migration_name: &'static str) -> frame_support::weights::Weight { - // Execute the migration and store its weight - let weight: frame_support::weights::Weight = - crate::migrations::migrate_fix_total_coldkey_stake::migrate_fix_total_coldkey_stake::( - ); - - // Check if the migration has been marked as completed - assert!(HasMigrationRun::::get( - migration_name.as_bytes().to_vec() - )); - - // Return the weight of the executed migration - weight -} - #[test] fn test_migrate_commit_reveal_2() { new_test_ext(1).execute_with(|| { @@ -201,194 +185,195 @@ fn test_migrate_commit_reveal_2() { }); } +// Leaving in for reference. Will remove later. // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::migration::test_migrate_rao --exact --show-output --nocapture -#[test] -fn test_migrate_rao() { - new_test_ext(1).execute_with(|| { - // Setup initial state - let netuid_0: u16 = 0; - let netuid_1: u16 = 1; - let netuid_2: u16 = 2; - let netuid_3: u16 = 3; - let hotkey1 = U256::from(1); - let hotkey2 = U256::from(2); - let coldkey1 = U256::from(3); - let coldkey2 = U256::from(4); - let coldkey3 = U256::from(5); - let stake_amount: u64 = 1_000_000_000; - let lock_amount: u64 = 500; - NetworkMinLockCost::::set(500); - - // Add networks root and alpha - add_network(netuid_0, 1, 0); - add_network(netuid_1, 1, 0); - add_network(netuid_2, 1, 0); - add_network(netuid_3, 1, 0); - - // Set subnet lock - SubnetLocked::::insert(netuid_1, lock_amount); - - // Add some initial stake - EmissionValues::::insert(netuid_1, 1_000_000_000); - EmissionValues::::insert(netuid_2, 2_000_000_000); - EmissionValues::::insert(netuid_3, 3_000_000_000); - - Owner::::insert(hotkey1, coldkey1); - Owner::::insert(hotkey2, coldkey2); - Stake::::insert(hotkey1, coldkey1, stake_amount); - Stake::::insert(hotkey1, coldkey2, stake_amount); - Stake::::insert(hotkey2, coldkey2, stake_amount); - Stake::::insert(hotkey2, coldkey3, stake_amount); - - // Verify initial conditions - assert_eq!(SubnetTAO::::get(netuid_0), 0); - assert_eq!(SubnetTAO::::get(netuid_1), 0); - assert_eq!(SubnetAlphaOut::::get(netuid_0), 0); - assert_eq!(SubnetAlphaOut::::get(netuid_1), 0); - assert_eq!(SubnetAlphaIn::::get(netuid_0), 0); - assert_eq!(SubnetAlphaIn::::get(netuid_1), 0); - assert_eq!(TotalHotkeyShares::::get(hotkey1, netuid_0), 0); - assert_eq!(TotalHotkeyShares::::get(hotkey1, netuid_1), 0); - assert_eq!(TotalHotkeyAlpha::::get(hotkey1, netuid_0), 0); - assert_eq!(TotalHotkeyAlpha::::get(hotkey2, netuid_1), 0); - - // Run migration - crate::migrations::migrate_rao::migrate_rao::(); - - // Verify root subnet (netuid 0) state after migration - assert_eq!(SubnetTAO::::get(netuid_0), 4 * stake_amount); // Root has everything - assert_eq!(SubnetTAO::::get(netuid_1), 1_000_000_000); // Always 1000000000 - assert_eq!(SubnetAlphaIn::::get(netuid_0), 1_000_000_000); // Always 1_000_000_000 - assert_eq!(SubnetAlphaIn::::get(netuid_1), 1_000_000_000); // Always 1_000_000_000 - assert_eq!(SubnetAlphaOut::::get(netuid_0), 4 * stake_amount); // Root has everything. - assert_eq!(SubnetAlphaOut::::get(netuid_1), 0); // No stake outstanding. - - // Assert share information for hotkey1 on netuid_0 - assert_eq!( - TotalHotkeyShares::::get(hotkey1, netuid_0), - 2 * stake_amount - ); // Shares - // Assert no shares for hotkey1 on netuid_1 - assert_eq!(TotalHotkeyShares::::get(hotkey1, netuid_1), 0); // No shares - // Assert alpha for hotkey1 on netuid_0 - assert_eq!( - TotalHotkeyAlpha::::get(hotkey1, netuid_0), - 2 * stake_amount - ); // Alpha - // Assert no alpha for hotkey1 on netuid_1 - assert_eq!(TotalHotkeyAlpha::::get(hotkey1, netuid_1), 0); // No alpha. - // Assert share information for hotkey2 on netuid_0 - assert_eq!( - TotalHotkeyShares::::get(hotkey2, netuid_0), - 2 * stake_amount - ); // Shares - // Assert no shares for hotkey2 on netuid_1 - assert_eq!(TotalHotkeyShares::::get(hotkey2, netuid_1), 0); // No shares - // Assert alpha for hotkey2 on netuid_0 - assert_eq!( - TotalHotkeyAlpha::::get(hotkey2, netuid_0), - 2 * stake_amount - ); // Alpha - // Assert no alpha for hotkey2 on netuid_1 - assert_eq!(TotalHotkeyAlpha::::get(hotkey2, netuid_1), 0); // No alpha. - - // Assert stake balances for hotkey1 and coldkey1 on netuid_0 - assert_eq!( - SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey1, &coldkey1, netuid_0 - ), - stake_amount - ); - // Assert stake balances for hotkey1 and coldkey2 on netuid_0 - assert_eq!( - SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey1, &coldkey2, netuid_0 - ), - stake_amount - ); - // Assert stake balances for hotkey2 and coldkey2 on netuid_0 - assert_eq!( - SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey2, &coldkey2, netuid_0 - ), - stake_amount - ); - // Assert stake balances for hotkey2 and coldkey3 on netuid_0 - assert_eq!( - SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey2, &coldkey3, netuid_0 - ), - stake_amount - ); - // Assert total stake for hotkey1 on netuid_0 - assert_eq!( - SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey1, netuid_0), - 2 * stake_amount - ); - // Assert total stake for hotkey2 on netuid_0 - assert_eq!( - SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey2, netuid_0), - 2 * stake_amount - ); - // Increase stake for hotkey1 and coldkey1 on netuid_0 - SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey1, - &coldkey1, - netuid_0, - stake_amount, - ); - // Assert updated stake for hotkey1 and coldkey1 on netuid_0 - assert_eq!( - SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey1, &coldkey1, netuid_0 - ), - 2 * stake_amount - ); - // Assert updated total stake for hotkey1 on netuid_0 - assert_eq!( - SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey1, netuid_0), - 3 * stake_amount - ); - // Increase stake for hotkey1 and coldkey1 on netuid_1 - SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey1, - &coldkey1, - netuid_1, - stake_amount, - ); - // Assert updated stake for hotkey1 and coldkey1 on netuid_1 - assert_eq!( - SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey1, &coldkey1, netuid_1 - ), - stake_amount - ); - // Assert updated total stake for hotkey1 on netuid_1 - assert_eq!( - SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey1, netuid_1), - stake_amount - ); - - // Run the coinbase - let emission: u64 = 1_000_000_000; - SubtensorModule::run_coinbase(I96F32::from_num(emission)); - close( - SubnetTaoInEmission::::get(netuid_1), - emission / 6, - 100, - ); - close( - SubnetTaoInEmission::::get(netuid_2), - 2 * (emission / 6), - 100, - ); - close( - SubnetTaoInEmission::::get(netuid_3), - 3 * (emission / 6), - 100, - ); - }); -} +// #[test] +// fn test_migrate_rao() { +// new_test_ext(1).execute_with(|| { +// // Setup initial state +// let netuid_0: u16 = 0; +// let netuid_1: u16 = 1; +// let netuid_2: u16 = 2; +// let netuid_3: u16 = 3; +// let hotkey1 = U256::from(1); +// let hotkey2 = U256::from(2); +// let coldkey1 = U256::from(3); +// let coldkey2 = U256::from(4); +// let coldkey3 = U256::from(5); +// let stake_amount: u64 = 1_000_000_000; +// let lock_amount: u64 = 500; +// NetworkMinLockCost::::set(500); + +// // Add networks root and alpha +// add_network(netuid_0, 1, 0); +// add_network(netuid_1, 1, 0); +// add_network(netuid_2, 1, 0); +// add_network(netuid_3, 1, 0); + +// // Set subnet lock +// SubnetLocked::::insert(netuid_1, lock_amount); + +// // Add some initial stake +// EmissionValues::::insert(netuid_1, 1_000_000_000); +// EmissionValues::::insert(netuid_2, 2_000_000_000); +// EmissionValues::::insert(netuid_3, 3_000_000_000); + +// Owner::::insert(hotkey1, coldkey1); +// Owner::::insert(hotkey2, coldkey2); +// Stake::::insert(hotkey1, coldkey1, stake_amount); +// Stake::::insert(hotkey1, coldkey2, stake_amount); +// Stake::::insert(hotkey2, coldkey2, stake_amount); +// Stake::::insert(hotkey2, coldkey3, stake_amount); + +// // Verify initial conditions +// assert_eq!(SubnetTAO::::get(netuid_0), 0); +// assert_eq!(SubnetTAO::::get(netuid_1), 0); +// assert_eq!(SubnetAlphaOut::::get(netuid_0), 0); +// assert_eq!(SubnetAlphaOut::::get(netuid_1), 0); +// assert_eq!(SubnetAlphaIn::::get(netuid_0), 0); +// assert_eq!(SubnetAlphaIn::::get(netuid_1), 0); +// assert_eq!(TotalHotkeyShares::::get(hotkey1, netuid_0), 0); +// assert_eq!(TotalHotkeyShares::::get(hotkey1, netuid_1), 0); +// assert_eq!(TotalHotkeyAlpha::::get(hotkey1, netuid_0), 0); +// assert_eq!(TotalHotkeyAlpha::::get(hotkey2, netuid_1), 0); + +// // Run migration +// crate::migrations::migrate_rao::migrate_rao::(); + +// // Verify root subnet (netuid 0) state after migration +// assert_eq!(SubnetTAO::::get(netuid_0), 4 * stake_amount); // Root has everything +// assert_eq!(SubnetTAO::::get(netuid_1), 1_000_000_000); // Always 1000000000 +// assert_eq!(SubnetAlphaIn::::get(netuid_0), 1_000_000_000); // Always 1_000_000_000 +// assert_eq!(SubnetAlphaIn::::get(netuid_1), 1_000_000_000); // Always 1_000_000_000 +// assert_eq!(SubnetAlphaOut::::get(netuid_0), 4 * stake_amount); // Root has everything. +// assert_eq!(SubnetAlphaOut::::get(netuid_1), 0); // No stake outstanding. + +// // Assert share information for hotkey1 on netuid_0 +// assert_eq!( +// TotalHotkeyShares::::get(hotkey1, netuid_0), +// 2 * stake_amount +// ); // Shares +// // Assert no shares for hotkey1 on netuid_1 +// assert_eq!(TotalHotkeyShares::::get(hotkey1, netuid_1), 0); // No shares +// // Assert alpha for hotkey1 on netuid_0 +// assert_eq!( +// TotalHotkeyAlpha::::get(hotkey1, netuid_0), +// 2 * stake_amount +// ); // Alpha +// // Assert no alpha for hotkey1 on netuid_1 +// assert_eq!(TotalHotkeyAlpha::::get(hotkey1, netuid_1), 0); // No alpha. +// // Assert share information for hotkey2 on netuid_0 +// assert_eq!( +// TotalHotkeyShares::::get(hotkey2, netuid_0), +// 2 * stake_amount +// ); // Shares +// // Assert no shares for hotkey2 on netuid_1 +// assert_eq!(TotalHotkeyShares::::get(hotkey2, netuid_1), 0); // No shares +// // Assert alpha for hotkey2 on netuid_0 +// assert_eq!( +// TotalHotkeyAlpha::::get(hotkey2, netuid_0), +// 2 * stake_amount +// ); // Alpha +// // Assert no alpha for hotkey2 on netuid_1 +// assert_eq!(TotalHotkeyAlpha::::get(hotkey2, netuid_1), 0); // No alpha. + +// // Assert stake balances for hotkey1 and coldkey1 on netuid_0 +// assert_eq!( +// SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( +// &hotkey1, &coldkey1, netuid_0 +// ), +// stake_amount +// ); +// // Assert stake balances for hotkey1 and coldkey2 on netuid_0 +// assert_eq!( +// SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( +// &hotkey1, &coldkey2, netuid_0 +// ), +// stake_amount +// ); +// // Assert stake balances for hotkey2 and coldkey2 on netuid_0 +// assert_eq!( +// SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( +// &hotkey2, &coldkey2, netuid_0 +// ), +// stake_amount +// ); +// // Assert stake balances for hotkey2 and coldkey3 on netuid_0 +// assert_eq!( +// SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( +// &hotkey2, &coldkey3, netuid_0 +// ), +// stake_amount +// ); +// // Assert total stake for hotkey1 on netuid_0 +// assert_eq!( +// SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey1, netuid_0), +// 2 * stake_amount +// ); +// // Assert total stake for hotkey2 on netuid_0 +// assert_eq!( +// SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey2, netuid_0), +// 2 * stake_amount +// ); +// // Increase stake for hotkey1 and coldkey1 on netuid_0 +// SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( +// &hotkey1, +// &coldkey1, +// netuid_0, +// stake_amount, +// ); +// // Assert updated stake for hotkey1 and coldkey1 on netuid_0 +// assert_eq!( +// SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( +// &hotkey1, &coldkey1, netuid_0 +// ), +// 2 * stake_amount +// ); +// // Assert updated total stake for hotkey1 on netuid_0 +// assert_eq!( +// SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey1, netuid_0), +// 3 * stake_amount +// ); +// // Increase stake for hotkey1 and coldkey1 on netuid_1 +// SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( +// &hotkey1, +// &coldkey1, +// netuid_1, +// stake_amount, +// ); +// // Assert updated stake for hotkey1 and coldkey1 on netuid_1 +// assert_eq!( +// SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( +// &hotkey1, &coldkey1, netuid_1 +// ), +// stake_amount +// ); +// // Assert updated total stake for hotkey1 on netuid_1 +// assert_eq!( +// SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey1, netuid_1), +// stake_amount +// ); + +// // Run the coinbase +// let emission: u64 = 1_000_000_000; +// SubtensorModule::run_coinbase(I96F32::from_num(emission)); +// close( +// SubnetTaoInEmission::::get(netuid_1), +// emission / 6, +// 100, +// ); +// close( +// SubnetTaoInEmission::::get(netuid_2), +// 2 * (emission / 6), +// 100, +// ); +// close( +// SubnetTaoInEmission::::get(netuid_3), +// 3 * (emission / 6), +// 100, +// ); +// }); +// } // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::migration::test_migrate_subnet_volume --exact --show-output #[test] diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index be2292623..aae6aa60e 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -2,20 +2,20 @@ use crate::utils::rate_limiting::TransactionType; use frame_support::derive_impl; use frame_support::dispatch::DispatchResultWithPostInfo; -use frame_support::weights::constants::RocksDbWeight; use frame_support::weights::Weight; +use frame_support::weights::constants::RocksDbWeight; use frame_support::{ assert_ok, parameter_types, traits::{Everything, Hooks, PrivilegeCmp}, }; use frame_system as system; -use frame_system::{limits, EnsureNever, EnsureRoot, RawOrigin}; +use frame_system::{EnsureNever, EnsureRoot, RawOrigin, limits}; use pallet_collective::MemberCount; -use sp_core::{offchain::KeyTypeId, ConstU64, Get, H256, U256}; +use sp_core::{ConstU64, Get, H256, U256, offchain::KeyTypeId}; use sp_runtime::Perbill; use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, BuildStorage, + traits::{BlakeTwo256, IdentityLookup}, }; use sp_std::cmp::Ordering; @@ -133,7 +133,7 @@ parameter_types! { pub const SDebug:u64 = 1; pub const InitialRho: u16 = 30; pub const InitialKappa: u16 = 32_767; - pub const InitialTempo: u16 = 0; + pub const InitialTempo: u16 = 360; pub const SelfOwnership: u64 = 2; pub const InitialImmunityPeriod: u16 = 2; pub const InitialMaxAllowedUids: u16 = 2; @@ -463,8 +463,8 @@ impl pallet_preimage::Config for Test { mod test_crypto { use super::KEY_TYPE; use sp_core::{ - sr25519::{Public as Sr25519Public, Signature as Sr25519Signature}, U256, + sr25519::{Public as Sr25519Public, Signature as Sr25519Signature}, }; use sp_runtime::{ app_crypto::{app_crypto, sr25519}, diff --git a/pallets/subtensor/src/tests/move_stake.rs b/pallets/subtensor/src/tests/move_stake.rs index 15832b93f..afaee9b98 100644 --- a/pallets/subtensor/src/tests/move_stake.rs +++ b/pallets/subtensor/src/tests/move_stake.rs @@ -3,7 +3,7 @@ use crate::*; use approx::assert_abs_diff_eq; use frame_support::{assert_err, assert_noop, assert_ok}; use sp_core::{Get, U256}; -use substrate_fixed::types::I96F32; +use substrate_fixed::types::{I96F32, U64F64}; // 1. test_do_move_success // Description: Test a successful move of stake between two hotkeys in the same subnet @@ -245,7 +245,9 @@ fn test_do_move_nonexistent_destination_hotkey() { let fee = 0; // Set up initial stake - SubtensorModule::stake_into_subnet(&origin_hotkey, &coldkey, netuid, stake_amount, fee); + SubtensorModule::create_account_if_non_existent(&coldkey, &origin_hotkey); + let alpha = + SubtensorModule::stake_into_subnet(&origin_hotkey, &coldkey, netuid, stake_amount, fee); // Attempt to move stake from a non-existent origin hotkey add_network(netuid, 1, 0); @@ -256,12 +258,12 @@ fn test_do_move_nonexistent_destination_hotkey() { nonexistent_destination_hotkey, netuid, netuid, - 1234 + alpha ), Error::::HotKeyAccountNotExists ); - // Check that the stake was moved successfully + // Check that the stake was not moved assert_eq!( SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( &origin_hotkey, @@ -1641,3 +1643,112 @@ fn test_stake_transfers_disabled_validate() { assert_ok!(result3); }); } + +#[test] +// RUST_LOG=info cargo test --package pallet-subtensor --lib -- tests::staking::test_move_stake_specific_stake_into_subnet_fail --exact --show-output +fn test_move_stake_specific_stake_into_subnet_fail() { + new_test_ext(1).execute_with(|| { + let sn_owner_coldkey = U256::from(55453); + + let hotkey_account_id = U256::from(533453); + let coldkey_account_id = U256::from(55454); + let hotkey_owner_account_id = U256::from(533454); + + let existing_shares: U64F64 = + U64F64::from_num(161_986_254).saturating_div(U64F64::from_num(u64::MAX)); + let existing_stake = 36_711_495_953; + + let tao_in = 2_409_892_148_947; + let alpha_in = 15_358_708_513_716; + + let tao_staked = 200_000_000; + + //add network + let netuid: u16 = add_dynamic_network(&sn_owner_coldkey, &sn_owner_coldkey); + + let origin_netuid: u16 = add_dynamic_network(&sn_owner_coldkey, &sn_owner_coldkey); + + // Register hotkey on netuid + register_ok_neuron(netuid, hotkey_account_id, hotkey_owner_account_id, 0); + // Register hotkey on origin netuid + register_ok_neuron(origin_netuid, hotkey_account_id, hotkey_owner_account_id, 0); + + // Check we have zero staked + assert_eq!( + SubtensorModule::get_total_stake_for_hotkey(&hotkey_account_id), + 0 + ); + + // Set a hotkey pool for the hotkey on destination subnet + let mut hotkey_pool = SubtensorModule::get_alpha_share_pool(hotkey_account_id, netuid); + hotkey_pool.update_value_for_one(&hotkey_owner_account_id, 1234); // Doesn't matter, will be overridden + + // Adjust the total hotkey stake and shares to match the existing values + TotalHotkeyShares::::insert(hotkey_account_id, netuid, existing_shares); + TotalHotkeyAlpha::::insert(hotkey_account_id, netuid, existing_stake); + + // Make the hotkey a delegate + Delegates::::insert(hotkey_account_id, 0); + + // Setup Subnet pool + SubnetAlphaIn::::insert(netuid, alpha_in); + SubnetTAO::::insert(netuid, tao_in); + + // Give TAO balance to coldkey + SubtensorModule::add_balance_to_coldkey_account( + &coldkey_account_id, + tao_staked + 1_000_000_000, + ); + + // Setup Subnet pool for origin netuid + SubnetAlphaIn::::insert(origin_netuid, alpha_in + 10_000_000); + SubnetTAO::::insert(origin_netuid, tao_in + 10_000_000); + + // Add stake as new hotkey + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(coldkey_account_id), + hotkey_account_id, + origin_netuid, + tao_staked, + ),); + let alpha_to_move = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey_account_id, + &coldkey_account_id, + origin_netuid, + ); + + // Move stake to destination subnet + assert_ok!(SubtensorModule::move_stake( + RuntimeOrigin::signed(coldkey_account_id), + hotkey_account_id, + hotkey_account_id, + origin_netuid, + netuid, + alpha_to_move, + )); + + // Check that the stake has been moved + assert_eq!( + SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey_account_id, + &coldkey_account_id, + origin_netuid + ), + 0 + ); + let fee = DefaultStakingFee::::get(); + let alpha_fee: I96F32 = I96F32::from_num(fee) / SubtensorModule::get_alpha_price(netuid); + let expected_value = I96F32::from_num(alpha_to_move) + * SubtensorModule::get_alpha_price(origin_netuid) + / SubtensorModule::get_alpha_price(netuid); + assert_abs_diff_eq!( + SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey_account_id, + &coldkey_account_id, + netuid + ), + (expected_value - alpha_fee).to_num::(), + epsilon = (expected_value / 1000).to_num::() + ); + }); +} diff --git a/pallets/subtensor/src/tests/networks.rs b/pallets/subtensor/src/tests/networks.rs index ad50c69e8..f367a01d0 100644 --- a/pallets/subtensor/src/tests/networks.rs +++ b/pallets/subtensor/src/tests/networks.rs @@ -326,3 +326,20 @@ fn test_register_subnet_high_lock_cost() { assert_eq!(SubnetAlphaIn::::get(netuid), lock_cost); }) } + +#[test] +fn test_tempo_greater_than_weight_set_rate_limit() { + new_test_ext(1).execute_with(|| { + let subnet_owner_hotkey = U256::from(1); + let subnet_owner_coldkey = U256::from(2); + + let netuid = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); + + // Get tempo + let tempo = SubtensorModule::get_tempo(netuid); + + let weights_set_rate_limit = SubtensorModule::get_weights_set_rate_limit(netuid); + + assert!(tempo as u64 >= weights_set_rate_limit); + }) +} diff --git a/pallets/subtensor/src/tests/registration.rs b/pallets/subtensor/src/tests/registration.rs index d3bf61494..988f1de66 100644 --- a/pallets/subtensor/src/tests/registration.rs +++ b/pallets/subtensor/src/tests/registration.rs @@ -5,7 +5,7 @@ use frame_support::traits::Currency; use super::mock::*; use crate::{AxonInfoOf, CustomTransactionError, Error, SubtensorSignedExtension}; use frame_support::dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays}; -use frame_support::sp_runtime::{transaction_validity::InvalidTransaction, DispatchError}; +use frame_support::sp_runtime::{DispatchError, transaction_validity::InvalidTransaction}; use frame_support::{assert_err, assert_noop, assert_ok}; use frame_system::Config; use sp_core::U256; @@ -300,7 +300,7 @@ fn test_burned_registration_under_limit() { SubtensorModule::set_burn(netuid, burn_cost); add_network(netuid, 13, 0); // Add the network - // Give it some TAO to the coldkey balance; more than the burn cost + // Give it some TAO to the coldkey balance; more than the burn cost SubtensorModule::add_balance_to_coldkey_account(&coldkey_account_id, burn_cost + 10_000); let target_registrants = 2; @@ -383,7 +383,7 @@ fn test_burned_registration_rate_allows_burn_adjustment() { SubtensorModule::set_burn(netuid, burn_cost); add_network(netuid, 13, 0); // Add the network - // Give it some TAO to the coldkey balance; more than the burn cost + // Give it some TAO to the coldkey balance; more than the burn cost SubtensorModule::add_balance_to_coldkey_account(&coldkey_account_id, burn_cost + 10_000); let target_registrants = 1; // Target is 1, but we can register more than that, up to some maximum. @@ -425,7 +425,7 @@ fn test_burned_registration_ok() { let hotkey_account_id = U256::from(1); let burn_cost = 1000; let coldkey_account_id = U256::from(667); // Neighbour of the beast, har har - //add network + //add network SubtensorModule::set_burn(netuid, burn_cost); add_network(netuid, tempo, 0); // Give it some $$$ in his coldkey balance @@ -441,7 +441,7 @@ fn test_burned_registration_ok() { SubtensorModule::get_coldkey_balance(&coldkey_account_id), 10000 - burn_cost ); // funds drained on reg. - // Check if neuron has added to the specified network(netuid) + // Check if neuron has added to the specified network(netuid) assert_eq!(SubtensorModule::get_subnetwork_n(netuid), 1); //check if hotkey is added to the Hotkeys assert_eq!( @@ -472,7 +472,7 @@ fn test_burn_registration_without_neuron_slot() { let hotkey_account_id = U256::from(1); let burn_cost = 1000; let coldkey_account_id = U256::from(667); // Neighbour of the beast, har har - //add network + //add network SubtensorModule::set_burn(netuid, burn_cost); add_network(netuid, tempo, 0); // Give it some $$$ in his coldkey balance @@ -1076,7 +1076,7 @@ fn test_registration_too_many_registrations_per_interval() { #[test] fn test_registration_immunity_period() { //impl this test when epoch impl and calculating pruning score is done - /* TO DO */ + // TODO: Implement this test } #[test] diff --git a/pallets/subtensor/src/tests/senate.rs b/pallets/subtensor/src/tests/senate.rs index 70ad5bb52..5592b303b 100644 --- a/pallets/subtensor/src/tests/senate.rs +++ b/pallets/subtensor/src/tests/senate.rs @@ -6,16 +6,16 @@ use approx::assert_abs_diff_eq; use codec::Encode; use frame_support::{assert_noop, assert_ok}; use frame_system::{EventRecord, Phase}; -use sp_core::{bounded_vec, Get, H256, U256}; +use sp_core::{Get, H256, U256, bounded_vec}; use sp_runtime::{ - traits::{BlakeTwo256, Hash}, BuildStorage, + traits::{BlakeTwo256, Hash}, }; -use crate::migrations; use crate::Error; -use frame_system::pallet_prelude::*; +use crate::migrations; use frame_system::Config; +use frame_system::pallet_prelude::*; use pallet_collective::Event as CollectiveEvent; use crate::Delegates; @@ -86,7 +86,7 @@ fn test_senate_join_works() { SubtensorModule::get_coldkey_balance(&coldkey_account_id), (10000 - burn_cost) ); // funds drained on reg. - // Check if neuron has added to the specified network(netuid) + // Check if neuron has added to the specified network(netuid) assert_eq!(SubtensorModule::get_subnetwork_n(netuid), 1); // Check if hotkey is added to the Hotkeys assert_eq!( @@ -160,7 +160,7 @@ fn test_senate_vote_works() { SubtensorModule::get_coldkey_balance(&coldkey_account_id), (10000 - burn_cost) ); // funds drained on reg. - // Check if neuron has added to the specified network(netuid) + // Check if neuron has added to the specified network(netuid) assert_eq!(SubtensorModule::get_subnetwork_n(netuid), 1); // Check if hotkey is added to the Hotkeys assert_eq!( @@ -272,7 +272,7 @@ fn test_senate_vote_not_member() { SubtensorModule::get_coldkey_balance(&coldkey_account_id), (10000 - burn_cost) ); // funds drained on reg. - // Check if neuron has added to the specified network(netuid) + // Check if neuron has added to the specified network(netuid) assert_eq!(SubtensorModule::get_subnetwork_n(netuid), 1); // Check if hotkey is added to the Hotkeys assert_eq!( @@ -334,7 +334,7 @@ fn test_senate_leave_works() { SubtensorModule::get_coldkey_balance(&coldkey_account_id), (10000 - burn_cost) ); // funds drained on reg. - // Check if neuron has added to the specified network(netuid) + // Check if neuron has added to the specified network(netuid) assert_eq!(SubtensorModule::get_subnetwork_n(netuid), 1); // Check if hotkey is added to the Hotkeys assert_eq!( @@ -409,7 +409,7 @@ fn test_senate_leave_vote_removal() { SubtensorModule::get_coldkey_balance(&coldkey_account_id), (stake - burn_cost) ); // funds drained on reg. - // Check if neuron has added to the specified network(netuid) + // Check if neuron has added to the specified network(netuid) assert_eq!(SubtensorModule::get_subnetwork_n(netuid), 1); // Check if hotkey is added to the Hotkeys assert_eq!( @@ -484,7 +484,7 @@ fn test_senate_leave_vote_removal() { let cold: U256 = U256::from(i + 100); // Add balance SubtensorModule::add_balance_to_coldkey_account(&cold, 100_000_000 + (i as u64)); // lots ot stake - // Register + // Register assert_ok!(SubtensorModule::burned_register( <::RuntimeOrigin>::signed(cold), other_netuid, @@ -551,7 +551,7 @@ fn test_senate_not_leave_when_stake_removed() { SubtensorModule::get_coldkey_balance(&coldkey_account_id), (10000 - burn_cost) ); // funds drained on reg. - // Check if neuron has added to the specified network(netuid) + // Check if neuron has added to the specified network(netuid) assert_eq!(SubtensorModule::get_subnetwork_n(netuid), 1); // Check if hotkey is added to the Hotkeys assert_eq!( @@ -634,7 +634,7 @@ fn test_senate_join_current_delegate() { SubtensorModule::get_coldkey_balance(&coldkey_account_id), (10000 - burn_cost) ); // funds drained on reg. - // Check if neuron has added to the specified network(netuid) + // Check if neuron has added to the specified network(netuid) assert_eq!(SubtensorModule::get_subnetwork_n(netuid), 1); // Check if hotkey is added to the Hotkeys assert_eq!( @@ -727,7 +727,7 @@ fn test_adjust_senate_events() { SubtensorModule::get_coldkey_balance(&coldkey_account_id), (balance_to_add - burn_cost) ); // funds drained on reg. - // Check if neuron has added to the specified network(netuid) + // Check if neuron has added to the specified network(netuid) assert_eq!(SubtensorModule::get_subnetwork_n(netuid), 1); // Check if hotkey is added to the Hotkeys assert_eq!( diff --git a/pallets/subtensor/src/tests/serving.rs b/pallets/subtensor/src/tests/serving.rs index 5d5858a31..1d8202a24 100644 --- a/pallets/subtensor/src/tests/serving.rs +++ b/pallets/subtensor/src/tests/serving.rs @@ -238,7 +238,7 @@ fn test_axon_serving_rate_limit_exceeded() { add_network(netuid, tempo, modality); register_ok_neuron(netuid, hotkey_account_id, U256::from(66), 0); run_to_block(1); // Go to block 1 - // No issue on multiple + // No issue on multiple assert_ok!(SubtensorModule::serve_axon( <::RuntimeOrigin>::signed(hotkey_account_id), netuid, @@ -285,7 +285,7 @@ fn test_axon_serving_rate_limit_exceeded() { )); SubtensorModule::set_serving_rate_limit(netuid, 2); run_to_block(2); // Go to block 2 - // Needs to be 2 blocks apart, we are only 1 block apart + // Needs to be 2 blocks apart, we are only 1 block apart assert_eq!( SubtensorModule::serve_axon( <::RuntimeOrigin>::signed(hotkey_account_id), @@ -452,7 +452,7 @@ fn test_prometheus_serving_rate_limit_exceeded() { add_network(netuid, tempo, modality); register_ok_neuron(netuid, hotkey_account_id, U256::from(66), 0); run_to_block(1); // Go to block 1 - // No issue on multiple + // No issue on multiple assert_ok!(SubtensorModule::serve_prometheus( <::RuntimeOrigin>::signed(hotkey_account_id), netuid, @@ -605,7 +605,9 @@ fn test_serving_is_invalid_ipv6_address() { )); assert!(!SubtensorModule::is_valid_ip_address( 4, - test::ipv6(0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff) + test::ipv6( + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff + ) )); }); } diff --git a/pallets/subtensor/src/tests/staking.rs b/pallets/subtensor/src/tests/staking.rs index f97373b0b..5d9db9f4e 100644 --- a/pallets/subtensor/src/tests/staking.rs +++ b/pallets/subtensor/src/tests/staking.rs @@ -932,7 +932,7 @@ fn test_remove_balance_from_coldkey_account_ok() { new_test_ext(1).execute_with(|| { let coldkey_account_id = U256::from(434324); // Random let ammount = 10000; // Arbitrary - // Put some $$ on the bank + // Put some $$ on the bank SubtensorModule::add_balance_to_coldkey_account(&coldkey_account_id, ammount); assert_eq!( SubtensorModule::get_coldkey_balance(&coldkey_account_id), @@ -1671,6 +1671,70 @@ fn test_rate_limits_enforced_on_increase_take() { }); } +// Test rate-limiting on an increase take just after a decrease take +// Prevents a Validator from decreasing take and then increasing it immediately after. +#[test] +fn test_rate_limits_enforced_on_decrease_before_increase_take() { + new_test_ext(1).execute_with(|| { + // Make account + let hotkey0 = U256::from(1); + let coldkey0 = U256::from(3); + + // Add balance + SubtensorModule::add_balance_to_coldkey_account(&coldkey0, 100000); + + // Register the neuron to a new network + let netuid = 1; + add_network(netuid, 1, 0); + register_ok_neuron(netuid, hotkey0, coldkey0, 124124); + + // Coldkey / hotkey 0 become delegates with 9% take + Delegates::::insert(hotkey0, SubtensorModule::get_min_delegate_take() + 1); + assert_eq!( + SubtensorModule::get_hotkey_take(&hotkey0), + SubtensorModule::get_min_delegate_take() + 1 + ); + + // Decrease take + assert_ok!(SubtensorModule::do_decrease_take( + RuntimeOrigin::signed(coldkey0), + hotkey0, + SubtensorModule::get_min_delegate_take() + )); // Verify decrease + assert_eq!( + SubtensorModule::get_hotkey_take(&hotkey0), + SubtensorModule::get_min_delegate_take() + ); + + // Increase take immediately after + assert_eq!( + SubtensorModule::do_increase_take( + RuntimeOrigin::signed(coldkey0), + hotkey0, + SubtensorModule::get_min_delegate_take() + 1 + ), + Err(Error::::DelegateTxRateLimitExceeded.into()) + ); // Verify no change + assert_eq!( + SubtensorModule::get_hotkey_take(&hotkey0), + SubtensorModule::get_min_delegate_take() + ); + + step_block(1 + InitialTxDelegateTakeRateLimit::get() as u16); + + // Can increase after waiting + assert_ok!(SubtensorModule::do_increase_take( + RuntimeOrigin::signed(coldkey0), + hotkey0, + SubtensorModule::get_min_delegate_take() + 1 + )); // Verify increase + assert_eq!( + SubtensorModule::get_hotkey_take(&hotkey0), + SubtensorModule::get_min_delegate_take() + 1 + ); + }); +} + #[test] fn test_get_total_delegated_stake_after_unstaking() { new_test_ext(1).execute_with(|| { @@ -1939,76 +2003,93 @@ fn test_get_total_delegated_stake_exclude_owner_stake() { #[test] fn test_mining_emission_distribution_validator_valiminer_miner() { new_test_ext(1).execute_with(|| { - let coldkey = U256::from(1); - let validator = 2; - let validator_miner = 3; - let miner = U256::from(4); + let validator_coldkey = U256::from(1); + let validator_hotkey = U256::from(2); + let validator_miner_coldkey = U256::from(3); + let validator_miner_hotkey = U256::from(4); + let miner_coldkey = U256::from(5); + let miner_hotkey = U256::from(6); let netuid: u16 = 1; - let root_id: u16 = 0; - let root_tempo = 9; // neet root epoch to happen before subnet tempo let subnet_tempo = 10; let stake = 100_000_000_000; // Add network, register hotkeys, and setup network parameters - add_network(root_id, root_tempo, 0); add_network(netuid, subnet_tempo, 0); - register_ok_neuron(netuid, validator.into(), coldkey, 0); - register_ok_neuron(netuid, validator_miner.into(), coldkey, 1); - register_ok_neuron(netuid, miner, coldkey, 2); + register_ok_neuron(netuid, validator_hotkey, validator_coldkey, 0); + register_ok_neuron(netuid, validator_miner_hotkey, validator_miner_coldkey, 1); + register_ok_neuron(netuid, miner_hotkey, miner_coldkey, 2); SubtensorModule::add_balance_to_coldkey_account( - &coldkey, - 3 * stake + ExistentialDeposit::get(), + &validator_coldkey, + stake + ExistentialDeposit::get(), + ); + SubtensorModule::add_balance_to_coldkey_account( + &validator_miner_coldkey, + stake + ExistentialDeposit::get(), + ); + SubtensorModule::add_balance_to_coldkey_account( + &miner_coldkey, + stake + ExistentialDeposit::get(), ); SubtensorModule::set_weights_set_rate_limit(netuid, 0); step_block(subnet_tempo); - crate::SubnetOwnerCut::::set(0); - // All stake is active - crate::ActivityCutoff::::set(netuid, u16::MAX); + SubnetOwnerCut::::set(0); // There are two validators and three neurons - crate::MaxAllowedUids::::set(netuid, 3); + MaxAllowedUids::::set(netuid, 3); SubtensorModule::set_max_allowed_validators(netuid, 2); // Setup stakes: // Stake from validator // Stake from valiminer - crate::Stake::::set(U256::from(validator), coldkey, stake); - crate::Stake::::set(U256::from(validator_miner), coldkey, stake); - - // Setup YUMA so that it creates emissions: - // Validator 1 sets weight for valiminer |- to achieve equal incentive for both miners - // Valiminer sets weights for the second miner | - // Validator registers on root and - // Sets root weights - // Last weight update is after block at registration - crate::Weights::::insert(netuid, 0, vec![(1, 0xFFFF)]); - crate::Weights::::insert(netuid, 1, vec![(2, 0xFFFF)]); - assert_ok!(SubtensorModule::do_root_register( - RuntimeOrigin::signed(coldkey), - U256::from(validator), + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(validator_coldkey), + validator_hotkey, + netuid, + stake + )); + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(validator_miner_coldkey), + validator_miner_hotkey, + netuid, + stake )); - crate::Weights::::insert(root_id, 0, vec![(0, 0xFFFF), (1, 0xFFFF)]); - crate::BlockAtRegistration::::set(netuid, 0, 1); - crate::BlockAtRegistration::::set(netuid, 1, 1); - crate::LastUpdate::::set(netuid, vec![2, 2, 2]); - crate::Kappa::::set(netuid, u16::MAX / 5); + + // Setup YUMA so that it creates emissions + Weights::::insert(netuid, 0, vec![(1, 0xFFFF)]); + Weights::::insert(netuid, 1, vec![(2, 0xFFFF)]); + BlockAtRegistration::::set(netuid, 0, 1); + BlockAtRegistration::::set(netuid, 1, 1); + BlockAtRegistration::::set(netuid, 2, 1); + LastUpdate::::set(netuid, vec![2, 2, 2]); + Kappa::::set(netuid, u16::MAX / 5); + ActivityCutoff::::set(netuid, u16::MAX); // makes all stake active + ValidatorPermit::::insert(netuid, vec![true, true, false]); // Run run_coinbase until emissions are drained - step_block(subnet_tempo * 4); + let validator_stake_before = + SubtensorModule::get_total_stake_for_coldkey(&validator_coldkey); + let valiminer_stake_before = + SubtensorModule::get_total_stake_for_coldkey(&validator_miner_coldkey); + let miner_stake_before = SubtensorModule::get_total_stake_for_coldkey(&miner_coldkey); + + step_block(subnet_tempo); // Verify how emission is split between keys - // - 50% goes to miners and 50% goes to validators + // - Owner cut is zero => 50% goes to miners and 50% goes to validators // - Validator gets 25% because there are two validators // - Valiminer gets 25% as a validator and 25% as miner // - Miner gets 25% as miner - let validator_emission = crate::Stake::::get(U256::from(validator), coldkey) - stake; + let validator_emission = SubtensorModule::get_total_stake_for_coldkey(&validator_coldkey) + - validator_stake_before; let valiminer_emission = - crate::Stake::::get(U256::from(validator_miner), coldkey) - stake; - let miner_emission = crate::Stake::::get(miner, coldkey); + SubtensorModule::get_total_stake_for_coldkey(&validator_miner_coldkey) + - valiminer_stake_before; + let miner_emission = + SubtensorModule::get_total_stake_for_coldkey(&miner_coldkey) - miner_stake_before; let total_emission = validator_emission + valiminer_emission + miner_emission; - assert_eq!(validator_emission, total_emission / 4); - assert_eq!(valiminer_emission, total_emission / 2); - assert_eq!(miner_emission, total_emission / 4); + assert_abs_diff_eq!(validator_emission, total_emission / 4, epsilon = 10); + assert_abs_diff_eq!(valiminer_emission, total_emission / 2, epsilon = 10); + assert_abs_diff_eq!(miner_emission, total_emission / 4, epsilon = 10); }); } @@ -2161,17 +2242,17 @@ fn test_stake_below_min_validate() { amount_staked, }); - let info: crate::DispatchInfo = - crate::DispatchInfoOf::<::RuntimeCall>::default(); + let info: DispatchInfo = + DispatchInfoOf::<::RuntimeCall>::default(); - let extension = crate::SubtensorSignedExtension::::new(); + let extension = SubtensorSignedExtension::::new(); // Submit to the signed extension validate function let result_no_stake = extension.validate(&coldkey, &call.clone(), &info, 10); // Should fail due to insufficient stake assert_err!( result_no_stake, - crate::TransactionValidityError::Invalid(crate::InvalidTransaction::Custom( + TransactionValidityError::Invalid(InvalidTransaction::Custom( CustomTransactionError::StakeAmountTooLow.into() )) ); @@ -2190,7 +2271,7 @@ fn test_stake_below_min_validate() { // Still doesn't pass, but with a different reason (balance too low) assert_err!( result_low_balance, - crate::TransactionValidityError::Invalid(crate::InvalidTransaction::Custom( + TransactionValidityError::Invalid(InvalidTransaction::Custom( CustomTransactionError::BalanceTooLow.into() )) ); @@ -2244,17 +2325,17 @@ fn test_add_stake_limit_validate() { allow_partial: false, }); - let info: crate::DispatchInfo = - crate::DispatchInfoOf::<::RuntimeCall>::default(); + let info: DispatchInfo = + DispatchInfoOf::<::RuntimeCall>::default(); - let extension = crate::SubtensorSignedExtension::::new(); + let extension = SubtensorSignedExtension::::new(); // Submit to the signed extension validate function let result_no_stake = extension.validate(&coldkey, &call.clone(), &info, 10); // Should fail due to slippage assert_err!( result_no_stake, - crate::TransactionValidityError::Invalid(crate::InvalidTransaction::Custom( + TransactionValidityError::Invalid(InvalidTransaction::Custom( CustomTransactionError::SlippageTooHigh.into() )) ); @@ -2304,17 +2385,17 @@ fn test_remove_stake_limit_validate() { allow_partial: false, }); - let info: crate::DispatchInfo = - crate::DispatchInfoOf::<::RuntimeCall>::default(); + let info: DispatchInfo = + DispatchInfoOf::<::RuntimeCall>::default(); - let extension = crate::SubtensorSignedExtension::::new(); + let extension = SubtensorSignedExtension::::new(); // Submit to the signed extension validate function let result_no_stake = extension.validate(&coldkey, &call.clone(), &info, 10); // Should fail due to slippage assert_err!( result_no_stake, - crate::TransactionValidityError::Invalid(crate::InvalidTransaction::Custom( + TransactionValidityError::Invalid(InvalidTransaction::Custom( CustomTransactionError::SlippageTooHigh.into() )) ); @@ -2393,17 +2474,17 @@ fn test_stake_low_liquidity_validate() { amount_staked, }); - let info: crate::DispatchInfo = - crate::DispatchInfoOf::<::RuntimeCall>::default(); + let info: DispatchInfo = + DispatchInfoOf::<::RuntimeCall>::default(); - let extension = crate::SubtensorSignedExtension::::new(); + let extension = SubtensorSignedExtension::::new(); // Submit to the signed extension validate function let result_no_stake = extension.validate(&coldkey, &call.clone(), &info, 10); // Should fail due to insufficient stake assert_err!( result_no_stake, - crate::TransactionValidityError::Invalid(crate::InvalidTransaction::Custom( + TransactionValidityError::Invalid(InvalidTransaction::Custom( CustomTransactionError::InsufficientLiquidity.into() )) ); @@ -2448,17 +2529,17 @@ fn test_unstake_low_liquidity_validate() { amount_unstaked: alpha, }); - let info: crate::DispatchInfo = - crate::DispatchInfoOf::<::RuntimeCall>::default(); + let info: DispatchInfo = + DispatchInfoOf::<::RuntimeCall>::default(); - let extension = crate::SubtensorSignedExtension::::new(); + let extension = SubtensorSignedExtension::::new(); // Submit to the signed extension validate function let result_no_stake = extension.validate(&coldkey, &call.clone(), &info, 10); // Should fail due to insufficient stake assert_err!( result_no_stake, - crate::TransactionValidityError::Invalid(crate::InvalidTransaction::Custom( + TransactionValidityError::Invalid(InvalidTransaction::Custom( CustomTransactionError::InsufficientLiquidity.into() )) ); @@ -3669,102 +3750,138 @@ fn test_add_stake_specific_stake_into_subnet_fail() { ); // Add stake as new hotkey - assert_noop!( - SubtensorModule::add_stake( - RuntimeOrigin::signed(coldkey_account_id), - hotkey_account_id, - netuid, - tao_staked, + let expected_alpha = + SubtensorModule::sim_swap_tao_for_alpha(netuid, tao_staked).unwrap_or(0); + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(coldkey_account_id), + hotkey_account_id, + netuid, + tao_staked, + )); + + // Check we have non-zero staked + assert!(expected_alpha > 0); + assert_abs_diff_eq!( + SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey_account_id, + &coldkey_account_id, + netuid ), - Error::::InsufficientLiquidity + expected_alpha, + epsilon = expected_alpha / 1000 ); }); } +// cargo test --package pallet-subtensor --lib -- tests::staking::test_remove_99_999_per_cent_stake_removes_all --exact --show-output #[test] -// RUST_LOG=info cargo test --package pallet-subtensor --lib -- tests::staking::test_move_stake_specific_stake_into_subnet_fail --exact --show-output -fn test_move_stake_specific_stake_into_subnet_fail() { +fn test_remove_99_9991_per_cent_stake_removes_all() { new_test_ext(1).execute_with(|| { - let sn_owner_coldkey = U256::from(55453); - - let hotkey_account_id = U256::from(533453); - let coldkey_account_id = U256::from(55454); - let hotkey_owner_account_id = U256::from(533454); - - let existing_shares: U64F64 = - U64F64::from_num(161_986_254).saturating_div(U64F64::from_num(u64::MAX)); - let existing_stake = 36_711_495_953; - - let tao_in = 2_409_892_148_947; - let alpha_in = 15_358_708_513_716; - - let tao_staked = 200_000_000; + let subnet_owner_coldkey = U256::from(1); + let subnet_owner_hotkey = U256::from(2); + let hotkey_account_id = U256::from(581337); + let coldkey_account_id = U256::from(81337); + let amount = 10_000_000_000; + let netuid: u16 = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); + let fee = DefaultStakingFee::::get(); + register_ok_neuron(netuid, hotkey_account_id, coldkey_account_id, 192213123); - //add network - let netuid: u16 = add_dynamic_network(&sn_owner_coldkey, &sn_owner_coldkey); + // Give it some $$$ in his coldkey balance + SubtensorModule::add_balance_to_coldkey_account(&coldkey_account_id, amount); - let origin_netuid: u16 = add_dynamic_network(&sn_owner_coldkey, &sn_owner_coldkey); + // Stake to hotkey account, and check if the result is ok + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(coldkey_account_id), + hotkey_account_id, + netuid, + amount + )); - // Register hotkey on netuid - register_ok_neuron(netuid, hotkey_account_id, hotkey_owner_account_id, 0); - // Register hotkey on origin netuid - register_ok_neuron(origin_netuid, hotkey_account_id, hotkey_owner_account_id, 0); + // Remove 99.9991% stake + let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey_account_id, + &coldkey_account_id, + netuid, + ); + assert_ok!(SubtensorModule::remove_stake( + RuntimeOrigin::signed(coldkey_account_id), + hotkey_account_id, + netuid, + (U64F64::from_num(alpha) * U64F64::from_num(0.999991)).to_num::() + )); - // Check we have zero staked + // Check that all alpha was unstaked and all TAO balance was returned (less fees) + assert_abs_diff_eq!( + SubtensorModule::get_coldkey_balance(&coldkey_account_id), + amount - fee * 2, + epsilon = 10000, + ); assert_eq!( SubtensorModule::get_total_stake_for_hotkey(&hotkey_account_id), 0 ); - - // Set a hotkey pool for the hotkey on destination subnet - let mut hotkey_pool = SubtensorModule::get_alpha_share_pool(hotkey_account_id, netuid); - hotkey_pool.update_value_for_one(&hotkey_owner_account_id, 1234); // Doesn't matter, will be overridden - - // Adjust the total hotkey stake and shares to match the existing values - TotalHotkeyShares::::insert(hotkey_account_id, netuid, existing_shares); - TotalHotkeyAlpha::::insert(hotkey_account_id, netuid, existing_stake); - - // Make the hotkey a delegate - Delegates::::insert(hotkey_account_id, 0); - - // Setup Subnet pool - SubnetAlphaIn::::insert(netuid, alpha_in); - SubnetTAO::::insert(netuid, tao_in); - - // Give TAO balance to coldkey - SubtensorModule::add_balance_to_coldkey_account( + let new_alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey_account_id, &coldkey_account_id, - tao_staked + 1_000_000_000, + netuid, ); + assert_eq!(new_alpha, 0); + }); +} + +// cargo test --package pallet-subtensor --lib -- tests::staking::test_remove_99_9989_per_cent_stake_leaves_a_little --exact --show-output +#[test] +fn test_remove_99_9989_per_cent_stake_leaves_a_little() { + new_test_ext(1).execute_with(|| { + let subnet_owner_coldkey = U256::from(1); + let subnet_owner_hotkey = U256::from(2); + let hotkey_account_id = U256::from(581337); + let coldkey_account_id = U256::from(81337); + let amount = 10_000_000_000; + let netuid: u16 = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); + let fee = DefaultStakingFee::::get(); + register_ok_neuron(netuid, hotkey_account_id, coldkey_account_id, 192213123); - // Setup Subnet pool for origin netuid - SubnetAlphaIn::::insert(origin_netuid, alpha_in + 10_000_000); - SubnetTAO::::insert(origin_netuid, tao_in + 10_000_000); + // Give it some $$$ in his coldkey balance + SubtensorModule::add_balance_to_coldkey_account(&coldkey_account_id, amount); - // Add stake as new hotkey + // Stake to hotkey account, and check if the result is ok assert_ok!(SubtensorModule::add_stake( RuntimeOrigin::signed(coldkey_account_id), hotkey_account_id, - origin_netuid, - tao_staked, - ),); - let alpha_to_move = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( + netuid, + amount + )); + + // Remove 99.9989% stake + let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( &hotkey_account_id, &coldkey_account_id, - origin_netuid, + netuid, ); + assert_ok!(SubtensorModule::remove_stake( + RuntimeOrigin::signed(coldkey_account_id), + hotkey_account_id, + netuid, + (U64F64::from_num(alpha) * U64F64::from_num(0.99)).to_num::() + )); - // Move stake to destination subnet - assert_noop!( - SubtensorModule::move_stake( - RuntimeOrigin::signed(coldkey_account_id), - hotkey_account_id, - hotkey_account_id, - origin_netuid, - netuid, - alpha_to_move, - ), - Error::::InsufficientLiquidity + // Check that all alpha was unstaked and 99% TAO balance was returned (less fees) + assert_abs_diff_eq!( + SubtensorModule::get_coldkey_balance(&coldkey_account_id), + (amount as f64 * 0.99) as u64 - fee * 2, + epsilon = amount / 1000, + ); + assert_abs_diff_eq!( + SubtensorModule::get_total_stake_for_hotkey(&hotkey_account_id), + (amount as f64 * 0.01) as u64, + epsilon = amount / 1000, + ); + let new_alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey_account_id, + &coldkey_account_id, + netuid, ); + assert_abs_diff_eq!(new_alpha, (alpha as f64 * 0.01) as u64, epsilon = 10); }); } diff --git a/pallets/subtensor/src/tests/staking2.rs b/pallets/subtensor/src/tests/staking2.rs index 2abff8faf..d4c114543 100644 --- a/pallets/subtensor/src/tests/staking2.rs +++ b/pallets/subtensor/src/tests/staking2.rs @@ -1,5 +1,10 @@ use super::mock::*; use crate::*; +use frame_support::{ + assert_ok, + dispatch::{GetDispatchInfo, Pays}, + weights::Weight, +}; use sp_core::U256; use substrate_fixed::types::I96F32; @@ -424,23 +429,30 @@ fn test_share_based_staking_denominator_precision() { let stake1 = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( &hotkey1, &coldkey1, netuid, ); - assert_eq!(stake1, stake_amount - unstake_amount); + let expected_remaining_stake = + if (stake_amount as f64 - unstake_amount as f64) / (stake_amount as f64) <= 0.00001 + { + 0 + } else { + stake_amount - unstake_amount + }; + assert_eq!(stake1, expected_remaining_stake); }); }); } -// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::staking2::test_share_based_staking_denominator_precision_2 --exact --show-output --nocapture +// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::staking2::test_share_based_staking_stake_unstake_inject --exact --show-output --nocapture #[test] fn test_share_based_staking_stake_unstake_inject() { // Test case amounts: stake, unstake, inject, tolerance [ (1_000, 999, 1_000_000, 0), - (1_000_000, 999_999, 100_000_000, 0), + (1_000_000, 999_000, 100_000_000, 0), (1_000_000, 900_000, 100_000_000, 0), (100_000_000_000, 1_000_000_000, 1_000_000_000_000, 1), (100_000_000_000, 99_000_000_000, 1_000_000_000_000, 1), - (100_000_000_000, 99_999_999_500, 1_000_000_000_000, 1), - (100_000_000_000, 99_999_999_500, 1_234_567_890, 1), + (100_000_000_000, 99_990_000_000, 1_000_000_000_000, 1), + (100_000_000_000, 99_990_000_000, 1_234_567_890, 1), ] .iter() .for_each(|test_case| { @@ -550,3 +562,64 @@ fn test_share_based_staking_stake_inject_stake_new() { }); }); } + +// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::staking2::test_try_associate_hotkey --exact --show-output --nocapture +#[test] +fn test_try_associate_hotkey() { + new_test_ext(1).execute_with(|| { + let hotkey1 = U256::from(1); + let coldkey1 = U256::from(2); + let coldkey2 = U256::from(3); + + // Check initial association + assert!(!SubtensorModule::hotkey_account_exists(&hotkey1)); + + // Associate hotkey1 with coldkey1 + assert_ok!(SubtensorModule::try_associate_hotkey( + RuntimeOrigin::signed(coldkey1), + hotkey1 + )); + + // Check that hotkey1 is associated with coldkey1 + assert!(SubtensorModule::hotkey_account_exists(&hotkey1)); + assert_eq!( + SubtensorModule::get_owning_coldkey_for_hotkey(&hotkey1), + coldkey1 + ); + assert_ne!(SubtensorModule::get_owned_hotkeys(&coldkey1).len(), 0); + assert!(SubtensorModule::get_owned_hotkeys(&coldkey1).contains(&hotkey1)); + + // Verify this tx requires a fee + let call = + RuntimeCall::SubtensorModule(crate::Call::try_associate_hotkey { hotkey: hotkey1 }); + let dispatch_info = call.get_dispatch_info(); + // Verify tx weight > 0 + assert!(dispatch_info.weight.all_gte(Weight::from_all(0))); + // Verify pays Yes is set + assert_eq!(dispatch_info.pays_fee, Pays::Yes); + + // Check that coldkey2 is not associated with any hotkey + assert!(!SubtensorModule::get_owned_hotkeys(&coldkey2).contains(&hotkey1)); + assert_eq!(SubtensorModule::get_owned_hotkeys(&coldkey2).len(), 0); + + // Try to associate hotkey1 with coldkey2 + // Should have no effect because coldkey1 is already associated with hotkey1 + assert_ok!(SubtensorModule::try_associate_hotkey( + RuntimeOrigin::signed(coldkey2), + hotkey1 + )); + + // Check that hotkey1 is still associated with coldkey1 + assert!(SubtensorModule::hotkey_account_exists(&hotkey1)); + assert_eq!( + SubtensorModule::get_owning_coldkey_for_hotkey(&hotkey1), + coldkey1 + ); + assert_ne!(SubtensorModule::get_owned_hotkeys(&coldkey1).len(), 0); + assert!(SubtensorModule::get_owned_hotkeys(&coldkey1).contains(&hotkey1)); + + // Check that coldkey2 is still not associated with any hotkey + assert!(!SubtensorModule::get_owned_hotkeys(&coldkey2).contains(&hotkey1)); + assert_eq!(SubtensorModule::get_owned_hotkeys(&coldkey2).len(), 0); + }); +} diff --git a/pallets/subtensor/src/tests/swap_coldkey.rs b/pallets/subtensor/src/tests/swap_coldkey.rs index d7f712334..8f7b024e4 100644 --- a/pallets/subtensor/src/tests/swap_coldkey.rs +++ b/pallets/subtensor/src/tests/swap_coldkey.rs @@ -9,9 +9,9 @@ use crate::*; use crate::{Call, ColdkeySwapScheduleDuration, Error}; use approx::assert_abs_diff_eq; use frame_support::error::BadOrigin; -use frame_support::traits::schedule::v3::Named as ScheduleNamed; -use frame_support::traits::schedule::DispatchTime; use frame_support::traits::OnInitialize; +use frame_support::traits::schedule::DispatchTime; +use frame_support::traits::schedule::v3::Named as ScheduleNamed; use sp_core::{Get, H256, U256}; use sp_runtime::DispatchError; @@ -68,29 +68,6 @@ fn test_swap_subnet_owner() { }); } -// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_coldkey -- test_swap_stake --exact --nocapture -#[test] -fn test_swap_stake() { - new_test_ext(1).execute_with(|| { - let old_coldkey = U256::from(1); - let new_coldkey = U256::from(2); - let hotkey = U256::from(3); - let stake = 100; - - StakingHotkeys::::insert(old_coldkey, vec![hotkey]); - Stake::::insert(hotkey, old_coldkey, stake); - let mut weight = Weight::zero(); - assert_ok!(SubtensorModule::perform_swap_coldkey( - &old_coldkey, - &new_coldkey, - &mut weight - )); - - assert!(!Stake::::contains_key(hotkey, old_coldkey)); - assert_eq!(Stake::::get(hotkey, new_coldkey), stake); - }); -} - // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::swap_coldkey::test_swap_total_coldkey_stake --exact --show-output #[test] fn test_swap_total_coldkey_stake() { @@ -316,7 +293,7 @@ fn test_swap_idempotency() { // Add a network add_network(netuid, 1, 0); SubtensorModule::add_balance_to_coldkey_account(&old_coldkey, stake); // Give old coldkey some balance - // Stake to a hotkey + // Stake to a hotkey register_ok_neuron(netuid, hotkey, old_coldkey, 1001000); assert_ok!(SubtensorModule::add_stake( <::RuntimeOrigin>::signed(old_coldkey), @@ -494,16 +471,36 @@ fn test_swap_with_max_hotkeys() { #[test] fn test_swap_effect_on_delegated_stake() { new_test_ext(1).execute_with(|| { + let subnet_owner_coldkey = U256::from(1001); + let subnet_owner_hotkey = U256::from(1002); + let netuid = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); + let old_coldkey = U256::from(1); let new_coldkey = U256::from(2); let delegator = U256::from(3); let hotkey = U256::from(4); - let stake = 10_000; + let stake = 100_000_000_000; StakingHotkeys::::insert(old_coldkey, vec![hotkey]); StakingHotkeys::::insert(delegator, vec![hotkey]); - Stake::::insert(hotkey, old_coldkey, stake); - Stake::::insert(hotkey, delegator, stake); + SubtensorModule::create_account_if_non_existent(&old_coldkey, &hotkey); + SubtensorModule::add_balance_to_coldkey_account(&old_coldkey, stake); + SubtensorModule::add_balance_to_coldkey_account(&delegator, stake); + + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(old_coldkey), + hotkey, + netuid, + stake + )); + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(delegator), + hotkey, + netuid, + stake + )); + let coldkey_stake_before = SubtensorModule::get_total_stake_for_coldkey(&old_coldkey); + let delegator_stake_before = SubtensorModule::get_total_stake_for_coldkey(&delegator); let mut weight = Weight::zero(); assert_ok!(SubtensorModule::perform_swap_coldkey( @@ -512,9 +509,21 @@ fn test_swap_effect_on_delegated_stake() { &mut weight )); - assert_eq!(Stake::::get(hotkey, new_coldkey), stake); - assert_eq!(Stake::::get(hotkey, delegator), stake); - assert_eq!(Stake::::get(hotkey, old_coldkey), 0); + assert_abs_diff_eq!( + SubtensorModule::get_total_stake_for_coldkey(&new_coldkey), + coldkey_stake_before, + epsilon = 500 + ); + assert_abs_diff_eq!( + SubtensorModule::get_total_stake_for_coldkey(&delegator), + delegator_stake_before, + epsilon = 500 + ); + assert_abs_diff_eq!( + SubtensorModule::get_total_stake_for_coldkey(&old_coldkey), + 0, + epsilon = 500 + ); }); } diff --git a/pallets/subtensor/src/tests/swap_hotkey.rs b/pallets/subtensor/src/tests/swap_hotkey.rs index 4e0225870..dab167507 100644 --- a/pallets/subtensor/src/tests/swap_hotkey.rs +++ b/pallets/subtensor/src/tests/swap_hotkey.rs @@ -419,30 +419,6 @@ fn test_swap_loaded_emission() { }); } -// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_stake --exact --nocapture -#[test] -fn test_swap_stake() { - new_test_ext(1).execute_with(|| { - let old_hotkey = U256::from(1); - let new_hotkey = U256::from(2); - let coldkey = U256::from(3); - let stake_amount = 100u64; - let mut weight = Weight::zero(); - - Stake::::insert(old_hotkey, coldkey, stake_amount); - - assert_ok!(SubtensorModule::perform_hotkey_swap( - &old_hotkey, - &new_hotkey, - &coldkey, - &mut weight - )); - - assert!(!Stake::::contains_key(old_hotkey, coldkey)); - assert_eq!(Stake::::get(new_hotkey, coldkey), stake_amount); - }); -} - // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_staking_hotkeys --exact --nocapture #[test] fn test_swap_staking_hotkeys() { @@ -453,7 +429,6 @@ fn test_swap_staking_hotkeys() { let mut weight = Weight::zero(); let netuid = 1; - Stake::::insert(old_hotkey, coldkey, 100); StakingHotkeys::::insert(coldkey, vec![old_hotkey]); Alpha::::insert((old_hotkey, coldkey, netuid), U64F64::from_num(100)); @@ -470,24 +445,47 @@ fn test_swap_staking_hotkeys() { }); } -// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_hotkey_with_multiple_coldkeys --exact --nocapture +// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::swap_hotkey::test_swap_hotkey_with_multiple_coldkeys --exact --show-output --nocapture #[test] fn test_swap_hotkey_with_multiple_coldkeys() { new_test_ext(1).execute_with(|| { + let subnet_owner_coldkey = U256::from(1001); + let subnet_owner_hotkey = U256::from(1002); + let netuid = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); + let old_hotkey = U256::from(1); let new_hotkey = U256::from(2); let coldkey1 = U256::from(3); let coldkey2 = U256::from(4); let mut weight = Weight::zero(); - let netuid = 1; + let stake = 1_000_000_000; - Stake::::insert(old_hotkey, coldkey1, 100); - Stake::::insert(old_hotkey, coldkey2, 200); StakingHotkeys::::insert(coldkey1, vec![old_hotkey]); StakingHotkeys::::insert(coldkey2, vec![old_hotkey]); + SubtensorModule::create_account_if_non_existent(&coldkey1, &old_hotkey); + SubtensorModule::add_balance_to_coldkey_account( + &coldkey1, + stake + ExistentialDeposit::get(), + ); + SubtensorModule::add_balance_to_coldkey_account( + &coldkey2, + stake + ExistentialDeposit::get(), + ); - Alpha::::insert((old_hotkey, coldkey1, netuid), U64F64::from_num(100)); - Alpha::::insert((old_hotkey, coldkey2, netuid), U64F64::from_num(200)); + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(coldkey1), + old_hotkey, + netuid, + stake + )); + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(coldkey2), + old_hotkey, + netuid, + stake / 2 + )); + let stake1_before = SubtensorModule::get_total_stake_for_coldkey(&coldkey1); + let stake2_before = SubtensorModule::get_total_stake_for_coldkey(&coldkey2); assert_ok!(SubtensorModule::perform_hotkey_swap( &old_hotkey, @@ -496,36 +494,19 @@ fn test_swap_hotkey_with_multiple_coldkeys() { &mut weight )); - assert_eq!(Stake::::get(new_hotkey, coldkey1), 100); - assert_eq!(Stake::::get(new_hotkey, coldkey2), 200); + assert_eq!( + SubtensorModule::get_total_stake_for_coldkey(&coldkey1), + stake1_before + ); + assert_eq!( + SubtensorModule::get_total_stake_for_coldkey(&coldkey2), + stake2_before + ); assert!(StakingHotkeys::::get(coldkey1).contains(&new_hotkey)); assert!(StakingHotkeys::::get(coldkey2).contains(&new_hotkey)); }); } -// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_hotkey_with_existing_stake --exact --nocapture -#[test] -fn test_swap_hotkey_with_existing_stake() { - new_test_ext(1).execute_with(|| { - let old_hotkey = U256::from(1); - let new_hotkey = U256::from(2); - let coldkey = U256::from(3); - let mut weight = Weight::zero(); - - Stake::::insert(old_hotkey, coldkey, 100); - Stake::::insert(new_hotkey, coldkey, 50); - - assert_ok!(SubtensorModule::perform_hotkey_swap( - &old_hotkey, - &new_hotkey, - &coldkey, - &mut weight - )); - - assert_eq!(Stake::::get(new_hotkey, coldkey), 150); - }); -} - // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey -- test_swap_hotkey_with_multiple_subnets --exact --nocapture #[test] fn test_swap_hotkey_with_multiple_subnets() { @@ -560,22 +541,43 @@ fn test_swap_hotkey_with_multiple_subnets() { #[test] fn test_swap_staking_hotkeys_multiple_coldkeys() { new_test_ext(1).execute_with(|| { + let subnet_owner_coldkey = U256::from(1001); + let subnet_owner_hotkey = U256::from(1002); + let netuid = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); + let old_hotkey = U256::from(1); let new_hotkey = U256::from(2); let coldkey1 = U256::from(3); let coldkey2 = U256::from(4); + let staker5 = U256::from(5); let mut weight = Weight::zero(); - let netuid = 1; + let stake = 1_000_000_000; // Set up initial state - Stake::::insert(old_hotkey, coldkey1, 100); - Stake::::insert(old_hotkey, coldkey2, 200); - - Alpha::::insert((old_hotkey, coldkey1, netuid), U64F64::from_num(100)); - Alpha::::insert((old_hotkey, coldkey2, netuid), U64F64::from_num(200)); - StakingHotkeys::::insert(coldkey1, vec![old_hotkey]); - StakingHotkeys::::insert(coldkey2, vec![old_hotkey, U256::from(5)]); + StakingHotkeys::::insert(coldkey2, vec![old_hotkey, staker5]); + + SubtensorModule::create_account_if_non_existent(&coldkey1, &old_hotkey); + SubtensorModule::add_balance_to_coldkey_account( + &coldkey1, + stake + ExistentialDeposit::get(), + ); + SubtensorModule::add_balance_to_coldkey_account( + &coldkey2, + stake + ExistentialDeposit::get(), + ); + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(coldkey1), + old_hotkey, + netuid, + stake + )); + assert_ok!(SubtensorModule::add_stake( + RuntimeOrigin::signed(coldkey2), + old_hotkey, + netuid, + stake + )); assert_ok!(SubtensorModule::perform_hotkey_swap( &old_hotkey, @@ -591,7 +593,7 @@ fn test_swap_staking_hotkeys_multiple_coldkeys() { // Check if new_hotkey replaced old_hotkey for coldkey2 as well assert!(StakingHotkeys::::get(coldkey2).contains(&new_hotkey)); assert!(!StakingHotkeys::::get(coldkey2).contains(&old_hotkey)); - assert!(StakingHotkeys::::get(coldkey2).contains(&U256::from(5))); + assert!(StakingHotkeys::::get(coldkey2).contains(&staker5)); // Other hotkeys should remain }); } @@ -600,6 +602,10 @@ fn test_swap_staking_hotkeys_multiple_coldkeys() { #[test] fn test_swap_hotkey_with_no_stake() { new_test_ext(1).execute_with(|| { + let subnet_owner_coldkey = U256::from(1001); + let subnet_owner_hotkey = U256::from(1002); + let netuid = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); + let old_hotkey = U256::from(1); let new_hotkey = U256::from(2); let coldkey = U256::from(3); @@ -620,8 +626,8 @@ fn test_swap_hotkey_with_no_stake() { assert_eq!(Owner::::get(new_hotkey), coldkey); // Ensure no unexpected changes in Stake - assert!(!Stake::::contains_key(old_hotkey, coldkey)); - assert!(!Stake::::contains_key(new_hotkey, coldkey)); + assert!(!Alpha::::contains_key((old_hotkey, coldkey, netuid))); + assert!(!Alpha::::contains_key((new_hotkey, coldkey, netuid))); }); } @@ -940,7 +946,6 @@ fn test_swap_stake_success() { let mut weight = Weight::zero(); // Initialize staking variables for old_hotkey - Stake::::insert(old_hotkey, coldkey, 0); TotalHotkeyAlpha::::insert(old_hotkey, netuid, amount); TotalHotkeyShares::::insert(old_hotkey, netuid, U64F64::from_num(shares)); Alpha::::insert((old_hotkey, coldkey, netuid), U64F64::from_num(amount)); @@ -977,21 +982,22 @@ fn test_swap_stake_old_hotkey_not_exist() { let old_hotkey = U256::from(1); let new_hotkey = U256::from(2); let coldkey = U256::from(3); - let stake_amount = 1000u64; + let alpha_share = U64F64::from_num(1234); let mut weight = Weight::zero(); + let netuid = 1; // Initialize Stake for old_hotkey - Stake::::insert(old_hotkey, coldkey, stake_amount); + Alpha::::insert((old_hotkey, coldkey, netuid), alpha_share); // Ensure old_hotkey has a stake - assert!(Stake::::contains_key(old_hotkey, coldkey)); + assert!(Alpha::::contains_key((old_hotkey, coldkey, netuid))); // Perform the swap SubtensorModule::perform_hotkey_swap(&old_hotkey, &new_hotkey, &coldkey, &mut weight); // Verify that new_hotkey has the stake and old_hotkey does not - assert!(Stake::::contains_key(new_hotkey, coldkey)); - assert!(!Stake::::contains_key(old_hotkey, coldkey)); + assert!(Alpha::::contains_key((new_hotkey, coldkey, netuid))); + assert!(!Alpha::::contains_key((old_hotkey, coldkey, netuid))); }); } diff --git a/pallets/subtensor/src/tests/uids.rs b/pallets/subtensor/src/tests/uids.rs index 87f645968..178613fbb 100644 --- a/pallets/subtensor/src/tests/uids.rs +++ b/pallets/subtensor/src/tests/uids.rs @@ -73,18 +73,20 @@ fn test_replace_neuron() { let ip: u128 = 1676056785; let port: u16 = 9999; let ip_type: u8 = 4; - assert!(SubtensorModule::serve_axon( - <::RuntimeOrigin>::signed(hotkey_account_id), - netuid, - 0, - ip, - port, - ip_type, - 0, - 0, - 0 - ) - .is_ok()); + assert!( + SubtensorModule::serve_axon( + <::RuntimeOrigin>::signed(hotkey_account_id), + netuid, + 0, + ip, + port, + ip_type, + 0, + 0, + 0 + ) + .is_ok() + ); // Set a neuron certificate for it NeuronCertificates::::insert(netuid, hotkey_account_id, certificate); diff --git a/pallets/subtensor/src/tests/weights.rs b/pallets/subtensor/src/tests/weights.rs index 57d51598c..5fcbbcb69 100644 --- a/pallets/subtensor/src/tests/weights.rs +++ b/pallets/subtensor/src/tests/weights.rs @@ -8,13 +8,13 @@ use frame_support::{ assert_err, assert_ok, dispatch::{DispatchClass, DispatchResult, GetDispatchInfo, Pays}, }; -use rand_chacha::{rand_core::SeedableRng, ChaCha20Rng}; +use rand_chacha::{ChaCha20Rng, rand_core::SeedableRng}; use scale_info::prelude::collections::HashMap; use sha2::Digest; use sp_core::{Get, H256, U256}; use sp_runtime::{ - traits::{BlakeTwo256, ConstU32, Hash, SignedExtension}, BoundedVec, DispatchError, + traits::{BlakeTwo256, ConstU32, Hash, SignedExtension}, }; use sp_std::collections::vec_deque::VecDeque; use substrate_fixed::types::I32F32; @@ -756,7 +756,7 @@ fn test_weights_err_has_duplicate_ids() { SubtensorModule::set_max_allowed_uids(netuid, 100); // Allow many registrations per block. SubtensorModule::set_max_registrations_per_block(netuid, 100); // Allow many registrations per block. SubtensorModule::set_target_registrations_per_interval(netuid, 100); // Allow many registrations per block. - // uid 0 + // uid 0 register_ok_neuron(netuid, hotkey_account_id, U256::from(77), 0); let neuron_uid: u16 = SubtensorModule::get_uid_for_net_and_hotkey(netuid, &hotkey_account_id) diff --git a/pallets/subtensor/src/utils/misc.rs b/pallets/subtensor/src/utils/misc.rs index b27921f27..bd093a76b 100644 --- a/pallets/subtensor/src/utils/misc.rs +++ b/pallets/subtensor/src/utils/misc.rs @@ -1,7 +1,7 @@ use super::*; use crate::{ - system::{ensure_root, ensure_signed_or_root, pallet_prelude::BlockNumberFor}, Error, + system::{ensure_root, ensure_signed_or_root, pallet_prelude::BlockNumberFor}, }; use safe_math::*; use sp_core::Get; diff --git a/primitives/safe-math/Cargo.toml b/primitives/safe-math/Cargo.toml index f67d53c5d..e41c7878b 100644 --- a/primitives/safe-math/Cargo.toml +++ b/primitives/safe-math/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "safe-math" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] substrate-fixed = { workspace = true } diff --git a/primitives/safe-math/src/lib.rs b/primitives/safe-math/src/lib.rs index e73aeb003..d17c6b570 100644 --- a/primitives/safe-math/src/lib.rs +++ b/primitives/safe-math/src/lib.rs @@ -5,7 +5,7 @@ use substrate_fixed::{ traits::Fixed, - types::{I110F18, I32F32, I64F64, I96F32, U110F18, U64F64, U96F32}, + types::{I32F32, I64F64, I96F32, I110F18, U64F64, U96F32, U110F18}, }; /// Safe division trait @@ -104,11 +104,7 @@ mod tests { // Helper function for absolute difference fn abs_diff(a: U110F18, b: U110F18) -> U110F18 { - if a > b { - a - b - } else { - b - a - } + if a > b { a - b } else { b - a } } #[test] diff --git a/primitives/share-pool/Cargo.toml b/primitives/share-pool/Cargo.toml index e0696ee30..79b7a232a 100644 --- a/primitives/share-pool/Cargo.toml +++ b/primitives/share-pool/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "share-pool" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] substrate-fixed = { workspace = true } diff --git a/primitives/share-pool/src/lib.rs b/primitives/share-pool/src/lib.rs index 8f963cfd3..d43f36259 100644 --- a/primitives/share-pool/src/lib.rs +++ b/primitives/share-pool/src/lib.rs @@ -1,6 +1,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::result_unit_err)] +use safe_math::*; use sp_std::marker; use sp_std::ops::Neg; use substrate_fixed::types::{I64F64, U64F64}; @@ -50,11 +51,32 @@ where let current_share: U64F64 = self.state_ops.get_share(key); let denominator: U64F64 = self.state_ops.get_denominator(); - shared_value - .checked_div(denominator) - .unwrap_or(U64F64::saturating_from_num(0)) - .saturating_mul(current_share) - .saturating_to_num::() + let maybe_value_per_share = shared_value.checked_div(denominator); + (if let Some(value_per_share) = maybe_value_per_share { + value_per_share.saturating_mul(current_share) + } else { + shared_value + .saturating_mul(current_share) + .checked_div(denominator) + .unwrap_or(U64F64::saturating_from_num(0)) + }) + .saturating_to_num::() + } + + pub fn get_value_from_shares(&self, current_share: U64F64) -> u64 { + let shared_value: U64F64 = self.state_ops.get_shared_value(); + let denominator: U64F64 = self.state_ops.get_denominator(); + + let maybe_value_per_share = shared_value.checked_div(denominator); + (if let Some(value_per_share) = maybe_value_per_share { + value_per_share.saturating_mul(current_share) + } else { + shared_value + .saturating_mul(current_share) + .checked_div(denominator) + .unwrap_or(U64F64::saturating_from_num(0)) + }) + .saturating_to_num::() } pub fn try_get_value(&self, key: &K) -> Result { @@ -84,46 +106,51 @@ where true } else { // There are already keys in the pool, set or update this key - let value_per_share: I64F64 = I64F64::saturating_from_num( - shared_value - .checked_div(denominator) // denominator is never 0 here - .unwrap_or(U64F64::saturating_from_num(0)), - ); - - let shares_per_update: I64F64 = I64F64::saturating_from_num(update) - .checked_div(value_per_share) - .unwrap_or(I64F64::saturating_from_num(0)); + let shares_per_update: I64F64 = + self.get_shares_per_update(update, &shared_value, &denominator); shares_per_update != 0 } } + fn get_shares_per_update( + &self, + update: i64, + shared_value: &U64F64, + denominator: &U64F64, + ) -> I64F64 { + let maybe_value_per_share = shared_value.checked_div(*denominator); + if let Some(value_per_share) = maybe_value_per_share { + I64F64::saturating_from_num(update) + .checked_div(I64F64::saturating_from_num(value_per_share)) + .unwrap_or(I64F64::saturating_from_num(0)) + } else { + I64F64::saturating_from_num(update) + .checked_div(I64F64::saturating_from_num(*shared_value)) + .unwrap_or(I64F64::saturating_from_num(0)) + .saturating_mul(I64F64::saturating_from_num(*denominator)) + } + } + /// Update the value associated with an item identified by the Key - pub fn update_value_for_one(&mut self, key: &K, update: i64) { + /// Returns actual update + /// + pub fn update_value_for_one(&mut self, key: &K, update: i64) -> i64 { let shared_value: U64F64 = self.state_ops.get_shared_value(); let current_share: U64F64 = self.state_ops.get_share(key); let denominator: U64F64 = self.state_ops.get_denominator(); - - // First, update shared value - self.update_value_for_all(update); - let new_shared_value: U64F64 = self.state_ops.get_shared_value(); + let initial_value: i64 = self.get_value(key) as i64; + let mut actual_update: i64 = update; // Then, update this key's share if denominator == 0 { // Initialize the pool. The first key gets all. - self.state_ops.set_denominator(new_shared_value); - self.state_ops.set_share(key, new_shared_value); + let update_fixed: U64F64 = U64F64::saturating_from_num(update); + self.state_ops.set_denominator(update_fixed); + self.state_ops.set_share(key, update_fixed); } else { - // There are already keys in the pool, set or update this key - let value_per_share: I64F64 = I64F64::saturating_from_num( - shared_value - .checked_div(denominator) // denominator is never 0 here - .unwrap_or(U64F64::saturating_from_num(0)), - ); - - let shares_per_update: I64F64 = I64F64::saturating_from_num(update) - .checked_div(value_per_share) - .unwrap_or(I64F64::saturating_from_num(0)); + let shares_per_update: I64F64 = + self.get_shares_per_update(update, &shared_value, &denominator); if shares_per_update >= 0 { self.state_ops.set_denominator( @@ -134,17 +161,36 @@ where current_share.saturating_add(U64F64::saturating_from_num(shares_per_update)), ); } else { - self.state_ops.set_denominator( - denominator - .saturating_sub(U64F64::saturating_from_num(shares_per_update.neg())), - ); - self.state_ops.set_share( - key, - current_share - .saturating_sub(U64F64::saturating_from_num(shares_per_update.neg())), - ); + // Check if this entry is about to break precision + let mut new_denominator = denominator + .saturating_sub(U64F64::saturating_from_num(shares_per_update.neg())); + let mut new_share = current_share + .saturating_sub(U64F64::saturating_from_num(shares_per_update.neg())); + + // The condition here is either the share remainder is too little OR + // the new_denominator is too low compared to what shared_value + year worth of emissions would be + if (new_share.safe_div(current_share) < U64F64::saturating_from_num(0.00001)) + || shared_value + .saturating_add(U64F64::saturating_from_num(2_628_000_000_000_000_u64)) + .checked_div(new_denominator) + .is_none() + { + // yes, precision is low, just remove all + new_share = U64F64::saturating_from_num(0); + new_denominator = denominator.saturating_sub(current_share); + actual_update = initial_value.neg(); + } + + self.state_ops.set_denominator(new_denominator); + self.state_ops.set_share(key, new_share); } } + + // Update shared value + self.update_value_for_all(actual_update); + + // Return actual udate + actual_update } } @@ -279,6 +325,62 @@ mod tests { assert_eq!(value2, 10); } + // cargo test --package share-pool --lib -- tests::test_denom_high_precision --exact --show-output + #[test] + fn test_denom_high_precision() { + let mock_ops = MockSharePoolDataOperations::new(); + let mut pool = SharePool::::new(mock_ops); + + pool.update_value_for_one(&1, 1); + pool.update_value_for_one(&2, 1); + + pool.update_value_for_all(999_999_999_999_998); + + pool.update_value_for_one(&1, -499_999_999_999_990); + pool.update_value_for_one(&2, -499_999_999_999_990); + + pool.update_value_for_all(999_999_999_999_980); + + pool.update_value_for_one(&1, 1_000_000_000_000); + pool.update_value_for_one(&2, 1_000_000_000_000); + + let value1 = pool.get_value(&1) as i128; + let value2 = pool.get_value(&2) as i128; + + // First to stake gets all accumulated emission if there are no other stakers + // (which is artificial situation because there will be no emissions if there is no stake) + assert!((value1 - 1_001_000_000_000_000).abs() < 100); + assert!((value2 - 1_000_000_000_000).abs() < 100); + } + + // cargo test --package share-pool --lib -- tests::test_denom_high_precision_many_small_unstakes --exact --show-output + #[test] + fn test_denom_high_precision_many_small_unstakes() { + let mock_ops = MockSharePoolDataOperations::new(); + let mut pool = SharePool::::new(mock_ops); + + pool.update_value_for_one(&1, 1); + pool.update_value_for_one(&2, 1); + + pool.update_value_for_all(1_000_000_000_000_000); + + for _ in 0..1_000_000 { + pool.update_value_for_one(&1, -500_000_000); + pool.update_value_for_one(&2, -500_000_000); + } + + pool.update_value_for_all(1_000_000_000_000_000); + + pool.update_value_for_one(&1, 1_000_000_000_000); + pool.update_value_for_one(&2, 1_000_000_000_000); + + let value1 = pool.get_value(&1) as i128; + let value2 = pool.get_value(&2) as i128; + + assert!((value1 - 1_001_000_000_000_000).abs() < 10); + assert!((value2 - 1_000_000_000_000).abs() < 10); + } + #[test] fn test_update_value_for_one() { let mock_ops = MockSharePoolDataOperations::new(); @@ -301,4 +403,50 @@ mod tests { U64F64::saturating_from_num(1000) ); } + + // cargo test --package share-pool --lib -- tests::test_get_shares_per_update --exact --show-output + #[test] + fn test_get_shares_per_update() { + [ + (1_i64, 1_u64, 1.0, 1.0), + ( + 1_000, + 21_000_000_000_000_000, + 0.00001, + 0.00000000000000000043, + ), + ( + 21_000_000_000_000_000, + 21_000_000_000_000_000, + 0.00001, + 0.00001, + ), + ( + 210_000_000_000_000_000, + 21_000_000_000_000_000, + 0.00001, + 0.0001, + ), + ( + 1_000, + 1_000, + 21_000_000_000_000_000_f64, + 21_000_000_000_000_000_f64, + ), + ] + .iter() + .for_each(|(update, shared_value, denominator, expected)| { + let mock_ops = MockSharePoolDataOperations::new(); + let pool = SharePool::::new(mock_ops); + + let shared_fixed = U64F64::from_num(*shared_value); + let denominator_fixed = U64F64::from_num(*denominator); + let expected_fixed = I64F64::from_num(*expected); + + let spu: I64F64 = + pool.get_shares_per_update(*update, &shared_fixed, &denominator_fixed); + let precision: I64F64 = I64F64::from_num(1000.); + assert!((spu - expected_fixed).abs() <= expected_fixed / precision,); + }); + } } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 2e6eda522..e28b7ba1b 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -4,7 +4,7 @@ version = "4.0.0-dev" description = "Subtensor network" authors = ["Opentensor Foundation "] homepage = "https://opentensor.ai/" -edition = "2021" +edition = "2024" license = "Unlicense" publish = false repository = "https://github.com/opentensor/subtensor/" @@ -100,6 +100,7 @@ pallet-commitments = { default-features = false, path = "../pallets/commitments" fp-evm = { workspace = true } fp-rpc = { workspace = true } fp-self-contained = { workspace = true } +precompile-utils = { workspace = true } # Frontier FRAME pallet-base-fee = { workspace = true } @@ -163,6 +164,7 @@ std = [ "pallet-scheduler/std", "pallet-preimage/std", "pallet-commitments/std", + "precompile-utils/std", "sp-api/std", "sp-block-builder/std", "sp-consensus-aura/std", diff --git a/runtime/src/check_nonce.rs b/runtime/src/check_nonce.rs index fd2a3a0db..94c06c648 100644 --- a/runtime/src/check_nonce.rs +++ b/runtime/src/check_nonce.rs @@ -3,12 +3,12 @@ use frame_support::dispatch::{DispatchInfo, Pays}; use frame_system::Config; use scale_info::TypeInfo; use sp_runtime::{ + Saturating, traits::{DispatchInfoOf, Dispatchable, One, SignedExtension, Zero}, transaction_validity::{ InvalidTransaction, TransactionLongevity, TransactionValidity, TransactionValidityError, ValidTransaction, }, - Saturating, }; use sp_std::vec; use subtensor_macros::freeze_struct; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 8dcce09b1..a8774795b 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -18,16 +18,16 @@ use frame_support::{ genesis_builder_helper::{build_state, get_preset}, pallet_prelude::Get, traits::{ + Contains, LinearStoragePrice, OnUnbalanced, fungible::{ DecreaseIssuance, HoldConsideration, Imbalance as FungibleImbalance, IncreaseIssuance, }, - Contains, LinearStoragePrice, OnUnbalanced, }, }; use frame_system::{EnsureNever, EnsureRoot, EnsureRootWithSuccess, RawOrigin}; use pallet_commitments::CanCommit; use pallet_grandpa::{ - fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, + AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, fg_primitives, }; use pallet_registry::CanRegisterIdentity; use pallet_subtensor::rpc_info::{ @@ -44,18 +44,18 @@ use smallvec::smallvec; use sp_api::impl_runtime_apis; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{ + H160, H256, OpaqueMetadata, U256, crypto::{ByteArray, KeyTypeId}, - OpaqueMetadata, H160, H256, U256, }; use sp_runtime::generic::Era; use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, + AccountId32, ApplyExtrinsicResult, ConsensusEngineId, MultiSignature, create_runtime_str, + generic, impl_opaque_keys, traits::{ AccountIdLookup, BlakeTwo256, Block as BlockT, DispatchInfoOf, Dispatchable, IdentifyAccount, NumberFor, One, PostDispatchInfoOf, UniqueSaturatedInto, Verify, }, transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, - AccountId32, ApplyExtrinsicResult, ConsensusEngineId, MultiSignature, }; use sp_std::cmp::Ordering; use sp_std::prelude::*; @@ -65,19 +65,18 @@ use sp_version::RuntimeVersion; // A few exports that help ease life for downstream crates. pub use frame_support::{ - construct_runtime, parameter_types, + StorageValue, construct_runtime, parameter_types, traits::{ - ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, FindAuthor, InstanceFilter, + ConstBool, ConstU8, ConstU32, ConstU64, ConstU128, FindAuthor, InstanceFilter, KeyOwnerProofSystem, OnFinalize, OnTimestampSet, PrivilegeCmp, Randomness, StorageInfo, }, weights::{ + IdentityFee, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, + WeightToFeePolynomial, constants::{ BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, }, - IdentityFee, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, - WeightToFeePolynomial, }, - StorageValue, }; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; @@ -229,7 +228,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: 239, + spec_version: 244, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -1024,7 +1023,7 @@ impl pallet_commitments::Config for Runtime { } #[cfg(not(feature = "fast-blocks"))] -pub const INITIAL_SUBNET_TEMPO: u16 = 99; +pub const INITIAL_SUBNET_TEMPO: u16 = 360; #[cfg(feature = "fast-blocks")] pub const INITIAL_SUBNET_TEMPO: u16 = 10; @@ -2062,7 +2061,7 @@ impl_runtime_apis! { SubtensorModule::get_delegate(delegate_account) } - fn get_delegated(delegatee_account: AccountId32) -> Vec<(DelegateInfo, Compact)> { + fn get_delegated(delegatee_account: AccountId32) -> Vec<(DelegateInfo, (Compact, Compact))> { SubtensorModule::get_delegated(delegatee_account) } } diff --git a/runtime/src/precompiles/balance_transfer.rs b/runtime/src/precompiles/balance_transfer.rs index 6154cf8a5..c1b68d4f7 100644 --- a/runtime/src/precompiles/balance_transfer.rs +++ b/runtime/src/precompiles/balance_transfer.rs @@ -1,60 +1,40 @@ -use pallet_evm::{ - BalanceConverter, ExitError, ExitSucceed, PrecompileHandle, PrecompileOutput, PrecompileResult, -}; +use pallet_evm::PrecompileHandle; +use precompile_utils::EvmResult; +use sp_core::H256; use sp_runtime::traits::UniqueSaturatedInto; -use sp_std::vec; -use crate::precompiles::{ - contract_to_origin, get_method_id, get_pubkey, get_slice, try_dispatch_runtime_call, -}; use crate::Runtime; - -pub const BALANCE_TRANSFER_INDEX: u64 = 2048; -// ss58 public key i.e., the contract sends funds it received to the destination address from the -// method parameter. -const CONTRACT_ADDRESS_SS58: [u8; 32] = [ - 0x07, 0xec, 0x71, 0x2a, 0x5d, 0x38, 0x43, 0x4d, 0xdd, 0x03, 0x3f, 0x8f, 0x02, 0x4e, 0xcd, 0xfc, - 0x4b, 0xb5, 0x95, 0x1c, 0x13, 0xc3, 0x08, 0x5c, 0x39, 0x9c, 0x8a, 0x5f, 0x62, 0x93, 0x70, 0x5d, -]; +use crate::precompiles::{PrecompileExt, PrecompileHandleExt, contract_to_origin, parse_pubkey}; pub struct BalanceTransferPrecompile; -impl BalanceTransferPrecompile { - pub fn execute(handle: &mut impl PrecompileHandle) -> PrecompileResult { - let txdata = handle.input(); - - // Match method ID: keccak256("transfer(bytes32)") - let method = get_slice(txdata, 0, 4)?; - if get_method_id("transfer(bytes32)") != method { - return Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: vec![], - }); - } - - // Forward all received value to the destination address - let amount = handle.context().apparent_value; +impl PrecompileExt for BalanceTransferPrecompile { + const INDEX: u64 = 2048; + const ADDRESS_SS58: [u8; 32] = [ + 0x07, 0xec, 0x71, 0x2a, 0x5d, 0x38, 0x43, 0x4d, 0xdd, 0x03, 0x3f, 0x8f, 0x02, 0x4e, 0xcd, + 0xfc, 0x4b, 0xb5, 0x95, 0x1c, 0x13, 0xc3, 0x08, 0x5c, 0x39, 0x9c, 0x8a, 0x5f, 0x62, 0x93, + 0x70, 0x5d, + ]; +} - // Use BalanceConverter to convert EVM amount to Substrate balance - let amount_sub = - ::BalanceConverter::into_substrate_balance(amount) - .ok_or(ExitError::OutOfFund)?; +#[precompile_utils::precompile] +impl BalanceTransferPrecompile { + #[precompile::public("transfer(bytes32)")] + #[precompile::payable] + fn transfer(handle: &mut impl PrecompileHandle, address: H256) -> EvmResult<()> { + let amount_sub = handle.try_convert_apparent_value()?; if amount_sub.is_zero() { - return Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: vec![], - }); + return Ok(()); } - let address_bytes_dst = get_slice(txdata, 4, 36)?; - let (account_id_dst, _) = get_pubkey(address_bytes_dst)?; + let dest = parse_pubkey(address.as_bytes())?.0.into(); let call = pallet_balances::Call::::transfer_allow_death { - dest: account_id_dst.into(), + dest, value: amount_sub.unique_saturated_into(), }; - try_dispatch_runtime_call(handle, call, contract_to_origin(&CONTRACT_ADDRESS_SS58)?) + handle.try_dispatch_runtime_call(call, contract_to_origin(&Self::ADDRESS_SS58)?) } } diff --git a/runtime/src/precompiles/ed25519.rs b/runtime/src/precompiles/ed25519.rs index 83be4ca77..601247f4e 100644 --- a/runtime/src/precompiles/ed25519.rs +++ b/runtime/src/precompiles/ed25519.rs @@ -2,14 +2,18 @@ extern crate alloc; use alloc::vec::Vec; -use crate::precompiles::get_slice; use ed25519_dalek::{Signature, Verifier, VerifyingKey}; use fp_evm::{ExitError, ExitSucceed, LinearCostPrecompile, PrecompileFailure}; -pub const EDVERIFY_PRECOMPILE_INDEX: u64 = 1026; +use crate::precompiles::{PrecompileExt, parse_slice}; pub struct Ed25519Verify; +impl PrecompileExt for Ed25519Verify { + const INDEX: u64 = 1026; + const ADDRESS_SS58: [u8; 32] = [0; 32]; +} + impl LinearCostPrecompile for Ed25519Verify { const BASE: u64 = 15; const WORD: u64 = 3; @@ -23,13 +27,13 @@ impl LinearCostPrecompile for Ed25519Verify { let mut buf = [0u8; 32]; - let msg = get_slice(input, 4, 36)?; - let pk = VerifyingKey::try_from(get_slice(input, 36, 68)?).map_err(|_| { + let msg = parse_slice(input, 4, 36)?; + let pk = VerifyingKey::try_from(parse_slice(input, 36, 68)?).map_err(|_| { PrecompileFailure::Error { exit_status: ExitError::Other("Public key recover failed".into()), } })?; - let sig = Signature::try_from(get_slice(input, 68, 132)?).map_err(|_| { + let sig = Signature::try_from(parse_slice(input, 68, 132)?).map_err(|_| { PrecompileFailure::Error { exit_status: ExitError::Other("Signature recover failed".into()), } diff --git a/runtime/src/precompiles/metagraph.rs b/runtime/src/precompiles/metagraph.rs index ffc4cbed7..e7a924350 100644 --- a/runtime/src/precompiles/metagraph.rs +++ b/runtime/src/precompiles/metagraph.rs @@ -1,360 +1,171 @@ extern crate alloc; -use crate::precompiles::{get_method_id, get_slice}; -use crate::Runtime; -use fp_evm::{ - ExitError, ExitSucceed, PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileResult, -}; -use sp_core::{ByteArray, U256}; -use sp_std::vec; -pub const METAGRAPH_PRECOMPILE_INDEX: u64 = 2050; -pub struct MetagraphPrecompile; - -const NO_HOTKEY: &str = "no hotkey"; - -impl MetagraphPrecompile { - pub fn execute(handle: &mut impl PrecompileHandle) -> PrecompileResult { - let txdata = handle.input(); - let method_id = get_slice(txdata, 0, 4)?; - let method_input = txdata - .get(4..) - .map_or_else(vec::Vec::new, |slice| slice.to_vec()); // Avoiding borrowing conflicts +use alloc::string::String; - match method_id { - id if id == get_method_id("getUidCount(uint16)") => Self::get_uid_count(&method_input), - id if id == get_method_id("getStake(uint16,uint16)") => Self::get_stake(&method_input), - id if id == get_method_id("getRank(uint16,uint16)") => Self::get_rank(&method_input), - id if id == get_method_id("getTrust(uint16,uint16)") => Self::get_trust(&method_input), - id if id == get_method_id("getConsensus(uint16,uint16)") => { - Self::get_consensus(&method_input) - } - id if id == get_method_id("getIncentive(uint16,uint16)") => { - Self::get_incentive(&method_input) - } - id if id == get_method_id("getDividends(uint16,uint16)") => { - Self::get_dividends(&method_input) - } - id if id == get_method_id("getEmission(uint16,uint16)") => { - Self::get_emission(&method_input) - } - id if id == get_method_id("getVtrust(uint16,uint16)") => { - Self::get_vtrust(&method_input) - } - id if id == get_method_id("getValidatorStatus(uint16,uint16)") => { - Self::get_validator_status(&method_input) - } - id if id == get_method_id("getLastUpdate(uint16,uint16)") => { - Self::get_last_update(&method_input) - } - id if id == get_method_id("getIsActive(uint16,uint16)") => { - Self::get_is_active(&method_input) - } - id if id == get_method_id("getAxon(uint16,uint16)") => Self::get_axon(&method_input), - id if id == get_method_id("getHotkey(uint16,uint16)") => { - Self::get_hotkey(&method_input) - } - id if id == get_method_id("getColdkey(uint16,uint16)") => { - Self::get_coldkey(&method_input) - } +use fp_evm::{ExitError, PrecompileFailure, PrecompileHandle}; +use pallet_subtensor::AxonInfo as SubtensorModuleAxonInfo; +use precompile_utils::{EvmResult, solidity::Codec}; +use sp_core::{ByteArray, H256}; - _ => Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }), - } - } +use crate::Runtime; +use crate::precompiles::PrecompileExt; - fn get_uid_count(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid_count = pallet_subtensor::SubnetworkN::::get(netuid); +pub struct MetagraphPrecompile; - let uid_count_u256 = U256::from(uid_count); - let mut result = [0_u8; 32]; - U256::to_big_endian(&uid_count_u256, &mut result); +impl PrecompileExt for MetagraphPrecompile { + const INDEX: u64 = 2050; + const ADDRESS_SS58: [u8; 32] = [0; 32]; +} - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) +#[precompile_utils::precompile] +impl MetagraphPrecompile { + #[precompile::public("getUidCount(uint16)")] + #[precompile::view] + fn get_uid_count(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::SubnetworkN::::get(netuid)) } - fn get_stake(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; + #[precompile::public("getStake(uint16,uint16)")] + #[precompile::view] + fn get_stake(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { let hotkey = pallet_subtensor::Pallet::::get_hotkey_for_net_and_uid(netuid, uid) .map_err(|_| PrecompileFailure::Error { exit_status: ExitError::InvalidRange, })?; - let stake = pallet_subtensor::Pallet::::get_total_stake_for_hotkey(&hotkey); - let result_u256 = U256::from(stake); - let mut result = [0_u8; 32]; - U256::to_big_endian(&result_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + Ok(pallet_subtensor::Pallet::::get_total_stake_for_hotkey(&hotkey)) } - fn get_rank(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - let rank = pallet_subtensor::Pallet::::get_rank_for_uid(netuid, uid); - - let result_u256 = U256::from(rank); - let mut result = [0_u8; 32]; - U256::to_big_endian(&result_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getRank(uint16,uint16)")] + #[precompile::view] + fn get_rank(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { + Ok(pallet_subtensor::Pallet::::get_rank_for_uid( + netuid, uid, + )) } - fn get_trust(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - - let trust = pallet_subtensor::Pallet::::get_trust_for_uid(netuid, uid); - - let result_u256 = U256::from(trust); - let mut result = [0_u8; 32]; - U256::to_big_endian(&result_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getTrust(uint16,uint16)")] + #[precompile::view] + fn get_trust(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { + Ok(pallet_subtensor::Pallet::::get_trust_for_uid( + netuid, uid, + )) } - fn get_consensus(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - - let consensus = pallet_subtensor::Pallet::::get_consensus_for_uid(netuid, uid); - - let result_u256 = U256::from(consensus); - let mut result = [0_u8; 32]; - U256::to_big_endian(&result_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getConsensus(uint16,uint16)")] + #[precompile::view] + fn get_consensus(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { + Ok(pallet_subtensor::Pallet::::get_consensus_for_uid( + netuid, uid, + )) } - fn get_incentive(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - - let incentive = pallet_subtensor::Pallet::::get_incentive_for_uid(netuid, uid); - - let result_u256 = U256::from(incentive); - let mut result = [0_u8; 32]; - U256::to_big_endian(&result_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getIncentive(uint16,uint16)")] + #[precompile::view] + fn get_incentive(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { + Ok(pallet_subtensor::Pallet::::get_incentive_for_uid( + netuid, uid, + )) } - fn get_dividends(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - - let dividends = pallet_subtensor::Pallet::::get_dividends_for_uid(netuid, uid); - - let result_u256 = U256::from(dividends); - let mut result = [0_u8; 32]; - U256::to_big_endian(&result_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getDividends(uint16,uint16)")] + #[precompile::view] + fn get_dividends(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { + Ok(pallet_subtensor::Pallet::::get_dividends_for_uid( + netuid, uid, + )) } - fn get_emission(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - - let emission = pallet_subtensor::Pallet::::get_emission_for_uid(netuid, uid); - - let result_u256 = U256::from(emission); - let mut result = [0_u8; 32]; - U256::to_big_endian(&result_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getEmission(uint16,uint16)")] + #[precompile::view] + fn get_emission(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { + Ok(pallet_subtensor::Pallet::::get_emission_for_uid( + netuid, uid, + )) } - fn get_vtrust(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - - let vtrust = pallet_subtensor::Pallet::::get_validator_trust_for_uid(netuid, uid); - - let result_u256 = U256::from(vtrust); - let mut result = [0_u8; 32]; - U256::to_big_endian(&result_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getVtrust(uint16,uint16)")] + #[precompile::view] + fn get_vtrust(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { + Ok(pallet_subtensor::Pallet::::get_validator_trust_for_uid(netuid, uid)) } - fn get_validator_status(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - - let validator_permit = - pallet_subtensor::Pallet::::get_validator_permit_for_uid(netuid, uid); - - let result_u256 = if validator_permit { - U256::from(1) - } else { - U256::from(0) - }; - let mut result = [0_u8; 32]; - U256::to_big_endian(&result_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getValidatorStatus(uint16,uint16)")] + #[precompile::view] + fn get_validator_status( + _: &mut impl PrecompileHandle, + netuid: u16, + uid: u16, + ) -> EvmResult { + Ok(pallet_subtensor::Pallet::::get_validator_permit_for_uid(netuid, uid)) } - fn get_last_update(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - - let last_update = pallet_subtensor::Pallet::::get_last_update_for_uid(netuid, uid); - - let result_u256 = U256::from(last_update); - let mut result = [0_u8; 32]; - U256::to_big_endian(&result_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getLastUpdate(uint16,uint16)")] + #[precompile::view] + fn get_last_update(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { + Ok(pallet_subtensor::Pallet::::get_last_update_for_uid(netuid, uid)) } - fn get_is_active(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - - let active = pallet_subtensor::Pallet::::get_active_for_uid(netuid, uid); - - let result_u256 = if active { U256::from(1) } else { U256::from(0) }; - let mut result = [0_u8; 32]; - U256::to_big_endian(&result_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getIsActive(uint16,uint16)")] + #[precompile::view] + fn get_is_active(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { + Ok(pallet_subtensor::Pallet::::get_active_for_uid( + netuid, uid, + )) } - fn get_axon(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - + #[precompile::public("getAxon(uint16,uint16)")] + #[precompile::view] + fn get_axon(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { let hotkey = pallet_subtensor::Pallet::::get_hotkey_for_net_and_uid(netuid, uid) .map_err(|_| PrecompileFailure::Error { - exit_status: ExitError::Other(sp_version::Cow::Borrowed(NO_HOTKEY)), + exit_status: ExitError::Other("hotkey not found".into()), })?; - let axon = pallet_subtensor::Pallet::::get_axon_info(netuid, &hotkey); - - let mut block_result = [0_u8; 32]; - U256::to_big_endian(&U256::from(axon.block), &mut block_result); - - let mut version_result = [0_u8; 32]; - U256::to_big_endian(&U256::from(axon.version), &mut version_result); - - let mut ip_result = [0_u8; 32]; - U256::to_big_endian(&U256::from(axon.ip), &mut ip_result); - - let mut port_result = [0_u8; 32]; - U256::to_big_endian(&U256::from(axon.port), &mut port_result); - - let mut ip_type_result = [0_u8; 32]; - U256::to_big_endian(&U256::from(axon.ip_type), &mut ip_type_result); - - let mut protocol_result = [0_u8; 32]; - U256::to_big_endian(&U256::from(axon.protocol), &mut protocol_result); - - let mut result = [0_u8; 192]; - result[..32].copy_from_slice(&block_result); - result[32..64].copy_from_slice(&version_result); - result[64..96].copy_from_slice(&ip_result); - result[96..128].copy_from_slice(&port_result); - result[128..160].copy_from_slice(&ip_type_result); - result[160..].copy_from_slice(&protocol_result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + Ok(pallet_subtensor::Pallet::::get_axon_info(netuid, &hotkey).into()) } - fn get_hotkey(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - - let hotkey = pallet_subtensor::Pallet::::get_hotkey_for_net_and_uid(netuid, uid) + #[precompile::public("getHotkey(uint16,uint16)")] + #[precompile::view] + fn get_hotkey(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { + pallet_subtensor::Pallet::::get_hotkey_for_net_and_uid(netuid, uid) + .map(|acc| H256::from_slice(acc.as_slice())) .map_err(|_| PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - })?; - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: hotkey.as_slice().into(), - }) + exit_status: ExitError::InvalidRange, + }) } - fn get_coldkey(data: &[u8]) -> PrecompileResult { - let netuid = Self::parse_netuid(data)?; - let uid = Self::parse_uid(get_slice(data, 32, 64)?)?; - + #[precompile::public("getColdkey(uint16,uint16)")] + #[precompile::view] + fn get_coldkey(_: &mut impl PrecompileHandle, netuid: u16, uid: u16) -> EvmResult { let hotkey = pallet_subtensor::Pallet::::get_hotkey_for_net_and_uid(netuid, uid) .map_err(|_| PrecompileFailure::Error { exit_status: ExitError::InvalidRange, })?; - let coldkey = pallet_subtensor::Owner::::get(&hotkey); - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: coldkey.as_slice().into(), - }) + Ok(H256::from_slice(coldkey.as_slice())) } +} - fn parse_netuid(data: &[u8]) -> Result { - if data.len() < 32 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - let mut netuid = [0u8; 2]; - netuid.copy_from_slice(get_slice(data, 30, 32)?); - let result = u16::from_be_bytes(netuid); - Ok(result) - } +#[derive(Codec)] +struct AxonInfo { + block: u64, + version: u32, + ip: u128, + port: u16, + ip_type: u8, + protocol: u8, +} - fn parse_uid(data: &[u8]) -> Result { - if data.len() < 32 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); +impl From for AxonInfo { + fn from(value: SubtensorModuleAxonInfo) -> Self { + Self { + block: value.block, + version: value.version, + ip: value.ip, + port: value.port, + ip_type: value.ip_type, + protocol: value.protocol, } - let mut uid = [0u8; 2]; - uid.copy_from_slice(get_slice(data, 30, 32)?); - let result = u16::from_be_bytes(uid); - Ok(result) } } diff --git a/runtime/src/precompiles/mod.rs b/runtime/src/precompiles/mod.rs index 6bed2913c..bba70eb02 100644 --- a/runtime/src/precompiles/mod.rs +++ b/runtime/src/precompiles/mod.rs @@ -3,24 +3,26 @@ extern crate alloc; use alloc::format; use core::marker::PhantomData; -use crate::{Runtime, RuntimeCall}; - +use frame_support::dispatch::{GetDispatchInfo, Pays}; +use frame_system::RawOrigin; use pallet_evm::{ - ExitError, ExitSucceed, GasWeightMapping, IsPrecompileResult, Precompile, PrecompileFailure, - PrecompileHandle, PrecompileOutput, PrecompileResult, PrecompileSet, + AddressMapping, BalanceConverter, ExitError, GasWeightMapping, HashedAddressMapping, + IsPrecompileResult, Precompile, PrecompileFailure, PrecompileHandle, PrecompileResult, + PrecompileSet, }; use pallet_evm_precompile_modexp::Modexp; use pallet_evm_precompile_sha3fips::Sha3FIPS256; use pallet_evm_precompile_simple::{ECRecover, ECRecoverPublicKey, Identity, Ripemd160, Sha256}; - -use frame_support::dispatch::{GetDispatchInfo, Pays}; -use frame_system::RawOrigin; -use sp_core::{hashing::keccak_256, H160}; -use sp_runtime::{traits::Dispatchable, AccountId32}; +use precompile_utils::EvmResult; +use sp_core::{H160, U256}; +use sp_runtime::traits::BlakeTwo256; +use sp_runtime::{AccountId32, traits::Dispatchable}; use pallet_admin_utils::{PrecompileEnable, PrecompileEnum}; use sp_std::vec; +use crate::{Runtime, RuntimeCall}; + // Include custom precompiles mod balance_transfer; mod ed25519; @@ -35,6 +37,7 @@ use metagraph::*; use neuron::*; use staking::*; use subnet::*; + pub struct FrontierPrecompiles(PhantomData); impl Default for FrontierPrecompiles where @@ -61,12 +64,12 @@ where hash(5), hash(1024), hash(1025), - hash(EDVERIFY_PRECOMPILE_INDEX), - hash(BALANCE_TRANSFER_INDEX), - hash(STAKING_PRECOMPILE_INDEX), - hash(SUBNET_PRECOMPILE_INDEX), - hash(METAGRAPH_PRECOMPILE_INDEX), - hash(NEURON_PRECOMPILE_INDEX), + hash(Ed25519Verify::INDEX), + hash(BalanceTransferPrecompile::INDEX), + hash(StakingPrecompile::INDEX), + hash(SubnetPrecompile::INDEX), + hash(MetagraphPrecompile::INDEX), + hash(NeuronPrecompile::INDEX), ] } } @@ -85,10 +88,9 @@ where // Non-Frontier specific nor Ethereum precompiles : a if a == hash(1024) => Some(Sha3FIPS256::execute(handle)), a if a == hash(1025) => Some(ECRecoverPublicKey::execute(handle)), - - a if a == hash(EDVERIFY_PRECOMPILE_INDEX) => Some(Ed25519Verify::execute(handle)), + a if a == hash(Ed25519Verify::INDEX) => Some(Ed25519Verify::execute(handle)), // Subtensor specific precompiles : - a if a == hash(BALANCE_TRANSFER_INDEX) => { + a if a == hash(BalanceTransferPrecompile::INDEX) => { if PrecompileEnable::::get(PrecompileEnum::BalanceTransfer) { Some(BalanceTransferPrecompile::execute(handle)) } else { @@ -99,7 +101,7 @@ where })) } } - a if a == hash(STAKING_PRECOMPILE_INDEX) => { + a if a == hash(StakingPrecompile::INDEX) => { if PrecompileEnable::::get(PrecompileEnum::Staking) { Some(StakingPrecompile::execute(handle)) } else { @@ -111,7 +113,7 @@ where } } - a if a == hash(SUBNET_PRECOMPILE_INDEX) => { + a if a == hash(SubnetPrecompile::INDEX) => { if PrecompileEnable::::get(PrecompileEnum::Subnet) { Some(SubnetPrecompile::execute(handle)) } else { @@ -120,7 +122,7 @@ where })) } } - a if a == hash(METAGRAPH_PRECOMPILE_INDEX) => { + a if a == hash(MetagraphPrecompile::INDEX) => { if PrecompileEnable::::get(PrecompileEnum::Metagraph) { Some(MetagraphPrecompile::execute(handle)) } else { @@ -129,7 +131,7 @@ where })) } } - a if a == hash(NEURON_PRECOMPILE_INDEX) => { + a if a == hash(NeuronPrecompile::INDEX) => { if PrecompileEnable::::get(PrecompileEnum::Neuron) { Some(NeuronPrecompile::execute(handle)) } else { @@ -155,19 +157,8 @@ fn hash(a: u64) -> H160 { H160::from_low_u64_be(a) } -/// Returns Ethereum method ID from an str method signature -/// -pub fn get_method_id(method_signature: &str) -> [u8; 4] { - // Calculate the full Keccak-256 hash of the method signature - let hash = keccak_256(method_signature.as_bytes()); - - // Extract the first 4 bytes to get the method ID - [hash[0], hash[1], hash[2], hash[3]] -} - /// Takes a slice from bytes with PrecompileFailure as Error -/// -pub fn get_slice(data: &[u8], from: usize, to: usize) -> Result<&[u8], PrecompileFailure> { +fn parse_slice(data: &[u8], from: usize, to: usize) -> Result<&[u8], PrecompileFailure> { let maybe_slice = data.get(from..to); if let Some(slice) = maybe_slice { Ok(slice) @@ -184,9 +175,9 @@ pub fn get_slice(data: &[u8], from: usize, to: usize) -> Result<&[u8], Precompil } } -pub fn get_pubkey(data: &[u8]) -> Result<(AccountId32, vec::Vec), PrecompileFailure> { +fn parse_pubkey(data: &[u8]) -> Result<(AccountId32, vec::Vec), PrecompileFailure> { let mut pubkey = [0u8; 32]; - pubkey.copy_from_slice(get_slice(data, 0, 32)?); + pubkey.copy_from_slice(parse_slice(data, 0, 32)?); Ok(( pubkey.into(), @@ -195,107 +186,107 @@ pub fn get_pubkey(data: &[u8]) -> Result<(AccountId32, vec::Vec), Precompile )) } -fn parse_netuid(data: &[u8], offset: usize) -> Result { - if data.len() < offset + 2 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let mut netuid_bytes = [0u8; 2]; - netuid_bytes.copy_from_slice(get_slice(data, offset, offset + 2)?); - let netuid: u16 = netuid_bytes[1] as u16 | ((netuid_bytes[0] as u16) << 8u16); - - Ok(netuid) +fn try_u16_from_u256(value: U256) -> Result { + value.try_into().map_err(|_| PrecompileFailure::Error { + exit_status: ExitError::Other("the value is outside of u16 bounds".into()), + }) } fn contract_to_origin(contract: &[u8; 32]) -> Result, PrecompileFailure> { - let (account_id, _) = get_pubkey(contract)?; + let (account_id, _) = parse_pubkey(contract)?; Ok(RawOrigin::Signed(account_id)) } -/// Dispatches a runtime call, but also checks and records the gas costs. -fn try_dispatch_runtime_call( - handle: &mut impl PrecompileHandle, - call: impl Into, - origin: RawOrigin, -) -> PrecompileResult { - let call = Into::::into(call); - let info = call.get_dispatch_info(); - - let target_gas = handle.gas_limit(); - if let Some(gas) = target_gas { - let valid_weight = - ::GasWeightMapping::gas_to_weight(gas, false).ref_time(); - if info.weight.ref_time() > valid_weight { - return Err(PrecompileFailure::Error { - exit_status: ExitError::OutOfGas, - }); - } +trait PrecompileHandleExt: PrecompileHandle { + fn caller_account_id(&self) -> AccountId32 { + as AddressMapping>::into_account_id( + self.context().caller, + ) } - handle.record_external_cost( - Some(info.weight.ref_time()), - Some(info.weight.proof_size()), - None, - )?; + fn try_convert_apparent_value(&self) -> EvmResult { + let amount = self.context().apparent_value; + ::BalanceConverter::into_substrate_balance(amount).ok_or( + PrecompileFailure::Error { + exit_status: ExitError::Other( + "error converting balance from ETH to subtensor".into(), + ), + }, + ) + } - match call.dispatch(origin.into()) { - Ok(post_info) => { - if post_info.pays_fee(&info) == Pays::Yes { - let actual_weight = post_info.actual_weight.unwrap_or(info.weight); - let cost = - ::GasWeightMapping::weight_to_gas(actual_weight); - handle.record_cost(cost)?; + /// Dispatches a runtime call, but also checks and records the gas costs. + fn try_dispatch_runtime_call( + &mut self, + call: impl Into, + origin: RawOrigin, + ) -> EvmResult<()> { + let call = Into::::into(call); + let info = call.get_dispatch_info(); - handle.refund_external_cost( - Some( - info.weight - .ref_time() - .saturating_sub(actual_weight.ref_time()), - ), - Some( - info.weight - .proof_size() - .saturating_sub(actual_weight.proof_size()), - ), - ); + let target_gas = self.gas_limit(); + if let Some(gas) = target_gas { + let valid_weight = + ::GasWeightMapping::gas_to_weight(gas, false) + .ref_time(); + if info.weight.ref_time() > valid_weight { + return Err(PrecompileFailure::Error { + exit_status: ExitError::OutOfGas, + }); } + } - log::info!("Dispatch succeeded. Post info: {:?}", post_info); + self.record_external_cost( + Some(info.weight.ref_time()), + Some(info.weight.proof_size()), + None, + )?; - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: Default::default(), - }) - } - Err(e) => { - log::error!("Dispatch failed. Error: {:?}", e); - log::warn!("Returning error PrecompileFailure::Error"); - Err(PrecompileFailure::Error { - exit_status: ExitError::Other( - format!("dispatch execution failed: {}", <&'static str>::from(e)).into(), - ), - }) + match call.dispatch(origin.into()) { + Ok(post_info) => { + if post_info.pays_fee(&info) == Pays::Yes { + let actual_weight = post_info.actual_weight.unwrap_or(info.weight); + let cost = ::GasWeightMapping::weight_to_gas( + actual_weight, + ); + self.record_cost(cost)?; + + self.refund_external_cost( + Some( + info.weight + .ref_time() + .saturating_sub(actual_weight.ref_time()), + ), + Some( + info.weight + .proof_size() + .saturating_sub(actual_weight.proof_size()), + ), + ); + } + + log::info!("Dispatch succeeded. Post info: {:?}", post_info); + + Ok(()) + } + Err(e) => { + log::error!("Dispatch failed. Error: {:?}", e); + log::warn!("Returning error PrecompileFailure::Error"); + Err(PrecompileFailure::Error { + exit_status: ExitError::Other( + format!("dispatch execution failed: {}", <&'static str>::from(e)).into(), + ), + }) + } } } } -/// Retrieves a single u8 value from the given data slice at the specified index. -/// -/// # Args -/// * `data`: The slice of bytes from which to retrieve the u8 value. -/// * `index`: The index within the `data` slice where the u8 value is located. -/// -/// # Returns -/// A `Result` containing the u8 value at the specified index if successful, or a `PrecompileFailure` if the index is out of range. -pub fn get_single_u8(data: &[u8], index: usize) -> Result { - if let Some(result) = data.get(index) { - Ok(*result) - } else { - log::error!("fail to get data from data, {:?}, at {}", &data, index); - Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }) - } +impl PrecompileHandleExt for T where T: PrecompileHandle {} + +trait PrecompileExt: Precompile { + const INDEX: u64; + // ss58 public key i.e., the contract sends funds it received to the destination address from + // the method parameter. + const ADDRESS_SS58: [u8; 32]; } diff --git a/runtime/src/precompiles/neuron.rs b/runtime/src/precompiles/neuron.rs index 38fb701fb..65306f87c 100644 --- a/runtime/src/precompiles/neuron.rs +++ b/runtime/src/precompiles/neuron.rs @@ -1,157 +1,109 @@ -use pallet_evm::{ - AddressMapping, ExitError, HashedAddressMapping, PrecompileFailure, PrecompileHandle, - PrecompileResult, -}; - -use crate::precompiles::{ - get_method_id, get_pubkey, get_single_u8, get_slice, parse_netuid, try_dispatch_runtime_call, -}; -use crate::{Runtime, RuntimeCall}; use frame_system::RawOrigin; +use pallet_evm::PrecompileHandle; +use precompile_utils::{EvmResult, prelude::UnboundedBytes}; use sp_core::H256; -use sp_runtime::traits::BlakeTwo256; -use sp_runtime::AccountId32; -use sp_std::vec; use sp_std::vec::Vec; -pub const NEURON_PRECOMPILE_INDEX: u64 = 2052; -// max paramter lenght 4K -pub const MAX_PARAMETER_SIZE: usize = 4 * 1024; -// ss58 public key i.e., the contract sends funds it received to the destination address from the -// method parameter. -#[allow(dead_code)] -const CONTRACT_ADDRESS_SS58: [u8; 32] = [ - 0xbc, 0x46, 0x35, 0x79, 0xbc, 0x99, 0xf9, 0xee, 0x7c, 0x59, 0xed, 0xee, 0x20, 0x61, 0xa3, 0x09, - 0xd2, 0x1e, 0x68, 0xd5, 0x39, 0xb6, 0x40, 0xec, 0x66, 0x46, 0x90, 0x30, 0xab, 0x74, 0xc1, 0xdb, -]; -pub struct NeuronPrecompile; - -impl NeuronPrecompile { - pub fn execute(handle: &mut impl PrecompileHandle) -> PrecompileResult { - let txdata = handle.input(); - let method_id = get_slice(txdata, 0, 4)?; - let method_input = txdata - .get(4..) - .map_or_else(vec::Vec::new, |slice| slice.to_vec()); // Avoiding borrowing conflicts - - if method_input.len() > MAX_PARAMETER_SIZE { - log::error!( - "method parameter data length as {} is too long", - method_input.len() - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - match method_id { - id if id == get_method_id("setWeights(uint16,uint16[],uint16[],uint64)") => { - Self::set_weights(handle, &method_input) - } - id if id == get_method_id("commitWeights(uint16,uint256)") => { - Self::commit_weights(handle, &method_input) - } - id if id - == get_method_id("revealWeights(uint16,uint16[],uint16[],uint16[],uint64)") => - { - Self::reveal_weights(handle, &method_input) - } +use crate::Runtime; +use crate::precompiles::{PrecompileExt, PrecompileHandleExt, parse_pubkey}; - id if id == get_method_id("burnedRegister(uint16,bytes32)") => { - Self::burned_register(handle, &method_input) - } - id if id - == get_method_id( - "serveAxon(uint16,uint32,uint128,uint16,uint8,uint8,uint8,uint8)", - ) => - { - Self::serve_axon(handle, &method_input) - } - id if id - == get_method_id( - "serveAxonTls(uint16,uint32,uint128,uint16,uint8,uint8,uint8,uint8,bytes)", - ) => - { - Self::serve_axon_tls(handle, &method_input) - } - id if id == get_method_id("servePrometheus(uint16,uint32,uint128,uint16,uint8)") => { - Self::serve_prometheus(handle, &method_input) - } +pub struct NeuronPrecompile; - _ => Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }), - } - } +impl PrecompileExt for NeuronPrecompile { + const INDEX: u64 = 2052; + const ADDRESS_SS58: [u8; 32] = [ + 0xbc, 0x46, 0x35, 0x79, 0xbc, 0x99, 0xf9, 0xee, 0x7c, 0x59, 0xed, 0xee, 0x20, 0x61, 0xa3, + 0x09, 0xd2, 0x1e, 0x68, 0xd5, 0x39, 0xb6, 0x40, 0xec, 0x66, 0x46, 0x90, 0x30, 0xab, 0x74, + 0xc1, 0xdb, + ]; +} - pub fn set_weights(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, dests, weights, version_key) = Self::parse_netuid_dests_weights(data)?; - let call = RuntimeCall::SubtensorModule(pallet_subtensor::Call::::set_weights { +#[precompile_utils::precompile] +impl NeuronPrecompile { + #[precompile::public("setWeights(uint16,uint16[],uint16[],uint64)")] + #[precompile::payable] + pub fn set_weights( + handle: &mut impl PrecompileHandle, + netuid: u16, + dests: Vec, + weights: Vec, + version_key: u64, + ) -> EvmResult<()> { + let call = pallet_subtensor::Call::::set_weights { netuid, dests, weights, version_key, - }); - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); + }; - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - pub fn commit_weights(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, commit_hash) = Self::parse_netuid_commit_hash(data)?; + #[precompile::public("commitWeights(uint16,bytes32)")] + #[precompile::payable] + pub fn commit_weights( + handle: &mut impl PrecompileHandle, + netuid: u16, + commit_hash: H256, + ) -> EvmResult<()> { + let call = pallet_subtensor::Call::::commit_weights { + netuid, + commit_hash, + }; - let call = - RuntimeCall::SubtensorModule(pallet_subtensor::Call::::commit_weights { - netuid, - commit_hash, - }); - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - pub fn reveal_weights(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, uids, values, salt, version_key) = - Self::parse_netuid_dests_weights_salt(data)?; - let call = - RuntimeCall::SubtensorModule(pallet_subtensor::Call::::reveal_weights { - netuid, - uids, - values, - salt, - version_key, - }); - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } + #[precompile::public("revealWeights(uint16,uint16[],uint16[],uint16[],uint64)")] + #[precompile::payable] + pub fn reveal_weights( + handle: &mut impl PrecompileHandle, + netuid: u16, + uids: Vec, + values: Vec, + salt: Vec, + version_key: u64, + ) -> EvmResult<()> { + let call = pallet_subtensor::Call::::reveal_weights { + netuid, + uids, + values, + salt, + version_key, + }; - pub fn burned_register(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, hotkey) = Self::parse_netuid_hotkey_parameter(data)?; - let call = - RuntimeCall::SubtensorModule(pallet_subtensor::Call::::burned_register { - netuid, - hotkey, - }); - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) + } - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + #[precompile::public("burnedRegister(uint16,bytes32)")] + #[precompile::payable] + fn burned_register( + handle: &mut impl PrecompileHandle, + netuid: u16, + hotkey: H256, + ) -> EvmResult<()> { + let coldkey = handle.caller_account_id(); + let (hotkey, _) = parse_pubkey(hotkey.as_bytes())?; + let call = pallet_subtensor::Call::::burned_register { netuid, hotkey }; + + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(coldkey)) } - pub fn serve_axon(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, version, ip, port, ip_type, protocol, placeholder1, placeholder2) = - Self::parse_serve_axon_parameters(data)?; - let call = RuntimeCall::SubtensorModule(pallet_subtensor::Call::::serve_axon { + #[precompile::public("serveAxon(uint16,uint32,uint128,uint16,uint8,uint8,uint8,uint8)")] + #[precompile::payable] + #[allow(clippy::too_many_arguments)] + fn serve_axon( + handle: &mut impl PrecompileHandle, + netuid: u16, + version: u32, + ip: u128, + port: u16, + ip_type: u8, + protocol: u8, + placeholder1: u8, + placeholder2: u8, + ) -> EvmResult<()> { + let call = pallet_subtensor::Call::::serve_axon { netuid, version, ip, @@ -160,367 +112,29 @@ impl NeuronPrecompile { protocol, placeholder1, placeholder2, - }); - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } - - pub fn serve_axon_tls(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, version, ip, port, ip_type, protocol, placeholder1, placeholder2, certificate) = - Self::parse_serve_axon_tls_parameters(data)?; - let call = - RuntimeCall::SubtensorModule(pallet_subtensor::Call::::serve_axon_tls { - netuid, - version, - ip, - port, - ip_type, - protocol, - placeholder1, - placeholder2, - certificate, - }); - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); + }; - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - pub fn serve_prometheus(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, version, ip, port, ip_type) = Self::parse_serve_prometheus_parameters(data)?; - let call = - RuntimeCall::SubtensorModule(pallet_subtensor::Call::::serve_prometheus { - netuid, - version, - ip, - port, - ip_type, - }); - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - // Dispatch the register_network call - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } - - fn parse_netuid_hotkey_parameter(data: &[u8]) -> Result<(u16, AccountId32), PrecompileFailure> { - if data.len() < 64 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let netuid = parse_netuid(data, 30)?; - - let (hotkey, _) = get_pubkey(get_slice(data, 32, 64)?)?; - - Ok((netuid, hotkey)) - } - - fn parse_netuid_dests_weights( - data: &[u8], - ) -> Result<(u16, Vec, Vec, u64), PrecompileFailure> { - let data_len = data.len(); - if data_len < 4 * 32 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - let mut netuid_vec = [0u8; 2]; - netuid_vec.copy_from_slice(get_slice(data, 30, 32)?); - let netuid = u16::from_be_bytes(netuid_vec); - - // get the neuron amount in sebnet - let subnet_size = pallet_subtensor::Pallet::::get_subnetwork_n(netuid) as usize; - - let mut first_position_vec = [0u8; 2]; - first_position_vec.copy_from_slice(get_slice(data, 62, 64)?); - let first_position = u16::from_be_bytes(first_position_vec) as usize; - - if first_position > data_len { - log::error!("position for uids data as {} is too large", first_position); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let mut second_position_vec = [0u8; 2]; - second_position_vec.copy_from_slice(get_slice(data, 94, 96)?); - let second_position = u16::from_be_bytes(second_position_vec) as usize; - - if second_position > data_len { - log::error!("position for uids data as {} is too large", first_position); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let mut version_key_vec = [0u8; 8]; - version_key_vec.copy_from_slice(get_slice(data, 120, 128)?); - let version_key = u64::from_be_bytes(version_key_vec); - - let mut dests = vec![]; - let mut weights = vec![]; - - let mut dests_len_vec = [0u8; 2]; - dests_len_vec.copy_from_slice(get_slice(data, first_position + 30, first_position + 32)?); - let dests_len = u16::from_be_bytes(dests_len_vec) as usize; - - if dests_len > subnet_size { - log::error!( - "uids len as {} in set weight is more than neurons {} in subnet {}", - dests_len, - subnet_size, - netuid - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - for i in 0..dests_len { - let mut tmp_vec = [0u8; 2]; - let from = first_position - .saturating_add(62) - .saturating_add(i.saturating_mul(32)); - let to = from.saturating_add(2); - tmp_vec.copy_from_slice(get_slice(data, from, to)?); - let dest = u16::from_be_bytes(tmp_vec); - dests.push(dest); - } - - let mut weights_len_vec = [0u8; 2]; - weights_len_vec.copy_from_slice(get_slice( - data, - second_position + 30, - second_position + 32, - )?); - let weights_len = u16::from_be_bytes(weights_len_vec) as usize; - - if weights_len > subnet_size { - log::error!( - "weights len as {} in set weight is more than neurons {} in subnet {}", - weights_len, - subnet_size, - netuid - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - for i in 0..weights_len { - let mut tmp_vec = [0u8; 2]; - let from = second_position - .saturating_add(62) - .saturating_add(i.saturating_mul(32)); - let to = from.saturating_add(2); - tmp_vec.copy_from_slice(get_slice(data, from, to)?); - let weight = u16::from_be_bytes(tmp_vec); - weights.push(weight); - } - - Ok((netuid, dests, weights, version_key)) - } - - fn parse_netuid_commit_hash(data: &[u8]) -> Result<(u16, H256), PrecompileFailure> { - if data.len() < 2 * 32 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let mut netuid_vec = [0u8; 2]; - netuid_vec.copy_from_slice(get_slice(data, 30, 32)?); - let netuid = u16::from_be_bytes(netuid_vec); - let commit_hash = H256::from_slice(get_slice(data, 32, 64)?); - - Ok((netuid, commit_hash)) - } - - fn parse_netuid_dests_weights_salt( - data: &[u8], - ) -> Result<(u16, Vec, Vec, Vec, u64), PrecompileFailure> { - let data_len = data.len(); - if data_len < 5 * 32 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let netuid = parse_netuid(data, 30)?; - - // get the neuron amount in sebnet - let subnet_size = pallet_subtensor::Pallet::::get_subnetwork_n(netuid) as usize; - - let mut first_position_vec = [0u8; 2]; - first_position_vec.copy_from_slice(get_slice(data, 62, 64)?); - let first_position = u16::from_be_bytes(first_position_vec) as usize; - - if first_position > data_len { - log::error!("position for uids data as {} is too large", first_position); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let mut second_position_vec = [0u8; 2]; - second_position_vec.copy_from_slice(get_slice(data, 94, 96)?); - let second_position = u16::from_be_bytes(second_position_vec) as usize; - - if second_position > data_len { - log::error!( - "position for values data as {} is too large", - first_position - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let mut third_position_vec = [0u8; 2]; - third_position_vec.copy_from_slice(get_slice(data, 126, 128)?); - let third_position = u16::from_be_bytes(third_position_vec) as usize; - - if third_position > data_len { - log::error!("position for salt data as {} is too large", first_position); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let mut version_key_vec = [0u8; 8]; - version_key_vec.copy_from_slice(get_slice(data, 152, 160)?); - let version_key = u64::from_be_bytes(version_key_vec); - - let mut uids = vec![]; - let mut values = vec![]; - let mut salt = vec![]; - - let mut uids_len_vec = [0u8; 2]; - uids_len_vec.copy_from_slice(get_slice(data, first_position + 30, first_position + 32)?); - let uids_len = u16::from_be_bytes(uids_len_vec) as usize; - - if uids_len > subnet_size { - log::error!( - "uids len as {} in reveal weight is more than neurons {} in subnet {}", - uids_len, - subnet_size, - netuid - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - for i in 0..uids_len { - let mut tmp_vec = [0u8; 2]; - let from = first_position - .saturating_add(62) - .saturating_add(i.saturating_mul(32)); - let to = from.saturating_add(2); - tmp_vec.copy_from_slice(get_slice(data, from, to)?); - let uid = u16::from_be_bytes(tmp_vec); - uids.push(uid); - } - - let mut values_len_vec = [0u8; 2]; - values_len_vec.copy_from_slice(get_slice( - data, - second_position + 30, - second_position + 32, - )?); - let values_len = u16::from_be_bytes(values_len_vec) as usize; - - if values_len > subnet_size { - log::error!( - "values len as {} in reveal weight is more than neurons {} in subnet {}", - values_len, - subnet_size, - netuid - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - for i in 0..values_len { - let mut tmp_vec = [0u8; 2]; - let from = second_position - .saturating_add(62) - .saturating_add(i.saturating_mul(32)); - let to = from.saturating_add(2); - tmp_vec.copy_from_slice(get_slice(data, from, to)?); - let value = u16::from_be_bytes(tmp_vec); - values.push(value); - } - - let mut salt_len_vec = [0u8; 2]; - salt_len_vec.copy_from_slice(get_slice(data, third_position + 30, third_position + 32)?); - let salt_len = u16::from_be_bytes(salt_len_vec) as usize; - - if salt_len > subnet_size { - log::error!( - "salt len as {} in reveal weight is more than neurons {} in subnet {}", - salt_len, - subnet_size, - netuid - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - for i in 0..salt_len { - let mut tmp_vec = [0u8; 2]; - let from = third_position - .saturating_add(62) - .saturating_add(i.saturating_mul(32)); - let to = from.saturating_add(2); - tmp_vec.copy_from_slice(get_slice(data, from, to)?); - let value = u16::from_be_bytes(tmp_vec); - salt.push(value); - } - - Ok((netuid, uids, values, salt, version_key)) - } - - fn parse_serve_axon_parameters( - data: &[u8], - ) -> Result<(u16, u32, u128, u16, u8, u8, u8, u8), PrecompileFailure> { - if data.len() < 256 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let netuid = parse_netuid(data, 30)?; - - let mut version_vec = [0u8; 4]; - version_vec.copy_from_slice(get_slice(data, 60, 64)?); - let version = u32::from_be_bytes(version_vec); - - let mut ip_vec = [0u8; 16]; - ip_vec.copy_from_slice(get_slice(data, 80, 96)?); - let ip = u128::from_be_bytes(ip_vec); - - let mut port_vec = [0u8; 2]; - port_vec.copy_from_slice(get_slice(data, 126, 128)?); - let port = u16::from_be_bytes(port_vec); - - let ip_type = get_single_u8(data, 159)?; - let protocol = get_single_u8(data, 191)?; - let placeholder1 = get_single_u8(data, 223)?; - let placeholder2 = get_single_u8(data, 255)?; - Ok(( + #[precompile::public( + "serveAxonTls(uint16,uint32,uint128,uint16,uint8,uint8,uint8,uint8,bytes)" + )] + #[precompile::payable] + #[allow(clippy::too_many_arguments)] + fn serve_axon_tls( + handle: &mut impl PrecompileHandle, + netuid: u16, + version: u32, + ip: u128, + port: u16, + ip_type: u8, + protocol: u8, + placeholder1: u8, + placeholder2: u8, + certificate: UnboundedBytes, + ) -> EvmResult<()> { + let call = pallet_subtensor::Call::::serve_axon_tls { netuid, version, ip, @@ -529,101 +143,31 @@ impl NeuronPrecompile { protocol, placeholder1, placeholder2, - )) - } - - fn parse_serve_axon_tls_parameters( - data: &[u8], - ) -> Result<(u16, u32, u128, u16, u8, u8, u8, u8, vec::Vec), PrecompileFailure> { - let data_len = data.len(); - if data_len < 288 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let netuid = parse_netuid(data, 30)?; - - let mut version_vec = [0u8; 4]; - version_vec.copy_from_slice(get_slice(data, 60, 64)?); - let version = u32::from_be_bytes(version_vec); - - let mut ip_vec = [0u8; 16]; - ip_vec.copy_from_slice(get_slice(data, 80, 96)?); - let ip = u128::from_be_bytes(ip_vec); - - let mut port_vec = [0u8; 2]; - port_vec.copy_from_slice(get_slice(data, 126, 128)?); - let port = u16::from_be_bytes(port_vec); - - let ip_type = get_single_u8(data, 159)?; - let protocol = get_single_u8(data, 191)?; - let placeholder1 = get_single_u8(data, 223)?; - let placeholder2 = get_single_u8(data, 255)?; - - let mut len_position_vec = [0u8; 2]; - len_position_vec.copy_from_slice(get_slice(data, 286, 288)?); - let len_position = u16::from_be_bytes(len_position_vec) as usize; - - if len_position > data_len { - log::error!( - "the start position of certificate as {} is bigger than whole data len {}", - len_position, - data_len - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } + certificate: certificate.into(), + }; - let mut len_vec = [0u8; 2]; - len_vec.copy_from_slice(get_slice(data, len_position + 30, len_position + 32)?); - let vec_len = u16::from_be_bytes(len_vec) as usize; - - let vec_result = get_slice( - data, - len_position + 32, - len_position.saturating_add(32).saturating_add(vec_len), - )? - .to_vec(); + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) + } - Ok(( + #[precompile::public("servePrometheus(uint16,uint32,uint128,uint16,uint8)")] + #[precompile::payable] + #[allow(clippy::too_many_arguments)] + fn serve_prometheus( + handle: &mut impl PrecompileHandle, + netuid: u16, + version: u32, + ip: u128, + port: u16, + ip_type: u8, + ) -> EvmResult<()> { + let call = pallet_subtensor::Call::::serve_prometheus { netuid, version, ip, port, ip_type, - protocol, - placeholder1, - placeholder2, - vec_result, - )) - } - - fn parse_serve_prometheus_parameters( - data: &[u8], - ) -> Result<(u16, u32, u128, u16, u8), PrecompileFailure> { - if data.len() < 160 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let netuid = parse_netuid(data, 30)?; - - let mut version_vec = [0u8; 4]; - version_vec.copy_from_slice(get_slice(data, 60, 64)?); - let version = u32::from_be_bytes(version_vec); - - let mut ip_vec = [0u8; 16]; - ip_vec.copy_from_slice(get_slice(data, 80, 96)?); - let ip = u128::from_be_bytes(ip_vec); - - let mut port_vec = [0u8; 2]; - port_vec.copy_from_slice(get_slice(data, 126, 128)?); - let port = u16::from_be_bytes(port_vec); + }; - let ip_type = get_single_u8(data, 159)?; - Ok((netuid, version, ip, port, ip_type)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } } diff --git a/runtime/src/precompiles/solidity/neuron.abi b/runtime/src/precompiles/solidity/neuron.abi index e12685f99..e4ffb6fa1 100644 --- a/runtime/src/precompiles/solidity/neuron.abi +++ b/runtime/src/precompiles/solidity/neuron.abi @@ -25,9 +25,9 @@ "type": "uint16" }, { - "internalType": "uint256", + "internalType": "bytes32", "name": "commitHash", - "type": "uint256" + "type": "bytes32" } ], "name": "commitWeights", @@ -230,4 +230,4 @@ "stateMutability": "payable", "type": "function" } -] \ No newline at end of file +] diff --git a/runtime/src/precompiles/solidity/neuron.sol b/runtime/src/precompiles/solidity/neuron.sol index 772f29063..204bc3f60 100644 --- a/runtime/src/precompiles/solidity/neuron.sol +++ b/runtime/src/precompiles/solidity/neuron.sol @@ -99,9 +99,9 @@ interface INeuron { * @dev Commits the weights for a neuron. * * @param netuid The subnet to commit the weights for (uint16). - * @param commitHash The commit hash for the weights (uint256). + * @param commitHash The commit hash for the weights (bytes32). */ - function commitWeights(uint16 netuid, uint256 commitHash) external payable; + function commitWeights(uint16 netuid, bytes32 commitHash) external payable; /** * @dev Reveals the weights for a neuron. diff --git a/runtime/src/precompiles/solidity/subnet.abi b/runtime/src/precompiles/solidity/subnet.abi index fd81850b7..3cc16d9df 100644 --- a/runtime/src/precompiles/solidity/subnet.abi +++ b/runtime/src/precompiles/solidity/subnet.abi @@ -148,9 +148,9 @@ "name": "getImmunityPeriod", "outputs": [ { - "internalType": "uint64", + "internalType": "uint16", "name": "", - "type": "uint64" + "type": "uint16" } ], "stateMutability": "view", @@ -243,9 +243,9 @@ "name": "getMaxWeightLimit", "outputs": [ { - "internalType": "uint64", + "internalType": "uint16", "name": "", - "type": "uint64" + "type": "uint16" } ], "stateMutability": "view", @@ -443,39 +443,39 @@ "type": "bytes32" }, { - "internalType": "bytes", + "internalType": "string", "name": "subnetName", - "type": "bytes" + "type": "string" }, { - "internalType": "bytes", + "internalType": "string", "name": "githubRepo", - "type": "bytes" + "type": "string" }, { - "internalType": "bytes", + "internalType": "string", "name": "subnetContact", - "type": "bytes" + "type": "string" }, { - "internalType": "bytes", + "internalType": "string", "name": "subnetUrl", - "type": "bytes" + "type": "string" }, { - "internalType": "bytes", + "internalType": "string", "name": "discord", - "type": "bytes" + "type": "string" }, { - "internalType": "bytes", + "internalType": "string", "name": "description", - "type": "bytes" + "type": "string" }, { - "internalType": "bytes", + "internalType": "string", "name": "additional", - "type": "bytes" + "type": "string" } ], "name": "registerNetwork", @@ -622,9 +622,9 @@ "type": "uint16" }, { - "internalType": "uint64", + "internalType": "uint16", "name": "immunityPeriod", - "type": "uint64" + "type": "uint16" } ], "name": "setImmunityPeriod", @@ -712,9 +712,9 @@ "type": "uint16" }, { - "internalType": "uint64", + "internalType": "uint16", "name": "maxWeightLimit", - "type": "uint64" + "type": "uint16" } ], "name": "setMaxWeightLimit", @@ -884,4 +884,4 @@ "stateMutability": "payable", "type": "function" } -] \ No newline at end of file +] diff --git a/runtime/src/precompiles/solidity/subnet.sol b/runtime/src/precompiles/solidity/subnet.sol index 1afeced49..d5ef0916d 100644 --- a/runtime/src/precompiles/solidity/subnet.sol +++ b/runtime/src/precompiles/solidity/subnet.sol @@ -8,13 +8,13 @@ interface ISubnet { /// Registers a new network with specified subnet name, GitHub repository, and contact information. function registerNetwork( bytes32 hotkey, - bytes memory subnetName, - bytes memory githubRepo, - bytes memory subnetContact, - bytes memory subnetUrl, - bytes memory discord, - bytes memory description, - bytes memory additional + string memory subnetName, + string memory githubRepo, + string memory subnetContact, + string memory subnetUrl, + string memory discord, + string memory description, + string memory additional ) external payable; function getServingRateLimit(uint16 netuid) external view returns (uint64); @@ -61,14 +61,14 @@ interface ISubnet { uint64 adjustmentAlpha ) external payable; - function getMaxWeightLimit(uint16 netuid) external view returns (uint64); + function getMaxWeightLimit(uint16 netuid) external view returns (uint16); function setMaxWeightLimit( uint16 netuid, - uint64 maxWeightLimit + uint16 maxWeightLimit ) external payable; - function getImmunityPeriod(uint16) external view returns (uint64); + function getImmunityPeriod(uint16) external view returns (uint16); function setImmunityPeriod( uint16 netuid, diff --git a/runtime/src/precompiles/staking.rs b/runtime/src/precompiles/staking.rs index 8cc1c879a..848fe8e75 100644 --- a/runtime/src/precompiles/staking.rs +++ b/runtime/src/precompiles/staking.rs @@ -25,173 +25,122 @@ // - Precompile checks the result of do_remove_stake and, in case of a failure, reverts the transaction. // -use crate::precompiles::{ - get_method_id, get_pubkey, get_slice, parse_netuid, try_dispatch_runtime_call, -}; -use crate::{ProxyType, Runtime, RuntimeCall}; use frame_system::RawOrigin; -use pallet_evm::{ - AddressMapping, BalanceConverter, ExitError, ExitSucceed, HashedAddressMapping, - PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileResult, -}; -use sp_core::U256; -use sp_runtime::traits::{BlakeTwo256, Dispatchable, StaticLookup, UniqueSaturatedInto}; +use pallet_evm::{BalanceConverter, ExitError, PrecompileFailure, PrecompileHandle}; +use precompile_utils::EvmResult; +use sp_core::{H256, U256}; use sp_runtime::AccountId32; -use sp_std::vec; - -pub const STAKING_PRECOMPILE_INDEX: u64 = 2049; +use sp_runtime::traits::{Dispatchable, StaticLookup, UniqueSaturatedInto}; -// ss58 public key i.e., the contract sends funds it received to the destination address from the -// method parameter. -const CONTRACT_ADDRESS_SS58: [u8; 32] = [ - 0x26, 0xf4, 0x10, 0x1e, 0x52, 0xb7, 0x57, 0x34, 0x33, 0x24, 0x5b, 0xc3, 0x0a, 0xe1, 0x8b, 0x63, - 0x99, 0x53, 0xd8, 0x41, 0x79, 0x33, 0x03, 0x61, 0x4d, 0xfa, 0xcf, 0xf0, 0x37, 0xf7, 0x12, 0x94, -]; +use crate::precompiles::{PrecompileExt, PrecompileHandleExt, parse_pubkey, try_u16_from_u256}; +use crate::{ProxyType, Runtime, RuntimeCall}; pub struct StakingPrecompile; -impl StakingPrecompile { - pub fn execute(handle: &mut impl PrecompileHandle) -> PrecompileResult { - let txdata = handle.input(); - let method_id = get_slice(txdata, 0, 4)?; - let method_input = txdata - .get(4..) - .map_or_else(vec::Vec::new, |slice| slice.to_vec()); // Avoiding borrowing conflicts - - if method_id == get_method_id("addStake(bytes32,uint256)") { - Self::add_stake(handle, &method_input) - } else if method_id == get_method_id("removeStake(bytes32,uint256,uint256)") { - Self::remove_stake(handle, &method_input) - } else if method_id == get_method_id("getStake(bytes32,bytes32,uint256)") { - Self::get_stake(&method_input) - } else if method_id == get_method_id("addProxy(bytes32)") { - Self::add_proxy(handle, &method_input) - } else if method_id == get_method_id("removeProxy(bytes32)") { - Self::remove_proxy(handle, &method_input) - } else { - Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }) - } - } - - fn add_stake(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); +impl PrecompileExt for StakingPrecompile { + const INDEX: u64 = 2049; + const ADDRESS_SS58: [u8; 32] = [ + 0x26, 0xf4, 0x10, 0x1e, 0x52, 0xb7, 0x57, 0x34, 0x33, 0x24, 0x5b, 0xc3, 0x0a, 0xe1, 0x8b, + 0x63, 0x99, 0x53, 0xd8, 0x41, 0x79, 0x33, 0x03, 0x61, 0x4d, 0xfa, 0xcf, 0xf0, 0x37, 0xf7, + 0x12, 0x94, + ]; +} - let (hotkey, _) = get_pubkey(data)?; - let amount: U256 = handle.context().apparent_value; - let netuid = parse_netuid(data, 0x3E)?; +#[precompile_utils::precompile] +impl StakingPrecompile { + #[precompile::public("addStake(bytes32,uint256)")] + #[precompile::payable] + fn add_stake(handle: &mut impl PrecompileHandle, address: H256, netuid: U256) -> EvmResult<()> { + let account_id = handle.caller_account_id(); + let amount = handle.context().apparent_value; if !amount.is_zero() { Self::transfer_back_to_caller(&account_id, amount)?; } - let amount_sub = - ::BalanceConverter::into_substrate_balance(amount) - .ok_or(ExitError::OutOfFund)?; - - let call = RuntimeCall::SubtensorModule(pallet_subtensor::Call::::add_stake { + let amount_sub = handle.try_convert_apparent_value()?; + let (hotkey, _) = parse_pubkey(address.as_bytes())?; + let netuid = try_u16_from_u256(netuid)?; + let call = pallet_subtensor::Call::::add_stake { hotkey, netuid, amount_staked: amount_sub.unique_saturated_into(), - }); + }; - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(account_id)) } - fn remove_stake(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - let (hotkey, _) = get_pubkey(data)?; - let netuid = parse_netuid(data, 0x5E)?; - - // We have to treat this as uint256 (because of Solidity ABI encoding rules, it pads uint64), - // but this will never exceed 8 bytes, se we will ignore higher bytes and will only use lower - // 8 bytes. - let amount = data - .get(56..64) - .map(U256::from_big_endian) - .ok_or(ExitError::OutOfFund)?; - let amount_sub = - ::BalanceConverter::into_substrate_balance(amount) - .ok_or(ExitError::OutOfFund)?; - - let call = RuntimeCall::SubtensorModule(pallet_subtensor::Call::::remove_stake { + #[precompile::public("removeStake(bytes32,uint256,uint256)")] + fn remove_stake( + handle: &mut impl PrecompileHandle, + address: H256, + amount: U256, + netuid: U256, + ) -> EvmResult<()> { + let account_id = handle.caller_account_id(); + let (hotkey, _) = parse_pubkey(address.as_bytes())?; + let netuid = try_u16_from_u256(netuid)?; + let amount_unstaked = amount.unique_saturated_into(); + let call = pallet_subtensor::Call::::remove_stake { hotkey, netuid, - amount_unstaked: amount_sub.unique_saturated_into(), - }); - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + amount_unstaked, + }; + + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(account_id)) } - fn add_proxy(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - let (delegate, _) = get_pubkey(data)?; + #[precompile::public("addProxy(bytes32)")] + fn add_proxy(handle: &mut impl PrecompileHandle, delegate: H256) -> EvmResult<()> { + let account_id = handle.caller_account_id(); + let (delegate, _) = parse_pubkey(delegate.as_bytes())?; let delegate = ::Lookup::unlookup(delegate); - let call = RuntimeCall::Proxy(pallet_proxy::Call::::add_proxy { + let call = pallet_proxy::Call::::add_proxy { delegate, proxy_type: ProxyType::Staking, delay: 0, - }); + }; - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(account_id)) } - fn remove_proxy(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - let (delegate, _) = get_pubkey(data)?; + #[precompile::public("removeProxy(bytes32)")] + fn remove_proxy(handle: &mut impl PrecompileHandle, delegate: H256) -> EvmResult<()> { + let account_id = handle.caller_account_id(); + let (delegate, _) = parse_pubkey(delegate.as_bytes())?; let delegate = ::Lookup::unlookup(delegate); - let call = RuntimeCall::Proxy(pallet_proxy::Call::::remove_proxy { + let call = pallet_proxy::Call::::remove_proxy { delegate, proxy_type: ProxyType::Staking, delay: 0, - }); + }; - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(account_id)) } - fn get_stake(data: &[u8]) -> PrecompileResult { - let (hotkey, left_data) = get_pubkey(data)?; - let (coldkey, _) = get_pubkey(&left_data)?; - let netuid = parse_netuid(data, 0x5E)?; - + #[precompile::public("getStake(bytes32,bytes32,uint256)")] + #[precompile::view] + fn get_stake( + _: &mut impl PrecompileHandle, + hotkey: H256, + coldkey: H256, + netuid: U256, + ) -> EvmResult { + let (hotkey, _) = parse_pubkey(hotkey.as_bytes())?; + let (coldkey, _) = parse_pubkey(coldkey.as_bytes())?; + let netuid = try_u16_from_u256(netuid)?; let stake = pallet_subtensor::Pallet::::get_stake_for_hotkey_and_coldkey_on_subnet( &hotkey, &coldkey, netuid, ); - // Convert to EVM decimals - let stake_u256 = U256::from(stake); - let stake_eth = - ::BalanceConverter::into_evm_balance(stake_u256) - .ok_or(ExitError::InvalidRange)?; - - // Format output - let mut result = [0_u8; 32]; - U256::to_big_endian(&stake_eth, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + Ok(stake.into()) } fn transfer_back_to_caller( account_id: &AccountId32, amount: U256, ) -> Result<(), PrecompileFailure> { - let smart_contract_account_id: AccountId32 = CONTRACT_ADDRESS_SS58.into(); - + let smart_contract_account_id: AccountId32 = Self::ADDRESS_SS58.into(); let amount_sub = ::BalanceConverter::into_substrate_balance(amount) .ok_or(ExitError::OutOfFund)?; diff --git a/runtime/src/precompiles/subnet.rs b/runtime/src/precompiles/subnet.rs index ee85a3f86..db46b3033 100644 --- a/runtime/src/precompiles/subnet.rs +++ b/runtime/src/precompiles/subnet.rs @@ -1,1319 +1,522 @@ -use crate::precompiles::{ - get_method_id, get_pubkey, get_slice, parse_netuid, try_dispatch_runtime_call, -}; -use crate::{Runtime, RuntimeCall}; +use frame_support::traits::ConstU32; use frame_system::RawOrigin; -use pallet_evm::{ - AddressMapping, ExitError, ExitSucceed, HashedAddressMapping, PrecompileFailure, - PrecompileHandle, PrecompileOutput, PrecompileResult, -}; - -use sp_core::U256; -use sp_runtime::{traits::BlakeTwo256, AccountId32, Vec}; -use sp_std::vec; - -pub const SUBNET_PRECOMPILE_INDEX: u64 = 2051; -// bytes with max lenght 1K -pub const MAX_SINGLE_PARAMETER_SIZE: usize = 1024; -// seven bytes with max lenght 1K -pub const MAX_PARAMETER_SIZE: usize = 7 * MAX_SINGLE_PARAMETER_SIZE; -// ss58 public key i.e., the contract sends funds it received to the destination address from the -#[allow(dead_code)] -const CONTRACT_ADDRESS_SS58: [u8; 32] = [ - 0x3a, 0x86, 0x18, 0xfb, 0xbb, 0x1b, 0xbc, 0x47, 0x86, 0x64, 0xff, 0x53, 0x46, 0x18, 0x0c, 0x35, - 0xd0, 0x9f, 0xac, 0x26, 0xf2, 0x02, 0x70, 0x85, 0xb3, 0x1c, 0x56, 0xc1, 0x06, 0x3c, 0x1c, 0xd3, -]; +use pallet_evm::PrecompileHandle; +use precompile_utils::{EvmResult, prelude::BoundedString}; +use sp_core::H256; + +use crate::Runtime; +use crate::precompiles::{PrecompileExt, PrecompileHandleExt, parse_pubkey}; + pub struct SubnetPrecompile; -impl SubnetPrecompile { - pub fn execute(handle: &mut impl PrecompileHandle) -> PrecompileResult { - let txdata = handle.input(); - if txdata.len() > MAX_PARAMETER_SIZE { - log::error!("the length of subnet call is {} ", txdata.len()); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - let method_id = get_slice(txdata, 0, 4)?; - let method_input = txdata - .get(4..) - .map_or_else(vec::Vec::new, |slice| slice.to_vec()); // Avoiding borrowing conflicts - - match method_id { - id if id - == get_method_id( - "registerNetwork(bytes32,bytes,bytes,bytes,bytes,bytes,bytes,bytes)", - ) => - { - Self::register_network(handle, &method_input) - } - id if id == get_method_id("registerNetwork(bytes32)") => { - Self::register_network(handle, &method_input) - } - - id if id == get_method_id("getServingRateLimit(uint16)") => { - Self::get_serving_rate_limit(&method_input) - } - id if id == get_method_id("setServingRateLimit(uint16,uint64)") => { - Self::set_serving_rate_limit(handle, &method_input) - } - - id if id == get_method_id("getMinDifficulty(uint16)") => { - Self::get_min_difficulty(&method_input) - } - id if id == get_method_id("setMinDifficulty(uint16,uint64)") => { - Self::set_min_difficulty(handle, &method_input) - } - - id if id == get_method_id("getMaxDifficulty(uint16)") => { - Self::get_max_difficulty(&method_input) - } - id if id == get_method_id("setMaxDifficulty(uint16,uint64)") => { - Self::set_max_difficulty(handle, &method_input) - } - - id if id == get_method_id("getWeightsVersionKey(uint16)") => { - Self::get_weights_version_key(&method_input) - } - id if id == get_method_id("setWeightsVersionKey(uint16,uint64)") => { - Self::set_weights_version_key(handle, &method_input) - } - - id if id == get_method_id("getWeightsSetRateLimit(uint16)") => { - Self::get_weights_set_rate_limit(&method_input) - } - id if id == get_method_id("setWeightsSetRateLimit(uint16,uint64)") => { - Self::set_weights_set_rate_limit(handle, &method_input) - } - - id if id == get_method_id("getAdjustmentAlpha(uint16)") => { - Self::get_adjustment_alpha(&method_input) - } - id if id == get_method_id("setAdjustmentAlpha(uint16,uint64)") => { - Self::set_adjustment_alpha(handle, &method_input) - } - - id if id == get_method_id("getMaxWeightLimit(uint16)") => { - Self::get_max_weight_limit(&method_input) - } - id if id == get_method_id("setMaxWeightLimit(uint16,uint64)") => { - Self::set_max_weight_limit(handle, &method_input) - } - - id if id == get_method_id("getImmunityPeriod(uint16)") => { - Self::get_immunity_period(&method_input) - } - id if id == get_method_id("setImmunityPeriod(uint16,uint64)") => { - Self::set_immunity_period(handle, &method_input) - } - - id if id == get_method_id("getMinAllowedWeights(uint16)") => { - Self::get_min_allowed_weights(&method_input) - } - id if id == get_method_id("setMinAllowedWeights(uint16,uint16)") => { - Self::set_min_allowed_weights(handle, &method_input) - } - - id if id == get_method_id("getKappa(uint16)") => Self::get_kappa(&method_input), - id if id == get_method_id("setKappa(uint16,uint16)") => { - Self::set_kappa(handle, &method_input) - } - - id if id == get_method_id("getRho(uint16)") => Self::get_rho(&method_input), - id if id == get_method_id("setRho(uint16,uint16)") => { - Self::set_rho(handle, &method_input) - } - - id if id == get_method_id("getActivityCutoff(uint16)") => { - Self::get_activity_cutoff(&method_input) - } - id if id == get_method_id("setActivityCutoff(uint16,uint16)") => { - Self::set_activity_cutoff(handle, &method_input) - } - - id if id == get_method_id("getNetworkRegistrationAllowed(uint16)") => { - Self::get_network_registration_allowed(&method_input) - } - id if id == get_method_id("setNetworkRegistrationAllowed(uint16,bool)") => { - Self::set_network_registration_allowed(handle, &method_input) - } - - id if id == get_method_id("getNetworkPowRegistrationAllowed(uint16)") => { - Self::get_network_pow_registration_allowed(&method_input) - } - id if id == get_method_id("setNetworkPowRegistrationAllowed(uint16,bool)") => { - Self::set_network_pow_registration_allowed(handle, &method_input) - } - - id if id == get_method_id("getMinBurn(uint16)") => Self::get_min_burn(&method_input), - id if id == get_method_id("setMinBurn(uint16,uint64)") => { - Self::set_min_burn(handle, &method_input) - } - - id if id == get_method_id("getMaxBurn(uint16)") => Self::get_max_burn(&method_input), - id if id == get_method_id("setMaxBurn(uint16,uint64)") => { - Self::set_max_burn(handle, &method_input) - } - - id if id == get_method_id("getDifficulty(uint16)") => { - Self::get_difficulty(&method_input) - } - id if id == get_method_id("setDifficulty(uint16,uint64)") => { - Self::set_difficulty(handle, &method_input) - } - - id if id == get_method_id("getBondsMovingAverage(uint16)") => { - Self::get_bonds_moving_average(&method_input) - } - id if id == get_method_id("setBondsMovingAverage(uint16,uint64)") => { - Self::set_bonds_moving_average(handle, &method_input) - } - - id if id == get_method_id("getCommitRevealWeightsEnabled(uint16)") => { - Self::get_commit_reveal_weights_enabled(&method_input) - } - id if id == get_method_id("setCommitRevealWeightsEnabled(uint16,bool)") => { - Self::set_commit_reveal_weights_enabled(handle, &method_input) - } - - id if id == get_method_id("getLiquidAlphaEnabled(uint16)") => { - Self::get_liquid_alpha_enabled(&method_input) - } - id if id == get_method_id("setLiquidAlphaEnabled(uint16,bool)") => { - Self::set_liquid_alpha_enabled(handle, &method_input) - } - - id if id == get_method_id("getAlphaValues(uint16)") => { - Self::get_alpha_values(&method_input) - } - id if id == get_method_id("setAlphaValues(uint16,uint16,uint16)") => { - Self::set_alpha_values(handle, &method_input) - } - - id if id == get_method_id("getCommitRevealWeightsInterval(uint16)") => { - Self::get_commit_reveal_weights_interval(&method_input) - } - id if id == get_method_id("setCommitRevealWeightsInterval(uint16,uint64)") => { - Self::set_commit_reveal_weights_interval(handle, &method_input) - } - _ => Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }), - } - } +impl PrecompileExt for SubnetPrecompile { + const INDEX: u64 = 2051; + const ADDRESS_SS58: [u8; 32] = [ + 0x3a, 0x86, 0x18, 0xfb, 0xbb, 0x1b, 0xbc, 0x47, 0x86, 0x64, 0xff, 0x53, 0x46, 0x18, 0x0c, + 0x35, 0xd0, 0x9f, 0xac, 0x26, 0xf2, 0x02, 0x70, 0x85, 0xb3, 0x1c, 0x56, 0xc1, 0x06, 0x3c, + 0x1c, 0xd3, + ]; +} - fn register_network(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let call = match data.len() { - 32 => { - let (hotkey, _) = get_pubkey(data)?; - RuntimeCall::SubtensorModule( - pallet_subtensor::Call::::register_network_with_identity { - hotkey, - identity: None, - }, - ) - } - 33.. => { - let ( - hotkey, - subnet_name, - github_repo, - subnet_contact, - subnet_url, - discord, - description, - additional, - ) = Self::parse_register_network_parameters(data)?; - - let identity: pallet_subtensor::SubnetIdentityOfV2 = - pallet_subtensor::SubnetIdentityOfV2 { - subnet_name, - github_repo, - subnet_contact, - subnet_url, - discord, - description, - additional, - }; - - // Create the register_network callcle - RuntimeCall::SubtensorModule( - pallet_subtensor::Call::::register_network_with_identity { - hotkey, - identity: Some(identity), - }, - ) - } - _ => { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } +#[precompile_utils::precompile] +impl SubnetPrecompile { + #[precompile::public("registerNetwork(bytes32)")] + #[precompile::payable] + fn register_network(handle: &mut impl PrecompileHandle, hotkey: H256) -> EvmResult<()> { + let (hotkey, _) = parse_pubkey(hotkey.as_bytes())?; + let call = pallet_subtensor::Call::::register_network_with_identity { + hotkey, + identity: None, }; - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn get_serving_rate_limit(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::ServingRateLimit::::get(netuid); + #[precompile::public( + "registerNetwork(bytes32,string,string,string,string,string,string,string)" + )] + #[precompile::payable] + #[allow(clippy::too_many_arguments)] + fn register_network_with_identity( + handle: &mut impl PrecompileHandle, + hotkey: H256, + subnet_name: BoundedString>, + github_repo: BoundedString>, + subnet_contact: BoundedString>, + subnet_url: BoundedString>, + discord: BoundedString>, + description: BoundedString>, + additional: BoundedString>, + ) -> EvmResult<()> { + let (hotkey, _) = parse_pubkey(hotkey.as_bytes())?; + let identity = pallet_subtensor::SubnetIdentityOfV2 { + subnet_name: subnet_name.into(), + github_repo: github_repo.into(), + subnet_contact: subnet_contact.into(), + subnet_url: subnet_url.into(), + discord: discord.into(), + description: description.into(), + additional: additional.into(), + }; - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + let call = pallet_subtensor::Call::::register_network_with_identity { + hotkey, + identity: Some(identity), + }; - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn set_serving_rate_limit(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, serving_rate_limit) = Self::parse_netuid_u64_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_serving_rate_limit { - netuid, - serving_rate_limit, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + #[precompile::public("getServingRateLimit(uint16)")] + #[precompile::view] + fn get_serving_rate_limit(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::ServingRateLimit::::get(netuid)) } - fn get_min_difficulty(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::MinDifficulty::::get(netuid); - - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + #[precompile::public("setServingRateLimit(uint16,uint64)")] + #[precompile::payable] + fn set_serving_rate_limit( + handle: &mut impl PrecompileHandle, + netuid: u16, + serving_rate_limit: u64, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_serving_rate_limit { + netuid, + serving_rate_limit, + }; - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn set_min_difficulty(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, min_difficulty) = Self::parse_netuid_u64_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_min_difficulty { - netuid, - min_difficulty, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + #[precompile::public("getMinDifficulty(uint16)")] + #[precompile::view] + fn get_min_difficulty(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::MinDifficulty::::get(netuid)) } - fn get_max_difficulty(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::MaxDifficulty::::get(netuid); - - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + #[precompile::public("setMinDifficulty(uint16,uint64)")] + #[precompile::payable] + fn set_min_difficulty( + handle: &mut impl PrecompileHandle, + netuid: u16, + min_difficulty: u64, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_min_difficulty { + netuid, + min_difficulty, + }; - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn set_max_difficulty(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, max_difficulty) = Self::parse_netuid_u64_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_max_difficulty { - netuid, - max_difficulty, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + #[precompile::public("getMaxDifficulty(uint16)")] + #[precompile::view] + fn get_max_difficulty(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::MaxDifficulty::::get(netuid)) } - fn get_weights_version_key(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::WeightsVersionKey::::get(netuid); + #[precompile::public("setMaxDifficulty(uint16,uint64)")] + #[precompile::payable] + fn set_max_difficulty( + handle: &mut impl PrecompileHandle, + netuid: u16, + max_difficulty: u64, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_max_difficulty { + netuid, + max_difficulty, + }; - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) + } - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getWeightsVersionKey(uint16)")] + #[precompile::view] + fn get_weights_version_key(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::WeightsVersionKey::::get(netuid)) } + #[precompile::public("setWeightsVersionKey(uint16,uint64)")] + #[precompile::payable] fn set_weights_version_key( handle: &mut impl PrecompileHandle, - data: &[u8], - ) -> PrecompileResult { - let (netuid, weights_version_key) = Self::parse_netuid_u64_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_weights_version_key { - netuid, - weights_version_key, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } - - fn get_weights_set_rate_limit(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::WeightsSetRateLimit::::get(netuid); + netuid: u16, + weights_version_key: u64, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_weights_version_key { + netuid, + weights_version_key, + }; - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) + } - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getWeightsSetRateLimit(uint16)")] + #[precompile::view] + fn get_weights_set_rate_limit(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::WeightsSetRateLimit::::get( + netuid, + )) } + #[precompile::public("setWeightsSetRateLimit(uint16,uint64)")] + #[precompile::payable] fn set_weights_set_rate_limit( handle: &mut impl PrecompileHandle, - data: &[u8], - ) -> PrecompileResult { - let (netuid, weights_set_rate_limit) = Self::parse_netuid_u64_parameter(data)?; - - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_weights_set_rate_limit { - netuid, - weights_set_rate_limit, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } - - fn get_adjustment_alpha(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::AdjustmentAlpha::::get(netuid); - - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + netuid: u16, + weights_set_rate_limit: u64, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_weights_set_rate_limit { + netuid, + weights_set_rate_limit, + }; - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn set_adjustment_alpha(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, adjustment_alpha) = Self::parse_netuid_u64_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_adjustment_alpha { - netuid, - adjustment_alpha, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + #[precompile::public("getAdjustmentAlpha(uint16)")] + #[precompile::view] + fn get_adjustment_alpha(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::AdjustmentAlpha::::get(netuid)) } - fn get_max_weight_limit(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::MaxWeightsLimit::::get(netuid); - - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + #[precompile::public("setAdjustmentAlpha(uint16,uint64)")] + #[precompile::payable] + fn set_adjustment_alpha( + handle: &mut impl PrecompileHandle, + netuid: u16, + adjustment_alpha: u64, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_adjustment_alpha { + netuid, + adjustment_alpha, + }; - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn set_max_weight_limit(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, max_weight_limit) = Self::parse_netuid_u16_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_max_weight_limit { - netuid, - max_weight_limit, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + #[precompile::public("getMaxWeightLimit(uint16)")] + #[precompile::view] + fn get_max_weight_limit(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::MaxWeightsLimit::::get(netuid)) } - fn get_immunity_period(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::ImmunityPeriod::::get(netuid); - - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + #[precompile::public("setMaxWeightLimit(uint16,uint16)")] + #[precompile::payable] + fn set_max_weight_limit( + handle: &mut impl PrecompileHandle, + netuid: u16, + max_weight_limit: u16, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_max_weight_limit { + netuid, + max_weight_limit, + }; - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn set_immunity_period(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, immunity_period) = Self::parse_netuid_u16_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_immunity_period { - netuid, - immunity_period, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + #[precompile::public("getImmunityPeriod(uint16)")] + #[precompile::view] + fn get_immunity_period(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::ImmunityPeriod::::get(netuid)) } - fn get_min_allowed_weights(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::MinAllowedWeights::::get(netuid); + #[precompile::public("setImmunityPeriod(uint16,uint16)")] + #[precompile::payable] + fn set_immunity_period( + handle: &mut impl PrecompileHandle, + netuid: u16, + immunity_period: u16, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_immunity_period { + netuid, + immunity_period, + }; - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) + } - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getMinAllowedWeights(uint16)")] + #[precompile::view] + fn get_min_allowed_weights(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::MinAllowedWeights::::get(netuid)) } + #[precompile::public("setMinAllowedWeights(uint16,uint16)")] + #[precompile::payable] fn set_min_allowed_weights( handle: &mut impl PrecompileHandle, - data: &[u8], - ) -> PrecompileResult { - let (netuid, min_allowed_weights) = Self::parse_netuid_u16_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_min_allowed_weights { - netuid, - min_allowed_weights, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } - - fn get_kappa(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::Kappa::::get(netuid); - - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) - } - - fn set_kappa(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, kappa) = Self::parse_netuid_u16_parameter(data)?; - let call = RuntimeCall::AdminUtils(pallet_admin_utils::Call::::sudo_set_kappa { + netuid: u16, + min_allowed_weights: u16, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_min_allowed_weights { netuid, - kappa, - }); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); + min_allowed_weights, + }; - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn get_rho(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::Rho::::get(netuid); - - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getKappa(uint16)")] + #[precompile::view] + fn get_kappa(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::Kappa::::get(netuid)) } - fn set_rho(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, rho) = Self::parse_netuid_u16_parameter(data)?; - let call = RuntimeCall::AdminUtils(pallet_admin_utils::Call::::sudo_set_rho { - netuid, - rho, - }); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); + #[precompile::public("setKappa(uint16,uint16)")] + #[precompile::payable] + fn set_kappa(handle: &mut impl PrecompileHandle, netuid: u16, kappa: u16) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_kappa { netuid, kappa }; - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn get_activity_cutoff(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::ActivityCutoff::::get(netuid); + #[precompile::public("getRho(uint16)")] + #[precompile::view] + fn get_rho(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::Rho::::get(netuid)) + } - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + #[precompile::public("setRho(uint16,uint16)")] + #[precompile::payable] + fn set_rho(handle: &mut impl PrecompileHandle, netuid: u16, rho: u16) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_rho { netuid, rho }; - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn set_activity_cutoff(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, activity_cutoff) = Self::parse_netuid_u16_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_activity_cutoff { - netuid, - activity_cutoff, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + #[precompile::public("getActivityCutoff(uint16)")] + #[precompile::view] + fn get_activity_cutoff(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::ActivityCutoff::::get(netuid)) } - fn get_network_registration_allowed(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::NetworkRegistrationAllowed::::get(netuid); + #[precompile::public("setActivityCutoff(uint16,uint16)")] + #[precompile::payable] + fn set_activity_cutoff( + handle: &mut impl PrecompileHandle, + netuid: u16, + activity_cutoff: u16, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_activity_cutoff { + netuid, + activity_cutoff, + }; - let value_u256 = if value { U256::from(1) } else { U256::from(0) }; - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) + } - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getNetworkRegistrationAllowed(uint16)")] + #[precompile::view] + fn get_network_registration_allowed( + _: &mut impl PrecompileHandle, + netuid: u16, + ) -> EvmResult { + Ok(pallet_subtensor::NetworkRegistrationAllowed::::get(netuid)) } + #[precompile::public("setNetworkRegistrationAllowed(uint16,bool)")] + #[precompile::payable] fn set_network_registration_allowed( handle: &mut impl PrecompileHandle, - data: &[u8], - ) -> PrecompileResult { - let (netuid, registration_allowed) = Self::parse_netuid_bool_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_network_registration_allowed { - netuid, - registration_allowed, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } - - fn get_network_pow_registration_allowed(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::NetworkPowRegistrationAllowed::::get(netuid); + netuid: u16, + registration_allowed: bool, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_network_registration_allowed { + netuid, + registration_allowed, + }; - let value_u256 = if value { U256::from(1) } else { U256::from(0) }; - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) + } - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getNetworkPowRegistrationAllowed(uint16)")] + #[precompile::view] + fn get_network_pow_registration_allowed( + _: &mut impl PrecompileHandle, + netuid: u16, + ) -> EvmResult { + Ok(pallet_subtensor::NetworkPowRegistrationAllowed::::get(netuid)) } + #[precompile::public("setNetworkPowRegistrationAllowed(uint16,bool)")] + #[precompile::payable] fn set_network_pow_registration_allowed( handle: &mut impl PrecompileHandle, - data: &[u8], - ) -> PrecompileResult { - let (netuid, registration_allowed) = Self::parse_netuid_bool_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_network_pow_registration_allowed { - netuid, - registration_allowed, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } - - fn get_min_burn(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::MinBurn::::get(netuid); - - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + netuid: u16, + registration_allowed: bool, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_network_pow_registration_allowed { + netuid, + registration_allowed, + }; - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn set_min_burn(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, min_burn) = Self::parse_netuid_u64_parameter(data)?; - let call = - RuntimeCall::AdminUtils(pallet_admin_utils::Call::::sudo_set_min_burn { - netuid, - min_burn, - }); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + #[precompile::public("getMinBurn(uint16)")] + #[precompile::view] + fn get_min_burn(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::MinBurn::::get(netuid)) } - fn get_max_burn(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::MaxBurn::::get(netuid); - - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + #[precompile::public("setMinBurn(uint16,uint64)")] + #[precompile::payable] + fn set_min_burn( + handle: &mut impl PrecompileHandle, + netuid: u16, + min_burn: u64, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_min_burn { netuid, min_burn }; - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn set_max_burn(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, max_burn) = Self::parse_netuid_u64_parameter(data)?; - let call = - RuntimeCall::AdminUtils(pallet_admin_utils::Call::::sudo_set_max_burn { - netuid, - max_burn, - }); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + #[precompile::public("getMaxBurn(uint16)")] + #[precompile::view] + fn get_max_burn(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::MaxBurn::::get(netuid)) } - fn get_difficulty(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::Difficulty::::get(netuid); - - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + #[precompile::public("setMaxBurn(uint16,uint64)")] + #[precompile::payable] + fn set_max_burn( + handle: &mut impl PrecompileHandle, + netuid: u16, + max_burn: u64, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_max_burn { netuid, max_burn }; - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn set_difficulty(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, difficulty) = Self::parse_netuid_u64_parameter(data)?; - let call = - RuntimeCall::AdminUtils(pallet_admin_utils::Call::::sudo_set_difficulty { - netuid, - difficulty, - }); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) + #[precompile::public("getDifficulty(uint16)")] + #[precompile::view] + fn get_difficulty(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::Difficulty::::get(netuid)) } - fn get_bonds_moving_average(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::BondsMovingAverage::::get(netuid); + #[precompile::public("setDifficulty(uint16,uint64)")] + #[precompile::payable] + fn set_difficulty( + handle: &mut impl PrecompileHandle, + netuid: u16, + difficulty: u64, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_difficulty { netuid, difficulty }; - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) + } - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getBondsMovingAverage(uint16)")] + #[precompile::view] + fn get_bonds_moving_average(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::BondsMovingAverage::::get(netuid)) } + #[precompile::public("setBondsMovingAverage(uint16,uint64)")] + #[precompile::payable] fn set_bonds_moving_average( handle: &mut impl PrecompileHandle, - data: &[u8], - ) -> PrecompileResult { - let (netuid, bonds_moving_average) = Self::parse_netuid_u64_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_bonds_moving_average { - netuid, - bonds_moving_average, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } - - fn get_commit_reveal_weights_enabled(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::CommitRevealWeightsEnabled::::get(netuid); + netuid: u16, + bonds_moving_average: u64, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_bonds_moving_average { + netuid, + bonds_moving_average, + }; - let value_u256 = if value { U256::from(1) } else { U256::from(0) }; - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) + } - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getCommitRevealWeightsEnabled(uint16)")] + #[precompile::view] + fn get_commit_reveal_weights_enabled( + _: &mut impl PrecompileHandle, + netuid: u16, + ) -> EvmResult { + Ok(pallet_subtensor::CommitRevealWeightsEnabled::::get(netuid)) } + #[precompile::public("setCommitRevealWeightsEnabled(uint16,bool)")] + #[precompile::payable] fn set_commit_reveal_weights_enabled( handle: &mut impl PrecompileHandle, - data: &[u8], - ) -> PrecompileResult { - let (netuid, enabled) = Self::parse_netuid_bool_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_commit_reveal_weights_enabled { - netuid, - enabled, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } - - fn get_liquid_alpha_enabled(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::LiquidAlphaOn::::get(netuid); + netuid: u16, + enabled: bool, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_commit_reveal_weights_enabled { + netuid, + enabled, + }; - let value_u256 = if value { U256::from(1) } else { U256::from(0) }; - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) + } - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) + #[precompile::public("getLiquidAlphaEnabled(uint16)")] + #[precompile::view] + fn get_liquid_alpha_enabled(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult { + Ok(pallet_subtensor::LiquidAlphaOn::::get(netuid)) } + #[precompile::public("setLiquidAlphaEnabled(uint16,bool)")] + #[precompile::payable] fn set_liquid_alpha_enabled( handle: &mut impl PrecompileHandle, - data: &[u8], - ) -> PrecompileResult { - let (netuid, enabled) = Self::parse_netuid_bool_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_liquid_alpha_enabled { netuid, enabled }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } - - fn get_alpha_values(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let (alpha_low, alpha_high) = pallet_subtensor::AlphaValues::::get(netuid); - - let mut value_u256 = U256::from(alpha_low); - let mut result = [0_u8; 64]; - U256::to_big_endian(&value_u256, &mut result[0..]); - - value_u256 = U256::from(alpha_high); - U256::to_big_endian(&value_u256, &mut result[32..]); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) - } - - fn set_alpha_values(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { - let (netuid, alpha_low, alpha_high) = Self::parse_netuid_u16_u16_parameter(data)?; + netuid: u16, + enabled: bool, + ) -> EvmResult<()> { let call = - RuntimeCall::AdminUtils(pallet_admin_utils::Call::::sudo_set_alpha_values { - netuid, - alpha_low, - alpha_high, - }); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } - - fn get_commit_reveal_weights_interval(data: &[u8]) -> PrecompileResult { - let netuid = parse_netuid(data, 30)?; - - let value = pallet_subtensor::RevealPeriodEpochs::::get(netuid); - - let value_u256 = U256::from(value); - let mut result = [0_u8; 32]; - U256::to_big_endian(&value_u256, &mut result); - - Ok(PrecompileOutput { - exit_status: ExitSucceed::Returned, - output: result.into(), - }) - } - - fn set_commit_reveal_weights_interval( - handle: &mut impl PrecompileHandle, - data: &[u8], - ) -> PrecompileResult { - let (netuid, interval) = Self::parse_netuid_u64_parameter(data)?; - let call = RuntimeCall::AdminUtils( - pallet_admin_utils::Call::::sudo_set_commit_reveal_weights_interval { - netuid, - interval, - }, - ); - - let account_id = - as AddressMapping>::into_account_id( - handle.context().caller, - ); - - try_dispatch_runtime_call(handle, call, RawOrigin::Signed(account_id)) - } + pallet_admin_utils::Call::::sudo_set_liquid_alpha_enabled { netuid, enabled }; - fn parse_register_network_parameters( - data: &[u8], - ) -> Result< - ( - AccountId32, - Vec, - Vec, - Vec, - Vec, - Vec, - Vec, - Vec, - ), - PrecompileFailure, - > { - let (pubkey, dynamic_params) = get_pubkey(data)?; - let dynamic_data_len = dynamic_params.len(); - - let mut buf = [0_u8; 4]; - // get all start points for the data items: name, repo, contact, url, discord, description, additional - buf.copy_from_slice(get_slice(data, 60, 64)?); - let subnet_name_start: usize = u32::from_be_bytes(buf) as usize; - if subnet_name_start > dynamic_data_len { - log::error!( - "the start position of subnet name as {} is too big ", - subnet_name_start - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - buf.copy_from_slice(get_slice(data, 92, 96)?); - let github_repo_start: usize = u32::from_be_bytes(buf) as usize; - if github_repo_start > dynamic_data_len { - log::error!( - "the start position of github repo as {} is too big ", - github_repo_start - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - buf.copy_from_slice(get_slice(data, 124, 128)?); - let subnet_contact_start: usize = u32::from_be_bytes(buf) as usize; - if subnet_contact_start > dynamic_data_len { - log::error!( - "the start position of subnet contact as {} is too big ", - subnet_contact_start - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - buf.copy_from_slice(get_slice(data, 156, 160)?); - let subnet_url_start: usize = u32::from_be_bytes(buf) as usize; - if subnet_url_start > dynamic_data_len { - log::error!( - "the start position of subnet_url as {} is too big ", - subnet_url_start - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - buf.copy_from_slice(get_slice(data, 188, 192)?); - let discord_start: usize = u32::from_be_bytes(buf) as usize; - if discord_start > dynamic_data_len { - log::error!( - "the start position of discord as {} is too big ", - discord_start - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - buf.copy_from_slice(get_slice(data, 220, 224)?); - let description_start: usize = u32::from_be_bytes(buf) as usize; - if description_start > dynamic_data_len { - log::error!( - "the start position of description as {} is too big ", - description_start - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - buf.copy_from_slice(get_slice(data, 252, 256)?); - let additional_start: usize = u32::from_be_bytes(buf) as usize; - if additional_start > dynamic_data_len { - log::error!( - "the start position of additional as {} is too big ", - additional_start - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - // get name - buf.copy_from_slice(get_slice( - data, - subnet_name_start + 28, - subnet_name_start + 32, - )?); - let subnet_name_len: usize = u32::from_be_bytes(buf) as usize; - - if subnet_name_len > MAX_SINGLE_PARAMETER_SIZE { - log::error!( - "the length of subnet name as {} is too big", - subnet_name_len - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let mut name_vec = vec![0; subnet_name_len]; - name_vec.copy_from_slice(get_slice( - data, - subnet_name_start + 32, - subnet_name_start + subnet_name_len + 32, - )?); - - // get repo data - buf.copy_from_slice(get_slice( - data, - github_repo_start + 28, - github_repo_start + 32, - )?); - let github_repo_len: usize = u32::from_be_bytes(buf) as usize; - if github_repo_len > MAX_SINGLE_PARAMETER_SIZE { - log::error!( - "the length of github repo as {} is too big", - github_repo_len - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let mut repo_vec = vec![0; github_repo_len]; - repo_vec.copy_from_slice(get_slice( - data, - github_repo_start + 32, - github_repo_start + github_repo_len + 32, - )?); - - // get contact data - buf.copy_from_slice(get_slice( - data, - subnet_contact_start + 28, - subnet_contact_start + 32, - )?); - let subnet_contact_len: usize = u32::from_be_bytes(buf) as usize; - if subnet_contact_len > MAX_SINGLE_PARAMETER_SIZE { - log::error!( - "the length of subnet contact as {} is too big", - subnet_contact_len - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - - let mut contact_vec = vec![0; subnet_contact_len]; - contact_vec.copy_from_slice(get_slice( - data, - subnet_contact_start + 32, - subnet_contact_start + subnet_contact_len + 32, - )?); - - // get subnet_url - buf.copy_from_slice(get_slice( - data, - subnet_url_start + 28, - subnet_url_start + 32, - )?); - let subnet_url_len: usize = u32::from_be_bytes(buf) as usize; - if subnet_url_len > MAX_SINGLE_PARAMETER_SIZE { - log::error!("the length of subnet_url as {} is too big", subnet_url_len); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - let mut url_vec = vec![0; subnet_url_len]; - url_vec.copy_from_slice(get_slice( - data, - subnet_url_start + 32, - subnet_url_start + subnet_url_len + 32, - )?); - - // get discord - buf.copy_from_slice(get_slice(data, discord_start + 28, discord_start + 32)?); - let discord_len: usize = u32::from_be_bytes(buf) as usize; - if discord_len > MAX_SINGLE_PARAMETER_SIZE { - log::error!("the length of discord as {} is too big", discord_len); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - let mut discord_vec = vec![0; discord_len]; - discord_vec.copy_from_slice(get_slice( - data, - discord_start + 32, - discord_start + discord_len + 32, - )?); - - // get description - buf.copy_from_slice(get_slice( - data, - description_start + 28, - description_start + 32, - )?); - let description_len: usize = u32::from_be_bytes(buf) as usize; - if description_len > MAX_SINGLE_PARAMETER_SIZE { - log::error!( - "the length of description as {} is too big", - description_len - ); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - let mut description_vec = vec![0; description_len]; - description_vec.copy_from_slice(get_slice( - data, - description_start + 32, - description_start + description_len + 32, - )?); - - // get additional - buf.copy_from_slice(get_slice( - data, - additional_start + 28, - additional_start + 32, - )?); - let additional_len: usize = u32::from_be_bytes(buf) as usize; - if additional_len > MAX_SINGLE_PARAMETER_SIZE { - log::error!("the length of additional as {} is too big", additional_len); - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - let mut additional_vec = vec![0; additional_len]; - additional_vec.copy_from_slice(get_slice( - data, - additional_start + 32, - additional_start + additional_len + 32, - )?); - - Ok(( - pubkey, - name_vec, - repo_vec, - contact_vec, - url_vec, - discord_vec, - description_vec, - additional_vec, - )) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn parse_netuid_u64_parameter(data: &[u8]) -> Result<(u16, u64), PrecompileFailure> { - if data.len() < 64 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - let netuid = parse_netuid(data, 30)?; - - let mut parameter_vec = [0u8; 8]; - parameter_vec.copy_from_slice(get_slice(data, 56, 64)?); - let parameter = u64::from_be_bytes(parameter_vec); - - Ok((netuid, parameter)) + #[precompile::public("getAlphaValues(uint16)")] + #[precompile::view] + fn get_alpha_values(_: &mut impl PrecompileHandle, netuid: u16) -> EvmResult<(u16, u16)> { + Ok(pallet_subtensor::AlphaValues::::get(netuid)) } - fn parse_netuid_u16_parameter(data: &[u8]) -> Result<(u16, u16), PrecompileFailure> { - if data.len() < 64 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - let netuid = parse_netuid(data, 30)?; - - let mut parameter_vec = [0u8; 2]; - parameter_vec.copy_from_slice(get_slice(data, 62, 64)?); - let parameter = u16::from_be_bytes(parameter_vec); + #[precompile::public("setAlphaValues(uint16,uint16,uint16)")] + #[precompile::payable] + fn set_alpha_values( + handle: &mut impl PrecompileHandle, + netuid: u16, + alpha_low: u16, + alpha_high: u16, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_alpha_values { + netuid, + alpha_low, + alpha_high, + }; - Ok((netuid, parameter)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } - fn parse_netuid_u16_u16_parameter(data: &[u8]) -> Result<(u16, u16, u16), PrecompileFailure> { - if data.len() < 96 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - let netuid = parse_netuid(data, 30)?; - - let mut parameter_1_vec = [0u8; 2]; - parameter_1_vec.copy_from_slice(get_slice(data, 62, 64)?); - let parameter_1 = u16::from_be_bytes(parameter_1_vec); - - let mut parameter_2_vec = [0u8; 2]; - parameter_2_vec.copy_from_slice(get_slice(data, 94, 96)?); - let parameter_2 = u16::from_be_bytes(parameter_2_vec); - - Ok((netuid, parameter_1, parameter_2)) + #[precompile::public("getCommitRevealWeightsInterval(uint16)")] + #[precompile::view] + fn get_commit_reveal_weights_interval( + _: &mut impl PrecompileHandle, + netuid: u16, + ) -> EvmResult { + Ok(pallet_subtensor::RevealPeriodEpochs::::get(netuid)) } - fn parse_netuid_bool_parameter(data: &[u8]) -> Result<(u16, bool), PrecompileFailure> { - if data.len() < 64 { - return Err(PrecompileFailure::Error { - exit_status: ExitError::InvalidRange, - }); - } - let netuid = parse_netuid(data, 30)?; - - let mut parameter_vec = [0_u8]; - parameter_vec.copy_from_slice(get_slice(data, 63, 64)?); - - let parameter = parameter_vec[0] != 0; + #[precompile::public("setCommitRevealWeightsInterval(uint16,uint64)")] + #[precompile::payable] + fn set_commit_reveal_weights_interval( + handle: &mut impl PrecompileHandle, + netuid: u16, + interval: u64, + ) -> EvmResult<()> { + let call = pallet_admin_utils::Call::::sudo_set_commit_reveal_weights_interval { + netuid, + interval, + }; - Ok((netuid, parameter)) + handle.try_dispatch_runtime_call(call, RawOrigin::Signed(handle.caller_account_id())) } } diff --git a/runtime/tests/pallet_proxy.rs b/runtime/tests/pallet_proxy.rs index 2cfbd908b..7d0dec967 100644 --- a/runtime/tests/pallet_proxy.rs +++ b/runtime/tests/pallet_proxy.rs @@ -1,7 +1,7 @@ #![allow(clippy::unwrap_used)] use codec::Encode; -use frame_support::{assert_ok, traits::InstanceFilter, BoundedVec}; +use frame_support::{BoundedVec, assert_ok, traits::InstanceFilter}; use node_subtensor_runtime::{ AccountId, BalancesCall, BuildStorage, Proxy, ProxyType, Runtime, RuntimeCall, RuntimeEvent, RuntimeGenesisConfig, RuntimeOrigin, SubtensorModule, System, SystemCall, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b8e64e100..49405bc64 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.84.0" +channel = "1.85.0" components = [ "cargo", "clippy", diff --git a/scripts/run/subtensor.sh b/scripts/run/subtensor.sh index 05baa7a76..cdc37c901 100755 --- a/scripts/run/subtensor.sh +++ b/scripts/run/subtensor.sh @@ -44,7 +44,7 @@ function run_command() { --chain ./chainspecs/raw_spec_finney.json \ --rpc-external --rpc-cors all \ --no-mdns \ - --rpc-max-connections 10000 --in-peers 500 --out-peers 500 \ + --rpc-max-connections 10000 \ $SPECIFIC_OPTIONS } diff --git a/support/linting/Cargo.toml b/support/linting/Cargo.toml index 4378ca9dd..a74f77be2 100644 --- a/support/linting/Cargo.toml +++ b/support/linting/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "subtensor-linting" version = "0.1.0" -edition = "2021" +edition = "2024" [dependencies] syn.workspace = true diff --git a/support/linting/src/forbid_as_primitive.rs b/support/linting/src/forbid_as_primitive.rs index 2af8e0132..228b978ef 100644 --- a/support/linting/src/forbid_as_primitive.rs +++ b/support/linting/src/forbid_as_primitive.rs @@ -1,5 +1,5 @@ use super::*; -use syn::{visit::Visit, ExprMethodCall, File, Ident}; +use syn::{ExprMethodCall, File, Ident, visit::Visit}; pub struct ForbidAsPrimitiveConversion; diff --git a/support/linting/src/forbid_keys_remove.rs b/support/linting/src/forbid_keys_remove.rs index e7e5011b1..204020fa2 100644 --- a/support/linting/src/forbid_keys_remove.rs +++ b/support/linting/src/forbid_keys_remove.rs @@ -1,7 +1,7 @@ use super::*; use syn::{ - punctuated::Punctuated, spanned::Spanned, token::Comma, visit::Visit, Expr, ExprCall, ExprPath, - File, Path, + Expr, ExprCall, ExprPath, File, Path, punctuated::Punctuated, spanned::Spanned, token::Comma, + visit::Visit, }; pub struct ForbidKeysRemoveCall; diff --git a/support/linting/src/pallet_index.rs b/support/linting/src/pallet_index.rs index 072f632b7..434309bc3 100644 --- a/support/linting/src/pallet_index.rs +++ b/support/linting/src/pallet_index.rs @@ -2,7 +2,7 @@ use super::*; use proc_macro2::TokenStream as TokenStream2; use procedural_fork::exports::construct_runtime::parse::RuntimeDeclaration; use quote::ToTokens; -use syn::{visit::Visit, File}; +use syn::{File, visit::Visit}; pub struct RequireExplicitPalletIndex; diff --git a/support/linting/src/require_freeze_struct.rs b/support/linting/src/require_freeze_struct.rs index 8f02e2697..a1d86109e 100644 --- a/support/linting/src/require_freeze_struct.rs +++ b/support/linting/src/require_freeze_struct.rs @@ -1,7 +1,7 @@ use super::*; use syn::{ - parse_quote, punctuated::Punctuated, visit::Visit, Attribute, File, ItemStruct, Meta, MetaList, - Path, Token, + Attribute, File, ItemStruct, Meta, MetaList, Path, Token, parse_quote, punctuated::Punctuated, + visit::Visit, }; pub struct RequireFreezeStruct; diff --git a/support/macros/Cargo.toml b/support/macros/Cargo.toml index b5a5febad..e9acb21ab 100644 --- a/support/macros/Cargo.toml +++ b/support/macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "subtensor-macros" version = "0.1.0" -edition = "2021" +edition = "2024" license = "MIT" description = "support macros for Subtensor" diff --git a/support/macros/src/lib.rs b/support/macros/src/lib.rs index 97dd76082..91b5ed2a7 100644 --- a/support/macros/src/lib.rs +++ b/support/macros/src/lib.rs @@ -1,7 +1,7 @@ use proc_macro::TokenStream; use proc_macro2::TokenStream as TokenStream2; use quote::ToTokens; -use syn::{parse2, visit_mut::visit_item_struct_mut, Error, ItemStruct, LitStr, Result}; +use syn::{Error, ItemStruct, LitStr, Result, parse2, visit_mut::visit_item_struct_mut}; mod visitor; use visitor::*; @@ -44,9 +44,12 @@ fn freeze_struct_impl( let calculated_hash_hex = format!("{:x}", calculated_hash); if attr.is_empty() { - return Err(Error::new_spanned(item, - format!("You must provide a hashcode in the `freeze_struct` attribute to freeze this struct.\n\n\ - expected hashcode: `#[freeze_struct(\"{calculated_hash_hex}\")]`"), + return Err(Error::new_spanned( + item, + format!( + "You must provide a hashcode in the `freeze_struct` attribute to freeze this struct.\n\n\ + expected hashcode: `#[freeze_struct(\"{calculated_hash_hex}\")]`" + ), )); } @@ -54,7 +57,8 @@ fn freeze_struct_impl( let provided_hash_hex = parsed_attr.value().to_lowercase(); if provided_hash_hex != calculated_hash_hex { - return Err(Error::new_spanned(item, + return Err(Error::new_spanned( + item, format!( "You have made a non-trivial change to this struct and the provided hashcode no longer matches:\n{} != {}\n\n\ If this was intentional, please update the hashcode in the `freeze_struct` attribute to:\n\ diff --git a/support/tools/Cargo.toml b/support/tools/Cargo.toml index 2e15929d7..ab8506ffa 100644 --- a/support/tools/Cargo.toml +++ b/support/tools/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "subtensor-tools" version = "0.1.0" -edition = "2021" +edition = "2024" license = "MIT" description = "support tools for Subtensor"