-
Notifications
You must be signed in to change notification settings - Fork 698
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
base: develop
Are you sure you want to change the base?
fix: /v3/health
use canonical stacks height header
#6347
Conversation
Codecov Report❌ Patch coverage is ❌ Your project check has failed because the head coverage (75.79%) 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 81.00% 75.79% -5.21%
===========================================
Files 541 552 +11
Lines 347855 351029 +3174
===========================================
- Hits 281772 266079 -15693
- Misses 66083 84950 +18867
... and 229 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
pub fn canonical_stacks_tip_height(&mut self) -> u64 { | ||
self.with_node_state(|network, _, _, _, _| network.stacks_tip.height) |
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.
@jcnelson I initially used network.burnchain_tip.canonical_stacks_tip_height
here, as you suggested. However, during integration tests (e.g. multiple_miners), I found out that burnchain_tip.canonical_stacks_tip_height
always lagged behind. in the multiple_miners
tests it always stops at 121 compared to stacks_tip.height
that arrives at 128 at the end of the test.
I must be missing a step in the test to properly trigger the refresh.
For now, I’ve used network.stacks_tip.height
, as it matches the expected value and is also used in /v2/info
.
I'm absolutely open to reverting this to use burnchain_tip
if someone has insight on how to consistently trigger its update in integration tests.
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