steem.dao and null balances are never cleared - consolidate_treasury_balance / clear_null_account_balance leave permanently inflated balances (steem.dao is rank 1 in /top-holders)
Summary
steem.dao and null are never cleared. Both carry balances that hived reports as zero, on every public deployment, and steem.dao grows every hour.
Hived sweeps these two accounts to zero in consensus, but announces it with virtual operations that btracker cannot act on:
consolidate_treasury_balance_operationcarries onlytotal_moved— the swept account is an implicit constant, not a field. HAF core's balance collector emits ahive.fundcredit and no matching debit.clear_null_account_balance_operationis different: HAF core's visitor body is empty, so nothing is emitted at all. The op does carrytotal_cleared, but as the code comment notes it is a summary lumping liquid, savings and pending rewards together, so it cannot be applied as a liquid debit.
In both cases HAF core deliberately delegates the clearing to consumers, naming balance_tracker in the source comments. btracker already honours that contract for the third operation in the same family — hardfork_hive_operation, handled by btracker_backend.process_hf_23 in backend/operation_parsers/hardforks.sql (shipped in !146 (merged)), which zeroes current_account_balances, account_rewards and account_savings together. The same contract is simply not implemented for these two.
This is not a wrong emission — it is a missing step. btracker's SQL port of get_impacted_balances is faithful to the C visitor by design and is guarded by a parity test; the defect is the absence of a compensating clear downstream, of the kind process_hf_23 already performs.
Environment
- Observed on five independent deployments (see Blast radius). Primary:
https://api.syncad.com/balance-api,/version=f4e34ef588665b9aa2c9f58c3ae746d88bae38bf= tag 1.28.6,/last-synced-block109,833,574 — current, not lagging. - Both code paths affected. At 1.28.6 the pipeline calls HAF core directly (
db/process_balances.sql:87-90→hive.get_impacted_balances);backend/operation_parsers/impacted_balances.sqldoes not exist at that tag. Ondevelop(b9f72443) and1.29.0-rc1the SQL port from !369 (merged) reproduces the same emission, so the defect survives the rewrite. - Code reviewed at balance_tracker
developb9f72443and tag1.28.6; hive/hive atmasteranddevelop(identical in the relevant lines). - Not verified against 1.29.0-rc1 as deployed.
Observed vs expected
Captured 2026-09-11 23:09 UTC, block 109,833,574. There is no at-block balance read (cf. #60 (closed)), so re-running shows larger numbers for every row except steem.dao HIVE.
| account | field | btracker | hived database_api.find_accounts |
|---|---|---|---|
| steem.dao | HBD | 258,381,783,930 | 0 |
| steem.dao | HIVE | 83,353,473,585 | 0 |
| null | HBD | 207,061,532 | 0 |
| null | HIVE | 4,984,406,321 | 0 |
| null | HBD savings | 1 | 0 |
| null | vesting_shares | 8,113,850 | 0 |
Agreed exactly by three independent hived nodes (api.hive.blog, api.openhive.network, rpc.mahdiyari.info).
steem.dao's phantom HBD is 8.07× current_hbd_supply (32,005,942,396) and its phantom HIVE is 14.24% of current_supply (585,457,911,467).
This is not endpoint-wide. Of 12 accounts sampled through the same endpoint, 9 match hived to the last milli-unit including savings — blocktrades (53,311 HBD / 277,701 HIVE / 50,974,508 HBD savings) and deepcrypto8 are exact. hive.fund tracks to 0.00078% (HIVE exact; HBD ~181,482 milli low and widening ~18/block, consistent with per-block DHF accrual booked only on discrete vops). Only steem.dao and null are wrong, and they are wrong by 8 orders of magnitude.
Reproduction
# 0. The mechanism, on chain. The Return Proposal pays steem.dao; hived sweeps it back
# in the next block. btracker books the payment and only the credit half of the sweep.
curl -s "https://api.syncad.com/hafah-api/blocks/109832958/operations?operation-types=66"
curl -s "https://api.syncad.com/hafah-api/blocks/109832959/operations?operation-types=71"
# 1. btracker: 258.4M HBD / 83.35M HIVE
curl -s "https://api.syncad.com/balance-api/accounts/steem.dao/balances"
# 2. hived: zero on every balance field
curl -s -X POST https://api.hive.blog -H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","method":"database_api.find_accounts","params":{"accounts":["steem.dao"]},"id":1}'
# 3. Control: a normal account is exact through the same endpoint, savings included.
curl -s "https://api.syncad.com/balance-api/accounts/blocktrades/balances"
# 4. Leaderboards: steem.dao rank 1 HBD and rank 2 HIVE; null rank 4 HBD and rank 7 HIVE.
curl -s "https://api.syncad.com/balance-api/top-holders?coin-type=HBD&page-size=10"
curl -s "https://api.syncad.com/balance-api/top-holders?coin-type=HIVE&page-size=10"
# 5. The series has not been debited since HF24: min_balance never dips below the
# prior period's close.
curl -s "https://api.syncad.com/balance-api/accounts/steem.dao/aggregated-history?coin-type=HBD&granularity=yearly&direction=desc"
# 6. Same defect on null (liquid, savings and vesting_shares all non-zero).
curl -s "https://api.syncad.com/balance-api/accounts/null/balances"Root cause
Why the sweep is invisible. hive/hive libraries/protocol/include/hive/protocol/hive_virtual_operations.hpp:404-407 (@ master):
struct consolidate_treasury_balance_operation : public virtual_operation
{
vector< asset > total_moved; //(HIVE, VESTS or HBD) funds moved from old to new treasury
};FC_REFLECT(..., (total_moved)) at :846. The swept account is OBSOLETE_TREASURY_ACCOUNT (config.hpp:456), a compile-time constant — it never appears in the op body.
HAF core delegates the clearing, by name. libraries/protocol/forward_impacted.cpp:801-817 (@ master, identical at tag 1.28.6):
void operator()(const clear_null_account_balance_operation& o)
{
// balance tracker and similar apps need to clear all balances or even skip handling null account altogether
// vop will not contain all the information necessary (f.e. it only has summary including savings and pending
// rewards, adding all details would bloat the vop)
}
void operator()(const consolidate_treasury_balance_operation& o)
{
// balance tracker and similar apps need to clear all balances of OBSOLETE_TREASURY_ACCOUNT like in case
// of clear_null_account_balance_operation
// NOTE: there is a potential problem, since the related routine rewrites balances one to one; normally
// treasury cannot have rewards or savings, but if it somehow did (f.e. if old treasury were treated like normal
// account due to bug), then we'd be erroneously counting reward/saving balances towards liquid balances
for( auto& value : o.total_moved )
emplace_back(NEW_HIVE_TREASURY_ACCOUNT, value);
}The account-impact visitor at :540-546 inserts both treasuries; the balance collector inserts only the new one. That asymmetry is deliberate upstream — and note that both comments name "balance tracker" explicitly as the party responsible for the clear.
For these two ops, btracker implements nothing, at any ref. A full-tree scan for steem.dao|OBSOLETE_TREASURY|consolidate_treasury|clear_null (note this deliberately excludes hardfork_hive_operation, which is handled — see Summary):
| ref | files | hits |
|---|---|---|
| 1.28.6 (deployed) | 333 | 0 — nothing anywhere |
| 1.29.0-rc1 | 440 | only the credit-only emission + parity fixtures |
develop b9f72443 |
441 | same, plus the batch-parity fixture |
No zeroing, no exclusion, no filter, no special case for either op — in db/process_balances.sql, db/btracker_app.sql, any migration, or backend/endpoint_helpers/get_top_holders/top_holders.sql (which filters only WHERE nai = _coin_type). Never implemented, rather than implemented and broken — while the sibling op's clear sits a few files away in hardforks.sql.
On develop the SQL port inherits it verbatim — backend/operation_parsers/impacted_balances.sql:163-165 (and :309-311 for the batch form) emit 'hive.fund', 1, elem with no matching -1, while clear_null_account_balance_operation has no branch at all. Its header explains why, and that is correct: "This must stay byte-for-byte equivalent to the C++ visitor... operations whose C++ overload is empty... intentionally have no branch and emit nothing."
Why it grows, forever. condenser_api.find_proposals([[0]]):
{"id":0,"creator":"gtg","receiver":"steem.dao","start_date":"2019-08-27T00:00:00",
"daily_pay":"240000000.000 HBD","subject":"Return Proposal"}The Return Proposal was created pre-HF24 and its receiver was never migrated at the treasury rename. dhf_processor.cpp:174 pays db.get_treasury_name() → hive.fund to that stored receiver, so every maintenance period pays hive.fund → steem.dao.
The pairing is structural, not incidental: in database::_apply_block, consolidate_treasury_balance() runs at line 2337 (early, every block) while process_proposals() runs at 2350 (late). A payout in block N is therefore swept in block N+1. Measured:
block 109,832,958 proposal_pay_operation {payer: hive.fund, receiver: steem.dao,
proposal_id: 0, amount: 9,111,643 milli-HBD}
block 109,832,959 consolidate_treasury_balance_operation {total_moved: [9,111,643 @@000000013]}btracker books the first in full and only the credit half of the second: hive.fund nets to ~0 and stays correct, steem.dao keeps the payment. Measured accrual ~9,111,600 milli-HBD/hour (~218,679 HBD/day), one credit per hour at :38:06.
The HBD series has not been debited since HF24. Across all 143,397 operations, 73,665 are debits — every one of them before block 47,797,680 (2020-10-14, HF24), when proposal_pay_operation still carried both signs. Since that block: ~69,700 consecutive credits, zero debits, 5 years 11 months.
The HIVE side is frozen. Last movement was block 47,797,680, 2020-10-14T19:31:24, a hardfork_hive_restore_operation. 628 operations total, nothing since. The hardfork_hive_restore_operations debited correctly — they carry a treasury field — but the bulk 83,353,473,585 was moved by consolidate and never removed.
null grows too, irregularly, driven by user burns (transfer, transfer_to_vesting): +73,007 milli-HIVE in the 29 hours while this report was being prepared.
Blast radius
- Five independent deployments return byte-identical phantom values:
api.syncad.com,api.hive.blog,rpc.mahdiyari.info,hiveapi.actifit.io,api.c0ff33a.uk. Theirlast-synced-blockvalues differ, so these are separate syncing instances — andapi.hive.blogruns a different build (aeb6be25…) and still produces the same number. Deterministic in the indexing logic, not local data corruption. /top-holders:steem.daois rank 1 HBD (11.1× the true top real holder) and rank 2 HIVE;nullis rank 4 HBD and rank 7 HIVE. Two of the top ten in each list.- Block Explorer UI already works around this without knowing what it is.
utils/systemAccounts.tsexcludes treasury/burn from concentration KPIs, so the Nakamoto and Top-N figures are protected — but the ranking table still displays the phantom values, andpages/top-holders.tsx:109-112documents a supply-base guard written around this exact defect: "the DHF holds far more HBD than that figure. Subtracting it outright would make the base negative, so system balances are only removed when they fit inside the supply." Consumers without that workaround get the raw values. - Both accounts'
/balances,/balance-historyand/aggregated-historyare wrong across their whole series, as is any aggregate overcurrent_account_balances(TVL, supply share, distribution analytics).
Suggested fix
Two shapes are possible and the choice is yours:
(a) Handle both operations as balance-clearing in db/process_balances.sql, after the impact join — zero every current_account_balances row for the account and write matching account_balance_history debits. This leaves get_impacted_balances a faithful port of the C visitor, which is what its parity test exists to protect.
(b) Push the clearing into HAF core so every consumer gets it — forward_impacted.cpp:810-811 says core deliberately does not, so this is a conversation with that team rather than a local change.
Scope notes:
- "Clear all balances" needs precision for
null. Its liquid HBD/HIVE,hbd_savingsandvesting_sharesare all wrong, butreceived_vestsis correct (13,977,240,269, matching hived exactly — real inbound delegations, which the sweep does not touch). Zeroing that would introduce a new error. - Backfill scope:
steem.daofrom block 47,797,680;nullfrom genesis. - Zero more than
current_account_balances. ABW's answer on hive#717 (closed) flags thatconsolidate_treasury_balance_operation"liquidates vests and vesting rewards and moves resulting HIVE to appropriate balance (main or rewards) without indicating exact amounts", echoed by the NOTE atforward_impacted.cpp:812-814. Soaccount_rewardsandaccount_savingsrows need zeroing too — which is exactly whatprocess_hf_23already does forhardfork_hive_operation, and why it is the natural template here. - A regression guard already exists.
tests/regression/(run_test.sh+sql/02_compare_accounts.sql) callsbtracker_test.compare_accounts()against a hiveddatabase_api.list_accountssnapshot, comparing all accounts with no exclusions. It passes today only because the committed fixture covers a block range where these ops never fire; a fixture spanning block 47,797,680 would catch this class permanently.
tests/parity/impacted_balances_parity.sql:117— theconsolidate_treasury_balance_operationfixture asserts multiset-equality with the C function, which has the same credit-only emission. Itstotal_movedis lifted from the real HF24 sweep:[{"amount":"83353473585",...},{"amount":"560371025",...}]— the same 83,353,473,585 stuck onsteem.daotoday.- Lines 155-169 — a second loop asserts
clear_null_account_balance_operationemits zero rows. tests/parity/impacted_balances_batch_parity.sql:64— the same consolidate fixture for the batch variant.
Applying the clear as a post-parity pipeline step avoids all three.
How to verify a fix
After the fix and backfill, all four should hold:
/accounts/steem.dao/balances→hbd_balance0,hive_balance0, matchingdatabase_api.find_accounts./accounts/null/balances→hbd_balance,hive_balance,hbd_savings,vesting_sharesall 0 — whilereceived_vestsstays 13,977,240,269./top-holders?coin-type=HBD→hive.fundat rank 1; neithersteem.daonornullin the top 10 of either coin./accounts/steem.dao/balance-history?coin-type=HBD&direction=desc→ a debit at block 109,832,959, and at each hourly consolidate thereafter, netting the credit one block earlier.
Prior art
Unreported against hive/balance_tracker. No issue (all 60, any state), no MR (open, merged or closed), and no branch or tag from 1.27.8 through 1.29.0-rc1 contains any debit for either operation — 149 refs scanned. This is not a regression from !369 (merged): the behaviour is identical before and after the SQL port, and dates to inception, because the C hive.get_impacted_balances it replaced has the same credit-only emission.
The canonical prior art is hive/hive#717 — "hardfork_hive should set balances to 0 - get_impacted_balances", opened 2024-09-01, closed 2024-09-09. It records this exact observation, both halves:
"the following example should return the impact on the
steem.daoaccount. The money is taken fromsteem.daoand sent tohive.fund. It isconsolidate_treasury_balanceVO." / "Also returns nothing forclear_null_account_balance"
and ABW's answer is the authoritative statement of the contract:
"there is no problem when it comes to source account balances after the operation - they are all zero. So whatever you are tracking for source account, set it to zero. The same for
clear_null_account_balance_operation- whatever data you have onnullbalances, set it to zero."
So the design question is settled and settled in this direction: the emission is intended, and the clear belongs to the consumer. What never happened is the follow-through — #717 was raised against hived by a balance_tracker contributor, answered correctly, and never turned into a balance_tracker ticket. This issue is that ticket.
Related open: hive/hive#743 asks hived for per-balance detail on hardfork_hive_operation for the same reason, establishing that "the vop is too coarse for btracker" is a live and accepted concern; nobody filed the consolidate analogue.
(hive/hive #87 and !134 (merged) are sometimes cited here but are a different matter — they added these ops to get_impacted_account_visitor, the account-impact side, which is why :540 names both treasuries while :808 names one. They never touched the balance collector.)