File tree Expand file tree Collapse file tree 7 files changed +67
-40
lines changed Expand file tree Collapse file tree 7 files changed +67
-40
lines changed Original file line number Diff line number Diff line change @@ -999,7 +999,7 @@ async def get_all_commitments(
999
999
)
1000
1000
result = {}
1001
1001
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 )
1003
1003
return result
1004
1004
1005
1005
async def get_current_weight_commit_info (
Original file line number Diff line number Diff line change @@ -314,20 +314,6 @@ async def add_stake_multiple_extrinsic(
314
314
if staking_response is True : # If we successfully staked.
315
315
# We only wait here if we expect finalization.
316
316
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
-
331
317
if not wait_for_finalization and not wait_for_inclusion :
332
318
old_balance -= staking_balance
333
319
successful_stakes += 1
Original file line number Diff line number Diff line change @@ -281,18 +281,6 @@ async def unstake_multiple_extrinsic(
281
281
if staking_response is True : # If we successfully unstaked.
282
282
# We only wait here if we expect finalization.
283
283
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
-
296
284
if not wait_for_finalization and not wait_for_inclusion :
297
285
successful_unstakes += 1
298
286
continue
Original file line number Diff line number Diff line change 1
- import time
2
1
from typing import Optional , TYPE_CHECKING
3
2
4
3
from bittensor .core .errors import StakeError , NotRegisteredError
@@ -266,16 +265,6 @@ def unstake_multiple_extrinsic(
266
265
if staking_response is True : # If we successfully unstaked.
267
266
# We only wait here if we expect finalization.
268
267
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
-
279
268
if not wait_for_finalization and not wait_for_inclusion :
280
269
successful_unstakes += 1
281
270
continue
Original file line number Diff line number Diff line change @@ -754,7 +754,7 @@ def get_all_commitments(
754
754
)
755
755
result = {}
756
756
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 )
758
758
return result
759
759
760
760
def get_current_weight_commit_info (
Original file line number Diff line number Diff line change 8
8
9
9
import pytest
10
10
from async_substrate_interface import SubstrateInterface
11
- from bittensor .core .subtensor import Subtensor
12
11
12
+ from bittensor .core .async_subtensor import AsyncSubtensor
13
+ from bittensor .core .subtensor import Subtensor
13
14
from bittensor .utils .btlogging import logging
14
15
from tests .e2e_tests .utils .e2e_test_utils import (
15
16
Templates ,
@@ -101,6 +102,11 @@ def subtensor(local_chain):
101
102
return Subtensor (network = "ws://localhost:9944" )
102
103
103
104
105
+ @pytest .fixture
106
+ def async_subtensor (local_chain ):
107
+ return AsyncSubtensor (network = "ws://localhost:9944" )
108
+
109
+
104
110
@pytest .fixture
105
111
def alice_wallet ():
106
112
keypair , wallet = setup_wallet ("//Alice" )
Original file line number Diff line number Diff line change @@ -51,3 +51,61 @@ def test_commitment(subtensor, alice_wallet):
51
51
netuid = 1 ,
52
52
uid = uid ,
53
53
)
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!"
You can’t perform that action at this time.
0 commit comments