Skip to content

fix(rpc): make verificationprogress tip-aware#1055

Open
Micah-Shallom wants to merge 5 commits into
getfloresta:masterfrom
Micah-Shallom:fix/rpc-getblockchaininfo-progress-formula
Open

fix(rpc): make verificationprogress tip-aware#1055
Micah-Shallom wants to merge 5 commits into
getfloresta:masterfrom
Micah-Shallom:fix/rpc-getblockchaininfo-progress-formula

Conversation

@Micah-Shallom
Copy link
Copy Markdown
Contributor

@Micah-Shallom Micah-Shallom commented May 13, 2026

Summary

Replaces validated / height (which sticks at 1.0 when the chain store stalls) with a time-based formula using wall clock and block timestamps as external references the daemon cannot fudge.

When validated freezes for any reason, now keeps advancing, the denominator grows, and progress visibly falls instead of falsely reporting fully synced.

Why time-based instead of tx-weighted

Bitcoin Core's formula uses per-block cumulative tx counts and a baked-in ChainTxData checkpoint. Both require a chainstore schema migration, which is out of scope for an RPC bugfix. Time-based progress uses two external references Floresta already has (wall clock + block timestamps) and resolves the bug as filed.

Formula

elapsed_validated = validated_block_time - genesis_time
elapsed_total     = max(now, header_tip_time) - genesis_time

verificationprogress = clamp(elapsed_validated / elapsed_total, 0.0, 1.0)

Two external references (now from the OS clock, validated_block_time from the block header) anchor the ratio outside daemon state, so a stalled chain store can't push the value to 1.0.

Test plan

  • cargo test -p floresta-node --lib
  • CI functional tests

stacked on #948
Partial fix for #1015.

Replace the validated/height formula (which sticks at 1.0 when the
chain store stalls) with a time-based estimate using wall clock and
block timestamps as external references the daemon cannot fudge.
When validated freezes, `now` keeps advancing, the denominator grows,
and progress visibly falls instead of falsely reporting fully synced.

Adds 7 unit tests on the new helper.
Floresta computes time-based progress; bitcoind computes tx-weighted.
Both converge at endpoints but drift mid-sync and at the tip (block
timestamps lag `now` by seconds). Apply the same tolerance pattern
already used for `difficulty`.
@Micah-Shallom Micah-Shallom force-pushed the fix/rpc-getblockchaininfo-progress-formula branch from d80bdc9 to 1243566 Compare May 13, 2026 21:35
@Micah-Shallom Micah-Shallom marked this pull request as ready for review May 14, 2026 05:47
@Davidson-Souza Davidson-Souza added the reliability Related to runtime reliability, stability and production readiness label May 14, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in Floresta May 14, 2026
@Davidson-Souza Davidson-Souza moved this from Backlog to In progress in Floresta May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reliability Related to runtime reliability, stability and production readiness

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants