fix(stream_cc3): progress watchdog on the finalized subscription; ws ping/pong on the cc3 client - #1351
fix(stream_cc3): progress watchdog on the finalized subscription; ws ping/pong on the cc3 client#1351DylanVerstraete wants to merge 1 commit into
Conversation
…ping/pong on the cc3 client Prover liveness audit, finding 2. A finalized-heads subscription can stay open and silent: the node dropped it server-side, a proxy stopped forwarding, or the peer is half-open. Both the seed and the steady-state loop awaited try_next() with no deadline, so the stream (and every consumer: prover caches, attestor production) hung forever with no error to react to. - StreamCC3 gains a progress deadline (--progress_timeout, default 90 s). When it elapses the stream reads the node's finalized head point-to-point: node ahead of us → the subscription is dead, reconnect + re-subscribe and let the parent walk fill the gap; node not ahead → finality is stalled upstream, keep waiting and log; probe failure → reconnect. The seed applies the same deadline so construction cannot hang on a subscription that never delivers. - A shared stream::cc3::Progress record (height, last-advance time, silent recoveries) is exposed through the config; the prover publishes it on /health as cc3_finalized_height / cc3_finalized_age_seconds / cc3_silent_recoveries. - cc_client::Client now builds its jsonrpsee WebSocket with ping/pong (30 s interval, 45 s inactive limit). subxt's from_insecure_url leaves pings off, so a half-open socket never surfaced a transport error. Client::finalized_head_number() added for the probe. - cc_client::ws_fixture (feature ws-fixture, tests only): an in-process fake Creditcoin node with a controllable finalized head, per-connection subscription silencing, socket closing and pruned-state errors. The proof-gen tests from the previous PR now use it. Tests (stream_cc3/tests/watchdog.rs): silent subscription is replaced with exactly one redial and heights 2,3 arrive gap-free; stalled finality does not reconnect and resumes on the same socket; seeding does not hang on a subscription that never delivers.
PR SummaryMedium Risk Overview
proof-gen-api-server shares that progress into the cc3 event task and Reviewed by Cursor Bugbot for commit 2395d7d. Bugbot is set up for automated code reviews on this repo. Configure here. |
Second PR of the prover liveness audit, finding 2. Stacked on #1350; retarget to
usc-devonce that merges.Problem
A finalized-heads subscription can stay open and silent (dropped server-side, a proxy that stopped forwarding, a half-open peer). Both the seed and the steady-state loop in
StreamCC3awaitedtry_next()with no deadline, so the stream and every consumer (prover caches, attestor production) hung forever with no error to react to.cc_client::ClientusedRpcClient::from_insecure_url, which leaves jsonrpsee WebSocket pings off, so a half-open socket never surfaced a transport error either. The workspacereconnecting-rpc-clientfeature was inert: it is a different client type that was never instantiated.Changes
StreamCC3(with_progress_timeout, default 90 s). On expiry the stream reads the node's finalized head point-to-point:The seed applies the same deadline so construction cannot hang on a subscription that never delivers.
stream::cc3::Progress(height, last-advance time, silent-recovery count) shared through the config. The prover publishes it on/healthascc3_finalized_height,cc3_finalized_age_seconds,cc3_silent_recoveries. This is the per-block progress signal the flattened event stream had lost.Client::finalized_head_number()added for the probe.cc_client::ws_fixture(cargo featurews-fixture, tests only): an in-process fake Creditcoin node with a controllable finalized head, per-connection subscription silencing, socket closing and pruned-state errors. The proof-gen tests from fix(proof-gen): share one Arc<CcClient> and supervise the cc3 event task #1350 now use it instead of a local copy.The attestor consumes the same stream and inherits the watchdog with the default timeout; no attestor code changes.
Tests
common/streams/cc3/tests/watchdog.rs:silent_recoveries == 1cargo test -p stream_cc3 -p cc-client -p proof-gen-api-servergreen; clippy-D warningson cc-client (both feature sets), stream_cc3, proof-gen-api-server, attestor; fmt, taplo, machete.