Skip to content

feat: require a chainstate's own Evo transaction at its entry points - #8270

Open
PastaPastaPasta wants to merge 24 commits into
dashpay:developfrom
PastaPastaPasta:feat/evo-unbound-reads
Open

PastaPastaPasta wants to merge 24 commits into
dashpay:developfrom
PastaPastaPasta:feat/evo-unbound-reads

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

With two chainstates, an Evo access resolves its view from the calling thread's open transaction or, without one, the active chainstate's view. Work for the background chainstate that ran outside its own transaction would silently compute its state from the snapshot's data. A rejected snapshot whose rejection could not be saved also stayed the active Evo view for the rest of the run.

AssumeUTXO stack (merge in this order; each PR holds the commits of the ones below it): #8237 → #8238 → #7887 → #8270 → #7593 → #8271 → #7601 → #8272 → #8078 → #8273 → #8079 → #8276. Every layer stays a draft until the one below it merges; review only the commits listed as new. The stack is rebased onto develop b2d64c27c7, which merged #8235, so #8237 is now the bottom layer.

Update (2026-11-29). 397bd2d328: mine_to requires each mineBlocks(1) to raise the height by one, so a block that does not connect fails the test at once (CodeRabbit r4729351799). Rebased with the layers below.

What was done?

Update (2026-11-28). Rebased onto develop c0ccc288b1 and the reshaped #8235. The release note is now doc/release-notes-8270.md and cites #8270 (it was doc/release-notes-7887.md, named after the PR this one was split from). Rebased onto develop 7f4b217 (#8256: DataStream/HashWriter/NetMsg conversions squashed into the commits that introduced the code). The test call sites follow #8237's removal of the EvoDB configuration fingerprint (knst's review of #8237). CodeRabbit review fixes, as fixup commits: 2f0c0288d1 the DKG test requests the worker stop from a guard, so a failed check reports instead of hanging; 6e9d129d16 when neither the rejection record nor the directory move persists, the stop message says the next start loads the snapshot again and names the restart that discards it; 725c618116 startup refuses a journaled swap of a rejected snapshot instead of promoting its generation, and 73530e6bc0 decides that by the missing chainstate_todelete directory rather than an _INVALID one, which may be an earlier snapshot's (chainstatemanager_snapshot_cleanup_recovers_completed_swap now keeps such a directory and still promotes); 3bffbc43b7 the DKG test bounds its wait for the round to start; 7938561fcd reworded the -checkevobinding release note (the option is now gone, see below).

Update (2026-11-28, no thread-local). #8237 drops EvoViewScope for knst's context-based approach: a view is the transaction the calling thread holds open, otherwise the active chainstate's default identity. Every access now resolves to a defined view, so there is no unbound access left to reject, and the layer shrinks from 51 files to 16. ffe202eff2 replaces the unbound-read check with one fail-closed rule at the chainstate entry points (below), and removes -checkevobinding, CEvoDB's check_binding argument, IsCurrentView(), the -checkevobinding paragraph of the release note, and the active-view bindings this commit had added to tests, fuzz targets and the Qt test helpers. 02ce71b78f: the DKG-style round in the unsaved-rejection test no longer holds a binding; once the generation is revoked it reads NORMAL and never the rejected generation. f9d3cf8660: the coinstatsindex unclean-shutdown test connects a block directly, so it opens the chainstate's Evo transaction, as ConnectTip does. 3217d0b9ab and 23d65cebfe (amend!) rewrite both commit messages to match. This layer adds no thread_local.

New on top of #7887:

  1. 4489d820f4 feat(evo): require a chainstate's own Evo transaction at its entry points (reworded by 3217d0b9ab; it was "reject unbound Evo reads during dual operation"). ProcessSpecialTxsInBlock, UndoSpecialTxsInBlock and CQuorumBlockProcessor::ProcessBlock/UndoBlock take an explicit chainstate and now throw EvoViewBindingError unless the calling thread holds that chainstate's Evo transaction (Chainstate::HoldsEvoTransaction, CEvoDB::HoldsTransaction(identity)), on connect and undo alike. The check is a plain throw, so it holds in release builds. A binding fault is a local error everywhere: state.Error in validation (the chainstate stalls, the block is not marked invalid), RPC_INTERNAL_ERROR over RPC, an aborted operation for P2P and the miner, a logged and ended task for queued and scheduled work, and an initialization failure at startup. It never becomes an empty success, consensus invalidity, a peer penalty or a process abort. The RPC dispatcher now returns RPC_INTERNAL_ERROR instead of RPC_MISC_ERROR for any evo::LocalStateError; doc/release-notes-8270.md records that.
  2. 20be95d307 fix(validation): stop reading a rejected snapshot when its rejection is not saved. When HandleSnapshotStateMismatch cannot sync EvoDB or persist the rejection (a write that throws, as a LevelDB I/O error does, or one that fails), the generation is revoked in memory for the rest of the run (CEvoDB::RevokeSnapshotGeneration): no access reaches it, the default identity is NORMAL, and the shutdown callback still runs. Its records stay on disk so startup recovery still rejects it, and until then no new generation can be created. Live rejection and startup recovery set the snapshot directory aside through the same node::SetAsideInvalidSnapshotDir(), which keeps an earlier nonempty chainstate_snapshot_INVALID and deletes through chainstate_snapshot_todelete.

What to focus on: the four entry-point checks and that every caller reaches them inside its chainstate's transaction (the Evo transactions opened by ConnectTip, DisconnectTip, TestBlockValidity, VerifyDB and ReplayBlocks), and the revocation in HandleSnapshotStateMismatch. With one chainstate every caller already holds the NORMAL transaction, so nothing changes without a snapshot apart from the RPC error code.

How Has This Been Tested?

On Linux x86_64 (Debug, GCC 13, depends), this head builds and all 185 unit and utility test binaries pass (ctest). The functional AssumeUTXO tests need loadtxoutset (#8078); they pass at the top of the stack, which includes these commits.

  • validation_chainstate_tests/chainstate_update_tip: ProcessBlock and ProcessSpecialTxsInBlock for the background chainstate throw EvoViewBindingError with no transaction and inside the snapshot chainstate's, and leave the validation state valid.
  • chainstatemanager_snapshot_evo_state_past_dip3: the snapshot chain is extended past DIP3, V20 and the first disk-snapshot period with a registered masternode; its MN-list, credit-pool and EHF state stays in its generation and cache partitions, and NORMAL rebuilds it after the snapshot is rejected and the node restarts.
  • chainstatemanager_evodb_repair_after_completion: after background validation completes, evodb refuses a stop height above the background tip, and a forced startup repair runs without interrupting the node.
  • interfaces_tests/evo_reads_from_another_thread_do_not_fail: every Evo-reading interfaces operation called from a thread of its own succeeds, with one view and with two.
  • chainstatemanager_unsaved_rejection_stops_reading_the_snapshot: throws dbwrapper_error from the rejection write (SetRejectionFailpointForTesting) while a DKG-style round that read the snapshot view waits at its start, starts with a nonempty earlier _INVALID and a leftover _todelete, and checks that the round resumes reading NORMAL and that after a restart the rejected generation is neither active nor promoted.

To test: ctest --test-dir build -R "evo_db|validation_chainstate|interfaces".

Breaking Changes

None with a single chainstate. Nothing here is reachable on mainnet or testnet: snapshots can only be loaded on regtest until the network pins (#8276) land.

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

@PastaPastaPasta PastaPastaPasta added this to the 24.1 milestone Nov 27, 2026
@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

@thepastaclaw

thepastaclaw commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit e342632) · triage: normal

thepastaclaw
thepastaclaw previously approved these changes Nov 27, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The two new commits enforce explicit Evo view bindings during dual-chainstate operation and revoke rejected snapshot generations in memory when the rejection cannot be persisted. CI has passed lint, Cppcheck, the Linux build, and the standard Linux and no-wallet tests; ASan, TSan, and multiprocess tests were still pending. The head conflicts with develop in src/evo/evodb.h and src/test/interfaces_tests.cpp.

🟡 5 suggestion(s) | 💬 2 nitpick(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

3 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Snapshot cleanup reports a rename to _INVALID even when it never tried that target
Impact: When an earlier _INVALID directory exists, a failed cleanup can send an operator looking at the wrong path.
src/validation.cpp:7448-7469

The fatal message always describes a rename to _INVALID. With that directory already present, SetAsideInvalidSnapshotDir() instead targets _todelete and can fail while clearing an old _todelete directory, before any rename is attempted. Report the filesystem error without assuming which operation or target failed.

    // Keep the first invalid snapshot for forensics and discard later ones.
    try {
        node::SetAsideInvalidSnapshotDir(snapshot_datadir);
    } catch (const fs::filesystem_error& e) {
        const auto src_str{fs::PathToString(snapshot_datadir)};
        LogPrintf("%s: failed to set aside invalid snapshot directory '%s': %s\n", __func__, src_str, e.what());
        return util::Error{strprintf(_(
            "Failed to set aside invalid snapshot directory '%s': %s. "
            "If the invalid snapshot directory is still at that path, move or delete it before restarting."),
            src_str, e.what())};
    }

source: muse-spark-1.3-contributor (phase1-reviewer: general)

💬 Nitpick: The Evo binding commit title omits write checks and its body overstates the release note
Impact: Maintainers reading the history can miss write-side enforcement and attribute older error handling to this commit.
<commit:d1d9e5a480b>:1

The subject names unbound reads during dual operation, but the commit also checks writes and enables strict binding with one chainstate on regtest. Its release-note paragraph says the note documents package errors, read-error shutdown, and pruned-data stalls; the added note documents the RPC dispatcher error change and strict regtest binding, and points package callers to their existing error paths. Broaden the subject to describe view-binding enforcement and align the paragraph with the note.

source: gpt-6.2-sol (phase2-reviewer: general, dash-core-commit-history)

💬 Nitpick: The unsaved-rejection commit also changes directory cleanup when the rejection is saved
Impact: Maintainers scanning history for repeated snapshot cleanup can miss this commit because its subject only names failed rejection writes.
<commit:b041e3d8004>:1

SetAsideInvalidSnapshotDir() now handles an existing _INVALID directory even when EvoDB successfully saves the rejection, and startup also cleans up a leftover _todelete directory. Split the directory handling into its own commit for a separate bisect point, or broaden the subject to cover both changes.

source: gpt-6.2-sol (phase2-reviewer: dash-core-commit-history)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The two new commits add cross-cutting Evo view checks in CEvoDB::ResolveView and in-memory snapshot revocation on rejection-persistence failure, but do not change consensus rules or migrate on-disk state.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — dash-core-commit-history (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `src/validation.cpp`:
- [SUGGESTION] src/validation.cpp:6990-7003: Restart can reopen a rejected snapshot if neither the rejection nor the directory move reaches disk
  Impact: A node with an existing snapshot can reopen the rejected generation on restart if the EvoDB write fails and the snapshot directory remains at its original path.
  An ordinary restart can reuse the snapshot that triggered shutdown. Revocation leaves the on-disk record `PUBLISHED`, and `SetAsideInvalidSnapshotDir()` can fail before moving the directory, for example if it cannot remove a leftover `_todelete` directory. With both the published record and the original directory intact, `RecoverSnapshotCleanup()` has no rejection to finish, and `DetectSnapshotChainstate()` opens the snapshot. A mismatch detected during block connection can occur before the background chain reaches the base, so the startup completion check can skip it. This head can reopen existing snapshots but has no production caller that initially loads one. Make startup honor a durable rejection intent before reopening the snapshot, and extend the restart test to cover a failed rejection write with the original directory still present.
- [SUGGESTION] src/validation.cpp:7448-7469: Snapshot cleanup reports a rename to `_INVALID` even when it never tried that target
  Impact: When an earlier `_INVALID` directory exists, a failed cleanup can send an operator looking at the wrong path.
  The fatal message always describes a rename to `_INVALID`. With that directory already present, `SetAsideInvalidSnapshotDir()` instead targets `_todelete` and can fail while clearing an old `_todelete` directory, before any rename is attempted. Report the filesystem error without assuming which operation or target failed.

In `src/evo/evodb.cpp`:
- [SUGGESTION] src/evo/evodb.cpp:679-681: Abandoning an activation after revocation can erase the markers startup still needs
  Impact: A second call to the activation API after an unsaved rejection can turn a recoverable restart into a `-reindex-chainstate` error.
  A retry can leave the `PUBLISHED` record on disk without its required dual-chainstate marker. After rejection switches the active chainstate back to NORMAL, `SnapshotBlockhash()` no longer stops a second `ActivateSnapshot()` call. `CreateSnapshotGeneration()` refuses to create a generation after revocation, but the activation failure path then calls `AbandonSnapshotGeneration()`. That erases the marker without updating the record because revocation already cleared `m_snapshot_generation`. `LoadSnapshotGenerations()` rejects that combination before startup cleanup can run. No RPC calls this activation API at this head; guard the retry before it touches the coins directory, and make abandonment preserve the revoked generation's recovery records.

In `src/llmq/net_dkg.cpp`:
- [SUGGESTION] src/llmq/net_dkg.cpp:789-795: A DKG round can keep the background Evo view after waiting through snapshot activation
  Impact: With runtime snapshot activation, a masternode whose DKG worker was already waiting can miss the first eligible round even though the active snapshot has the quorum data.
  `InitNewQuorum()` can look for a post-base quorum in the NORMAL view, which stops advancing at the snapshot base. `PhaseHandlerThread()` captures the view before `WaitForNextPhase()` waits for an initialized round. If activation happens during that wait, the phase and quorum hash can come from the active snapshot after background validation completes, while quorum member selection still uses the captured NORMAL view. `ResolveView()` accepts it because NORMAL remains a valid identity. Runtime activation is not exposed by this head, but this code owns the DKG binding used by that path. Capture the quorum and its view together after the wait, and abort the round if the active view changes afterward.

In `src/test/interfaces_tests.cpp`:
- [SUGGESTION] src/test/interfaces_tests.cpp:292-294: An escaped Evo binding error aborts the interface test without naming the failing call
  Impact: When an interface lets an Evo binding error escape, the test worker terminates the process instead of reporting that interface and checking the remaining calls.
  The sweep loses the diagnostic it was written to collect. `EvoViewBindingError` derives from `evo::LocalStateError`, which deliberately does not derive from `std::exception`, so the exception escapes the `std::thread` entry point. Catch `LocalStateError` in the per-call wrapper and record the interface name and error in both the single-view and dual-view sweeps.

In `<commit:d1d9e5a480b>`:
- [NITPICK] <commit:d1d9e5a480b>:1: The Evo binding commit title omits write checks and its body overstates the release note
  Impact: Maintainers reading the history can miss write-side enforcement and attribute older error handling to this commit.
  The subject names unbound reads during dual operation, but the commit also checks writes and enables strict binding with one chainstate on regtest. Its release-note paragraph says the note documents package errors, read-error shutdown, and pruned-data stalls; the added note documents the RPC dispatcher error change and strict regtest binding, and points package callers to their existing error paths. Broaden the subject to describe view-binding enforcement and align the paragraph with the note.

In `<commit:b041e3d8004>`:
- [NITPICK] <commit:b041e3d8004>:1: The unsaved-rejection commit also changes directory cleanup when the rejection is saved
  Impact: Maintainers scanning history for repeated snapshot cleanup can miss this commit because its subject only names failed rejection writes.
  `SetAsideInvalidSnapshotDir()` now handles an existing `_INVALID` directory even when EvoDB successfully saves the rejection, and startup also cleans up a leftover `_todelete` directory. Split the directory handling into its own commit for a separate bisect point, or broaden the subject to cover both changes.

Comment thread src/validation.cpp Outdated
Comment on lines +6990 to +7003
if (!evodb_synced ||
!written("recording the snapshot rejection",
[&]() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { return m_ibd_chainstate->m_evoDb.DiscardSnapshotMarkers(); })) {
LogPrintf("[snapshot] failed to record the snapshot rejection in EvoDB\n");
// The generation stays live on disk for startup recovery to reject,
// but the rest of this run must not read it.
m_ibd_chainstate->m_evoDb.RevokeSnapshotGeneration();
}
auto rename_result = m_snapshot_chainstate->InvalidateCoinsDBOnDisk();
if (!rename_result) {
user_error += Untranslated("\n") + util::ErrorString(rename_result);
} else if (!written("removing the rejected snapshot EvoDB generation",
[&]() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { return m_ibd_chainstate->m_evoDb.CollectRejectedGenerations(); })) {
LogPrintf("[snapshot] failed to remove the rejected snapshot EvoDB generation; retrying at startup\n");

@thepastaclaw thepastaclaw Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏭️ Deferred (maintainer decision; not blocking) at 154ba590; see the replies below.

🟡 Suggestion: Restart can reopen a rejected snapshot if neither the rejection nor the directory move reaches disk
Impact: A node with an existing snapshot can reopen the rejected generation on restart if the EvoDB write fails and the snapshot directory remains at its original path.

An ordinary restart can reuse the snapshot that triggered shutdown. Revocation leaves the on-disk record PUBLISHED, and SetAsideInvalidSnapshotDir() can fail before moving the directory, for example if it cannot remove a leftover _todelete directory. With both the published record and the original directory intact, RecoverSnapshotCleanup() has no rejection to finish, and DetectSnapshotChainstate() opens the snapshot. A mismatch detected during block connection can occur before the background chain reaches the base, so the startup completion check can skip it. This head can reopen existing snapshots but has no production caller that initially loads one. Make startup honor a durable rejection intent before reopening the snapshot, and extend the restart test to cover a failed rejection write with the original directory still present.

source: gpt-6.2-sol (phase2-reviewer: general, dash-core-commit-history)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still applies (re-reviewed at 7b09363c): The latest fixup improves the fatal message and documents the required reindex operation, but when both rejection persistence and directory set-aside fail there is still no durable marker preventing a plain restart from loading the rejected generation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that this remains, and this round does not cover it. When neither the rejection write nor the directory move reaches disk, nothing durable records the rejection: the generation is still PUBLISHED and chainstate_snapshot is still at its live path, so startup has nothing to act on. The new chainstate_todelete check only covers a journaled swap. A durable rejection marker that survives that double failure is tracked in #8275.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred (re-reviewed at 154ba590): The double-failure restart hazard remains acknowledged but is intentionally deferred to the durable rejection-marker work tracked in #8275. This head adds shutdown guidance and recovery improvements but does not add that durable marker.

Comment thread src/evo/evodb.cpp Resolved
Comment thread src/llmq/net_dkg.cpp Resolved
Comment thread src/test/interfaces_tests.cpp Resolved
@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

1 similar comment
@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

thepastaclaw
thepastaclaw previously approved these changes Nov 28, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 2 only (queue backlog)

New on this head: This head adds in-memory revocation when snapshot rejection persistence fails, shared invalid-snapshot directory handling, and regression coverage for unsaved rejection and restart recovery. ClangFormat and the main check pass; build-container jobs remain queued or skipped, with no failed code check reported.

🟡 4 suggestion(s) | 💬 2 nitpick(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

3 finding(s) not shown inline (the lines are not part of this PR's diff)

💬 Nitpick: The unsaved-rejection commit also changes directory cleanup when the rejection is saved
Impact: Future bisects and blame must attribute two independent snapshot-lifecycle policies to the same commit, making it harder to isolate either behavior.
<commit:d0dc3e4>:1

The permanent d0dc3e47b8d commit combines the in-memory revocation needed when rejection persistence fails with the separate SetAsideInvalidSnapshotDir cleanup policy that also changes the successful-rejection path. These have independent behavior and failure modes, so keeping the directory-cleanup redesign in a separate substantive commit would make regression isolation and selective backports clearer.

source: gpt-6.2-sol (phase2-reviewer: dash-core-commit-history)

💬 Nitpick: The Evo binding commit title omits write checks and its body overstates the release note
Impact: Readers using git log can miss that the commit changes writes, iterators, caches, and dispatcher boundaries, while the commit body describes broader release-note coverage than the note provides.
<commit:3a2d56d>:1

The 3a2d56da90b subject says only “reject unbound Evo reads,” although the diff also rejects unbound writes, iterators, cache lookups, and explicit manager-boundary calls. Its body says the release note records the externally visible changes, but the note covers only the RPC error and regtest binding behavior; reword the subject and body so the permanent history accurately scopes the change.

source: gpt-6.2-sol (phase2-reviewer: dash-core-commit-history)

🟡 Suggestion: Snapshot cleanup reports a rename to _INVALID even when it never tried that target
Impact: When an existing _INVALID directory causes cleanup to use _todelete, users receive an inaccurate error explaining a rename that was not attempted.
src/validation.cpp:7247-7257

A cleanup failure can be reported as snapshot -> snapshot_INVALID even though SetAsideInvalidSnapshotDir() first removes or renames through chainstate_snapshot_todelete; for example, the failure can occur while deleting the old _todelete directory or while moving the snapshot there. The resulting recovery instructions and logs misidentify the operation, so the error should report the actual attempted action and destination, or the helper should return that information.

source: gpt-6.2-sol (phase2-reviewer: general, dash-core-commit-history)

Still open from earlier rounds (3)

  • 🟡 Suggestion: A DKG round can keep the background Evo view after waiting through snapshot activation — src/llmq/net_dkg.cpp:789-795 (thread)
  • 🟡 Suggestion: Abandoning an activation after revocation can erase the markers startup still needs — src/evo/evodb.cpp:684-691 (thread)
  • 🟡 Suggestion: Restart can reopen a rejected snapshot if neither the rejection nor the directory move reaches disk — src/validation.cpp:6791-6799 (thread)
Review provenance

Source: reviewer 1: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — This is a large and intricate cross-cutting change involving Evo view binding, validation, chainstate handling, storage recovery, networking, RPC, and extensive tests, but it does not itself change consensus rules, funds movement, cryptography, peer-facing deserialization, or a storage migration.
  • Phase 1 reviewers: not run (skipped for throughput: 14 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — dash-core-commit-history (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `<commit:d0dc3e4>`:
- [NITPICK] <commit:d0dc3e4>:1: The unsaved-rejection commit also changes directory cleanup when the rejection is saved
  Impact: Future bisects and blame must attribute two independent snapshot-lifecycle policies to the same commit, making it harder to isolate either behavior.
  The permanent `d0dc3e47b8d` commit combines the in-memory revocation needed when rejection persistence fails with the separate `SetAsideInvalidSnapshotDir` cleanup policy that also changes the successful-rejection path. These have independent behavior and failure modes, so keeping the directory-cleanup redesign in a separate substantive commit would make regression isolation and selective backports clearer.

In `<commit:3a2d56d>`:
- [NITPICK] <commit:3a2d56d>:1: The Evo binding commit title omits write checks and its body overstates the release note
  Impact: Readers using git log can miss that the commit changes writes, iterators, caches, and dispatcher boundaries, while the commit body describes broader release-note coverage than the note provides.
  The `3a2d56da90b` subject says only “reject unbound Evo reads,” although the diff also rejects unbound writes, iterators, cache lookups, and explicit manager-boundary calls. Its body says the release note records the externally visible changes, but the note covers only the RPC error and regtest binding behavior; reword the subject and body so the permanent history accurately scopes the change.

In `src/validation.cpp`:
- [SUGGESTION] src/validation.cpp:7247-7257: Snapshot cleanup reports a rename to `_INVALID` even when it never tried that target
  Impact: When an existing `_INVALID` directory causes cleanup to use `_todelete`, users receive an inaccurate error explaining a rename that was not attempted.
  A cleanup failure can be reported as `snapshot -> snapshot_INVALID` even though `SetAsideInvalidSnapshotDir()` first removes or renames through `chainstate_snapshot_todelete`; for example, the failure can occur while deleting the old `_todelete` directory or while moving the snapshot there. The resulting recovery instructions and logs misidentify the operation, so the error should report the actual attempted action and destination, or the helper should return that information.
- [SUGGESTION] src/validation.cpp:6791-6799: Restart can reopen a rejected snapshot if neither the rejection nor the directory move reaches disk
  (carried; thread: https://github.com/dashpay/dash/pull/8270#discussion_r4724377174)

In `src/llmq/net_dkg.cpp`:
- [SUGGESTION] src/llmq/net_dkg.cpp:789-795: A DKG round can keep the background Evo view after waiting through snapshot activation
  (carried; thread: https://github.com/dashpay/dash/pull/8270#discussion_r4724377184)

In `src/evo/evodb.cpp`:
- [SUGGESTION] src/evo/evodb.cpp:684-691: Abandoning an activation after revocation can erase the markers startup still needs
  (carried; thread: https://github.com/dashpay/dash/pull/8270#discussion_r4724377182)

Comment thread src/test/interfaces_tests.cpp Resolved
thepastaclaw
thepastaclaw previously approved these changes Nov 29, 2026

@thepastaclaw thepastaclaw left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Updated after discussion: 2 finding(s) of this review were settled in the inline threads.

  • ✅ Withdrawn: 🟡 An in-flight asset-unlock RPC can read a rejected snapshot’s cached credit pool
  • ⏭️ Deferred (maintainer decision): 🟡 The credit-pool manager exposes a cache reset that only one test uses (tracked in #8238)

New on this head: This revision keeps the chainstate-specific Evo transaction checks and in-memory snapshot revocation, but changes the credit-pool cache from per-view partitions to a shared cache, consolidates the snapshot block-read helpers, and updates the snapshot test. GitHub CI passed the Linux x86-64 build, ClangFormat, lint, and Cppcheck; the Linux test job and several other builds are still pending, with no failed code checks reported. The supplied merge check reports no conflicts with develop.

🟡 4 2 suggestion(s) | 💬 1 nitpick(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

3 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Snapshot cleanup reports a rename to _INVALID even when it never tried that target
Impact: An operator investigating a failed snapshot cleanup can be directed to the wrong filesystem operation and destination.
src/validation.cpp:7246-7258

The log and returned error always say that renaming the live snapshot directory to _INVALID failed. When an earlier _INVALID exists, SetAsideInvalidSnapshotDir() instead removes any leftover chainstate_snapshot_todelete and then renames the live directory there. Either operation can throw without attempting a rename to _INVALID. Report that setting aside the live directory failed and include the filesystem exception rather than supplying a destination the helper may never have used.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: general, dash-core-commit-history)

🟡 Suggestion: Eleven fixup! commits leave review corrections as permanent history
Impact: Merging this layer as-is would leave eleven fixups and two message amendments separate from the two substantive commits they correct.
<commit:aebf2779838>:1

The current #8270 layer still contains eleven fixup! commits and two amend! commits, not counting those in the lower layers. In particular, 806ea3fa1c0 still carries the old reads-only subject and describes the removed -checkevobinding option; the accurate entry-point subject and RPC-only release-note wording are in 6deb67d6579. Autosquash this layer before merge so the substantive commits contain their corrections and use the replacement messages.

source: gpt-6.2-sol (phase2-reviewer: general)

💬 Nitpick: The unsaved-rejection commit also changes directory cleanup when the rejection is saved
Impact: A maintainer tracing a change in successful rejection or startup cleanup would not find it from the commit's failed-write subject.
<commit:0c0edcc809d>:1

The replacement body documents both changes, but its subject still names only the case where the rejection cannot be saved. InvalidateCoinsDBOnDisk() calls the new SetAsideInvalidSnapshotDir() regardless of whether rejection persistence succeeded, and startup uses it to finish a persisted rejection. Broaden the subject to include the directory handling, or split that policy into its own commit.

source: gpt-6.2-sol (phase2-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — This is a large, cross-cutting change to Evo view binding, chainstate validation, snapshot handling, networking, interfaces, and tests, but the diff does not clearly alter consensus rules, funds movement, cryptography, peer-facing deserialization, or a storage migration.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — dash-core-commit-history (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `src/evo/creditpool.cpp`:
- [SUGGESTION → WITHDRAWN in discussion; do not fix] src/evo/creditpool.cpp:134-148: An in-flight asset-unlock RPC can read a rejected snapshot’s cached credit pool
  Impact: On a node running an existing snapshot, an in-flight `getassetunlockstatuses` request can report an unlock as mined or ChainLocked from a cached pool after the node has rejected that snapshot.
  Revoking the Evo generation no longer prevents reads of its cached credit pools. The rewritten cache commit, `275183e4099`, admits SNAPSHOT pools above the base, but `GetFromCache()` accepts a hit by block hash alone, without checking which view produced it. `getassetunlockstatuses` captures the active tip under `cs_main` and releases the lock before reading the pool (`src/rpc/rawtransaction.cpp:825,865–871`). If rejection switches EvoDB to NORMAL between those operations, the request can still use a warmed SNAPSHOT entry for the captured block. The background height limit does not constrain this RPC, and requesting shutdown does not cancel it. The latest test fixup clears the cache at line 870 before the NORMAL read can expose this cross-view hit. Restore the prior `EvoViewCache` partitioning for snapshot-dependent pools so generation retirement applies to those entries too.

In `src/validation.cpp`:
- [SUGGESTION] src/validation.cpp:7246-7258: Snapshot cleanup reports a rename to `_INVALID` even when it never tried that target
  Impact: An operator investigating a failed snapshot cleanup can be directed to the wrong filesystem operation and destination.
  The log and returned error always say that renaming the live snapshot directory to `_INVALID` failed. When an earlier `_INVALID` exists, `SetAsideInvalidSnapshotDir()` instead removes any leftover `chainstate_snapshot_todelete` and then renames the live directory there. Either operation can throw without attempting a rename to `_INVALID`. Report that setting aside the live directory failed and include the filesystem exception rather than supplying a destination the helper may never have used.

In `src/evo/creditpool.h`:
- [SUGGESTION → DEFERRED by a maintainer; not blocking, do not fix in this PR] src/evo/creditpool.h:131-135: The credit-pool manager exposes a cache reset that only one test uses
  Impact: The production credit-pool API exposes a cache reset whose only callers are two sites in the same snapshot test.
  The latest fixup adds `ClearCacheForTesting()` to the public `CCreditPoolManager` API, but only `chainstatemanager_snapshot_evo_state_past_dip3` calls it. That conflicts with the project's convention against public test-only helpers. Construct a fresh `CCreditPoolManager` with the existing EvoDB and chainstate manager for the cold-cache portion of the test, and use that same instance for both view reads so the test does not clear the cache between them.

In `<commit:aebf2779838>`:
- [SUGGESTION] <commit:aebf2779838>:1: Eleven `fixup!` commits leave review corrections as permanent history
  Impact: Merging this layer as-is would leave eleven fixups and two message amendments separate from the two substantive commits they correct.
  The current #8270 layer still contains eleven `fixup!` commits and two `amend!` commits, not counting those in the lower layers. In particular, `806ea3fa1c0` still carries the old reads-only subject and describes the removed `-checkevobinding` option; the accurate entry-point subject and RPC-only release-note wording are in `6deb67d6579`. Autosquash this layer before merge so the substantive commits contain their corrections and use the replacement messages.

In `<commit:0c0edcc809d>`:
- [NITPICK] <commit:0c0edcc809d>:1: The unsaved-rejection commit also changes directory cleanup when the rejection is saved
  Impact: A maintainer tracing a change in successful rejection or startup cleanup would not find it from the commit's failed-write subject.
  The replacement body documents both changes, but its subject still names only the case where the rejection cannot be saved. `InvalidateCoinsDBOnDisk()` calls the new `SetAsideInvalidSnapshotDir()` regardless of whether rejection persistence succeeded, and startup uses it to finish a persisted rejection. Broaden the subject to include the directory handling, or split that policy into its own commit.
Out-of-scope follow-up suggestions (3)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • The Evo binding commit subject omits write checks and its body overstates the release note — OUTDATED — the old commit anchors are outside the rewritten range. The replacement message in 6deb67d6579 accurately describes the four entry-point checks and the RPC-only release note; the remaining need to fold that message into 806ea3fa1c0 is covered by the current autosquash finding.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
  • The unsaved-rejection commit also changes directory cleanup when the rejection is saved — OUTDATED — the duplicate entries point to earlier versions of the rejection commit outside the current range. The scope issue is carried once at its current equivalent, 0c0edcc809d.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
  • Eleven fixup! commits leave review corrections as permanent history — OUTDATED — the duplicate entries cite fixup anchors outside the current range. The current-head finding covers the verified count of eleven fixups and two amendments in #8270's own layer; the count of 21 includes the lower layers.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.

Comment thread src/evo/creditpool.cpp Resolved
Comment thread src/evo/creditpool.h Outdated
Comment on lines +131 to +135
void ClearCacheForTesting() EXCLUSIVE_LOCKS_REQUIRED(!cache_mutex)
{
LOCK(cache_mutex);
creditPoolCache.clear();
}

@thepastaclaw thepastaclaw Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏭️ Deferred (maintainer decision; not blocking) at c9031ca3; see the replies below.

🟡 Suggestion: The credit-pool manager exposes a cache reset that only one test uses
Impact: The production credit-pool API exposes a cache reset whose only callers are two sites in the same snapshot test.

The latest fixup adds ClearCacheForTesting() to the public CCreditPoolManager API, but only chainstatemanager_snapshot_evo_state_past_dip3 calls it. That conflicts with the project's convention against public test-only helpers. Construct a fresh CCreditPoolManager with the existing EvoDB and chainstate manager for the cold-cache portion of the test, and use that same instance for both view reads so the test does not clear the cache between them.

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same point as on #7593 and #8276 (#7593 (comment)). This layer introduces ClearCacheForTesting() next to the existing ForTesting helpers on this class. Moving them behind a friend test helper is a separate cleanup, so I'm keeping it here.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClearCacheForTesting() is the only ForTesting method on CCreditPoolManager at this head, so removing it doesn’t require a broader friend-helper cleanup. I’d revise my original suggestion: with the cache shared, use one fresh manager for each of the two cold reads, not one for both. evo_db_tests.cpp already shows how to construct a local manager with the existing EvoDB and chainstate manager.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, and my earlier reply was wrong: ClearCacheForTesting() is the only ForTesting method on CCreditPoolManager. In this layer, giving each of the two cold reads its own fresh manager would work.

The hook is still needed higher up the stack, though. In #7593 (evo_snapshot_tests.cpp) and #8272 (validation_chainstatemanager_tests.cpp), the code under test reads through the node's own m_node.special_tx->m_cpoolman, so a local manager wouldn't reach the cache those tests need to clear. If knst restores the credit-pool partition on #8238, most of those clears go away, and I'll revisit the hook then, together with that change.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. At this head the helper is only used by this test, but the higher-stack tests need to clear the node-owned manager, so the appropriate cleanup depends on whether #8238 partitions that cache. I’m accepting the deferral to that change.

Tracked in #8238. Deferred on a maintainer's call: this finding no longer blocks this pull request.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred (re-reviewed at c9031ca3): The partitioning you pointed to is now in this head. CCreditPoolManager no longer exposes ClearCacheForTesting(), and the snapshot test no longer calls it, so there is no remaining API change to make here.

@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 2 only (queue backlog)

New on this head: This rebase restores credit-pool cache partitioning by Evo view, so the snapshot test can use the same manager for SNAPSHOT and NORMAL reads. The chainstate transaction checks and snapshot revocation behavior are unchanged. ClangFormat and main passed, Proof was skipped, and the skip-condition and review checks were pending; no failed code check was reported.

🟡 2 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

2 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Snapshot cleanup reports a rename to _INVALID even when it never tried that target
Impact: An operator diagnosing a failed snapshot rejection can be pointed to a preserved _INVALID directory instead of the filesystem operation that actually failed.
src/validation.cpp:7246-7258

The shutdown message can say that renaming to _INVALID failed even when that directory was deliberately left untouched. When _INVALID already exists, SetAsideInvalidSnapshotDir() can instead fail while removing a stale chainstate_snapshot_todelete or renaming the live snapshot directory to that path. InvalidateCoinsDBOnDisk() still constructs the destination from SNAPSHOT_INVALID_SUFFIX and includes the exception text only in the log. Report that setting the snapshot directory aside failed and include e.what() in the user-facing error without assuming a destination.

source: gpt-6.2-astra (phase2-reviewer: general, dash-core-commit-history)

🟡 Suggestion: Eleven fixup! commits leave review corrections as permanent history
Impact: If the series lands unsquashed, maintainers tracing the Evo transaction requirement will encounter a superseded design in the feature commit and have to reconstruct the shipped change from later corrections.
<commit:c9031ca3d0b>:1

The rebase removed the shared-cache test fixup, leaving ten fixup! and two amend! commits in this layer. In particular, 79d9d55db52 introduces and describes unbound-access checks, 9b842648001 replaces them with transaction-ownership checks at four entry points, and 06cfacabbe4 supplies the matching commit message. Fold the corrections and amended messages into their targets before merge, keeping the Evo feature and the snapshot-rejection fix as separate logical commits.

source: gpt-6.2-astra (phase2-reviewer: general, dash-core-commit-history)

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This is a large, intricate change to consensus-critical validation and Evo state handling, including ProcessSpecialTxsInBlock, UndoSpecialTxsInBlock, and chainstate snapshot/transaction entry points.
  • Phase 1 reviewers: not run (skipped for throughput: 11 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — dash-core-commit-history (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `src/validation.cpp`:
- [SUGGESTION] src/validation.cpp:7246-7258: Snapshot cleanup reports a rename to `_INVALID` even when it never tried that target
  Impact: An operator diagnosing a failed snapshot rejection can be pointed to a preserved `_INVALID` directory instead of the filesystem operation that actually failed.
  The shutdown message can say that renaming to `_INVALID` failed even when that directory was deliberately left untouched. When `_INVALID` already exists, `SetAsideInvalidSnapshotDir()` can instead fail while removing a stale `chainstate_snapshot_todelete` or renaming the live snapshot directory to that path. `InvalidateCoinsDBOnDisk()` still constructs the destination from `SNAPSHOT_INVALID_SUFFIX` and includes the exception text only in the log. Report that setting the snapshot directory aside failed and include `e.what()` in the user-facing error without assuming a destination.

In `<commit:c9031ca3d0b>`:
- [SUGGESTION] <commit:c9031ca3d0b>:1: Eleven `fixup!` commits leave review corrections as permanent history
  Impact: If the series lands unsquashed, maintainers tracing the Evo transaction requirement will encounter a superseded design in the feature commit and have to reconstruct the shipped change from later corrections.
  The rebase removed the shared-cache test fixup, leaving ten `fixup!` and two `amend!` commits in this layer. In particular, `79d9d55db52` introduces and describes unbound-access checks, `9b842648001` replaces them with transaction-ownership checks at four entry points, and `06cfacabbe4` supplies the matching commit message. Fold the corrections and amended messages into their targets before merge, keeping the Evo feature and the snapshot-rejection fix as separate logical commits.

Comment thread src/evo/creditpool.h Outdated
Comment on lines +131 to +135
void ClearCacheForTesting() EXCLUSIVE_LOCKS_REQUIRED(!cache_mutex)
{
LOCK(cache_mutex);
creditPoolCache.clear();
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferred (re-reviewed at c9031ca3): The partitioning you pointed to is now in this head. CCreditPoolManager no longer exposes ClearCacheForTesting(), and the snapshot test no longer calls it, so there is no remaining API change to make here.

PastaPastaPasta and others added 24 commits November 30, 2026 02:20
Isolating the snapshot generation's records is not enough while the
managers keep one cache for both chainstates. The snapshot chainstate
derives values at and below its base from state the snapshot carries,
which nothing has validated yet. The background chainstate connects the
same block hashes and, through a shared cache, took those values
instead of deriving its own: a list, quorum member set, mined-commitment
location or deployment state. For the credit pool at the base, the
background capture then recorded the carried pool, so completion
compared the carried pool with itself.

EvoViewCache keeps one partition per Evo view (EvoDB, identity,
generation). Every cache keyed by a block or quorum hash now resolves
the calling operation's view and uses only that partition: the MN-list
lists, diffs, tip and initial-snapshot anchor; quorum snapshots; MNHF
signals; credit pools; mined-commitment locations and the qc-hash caches,
including the active quorum set GetQcHashes derives from the previous
block's;
the quorum member caches; the quorum manager's quorum, scan and
commitment-scan caches; the versionbits cache; and the previous-coinbase
ChainLock slot, which a snapshot block's validation must read from the
same view the miner of its template did. The versionbits partition and
the EHF signals SignalHeight reads both come from the calling thread's
view. Caches of data parsed from block bytes and the vvec/skshare stores
stay shared, and so do the warning cache, the quorum proof caches and the
quorum-data cleanup cache: only the active view fills them, a rejected
snapshot shuts the node down, and a promoted one has been validated.
What a block mined is read from the block itself, so the record of the
commitments recent blocks mined stays shared.
Retiring a generation drops its partitions at the next lookup and
leaves NORMAL's, so a failed snapshot load no longer empties the active
masternode list until the next block. Promoting a generation, like
opening a CEvoDB, bumps an epoch that drops every partition.
DeploymentActiveAfter/At through a ChainstateManager decide a buried
deployment by height alone, without resolving a view.

The MN-list cache of a view is pruned against the higher of its tip and
the highest block it processed: a view stops receiving tip notifications
once its chainstate is no longer the active one, so a stale tip would
keep its cache from ever being pruned.

EvoViewToken::AtOrBelowSnapshotBase() names the heights at which a snapshot
view holds only carried state, and ReadBlockInView() reads a block body
for a view, raising BlockDataUnavailableError where the snapshot view lacks
it instead of reporting the body as unreadable.

A snapshot view has no quorum history at or below its base once DIP3 is
active there (a base at or above the DIP3 height), so lookups that would
need it raise BlockDataUnavailableError instead of answering from
partial data: a mined-commitment scan that comes up short
(GetMinedCommitmentsUntilBlock, and the rotating per-index scan on a
miss), a HasMinedCommitment miss for a quorum at or below the base, and
the coinbase ChainLock read of a block at or below the base whose body
is not stored.

EHF signal lookups only read, as on develop since dashpay#8098, so
the signals are still written only when a block is connected or rebuilt
at startup, inside an Evo transaction. The MNHF signal cache keeps one
partition per view like the others. A snapshot view holds only what its
snapshot carried and its chainstate connected, and what else it lacks is
recovered by the startup that promotes the validated snapshot, so a
lookup there that finds no record raises BlockDataUnavailableError (a
stall) instead of EvoDbMissingStateError, which NORMAL keeps. The
startup rebuild never walks a snapshot view at or below its base, whose
blocks are unvalidated and whose bodies it lacks.

Adds CDeterministicMNManager::SetListSnapshotMissHookForTesting, which
reports lookups that miss both the cache and the stored lists, and
CachedListHeightsForTesting, for the partition and pruning tests and the
tests that need one lookup to fail. With the hook, a test also
rejects a snapshot in the middle of a block connection and checks that
the background chainstate becomes the active one.

A quorum scan is cached only when its start block is on the chain that
its view's mined-commitment index describes (dashpay#8102), now the
chain of the usable chainstate with the view's Evo identity
(ChainstateManager::EvoChain) instead of the active chain. A background
view's index follows the background chainstate, so its scans from blocks
it has not connected are not cached, and a view no usable chainstate
reads caches nothing.
chainstatemanager_rejection_mid_connect_activates_background checks that
mapping during dual operation and after a rejection.

RequireSatisfiedScan raises for a short height-index scan under a snapshot
view based at or above DIP3 only when the type was enabled at the end of
the missing range or at DIP3 activation: a type not enabled up to the base
has no commitments there, so its short scan is complete, and a CbTx
quorum-root check over it must not stall the snapshot chainstate. Deployment-gated types stay enabled once enabled, and the types
DIP0024 retires are enabled from DIP3 on. The check runs before the EvoDB
lock is taken, because deployment state can read EvoDB.

The mined-commitment walkers that getPlatformQuorum reads its window
with throw BlockDataUnavailableError under such a view when the window
reaches history the view lacks, even for a quorum in the part of the
window above the base.

The base is checked first, and the DIP3 ancestor is only looked up when
that check fails: a chain that does not reach genesis, such as the
testnet-height chain quorum_proofs_tests builds, has no such ancestor.

With the MN-list miss hook this adds, a test also rejects the snapshot in
an ActivateBestChain step that first disconnected one of its blocks, which
must not leave that block's transactions queued.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Evo accesses resolved their view from an open transaction or, failing
that, the active chainstate. Work for the background chainstate outside
a transaction, and work handed to another thread, silently used the
active (snapshot) view instead. ForceSignalDBUpdate, for one, opened a
NORMAL transaction at the active snapshot tip and flushed the NORMAL
root.

Every Chainstate method that reads Evo state (ActivateBestChain,
ConnectTip, DisconnectTip, ReplayBlocks, LoadChainTip, RollforwardBlock,
FlushStateToDisk, InvalidateBlock, EnforceBlock), TestBlockValidity, VerifyDB and the
per-chainstate startup loops now bind that chainstate's view.
ForceSignalDBUpdate takes the intended chainstate's view and uses its
identity for the transaction and the root commit. Signals that view cannot
rebuild (through RebuildSignals(), the startup-only rebuild of
dashpay#8098) are left unavailable when it is a snapshot view, so
startup can still reach the promotion of a validated snapshot; NORMAL,
which lacks history only when it was pruned, still fails startup, as
does a body that cannot be read. ReplayBlocks runs that rebuild only for
NORMAL, the one view a datadir from before v22 can have left in the old
format.

DMN repair binds NORMAL and takes its block range from NORMAL's chain:
`evodb verify` and `evodb repair` default to it, resolve a height in it
and refuse a block outside it, and the startup repair stops at its tip.
Until promotion, NORMAL's records end at the background tip, even after
background validation completes, so a range ending at the active
snapshot tip would ask NORMAL to verify records it does not hold.

Active-chain dispatchers bind the active chainstate's view per operation
unless the thread is already bound, with a single view too, so a turn
that a snapshot publication overtakes finishes in the view it started
in. While a snapshot generation is live, the view is read under cs_main,
together with the active tip where the turn needs one
(ActiveEvoViewScope::Tip()), so a turn never pairs one chainstate's view
with another's tip. With a single view there is nothing to pair, and a
turn that needs no tip binds without waiting for cs_main.

The dispatchers are: RPC execution, each peer's message-handler turn
as two operations (receiving its queued GETDATA requests and its next
message, then its sends, so a view change between them can reach the
sends), the miner, mempool admission, Evo-reading interfaces calls, each
node-scheduler task and each ChainLock, DKG and InstantSend work round.
A failing work round, the LLMQ signing loops' and each DKG phase
handler's included, is logged once per operation, view generation and
reason, and its recovery once the operation has gone a minute without
failing. A local Evo state error in a message handler drops that
message, like any exception there, without punishing the peer; one from
the peer's queued GETDATA requests ends receiving for that turn. Neither
ends the message-handler thread, and the peer's sends (including its
discouragement and ping timeout) still run. GETDATA requests leave the
queue before they are served, so a failed lookup neither serves earlier
requests again nor keeps the peer's later messages waiting; it is
answered with NOTFOUND together with the requests found missing before
it, and the requests after it are served on the next turn. The node
scheduler and REST start before the block databases load, and a load
retry replaces the Evo database, so they bind only to the one startup
publishes once loading is final (and withdraws before destroying it,
after they have stopped); until then their work runs unbound. RPC is
held off by its warm-up until then. A chainstate load retry first lets
the validation events the failed attempt queued run, since they are
bound to the databases it then releases. Queued validation events and
LLMQ worker-pool tasks capture the enqueuing thread's binding and
reinstall it when they run; a task bound to a retired generation, or
whose binding cannot be installed, is dropped, and what its enqueuer
claimed for it is released. A local Evo state error in one subscriber to
a queued event stays with that subscriber, and the others still receive
the event; synchronous signals still pass it on to their caller. Either
way the subscriber's registration count stays right, so it can still be
unregistered.

Every GUI- and wallet-facing interface operation that reads Evo state
(the EVO provider operations, Evo, governance and LLMQ reads,
isV24Active and listMNCollaterials) binds the active view and contains
evo::LocalStateError at the interface boundary: it logs once per
operation and generation, sets the misc warning, and reports failure
through the operation's own channel. Operations without one now return
std::optional (or, for GovernanceInfo, an optional fundingthreshold),
and their Qt and wallet consumers keep their current data, show that the
masternode state is unavailable, or refuse the action, instead of
treating it as data. getPlatformQuorum runs Q's lookup in the bound
view as well, and answers UNAVAILABLE when it cannot, or when a snapshot
was published after it bound its view. While the masternode list is unavailable, the
wallet keeps outputs it cannot classify out of automatic coin selection,
CoinJoin's included, and classifies them again on the next block. A
block builds its wallet batch only for that work or for a block it
scans.

An automatic outbound round reads the tip masternode list only when a
connected masternode has to be skipped, so a node that lost its peers
while the list is unavailable can still connect. A recovered signature
whose quorum cannot be checked is dropped on its own, without blaming its
peer, and the rest of its batch is still verified.

During dual operation a quorum based at or below the snapshot base is in
history the snapshot view does not have, and selecting it throws a local
Evo state error. That error escaped BuildVerificationBatch, ended the work
round, and dropped every lock FetchPendingLocks had already taken off the
queue, so one such lock cost up to 31 others.

Catch it per lock instead. The lock is left out of the batch and of the
results: it cannot be verified in this run, and its peer is not to blame.

The catch covers any local Evo state error from quorum selection, such
as a rotating-quorum scan that fails before a signing quorum is chosen;
a quorum below the snapshot base is the case that prompted it.

GUI models poll the wrapped operations, and every failed poll set the misc
warning again and notified the GUI. Raise it together with the log line,
through the new WarnLocalEvoStateUnavailable(), once per operation and
active Evo view. On a node without a snapshot it
says that block data was pruned and suggests -reindex when block data is
what is missing; for any other cause it names neither pruning nor a
snapshot.

getPlatformQuorum runs through WithActiveEvoView, so the typed scan error
becomes UNAVAILABLE rather than INVALID, even for a quorum in the part of
the window above the base. A quorum mined below the base is a block of the
active chain below any later height, so it stays UNAVAILABLE once a window
above the base has left it behind, too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…icitly

The endpoint recovery check restored the DIP3 height before retrying, so
the height-100 lookup returned an empty list without reading EvoDB and
passed whatever the read would do. Retry with DIP3 still active, against
a stored tip list, and restore the height afterwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…icitly

An unreadable masternode list made outbound selection skip whole rounds,
feelers and extra block-relay attempts included, for as long as it stayed
unreadable. Select without the connected-masternode filter instead. Also
say that Node::isV24Active() describes the next block, as it evaluates
DeploymentActiveAfter(tip).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…icitly

Restore DIP0003Height from a guard in evo_state_unavailable_is_contained,
so a failed BOOST_REQUIRE does not leave DIP3 counted from genesis for the
tests after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…icitly

There is no thread-bound view to bind any more. A chainstate's Evo work
resolves its view through the transaction the chainstate opens, and every
other access reads the active chainstate's view, so:

- The chainstate methods, mempool admission and the miner no longer bind
  a scope: their Evo work runs inside their transaction, or serves the
  active chainstate. Evicting a rolled-back candidate from the MN-list
  cache names the chainstate's view, since the transaction is gone by then.
- Activation reads the background chainstate's base list inside the NORMAL
  transaction it writes the hash in. DMN verification and repair take
  cs_main and a NORMAL transaction per snapshot pair, IsRepaired() one for
  its read, and CompleteRepair() writes NORMAL by name.
- The dispatcher boundaries (RPC, REST, both halves of the message-handler
  turn, the interfaces operations, the scheduler and the LLMQ work rounds)
  keep containing evo::LocalStateError, without ActiveEvoViewScope.
  getPlatformQuorum reads under cs_main, where the active chain and its view
  change together, so it no longer compares views.
- Queued validation events and worker-pool tasks read the view that is
  active when they run. EvoViewCapture, WithCapturedEvoView and their drop
  path are gone; ContainLocalEvoErrors keeps a local Evo error inside the
  task, and the per-subscriber containment of queued events is an argument
  of MainSignalsImpl::Iterate (IterateQueued) instead of a thread_local.
- NodeContext::evodb_for_dispatch, RunSchedulerTask and the Evo database
  argument of the message handler are gone with the bindings they served.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…icitly

A reorg revalidates each provider transaction in the mempool with
CheckSpecialTx() at the new tip (dashpay#8214). Under a snapshot view
that lacks the state the check needs, it throws evo::LocalStateError, which
is not a std::exception: CheckSpecialTxInner() does not catch it, and
nothing on the way out of MaybeUpdateMempoolForReorg() did either, so the
error ended the block processing or RPC call that reorganized the chain.

Remove such a transaction instead. This node cannot tell whether it is
still valid, and keeping it unchecked would let block assembly select it.
Its sender is not blamed, and the reorg completes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…icitly

fix(evo): name non-active Evo views and contain local Evo errors

Evo accesses resolve their view from the calling thread's open
transaction or, failing that, the active chainstate. Work for the
background chainstate outside its transaction silently used the active
(snapshot) view instead. ForceSignalDBUpdate, for one, opened a NORMAL
transaction at the active snapshot tip and flushed the NORMAL root.

Such work now names the view it serves. ForceSignalDBUpdate takes the
intended chainstate's view and uses its identity for the transaction and
the root commit. Signals that view cannot rebuild (through
RebuildSignals(), the startup-only rebuild of dashpay#8098) are
left unavailable when it is a snapshot view, so startup can still reach
the promotion of a validated snapshot; NORMAL, which lacks history only
when it was pruned, still fails startup, as does a body that cannot be
read. ReplayBlocks runs that rebuild only for NORMAL, the one view a
datadir from before v22 can have left in the old format. Activation
reads the background chainstate's base list inside the NORMAL
transaction it records its hash in, and a candidate block whose
transaction was rolled back is evicted from its own chainstate's MN-list
cache.

DMN repair reads NORMAL, through a NORMAL transaction per snapshot pair
under cs_main, and takes its block range from NORMAL's chain: `evodb
verify` and `evodb repair` default to it, resolve a height in it and
refuse a block outside it, and the startup repair stops at its tip.
Until promotion, NORMAL's records end at the background tip, even after
background validation completes, so a range ending at the active
snapshot tip would ask NORMAL to verify records it does not hold.

Active-chain dispatchers read the active view and contain this node's
local Evo state errors at their boundary. They are: RPC execution, each
peer's message-handler turn as two operations (receiving its queued
GETDATA requests and its next message, then its sends, so a view change
between them can reach the sends), the miner, mempool admission,
Evo-reading interfaces calls, each node-scheduler task and each
ChainLock, DKG and InstantSend work round. A failing work round, the
LLMQ signing loops' and each DKG phase handler's included, is logged
once per operation, active view generation and reason, and its recovery
once the operation has gone a minute without failing. A local Evo state
error in a message handler drops that message, like any exception there,
without punishing the peer; one from the peer's queued GETDATA requests
ends receiving for that turn. Neither ends the message-handler thread,
and the peer's sends (including its discouragement and ping timeout)
still run. GETDATA requests leave the queue before they are served, so a
failed lookup neither serves earlier requests again nor keeps the peer's
later messages waiting; it is answered with NOTFOUND together with the
requests found missing before it, and the requests after it are served
on the next turn. A chainstate load retry first lets the validation
events the failed attempt queued run, since they can read the databases
it then releases. Queued validation events and LLMQ worker-pool tasks
read the view active when they run; a local Evo state error ends the
task, and what its enqueuer claimed for it is released. A local Evo
state error in one subscriber to a queued event stays with that
subscriber, and the others still receive the event; synchronous signals
still pass it on to their caller. Either way the subscriber's
registration count stays right, so it can still be unregistered.

Every GUI- and wallet-facing interface operation that reads Evo state
(the EVO provider operations, Evo, governance and LLMQ reads,
isV24Active and listMNCollaterials) contains evo::LocalStateError at the
interface boundary: it logs once per operation and generation, sets the
misc warning, and reports failure through the operation's own channel.
Operations without one now return std::optional (or, for GovernanceInfo,
an optional fundingthreshold), and their Qt and wallet consumers keep
their current data, show that the masternode state is unavailable, or
refuse the action, instead of treating it as data. getPlatformQuorum
answers UNAVAILABLE when its lookup cannot read the state. While the
masternode list is unavailable, the wallet keeps outputs it cannot
classify out of automatic coin selection, CoinJoin's included, and
classifies them again on the next block. A block builds its wallet batch
only for that work or for a block it scans.

An automatic outbound round reads the tip masternode list only when a
connected masternode has to be skipped, so a node that lost its peers
while the list is unavailable can still connect. A recovered signature
whose quorum cannot be checked is dropped on its own, without blaming
its peer, and the rest of its batch is still verified.

During dual operation a quorum based at or below the snapshot base is in
history the snapshot view does not have, and selecting it throws a local
Evo state error. That error escaped BuildVerificationBatch, ended the
work round, and dropped every lock FetchPendingLocks had already taken
off the queue, so one such lock cost up to 31 others.

Catch it per lock instead. The lock is left out of the batch and of the
results: it cannot be verified in this run, and its peer is not to
blame.

The catch covers any local Evo state error from quorum selection, such
as a rotating-quorum scan that fails before a signing quorum is chosen;
a quorum below the snapshot base is the case that prompted it.

GUI models poll the wrapped operations, and every failed poll set the
misc warning again and notified the GUI. Raise it together with the log
line, through the new WarnLocalEvoStateUnavailable(), once per operation
and active Evo view. On a node without a snapshot it says that block
data was pruned and suggests -reindex when block data is what is
missing; for any other cause it names neither pruning nor a snapshot.

getPlatformQuorum runs through WithActiveEvoView, so the typed scan
error becomes UNAVAILABLE rather than INVALID, even for a quorum in the
part of the window above the base. A quorum mined below the base is a
block of the active chain below any later height, so it stays
UNAVAILABLE once a window above the base has left it behind, too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
With two chainstates, an Evo access that no transaction or scope binds
says nothing about which chainstate it serves. Resolving it to the
default identity silently computed one chainstate's state from the
other's data.

While a snapshot generation is live, an unbound read, write, iterator
or cache lookup now raises EvoViewBindingError before touching any
state, as one bound to a retired generation already does. The check is a plain
throw, so it holds in release builds. Manager entry points that take an
explicit chainstate (ProcessSpecialTxsInBlock, UndoSpecialTxsInBlock and
the quorum block processor's ProcessBlock and UndoBlock) refuse to run
unless the calling thread is bound to that chainstate's view, raising
EvoViewBindingError on connect and undo alike, so the chainstate
boundaries classify it as a local stall. With a
single chainstate the NORMAL default is unchanged unless
-checkevobinding is set.

A binding fault is a local error everywhere: state.Error during
validation, RPC_INTERNAL_ERROR over RPC, an aborted operation for P2P
and the miner, a logged and ended task for queued and scheduled work,
and an initialization failure at startup. It never becomes an empty
success, consensus invalidity, a peer penalty or a process abort.

A new test extends the snapshot chain past DIP3 and V20 activation and
the first disk-snapshot period with a registered masternode, and checks
that the real MN-list, credit-pool and EHF state it writes stays in its
generation and its cache partitions, and that NORMAL rebuilds all of it
after the snapshot is rejected and the node restarts.

-checkevobinding (default: on for regtest, and forced on in the unit
test fixtures) applies the same rule with a single chainstate: an
unbound access raises EvoViewBindingError before any snapshot exists, so
tests and regtest exercise the bindings everywhere. Test code that
drives the node the way a dispatcher does binds like one:
NotifyMNListTip delivers a tip notification in the active view, tests
and fuzz targets that drive a peer through the test connman bind its
turn as ServicePeer does, and test bodies that call into the node
directly open an active-chain turn. The interfaces sweep covers
getPlatformQuorum.

The release note records the externally visible changes:
RPC_INTERNAL_ERROR for local Evo errors and strict binding on regtest.

With dashpay#8098, MNHF signal lookups never rebuild from block
bodies. Its signals_unavailable_for_unconnected_block test binds the
active view for its lookups, as this commit requires of every Evo read.
In chainstatemanager_snapshot_evo_state_past_dip3, NORMAL finds the EHF
signals of the blocks only the snapshot chainstate connected missing,
and with them the credit pool it would derive there, rather than
rebuilding them.

The scan_from_stale_fork_block_is_rescanned_once_active test of
dashpay#8102 binds the active view the same way.

The four orphan-vote tests that dashpay#7819 adds to
governance_vote_processing_tests bind it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…is not saved

When HandleSnapshotStateMismatch could not sync EvoDB or persist the
rejection, the snapshot generation stayed bound and the default Evo
identity stayed SNAPSHOT, although the IBD chainstate was active again.
For the rest of the run, dispatches bound to the active view read the
rejected generation, and so did every operation that had bound it before
the rejection: a DKG round waiting at its start for background
validation, a message-handler turn waiting for cs_main, a queued event or
task.

In that case, revoke the generation for the rest of the run
(CEvoDB::RevokeSnapshotGeneration). In memory it is retired as a saved
rejection retires it: views bound to it no longer resolve, the default
identity is NORMAL, the node no longer counts as running two chainstates,
and what the generation has not written is dropped. Its records stay on
disk, so startup recovery still rejects it, and until then no new
generation can be created.

A test makes the rejection fail to persist through a new CEvoDB test
failpoint while a DKG-style round bound to the snapshot view waits at its
start. The round resumes and fails instead of reading the rejected
generation, active-view reads see NORMAL, and after a restart startup
recovery rejects the generation.

An earlier rejection's chainstate_snapshot_INVALID directory keeps its
place: the live path discards the rejected snapshot directory instead of
renaming it onto that one, as startup recovery already did. Otherwise
the rename failed, the snapshot directory and its generation both stayed
with no rejection on disk, and the next startup could promote the
rejected generation. Both paths share node::SetAsideInvalidSnapshotDir,
which renames to chainstate_snapshot_todelete before deleting, so a
deletion cut short never leaves a partial chainstate_snapshot. A
leftover chainstate_snapshot_todelete is removed at startup and before
the next move there, and one whose deletion fails after the move is only
logged, since nothing reads it. The test starts with a nonempty earlier
_INVALID directory and a leftover chainstate_snapshot_todelete, and
checks that the former is kept, the snapshot directory is set aside, and
after a restart the rejected generation is neither active nor promoted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ection is not saved

A fatal check that failed before the round resumed unwound into the
future's destructor, which waited for a worker nothing stopped, so the test
hung instead of reporting the failure. Request the stop from a guard that
every exit path runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ection is not saved

When neither the rejection record nor the move of the snapshot chainstate
directory persists, nothing on disk marks the snapshot rejected and the
next start loads it again. Say so in the stop message, and name the
restart that discards it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ection is not saved

A snapshot journaled for promotion, restarted before its first rename and
then rejected without the rejection being saved, leaves the promotion
journal next to a coins directory set aside as invalid. Startup took that
for a finished swap and would promote the rejected generation if the
background tip matched the journaled one. Refuse it instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Say that -checkevobinding=0 does not relax the binding requirement of
dual-chainstate operation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ection is not saved

SetAsideInvalidSnapshotDir keeps an earlier rejection's _INVALID
directory, so its presence does not mean the journaled snapshot was
rejected, and refusing on it blocked the promotion of a later validated
snapshot. The swap keeps chainstate_todelete until the promotion
completes, so refuse a journaled swap only when that directory is
missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ection is not saved

Bound the wait for the DKG round to bind, so a worker that exits before
binding fails the test instead of hanging it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without a thread-bound view there is no unbound access to reject: an
access resolves to this thread's open transaction or to the active
chainstate's view, the rule develop already has. What can still read the
wrong view is work for a chainstate that runs outside its own
transaction, so the manager entry points that take an explicit
chainstate (ProcessSpecialTxsInBlock, UndoSpecialTxsInBlock, and the
quorum block processor's ProcessBlock and UndoBlock) refuse to run unless
the calling thread holds that chainstate's Evo transaction
(Chainstate::HoldsEvoTransaction, CEvoDB::HoldsTransaction(identity)),
in release builds too.

-checkevobinding, CEvoDB's check_binding argument, IsCurrentView() and
the active-view bindings this commit added to tests, fuzz targets and the
NotifyMNListTip helper are gone. The interfaces sweep now checks that
every Evo-reading interfaces call from a thread of its own succeeds with
one view and with two. The release note keeps the RPC_INTERNAL_ERROR
change only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ection is not saved

A DKG-style round that started reading the snapshot view no longer holds
a binding to it: once the generation is revoked it resumes reading the
active view, NORMAL, and completes without ever reading the rejected
generation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(evo): require a chainstate's own Evo transaction at its entry points

With two chainstates, Evo state is read through the calling thread's
open transaction or, without one, in the active chainstate's view. Work
for the background chainstate that ran outside its own transaction would
silently compute its state from the snapshot's data.

Manager entry points that take an explicit chainstate
(ProcessSpecialTxsInBlock, UndoSpecialTxsInBlock and the quorum block
processor's ProcessBlock and UndoBlock) now refuse to run unless the
calling thread holds that chainstate's Evo transaction
(Chainstate::HoldsEvoTransaction), raising EvoViewBindingError on
connect and undo alike, so the chainstate boundaries classify it as a
local stall. The check is a plain throw, so it holds in release builds.

A binding fault is a local error everywhere: state.Error during
validation, RPC_INTERNAL_ERROR over RPC, an aborted operation for P2P
and the miner, a logged and ended task for queued and scheduled work,
and an initialization failure at startup. It never becomes an empty
success, consensus invalidity, a peer penalty or a process abort.

A new test extends the snapshot chain past DIP3 and V20 activation and
the first disk-snapshot period with a registered masternode, and checks
that the real MN-list, credit-pool and EHF state it writes stays in its
generation and its cache partitions, and that NORMAL rebuilds all of it
after the snapshot is rejected and the node restarts. Another calls
every Evo-reading interfaces operation from a thread of its own, with
one view and with two, and requires none of them to fail.

The release note records the externally visible change:
RPC_INTERNAL_ERROR for local Evo errors.

With dashpay#8098, MNHF signal lookups never rebuild from block
bodies. In chainstatemanager_snapshot_evo_state_past_dip3, NORMAL finds
the EHF signals of the blocks only the snapshot chainstate connected
missing, and with them the credit pool it would derive there, rather
than rebuilding them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ection is not saved

fix(validation): stop reading a rejected snapshot when its rejection is not saved

When HandleSnapshotStateMismatch could not sync EvoDB or persist the
rejection, the snapshot generation stayed bound and the default Evo
identity stayed SNAPSHOT, although the IBD chainstate was active again.
For the rest of the run, every read of the active view, a DKG round
waiting at its start for background validation, a message-handler turn
or a queued event or task alike, read the rejected generation.

In that case, revoke the generation for the rest of the run
(CEvoDB::RevokeSnapshotGeneration). In memory it is retired as a saved
rejection retires it: no access reaches it, the default identity is
NORMAL, the node no longer counts as running two chainstates, and what
the generation has not written is dropped. Its records stay on disk, so
startup recovery still rejects it, and until then no new generation can
be created.

A test makes the rejection fail to persist through a new CEvoDB test
failpoint while a DKG-style round that read the snapshot view waits at
its start. The round resumes reading NORMAL, never the rejected
generation, active-view reads see NORMAL, and after a restart startup
recovery rejects the generation.

An earlier rejection's chainstate_snapshot_INVALID directory keeps its
place: the live path discards the rejected snapshot directory instead of
renaming it onto that one, as startup recovery already did. Otherwise
the rename failed, the snapshot directory and its generation both stayed
with no rejection on disk, and the next startup could promote the
rejected generation. Both paths share node::SetAsideInvalidSnapshotDir,
which renames to chainstate_snapshot_todelete before deleting, so a
deletion cut short never leaves a partial chainstate_snapshot. A
leftover chainstate_snapshot_todelete is removed at startup and before
the next move there, and one whose deletion fails after the move is only
logged, since nothing reads it. The test starts with a nonempty earlier
_INVALID directory and a leftover chainstate_snapshot_todelete, and
checks that the former is kept, the snapshot directory is set aside, and
after a restart the rejected generation is neither active nor promoted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The coinstatsindex unclean-shutdown test connects a block directly, so it
opens the chainstate's Evo transaction for it, as ConnectTip does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

New on this head: This head rebases the AssumeUTXO Evo entry-point validation and rejected-snapshot revocation changes, with the latest commit only tightening snapshot-mining test progress checks. No code check has failed; formatting, lint, cache, and metadata checks pass, while several build and analysis jobs remain queued or in progress.

🟡 3 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

2 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Eleven fixup! commits leave review corrections as permanent history
Impact: Future readers encounter the review transcript as permanent history, making the Evo and validation changes harder to audit, bisect, selectively backport, or revert.
<commit:e342632f5a4>:1

The rebased range still preserves the same 20 fixup! or amend! commits, including the final test-only correction. Autosquash these review corrections into the substantive Evo and validation commits and reword the resulting messages before merging so each remaining commit has an independently meaningful historical boundary.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: dash-core-commit-history)

🟡 Suggestion: Snapshot cleanup reports a rename to _INVALID even when it never tried that target
Impact: When an earlier _INVALID directory exists and cleanup fails, operators receive a misleading recovery message naming a rename that was not attempted.
src/validation.cpp:7246-7258

The failure diagnostic always reports chainstate_snapshot being renamed to chainstate_snapshot_INVALID, but SetAsideInvalidSnapshotDir() preserves an existing _INVALID directory and instead renames the live directory to _todelete before deleting it. Consequently, the logged and returned error can describe an operation that never occurred exactly when manual recovery information matters. Report the selected destination or propagate an error from the helper that identifies the actual operation.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: general, dash-core-commit-history)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: dash-core-commit-history); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — This is a large, cross-cutting change affecting Evo view binding, chainstate entry points, validation, networking, interfaces, and extensive tests, but the diff does not itself meet the defined critical-surface criteria for consensus rules, funds movement, cryptography, peer-facing deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — dash-core-commit-history (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `<commit:e342632f5a4>`:
- [SUGGESTION] <commit:e342632f5a4>:1: Eleven `fixup!` commits leave review corrections as permanent history
  Impact: Future readers encounter the review transcript as permanent history, making the Evo and validation changes harder to audit, bisect, selectively backport, or revert.
  The rebased range still preserves the same 20 `fixup!` or `amend!` commits, including the final test-only correction. Autosquash these review corrections into the substantive Evo and validation commits and reword the resulting messages before merging so each remaining commit has an independently meaningful historical boundary.

In `src/validation.cpp`:
- [SUGGESTION] src/validation.cpp:7246-7258: Snapshot cleanup reports a rename to `_INVALID` even when it never tried that target
  Impact: When an earlier `_INVALID` directory exists and cleanup fails, operators receive a misleading recovery message naming a rename that was not attempted.
  The failure diagnostic always reports `chainstate_snapshot` being renamed to `chainstate_snapshot_INVALID`, but `SetAsideInvalidSnapshotDir()` preserves an existing `_INVALID` directory and instead renames the live directory to `_todelete` before deleting it. Consequently, the logged and returned error can describe an operation that never occurred exactly when manual recovery information matters. Report the selected destination or propagate an error from the helper that identifies the actual operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pastaclaw:approved thepastaclaw's latest review approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants