Skip to content

Commit ed87b94

Browse files
authored
Merge pull request #2341 from opentensor/set-start-call-init-0
set default start call time as 0
2 parents 698188f + cda6423 commit ed87b94

File tree

7 files changed

+28
-38
lines changed

7 files changed

+28
-38
lines changed

node/src/chain_spec/localnet.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,5 @@ fn localnet_genesis(
124124
"evmChainId": {
125125
"chainId": 42,
126126
},
127-
"subtensorModule": {
128-
"startCallDelay": 10,
129-
},
130127
})
131128
}

pallets/admin-utils/src/tests/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ parameter_types! {
145145
pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days
146146
pub const InitialTaoWeight: u64 = u64::MAX/10; // 10% global weight.
147147
pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks
148-
pub const InitialStartCallDelay: u64 = 7 * 24 * 60 * 60 / 12; // 7 days
148+
pub const InitialStartCallDelay: u64 = 0; // 0 days
149149
pub const InitialKeySwapOnSubnetCost: u64 = 10_000_000;
150150
pub const HotkeySwapOnSubnetInterval: u64 = 7 * 24 * 60 * 60 / 12; // 7 days
151151
pub const LeaseDividendsDistributionInterval: u32 = 100; // 100 blocks

pallets/admin-utils/src/tests/mod.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,10 +2898,7 @@ fn test_sudo_set_start_call_delay_permissions_and_zero_delay() {
28982898

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

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

2928-
// Test 3: Try to start the subnet immediately - should FAIL (delay not passed)
2929-
assert_err!(
2930-
pallet_subtensor::Pallet::<Test>::start_call(
2931-
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
2932-
netuid
2933-
),
2934-
pallet_subtensor::Error::<Test>::NeedWaitingMoreBlocksToStarCall
2935-
);
2925+
// Test 3: Can successfully start the subnet immediately
2926+
assert_ok!(pallet_subtensor::Pallet::<Test>::start_call(
2927+
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
2928+
netuid
2929+
));
29362930

2937-
// Verify emission has not been set
2938-
assert_eq!(
2939-
pallet_subtensor::FirstEmissionBlockNumber::<Test>::get(netuid),
2940-
None,
2941-
"Emission should not be set yet"
2931+
// Verify emission has been set
2932+
assert!(
2933+
pallet_subtensor::FirstEmissionBlockNumber::<Test>::get(netuid).is_some(),
2934+
"Emission should be set"
29422935
);
29432936

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

2960-
// Test 5: Try to start the subnet again - should SUCCEED (delay is now zero)
2953+
// Test 5: Try to start the subnet again - should be FAILED (first emission block already set)
29612954
let current_block = frame_system::Pallet::<Test>::block_number();
2962-
assert_ok!(pallet_subtensor::Pallet::<Test>::start_call(
2963-
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
2964-
netuid
2965-
));
2955+
assert_err!(
2956+
pallet_subtensor::Pallet::<Test>::start_call(
2957+
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
2958+
netuid
2959+
),
2960+
pallet_subtensor::Error::<Test>::FirstEmissionBlockNumberAlreadySet
2961+
);
29662962

29672963
assert_eq!(
29682964
pallet_subtensor::FirstEmissionBlockNumber::<Test>::get(netuid),

pallets/subtensor/src/tests/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ parameter_types! {
218218
pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days
219219
pub const InitialTaoWeight: u64 = 0; // 100% global weight.
220220
pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks
221-
pub const InitialStartCallDelay: u64 = 7 * 24 * 60 * 60 / 12; // Default as 7 days
221+
pub const InitialStartCallDelay: u64 = 0; // 0 days
222222
pub const InitialKeySwapOnSubnetCost: u64 = 10_000_000;
223223
pub const HotkeySwapOnSubnetInterval: u64 = 15; // 15 block, should be bigger than subnet number, then trigger clean up for all subnets
224224
pub const MaxContributorsPerLeaseToRemove: u32 = 3;

pallets/subtensor/src/tests/subnet.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn test_do_start_call_fail_not_owner() {
8989
}
9090

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

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

109-
assert_noop!(
110-
SubtensorModule::start_call(
111-
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
112-
netuid
113-
),
114-
Error::<Test>::NeedWaitingMoreBlocksToStarCall
115-
);
109+
assert_ok!(SubtensorModule::start_call(
110+
<<Test as Config>::RuntimeOrigin>::signed(coldkey_account_id),
111+
netuid
112+
));
116113
});
117114
}
118115

pallets/transaction-fee/src/tests/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ parameter_types! {
210210
pub const InitialDissolveNetworkScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days
211211
pub const InitialTaoWeight: u64 = u64::MAX/10; // 10% global weight.
212212
pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks
213-
pub const InitialStartCallDelay: u64 = 7 * 24 * 60 * 60 / 12; // 7 days
213+
pub const InitialStartCallDelay: u64 = 0; // 0 days
214214
pub const InitialKeySwapOnSubnetCost: u64 = 10_000_000;
215215
pub const HotkeySwapOnSubnetInterval: u64 = 7 * 24 * 60 * 60 / 12; // 7 days
216216
pub const LeaseDividendsDistributionInterval: u32 = 100; // 100 blocks

runtime/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,8 @@ parameter_types! {
10571057
pub const InitialDissolveNetworkScheduleDuration: BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days
10581058
pub const SubtensorInitialTaoWeight: u64 = 971_718_665_099_567_868; // 0.05267697438728329% tao weight.
10591059
pub const InitialEmaPriceHalvingPeriod: u64 = 201_600_u64; // 4 weeks
1060-
// 7 * 24 * 60 * 60 / 12 = 7 days
1061-
pub const InitialStartCallDelay: u64 = prod_or_fast!(7 * 24 * 60 * 60 / 12, 10);
1060+
// 0 days
1061+
pub const InitialStartCallDelay: u64 = prod_or_fast!(0, 0);
10621062
pub const SubtensorInitialKeySwapOnSubnetCost: u64 = 1_000_000; // 0.001 TAO
10631063
pub const HotkeySwapOnSubnetInterval : BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days
10641064
pub const LeaseDividendsDistributionInterval: BlockNumber = 100; // 100 blocks

0 commit comments

Comments
 (0)