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>
🛡️ AI Review — Skeptic (security review)VERDICT: SAFE BASELINE scrutiny: established write-permission contributor; no Gittensor allowlist hit; branch unconst/miner-burn-tao-outflow -> devnet-ready. The PR touches one pallet runtime file and does not modify FindingsNo findings. Prior-comment reconciliation
ConclusionNo malicious intent or security vulnerability found in the current diff. The previous accounting issue is addressed and I found no new panic, overflow, origin-bypass, supply-chain, or trust-file risk. 📜 Previous run (superseded)
🔍 AI Review — Auditor (domain review)VERDICT: 👎 Write-permission opentensor contributor with substantial prior history; no Gittensor allowlist match found, so standard duplicate-work scrutiny applied. PR body is substantive and matches the implementation. I checked the overlapping open PRs listed in the pre-fetched context (#2659, #2645, #2638, #2603, #2505); they touch the same file but do not implement this miner-burn TAO-flow accounting, so none is a better duplicate candidate. No auto-fixes were applied. The devnet spec-version RPC could not be resolved from this environment, so I could not safely determine whether an automatic Findings
ConclusionThe accounting direction looks plausible, but the new storage mutation is inside the coinbase |
|
🔄 AI review updated — Skeptic: VULNERABLE |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
🔄 AI review updated — Skeptic: VULNERABLE |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
| // Record the miner burn as a TAO outflow. The incentive is | ||
| // denominated in alpha, so convert to its TAO equivalent at | ||
| // the current spot price (no slippage, since no swap occurs). | ||
| let current_price: U96F32 = T::SwapInterface::current_alpha_price(netuid.into()); | ||
| let tao_equivalent: TaoBalance = current_price | ||
| .saturating_mul(asfloat!(incentive)) | ||
| .saturating_to_num::<u64>() | ||
| .min(i64::MAX as u64) | ||
| .into(); | ||
| Self::record_tao_outflow(netuid, tao_equivalent); |
There was a problem hiding this comment.
[HIGH] Avoid per-hotkey SubnetTaoFlow writes in on_initialize
run_coinbase is reached from the pallet on_initialize hook, which returns a fixed weight. This new record_tao_outflow call mutates SubnetTaoFlow once for every owner-associated hotkey skipped by the incentives loop. OwnedHotkeys is stored as an unbounded Vec, and the skip count is only indirectly bounded by registered UIDs, so this adds loop-amplified DB IO without updating the hook weight.
Aggregate the TAO equivalent into a local total and call record_tao_outflow(netuid, total) once after the incentives loop, or update the hook weight to cover the actual worst case. This should also get a targeted coinbase test asserting SubnetTaoFlow decreases by the expected spot-price TAO equivalent for skipped owner hotkey incentives.
|
🔄 AI review updated — Skeptic: SAFE Auditor: 👎 |
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