Skip to content

Record miner burn as TAO outflow in coinbase#2692

Open
unconst wants to merge 1 commit into
devnet-readyfrom
unconst/miner-burn-tao-outflow
Open

Record miner burn as TAO outflow in coinbase#2692
unconst wants to merge 1 commit into
devnet-readyfrom
unconst/miner-burn-tao-outflow

Conversation

@unconst
Copy link
Copy Markdown
Contributor

@unconst unconst commented May 25, 2026

Summary

  • When the coinbase incentive loop encounters an SN-owner-associated hotkey, it skips the payout and recycles or burns the incentive. The corresponding TAO leaving the pool was not being recorded.
  • This PR converts the skipped alpha incentive to its TAO equivalent at the current spot price (no slippage, since no swap occurs) and calls record_tao_outflow(netuid, tao_equivalent) so the subnet's TAO flow accounting stays in sync with what actually leaves circulation on this path.

Code path touched: pallets/subtensor/src/coinbase/run_coinbase.rs, inside the owner_hotkeys.contains(&hotkey) branch of the incentives loop, just before the RecycleOrBurn match.

Test plan

  • cargo check -p pallet-subtensor — clean
  • Existing coinbase tests still pass: cargo test -p pallet-subtensor --lib tests::coinbase
  • Spot-check that SubnetTaoFlow decreases by the expected TAO-equivalent on a subnet where an owner hotkey appears in the incentives list

Made with Cursor

When the SN-owner-hotkey path skips a miner incentive (and the alpha
is then recycled or burned), reflect the corresponding TAO leaving
the pool by calling record_tao_outflow. The skipped incentive is
denominated in alpha, so it is valued at the current spot price for
the outflow accounting (no swap occurs, so no slippage applies).

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment on lines +626 to +630
let tao_equivalent: TaoBalance = current_price
.saturating_mul(asfloat!(incentive))
.saturating_to_num::<u64>()
.into();
Self::record_tao_outflow(netuid, tao_equivalent);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[MEDIUM] Clamp the synthetic outflow before recording signed flow

record_tao_outflow stores into SubnetTaoFlow<i64> by casting u64::from(tao) as i64. This new path derives tao_equivalent from spot price times incentive and can saturate above i64::MAX; once that happens the cast becomes negative, and saturating_sub(negative) records an inflow instead of an outflow. A subnet owner hotkey can trigger this branch, so this can distort flow-based emission accounting. Bound the synthetic outflow to the signed accumulator range before recording it, or change the recorder to use a checked/clamped conversion.

Suggested change
let tao_equivalent: TaoBalance = current_price
.saturating_mul(asfloat!(incentive))
.saturating_to_num::<u64>()
.into();
Self::record_tao_outflow(netuid, tao_equivalent);
let tao_equivalent: TaoBalance = current_price
.saturating_mul(asfloat!(incentive))
.saturating_to_num::<u64>()
.min(i64::MAX as u64)
.into();

@github-actions
Copy link
Copy Markdown
Contributor

🛡️ AI Review — Skeptic (security review)

VERDICT: VULNERABLE

BASELINE scrutiny: established write-permission contributor, long prior subtensor history, no Gittensor allowlist hit; branch unconst/miner-burn-tao-outflow -> devnet-ready.

Findings

Sev File Finding
MEDIUM pallets/subtensor/src/coinbase/run_coinbase.rs:630 Clamp the synthetic outflow before recording signed flow inline

Conclusion

The PR is small and matches the stated coinbase-accounting path, but it introduces a new synthetic TaoBalance outflow that can exceed the signed SubnetTaoFlow accumulator’s range. Clamp or otherwise bound the value before passing it to record_tao_outflow.


# 🔍 AI Review — Auditor (domain review) has not yet run on this PR.

@github-actions
Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: VULNERABLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant