Repository navigation
fix: prevent sync handover and restart failures - #1500
Conversation
Align block application, request generation and sync metrics with the snapshot height before starting the synchronizer. Clear stale retries without replacing the generator used by concurrent peer updates. Cover full-history and pruned peers, plus a non-default initial height with a stale retry, through SwitchToBlockSync's first block request. Co-Authored-By: OpenAI Codex <[email protected]> <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: dashpay/tenderdash/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
Retain initialized services when RPC binding fails so startup retries do not overwrite NodeInfo or rerun the handshake against live consensus. Preserve the validator context when retrying RPC setup, and assert that channels registered by running services survive the retry. Co-Authored-By: OpenAI Codex <[email protected]> <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
Separate RPC address acquisition from request serving. Reserve every configured address before starting the application or reactors, close partial acquisitions on bind failure, and release listeners if later startup fails. Serve RPC only after node initialization completes. Remove the persistent startup-phase flag and RPC-only retry path. Test that failed binds leave services unstarted, partially bound ports are released, and later application failures release reserved listeners. Co-Authored-By: OpenAI Codex <[email protected]> <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
Stage application state separately and publish it only after serialization and close succeed. Interrupted or failed writes retain the previous state instead of leaving an empty state.json that restarts report as height zero. Use the existing atomicfile transaction helper for file storage, and apply the same replacement contract to memory storage. Cover restart reads before any bytes and during a partial write, plus preservation after failure. Co-Authored-By: OpenAI Codex <[email protected]> <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
Keep consensus ready for sync handover when waiting for synchronization, but initialize blocksync before consensus can commit in direct-start mode. Guard this startup dependency in the RPC retry regression test. Co-Authored-By: OpenAI Codex <[email protected]> <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
Exercise a fresh node with default consensus settings and a paused ABCI FinalizeBlock response. Yield startup after consensus launches so the real block-store/state-store write interval is observable. Assert startup success instead of imposing a particular reactor order on the retry test. Co-Authored-By: OpenAI Codex <[email protected]> <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
|
/self-reviewed |
|
@thepastaclaw review No review for |
thepastaclaw
left a comment
There was a problem hiding this comment.
⚠️ DEGRADED — Final validation — Phase 2 only (queue backlog)
⚠️ DEGRADED review. The primary review models were unavailable (gpt-6-astraunavailable: All credentials for model gpt-6-astra are cooling down (last error: usage_limit_reached: The usage limit has been reache), so this review ran on stand-in models:gpt-5.6-luna→muse-spark-1.3-contributor,gpt-5.6-sol→muse-spark-1.3-contributor,gpt-5.6-terra→muse-spark-1.3-contributor,gpt-6-astra→muse-spark-1.3-contributor. Both review phases and the independent verifiers still ran, but on weaker models, with Phase 1 capped athigheffort. Treat the verdict as provisional; a full-strength re-review will run on the next push once the primary models are back.
Verified the blocksync handover realignment, RPC listener pre-binding with cleanup, service ordering, and kvstore atomic persistence against the diff; each fix narrows a prior race or crash window and the added regression tests match the described behavior. No in-scope defects found.
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: astra-verifier, role: final-verifier)
- Degraded mode:
gpt-6-astraunavailable: All credentials for model gpt-6-astra are cooling down (last error: usage_limit_reached: The usage limit has been reache (detected by probe, since 2026-09-20T20:45:34Z); stand-insgpt-5.6-luna→muse-spark-1.3-contributor,gpt-5.6-sol→muse-spark-1.3-contributor,gpt-5.6-terra→muse-spark-1.3-contributor,gpt-6-astra→muse-spark-1.3-contributor; Phase 1 effort capped athigh - Triage:
normalbymuse-spark-1.3-contributor(standing in forgpt-6-astra) (effort low) — Large multi-area fix across blocksync handover, node startup ordering, and kvstore persistence, but none changes consensus rules, crypto, funds, peer deserialization, or migrations. - Phase 1 reviewers: not run (skipped for throughput: 30 PRs queued, above the 10 limit)
- Fresh verifier:
muse-spark-1.3-contributor(standing in forgpt-6-astra) — final-verifier; agentastra-verifier - Phase 2 reviewers:
muse-spark-1.3-contributor(standing in forgpt-6-astra) — general (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — tenderdash-consensus-security (completed, effort high); agentphase2-reviewer
|
Bots are done — your move: post |
|
/self-reviewed |
|
Policy satisfied — this can merge. |
TL;DR: Resume block downloads after a restored snapshot, acquire RPC addresses before starting services, and retain complete application state across interrupted writes.
User story
As a node operator, I want snapshot recovery to fetch only missing blocks and a failed RPC bind to leave the node safe to start again after freeing the port.
Scenario
After restoring a snapshot at height 100, a node should request height 101. Previously it requested height 1, or stalled against peers with pruned history. When an RPC address is occupied, startup should fail before the application and reactors start; previously retrying startup reinitialized state while those services were already running. Restarting the e2e application during persistence must retain the last complete state rather than report height zero.
Detailed discussion
Issue being fixed or feature implemented
SwitchToBlockSyncupdated the application height but left request generation and metrics at their original height. CI also exposed the RPC startup retry race in #1494: startup overwroteNodeInfowhile reactors registered channels and reran the handshake against live consensus.The rotate e2e failure additionally exposed kvstore persistence truncating
state.jsonbefore serialization. A restart interrupted during FinalizeBlock then loaded an empty file, reported application height 0, and could not replay from the retained block-store base.What was done?
Align application, request generation and metrics at
LastBlockHeight + 1; clear stale retry heights before starting synchronization.Preserve the generator and peer store under their respective locks and use synchronized applier state updates.
Initialize blocksync before consensus can write blocks when starting without synchronization; when syncing, initialize waiting consensus before the sync handover can occur.
Separate RPC listener acquisition from serving: bind every address before starting services, then serve requests after node initialization.
Close partially acquired listeners on bind failure and release reserved listeners if later startup fails. An occupied port therefore fails without starting the application or reactors, allowing a normal startup retry.
Cover full-history and pruned peers, custom initial heights with stale retries, failed binds before service startup, and listener cleanup after both partial binds and later startup failures.
Persist kvstore state using the existing
atomicfile.Txhelper, publishing only successfully serialized state and propagating close/rename errors. Failed writes preserve the prior state; memory storage follows the same replacement contract.How Has This Been Tested?
Confirmed blocksync regression tests fail before the fix: request 1 instead of 101, or no request reaches the pruned peer.
Confirmed the strengthened startup retry test fails before listener acquisition is moved ahead of service startup.
Passed 10 repetitions of the focused startup retry and listener-cleanup tests with
-race -tags=deadlock.Passed full affected packages:
go test -race -tags=deadlock -p 1 ./node ./internal/rpc/core ./internal/blocksync -count=1.Passed golangci-lint v2.13.2 for all three packages with
--new-from-rev=origin/v1.8-dev: zero issues.Formatting and
git diff --checkpassed.Native BLS uses a compatible local build of the repository-pinned revision.
Added regression tests that reopen the application during empty/partial writes and after failure. Both fail before atomic persistence and pass after the fix.
Passed
go test -race -tags=deadlock -p 1 ./abci/example/kvstore ./test/e2e/app -count=1and targeted lint.Passed the full local
rotate.tomle2e scenario, including validator06 restarting after state sync and all final assertions. Both CI e2e scenarios (rotateanddashcore) passed onc0e27ac87.Reproduced the exact state-0/store-1 startup failure on a fresh single-validator node with default consensus settings, no RPC listener and no retry. The regression test pauses the first ABCI FinalizeBlock and yields startup after consensus launches; it fails with the previous service order and passes with the fix, without asserting service ordering.
Passed ten full
nodepackage repetitions with-race -tags=deadlock, followed by the full package with the behavioral regression test, and targeted lint. CItests (04)passed onf286d4e74.Breaking Changes
RPC/ABCI wire formats and configuration are unchanged. The internal RPC startup API accepts prebound listeners. The example kvstore
StoreFactoryhelper replacesWriter()with a transactionalWrite(func(io.Writer) error)operation.Checklist:
For repository code-owners and collaborators only
🤖 Co-authored by Claudius the Magnificent AI Agent
PR Hygiene ·
209f3c6When every box is checked the
PR Hygienecheck passes and this can merge.