fix: finance v2 handler RPC regressions#67
Merged
tekwani merged 4 commits intotetherto:developfrom Apr 28, 2026
Merged
Conversation
This was referenced Apr 28, 2026
The mempool worker's getWrkExtData returns a flat array of block records
[{ts, blockSize, blockReward, blockTotalFees}, ...], but processBlockData
only handled nested .data/.blocks wrappers - it iterated entry's own field
names, Number('ts') returned NaN, and produced an empty daily map. The
SubsidyFee page then rendered "No data available".
Detect the flat shape (entry has .ts/.timestamp/.time) and process it
directly. Also surface blockSize on getSubsidyFees and getRevenueSummary
log entries (and totalBlockSize/avgBlockSize on the summary) - needed for
SubsidyFee's "Avg Fees in Sats/vByte" chart to render after this fix.
Two compounding bugs in getCostSummary caused btcPrice=0 for every log
entry, leaving ProductionCostPriceChart's overlay line at 0:
1. Wrong RPC key. The handler queried mempool with key: 'prices', which
the worker doesn't recognize and so returns the live snapshot
({currentPrice, blockHeight, ...}). Switched to 'HISTORICAL_PRICES',
which returns [{ts, priceUSD}, ...].
2. processEbitdaPrices couldn't parse the production shape. Same class
as the processBlockData fix (Bug C): the mempool worker returns a flat
per-ORK array of records, not a wrapper. Detect when entry has
.ts/.timestamp/.time and process it as the item directly; also accept
priceUSD (the actual upstream field name) alongside price.
The processEbitdaPrices fix incidentally makes getRevenueSummary and
getHashRevenue use real per-day prices instead of falling back to
currentBtcPrice. getEbitda still uses the wrong key: 'prices' (line 344)
and is left for a follow-up.
The TAIL_LOG_RANGE_AGGR RPC returns per-day items as
{ts, val: {site_power_w, hashrate_mhs_5m_sum_aggr}}, but
processTailLogData read item[AGGR_FIELDS.SITE_POWER] directly without
drilling into .val, so powerW and hashrateMhs were 0 for every entry.
RevenueSummary then showed 0 for Avg Power, Avg Hashrate, and Hashrate
Capacity Factor; EBITDA's per-day power/hashrate were similarly zeroed.
Mirror the .val/.flat fallback pattern that processConsumptionData
already uses (workers/lib/server/handlers/finance.handlers.js:172).
Two bugs in getHashRevenue caused hashrateMhs and networkHashrateMhs
to be 0 for every log entry, leaving HashBalance entirely zeroed:
1. processHashrateData read item[AGGR_FIELDS.HASHRATE_SUM] directly,
but TAIL_LOG_RANGE_AGGR wraps measurements as
{ts, val: {hashrate_mhs_5m_sum_aggr}}. Same .val drilling fix as
processTailLogData.
2. processNetworkHashrateData expected entries wrapped under .data,
but the HISTORICAL_HASHRATE RPC returns a flat per-ORK array of
{ts, avgHashrateMHs} records. Same flat-shape detection as
processBlockData (Bug C).
4db6753 to
d130147
Compare
paragmore
approved these changes
Apr 28, 2026
tekwani
approved these changes
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
processTailLogDatanow drills into.valfor nested TAIL_LOG_RANGE_AGGR items; RevenueSummary's Avg Power / Avg Hashrate / Capacity Factor populate..valfix inprocessHashrateData; flat-shape detection inprocessNetworkHashrateData; HashBalance populates.processBlockDataparses the flat HISTORICAL_BLOCKSIZES shape;blockSizeplumbed through for the Sats/vByte chart; SubsidyFee renders.'prices'→'HISTORICAL_PRICES');processEbitdaPriceshandles the flat shape andpriceUSDfield; cost-summary returns real per-daybtcPrice.89/89 unit tests pass; lint clean. All four fixes smoke-verified end-to-end against
dev-moria.tether.to.