Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions tests/e2e_tests/test_commit_reveal_v3.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import re
import time

import numpy as np
import pytest
from bittensor.utils.btlogging import logging
from bittensor.utils.balance import Balance
from bittensor.utils.weight_utils import convert_weights_and_uids_for_emit
from tests.e2e_tests.utils.chain_interactions import (
sudo_set_admin_utils,
sudo_set_hyperparameter_bool,
sudo_set_hyperparameter_values,
wait_interval,
next_tempo,
)
Expand Down Expand Up @@ -57,14 +54,16 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
logging.console.info("Commit reveal enabled")

# Change the weights rate limit on the subnet
assert sudo_set_hyperparameter_values(
status, error = sudo_set_admin_utils(
local_chain,
alice_wallet,
call_function="sudo_set_weights_set_rate_limit",
call_params={"netuid": netuid, "weights_set_rate_limit": "0"},
return_error_message=True,
)

assert error is None
assert status is True

# Verify weights rate limit was changed
assert (
subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0
Expand All @@ -81,7 +80,6 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
alice_wallet,
call_function="sudo_set_tempo",
call_params={"netuid": netuid, "tempo": tempo_set},
return_error_message=True,
)[0]
is True
)
Expand Down
16 changes: 10 additions & 6 deletions tests/e2e_tests/test_commit_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from tests.e2e_tests.utils.chain_interactions import (
sudo_set_admin_utils,
sudo_set_hyperparameter_bool,
sudo_set_hyperparameter_values,
wait_epoch,
)

Expand Down Expand Up @@ -54,15 +53,18 @@ async def test_commit_and_reveal_weights_legacy(local_chain, subtensor, alice_wa
assert (
subtensor.weights_rate_limit(netuid=netuid) > 0
), "Weights rate limit is below 0"

# Lower the rate limit
assert sudo_set_hyperparameter_values(
status, error = sudo_set_admin_utils(
local_chain,
alice_wallet,
call_function="sudo_set_weights_set_rate_limit",
call_params={"netuid": netuid, "weights_set_rate_limit": "0"},
return_error_message=True,
)

assert error is None
assert status is True

assert (
subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0
), "Failed to set weights_rate_limit"
Expand All @@ -77,7 +79,6 @@ async def test_commit_and_reveal_weights_legacy(local_chain, subtensor, alice_wa
"netuid": netuid,
"tempo": 100,
},
return_error_message=True,
)

# Commit-reveal values
Expand Down Expand Up @@ -192,15 +193,18 @@ async def test_commit_weights_uses_next_nonce(local_chain, subtensor, alice_wall
assert (
subtensor.weights_rate_limit(netuid=netuid) > 0
), "Weights rate limit is below 0"

# Lower the rate limit
assert sudo_set_hyperparameter_values(
status, error = sudo_set_admin_utils(
local_chain,
alice_wallet,
call_function="sudo_set_weights_set_rate_limit",
call_params={"netuid": netuid, "weights_set_rate_limit": "0"},
return_error_message=True,
)

assert error is None
assert status is True

assert (
subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0
), "Failed to set weights_rate_limit"
Expand Down
1 change: 0 additions & 1 deletion tests/e2e_tests/test_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ def test_nominator_min_required_stake(local_chain, subtensor, alice_wallet, bob_
call_params={
"min_stake": "100000000000000",
},
return_error_message=True,
)

minimum_required_stake = subtensor.get_minimum_required_stake()
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e_tests/test_dendrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from bittensor.utils.btlogging import logging
from tests.e2e_tests.utils.chain_interactions import (
sudo_set_admin_utils,
sudo_set_hyperparameter_values,
wait_epoch,
)

Expand Down Expand Up @@ -44,21 +43,22 @@ async def test_dendrite(local_chain, subtensor, templates, alice_wallet, bob_wal
"netuid": netuid,
"max_allowed_validators": 1,
},
return_error_message=True,
)

# update weights_set_rate_limit for fast-blocks
assert sudo_set_hyperparameter_values(
status, error = sudo_set_admin_utils(
local_chain,
alice_wallet,
call_function="sudo_set_weights_set_rate_limit",
call_params={
"netuid": netuid,
"weights_set_rate_limit": 10,
},
return_error_message=True,
)

assert error is None
assert status is True

# Register Bob to the network
assert subtensor.burned_register(
bob_wallet, netuid
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e_tests/test_hotkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ async def test_children(subtensor, alice_wallet, bob_wallet):
assert error == ""
assert success is True

subtensor.wait_for_block(subtensor.block + SET_CHILDREN_COOLDOWN_PERIOD)

await wait_epoch(subtensor, netuid=1)

success, children, error = subtensor.get_children(
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e_tests/test_incentive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from tests.e2e_tests.utils.chain_interactions import (
sudo_set_hyperparameter_values,
sudo_set_admin_utils,
wait_epoch,
)

Expand Down Expand Up @@ -66,18 +66,20 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa
assert bob_neuron.trust == 0

# update weights_set_rate_limit for fast-blocks
assert sudo_set_hyperparameter_values(
status, error = sudo_set_admin_utils(
local_chain,
alice_wallet,
call_function="sudo_set_weights_set_rate_limit",
call_params={"netuid": netuid, "weights_set_rate_limit": 10},
return_error_message=True,
)

assert error is None
assert status is True

async with templates.miner(bob_wallet, netuid):
async with templates.validator(alice_wallet, netuid) as validator:
# wait for the Validator to process and set_weights
async with asyncio.timeout(15):
async with asyncio.timeout(60):
await validator.set_weights.wait()

# Wait few epochs
Expand Down
10 changes: 5 additions & 5 deletions tests/e2e_tests/test_set_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from bittensor.utils.weight_utils import convert_weights_and_uids_for_emit
from tests.e2e_tests.utils.chain_interactions import (
sudo_set_hyperparameter_bool,
sudo_set_hyperparameter_values,
sudo_set_admin_utils,
wait_epoch,
)
Expand Down Expand Up @@ -35,15 +34,13 @@ async def test_set_weights_uses_next_nonce(local_chain, subtensor, alice_wallet)
alice_wallet,
call_function="sudo_set_network_rate_limit",
call_params={"rate_limit": "0"}, # No limit
return_error_message=True,
)
# Set lock reduction interval
sudo_set_admin_utils(
local_chain,
alice_wallet,
call_function="sudo_set_lock_reduction_interval",
call_params={"interval": "1"}, # 1 block # reduce lock every block
return_error_message=True,
)

# Try to register the subnets
Expand Down Expand Up @@ -84,15 +81,18 @@ async def test_set_weights_uses_next_nonce(local_chain, subtensor, alice_wallet)
assert (
subtensor.weights_rate_limit(netuid=netuid) > 0
), "Weights rate limit is below 0"

# Lower the rate limit
assert sudo_set_hyperparameter_values(
status, error = sudo_set_admin_utils(
local_chain,
alice_wallet,
call_function="sudo_set_weights_set_rate_limit",
call_params={"netuid": netuid, "weights_set_rate_limit": "0"},
return_error_message=True,
)

assert error is None
assert status is True

assert (
subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0
), "Failed to set weights_rate_limit"
Expand Down
11 changes: 3 additions & 8 deletions tests/e2e_tests/utils/chain_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ def sudo_set_admin_utils(
wallet: "Wallet",
call_function: str,
call_params: dict,
return_error_message: bool = False,
) -> tuple[bool, str]:
) -> tuple[bool, Optional[dict]]:
"""
Wraps the call in sudo to set hyperparameter values using AdminUtils.

Expand All @@ -160,10 +159,9 @@ def sudo_set_admin_utils(
wallet (Wallet): Wallet object with the keypair for signing.
call_function (str): The AdminUtils function to call.
call_params (dict): Parameters for the AdminUtils function.
return_error_message (bool): If True, returns the error message along with the success status.

Returns:
Union[bool, tuple[bool, Optional[str]]]: Success status or (success status, error message).
tuple[bool, Optional[dict]]: (success status, error details).
"""
inner_call = substrate.compose_call(
call_module="AdminUtils",
Expand All @@ -185,10 +183,7 @@ def sudo_set_admin_utils(
wait_for_finalization=True,
)

if return_error_message:
return response.is_success, response.error_message

return response.is_success, ""
return response.is_success, response.error_message


async def root_set_subtensor_hyperparameter_values(
Expand Down
Loading