Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

two arguments for create network extrinsic #2372

Open
wants to merge 27 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion tests/e2e_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ def wait_for_node_start(process, pattern):

# uninstall templates
logging.info("uninstalling neuron templates")
uninstall_templates(template_path)
uninstall_templates(template_path)
3 changes: 2 additions & 1 deletion tests/e2e_tests/test_axon.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ async def test_axon(local_chain):

print("Testing test_axon")

netuid = 1
netuid = 2
# Register root as Alice - the subnet owner
alice_keypair, wallet = setup_wallet("//Alice")

# Register a subnet, netuid 2
subtensor = Subtensor(network="ws://localhost:9945")

# Register a subnet, netuid 1
Expand Down
33 changes: 22 additions & 11 deletions tests/e2e_tests/test_commit_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
register_subnet,
sudo_set_hyperparameter_bool,
sudo_set_hyperparameter_values,
wait_epoch,
wait_interval,
)
from tests.e2e_tests.utils.e2e_test_utils import setup_wallet
Expand All @@ -31,15 +32,15 @@ async def test_commit_and_reveal_weights(local_chain):
Raises:
AssertionError: If any of the checks or verifications fail
"""
netuid = 1
netuid = 2
print("Testing test_commit_and_reveal_weights")
# Register root as Alice
keypair, alice_wallet = setup_wallet("//Alice")
assert register_subnet(local_chain, alice_wallet), "Unable to register the subnet"

# Verify subnet 1 created successfully
assert local_chain.query(
"SubtensorModule", "NetworksAdded", [1]
"SubtensorModule", "NetworksAdded", [netuid]
).serialize(), "Subnet wasn't created successfully"

subtensor = Subtensor(network="ws://localhost:9945")
Expand All @@ -50,7 +51,7 @@ async def test_commit_and_reveal_weights(local_chain):
), "Unable to register Alice as a neuron"

# Stake to become to top neuron after the first epoch
add_stake(local_chain, alice_wallet, Balance.from_tao(100_000))
add_stake(local_chain, alice_wallet, netuid, Balance.from_tao(100_000))

# Enable commit_reveal on the subnet
assert sudo_set_hyperparameter_bool(
Expand Down Expand Up @@ -84,6 +85,16 @@ async def test_commit_and_reveal_weights(local_chain):
assert (
subtensor.weights_rate_limit(netuid=netuid) > 0
), "Weights rate limit is below 0"

# Lower commit period
assert sudo_set_hyperparameter_values(
local_chain,
alice_wallet,
call_function="sudo_set_commit_reveal_weights_interval",
call_params={"netuid": netuid, "interval": "1"},
return_error_message=True,
)

# Lower the rate limit
assert sudo_set_hyperparameter_values(
local_chain,
Expand Down Expand Up @@ -126,20 +137,21 @@ async def test_commit_and_reveal_weights(local_chain):
)
# Assert that the committed weights are set correctly
assert weight_commits.value is not None, "Weight commit not found in storage"
commit_hash, commit_block, reveal_block, expire_block = weight_commits.value[0]
commit_queue = weight_commits.value
commit_hash = commit_queue[0]
commit_block = commit_queue[0][1]

assert commit_block > 0, f"Invalid block number: {commit_block}"

# Query the WeightCommitRevealInterval storage map
reveal_periods = subtensor.query_module(
weight_commit_reveal_interval = subtensor.query_module(
module="SubtensorModule", name="RevealPeriodEpochs", params=[netuid]
)
periods = reveal_periods.value

periods = weight_commit_reveal_interval.value
assert periods > 0, "Invalid RevealPeriodEpochs"

# Wait until the reveal block range
await wait_interval(
subtensor.get_subnet_hyperparameters(netuid=netuid).tempo, subtensor
)
await wait_epoch(subtensor, netuid=netuid)

# Reveal weights
success, message = subtensor.reveal_weights(
Expand All @@ -165,7 +177,6 @@ async def test_commit_and_reveal_weights(local_chain):

# Assert that the revealed weights are set correctly
assert revealed_weights.value is not None, "Weight reveal not found in storage"

assert (
weight_vals[0] == revealed_weights.value[0][1]
), f"Incorrect revealed weights. Expected: {weights[0]}, Actual: {revealed_weights.value[0][1]}"
Expand Down
22 changes: 11 additions & 11 deletions tests/e2e_tests/test_dendrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def test_dendrite(local_chain):
"""

logging.console.info("Testing test_dendrite")
netuid = 1
netuid = 2

# Register root as Alice - the subnet owner
alice_keypair, alice_wallet = setup_wallet("//Alice")
Expand All @@ -61,25 +61,25 @@ async def test_dendrite(local_chain):
metagraph = Metagraph(netuid=netuid, network="ws://localhost:9945")

# Assert one neuron is Bob
assert len(subtensor.neurons(netuid=netuid)) == 1
neuron = metagraph.neurons[0]
assert len(subtensor.neurons(netuid=netuid)) == 2
neuron = metagraph.neurons[1]
assert neuron.hotkey == bob_keypair.ss58_address
assert neuron.coldkey == bob_keypair.ss58_address

# Assert stake is 0
assert neuron.stake.tao == 0

# Stake to become to top neuron after the first epoch
assert add_stake(local_chain, bob_wallet, Balance.from_tao(10_000))
assert add_stake(local_chain, bob_wallet, netuid, Balance.from_tao(10_000))

# Refresh metagraph
metagraph = Metagraph(netuid=netuid, network="ws://localhost:9945")
old_neuron = metagraph.neurons[0]
old_neuron = metagraph.neurons[1]

# Assert stake is 10000
assert (
old_neuron.stake.tao == 10_000.0
), f"Expected 10_000.0 staked TAO, but got {neuron.stake.tao}"
# Assert stake is 10000 can't compare anymore. the stake value is the alpha now.
# assert (
# old_neuron.stake.tao == 10_000.0
# ), f"Expected 10_000.0 staked TAO, but got {neuron.stake.tao}"

# Assert neuron is not a validator yet
assert old_neuron.active is True
Expand Down Expand Up @@ -124,9 +124,9 @@ async def test_dendrite(local_chain):
metagraph = Metagraph(netuid=netuid, network="ws://localhost:9945")

# Refresh validator neuron
updated_neuron = metagraph.neurons[0]
updated_neuron = metagraph.neurons[1]

assert len(metagraph.neurons) == 1
assert len(metagraph.neurons) == 2
assert updated_neuron.active is True
assert updated_neuron.validator_permit is True
assert updated_neuron.hotkey == bob_keypair.ss58_address
Expand Down
20 changes: 11 additions & 9 deletions tests/e2e_tests/test_incentive.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def test_incentive(local_chain):
"""

print("Testing test_incentive")
netuid = 1
netuid = 2

# Register root as Alice - the subnet owner and validator
alice_keypair, alice_wallet = setup_wallet("//Alice")
Expand All @@ -55,9 +55,10 @@ async def test_incentive(local_chain):
subtensor = Subtensor(network="ws://localhost:9945")

# Register Alice as a neuron on the subnet
assert subtensor.burned_register(
alice_wallet, netuid
), "Unable to register Alice as a neuron"
# register_neuron(local_chain, alice_wallet, netuid)
# assert subtensor.burned_register(
# alice_wallet, netuid
# ), "Unable to register Alice as a neuron"

# Register Bob as a neuron on the subnet
assert subtensor.burned_register(
Expand All @@ -70,7 +71,7 @@ async def test_incentive(local_chain):
), "Alice & Bob not registered in the subnet"

# Alice to stake to become to top neuron after the first epoch
add_stake(local_chain, alice_wallet, Balance.from_tao(10_000))
add_stake(local_chain, alice_wallet, netuid, Balance.from_tao(10_000))

# Prepare to run Bob as miner
cmd = " ".join(
Expand Down Expand Up @@ -149,11 +150,12 @@ async def test_incentive(local_chain):
alice_neuron = metagraph.neurons[0]
assert alice_neuron.validator_permit is False
assert alice_neuron.dividends == 0
assert alice_neuron.stake.tao == 10_000.0

# assert alice_neuron.stake.tao == 10_000.0
assert alice_neuron.validator_trust == 0

# Wait until next epoch
await wait_epoch(subtensor)
await wait_epoch(subtensor, netuid = netuid)

# Set weights by Alice on the subnet
do_set_weights(
Expand All @@ -169,7 +171,7 @@ async def test_incentive(local_chain):
)
print("Alice neuron set weights successfully")

await wait_epoch(subtensor)
await wait_epoch(subtensor, netuid = netuid)

# Refresh metagraph
metagraph = Metagraph(netuid=netuid, network="ws://localhost:9945")
Expand All @@ -184,7 +186,7 @@ async def test_incentive(local_chain):
alice_neuron = metagraph.neurons[0]
assert alice_neuron.validator_permit is True
assert alice_neuron.dividends == 1
assert alice_neuron.stake.tao == 10_000.0
# assert alice_neuron.stake.tao == 10_000.0
assert alice_neuron.validator_trust == 1

print("✅ Passed test_incentive")
20 changes: 14 additions & 6 deletions tests/e2e_tests/test_liquid_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ def test_liquid_alpha(local_chain):
AssertionError: If any of the checks or verifications fail
"""
u16_max = 65535
<<<<<<< HEAD
netuid = 2
logging.info("Testing test_liquid_alpha_enabled")
=======
netuid = 1
logging.console.info("Testing test_liquid_alpha_enabled")
>>>>>>> staging

# Register root as Alice
keypair, alice_wallet = setup_wallet("//Alice")
Expand All @@ -43,14 +48,17 @@ def test_liquid_alpha(local_chain):
# Verify subnet 1 created successfully
assert local_chain.query("SubtensorModule", "NetworksAdded", [1]).serialize()

<<<<<<< HEAD
=======
# Register a neuron (Alice) to the subnet
subtensor = Subtensor(network="ws://localhost:9945")
assert subtensor.burned_register(
alice_wallet, netuid
), "Unable to register Alice as a neuron"

>>>>>>> staging
# Stake to become to top neuron after the first epoch
add_stake(local_chain, alice_wallet, Balance.from_tao(100_000))
add_stake(local_chain, alice_wallet, netuid, Balance.from_tao(100_000))

# Assert liquid alpha is disabled
assert (
Expand All @@ -77,7 +85,7 @@ def test_liquid_alpha(local_chain):
), "Unable to enable liquid alpha"

assert subtensor.get_subnet_hyperparameters(
netuid=1
netuid=netuid,
).liquid_alpha_enabled, "Failed to enable liquid alpha"

# Attempt to set alpha high & low after enabling the hyperparameter
Expand All @@ -90,10 +98,10 @@ def test_liquid_alpha(local_chain):
call_params=call_params,
), "Unable to set alpha_values"
assert (
subtensor.get_subnet_hyperparameters(netuid=1).alpha_high == 54099
subtensor.get_subnet_hyperparameters(netuid=netuid).alpha_high == 54099
), "Failed to set alpha high"
assert (
subtensor.get_subnet_hyperparameters(netuid=1).alpha_low == 87
subtensor.get_subnet_hyperparameters(netuid=netuid).alpha_low == 87
), "Failed to set alpha low"

# Testing alpha high upper and lower bounds
Expand Down Expand Up @@ -169,10 +177,10 @@ def test_liquid_alpha(local_chain):
), "Unable to set liquid alpha values"

assert (
subtensor.get_subnet_hyperparameters(netuid=1).alpha_high == 53083
subtensor.get_subnet_hyperparameters(netuid=netuid).alpha_high == 53083
), "Failed to set alpha high"
assert (
subtensor.get_subnet_hyperparameters(netuid=1).alpha_low == 6553
subtensor.get_subnet_hyperparameters(netuid=netuid).alpha_low == 6553
), "Failed to set alpha low"

# Disable Liquid Alpha
Expand Down
Loading
Loading