docs: emit header timestamp and nBits in BlockSubmitted (reminder) - #94
Draft
lsheva wants to merge 1 commit into
Draft
docs: emit header timestamp and nBits in BlockSubmitted (reminder)#94lsheva wants to merge 1 commit into
lsheva wants to merge 1 commit into
Conversation
The indexer's actual-hashrate estimate reads the Bitcoin header timestamp and nBits back out of the ring buffer with getBlockFromTip, because the event does not carry them. Emitting them costs ~512 gas since both are already in memory at the emit site, but the contract is immutable so it means a redeploy of both HashpriceBTC and HashpriceUSD. Recording the reasoning so it can ride along with the next redeploy rather than justifying one.
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.
Draft, left open as a reminder. Not scheduled — this should ride along with the next
HashpriceBTCredeploy rather than justify one.Why
The actual-hashrate estimate added in #93 needs the Bitcoin header timestamp and
nBitsper block.BlockSubmittedcarries neither, so the mapping reads them back out of the 32-slot ring buffer withgetBlockFromTip— oneeth_callfor the tip height plus one per non-tip block, ~288/day. Cheap, but it ties the mapping to an archive node and caps the submission depth the indexer can follow at 32 blocks.Adding the two fields costs ~512 gas (both are already in memory at the emit site, so it is log data only — 64 bytes at 8 gas each, against a ~121k gas average
submitBlock).Why it is blocked
HashpriceBTCis immutable andHashpriceUSD.hashpriceOracleisimmutabletoo, so this is a redeploy of both, plus a new checkpoint, consumer migration,oracle-abibump, full subgraph resync, and a fresh 144-block fee SMA warmup. Not worth paying to remove twoeth_calls.The doc also records two things deliberately left off-chain: median time past (~23k gas/block for 11 ring-buffer reads, free in the mapping) and cumulative work (pure function of
nBits).Full reasoning and a checklist for when a redeploy does happen:
.ai-docs/blocksubmitted-header-fields.md.