-
Notifications
You must be signed in to change notification settings - Fork 699
fix: /v3/health
use canonical stacks height header
#6347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: /v3/health
use canonical stacks height header
#6347
Conversation
Codecov Report❌ Patch coverage is ❌ Your project status has failed because the head coverage (77.00%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #6347 +/- ##
===========================================
- Coverage 79.28% 77.00% -2.28%
===========================================
Files 556 556
Lines 351170 350660 -510
===========================================
- Hits 278424 270042 -8382
- Misses 72746 80618 +7872
... and 105 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
…fix/health-v3-use-canonical-stacks-height-header
Looks like some of your tests are failing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please address the nit before merging. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT!
Waiting for the nit to be addressed before providing final approval
QQ for both of you: I’ve already been bitten a couple of times by my own assumptions about how this endpoint gets the information (first I was extracting the chaintip from unconfirmed tenures only, then I added confirmed ones… both times I was solving the wrong problem). Tests were passing, but they didn’t really reflect real operations. For the previous PRs I could have catched this by running the updates on a synced node, but in this case I can’t since the canonical chaintip header isn’t yet released on the operational nodes. For this PR, I validated the approach by:
Do you think that’s solid enough validation, or would you suggest adding anything else? |
Actually I'm fine with this. Aside from running on a live network, this seems like the most thorough validation we can do at this stage. |
I think that's fine for now. |
03d84fa
This PR builds on top of #6344 and will remain in review until that one is merged.
Previously, the
/v3/health
endpoint relied on data fromNakamotoDownloadStateMachine
, which is consumed after evaluation. This led to inconsistent behavior: during syncing, the endpoint worked correctly, but once the node reached chaintip, the necessary data was often already consumed, resulting in missing neighbor info and a 500 error.This PR introduces a new approach builds on top of the changes in #6344, which ensure that all RPC endpoints include the
X-Canonical-Stacks-Tip-Height
header in their responses. Now, the node caches the highest tip received from neighbors during normal operations and uses that as the reference point for the/v3/health
endpoint.Key changes:
get_max_stacks_height_of_neighbors
.multiple_miner
test. This ensures thatConversationHttp::chat
is called and that the peer height is updated correctly during normal operation.StacksNodeState::canonical_stacks_tip_height
to returnPeerNetwork::stacks_tip.height
instead ofPeerNetwork::burnchain_tip.stacks_block_height
.To validate the reliability, I analyzed the logs from a mainnet node at chaintip over the past 24 hours. I measured how often it receives responses from peers
--- Request Time Interval Analysis (Last 24 Hours) ---
Average Time: 6.4775 seconds
Minimum Time: 0.0002 seconds
Maximum Time: 55.2894 seconds
Standard Deviation: 8.1859
Total Intervals Found: 13,440
This suggests the new method won't always have the absolute latest tip but provides a close and stable approximation.
Applicable issues
Additional info (benefits, drawbacks, caveats)
Checklist
docs/rpc/openapi.yaml
andrpc-endpoints.md
for v2 endpoints,event-dispatcher.md
for new events)clarity-benchmarking
repobitcoin-tests.yml