Repository navigation
fix(node): serve stored readiness from the peer ping route - #641
Conversation
Return the peer row's stored readiness instead of probing the peer URL. The anonymous diagnostic now sends no outbound request and writes nothing.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
jatmn
left a comment
There was a problem hiding this comment.
Merge readiness
Rebase onto current main before merge. GitHub reports mergeStateStatus: DIRTY / mergeable: CONFLICTING. A three-way merge of origin/main against this head shows overlapping edits in crates/twigpine-node/src/api/peers.rs (same file as this change). Resolve conflicts and re-run CI on the rebased head.
The author noted PR #634 edits the same sentence in docs/RUN-A-NODE.md. Whichever lands second needs a one-line doc reconciliation.
Required check test (stable) failed on head 44cee716 (job log). The failing test is test_support::tests::sweep_backs_off_after_a_run_that_repairs_nothing in crates/twigpine-node/src/test_support.rs, which is outside this PR’s three-file diff. test (beta) passed on the same run. Treat the stable failure as unrelated until reproduced on a rebased head; if it persists after rebase, triage separately from this security fix.
Other PR checks on this head: fmt + clippy, build --release, MSRV, and CodeRabbit passed.
🟢 Thanks for the contribution. I do not see any actionable issues from my review.
The handler change matches issue #269 option 2: ping_peer returns stored last_ping_ok, sends no outbound request, and still does not mutate federation state. Tests cover no-probe behavior (mockito expect(0)), stored true/false, private-URL non-blocking response, unknown-DID 404, and unchanged response keys. list_peers and resolve already exposed reachable as last_ping_ok, so semantics are now consistent across read surfaces.
Resolves the docs/RUN-A-NODE.md conflict with the proxy client-IP section that landed on main: main's section is kept and the ping sentence keeps the stored-readiness wording from this branch.
|
Brought the branch current by merging origin/main (ae06f01) instead of rebasing, so the approved commits are unchanged. The only conflict was docs/RUN-A-NODE.md: main's new proxy client-IP section from #634 is kept as is, and the ping sentence keeps this PR's stored-readiness wording. peers.rs and db/mod.rs merged without conflicts, and the two existing rate limiter fixtures in peers.rs already carry main's new On the merged head,
|
Summary
GET /api/v1/peers/{did}/pingnow returns the readiness stored on the peer row and sends no request to the peer. Before, any anonymous caller could make the node issue an outbound request to a registered peer URL on every call, with no limit.Motivation & context
The route is anonymous and each call sent
/ready(then a/healthfallback) to the peer's storedhttp_url. Since #248 the/readyrequest also makes the target run a database query. A caller who registers a peer can repeat that at will.I took the second option from the issue (stop probing) over a per-IP limit. A limit leaves the reflector in place at the allowed rate, and it would depend on proxy-peer trust that is not settled yet (#207).
Closes #269
Kind of change
What changed
twigpine-node only, plus one docs sentence.
api/peers.rs:ping_peerreturnspeer.last_ping_okinstead of calling the readiness probe. Response keys (did,http_url,reachable) are unchanged and the route still writes nothing. The periodic gossip ping is untouched and remains the only thing that probes peers and records the result.api/peers.rstests: a healthy mock peer receives no request and a storedfalseis returned anyway; a storedtrueis not replaced by a probe result; a private-URL peer returns immediately instead of waiting on a connection; an unknown DID still returns 404.db/mod.rs: the peers-write ledger row now names the renamed test fixture.docs/RUN-A-NODE.md: one sentence described the old behavior and now describes this one.How a reviewer can verify
The new tests fail on the old handler (for example
left: Bool(true) right: false) and pass here.DATABASE_URL=postgresql://gitlawb:changeme@localhost:5432/gitlawb \ cargo test -p twigpine-node --lib ping_peerBefore you request review
cargo test --workspacepasses locally (I ran theapi::peerstests, the peers-write ledger test and thetwigpine-clipeer tests, not the whole workspace)cargo fmt --allandcargo clippy --workspace --all-targets -- -D warningsare cleanfeat(...),fix(...),docs(...)).env.exampleupdated if behavior or config changed (or N/A)Protocol & signing impact
did:key, Ed25519 / RFC 9421 signatures, UCAN, ref certs, or P2P wire formatsNotes for reviewers
reachableis now the node's last gossip observation, not a live check, sotwigpine peer pingcan lag a peer's real state by one gossip interval. The route still loads the whole peers table to find one DID; that predates this change and I left it.#634 edits the same sentence in
docs/RUN-A-NODE.md, so whichever of the two lands second needs a one-line rebase.Summary by CodeRabbit