Skip to content

Commit 46b512f

Browse files
committed
doc
1 parent ddc51e5 commit 46b512f

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

pallets/subtensor/src/macros/dispatches.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,17 @@ mod dispatches {
186186
/// - The u16 network identifier.
187187
///
188188
/// * `commit` (`Vec<u8>`):
189-
/// - The encrypted weights commit.
189+
/// - The encrypted compressed commit.
190+
/// The steps for this are:
191+
/// 1. Instantiate [`WeightsTlockPayload`]
192+
/// 2. Serialize it using the `parity_scale_codec::Encode` trait
193+
/// 3. Encrypt it following the steps (here)[https://github.com/ideal-lab5/tle/blob/f8e6019f0fb02c380ebfa6b30efb61786dede07b/timelock/src/tlock.rs#L283-L336]
194+
/// to produce a [`TLECiphertext<TinyBLS381>`] type.
195+
/// 4. Serialize and compress using the `ark-serialize` `CanonicalSerialize` trait.
196+
///
197+
/// * reveal_round (`u64`):
198+
/// - The drand reveal round which will be avaliable during epoch `n+1` from the current
199+
/// epoch.
190200
///
191201
/// # Raises:
192202
/// * `CommitRevealV3Disabled`:

pallets/subtensor/tests/weights.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4188,3 +4188,27 @@ fn test_commit_weights_rate_limit() {
41884188
));
41894189
});
41904190
}
4191+
4192+
#[test]
4193+
fn test_commit_weights_dispatch_info_ok() {
4194+
new_test_ext(0).execute_with(|| {
4195+
let dests = vec![1, 1];
4196+
let weights = vec![1, 1];
4197+
let netuid: u16 = 1;
4198+
let salt: Vec<u16> = vec![1, 2, 3, 4, 5, 6, 7, 8];
4199+
let version_key: u64 = 0;
4200+
let hotkey: U256 = U256::from(1);
4201+
4202+
let commit_hash: H256 =
4203+
BlakeTwo256::hash_of(&(hotkey, netuid, dests, weights, salt, version_key));
4204+
4205+
let call = RuntimeCall::SubtensorModule(SubtensorCall::commit_weights {
4206+
netuid,
4207+
commit_hash,
4208+
});
4209+
let dispatch_info = call.get_dispatch_info();
4210+
4211+
assert_eq!(dispatch_info.class, DispatchClass::Normal);
4212+
assert_eq!(dispatch_info.pays_fee, Pays::No);
4213+
});
4214+
}

0 commit comments

Comments
 (0)