fix(api): round account-summary activity.total_fee_tao to rao precision#2352
Conversation
The account-summary signing-activity aggregate (loadAccountSummary, shared by
the REST /accounts/{ss58} route and the MCP get_account tool) reported
activity.total_fee_tao straight from a D1 SUM(fee_tao) without rounding, so the
payload leaked accumulated IEEE-754 float noise (e.g. 0.30000000000000004).
Every other TAO sum in the codebase rounds to rao precision (9 dp) for exactly
this reason -- the same signer-total-fee value is rounded via toTao in
buildChainSigners (/chain/signers) and buildChainFees (/chain/fees). Round it in
formatAccountActivity too (null-preserving, since the aggregate is null on a
cold store), so the same fee reads identically across endpoints.
Fixes JSONbored#2351
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-06-29 23:23:07 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2352 +/- ##
=======================================
Coverage 95.46% 95.47%
=======================================
Files 61 61
Lines 9777 9788 +11
Branches 3634 3637 +3
=======================================
+ Hits 9334 9345 +11
Misses 70 70
Partials 373 373
🚀 New features to boost your workflow:
|
Summary
GET /api/v1/accounts/{ss58}and the MCPget_accounttool (both shareloadAccountSummaryinsrc/account-events.mjs) reportedactivity.total_fee_taostraight from a D1SUM(fee_tao)aggregate, unrounded — so summing manyREALfee cells leaked accumulated IEEE-754 float noise (e.g.0.30000000000000004).toTaoinbuildChainSigners(/chain/signers) andbuildChainFees(/chain/fees); the account-summary path was the one that was missed, so the endpoints disagreed on the precision of the same number.Fixes #2351
What Changed
src/account-events.mjs: added a null-preservingtoTaoOrNullhelper (rounds to 9 dp, keepsnullfor the cold-store aggregate) and used it foractivity.total_fee_taoinformatAccountActivity. MirrorstoTaoinsrc/chain-analytics.mjs; null-preserving because the activity aggregate isnull(not0) on a cold store. No schema/contract change — same field, same type, just without the float tail.tests/account-events.test.mjs: added a regression test asserting a noisy sum (0.1 + 0.2) rounds to0.3, a sub-rao tail is rounded to 9 dp, and an absent aggregate staysnull.Registry Safety
Validation
npm run check(lint clean; format check passes on CI's LF checkout)npm run worker:test(tests/account-events.test.mjs: 45 passed, incl. new regression test)git diff --check