Skip to content

Commit 6912434

Browse files
committed
Merge branch 'devnet-ready' into reveal-tl-commitments-weights
2 parents a271c90 + bc7469b commit 6912434

File tree

13 files changed

+66
-96
lines changed

13 files changed

+66
-96
lines changed

.github/workflows/docker-localnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ permissions:
2828

2929
jobs:
3030
publish:
31-
runs-on: [self-hosted, type-ccx33]
31+
runs-on: [self-hosted, type-ccx53, type-ccx43, type-ccx33]
3232

3333
steps:
3434
- name: Determine Docker tag and ref

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ permissions:
2727

2828
jobs:
2929
publish:
30-
runs-on: [self-hosted, type-ccx33]
30+
runs-on: [self-hosted, type-ccx53, type-ccx43, type-ccx33]
3131

3232
steps:
3333
- name: Determine Docker tag and ref

node/src/command.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,14 @@ fn customise_config(arg_matches: &ArgMatches, config: Configuration) -> Configur
318318

319319
// If the operator did **not** supply `--rpc-max-subscriptions-per-connection` set to high value.
320320
config.rpc.max_subs_per_conn = match arg_matches
321-
.value_source("rpc-max-subscriptions-per-connection")
321+
.value_source("rpc_max_subscriptions_per_connection")
322322
{
323323
Some(ValueSource::CommandLine) => cli.run.rpc_params.rpc_max_subscriptions_per_connection,
324324
_ => 10000,
325325
};
326326

327327
// If the operator did **not** supply `--rpc-max-connections` set to high value.
328-
config.rpc.max_connections = match arg_matches.value_source("rpc-max-connections") {
328+
config.rpc.max_connections = match arg_matches.value_source("rpc_max_connections") {
329329
Some(ValueSource::CommandLine) => cli.run.rpc_params.rpc_max_connections,
330330
_ => 10000,
331331
};

pallets/subtensor/src/benchmarks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,7 @@ mod pallet_benchmarks {
10731073
Subtensor::<T>::init_new_network(netuid, 1);
10741074
Subtensor::<T>::set_network_registration_allowed(netuid, true);
10751075
SubtokenEnabled::<T>::insert(netuid, true);
1076+
Subtensor::<T>::set_commit_reveal_weights_enabled(netuid, false);
10761077

10771078
let reg_fee = Subtensor::<T>::get_burn(netuid);
10781079
Subtensor::<T>::add_balance_to_coldkey_account(&hotkey, reg_fee.to_u64().saturating_mul(2));

pallets/subtensor/src/coinbase/run_coinbase.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ impl<T: Config> Pallet<T> {
3939
log::debug!("Subnets to emit to: {subnets_to_emit_to:?}");
4040

4141
// --- 2. Get sum of tao reserves ( in a later version we will switch to prices. )
42-
let mut total_moving_prices = U96F32::saturating_from_num(0.0);
42+
let mut acc_total_moving_prices = U96F32::saturating_from_num(0.0);
4343
// Only get price EMA for subnets that we emit to.
4444
for netuid_i in subnets_to_emit_to.iter() {
4545
// Get and update the moving price of each subnet adding the total together.
46-
total_moving_prices =
47-
total_moving_prices.saturating_add(Self::get_moving_alpha_price(*netuid_i));
46+
acc_total_moving_prices =
47+
acc_total_moving_prices.saturating_add(Self::get_moving_alpha_price(*netuid_i));
4848
}
49+
let total_moving_prices = acc_total_moving_prices;
4950
log::debug!("total_moving_prices: {total_moving_prices:?}");
5051

5152
// --- 3. Get subnet terms (tao_in, alpha_in, and alpha_out)
@@ -183,21 +184,22 @@ impl<T: Config> Pallet<T> {
183184
});
184185
}
185186

187+
// Get total TAO on root.
188+
let root_tao: U96F32 = asfloat!(SubnetTAO::<T>::get(NetUid::ROOT));
189+
log::debug!("root_tao: {root_tao:?}");
190+
// Get tao_weight
191+
let tao_weight: U96F32 = root_tao.saturating_mul(Self::get_tao_weight());
192+
log::debug!("tao_weight: {tao_weight:?}");
193+
186194
// --- 6. Seperate out root dividends in alpha and sell them into tao.
187195
// Then accumulate those dividends for later.
188196
for netuid_i in subnets_to_emit_to.iter() {
189197
// Get remaining alpha out.
190198
let alpha_out_i: U96F32 = *alpha_out.get(netuid_i).unwrap_or(&asfloat!(0.0));
191199
log::debug!("alpha_out_i: {alpha_out_i:?}");
192-
// Get total TAO on root.
193-
let root_tao: U96F32 = asfloat!(SubnetTAO::<T>::get(NetUid::ROOT));
194-
log::debug!("root_tao: {root_tao:?}");
195200
// Get total ALPHA on subnet.
196201
let alpha_issuance: U96F32 = asfloat!(Self::get_alpha_issuance(*netuid_i));
197202
log::debug!("alpha_issuance: {alpha_issuance:?}");
198-
// Get tao_weight
199-
let tao_weight: U96F32 = root_tao.saturating_mul(Self::get_tao_weight());
200-
log::debug!("tao_weight: {tao_weight:?}");
201203
// Get root proportional dividends.
202204
let root_proportion: U96F32 = tao_weight
203205
.checked_div(tao_weight.saturating_add(alpha_issuance))
@@ -239,14 +241,14 @@ impl<T: Config> Pallet<T> {
239241
});
240242
}
241243

242-
// --- 7 Update moving prices after using them in the emission calculation.
244+
// --- 7. Update moving prices after using them in the emission calculation.
243245
// Only update price EMA for subnets that we emit to.
244246
for netuid_i in subnets_to_emit_to.iter() {
245247
// Update moving prices after using them above.
246248
Self::update_moving_price(*netuid_i);
247249
}
248250

249-
// --- 7. Drain pending emission through the subnet based on tempo.
251+
// --- 8. Drain pending emission through the subnet based on tempo.
250252
// Run the epoch for *all* subnets, even if we don't emit anything.
251253
for &netuid in subnets.iter() {
252254
// Reveal matured weights.

pallets/subtensor/src/macros/dispatches.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ mod dispatches {
120120
/// - On failure for each failed item in the batch.
121121
///
122122
#[pallet::call_index(80)]
123-
#[pallet::weight((Weight::from_parts(19_540_000, 0)
124-
.saturating_add(T::DbWeight::get().reads(1_u64))
125-
.saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))]
123+
#[pallet::weight((Weight::from_parts(95_160_000, 0)
124+
.saturating_add(T::DbWeight::get().reads(14))
125+
.saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))]
126126
pub fn batch_set_weights(
127127
origin: OriginFor<T>,
128128
netuids: Vec<Compact<NetUid>>,
@@ -2156,7 +2156,7 @@ mod dispatches {
21562156
/// Emits a `SymbolUpdated` event on success.
21572157
#[pallet::call_index(112)]
21582158
#[pallet::weight((
2159-
Weight::from_parts(26_880_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)),
2159+
Weight::from_parts(26_200_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)),
21602160
DispatchClass::Operational,
21612161
Pays::Yes
21622162
))]

pallets/subtensor/src/staking/helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,15 @@ impl<T: Config> Pallet<T> {
184184
) {
185185
// Verify if the account is a nominator account by checking ownership of the hotkey by the coldkey.
186186
if !Self::coldkey_owns_hotkey(coldkey, hotkey) {
187-
// If the stake is below the minimum required, it's considered a small nomination and needs to be cleared.
187+
// If the stake is non-zero and below the minimum required, it's considered a small nomination and needs to be cleared.
188188
// Log if the stake is below the minimum required
189189
let alpha_stake =
190190
Self::get_stake_for_hotkey_and_coldkey_on_subnet(hotkey, coldkey, netuid);
191191
let min_alpha_stake =
192192
U96F32::saturating_from_num(Self::get_nominator_min_required_stake())
193193
.safe_div(T::SwapInterface::current_alpha_price(netuid))
194194
.saturating_to_num::<u64>();
195-
if alpha_stake < min_alpha_stake.into() {
195+
if alpha_stake > 0.into() && alpha_stake < min_alpha_stake.into() {
196196
// Log the clearing of a small nomination
197197
// Remove the stake from the nominator account. (this is a more forceful unstake operation which )
198198
// Actually deletes the staking account.

pallets/subtensor/src/subnets/registration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl<T: Config> Pallet<T> {
369369

370370
// --- 5. Add Balance via faucet.
371371
let balance_to_add: u64 = 1_000_000_000_000;
372-
Self::coinbase(100_000_000_000.into()); // We are creating tokens here from the coinbase.
372+
Self::increase_issuance(100_000_000_000.into()); // We are creating tokens here from the coinbase.
373373

374374
Self::add_balance_to_coldkey_account(&coldkey, balance_to_add);
375375

pallets/subtensor/src/subnets/uids.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<T: Config> Pallet<T> {
8181
// 1. Get the next uid. This is always equal to subnetwork_n.
8282
let next_uid: u16 = Self::get_subnetwork_n(netuid);
8383
log::debug!(
84-
"append_neuron( netuid: {netuid:?} | next_uid: {new_hotkey:?} | new_hotkey: {next_uid:?} ) "
84+
"append_neuron( netuid: {netuid:?} | next_uid: {next_uid:?} | new_hotkey: {new_hotkey:?} ) "
8585
);
8686

8787
// 2. Get and increase the uid count.

pallets/subtensor/src/tests/swap_coldkey.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,8 +2493,12 @@ fn test_coldkey_in_swap_schedule_prevents_funds_usage() {
24932493
&TxBaseImplication(()),
24942494
TransactionSource::External,
24952495
);
2496-
// Should pass, not in list.
2497-
assert_ok!(result);
2496+
// Should fail
2497+
assert_eq!(
2498+
// Should get an invalid transaction error
2499+
result.unwrap_err(),
2500+
CustomTransactionError::ColdkeyInSwapSchedule.into()
2501+
);
24982502

24992503
// Remove stake limit
25002504
let call = RuntimeCall::SubtensorModule(SubtensorCall::remove_stake_limit {
@@ -2513,7 +2517,27 @@ fn test_coldkey_in_swap_schedule_prevents_funds_usage() {
25132517
&TxBaseImplication(()),
25142518
TransactionSource::External,
25152519
);
2516-
// Should pass, not in list.
2520+
// Should fail
2521+
assert_eq!(
2522+
// Should get an invalid transaction error
2523+
result.unwrap_err(),
2524+
CustomTransactionError::ColdkeyInSwapSchedule.into()
2525+
);
2526+
2527+
// Schedule swap should succeed
2528+
let call = RuntimeCall::SubtensorModule(SubtensorCall::schedule_swap_coldkey {
2529+
new_coldkey: hotkey,
2530+
});
2531+
let result = extension.validate(
2532+
RawOrigin::Signed(who).into(),
2533+
&call.clone(),
2534+
&info,
2535+
10,
2536+
(),
2537+
&TxBaseImplication(()),
2538+
TransactionSource::External,
2539+
);
2540+
// Should be ok
25172541
assert_ok!(result);
25182542
});
25192543
}

0 commit comments

Comments
 (0)