@@ -226,21 +226,19 @@ async def test_commit_weights_uses_next_nonce(local_chain, subtensor, alice_wall
226
226
# wait while weights_rate_limit changes applied.
227
227
subtensor .wait_for_block (subnet_tempo + 1 )
228
228
229
- # Commit-reveal values
230
- uids = np .array ([0 ], dtype = np .int64 )
231
- weights = np .array ([0.1 ], dtype = np .float32 )
232
- salt = [18 , 179 , 107 , 0 , 165 , 211 , 141 , 197 ]
233
- weight_uids , weight_vals = convert_weights_and_uids_for_emit (
234
- uids = uids , weights = weights
235
- )
236
-
237
- # Make a second salt
238
- salt2 = salt .copy ()
239
- salt2 [0 ] += 1 # Increment the first byte to produce a different commit hash
240
-
241
- # Make a third salt
242
- salt3 = salt .copy ()
243
- salt3 [0 ] += 2 # Increment the first byte to produce a different commit hash
229
+ # create different commited data to avoid coming into pool black list with the error
230
+ # Failed to commit weights: Subtensor returned `Custom type(1012)` error. This means: `Transaction is temporarily
231
+ # banned`.Failed to commit weights: Subtensor returned `Custom type(1012)` error. This means: `Transaction is
232
+ # temporarily banned`.`
233
+ def get_weights_and_salt (counter : int ):
234
+ # Commit-reveal values
235
+ salt_ = [18 , 179 , 107 , counter , 165 , 211 , 141 , 197 ]
236
+ uids_ = np .array ([0 ], dtype = np .int64 )
237
+ weights_ = np .array ([counter / 10 ], dtype = np .float32 )
238
+ weight_uids_ , weight_vals_ = convert_weights_and_uids_for_emit (
239
+ uids = uids_ , weights = weights_
240
+ )
241
+ return salt_ , weight_uids_ , weight_vals_
244
242
245
243
logging .console .info (
246
244
f"[orange]Nonce before first commit_weights: "
@@ -250,23 +248,24 @@ async def test_commit_weights_uses_next_nonce(local_chain, subtensor, alice_wall
250
248
# 3 time doing call if nonce wasn't updated, then raise error
251
249
@retry .retry (exceptions = Exception , tries = 3 , delay = 1 )
252
250
@execute_and_wait_for_next_nonce (subtensor = subtensor , wallet = alice_wallet )
253
- def send_commit (salt_ ):
251
+ def send_commit (salt_ , weight_uids_ , weight_vals_ ):
254
252
success , message = subtensor .commit_weights (
255
253
wallet = alice_wallet ,
256
254
netuid = netuid ,
257
255
salt = salt_ ,
258
- uids = weight_uids ,
259
- weights = weight_vals ,
256
+ uids = weight_uids_ ,
257
+ weights = weight_vals_ ,
260
258
wait_for_inclusion = True ,
261
259
wait_for_finalization = True ,
262
260
)
263
261
assert success is True , message
264
262
265
- send_commit (salt )
266
-
267
- send_commit (salt2 )
263
+ # send some amount of commit weights
264
+ AMOUNT_OF_COMMIT_WEIGHTS = 3
265
+ for call in range (AMOUNT_OF_COMMIT_WEIGHTS ):
266
+ weight_uids , weight_vals , salt = get_weights_and_salt (call )
268
267
269
- send_commit (salt3 )
268
+ send_commit (salt , weight_uids , weight_vals )
270
269
271
270
logging .console .info (
272
271
f"[orange]Nonce after third commit_weights: "
@@ -288,4 +287,6 @@ def send_commit(salt_):
288
287
assert commit_block > 0 , f"Invalid block number: { commit_block } "
289
288
290
289
# Check for three commits in the WeightCommits storage map
291
- assert len (weight_commits .value ) == 3 , "Expected 3 weight commits"
290
+ assert (
291
+ len (weight_commits .value ) == AMOUNT_OF_COMMIT_WEIGHTS
292
+ ), "Expected exact list of weight commits"
0 commit comments