Skip to content

Commit d32cd83

Browse files
authored
Merge branch 'staging' into fix/e2e-test-incentive
2 parents a25bb64 + 80634e0 commit d32cd83

File tree

8 files changed

+68
-42
lines changed

8 files changed

+68
-42
lines changed

bittensor/core/async_subtensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ async def get_all_commitments(
999999
)
10001000
result = {}
10011001
async for id_, value in query:
1002-
result[decode_account_id(id_[0])] = decode_account_id(value)
1002+
result[decode_account_id(id_[0])] = decode_metadata(value)
10031003
return result
10041004

10051005
async def get_current_weight_commit_info(

bittensor/core/extrinsics/asyncex/staking.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -314,20 +314,6 @@ async def add_stake_multiple_extrinsic(
314314
if staking_response is True: # If we successfully staked.
315315
# We only wait here if we expect finalization.
316316

317-
if idx < len(hotkey_ss58s) - 1:
318-
# Wait for tx rate limit.
319-
tx_query = await subtensor.substrate.query(
320-
module="SubtensorModule", storage_function="TxRateLimit"
321-
)
322-
tx_rate_limit_blocks: int = getattr(tx_query, "value", 0)
323-
if tx_rate_limit_blocks > 0:
324-
logging.error(
325-
f":hourglass: [yellow]Waiting for tx rate limit: [white]{tx_rate_limit_blocks}[/white] "
326-
f"blocks[/yellow]"
327-
)
328-
# 12 seconds per block
329-
await asyncio.sleep(tx_rate_limit_blocks * 12)
330-
331317
if not wait_for_finalization and not wait_for_inclusion:
332318
old_balance -= staking_balance
333319
successful_stakes += 1

bittensor/core/extrinsics/asyncex/unstaking.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,6 @@ async def unstake_multiple_extrinsic(
281281
if staking_response is True: # If we successfully unstaked.
282282
# We only wait here if we expect finalization.
283283

284-
if idx < len(hotkey_ss58s) - 1:
285-
# Wait for tx rate limit.
286-
tx_rate_limit_blocks = await subtensor.tx_rate_limit()
287-
if tx_rate_limit_blocks > 0:
288-
logging.info(
289-
f":hourglass: [yellow]Waiting for tx rate limit: "
290-
f"[white]{tx_rate_limit_blocks}[/white] blocks[/yellow]"
291-
)
292-
await asyncio.sleep(
293-
tx_rate_limit_blocks * 12
294-
) # 12 seconds per block
295-
296284
if not wait_for_finalization and not wait_for_inclusion:
297285
successful_unstakes += 1
298286
continue

bittensor/core/extrinsics/unstaking.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import time
21
from typing import Optional, TYPE_CHECKING
32

43
from bittensor.core.errors import StakeError, NotRegisteredError
@@ -266,16 +265,6 @@ def unstake_multiple_extrinsic(
266265
if staking_response is True: # If we successfully unstaked.
267266
# We only wait here if we expect finalization.
268267

269-
if idx < len(hotkey_ss58s) - 1:
270-
# Wait for tx rate limit.
271-
tx_rate_limit_blocks = subtensor.tx_rate_limit()
272-
if tx_rate_limit_blocks > 0:
273-
logging.info(
274-
f":hourglass: [yellow]Waiting for tx rate limit: "
275-
f"[white]{tx_rate_limit_blocks}[/white] blocks[/yellow]"
276-
)
277-
time.sleep(tx_rate_limit_blocks * 12) # 12 seconds per block
278-
279268
if not wait_for_finalization and not wait_for_inclusion:
280269
successful_unstakes += 1
281270
continue

bittensor/core/subtensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ def get_all_commitments(
754754
)
755755
result = {}
756756
for id_, value in query:
757-
result[decode_account_id(id_[0])] = decode_account_id(value)
757+
result[decode_account_id(id_[0])] = decode_metadata(value)
758758
return result
759759

760760
def get_current_weight_commit_info(

tests/e2e_tests/conftest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
import pytest
1010
from async_substrate_interface import SubstrateInterface
11-
from bittensor.core.subtensor import Subtensor
1211

12+
from bittensor.core.async_subtensor import AsyncSubtensor
13+
from bittensor.core.subtensor import Subtensor
1314
from bittensor.utils.btlogging import logging
1415
from tests.e2e_tests.utils.e2e_test_utils import (
1516
Templates,
@@ -101,6 +102,11 @@ def subtensor(local_chain):
101102
return Subtensor(network="ws://localhost:9944")
102103

103104

105+
@pytest.fixture
106+
def async_subtensor(local_chain):
107+
return AsyncSubtensor(network="ws://localhost:9944")
108+
109+
104110
@pytest.fixture
105111
def alice_wallet():
106112
keypair, wallet = setup_wallet("//Alice")

tests/e2e_tests/test_commitment.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,61 @@ def test_commitment(subtensor, alice_wallet):
5151
netuid=1,
5252
uid=uid,
5353
)
54+
55+
assert (
56+
subtensor.get_all_commitments(netuid=1)[alice_wallet.hotkey.ss58_address]
57+
== "Hello World!"
58+
)
59+
60+
61+
@pytest.mark.asyncio
62+
async def test_commitment_async(async_subtensor, alice_wallet):
63+
async with async_subtensor as sub:
64+
with pytest.raises(SubstrateRequestException, match="AccountNotAllowedCommit"):
65+
await sub.set_commitment(
66+
alice_wallet,
67+
netuid=1,
68+
data="Hello World!",
69+
)
70+
71+
assert await sub.burned_register(
72+
alice_wallet,
73+
netuid=1,
74+
)
75+
76+
uid = await sub.get_uid_for_hotkey_on_subnet(
77+
alice_wallet.hotkey.ss58_address,
78+
netuid=1,
79+
)
80+
81+
assert uid is not None
82+
83+
assert "" == await sub.get_commitment(
84+
netuid=1,
85+
uid=uid,
86+
)
87+
88+
assert await sub.set_commitment(
89+
alice_wallet,
90+
netuid=1,
91+
data="Hello World!",
92+
)
93+
94+
with pytest.raises(
95+
SubstrateRequestException,
96+
match="CommitmentSetRateLimitExceeded",
97+
):
98+
await sub.set_commitment(
99+
alice_wallet,
100+
netuid=1,
101+
data="Hello World!",
102+
)
103+
104+
assert "Hello World!" == await sub.get_commitment(
105+
netuid=1,
106+
uid=uid,
107+
)
108+
109+
assert (await sub.get_all_commitments(netuid=1))[
110+
alice_wallet.hotkey.ss58_address
111+
] == "Hello World!"

tests/unit_tests/test_config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
def test_py_config_parsed_successfully_rust_wallet():
66
"""Verify that python based config object is successfully parsed with rust-based wallet object."""
7-
# Preps
87
parser = argparse.ArgumentParser()
98

109
bittensor.wallet.add_args(parser)
@@ -14,7 +13,7 @@ def test_py_config_parsed_successfully_rust_wallet():
1413

1514
config = bittensor.config(parser)
1615

17-
# since we can't apply mocking to rust implewmented object then replace those directly
16+
# override config manually since we can't apply mocking to rust objects easily
1817
config.wallet.name = "new_wallet_name"
1918
config.wallet.hotkey = "new_hotkey"
2019
config.wallet.path = "/some/not_default/path"

0 commit comments

Comments
 (0)