Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
54e7033
change name of reveal fn and move to block step
camfairchild Nov 6, 2025
8ad48b3
update moving prices outside of coinbase
camfairchild Nov 6, 2025
f00a7ac
filter root out just in case
camfairchild Nov 6, 2025
feeee61
refactor coinbase
camfairchild Nov 6, 2025
4abd92d
chore: fmt
camfairchild Nov 6, 2025
1f965d4
chore: clippy
camfairchild Nov 6, 2025
1ea4ddf
add test for reg disabled
camfairchild Nov 6, 2025
7a9b662
refactor get sn terms
camfairchild Nov 6, 2025
0b5df3c
test wip -- set price
camfairchild Nov 6, 2025
fb0cd73
make maybe init v3 pub
camfairchild Nov 6, 2025
6e20035
add type
camfairchild Nov 6, 2025
660b1c6
fix coinbase test
camfairchild Nov 6, 2025
a0c2369
rename test vars and add comment
camfairchild Nov 6, 2025
8652a5f
rename fn
camfairchild Nov 6, 2025
ba0fae0
rename sub -> excess
camfairchild Nov 6, 2025
47a5d54
Merge branch 'hotfix/vune/epoch-fn-inp' into feat/new-coinbase
camfairchild Nov 6, 2025
8e6286c
remove ref to subs
camfairchild Nov 6, 2025
c38aa09
remove dup fn
camfairchild Nov 6, 2025
61227c8
rename vars
camfairchild Nov 6, 2025
c2598a9
add test for injection order
camfairchild Nov 7, 2025
09a2cac
add comment to test
camfairchild Nov 7, 2025
3b9c11e
add tests for drain pending
camfairchild Nov 7, 2025
1b540d9
rename test
camfairchild Nov 7, 2025
d3d5819
rename tests
camfairchild Nov 7, 2025
f1c0476
lower eps
camfairchild Nov 7, 2025
9de47ed
add another subnetterms test
camfairchild Nov 7, 2025
01f8f61
remove unneeded test setup
camfairchild Nov 7, 2025
16822b4
wip
camfairchild Nov 7, 2025
f4eb1ad
Merge branch 'main' into feat/new-coinbase
camfairchild Nov 8, 2025
8b8f763
move reg disabled filter to sn to emit to
camfairchild Nov 8, 2025
b4f259e
Merge branch 'main' into feat/new-coinbase
camfairchild Nov 12, 2025
e3400c9
Merge branch 'devnet-ready' into feat/new-coinbase
camfairchild Nov 12, 2025
5dfdf47
fix test for change from main
camfairchild Nov 12, 2025
5cfed02
remove line from merge resolution
camfairchild Nov 12, 2025
55e52c1
refactor emit_to_sns
camfairchild Nov 12, 2025
e0e8c9b
bump spec
camfairchild Nov 12, 2025
6511867
Merge remote-tracking branch 'origin/devnet-ready' into feat/new-coin…
sam0x17 Nov 12, 2025
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
33 changes: 29 additions & 4 deletions pallets/subtensor/src/coinbase/block_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ impl<T: Config + pallet_drand::Config> Pallet<T> {
.to_u64(),
);
log::debug!("Block emission: {block_emission:?}");
// --- 3. Run emission through network.

// --- 3. Reveal matured weights.
Self::reveal_crv3_commits();
// --- 4. Run emission through network.
Self::run_coinbase(block_emission);
// --- 4. Set pending children on the epoch; but only after the coinbase has been run.
// --- 5. Update moving prices AFTER using them for emissions.
Self::update_moving_prices();
// --- 6. Set pending children on the epoch; but only after the coinbase has been run.
Self::try_set_pending_children(block_number);
// --- 5. Run auto-claim root divs.
// --- 7. Run auto-claim root divs.
Self::run_auto_claim_root_divs(last_block_hash);
// --- 6. Populate root coldkey maps.
// --- 8. Populate root coldkey maps.
Self::populate_root_coldkey_staking_maps();

// Return ok.
Expand Down Expand Up @@ -261,4 +266,24 @@ impl<T: Config + pallet_drand::Config> Pallet<T> {
return next_value.saturating_to_num::<u64>().into();
}
}

pub fn update_moving_prices() {
let subnets_to_emit_to: Vec<NetUid> =
Self::get_subnets_to_emit_to(&Self::get_all_subnet_netuids());
// Only update price EMA for subnets that we emit to.
for netuid_i in subnets_to_emit_to.iter() {
// Update moving prices after using them above.
Self::update_moving_price(*netuid_i);
}
}

pub fn reveal_crv3_commits() {
let netuids: Vec<NetUid> = Self::get_all_subnet_netuids();
for netuid in netuids.into_iter().filter(|netuid| *netuid != NetUid::ROOT) {
// Reveal matured weights.
if let Err(e) = Self::reveal_crv3_commits_for_subnet(netuid) {
log::warn!("Failed to reveal commits for subnet {netuid} due to error: {e:?}");
};
}
}
}
2 changes: 1 addition & 1 deletion pallets/subtensor/src/coinbase/reveal_commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct LegacyWeightsTlockPayload {

impl<T: Config> Pallet<T> {
/// The `reveal_crv3_commits` function is run at the very beginning of epoch `n`,
pub fn reveal_crv3_commits(netuid: NetUid) -> dispatch::DispatchResult {
pub fn reveal_crv3_commits_for_subnet(netuid: NetUid) -> dispatch::DispatchResult {
let reveal_period = Self::get_reveal_period(netuid);
let cur_block = Self::get_current_block_as_u64();
let cur_epoch = Self::get_epoch_index(netuid, cur_block);
Expand Down
331 changes: 182 additions & 149 deletions pallets/subtensor/src/coinbase/run_coinbase.rs

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions pallets/subtensor/src/coinbase/subnet_emissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ use subtensor_swap_interface::SwapHandler;

impl<T: Config> Pallet<T> {
pub fn get_subnets_to_emit_to(subnets: &[NetUid]) -> Vec<NetUid> {
// Filter out root subnet.
// Filter out subnets with no first emission block number.
subnets
.iter()
.filter(|netuid| !netuid.is_root())
.filter(|netuid| FirstEmissionBlockNumber::<T>::get(*netuid).is_some())
.filter(|netuid| SubtokenEnabled::<T>::get(*netuid))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is such a better place to do this filter.

.filter(|&netuid| {
// Only emit TAO if the subnetwork allows registration.
Self::get_network_registration_allowed(*netuid)
|| Self::get_network_pow_registration_allowed(*netuid)
})
.copied()
.collect()
}
Expand Down
Loading
Loading