Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions node/src/chain_spec/localnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,5 @@ fn localnet_genesis(
"evmChainId": {
"chainId": 42,
},
"subtensorModule": {
"startCallDelay": 10,
},
})
}
2 changes: 1 addition & 1 deletion pallets/admin-utils/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ parameter_types! {
pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days
pub const InitialTaoWeight: u64 = u64::MAX/10; // 10% global weight.
pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks
pub const InitialStartCallDelay: u64 = 7 * 24 * 60 * 60 / 12; // 7 days
pub const InitialStartCallDelay: u64 = 0; // 0 days
pub const InitialKeySwapOnSubnetCost: u64 = 10_000_000;
pub const HotkeySwapOnSubnetInterval: u64 = 7 * 24 * 60 * 60 / 12; // 7 days
pub const LeaseDividendsDistributionInterval: u32 = 100; // 100 blocks
Expand Down
40 changes: 18 additions & 22 deletions pallets/admin-utils/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2898,10 +2898,7 @@ fn test_sudo_set_start_call_delay_permissions_and_zero_delay() {

// Get initial delay value (should be non-zero)
let initial_delay = pallet_subtensor::StartCallDelay::<Test>::get();
assert!(
initial_delay > 0,
"Initial delay should be greater than zero"
);
assert_eq!(initial_delay, 0);

// Test 1: Non-root account should fail to set delay
assert_noop!(
Expand All @@ -2925,20 +2922,16 @@ fn test_sudo_set_start_call_delay_permissions_and_zero_delay() {
"Default owner should be account 0"
);

// Test 3: Try to start the subnet immediately - should FAIL (delay not passed)
assert_err!(
pallet_subtensor::Pallet::<Test>::start_call(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
netuid
),
pallet_subtensor::Error::<Test>::NeedWaitingMoreBlocksToStarCall
);
// Test 3: Can successfully start the subnet immediately
assert_ok!(pallet_subtensor::Pallet::<Test>::start_call(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
netuid
));

// Verify emission has not been set
assert_eq!(
pallet_subtensor::FirstEmissionBlockNumber::<Test>::get(netuid),
None,
"Emission should not be set yet"
// Verify emission has been set
assert!(
pallet_subtensor::FirstEmissionBlockNumber::<Test>::get(netuid).is_some(),
"Emission should be set"
);

// Test 4: Root sets delay to zero
Expand All @@ -2957,12 +2950,15 @@ fn test_sudo_set_start_call_delay_permissions_and_zero_delay() {
pallet_subtensor::Event::StartCallDelaySet(0),
));

// Test 5: Try to start the subnet again - should SUCCEED (delay is now zero)
// Test 5: Try to start the subnet again - should be FAILED (first emission block already set)
let current_block = frame_system::Pallet::<Test>::block_number();
assert_ok!(pallet_subtensor::Pallet::<Test>::start_call(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
netuid
));
assert_err!(
pallet_subtensor::Pallet::<Test>::start_call(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
netuid
),
pallet_subtensor::Error::<Test>::FirstEmissionBlockNumberAlreadySet
);

assert_eq!(
pallet_subtensor::FirstEmissionBlockNumber::<Test>::get(netuid),
Expand Down
2 changes: 1 addition & 1 deletion pallets/subtensor/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ parameter_types! {
pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days
pub const InitialTaoWeight: u64 = 0; // 100% global weight.
pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks
pub const InitialStartCallDelay: u64 = 7 * 24 * 60 * 60 / 12; // Default as 7 days
pub const InitialStartCallDelay: u64 = 0; // 0 days
pub const InitialKeySwapOnSubnetCost: u64 = 10_000_000;
pub const HotkeySwapOnSubnetInterval: u64 = 15; // 15 block, should be bigger than subnet number, then trigger clean up for all subnets
pub const MaxContributorsPerLeaseToRemove: u32 = 3;
Expand Down
13 changes: 5 additions & 8 deletions pallets/subtensor/src/tests/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn test_do_start_call_fail_not_owner() {
}

#[test]
fn test_do_start_call_fail_with_cannot_start_call_now() {
fn test_do_start_call_can_start_now() {
new_test_ext(0).execute_with(|| {
let netuid = NetUid::from(1);
let tempo: u16 = 13;
Expand All @@ -106,13 +106,10 @@ fn test_do_start_call_fail_with_cannot_start_call_now() {

assert_eq!(SubnetOwner::<Test>::get(netuid), coldkey_account_id);

assert_noop!(
SubtensorModule::start_call(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
netuid
),
Error::<Test>::NeedWaitingMoreBlocksToStarCall
);
assert_ok!(SubtensorModule::start_call(
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
netuid
));
});
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/transaction-fee/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ parameter_types! {
pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days
pub const InitialTaoWeight: u64 = u64::MAX/10; // 10% global weight.
pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks
pub const InitialStartCallDelay: u64 = 7 * 24 * 60 * 60 / 12; // 7 days
pub const InitialStartCallDelay: u64 = 0; // 0 days
pub const InitialKeySwapOnSubnetCost: u64 = 10_000_000;
pub const HotkeySwapOnSubnetInterval: u64 = 7 * 24 * 60 * 60 / 12; // 7 days
pub const LeaseDividendsDistributionInterval: u32 = 100; // 100 blocks
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,8 +1057,8 @@ parameter_types! {
pub const InitialDissolveNetworkScheduleDuration: BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days
pub const SubtensorInitialTaoWeight: u64 = 971_718_665_099_567_868; // 0.05267697438728329% tao weight.
pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks
// 7 * 24 * 60 * 60 / 12 = 7 days
pub const InitialStartCallDelay: u64 = prod_or_fast!(7 * 24 * 60 * 60 / 12, 10);
// 0 days
pub const InitialStartCallDelay: u64 = prod_or_fast!(0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since both values are equal, you can just use 0 here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense, thanks! I will rebase my other PR and put the change from comment there

pub const SubtensorInitialKeySwapOnSubnetCost: u64 = 1_000_000; // 0.001 TAO
pub const HotkeySwapOnSubnetInterval : BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days
pub const LeaseDividendsDistributionInterval: BlockNumber = 100; // 100 blocks
Expand Down
Loading