@@ -163,7 +163,6 @@ impl<T: Config> Pallet<T> {
163
163
164
164
// --- 6. After removing expired commits, check if any commits are left.
165
165
if commits. is_empty ( ) {
166
- // No non-expired commits
167
166
// Check if provided_hash matches any expired commits
168
167
if expired_hashes. contains ( & provided_hash) {
169
168
return Err ( Error :: < T > :: ExpiredWeightCommit . into ( ) ) ;
@@ -202,7 +201,6 @@ impl<T: Config> Pallet<T> {
202
201
Self :: do_set_weights ( origin, netuid, uids, values, version_key)
203
202
} else {
204
203
// --- 13. The provided_hash does not match any non-expired commits.
205
- // Check if provided_hash matches any expired commits
206
204
if expired_hashes. contains ( & provided_hash) {
207
205
Err ( Error :: < T > :: ExpiredWeightCommit . into ( ) )
208
206
} else {
@@ -324,7 +322,6 @@ impl<T: Config> Pallet<T> {
324
322
}
325
323
326
324
// --- 7. Validate all reveals first to ensure atomicity.
327
- // This prevents partial updates if any reveal fails.
328
325
for ( _uids, _values, _version_key, provided_hash) in & reveals {
329
326
// --- 7a. Check if the provided_hash is in the non-expired commits.
330
327
if !commits
@@ -346,10 +343,8 @@ impl<T: Config> Pallet<T> {
346
343
. ok_or ( Error :: < T > :: NoWeightsCommitFound ) ?;
347
344
348
345
// --- 7d. Check if the commit is within the reveal window.
349
- let current_block: u64 = Self :: get_current_block_as_u64 ( ) ;
350
- let ( _, _, first_reveal_block, last_reveal_block) = commit;
351
346
ensure ! (
352
- current_block >= * first_reveal_block && current_block <= * last_reveal_block ,
347
+ Self :: is_reveal_block_range ( netuid , commit . 1 ) ,
353
348
Error :: <T >:: RevealTooEarly
354
349
) ;
355
350
}
@@ -366,14 +361,10 @@ impl<T: Config> Pallet<T> {
366
361
367
362
// --- 8c. Proceed to set the revealed weights.
368
363
Self :: do_set_weights ( origin. clone ( ) , netuid, uids, values, version_key) ?;
364
+ } else if expired_hashes. contains ( & provided_hash) {
365
+ return Err ( Error :: < T > :: ExpiredWeightCommit . into ( ) ) ;
369
366
} else {
370
- // This case should not occur as we've already validated the existence of the hash.
371
- // However, to ensure safety, we handle it.
372
- if expired_hashes. contains ( & provided_hash) {
373
- return Err ( Error :: < T > :: ExpiredWeightCommit . into ( ) ) ;
374
- } else {
375
- return Err ( Error :: < T > :: InvalidRevealCommitHashNotMatch . into ( ) ) ;
376
- }
367
+ return Err ( Error :: < T > :: InvalidRevealCommitHashNotMatch . into ( ) ) ;
377
368
}
378
369
}
379
370
0 commit comments