Skip to content

Commit f5df0ba

Browse files
committed
doc comments and lints
1 parent a82a1f8 commit f5df0ba

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

pallets/subtensor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ pub mod pallet {
569569
0
570570
}
571571
#[pallet::type_value]
572-
/// Default minimum stake for weights.
572+
/// Default Reveal Period Epochs
573573
pub fn DefaultRevealPeriodEpochs<T: Config>() -> u64 {
574574
1
575575
}

pallets/subtensor/src/subnets/weights.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ impl<T: Config> Pallet<T> {
163163

164164
// --- 6. After removing expired commits, check if any commits are left.
165165
if commits.is_empty() {
166-
// No non-expired commits
167166
// Check if provided_hash matches any expired commits
168167
if expired_hashes.contains(&provided_hash) {
169168
return Err(Error::<T>::ExpiredWeightCommit.into());
@@ -202,7 +201,6 @@ impl<T: Config> Pallet<T> {
202201
Self::do_set_weights(origin, netuid, uids, values, version_key)
203202
} else {
204203
// --- 13. The provided_hash does not match any non-expired commits.
205-
// Check if provided_hash matches any expired commits
206204
if expired_hashes.contains(&provided_hash) {
207205
Err(Error::<T>::ExpiredWeightCommit.into())
208206
} else {
@@ -324,7 +322,6 @@ impl<T: Config> Pallet<T> {
324322
}
325323

326324
// --- 7. Validate all reveals first to ensure atomicity.
327-
// This prevents partial updates if any reveal fails.
328325
for (_uids, _values, _version_key, provided_hash) in &reveals {
329326
// --- 7a. Check if the provided_hash is in the non-expired commits.
330327
if !commits
@@ -346,10 +343,8 @@ impl<T: Config> Pallet<T> {
346343
.ok_or(Error::<T>::NoWeightsCommitFound)?;
347344

348345
// --- 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;
351346
ensure!(
352-
current_block >= *first_reveal_block && current_block <= *last_reveal_block,
347+
Self::is_reveal_block_range(netuid, commit.1),
353348
Error::<T>::RevealTooEarly
354349
);
355350
}
@@ -366,14 +361,10 @@ impl<T: Config> Pallet<T> {
366361

367362
// --- 8c. Proceed to set the revealed weights.
368363
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());
369366
} 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());
377368
}
378369
}
379370

0 commit comments

Comments
 (0)