fix(block): use parent state for witness validation
What does this PR do?
Validate block witness signatures in Manager after selecting the candidate-parent state, for direct application and fork switching.
- Defer competing branches and retain up to four normalized signature candidates per block. Preserve the original signature and roll the remaining candidates so a later valid signature can still be used when the block becomes a fork ancestor or is applied directly after rollback.
- Return explicit processing results so forwarding, application metrics and peer-failure attribution follow the actual block outcome.
- Refresh receive timestamps for deferred broadcast blocks, clear only the restarting peer's pending sync payloads and requests, and share missing-parent/invalid-ancestor classification across both ingress paths.
- Preserve KhaosDatabase graph nodes and serialized storage of unprocessed blocks. Retain authenticated capsules only after execution commits.
The database and network changes address one validation problem and must land together: forwarding, retries and peer-failure attribution depend on the result returned by Manager.
Why are these changes required?
After a witness-key rotation or strict-ECDSA activation, validation against the local head can disagree with validation against a block's own parent. The selected parent state must govern witness recovery, permissions and scheduling.
This PR has been tested by:
- Focused tests on x86_64 / JDK 8: 141 tests across 11 framework classes covering parent-state validation, activation, fork rollback/recovery, signature overflow, direct application after rollback, storage, broadcast, duplicate metrics and synchronization.
- The broadcast and synchronization fifth-signature regression tests fail against the original PR implementation and pass with this fix.
- Checkstyle:
./gradlew :framework:checkstyleMain :framework:checkstyleTest :plugins:checkstyleMain --max-workers=2. bash .github/scripts/check_math_usage.shandgit diff --check.
Full-suite validation remains incomplete. ARM64 / JDK 17, multi-node convergence and historical replay have not been verified locally.
Follow up
Verify multi-node convergence and historical replay, measure propagation and validation costs, and determine rollout and activation requirements before deployment.
Extra details
Target: release_v4.8.3. This changes consensus-relevant block acceptance around witness-permission updates and strict-ECDSA activation. Existing and updated nodes may disagree on affected blocks. The supported mixed-version window and the node versions requiring a coordinated upgrade have not yet been established; these tests do not establish safe rolling-upgrade or hard-fork compatibility.
No dependency, configuration, protobuf or persistent database schema changes are introduced. The release branch's KhaosDatabase memory and commit lifecycle are preserved.