Record miner burn as TAO outflow in coinbase#2692
Conversation
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>
| let tao_equivalent: TaoBalance = current_price | ||
| .saturating_mul(asfloat!(incentive)) | ||
| .saturating_to_num::<u64>() | ||
| .into(); | ||
| Self::record_tao_outflow(netuid, tao_equivalent); |
There was a problem hiding this comment.
[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.
| 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(); |
🛡️ 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
ConclusionThe PR is small and matches the stated coinbase-accounting path, but it introduces a new synthetic # 🔍 AI Review — Auditor (domain review) has not yet run on this PR. |
|
🔄 AI review updated — Skeptic: VULNERABLE |
Summary
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 theowner_hotkeys.contains(&hotkey)branch of the incentives loop, just before theRecycleOrBurnmatch.Test plan
cargo check -p pallet-subtensor— cleancargo test -p pallet-subtensor --lib tests::coinbaseSubnetTaoFlowdecreases by the expected TAO-equivalent on a subnet where an owner hotkey appears in theincentiveslistMade with Cursor