Skip to content

Commit fffba8c

Browse files
authored
Merge pull request #2371 from opentensor/testnet
mainnet deploy 1/26/2026
2 parents f74d69e + db36ace commit fffba8c

File tree

7 files changed

+204
-208
lines changed

7 files changed

+204
-208
lines changed

pallets/subtensor/src/tests/networks.rs

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,24 +1812,25 @@ fn massive_dissolve_refund_and_reregistration_flow_is_lossless_and_cleans_state(
18121812
];
18131813

18141814
// Multiple bands/sizes → many positions per cold across nets, using mixed hotkeys.
1815-
let bands: [i32; 3] = [5, 13, 30];
1816-
let liqs: [u64; 3] = [400_000, 700_000, 1_100_000];
1815+
// let bands: [i32; 3] = [5, 13, 30];
1816+
// let liqs: [u64; 3] = [400_000, 700_000, 1_100_000];
18171817

1818+
// TODO: Revise when user liquidity is available
18181819
// Helper: add a V3 position via a (hot, cold) pair.
1819-
let add_pos = |net: NetUid, hot: U256, cold: U256, band: i32, liq: u64| {
1820-
let ct = pallet_subtensor_swap::CurrentTick::<Test>::get(net);
1821-
let lo = ct.saturating_sub(band);
1822-
let hi = ct.saturating_add(band);
1823-
pallet_subtensor_swap::EnabledUserLiquidity::<Test>::insert(net, true);
1824-
assert_ok!(pallet_subtensor_swap::Pallet::<Test>::add_liquidity(
1825-
RuntimeOrigin::signed(cold),
1826-
hot,
1827-
net,
1828-
lo,
1829-
hi,
1830-
liq
1831-
));
1832-
};
1820+
// let add_pos = |net: NetUid, hot: U256, cold: U256, band: i32, liq: u64| {
1821+
// let ct = pallet_subtensor_swap::CurrentTick::<Test>::get(net);
1822+
// let lo = ct.saturating_sub(band);
1823+
// let hi = ct.saturating_add(band);
1824+
// pallet_subtensor_swap::EnabledUserLiquidity::<Test>::insert(net, true);
1825+
// assert_ok!(pallet_subtensor_swap::Pallet::<Test>::add_liquidity(
1826+
// RuntimeOrigin::signed(cold),
1827+
// hot,
1828+
// net,
1829+
// lo,
1830+
// hi,
1831+
// liq
1832+
// ));
1833+
// };
18331834

18341835
// ────────────────────────────────────────────────────────────────────
18351836
// 1) Create many subnets, enable V3, fix price at tick=0 (sqrt≈1)
@@ -1954,19 +1955,20 @@ fn massive_dissolve_refund_and_reregistration_flow_is_lossless_and_cleans_state(
19541955
// ────────────────────────────────────────────────────────────────────
19551956
// 4) Add many V3 positions per cold across nets, alternating hotkeys
19561957
// ────────────────────────────────────────────────────────────────────
1957-
for (ni, &net) in nets.iter().enumerate() {
1958-
let participants = lp_sets_per_net[ni];
1959-
for (pi, &cold) in participants.iter().enumerate() {
1960-
let [hot1, hot2] = cold_to_hots[&cold];
1961-
let hots = [hot1, hot2];
1962-
for k in 0..3 {
1963-
let band = bands[(pi + k) % bands.len()];
1964-
let liq = liqs[(ni + k) % liqs.len()];
1965-
let hot = hots[k % hots.len()];
1966-
add_pos(net, hot, cold, band, liq);
1967-
}
1968-
}
1969-
}
1958+
// TODO: Revise when user liquidity is available
1959+
// for (ni, &net) in nets.iter().enumerate() {
1960+
// let participants = lp_sets_per_net[ni];
1961+
// for (pi, &cold) in participants.iter().enumerate() {
1962+
// let [hot1, hot2] = cold_to_hots[&cold];
1963+
// let hots = [hot1, hot2];
1964+
// for k in 0..3 {
1965+
// let band = bands[(pi + k) % bands.len()];
1966+
// let liq = liqs[(ni + k) % liqs.len()];
1967+
// let hot = hots[k % hots.len()];
1968+
// add_pos(net, hot, cold, band, liq);
1969+
// }
1970+
// }
1971+
// }
19701972

19711973
// Snapshot τ balances AFTER LP adds (to measure actual principal debit).
19721974
let mut tao_after_adds: BTreeMap<U256, u64> = BTreeMap::new();
@@ -2212,14 +2214,15 @@ fn massive_dissolve_refund_and_reregistration_flow_is_lossless_and_cleans_state(
22122214
}
22132215

22142216
// Ensure V3 still functional on new net: add a small position for the first cold using its hot1
2215-
let who_cold = cold_lps[0];
2216-
let [who_hot, _] = cold_to_hots[&who_cold];
2217-
add_pos(net_new, who_hot, who_cold, 8, 123_456);
2218-
assert!(
2219-
pallet_subtensor_swap::Positions::<Test>::iter()
2220-
.any(|((n, owner, _pid), _)| n == net_new && owner == who_cold),
2221-
"new position not recorded on the re-registered net"
2222-
);
2217+
// TODO: Revise when user liquidity is available
2218+
// let who_cold = cold_lps[0];
2219+
// let [who_hot, _] = cold_to_hots[&who_cold];
2220+
// add_pos(net_new, who_hot, who_cold, 8, 123_456);
2221+
// assert!(
2222+
// pallet_subtensor_swap::Positions::<Test>::iter()
2223+
// .any(|((n, owner, _pid), _)| n == net_new && owner == who_cold),
2224+
// "new position not recorded on the re-registered net"
2225+
// );
22232226
});
22242227
}
22252228

pallets/subtensor/src/tests/staking.rs

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ use frame_support::dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays
66
use frame_support::sp_runtime::DispatchError;
77
use frame_support::{assert_err, assert_noop, assert_ok, traits::Currency};
88
use frame_system::RawOrigin;
9-
use pallet_subtensor_swap::Call as SwapCall;
109
use pallet_subtensor_swap::tick::TickIndex;
1110
use safe_math::FixedExt;
1211
use sp_core::{Get, H256, U256};
13-
use sp_runtime::traits::Dispatchable;
1412
use substrate_fixed::traits::FromFixed;
1513
use substrate_fixed::types::{I96F32, I110F18, U64F64, U96F32};
1614
use subtensor_runtime_common::{
@@ -5337,44 +5335,45 @@ fn test_update_position_fees() {
53375335
});
53385336
}
53395337

5340-
fn setup_positions(netuid: NetUid) {
5341-
for (coldkey, hotkey, low_price, high_price, liquidity) in [
5342-
(2, 12, 0.1, 0.20, 1_000_000_000_000_u64),
5343-
(3, 13, 0.15, 0.25, 200_000_000_000_u64),
5344-
(4, 14, 0.25, 0.5, 3_000_000_000_000_u64),
5345-
(5, 15, 0.3, 0.6, 300_000_000_000_u64),
5346-
(6, 16, 0.4, 0.7, 8_000_000_000_000_u64),
5347-
(7, 17, 0.5, 0.8, 600_000_000_000_u64),
5348-
(8, 18, 0.6, 0.9, 700_000_000_000_u64),
5349-
(9, 19, 0.7, 1.0, 100_000_000_000_u64),
5350-
(10, 20, 0.8, 1.1, 300_000_000_000_u64),
5351-
] {
5352-
SubtensorModule::create_account_if_non_existent(&U256::from(coldkey), &U256::from(hotkey));
5353-
SubtensorModule::add_balance_to_coldkey_account(
5354-
&U256::from(coldkey),
5355-
1_000_000_000_000_000,
5356-
);
5357-
SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet(
5358-
&U256::from(hotkey),
5359-
&U256::from(coldkey),
5360-
netuid.into(),
5361-
1_000_000_000_000_000.into(),
5362-
);
5363-
5364-
let tick_low = price_to_tick(low_price);
5365-
let tick_high = price_to_tick(high_price);
5366-
let add_lq_call = SwapCall::<Test>::add_liquidity {
5367-
hotkey: U256::from(hotkey),
5368-
netuid: netuid.into(),
5369-
tick_low,
5370-
tick_high,
5371-
liquidity,
5372-
};
5373-
assert_ok!(
5374-
RuntimeCall::Swap(add_lq_call).dispatch(RuntimeOrigin::signed(U256::from(coldkey)))
5375-
);
5376-
}
5377-
}
5338+
// TODO: Revise when user liquidity is available
5339+
// fn setup_positions(netuid: NetUid) {
5340+
// for (coldkey, hotkey, low_price, high_price, liquidity) in [
5341+
// (2, 12, 0.1, 0.20, 1_000_000_000_000_u64),
5342+
// (3, 13, 0.15, 0.25, 200_000_000_000_u64),
5343+
// (4, 14, 0.25, 0.5, 3_000_000_000_000_u64),
5344+
// (5, 15, 0.3, 0.6, 300_000_000_000_u64),
5345+
// (6, 16, 0.4, 0.7, 8_000_000_000_000_u64),
5346+
// (7, 17, 0.5, 0.8, 600_000_000_000_u64),
5347+
// (8, 18, 0.6, 0.9, 700_000_000_000_u64),
5348+
// (9, 19, 0.7, 1.0, 100_000_000_000_u64),
5349+
// (10, 20, 0.8, 1.1, 300_000_000_000_u64),
5350+
// ] {
5351+
// SubtensorModule::create_account_if_non_existent(&U256::from(coldkey), &U256::from(hotkey));
5352+
// SubtensorModule::add_balance_to_coldkey_account(
5353+
// &U256::from(coldkey),
5354+
// 1_000_000_000_000_000,
5355+
// );
5356+
// SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet(
5357+
// &U256::from(hotkey),
5358+
// &U256::from(coldkey),
5359+
// netuid.into(),
5360+
// 1_000_000_000_000_000.into(),
5361+
// );
5362+
5363+
// let tick_low = price_to_tick(low_price);
5364+
// let tick_high = price_to_tick(high_price);
5365+
// let add_lq_call = SwapCall::<Test>::add_liquidity {
5366+
// hotkey: U256::from(hotkey),
5367+
// netuid: netuid.into(),
5368+
// tick_low,
5369+
// tick_high,
5370+
// liquidity,
5371+
// };
5372+
// assert_ok!(
5373+
// RuntimeCall::Swap(add_lq_call).dispatch(RuntimeOrigin::signed(U256::from(coldkey)))
5374+
// );
5375+
// }
5376+
// }
53785377

53795378
#[test]
53805379
fn test_large_swap() {
@@ -5397,7 +5396,8 @@ fn test_large_swap() {
53975396
)
53985397
.unwrap();
53995398

5400-
setup_positions(netuid.into());
5399+
// TODO: Revise when user liquidity is available
5400+
// setup_positions(netuid.into());
54015401

54025402
let swap_amount = TaoCurrency::from(100_000_000_000_000);
54035403
assert_ok!(SubtensorModule::add_stake(

pallets/swap/src/benchmarking.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,33 @@ mod benchmarks {
3232
set_fee_rate(RawOrigin::Root, netuid, rate);
3333
}
3434

35-
#[benchmark]
36-
fn add_liquidity() {
37-
let netuid = NetUid::from(1);
35+
// TODO: Revise when user liquidity is available
36+
// #[benchmark]
37+
// fn add_liquidity() {
38+
// let netuid = NetUid::from(1);
3839

39-
if !SwapV3Initialized::<T>::get(netuid) {
40-
SwapV3Initialized::<T>::insert(netuid, true);
41-
AlphaSqrtPrice::<T>::insert(netuid, U64F64::from_num(1));
42-
CurrentTick::<T>::insert(netuid, TickIndex::new(0).unwrap());
43-
CurrentLiquidity::<T>::insert(netuid, T::MinimumLiquidity::get());
44-
}
40+
// if !SwapV3Initialized::<T>::get(netuid) {
41+
// SwapV3Initialized::<T>::insert(netuid, true);
42+
// AlphaSqrtPrice::<T>::insert(netuid, U64F64::from_num(1));
43+
// CurrentTick::<T>::insert(netuid, TickIndex::new(0).unwrap());
44+
// CurrentLiquidity::<T>::insert(netuid, T::MinimumLiquidity::get());
45+
// }
4546

46-
let caller: T::AccountId = whitelisted_caller();
47-
let hotkey: T::AccountId = account("hotkey", 0, 0);
48-
let tick_low = TickIndex::new_unchecked(-1000);
49-
let tick_high = TickIndex::new_unchecked(1000);
47+
// let caller: T::AccountId = whitelisted_caller();
48+
// let hotkey: T::AccountId = account("hotkey", 0, 0);
49+
// let tick_low = TickIndex::new_unchecked(-1000);
50+
// let tick_high = TickIndex::new_unchecked(1000);
5051

51-
#[extrinsic_call]
52-
add_liquidity(
53-
RawOrigin::Signed(caller),
54-
hotkey,
55-
netuid,
56-
tick_low,
57-
tick_high,
58-
1000,
59-
);
60-
}
52+
// #[extrinsic_call]
53+
// add_liquidity(
54+
// RawOrigin::Signed(caller),
55+
// hotkey,
56+
// netuid,
57+
// tick_low,
58+
// tick_high,
59+
// 1000,
60+
// );
61+
// }
6162

6263
#[benchmark]
6364
fn remove_liquidity() {

0 commit comments

Comments
 (0)