@@ -4677,46 +4677,103 @@ fn test_do_commit_crv3_weights_committing_too_fast() {
4677
4677
fn test_do_commit_crv3_weights_too_many_unrevealed_commits ( ) {
4678
4678
new_test_ext ( 1 ) . execute_with ( || {
4679
4679
let netuid: u16 = 1 ;
4680
- let hotkey: AccountId = U256 :: from ( 1 ) ;
4680
+ let hotkey1: AccountId = U256 :: from ( 1 ) ;
4681
+ let hotkey2: AccountId = U256 :: from ( 2 ) ;
4681
4682
let reveal_round: u64 = 1000 ;
4682
4683
4683
4684
add_network ( netuid, 5 , 0 ) ;
4684
- register_ok_neuron ( netuid, hotkey , U256 :: from ( 2 ) , 100_000 ) ;
4685
- SubtensorModule :: set_weights_set_rate_limit ( netuid , 0 ) ;
4685
+ register_ok_neuron ( netuid, hotkey1 , U256 :: from ( 2 ) , 100_000 ) ;
4686
+ register_ok_neuron ( netuid , hotkey2 , U256 :: from ( 3 ) , 100_000 ) ;
4686
4687
SubtensorModule :: set_commit_reveal_weights_enabled ( netuid, true ) ;
4688
+ SubtensorModule :: set_weights_set_rate_limit ( netuid, 0 ) ;
4687
4689
4688
- // Simulate 10 unrevealed commits
4689
- let cur_epoch =
4690
- SubtensorModule :: get_epoch_index ( netuid, SubtensorModule :: get_current_block_as_u64 ( ) ) ;
4690
+ // Hotkey1 submits 10 commits successfully
4691
4691
for i in 0 ..10 {
4692
4692
let commit_data: Vec < u8 > = vec ! [ i as u8 ; 5 ] ;
4693
4693
let bounded_commit_data = commit_data
4694
4694
. try_into ( )
4695
4695
. expect ( "Failed to convert commit data into bounded vector" ) ;
4696
- assert_ok ! ( CRV3WeightCommits :: <Test >:: try_mutate(
4696
+
4697
+ assert_ok ! ( SubtensorModule :: do_commit_crv3_weights(
4698
+ RuntimeOrigin :: signed( hotkey1) ,
4697
4699
netuid,
4698
- cur_epoch,
4699
- |commits| -> DispatchResult {
4700
- commits. push_back( ( hotkey, bounded_commit_data, reveal_round) ) ;
4701
- Ok ( ( ) )
4702
- }
4700
+ bounded_commit_data,
4701
+ reveal_round
4703
4702
) ) ;
4704
4703
}
4705
4704
4706
- // Attempt to commit an 11th time, should fail
4705
+ // Hotkey1 attempts to commit an 11th time, should fail with TooManyUnrevealedCommits
4707
4706
let new_commit_data: Vec < u8 > = vec ! [ 11 ; 5 ] ;
4708
4707
let bounded_new_commit_data = new_commit_data
4709
4708
. try_into ( )
4710
4709
. expect ( "Failed to convert new commit data into bounded vector" ) ;
4710
+
4711
4711
assert_err ! (
4712
4712
SubtensorModule :: do_commit_crv3_weights(
4713
- RuntimeOrigin :: signed( hotkey ) ,
4713
+ RuntimeOrigin :: signed( hotkey1 ) ,
4714
4714
netuid,
4715
4715
bounded_new_commit_data,
4716
4716
reveal_round
4717
4717
) ,
4718
4718
Error :: <Test >:: TooManyUnrevealedCommits
4719
4719
) ;
4720
+
4721
+ // Hotkey2 can still submit commits independently
4722
+ let commit_data_hotkey2: Vec < u8 > = vec ! [ 0 ; 5 ] ;
4723
+ let bounded_commit_data_hotkey2 = commit_data_hotkey2
4724
+ . try_into ( )
4725
+ . expect ( "Failed to convert commit data into bounded vector" ) ;
4726
+
4727
+ assert_ok ! ( SubtensorModule :: do_commit_crv3_weights(
4728
+ RuntimeOrigin :: signed( hotkey2) ,
4729
+ netuid,
4730
+ bounded_commit_data_hotkey2,
4731
+ reveal_round
4732
+ ) ) ;
4733
+
4734
+ // Hotkey2 can submit up to 10 commits
4735
+ for i in 1 ..10 {
4736
+ let commit_data: Vec < u8 > = vec ! [ i as u8 ; 5 ] ;
4737
+ let bounded_commit_data = commit_data
4738
+ . try_into ( )
4739
+ . expect ( "Failed to convert commit data into bounded vector" ) ;
4740
+
4741
+ assert_ok ! ( SubtensorModule :: do_commit_crv3_weights(
4742
+ RuntimeOrigin :: signed( hotkey2) ,
4743
+ netuid,
4744
+ bounded_commit_data,
4745
+ reveal_round
4746
+ ) ) ;
4747
+ }
4748
+
4749
+ // Hotkey2 attempts to commit an 11th time, should fail
4750
+ let new_commit_data: Vec < u8 > = vec ! [ 11 ; 5 ] ;
4751
+ let bounded_new_commit_data = new_commit_data
4752
+ . try_into ( )
4753
+ . expect ( "Failed to convert new commit data into bounded vector" ) ;
4754
+
4755
+ assert_err ! (
4756
+ SubtensorModule :: do_commit_crv3_weights(
4757
+ RuntimeOrigin :: signed( hotkey2) ,
4758
+ netuid,
4759
+ bounded_new_commit_data,
4760
+ reveal_round
4761
+ ) ,
4762
+ Error :: <Test >:: TooManyUnrevealedCommits
4763
+ ) ;
4764
+
4765
+ step_epochs ( 10 , netuid) ;
4766
+
4767
+ let new_commit_data: Vec < u8 > = vec ! [ 11 ; 5 ] ;
4768
+ let bounded_new_commit_data = new_commit_data
4769
+ . try_into ( )
4770
+ . expect ( "Failed to convert new commit data into bounded vector" ) ;
4771
+ assert_ok ! ( SubtensorModule :: do_commit_crv3_weights(
4772
+ RuntimeOrigin :: signed( hotkey1) ,
4773
+ netuid,
4774
+ bounded_new_commit_data,
4775
+ reveal_round
4776
+ ) ) ;
4720
4777
} ) ;
4721
4778
}
4722
4779
0 commit comments