@@ -33,10 +33,12 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
33
33
logging .console .info ("Testing test_commit_and_reveal_weights" )
34
34
35
35
# Register root as Alice
36
- assert subtensor .register_subnet (alice_wallet ), "Unable to register the subnet"
36
+ assert await subtensor .register_subnet (
37
+ alice_wallet ,
38
+ ), "Unable to register the subnet"
37
39
38
40
# Verify subnet 2 created successfully
39
- assert subtensor .subnet_exists (netuid ), "Subnet wasn't created successfully"
41
+ assert await subtensor .subnet_exists (netuid ), "Subnet wasn't created successfully"
40
42
41
43
logging .console .info ("Subnet 2 is registered" )
42
44
@@ -50,7 +52,9 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
50
52
), "Unable to enable commit reveal on the subnet"
51
53
52
54
# Verify commit_reveal was enabled
53
- assert subtensor .commit_reveal_enabled (netuid ), "Failed to enable commit/reveal"
55
+ assert await subtensor .commit_reveal_enabled (
56
+ netuid ,
57
+ ), "Failed to enable commit/reveal"
54
58
logging .console .info ("Commit reveal enabled" )
55
59
56
60
# Change the weights rate limit on the subnet
@@ -66,9 +70,9 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
66
70
67
71
# Verify weights rate limit was changed
68
72
assert (
69
- subtensor .get_subnet_hyperparameters (netuid = netuid ). weights_rate_limit == 0
70
- ), "Failed to set weights_rate_limit"
71
- assert subtensor .weights_rate_limit (netuid = netuid ) == 0
73
+ await subtensor .get_subnet_hyperparameters (netuid = netuid )
74
+ ). weights_rate_limit == 0 , "Failed to set weights_rate_limit"
75
+ assert await subtensor .weights_rate_limit (netuid = netuid ) == 0
72
76
logging .console .info ("sudo_set_weights_set_rate_limit executed: set to 0" )
73
77
74
78
# Change the tempo of the subnet from default 360
@@ -83,7 +87,7 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
83
87
)[0 ]
84
88
is True
85
89
)
86
- tempo = subtensor .get_subnet_hyperparameters (netuid = netuid ). tempo
90
+ tempo = await subtensor .tempo (netuid )
87
91
assert tempo_set == tempo
88
92
logging .console .info (f"sudo_set_tempo executed: set to { tempo_set } " )
89
93
@@ -95,14 +99,14 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
95
99
)
96
100
97
101
# Fetch current block and calculate next tempo for the subnet
98
- current_block = subtensor .get_current_block ()
102
+ current_block = await subtensor .get_current_block ()
99
103
upcoming_tempo = next_tempo (current_block , tempo , netuid )
100
104
logging .console .info (
101
105
f"Checking if window is too low with Current block: { current_block } , next tempo: { upcoming_tempo } "
102
106
)
103
107
104
108
# Wait for 2 tempos to pass as CR3 only reveals weights after 2 tempos
105
- subtensor .wait_for_block (20 )
109
+ await subtensor .wait_for_block (20 )
106
110
107
111
# Lower than this might mean weights will get revealed before we can check them
108
112
if upcoming_tempo - current_block < 3 :
@@ -112,15 +116,15 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
112
116
netuid = netuid ,
113
117
reporting_interval = 1 ,
114
118
)
115
- current_block = subtensor .get_current_block ()
116
- latest_drand_round = subtensor .last_drand_round ()
119
+ current_block = await subtensor .get_current_block ()
120
+ latest_drand_round = await subtensor .last_drand_round ()
117
121
upcoming_tempo = next_tempo (current_block , tempo , netuid )
118
122
logging .console .info (
119
123
f"Post first wait_interval (to ensure window isnt too low): { current_block } , next tempo: { upcoming_tempo } , drand: { latest_drand_round } "
120
124
)
121
125
122
126
# Commit weights
123
- success , message = subtensor .set_weights (
127
+ success , message = await subtensor .set_weights (
124
128
alice_wallet ,
125
129
netuid ,
126
130
uids = weight_uids ,
@@ -139,8 +143,8 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
139
143
f"Successfully set weights: uids { weight_uids } , weights { weight_vals } , reveal_round: { expected_reveal_round } "
140
144
)
141
145
142
- current_block = subtensor .get_current_block ()
143
- latest_drand_round = subtensor .last_drand_round ()
146
+ current_block = await subtensor .get_current_block ()
147
+ latest_drand_round = await subtensor .last_drand_round ()
144
148
upcoming_tempo = next_tempo (current_block , tempo , netuid )
145
149
logging .console .info (
146
150
f"After setting weights: Current block: { current_block } , next tempo: { upcoming_tempo } , drand: { latest_drand_round } "
@@ -152,32 +156,32 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
152
156
), "Revealed drand pulse is older than the drand pulse right after setting weights"
153
157
154
158
# Fetch current commits pending on the chain
155
- commits_on_chain = subtensor .get_current_weight_commit_info (netuid = netuid )
159
+ commits_on_chain = await subtensor .get_current_weight_commit_info (netuid = netuid )
156
160
address , commit , reveal_round = commits_on_chain [0 ]
157
161
158
162
# Assert correct values are committed on the chain
159
163
assert expected_reveal_round == reveal_round
160
164
assert address == alice_wallet .hotkey .ss58_address
161
165
162
166
# Ensure no weights are available as of now
163
- assert subtensor .weights (netuid = netuid ) == []
167
+ assert await subtensor .weights (netuid = netuid ) == []
164
168
165
169
# Wait for the next tempo so weights can be revealed
166
170
await wait_interval (
167
- subtensor . get_subnet_hyperparameters ( netuid = netuid ). tempo ,
171
+ tempo ,
168
172
subtensor ,
169
173
netuid = netuid ,
170
174
reporting_interval = 1 ,
171
175
)
172
176
173
177
# Fetch the latest drand pulse
174
- latest_drand_round = subtensor .last_drand_round ()
178
+ latest_drand_round = await subtensor .last_drand_round ()
175
179
logging .console .info (
176
180
f"Latest drand round after waiting for tempo: { latest_drand_round } "
177
181
)
178
182
179
183
# Fetch weights on the chain as they should be revealed now
180
- revealed_weights_ = subtensor .weights (netuid = netuid )
184
+ revealed_weights_ = await subtensor .weights (netuid = netuid )
181
185
182
186
print ("revealed weights" , revealed_weights_ )
183
187
revealed_weights = revealed_weights_ [0 ][1 ]
@@ -186,7 +190,7 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
186
190
assert weight_vals [0 ] == revealed_weights [0 ][1 ]
187
191
188
192
# Now that the commit has been revealed, there shouldn't be any pending commits
189
- assert subtensor .get_current_weight_commit_info (netuid = netuid ) == []
193
+ assert await subtensor .get_current_weight_commit_info (netuid = netuid ) == []
190
194
191
195
# Ensure the drand_round is always in the positive w.r.t expected when revealed
192
196
assert (
0 commit comments