Skip to content

feat: seed the evo snapshot section safely and rebuild it at completion - #8272

Merged
PastaPastaPasta merged 4 commits into
dashpay:developfrom
PastaPastaPasta:feat/evo-snapshot-seed-verify
Dec 4, 2026
Merged

PastaPastaPasta merged 4 commits into
dashpay:developfrom
PastaPastaPasta:feat/evo-snapshot-seed-verify

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

After #7601 a snapshot's evo section is checked against its pin and then dropped: a snapshot chainstate at a DIP3-active base has none of the Evo state the blocks above its base need, and such a snapshot is never validated. The section has to be loaded into the snapshot chainstate, and background validation has to confirm that it is what the node derives itself.

AssumeUTXO stack (merge in this order): #8286, #7593, #8271 and #7601 are merged, then this PR → #8078 → #8273 → #8079 → #8276. The whole stack is in #8284.

What was done?

Built on #8286, #7593, #8271 and #7601: each Chainstate owns its Evo state, so the section is seeded into the snapshot chainstate's own EvoDB and a rejected snapshot takes that EvoDB with it. There is no unpublished generation and nothing to publish or roll back.

  1. feat(validation): seed the evo section into the snapshot chainstate.
    • Loading writes the pinned section into the snapshot chainstate's EvoDB through each manager's seeding entry point (SeedEvoSnapshotState()), then runs the chain checks export runs (PreflightEvoSnapshot()), reading deployment state at or below the base from the carried signal record.
    • Before activation a dry run (DryRunEvoSnapshot()) computes from the seeded state alone every quorum the chainstate may need at or right after the base. Any failure rejects the snapshot.
    • The shared block index is changed only after these checks, so a refused section leaves it as it was. A load that throws is cleaned up like a refused one before the exception is passed on.
    • An unpinned section before DIP3 carries nothing needed and is ignored.
    • The comparison of the serialized masternode list at completion is removed, with GetDeterministicMNListHash(). A snapshot numbers its masternodes by the rank of their proTxHash and a chainstate by registration order, so with a seeded list the two serializations differ even when they agree on every masternode.
  2. fix(validation): keep the validated chainstate's block candidates when a snapshot is rejected. The rejection makes the background chainstate active, but its candidates held only the base and its ancestors, so the next CheckBlockIndex() aborted. Inherited from assumeutxo: background validation completion bitcoin/bitcoin#25740; Bitcoin Core still has it.
  3. feat(validation): rebuild and compare the full evo section at completion.
    • When background validation reaches the base, completion rebuilds the whole section from the background chainstate's Evo state (BuildEvoSnapshot()) and requires its hash to be the pinned one. This replaces the gate of feat: emit the v4 evo snapshot section and require a matching evo pin #7601 that never validated a DIP3-active snapshot.
    • A disagreement rejects the snapshot (EVO_STATE_MISMATCH). Data the background chainstate still lacks leaves the snapshot in use, unvalidated (EVO_DATA_UNAVAILABLE). Unreadable or inconsistent local state, or an internal error, stops the node and keeps the snapshot (the new EVO_LOCAL_FAILURE and EVO_INTERNAL_ERROR); SnapshotCompletionStopMessage() tells the operator how to recover, at completion and at startup.
    • An EvoDB whose best block is not its chainstate's coins tip is such a local failure now; it used to reject the snapshot.

What to focus on: the order of seeding, preflight and dry run in PopulateAndValidateSnapshot(), and how completion classifies a failed rebuild.

How Has This Been Tested?

validation_chainstatemanager_tests, on the EvoSnapshotTestSetup of #7601:

  • chainstatemanager_evo_snapshot_cold_load (new): a node with only the headers loads the snapshot, extends it past the next rotation cycle from the carried state alone, validates it in the background and promotes it at the next start. Before that, a pinned section whose base coinbase the header does not prove is refused and leaves the block index untouched.
  • chainstatemanager_evo_snapshot_completion_rejects_a_lying_section (new): a pinned section that every load check accepts, with a credit-pool limit the chain does not derive, is rejected at completion and the node continues on the validated chain.
  • chainstatemanager_evo_snapshot_requires_its_pin: the honest snapshot now has its masternode list at the base and is validated where it used to stay unvalidated.
  • chainstatemanager_snapshot_completion_incorrect_base_mn_list is removed with the comparison it triggered.

Breaking Changes

None. Only C++ tests can activate a snapshot at this layer; loadtxoutset arrives later in the stack.

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

@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 15996de) · triage: normal

@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 2 only (queue backlog)

Changes requested: 5 blockers

  • Snapshot validation is skipped until restart when NORMAL reaches the base before the switch — src/validation.cpp:6775-6780 (new)
    Impact: A node that reaches the base during snapshot preparation can keep using snapshot state that disagrees with state it has already validated.
  • A crash after the snapshot base marker is synced can abort the next startup — src/validation.cpp:6697-6702 (new)
    Impact: A node loading a snapshot ahead of its downloaded block bodies can fail to restart if it stops after the base marker is synced but before the block index is flushed.
  • Coins left by an interrupted load can make a valid snapshot fail on retry — src/node/chainstate.cpp:453-465 (new)
    Impact: An operator who restarts after an interrupted load can retain an unused coins database and then have a valid snapshot at a different authorized base rejected.
  • Failed database opens leak resources that the new LeakSanitizer rule hides — test/sanitizer_suppressions/lsan:5-8 (new)
    Impact: The new failed-open test leaves three LevelDB option allocations unreleased, and the suppression also hides matching leaks from other database opens.
  • A background coins read error can make completion reject a good snapshot — src/validation.cpp:7434-7455 (new; not shown inline, see below)
    Impact: If a LevelDB checksum or I/O error interrupts the background UTXO scan, the node can quarantine a valid snapshot and revert to the database it could not fully read.

The two new commits seed and dry-run Evo state in an unpublished generation, then rebuild the section from NORMAL state at snapshot completion. Linux and ASan builds and tests, lint, and Cppcheck passed; the Windows, TSan, and multiprocess builds and the no-wallet tests were still pending. The stack has four merge conflicts with develop.

🔴 5 blocking | 🟡 4 suggestion(s)

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

🔴 Blocking: A background coins read error can make completion reject a good snapshot
Impact: If a LevelDB checksum or I/O error interrupts the background UTXO scan, the node can quarantine a valid snapshot and revert to the database it could not fully read.
src/validation.cpp:7434-7455

Completion preserves the snapshot only when ComputeUTXOStats() returns no result. The coins cursor does not expose CDBIterator::HasError(), so a LevelDB scan that skips records or stops early can still yield a successful hash of a partial set. That sends a local read failure down the HASH_MISMATCH path, which rejects the snapshot and shuts down. Propagate iterator status through the coins cursor and fail the stats scan before finalizing the hash. The malformed-coin test covers a GetValue() decode failure, not an iterator error.

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); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 4: 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) — The two new commits change the persistent chainstate migration in src/validation.cpp’s ValidatedSnapshotCleanup, where flush ordering and EvoDB marker promotion must remain consistent across crashes.
  • Phase 1 reviewers: not run (skipped for throughput: 15 PRs queued, above the 10 limit)
  • Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
  • 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, 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`:
- [BLOCKING] src/validation.cpp:6775-6780: Snapshot validation is skipped until restart when NORMAL reaches the base before the switch
  Impact: A node that reaches the base during snapshot preparation can keep using snapshot state that disagrees with state it has already validated.
  `SnapshotSwitchRefusal()` permits NORMAL's tip to equal the base, but activation then reports success without comparing the two states. The connect that reached the base ran while NORMAL was still active, so it skipped `MaybeCompleteSnapshotValidation()`. After the switch, newly arriving descendants are not eligible for background validation, so they do not trigger a retry. The switch-gap test reaches this case but calls `Complete()` itself. Run completion at the handoff when NORMAL is already at the base, handle the result before reporting success, and test that both a match and a disagreement are handled without an explicit completion call.
- [BLOCKING] src/validation.cpp:6697-6702: A crash after the snapshot base marker is synced can abort the next startup
  Impact: A node loading a snapshot ahead of its downloaded block bodies can fail to restart if it stops after the base marker is synced but before the block index is flushed.
  Startup can recognize a snapshot whose block index is not ready to use it. `WriteSnapshotBaseBlockhash()` syncs the marker before the loop that sets `nTx` and `BLOCK_ASSUMED_VALID`, and the index is flushed later. If the base header was already on disk but its block was not, startup reconstructs a zero `nChainTx` for the base. `LoadBlockIndex()` still admits the base as a background candidate, and `FindMostWorkChain()` asserts `HaveTxsDownloaded()` before checking for missing block data. Make recovery finish index preparation before candidate admission, or journal the handoff so this state cannot be resumed. The existing post-publication failpoint stops before the base-marker write and does not cover this window.
- [BLOCKING] src/validation.cpp:7434-7455: A background coins read error can make completion reject a good snapshot
  Impact: If a LevelDB checksum or I/O error interrupts the background UTXO scan, the node can quarantine a valid snapshot and revert to the database it could not fully read.
  Completion preserves the snapshot only when `ComputeUTXOStats()` returns no result. The coins cursor does not expose `CDBIterator::HasError()`, so a LevelDB scan that skips records or stops early can still yield a successful hash of a partial set. That sends a local read failure down the `HASH_MISMATCH` path, which rejects the snapshot and shuts down. Propagate iterator status through the coins cursor and fail the stats scan before finalizing the hash. The malformed-coin test covers a `GetValue()` decode failure, not an iterator error.
- [SUGGESTION] src/validation.cpp:6641-6645: An overlapping snapshot load can undo the first load's state
  Impact: If two callers try to activate on-disk snapshots concurrently, the second can clear the first attempt's Evo state or request a shutdown when it cannot delete the open database.
  The initial `SnapshotBlockhash()` check only detects an installed chainstate. A second call can pass it while the first owns the snapshot LevelDB; when the second open fails, its catch block runs cleanup against the manager's shared capture plan and generation, then attempts to destroy the first call's still-locked directory. This head has no production caller of `ActivateSnapshot()`, so this is an API hazard rather than an exposed RPC race. Give the manager a single activation reservation under `cs_main` before resizing caches or opening the database, and release it on every exit.

In `src/node/chainstate.cpp`:
- [BLOCKING] src/node/chainstate.cpp:453-465: Coins left by an interrupted load can make a valid snapshot fail on retry
  Impact: An operator who restarts after an interrupted load can retain an unused coins database and then have a valid snapshot at a different authorized base rejected.
  Startup cleans up the Evo state but leaves the unmarked `chainstate_snapshot` database available for reuse. Before publication, startup collects the unpublished generation without leaving a rejected record; after publication but before the base-marker write, startup discards the markers only after the recovery pass that handles rejected directories. In either case, the next activation opens that same database with `should_wipe=false`. It writes the incoming coins but does not erase old outpoints absent from the new snapshot, such as coins spent between the two bases, so its UTXO hash can fail. Remove the abandoned directory once recovery has ruled out a live snapshot or promotion, or guarantee a fresh database for the next load. Extend `CrashDuringActivation` to check the directory and retry at a different authorized base.

In `test/sanitizer_suppressions/lsan`:
- [BLOCKING] test/sanitizer_suppressions/lsan:5-8: Failed database opens leak resources that the new LeakSanitizer rule hides
  Impact: The new failed-open test leaves three LevelDB option allocations unreleased, and the suppression also hides matching leaks from other database opens.
  `GetOptions()` allocates a block cache, filter policy, and logger before `DB::Open()`. The missing-manifest test makes the open fail, then `HandleError()` throws before `CDBWrapper` finishes construction. Only `~CDBWrapper()` deletes those objects; unwinding the context with its raw pointers does not. Give the context RAII ownership of the resources, remove `leak:GetOptions`, and keep the failed-open test.

In `src/evo/snapshot_chain.cpp`:
- [SUGGESTION] src/evo/snapshot_chain.cpp:1002-1004: The dry run accepts mined commitments that refer to members the seeded view cannot supply
  Impact: A pinned section with inconsistent historical membership can pass activation even though its seeded view cannot supply every member named by a carried commitment.
  `DryRunEvoSnapshot()` discards the member vector returned for each active or safety commitment, and a short or empty vector need not throw. Preflight checks the encoded bitset lengths, but not whether the set bits refer to computed members. Ordinary `CFinalCommitment::Verify()` rejects `validMembers` or `signers` bits beyond the computed vector. Reuse the non-signature membership checks for carried mined commitments without imposing that requirement on cycles with no mined commitment.

In `src/evo/creditpool.h`:
- [SUGGESTION] src/evo/creditpool.h:207-208: The credit-pool manager exposes a process-wide cache reset solely for one test fixture
  Impact: A simulated restart depends on a public production method to clear state that survives the manager being reconstructed.
  `ClearBlockDataCacheForTesting()` is called only by `DropEvoCaches()` in the chainstate-manager tests. It clears a function-static parsed-block cache, not an instance's cache. Tie the cache to the component the fixture reconstructs so a restart simulation naturally starts cold, or keep the reset in test-only access rather than making it part of the manager's public API.

In `src/warnings.cpp`:
- [SUGGESTION] src/warnings.cpp:37-51: The snapshot-publication commit also changes warning lifetime on nodes without a snapshot
  Impact: A maintainer tracing why a successful GUI read now clears a pruning warning cannot review or revert that behavior independently of snapshot publication.
  Commit `24c53dabe35` changes existing Evo warnings from a shared miscellaneous warning to per-operation warnings, clears them on a successful read, and changes when the GUI is notified. `evo_state_unavailable_is_contained` verifies the new behavior before it creates a snapshot generation. Split the warning storage, interface changes, and corresponding assertions into a prerequisite commit so the activation and completion commits can use the policy without burying the standalone behavior change.

Comment thread src/validation.cpp Outdated
Comment on lines 6775 to 6780
LogPrintf("[snapshot] successfully activated snapshot %s\n", base_blockhash.ToString());
LogPrintf("[snapshot] (%.2f MB)\n",
m_snapshot_chainstate->CoinsTip().DynamicMemoryUsage() / (1000 * 1000));

this->MaybeRebalanceCaches();
return true;

@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 17f8d275; see the replies below.

🔴 Blocking: Snapshot validation is skipped until restart when NORMAL reaches the base before the switch
Impact: A node that reaches the base during snapshot preparation can keep using snapshot state that disagrees with state it has already validated.

SnapshotSwitchRefusal() permits NORMAL's tip to equal the base, but activation then reports success without comparing the two states. The connect that reached the base ran while NORMAL was still active, so it skipped MaybeCompleteSnapshotValidation(). After the switch, newly arriving descendants are not eligible for background validation, so they do not trigger a retry. The switch-gap test reaches this case but calls Complete() itself. Run completion at the handoff when NORMAL is already at the base, handle the result before reporting success, and test that both a match and a disagreement are handled without an explicit completion call.

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

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.

Not changing this in #8272. Nothing at this head calls ActivateSnapshot() outside the unit tests; loadtxoutset arrives in #8078. #8078's bitcoin#27596 commit (457fdae, with upstream's "validation: do not activate snapshot if behind active chain") replaces this check with SnapshotActivationRefusal(). That function refuses the switch unless the base has more work than NORMAL's tip (SnapshotHasMoreWork()), and the base itself counts. So a node whose NORMAL chainstate reached the base while the snapshot was being prepared refuses the load. It never switches into a state where completion can only run at the next restart. The switch-gap test then hides the base tip at the switch (ActivateWithBaseHidden, the same change), as upstream's tests do. Running completion at the handoff would only serve the window between these two PRs, and that window has no caller.


🤖 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 17f8d275): The handoff gap is intentionally handled by the stacked activation-refusal change in #8078, which refuses a snapshot unless its base has more work than the active NORMAL tip and therefore prevents switching after NORMAL has already reached the base.

Comment thread src/validation.cpp
Comment on lines +6697 to 6702
// If not in-memory, persist the base blockhash for use during subsequent
// initialization.
if (!in_memory && !node::WriteSnapshotBaseBlockhash(*snapshot_chainstate)) {
cleanup();
return false;
}

@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 17f8d275; see the replies below.

🔴 Blocking: A crash after the snapshot base marker is synced can abort the next startup
Impact: A node loading a snapshot ahead of its downloaded block bodies can fail to restart if it stops after the base marker is synced but before the block index is flushed.

Startup can recognize a snapshot whose block index is not ready to use it. WriteSnapshotBaseBlockhash() syncs the marker before the loop that sets nTx and BLOCK_ASSUMED_VALID, and the index is flushed later. If the base header was already on disk but its block was not, startup reconstructs a zero nChainTx for the base. LoadBlockIndex() still admits the base as a background candidate, and FindMostWorkChain() asserts HaveTxsDownloaded() before checking for missing block data. Make recovery finish index preparation before candidate admission, or journal the handoff so this state cannot be resumed. The existing post-publication failpoint stops before the base-marker write and does not cover this window.

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

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.

Not changing this in #8272. Like the previous finding, it needs an ActivateSnapshot() caller, and there is none at this head. The window also predates this PR: before it, the transaction counts were faked in PopulateAndValidateSnapshot(), but they still reached disk only through the MaybeRebalanceCaches() flush after WriteSnapshotBaseBlockhash(), as in upstream v26.

#8078 closes it with the upstream changes it backports. bitcoin#27596 (457fdae, "populate nChainTx value for assumedvalid chainstates") makes BlockManager::LoadBlockIndex() set the base's nChainTx from the pin whenever a snapshot is detected, whatever the stored record says. FindMostWorkChain() then finds HaveNumChainTxs() true for a base without its body and drops the candidate as missing data. Further up the stack, bitcoin#29370 (aab46c0, in #8079) removes the faked nTx and BLOCK_ASSUMED_VALID. From then on the loop after the marker write only marks entries dirty and sets the unpersisted nChainTx, so a crash there leaves the on-disk index exactly as a completed activation would.


🤖 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 17f8d275): The crash window after the base marker is synced is intentionally handled by the stacked AssumeUTXO backports in #8078 and its related follow-up, which reconstruct the assumed chain transaction count and prevent an incomplete base from being admitted as usable.

Comment thread src/node/chainstate.cpp Resolved
Comment thread test/sanitizer_suppressions/lsan Resolved
Comment thread src/validation.cpp Outdated
Comment on lines 6641 to 6645
} catch (...) {
LOCK(::cs_main);
cleanup();
throw;
}

@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 17f8d275; see the replies below.

🟡 Suggestion: An overlapping snapshot load can undo the first load's state
Impact: If two callers try to activate on-disk snapshots concurrently, the second can clear the first attempt's Evo state or request a shutdown when it cannot delete the open database.

The initial SnapshotBlockhash() check only detects an installed chainstate. A second call can pass it while the first owns the snapshot LevelDB; when the second open fails, its catch block runs cleanup against the manager's shared capture plan and generation, then attempts to destroy the first call's still-locked directory. This head has no production caller of ActivateSnapshot(), so this is an API hazard rather than an exposed RPC race. Give the manager a single activation reservation under cs_main before resizing caches or opening the database, and release it on every exit.

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

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.

This is already handled further up the stack: #8273's 6b50ba7 (fix(validation): serialize snapshot activations) adds an activation reservation that the manager takes before resizing caches or opening the database and releases on every exit. A second caller is refused with "Another snapshot activation is in progress" before it touches the capture plan, the generation or the directory. As you note, nothing at this head calls ActivateSnapshot() outside the unit tests, loadtxoutset arrives in #8078, and the reservation follows in #8273, the PR stacked directly on it.


🤖 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 17f8d275): The overlapping activation hazard remains outside this head's implementation, but stacked follow-up #8273 adds the activation reservation before shared state or the snapshot directory is touched and releases it on every exit.

Comment thread src/evo/snapshot_chain.cpp Resolved
Comment thread src/evo/creditpool.h Resolved
Comment thread src/warnings.cpp Resolved
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

On the body-only finding (a background coins read error can make completion reject a good snapshot): fixed in 4f5041e. CCoinsViewCursor gains HasError(), and CCoinsViewDBCursor forwards CDBIterator::HasError(). ComputeUTXOStats() fails when the cursor reports a read error at the end of the scan. LevelDB keeps the first iterator error in its status, so a block it skipped cannot go unnoticed. Completion therefore takes the existing "UTXO set cannot be read" path: it stops the node, keeps the snapshot and advises -reindex-chainstate. It no longer reports HASH_MISMATCH. The evo comparison after the UTXO hash is unchanged.

chainstatemanager_evo_snapshot_completion_stops_on_local_failures gains a case next to the malformed-coin one. It compacts the background coins database, flips a byte in the table block that holds a coin from the middle of the set, and restarts. Startup must fail with the "not rejected" advice, with the snapshot directory in place and no _INVALID directory. It then restores the byte, and the node promotes the snapshot. Without the HasError() check the same restart rejects the snapshot.


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

@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 removed the pastaclaw:changes-requested thepastaclaw's latest review requested changes label Nov 28, 2026
@PastaPastaPasta
PastaPastaPasta force-pushed the feat/evo-snapshot-seed-verify branch from 4f5041e to 17f8d27 Compare November 28, 2026 07:21
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 seeds snapshots through an unpublished Evo generation and now rebuilds and compares the complete retained Evo section at validation completion, while also detecting LevelDB cursor read errors during UTXO hashing. ClangFormat, main, title validation, and other completed code checks pass; the review check remains in progress and the skip-condition check is queued, with no failed code checks reported.

🟡 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.

Still open from earlier rounds (3)

  • 🟡 Suggestion: The snapshot-publication commit also changes warning lifetime on nodes without a snapshot — src/warnings.cpp:37-51 (thread)
  • 🟡 Suggestion: The credit-pool manager exposes a process-wide cache reset solely for one test fixture — src/evo/creditpool.h:207-208 (thread)
  • 🟡 Suggestion: The dry run accepts mined commitments that refer to members the seeded view cannot supply — src/evo/snapshot_chain.cpp:1006-1017 (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, intricate AssumeUTXO/Evo snapshot validation change affecting chainstate initialization, persistence, and completion checks, but the diff does not directly 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 `src/warnings.cpp`:
- [SUGGESTION] src/warnings.cpp:37-51: The snapshot-publication commit also changes warning lifetime on nodes without a snapshot
  (carried; thread: https://github.com/dashpay/dash/pull/8272#discussion_r4724482996)

In `src/evo/creditpool.h`:
- [SUGGESTION] src/evo/creditpool.h:207-208: The credit-pool manager exposes a process-wide cache reset solely for one test fixture
  (carried; thread: https://github.com/dashpay/dash/pull/8272#discussion_r4724482992)

In `src/evo/snapshot_chain.cpp`:
- [SUGGESTION] src/evo/snapshot_chain.cpp:1006-1017: The dry run accepts mined commitments that refer to members the seeded view cannot supply
  (carried; thread: https://github.com/dashpay/dash/pull/8272#discussion_r4724482987)

Comment thread src/validation.cpp Outdated
Comment on lines 6775 to 6780
LogPrintf("[snapshot] successfully activated snapshot %s\n", base_blockhash.ToString());
LogPrintf("[snapshot] (%.2f MB)\n",
m_snapshot_chainstate->CoinsTip().DynamicMemoryUsage() / (1000 * 1000));

this->MaybeRebalanceCaches();
return true;

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 17f8d275): The handoff gap is intentionally handled by the stacked activation-refusal change in #8078, which refuses a snapshot unless its base has more work than the active NORMAL tip and therefore prevents switching after NORMAL has already reached the base.

Comment thread src/validation.cpp
Comment on lines +6697 to 6702
// If not in-memory, persist the base blockhash for use during subsequent
// initialization.
if (!in_memory && !node::WriteSnapshotBaseBlockhash(*snapshot_chainstate)) {
cleanup();
return false;
}

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 17f8d275): The crash window after the base marker is synced is intentionally handled by the stacked AssumeUTXO backports in #8078 and its related follow-up, which reconstruct the assumed chain transaction count and prevent an incomplete base from being admitted as usable.

Comment thread src/node/chainstate.cpp Resolved
Comment thread test/sanitizer_suppressions/lsan Resolved
Comment thread src/validation.cpp Outdated
Comment on lines 6641 to 6645
} catch (...) {
LOCK(::cs_main);
cleanup();
throw;
}

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 17f8d275): The overlapping activation hazard remains outside this head's implementation, but stacked follow-up #8273 adds the activation reservation before shared state or the snapshot directory is touched and releases it on every exit.

Comment thread src/evo/snapshot_chain.cpp Resolved
Comment thread src/evo/creditpool.h Resolved
Comment thread src/warnings.cpp Resolved
PastaPastaPasta added a commit that referenced this pull request Nov 29, 2026
…B generation

1370095 refactor(evo): check that tip-based Evo reads serve only the active chainstate (Konstantin Akimov)
fed70e8 feat(evo): store snapshot-identity state in a generation namespace with journaled promotion (pasta)
5bb5947 refactor(validation): reject the snapshot when its Evo state disagrees with derived state (pasta)
7736bbe refactor(validation): move the invalid-snapshot handler into a ChainstateManager method (pasta)
adf5ec4 feat(dbwrapper): report LevelDB iterator read errors (pasta)
0867b0c refactor(evo): add EvoDB view tokens (pasta)
c04d41b refactor(llmq): stop writing the unused q_bbu2 best-block key (pasta)

Pull request description:

  ## Issue being fixed or feature implemented

  While an AssumeUTXO snapshot chainstate and the background chainstate run together, both write Evo state (masternode lists, quorum commitments, the credit pool, EHF signals) into one EvoDB keyspace. State the snapshot chainstate writes can then be read by background validation, which can make it mark valid blocks invalid, and a rejected snapshot leaves its records behind.

  **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` (#8235 merged at `6dee23aa4f`; #8274's test fix and #8264 since), so #8237 is the bottom layer. The layers above still carry this PR's commits in their pre-squash form, with the same tree, until each is restacked.

  New on top of develop: the seven commits below. With no snapshot loaded it changes no behaviour, and no snapshot can be loaded before #8078.

  ## What was done?

  1. **`c04d41bdc7` refactor(llmq): stop writing the unused q_bbu2 best-block key.** `CQuorumBlockProcessor` wrote its last processed block to `q_bbu2` on every block; only `UpgradeDB()` read it, and that was removed in v20.1.
  2. **`0867b0cdf1` refactor(evo): add EvoDB view tokens.** An immutable token (EvoDB, identity, generation, base). `CEvoDB::CurrentView()` resolves it to the transaction the calling thread holds open, otherwise the default identity, which belongs to the active chainstate. `ViewFor()` names the view of a given chainstate. Nothing uses the tokens yet, so behaviour is unchanged.
  3. **`adf5ec4f13` feat(dbwrapper): report LevelDB iterator read errors.** LevelDB skips a table block that fails its checksum and reports the failure only through the iterator's status, so a walk that stops on `!Valid()` cannot tell the end of the data from records it never saw. `CDBIterator::HasError()` exposes that status.
  4. **`7736bbeb74` refactor(validation): move the invalid-snapshot handler into a ChainstateManager method.** A pure move, so the next commit can call it from the chainstate boundary.
  5. **`5bb5947148` refactor(validation): reject the snapshot when its Evo state disagrees with derived state.** `evo::SnapshotStateMismatchError` is Evo state a snapshot carries that disagrees with state this node derives itself. The chainstate boundary hands it to `ChainstateManager::HandleSnapshotStateMismatch`, which reverts to the background chainstate, discards the snapshot's EvoDB markers and shuts down, as a failed completion check does; completion now uses the same handler. `ConnectTip` rolls back the block's EvoDB transaction before it classifies the error, so a mismatch raised mid-connect can reject the snapshot. With no usable snapshot active, or with an EvoDB transaction still open, the block fails with the new `LocalEvoStateResult::MISMATCH` local error instead. A rejection raised while `ActivateBestChainStep` connects a block clears the disconnect pool of the transactions of the blocks it disconnected, as the rejected chainstate handed its mempool back. Nothing throws the new error until the next commit.
  6. **`fed70e8c00` feat(evo): store snapshot-identity state in a generation namespace with journaled promotion.**
     - Snapshot-chainstate writes go to a per-generation key prefix, with no read fallback to NORMAL.
     - Rejecting a snapshot marks its generation in the same synced batch that discards the markers; the generation is collected once the snapshot's coins directory has been set aside, so a crash in between still finishes at startup. An earlier `chainstate_snapshot_INVALID` directory is kept.
     - Promotion after background validation is a journaled merge that resumes after a crash at any phase; after a crash between the coins renames and the merge, startup checks the generation's base height against the block index first.
     - Seeded keys are recorded in a manifest and never copied into NORMAL, which derives that state itself; where both hold a key, the records must be equal or the promotion fails.
     - Promotion, collection and generation loading check the iterator status before each key and at the end, and stop with their journal and records in place.
     - Startup refuses, before changing anything on disk, a promotion journal without its matching record (and the reverse), a live generation without its dual-chainstate marker, a base height that differs from the block index, and a generation of another schema version.
     - A snapshot in progress from a datadir that predates this change is detected, and startup suggests `-reindex-chainstate`.
  7. **`1370095ea8` refactor(evo): check that tip-based Evo reads serve only the active chainstate** (knst). Adds `Assume(ReadsActiveView())` to the masternode list at the chain tip and to the mined-commitment lookup against the active chain. If a consensus path starts reading the tip again from inside another chainstate's transaction, debug and fuzz builds catch it.

  ## 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 same holds at every layer head from #8237 to #8272 and at #8078, and at the top of the stack the AssumeUTXO, InstantSend, ChainLock, pruning and invalidation functional tests pass.

  New tests are in `evo_db_tests` and `validation_chainstatemanager_tests`: rejection isolation with snapshot-written masternode-list, credit-pool and EHF records and NORMAL reconstruction after rejection and restart; promotion crash recovery at each phase, including an interrupt at every batch boundary; a promotion over a corrupt table block (refused, journal and generation kept); the startup refusals above; startup recovery of each interrupted directory rename, including a completed swap whose generation's base height disagrees with the block index (`chainstatemanager_snapshot_cleanup_recovers_completed_swap`).

  ## Breaking Changes

  None with a single chainstate. A datadir with a regtest snapshot chainstate in progress from before this change needs `-reindex-chainstate`.

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [x] I have added or updated relevant unit/integration/functional/e2e tests

  🤖 Generated with [Claude Code](https://claude.com/claude-code)

Top commit has no ACKs.

Tree-SHA512: 85df0ba826154ce7be2929dd114c3f087b6ab1ba7c6e4f6b436bf7db3abeea42a2f7b207fb1d17d501ae4dd24339f2ef54ef8fa61d5399c2aa07d0755aaf05fe
@PastaPastaPasta
PastaPastaPasta force-pushed the feat/evo-snapshot-seed-verify branch from 2eea065 to fe6542f Compare November 29, 2026 17:48
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

New on this head: This head adds the final activation-cleanup and completion-error-handling fixups while retaining the snapshot seeding, Evo-section rebuild, and per-view cache changes. CI has no reported failures: lint, cppcheck, formatting, and policy checks pass, while the Linux build, ASan build, and cache checks remain in progress.

🟡 4 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.

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

🟡 Suggestion: Twelve explicit fixup commits leave incomplete changes in permanent history
Impact: Maintainers reviewing or bisecting the merged stack must reconstruct feature changes from 37 explicit fixup or amend commits, making regressions and ownership boundaries harder to identify.
<commit:c5468d77b>:1

The rebased history still contains explicit correction commits, including the completion fixups 16242e328cb and fe6542f3001, alongside 37 fixup!/amend! commits in the 54-commit stack. These commits only complete changes introduced earlier in the same PR and have no durable meaning as independent history. Autosquash them into their target commits before merging so each substantive snapshot-validation change is self-contained and bisectable.

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

🟡 Suggestion: Twelve explicit fixup commits leave incomplete changes in permanent history
Impact: Readers tracing the Evo view and generation work must reconstruct logical changes from numerous correction commits instead of seeing independently meaningful implementation steps.
<commit:c34a79d>:1

The current stack still preserves explicit fixups in the Evo-view and generation work, including 1e77b70f864, 70372747cdf, b581b6a4558, and 0acbc8b1dfc. The full PR contains 37 such fixup or amend commits, so blame and bisect results continue to point at intermediate review states. Fold these corrections into their respective substantive commits before merging.

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

🟡 Suggestion: Activation-cleanup corrections remain separate from the seeding feature commit
Impact: Readers of the permanent history must reconstruct activation cleanup behavior from later fixups rather than from the seeding commit that introduces it.
<commit:0732efb1f06>:1

The activation-cleanup corrections remain separate fixups, notably b62c66d8e3d and 853a90db73e, both targeting feat(validation): seed into an unpublished generation, dry-run, then publish. Squash them into 28697fa7f5b so the seeding commit contains the complete failure-cleanup behavior and can be reviewed or reverted as one logical unit.

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

🟡 Suggestion: Completion-validation corrections remain separate from the Evo comparison feature commit
Impact: The permanent history presents completion validation through a chain of correction commits instead of one coherent implementation and regression story.
<commit:dc39d0e945a>:1

The completion corrections remain separate fixups, notably 16242e328cb and the current tip fe6542f3001, both targeting feat(validation): rebuild and compare the full evo section at completion. These changes correct the feature introduced by 5e06bd40cb0; autosquash them into that feature commit before merging so its validation and failure-classification behavior is self-contained.

source: 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, intricate cross-cutting validation and snapshot-state change, but the described diff does not directly 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 `<commit:c5468d77b>`:
- [SUGGESTION] <commit:c5468d77b>:1: Twelve explicit fixup commits leave incomplete changes in permanent history
  Impact: Maintainers reviewing or bisecting the merged stack must reconstruct feature changes from 37 explicit fixup or amend commits, making regressions and ownership boundaries harder to identify.
  The rebased history still contains explicit correction commits, including the completion fixups `16242e328cb` and `fe6542f3001`, alongside 37 `fixup!`/`amend!` commits in the 54-commit stack. These commits only complete changes introduced earlier in the same PR and have no durable meaning as independent history. Autosquash them into their target commits before merging so each substantive snapshot-validation change is self-contained and bisectable.

In `<commit:c34a79d>`:
- [SUGGESTION] <commit:c34a79d>:1: Twelve explicit fixup commits leave incomplete changes in permanent history
  Impact: Readers tracing the Evo view and generation work must reconstruct logical changes from numerous correction commits instead of seeing independently meaningful implementation steps.
  The current stack still preserves explicit fixups in the Evo-view and generation work, including `1e77b70f864`, `70372747cdf`, `b581b6a4558`, and `0acbc8b1dfc`. The full PR contains 37 such fixup or amend commits, so blame and bisect results continue to point at intermediate review states. Fold these corrections into their respective substantive commits before merging.

In `<commit:0732efb1f06>`:
- [SUGGESTION] <commit:0732efb1f06>:1: Activation-cleanup corrections remain separate from the seeding feature commit
  Impact: Readers of the permanent history must reconstruct activation cleanup behavior from later fixups rather than from the seeding commit that introduces it.
  The activation-cleanup corrections remain separate fixups, notably `b62c66d8e3d` and `853a90db73e`, both targeting `feat(validation): seed into an unpublished generation, dry-run, then publish`. Squash them into `28697fa7f5b` so the seeding commit contains the complete failure-cleanup behavior and can be reviewed or reverted as one logical unit.

In `<commit:dc39d0e945a>`:
- [SUGGESTION] <commit:dc39d0e945a>:1: Completion-validation corrections remain separate from the Evo comparison feature commit
  Impact: The permanent history presents completion validation through a chain of correction commits instead of one coherent implementation and regression story.
  The completion corrections remain separate fixups, notably `16242e328cb` and the current tip `fe6542f3001`, both targeting `feat(validation): rebuild and compare the full evo section at completion`. These changes correct the feature introduced by `5e06bd40cb0`; autosquash them into that feature commit before merging so its validation and failure-classification behavior is self-contained.

Comment thread src/evo/specialtxman.cpp Resolved
@thepastaclaw thepastaclaw added the pastaclaw:approved thepastaclaw's latest review approved this PR label Nov 29, 2026
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

New on this head: This head adds the final activation-cleanup, completion-error handling, and restart-cache test fixes to the unpublished-generation seeding and Evo-section completion work. ClangFormat and policy checks pass, while the dependency/container build jobs and review check remain queued; no local build or tests were run in this static review.

🟡 4 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.

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

🟡 Suggestion: Completion-validation corrections remain separate from the Evo comparison feature commit
Impact: Maintainers bisecting or reverting the completion feature must combine its initial implementation with a later commit to obtain the actual retained-section and local-error behavior.
<commit:12ce91ec955>:1

The completion feature still lands before the corrections that define its final behavior. 12ce91ec955 adds the pinned-base retained-section requirement, retained-section read-error classification, and ordering of the EvoDB marker checks, but remains separate from 6eb6e6cb23c; fold those changes and their regression coverage into the owning completion commit before merging.

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

🟡 Suggestion: Activation-cleanup corrections remain separate from the seeding feature commit
Impact: Checking out the seeding feature commit alone exposes rollback paths that do not yet handle throwing EvoDB writes and can leave cleanup behavior incomplete.
<commit:d5cf7b51fe6>:1

The seeding feature and its final failure handling are still split. d5cf7b51fe6 adds the exception-safe generation rollback, capture cleanup, and completion-sync handling, but remains separate from c8b2f6939cf; fold these corrections and their regression coverage into the seeding commit so the feature commit contains the cleanup guarantees it describes.

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

🟡 Suggestion: Twelve explicit fixup commits leave incomplete changes in permanent history
Impact: The current layer still leaves intermediate revisions between the feature commits and their corrections that cannot be built or do not describe the implementation that will land.
<commit:7ee8a15b7b3>:1

Although the historical count in the title no longer describes this restack, the current layer still has five explicit fixups, including the view-binding correction in 7ee8a15b7b3 and the restart/cache corrections in 5fc7c395c7a and 25c57c86ada. In particular, the trees of c8b2f6939cf and 6eb6e6cb23c use EvoViewScope without declaring that type, and the later fixups remove those uses. Fold each correction into its owning feature commit and update the messages so the permanent history remains buildable and self-describing.

source: 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, intricate cross-cutting change to snapshot loading, chainstate validation, EvoDB storage, and startup/completion behavior, but the diff does not clearly modify one of the specified critical surfaces such as 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 `<commit:12ce91ec955>`:
- [SUGGESTION] <commit:12ce91ec955>:1: Completion-validation corrections remain separate from the Evo comparison feature commit
  Impact: Maintainers bisecting or reverting the completion feature must combine its initial implementation with a later commit to obtain the actual retained-section and local-error behavior.
  The completion feature still lands before the corrections that define its final behavior. `12ce91ec955` adds the pinned-base retained-section requirement, retained-section read-error classification, and ordering of the EvoDB marker checks, but remains separate from `6eb6e6cb23c`; fold those changes and their regression coverage into the owning completion commit before merging.

In `<commit:d5cf7b51fe6>`:
- [SUGGESTION] <commit:d5cf7b51fe6>:1: Activation-cleanup corrections remain separate from the seeding feature commit
  Impact: Checking out the seeding feature commit alone exposes rollback paths that do not yet handle throwing EvoDB writes and can leave cleanup behavior incomplete.
  The seeding feature and its final failure handling are still split. `d5cf7b51fe6` adds the exception-safe generation rollback, capture cleanup, and completion-sync handling, but remains separate from `c8b2f6939cf`; fold these corrections and their regression coverage into the seeding commit so the feature commit contains the cleanup guarantees it describes.

In `<commit:7ee8a15b7b3>`:
- [SUGGESTION] <commit:7ee8a15b7b3>:1: Twelve explicit fixup commits leave incomplete changes in permanent history
  Impact: The current layer still leaves intermediate revisions between the feature commits and their corrections that cannot be built or do not describe the implementation that will land.
  Although the historical count in the title no longer describes this restack, the current layer still has five explicit fixups, including the view-binding correction in `7ee8a15b7b3` and the restart/cache corrections in `5fc7c395c7a` and `25c57c86ada`. In particular, the trees of `c8b2f6939cf` and `6eb6e6cb23c` use `EvoViewScope` without declaring that type, and the later fixups remove those uses. Fold each correction into its owning feature commit and update the messages so the permanent history remains buildable and self-describing.

In `src/evo/creditpool.cpp`:
- [SUGGESTION] src/evo/creditpool.cpp:168-181: A warm NORMAL cache can hide the credit pool carried by the snapshot
  Impact: During dual-chain operation, a snapshot block can use NORMAL's base credit pool and therefore validate asset-unlock limits or mined-index checks against state different from the pool carried by the loaded snapshot.
  The shared-cache rewrite makes `GetFromCache()` consult the process-wide pool before reading the snapshot seed. `SeedSnapshot()` erases the base entry, but if the background NORMAL chainstate reaches the base after activation it can reconstruct and repopulate that same hash through `MaybeCache()`. A subsequent SNAPSHOT lookup then returns NORMAL's pool without reading `DB_CREDITPOOL_SNAPSHOT`; if the carried indexes or limits differ, snapshot-side validation depends on scheduling and may process the first descendants using the wrong state. Completion can reject the section later, but it does not undo the earlier view contamination. Keep computed pools qualified by Evo view, or otherwise prevent a NORMAL-derived entry from satisfying a SNAPSHOT lookup; the separately parsed block-body cache can remain shared.

Comment thread src/evo/creditpool.cpp Resolved
@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

thepastaclaw
thepastaclaw previously approved these changes Nov 30, 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

New on this head: This head seeds Evo state into an unpublished generation, validates it before publication, and rebuilds the retained Evo section during completion. The reported CI checks for main and ClangFormat are successful; the skip-condition check remains queued, with no failed code checks shown.

🟡 6 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.

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

🟡 Suggestion: Twelve explicit fixup commits leave incomplete changes in permanent history
Impact: Anyone using git blame or bisect on the Evo and snapshot-validation code will encounter numerous intermediate review states instead of self-contained commits that introduced the finished behavior.
<commit:7ee8a15b7b3>:1

The current stack still preserves 45 explicit fixup! or amend! commits, including the seeding and completion corrections at cdc00d8bfb8, 7a83b1d71b3, c1d78822cde, and 8e526bf8da7. Because this project retains PR commits in permanent history, these review-only patches make historical inspection and bisecting land on incomplete implementations. Autosquash each correction into its substantive target before merging.

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

🟡 Suggestion: Activation-cleanup corrections remain separate from the seeding feature commit
Impact: The permanent history presents snapshot activation cleanup as an intermediate implementation followed by separate corrections rather than one coherent seeding change.
<commit:d5cf7b51fe6>:1

The seeding feature remains followed by the explicit fixups cdc00d8bfb8 and c1d78822cde, which modify the unpublished-generation rollback, exception handling, and related tests. These corrections are required for the feature's failure behavior, so fold them into the seeding commit before the stack lands.

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

🟡 Suggestion: Completion-validation corrections remain separate from the Evo comparison feature commit
Impact: Future readers and bisect users see completion validation introduced in an intermediate form and corrected only by later review patches.
<commit:12ce91ec955>:1

The completion feature remains followed by the separate 7a83b1d71b3 and 8e526bf8da7 fixups, which change production validation and regression tests for the retained-section rebuild and its failure handling. Fold these corrections into the completion feature commit so it describes the complete behavior.

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

🟡 Suggestion: Completion-validation corrections remain separate from the Evo comparison feature commit
Impact: The final Evo comparison behavior remains split across a feature commit and later review patches, weakening blame and bisect results around snapshot completion.
<commit:dc39d0e945a>:1

Although the earlier fixup identity was rewritten, the same correction remains as the substantial 8e526bf8da7 completion fixup. It changes retained-section classification, pinned-base handling, marker ordering, and comparison-path behavior, so it should be folded into the substantive completion commit rather than retained as review chronology.

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

🟡 Suggestion: Activation-cleanup corrections remain separate from the seeding feature commit
Impact: The seeding history leaves exception-safe resource cleanup attached to a separate review fixup instead of the commit that introduced activation publication.
<commit:0732efb1f06>:1

The current seeding tail still retains c1d78822cde as an explicit fixup. Its changes are required to continue cleanup and revoke unusable generations after a failed EvoDB write, so fold them into the substantive seeding commit rather than preserving an incomplete intermediate implementation.

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

🟡 Suggestion: Twelve explicit fixup commits leave incomplete changes in permanent history
Impact: Permanent history remains noisy across the Evo and snapshot-validation work, making later diagnosis through blame or bisect dependent on transient review states.
<commit:c5468d77b>:1

The current branch still contains the broad class of history defect represented by this finding: 45 explicit fixup or amend commits remain across the Evo, LLMQ, and snapshot-validation changes. Fold each correction into its target substantive commit before the no-squash merge.

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

Follow-up candidates (optional) (1)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: AbandonSnapshotGeneration erases live rejection markers after a revoked generation
Impact: If a snapshot rejection write fails and another activation attempt occurs before restart, the next startup can find a live generation without its dual-chainstate marker and require -reindex-chainstate.
src/evo/evodb.cpp:595-597

A failed DiscardSnapshotMarkers() or activation rollback can leave a published generation on disk while RevokeSnapshotGeneration() unbinds it and preserves its lifecycle markers for startup recovery. A subsequent activation attempt is rejected because m_revoked_generation is set, but its cleanup still calls AbandonSnapshotGeneration() with no bound generation; DiscardBoundGeneration() then erases EVODB_DUAL_CHAINSTATE and the other lifecycle markers. Startup can therefore find the live generation but refuse recovery because its dual-chainstate marker is missing. Return successfully from AbandonSnapshotGeneration() when no generation is bound, leaving the revoked generation's markers intact.

bool CEvoDB::AbandonSnapshotGeneration()
{
    AssertLockHeld(::cs_main);
    LOCK(cs);
    if (!Assume(!active_transaction.has_value())) return false;
    if (!m_snapshot_generation) return true;
    ClearSnapshotTransactions();
    return DiscardBoundGeneration();
}

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 and intricate validation, snapshot, EvoDB, chainstate, and storage-behavior change, but it does not itself modify 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)
  • New since the last final review (25c57c86): 1 suggestion(s) on unchanged code listed as follow-up candidates; 1 finding(s) judged fixed earlier and raised again on unchanged lines kept settled
  • 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:7ee8a15b7b3>`:
- [SUGGESTION] <commit:7ee8a15b7b3>:1: Twelve explicit fixup commits leave incomplete changes in permanent history
  Impact: Anyone using git blame or bisect on the Evo and snapshot-validation code will encounter numerous intermediate review states instead of self-contained commits that introduced the finished behavior.
  The current stack still preserves 45 explicit `fixup!` or `amend!` commits, including the seeding and completion corrections at `cdc00d8bfb8`, `7a83b1d71b3`, `c1d78822cde`, and `8e526bf8da7`. Because this project retains PR commits in permanent history, these review-only patches make historical inspection and bisecting land on incomplete implementations. Autosquash each correction into its substantive target before merging.

In `<commit:d5cf7b51fe6>`:
- [SUGGESTION] <commit:d5cf7b51fe6>:1: Activation-cleanup corrections remain separate from the seeding feature commit
  Impact: The permanent history presents snapshot activation cleanup as an intermediate implementation followed by separate corrections rather than one coherent seeding change.
  The seeding feature remains followed by the explicit fixups `cdc00d8bfb8` and `c1d78822cde`, which modify the unpublished-generation rollback, exception handling, and related tests. These corrections are required for the feature's failure behavior, so fold them into the seeding commit before the stack lands.

In `<commit:12ce91ec955>`:
- [SUGGESTION] <commit:12ce91ec955>:1: Completion-validation corrections remain separate from the Evo comparison feature commit
  Impact: Future readers and bisect users see completion validation introduced in an intermediate form and corrected only by later review patches.
  The completion feature remains followed by the separate `7a83b1d71b3` and `8e526bf8da7` fixups, which change production validation and regression tests for the retained-section rebuild and its failure handling. Fold these corrections into the completion feature commit so it describes the complete behavior.

In `<commit:dc39d0e945a>`:
- [SUGGESTION] <commit:dc39d0e945a>:1: Completion-validation corrections remain separate from the Evo comparison feature commit
  Impact: The final Evo comparison behavior remains split across a feature commit and later review patches, weakening blame and bisect results around snapshot completion.
  Although the earlier fixup identity was rewritten, the same correction remains as the substantial `8e526bf8da7` completion fixup. It changes retained-section classification, pinned-base handling, marker ordering, and comparison-path behavior, so it should be folded into the substantive completion commit rather than retained as review chronology.

In `<commit:0732efb1f06>`:
- [SUGGESTION] <commit:0732efb1f06>:1: Activation-cleanup corrections remain separate from the seeding feature commit
  Impact: The seeding history leaves exception-safe resource cleanup attached to a separate review fixup instead of the commit that introduced activation publication.
  The current seeding tail still retains `c1d78822cde` as an explicit fixup. Its changes are required to continue cleanup and revoke unusable generations after a failed EvoDB write, so fold them into the substantive seeding commit rather than preserving an incomplete intermediate implementation.

In `<commit:c5468d77b>`:
- [SUGGESTION] <commit:c5468d77b>:1: Twelve explicit fixup commits leave incomplete changes in permanent history
  Impact: Permanent history remains noisy across the Evo and snapshot-validation work, making later diagnosis through blame or bisect dependent on transient review states.
  The current branch still contains the broad class of history defect represented by this finding: 45 explicit fixup or amend commits remain across the Evo, LLMQ, and snapshot-validation changes. Fold each correction into its target substantive commit before the no-squash merge.

Comment thread src/evo/creditpool.cpp Resolved
@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

thepastaclaw
thepastaclaw previously approved these changes Nov 30, 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

New on this head: This head adds the final activation-cleanup and completion-validation corrections, including handling EvoDB write failures, pinned retained sections, local read failures, and marker ordering. ClangFormat and policy checks pass; container build jobs remain queued and the review check is still in progress, with no failed code check reported.

🟡 6 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.

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

🟡 Suggestion: Twelve explicit fixup commits leave incomplete changes in permanent history
Impact: The permanent PR history leaves reviewers and future bisects on intermediate AssumeUTXO and Evo states rather than on complete logical changes.
<commit:c5468d77b>:1

The current range still contains 45 fixup! or amend! commits among 62 PR commits, including the latest activation and completion corrections. These commits repair feature commits before they have shipped and do not represent useful independent historical states. Autosquash the corrections into their substantive commits before merging.

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

🟡 Suggestion: Activation-cleanup corrections remain separate from the seeding feature commit
Impact: The seeding feature's complete cleanup behavior is split across review-only commits, so blame and bisect identify an incomplete activation implementation first.
<commit:0732efb1f06>:1

The activation-cleanup corrections remain in b4330b6b55d and 9cbe438a745 rather than in the seeding commit 84521b98401. The throwing-Abandon handling, revocation, directory cleanup, and related logging are corrections to that feature and have no durable meaning as separate release history. Fold them into the seeding commit before merge.

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

🟡 Suggestion: Completion-validation corrections remain separate from the Evo comparison feature commit
Impact: The completion feature appears incomplete until later fixups add its local-corruption handling and ordering guarantees.
<commit:dc39d0e945a>:1

The completion corrections remain in 918f649f2cd and 2bf15411297 after b82106546a3. The pinned-base gate, retained-section read classification, marker ordering, and capture-plan exception handling all repair the same completion feature and should be folded into its substantive commit so the history presents one complete validation policy.

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

🟡 Suggestion: Completion-validation corrections remain separate from the Evo comparison feature commit
Impact: The permanent history continues to expose a review-stage completion implementation that was immediately superseded by later corrections.
<commit:12ce91ec955>:1

The retained-section, marker-ordering, and error-handling changes are still represented by standalone fixups after b82106546a3, specifically 918f649f2cd and 2bf15411297. This is the same artificial seam identified previously; fold both corrections into the completion feature commit before merging.

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

🟡 Suggestion: Activation-cleanup corrections remain separate from the seeding feature commit
Impact: Blame and bisect on the seeding path first expose activation cleanup without the fixes required for failed EvoDB writes and generation revocation.
<commit:d5cf7b51fe6>:1

The current stack still keeps the activation cleanup in the standalone b4330b6b55d fixup after 84521b98401, with the related follow-up in 9cbe438a745. These changes belong to the seeding feature and should be incorporated into its substantive commit before merging.

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

🟡 Suggestion: Twelve explicit fixup commits leave incomplete changes in permanent history
Impact: The full AssumeUTXO stack remains difficult to audit and bisect because dozens of review-stage corrections would become permanent commits.
<commit:7ee8a15b7b3>:1

An independent count of the current PR range still finds 45 explicit fixup! or amend! commits among 62 commits, including the four late corrections for seeding and completion. Autosquash the full stack so each substantive commit contains its final behavior rather than preserving intermediate review states.

source: muse-spark-1.3-contributor (phase1-reviewer: general); 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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: 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) — The large diff changes consensus-adjacent Evo snapshot validation and persistent chainstate/EvoDB publication and rebuild logic in src/evo/snapshot_chain.cpp, src/evo/evodb.cpp, and validation.cpp, including storage-state transitions whose correctness affects accepted snapshot 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)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • New since the last final review (8e526bf8): 1 follow-up candidate(s) already listed by an earlier review, not repeated; 1 finding(s) judged fixed earlier and raised again on unchanged lines kept settled
  • 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 `<commit:c5468d77b>`:
- [SUGGESTION] <commit:c5468d77b>:1: Twelve explicit fixup commits leave incomplete changes in permanent history
  Impact: The permanent PR history leaves reviewers and future bisects on intermediate AssumeUTXO and Evo states rather than on complete logical changes.
  The current range still contains 45 `fixup!` or `amend!` commits among 62 PR commits, including the latest activation and completion corrections. These commits repair feature commits before they have shipped and do not represent useful independent historical states. Autosquash the corrections into their substantive commits before merging.

In `<commit:0732efb1f06>`:
- [SUGGESTION] <commit:0732efb1f06>:1: Activation-cleanup corrections remain separate from the seeding feature commit
  Impact: The seeding feature's complete cleanup behavior is split across review-only commits, so blame and bisect identify an incomplete activation implementation first.
  The activation-cleanup corrections remain in `b4330b6b55d` and `9cbe438a745` rather than in the seeding commit `84521b98401`. The throwing-Abandon handling, revocation, directory cleanup, and related logging are corrections to that feature and have no durable meaning as separate release history. Fold them into the seeding commit before merge.

In `<commit:dc39d0e945a>`:
- [SUGGESTION] <commit:dc39d0e945a>:1: Completion-validation corrections remain separate from the Evo comparison feature commit
  Impact: The completion feature appears incomplete until later fixups add its local-corruption handling and ordering guarantees.
  The completion corrections remain in `918f649f2cd` and `2bf15411297` after `b82106546a3`. The pinned-base gate, retained-section read classification, marker ordering, and capture-plan exception handling all repair the same completion feature and should be folded into its substantive commit so the history presents one complete validation policy.

In `<commit:12ce91ec955>`:
- [SUGGESTION] <commit:12ce91ec955>:1: Completion-validation corrections remain separate from the Evo comparison feature commit
  Impact: The permanent history continues to expose a review-stage completion implementation that was immediately superseded by later corrections.
  The retained-section, marker-ordering, and error-handling changes are still represented by standalone fixups after `b82106546a3`, specifically `918f649f2cd` and `2bf15411297`. This is the same artificial seam identified previously; fold both corrections into the completion feature commit before merging.

In `<commit:d5cf7b51fe6>`:
- [SUGGESTION] <commit:d5cf7b51fe6>:1: Activation-cleanup corrections remain separate from the seeding feature commit
  Impact: Blame and bisect on the seeding path first expose activation cleanup without the fixes required for failed EvoDB writes and generation revocation.
  The current stack still keeps the activation cleanup in the standalone `b4330b6b55d` fixup after `84521b98401`, with the related follow-up in `9cbe438a745`. These changes belong to the seeding feature and should be incorporated into its substantive commit before merging.

In `<commit:7ee8a15b7b3>`:
- [SUGGESTION] <commit:7ee8a15b7b3>:1: Twelve explicit fixup commits leave incomplete changes in permanent history
  Impact: The full AssumeUTXO stack remains difficult to audit and bisect because dozens of review-stage corrections would become permanent commits.
  An independent count of the current PR range still finds 45 explicit `fixup!` or `amend!` commits among 62 commits, including the four late corrections for seeding and completion. Autosquash the full stack so each substantive commit contains its final behavior rather than preserving intermediate review states.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

@knst

knst commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

knst force-pushed the feat/evo-snapshot-seed-verify branch from 2bf1541 to 1342af9 now

This force-push moves the PR onto the new #7601 (develop with #8286, #7593 and #8271 merged). The two feature commits of the previous head 2bf1541129 are re-implemented on per-chainstate Evo state, and one small fix is added between them.

Where each commit of the previous head went

Commit in the previous head Commit in this push
feat(validation): seed into an unpublished generation, dry-run, then publish feat(validation): seed the evo section into the snapshot chainstate
feat(validation): rebuild and compare the full evo section at completion same subject
— fix(validation): keep the validated chainstate's block candidates when a snapshot is rejected (new)

The four fixups of the previous head are not carried as commits; what they fixed is listed under "Not carried" where it does not exist here.

Reading the range-diff. git range-diff c42534b34a..2bf1541129 <#7601 head>..<this head> pairs nothing: the code is too different. The PR's own diff is +298/−97 in 8 files, was +3827/−278 in 24; there are 3 commits on #7601 instead of 6.

Unchanged. The order at load: pin check, seed, chain preflight (PreflightEvoSnapshot()), dry run (DryRunEvoSnapshot()), then activation. Completion rebuilds the whole section from the background chainstate with BuildEvoSnapshot() and compares its hash with the pin. The outcomes EVO_STATE_MISMATCH, EVO_DATA_UNAVAILABLE, EVO_LOCAL_FAILURE and EVO_INTERNAL_ERROR, the completion_failure classification of a failed rebuild into them (EvoSectionFailure), SnapshotCompletionStopMessage() and its use at startup, taken from the previous head without the warning calls. An EvoDB best block that does not match its coins tip is a local failure, not a rejection.

Different on purpose

  • No generation, no publication. The section is seeded into the snapshot chainstate's own EvoDB, which lives in its own directory. A load that fails, and a snapshot that is rejected, drop that EvoDB; nothing has to be published, revoked or collected. The generation markers, the configuration fingerprint and the publish step do not exist.
  • No retained section and no captures. Completion compares the rebuilt section's hash with the pinned hash, which the seeded section matched at load, so the section is not kept in the EvoDB (assumeutxo_evo_section) and is not re-read. The background chainstate derives its state from the blocks it connects, so there is no capture plan (assumeutxo_capture) for block bodies.
  • The masternode list comparison at completion is removed in the seeding commit, because a seeded list is numbered differently from a derived one. Between the first and the third commit a DIP3-active snapshot is still never validated (the gate of feat: emit the v4 evo snapshot section and require a matching evo pin #7601).
  • Candidates fix (new commit). After a rejection the background chainstate becomes active with candidates that held only the base and its ancestors, and CheckBlockIndex() aborted. Bitcoin Core has the same behaviour, so it is fixed here rather than backported.

Not carried

  • CCoinsViewCursor::HasError() and its check in ComputeUTXOStats() (a coins read error stopping the node instead of rejecting a good snapshot). It is independent of the Evo design and can come as its own PR.
  • LevelDBContext owning what a failed open allocated, and the removal of the leak:GetOptions LeakSanitizer suppression. Also independent.
  • Startup removing a snapshot coins directory left by a load that crashed before recording its base.
  • kernel::Notifications::evoStateWarningChanged(), SetEvoStateWarning() and the per-operation warnings in node/interfaces.cpp, with their checks in interfaces_tests and wallet_tests.
  • ClearBlockDataCacheForTesting() and the other test-only hooks.

Tests. The previous head added 42 unit test cases to validation_chainstatemanager_tests (about 2,470 lines); this push adds 2 and extends 1.

  • chainstatemanager_evo_snapshot_cold_load covers what chainstatemanager_evo_snapshot_cold_node, ..._bootstraps_the_next_cycle and ..._honest_completion covered on the same fixture: load on a node with only headers, mine past the next cycle from carried state, complete in the background, promote at restart.
  • chainstatemanager_evo_snapshot_completion_rejects_a_lying_section corresponds to ..._completion_rebuild_current_limit.
  • Not carried: the crash-during-activation, publication, switch, capture and generation cases, which test machinery that does not exist here; the other completion_rebuild_* substitutions (indexes, signal, quarter, credit history, safety commitments); ..._completion_stops_on_local_failures; and every case on EvoQuorumSnapshotTestSetup (real DKG quorums). Snapshots with real quorums are covered by the functional test feature_assumeutxo_dash.py once loadtxoutset can load them, later in the stack.

@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

Changes requested: 1 blocker

  • A background coins read error can make completion reject a good snapshot — src/validation.cpp:7434-7455 (carried; accepted as a deferral; lifts when a tracking issue is linked on its thread)

New on this head: This rewrite seeds the pinned Evo section into the snapshot chainstate’s own database, restores block candidates when a snapshot is rejected, and rebuilds the full Evo section from background validation before promotion. GitHub’s reported source builds, tests, and lint checks passed; only the review check was pending.

🔴 1 blocking | 🟡 6 suggestion(s)

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

🟡 Suggestion: Pruning after successful validation can prevent snapshot promotion on restart
Impact: A pruned node can finish background validation but return to dual-chainstate mode on restart if pruning removes a block needed to repeat the comparison.
src/validation.cpp:6964-6987

Runtime completion only marks the background chainstate disabled in memory. Startup recomputes completion before promoting, and the rewrite removed the captured inputs that let the rebuild survive pruning. Once the file containing the base block is outside the active chainstate’s retention window, pruning can remove it; no snapshot-completion prune lock protects it. The next rebuild returns EVO_DATA_UNAVAILABLE, and LoadChainstate() skips promotion. Protect the required inputs until promotion, or persist the successful comparison bound to the snapshot base and accepted pin.

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

🟡 Suggestion: Coins left by an interrupted load can make a valid snapshot fail on retry
Impact: A caller retrying at a different authorized base after an interrupted on-disk load can have a valid snapshot refused because the import reuses old coins.
src/validation.cpp:6344-6349

The rewrite drops the startup cleanup for an unmarked snapshot coins directory. Activation flushes coins before writing base_blockhash; if it stops in between, DetectSnapshotChainstate() ignores the directory and leaves it in place. The next activation wipes the snapshot EvoDB but opens the coins DB with should_wipe=false. Inserting the next snapshot’s coins does not erase old outpoints spent between the two bases, so a valid file can fail its UTXO hash check. Remove the abandoned coins directory after recovery rules out a live snapshot, or ensure a new on-disk activation opens a fresh coins database once it owns the directory. This head has no production caller for new snapshot activation.

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

🔴 Blocking: A background coins read error can make completion reject a good snapshot
src/validation.cpp:7434-7455

Completion preserves the snapshot only when ComputeUTXOStats() returns no result. The coins cursor does not expose CDBIterator::HasError(), so a LevelDB scan that skips records or stops early can still yield a successful hash of a partial set. That sends a local read failure down the HASH_MISMATCH path, which rejects the snapshot and shuts down. Propagate iterator status through the coins cursor and fail the stats scan before finalizing the hash. The malformed-coin test covers a GetValue() decode failure, not an iterator error.

Judged fixed at 2bf15411; raised again and confirmed by an independent pass: A C++ caller loads a valid pinned snapshot on disk through ChainstateManager::ActivateSnapshot() and lets background validation reach its base. If a disk read or checksum error makes LevelDB skip a table block containing live coins, ComputeUTXOStats() returns a successful hash of the incomplete set. Completion treats that hash as HASH_MISMATCH, quarantines the good snapshot, and shuts down, losing the ability to resume from the snapshot tip.

source: prior finding (deferral not tracked)

⏸️ Awaiting tracking link (1): A background coins read error can make completion reject a good snapshot. Link an issue on its thread, or ask there and PastaClaw files it.

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 validation and chainstate change, but it does not itself modify consensus rules, funds movement, cryptography, peer-facing deserialization, or storage migrations as defined for the critical tier.
  • 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)
  • New since the last final review (2bf15411): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed
  • 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:6931-6935: Changing the Evo pin before restart can promote state seeded under the old pin
  Impact: A regtest operator who corrects an Evo pin after loading a snapshot can promote seeded records that background validation never confirmed.
  Completion can verify one Evo section and promote another. Activation checks the section against the configured pin, but the rewrite removed the retained section and startup only restores the snapshot’s base block hash. If an operator loads a section whose credit-pool limit differs from the chain’s, then corrects only the Evo pin before restarting, the honest rebuild matches the new pin. `ValidatedSnapshotCleanup()` then copies the EvoDB seeded under the old pin. Persist the accepted Evo hash alongside the snapshot base and verify that binding before resuming or promoting the snapshot.
- [SUGGESTION] src/validation.cpp:6661-6689: A refused Evo snapshot load leaves headers marked as processed
  Impact: A caller loading a snapshot ahead of its downloaded blocks can get a refusal while the active chainstate retains synthetic transaction counts and assumed-valid flags.
  A load that fails the new Evo checks can still change the shared block index. The loop sets `nTx`, `nChainTx`, and `BLOCK_ASSUMED_VALID` and marks the entries dirty before seeding, preflight, and the dry run. For example, an authorized section can pass both hash checks and then fail preflight when a quorum work block marked as present cannot be read. Cleanup discards the temporary chainstate but does not revert those shared fields, so a later flush can persist them. Move the shared index updates back to the successful handoff, after the fallible preparation and base-marker write.
- [SUGGESTION] src/validation.cpp:6964-6987: Pruning after successful validation can prevent snapshot promotion on restart
  Impact: A pruned node can finish background validation but return to dual-chainstate mode on restart if pruning removes a block needed to repeat the comparison.
  Runtime completion only marks the background chainstate disabled in memory. Startup recomputes completion before promoting, and the rewrite removed the captured inputs that let the rebuild survive pruning. Once the file containing the base block is outside the active chainstate’s retention window, pruning can remove it; no snapshot-completion prune lock protects it. The next rebuild returns `EVO_DATA_UNAVAILABLE`, and `LoadChainstate()` skips promotion. Protect the required inputs until promotion, or persist the successful comparison bound to the snapshot base and accepted pin.
- [SUGGESTION] src/validation.cpp:6947-6969: A readable but damaged block body can make completion reject a good snapshot
  Impact: A node can quarantine an honest snapshot if its local copy of the base block is damaged but still deserializes.
  After the rewrite removed captured inputs, `BuildEvoSnapshot()` rereads the base block from disk and constructs a coinbase Merkle branch from its transactions. `ReadBlockFromDisk()` checks the header hash and proof of work, not the body’s Merkle root, and `EvoSnapshot::Validate()` does not verify the branch against the indexed header. Damage to a non-coinbase transaction can therefore change the rebuilt section hash while the coins hash and EvoDB best-block markers still match. Completion treats that difference as a proven mismatch and quarantines the snapshot. Verify the body against the indexed Merkle root before using it as rebuild evidence, and classify an integrity failure as local corruption.
- [SUGGESTION] src/validation.cpp:6724-6744: An EvoDB read error during activation skips snapshot cleanup
  Impact: A caller that encounters a LevelDB read failure during seeded-state checks is left with the temporary snapshot databases on disk and the active chainstate’s cache still reduced.
  The new preflight and dry run read from EvoDB after the coins import has been flushed. For example, a seeded quorum-modifier read in the dry run can throw `dbwrapper_error`, which is not an `evo::LocalStateError`. The outer catch restores signal routing and clears the deployment cache, then rethrows without running the cache rebalance or directory cleanup below it. Run the same activation cleanup on exceptions from seeded-state preparation as on a `false` return, while preserving the original storage error for the caller.
- [SUGGESTION] src/validation.cpp:6344-6349: Coins left by an interrupted load can make a valid snapshot fail on retry
  Impact: A caller retrying at a different authorized base after an interrupted on-disk load can have a valid snapshot refused because the import reuses old coins.
  The rewrite drops the startup cleanup for an unmarked snapshot coins directory. Activation flushes coins before writing `base_blockhash`; if it stops in between, `DetectSnapshotChainstate()` ignores the directory and leaves it in place. The next activation wipes the snapshot EvoDB but opens the coins DB with `should_wipe=false`. Inserting the next snapshot’s coins does not erase old outpoints spent between the two bases, so a valid file can fail its UTXO hash check. Remove the abandoned coins directory after recovery rules out a live snapshot, or ensure a new on-disk activation opens a fresh coins database once it owns the directory. This head has no production caller for new snapshot activation.
- [BLOCKING] src/validation.cpp:7434-7455: A background coins read error can make completion reject a good snapshot
  (awaiting a tracking link: link an issue on its thread, or ask there and PastaClaw files it; no code change needed)

Comment thread src/validation.cpp Outdated
Comment on lines +6931 to +6935
// Rebuild the whole evo section from the state background validation
// derived: it must be the pinned one, which the snapshot chainstate was
// seeded from. Promotion relies on this check for every seeded record.
const bool dip3_base{DeploymentActiveAt(index_new, GetConsensus(), Consensus::DEPLOYMENT_DIP0003)};
if (dip3_base || au_data.evo_hash != EvoSnapshotHash{uint256::ZERO}) {

@thepastaclaw thepastaclaw Dec 3, 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.

⚖️ Disputed (left to the maintainers; not blocking) at 15996de9; see the replies below.

🟡 Suggestion: Changing the Evo pin before restart can promote state seeded under the old pin
Impact: A regtest operator who corrects an Evo pin after loading a snapshot can promote seeded records that background validation never confirmed.

Completion can verify one Evo section and promote another. Activation checks the section against the configured pin, but the rewrite removed the retained section and startup only restores the snapshot’s base block hash. If an operator loads a section whose credit-pool limit differs from the chain’s, then corrects only the Evo pin before restarting, the honest rebuild matches the new pin. ValidatedSnapshotCleanup() then copies the EvoDB seeded under the old pin. Persist the accepted Evo hash alongside the snapshot base and verify that binding before resuming or promoting the snapshot.

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.

Not changing this. The pin is trusted chain parameters, and completion treats the coins the same way since bitcoin#25740: it hashes the background chainstate's UTXO set and compares it with hash_serialized from the parameters, it does not hash the coins the snapshot chainstate was loaded with. Coins loaded under one hash_serialized and completed under another are promoted in Bitcoin Core as well. Outside regtest (-assumeutxodata) a pin changes only with the binary. Binding a loaded snapshot to the parameters it was accepted under would have to cover both hashes and is not specific to the evo section.

@knst knst Dec 3, 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.

🔴 Blocking: A background coins read error can make completion reject a good snapshot
src/validation.cpp:7434-7455
Completion preserves the snapshot only when ComputeUTXOStats() returns no result. The coins cursor does not expose CDBIterator::HasError(), so a LevelDB scan that skips records or stops early can still yield a successful hash of a partial set. That sends a local read failure down the HASH_MISMATCH path, which rejects the snapshot and shuts down. Propagate iterator status through the coins cursor and fail the stats scan before finalizing the hash. The malformed-coin test covers a GetValue() decode failure, not an iterator error.
Judged fixed at 2bf1541; raised again and confirmed by an independent pass: A C++ caller loads a valid pinned snapshot on disk through ChainstateManager::ActivateSnapshot() and lets background validation reach its base. If a disk read or checksum error makes LevelDB skip a table block containing live coins, ComputeUTXOStats() returns a successful hash of the incomplete set. Completion treats that hash as HASH_MISMATCH, quarantines the good snapshot, and shuts down, losing the ability to resume from the snapshot tip.

"A background coins read error can make completion reject a good snapshot": this is not from this PR. ComputeUTXOStats() ignores the cursor's read status on develop and in Bitcoin Core, which affects gettxoutsetinfo and dumptxoutset as well as completion. The previous head fixed it with CCoinsViewCursor::HasError(); that fix is independent of the Evo snapshot and will come as its own PR. Please file a tracking issue for it.

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 9772cb7d): The coins comparison policy does not bind the separately seeded EvoDB to the pin accepted during activation. On the current path, changing only the Evo pin lets completion compare the background rebuild with the new pin and then merge the old seeded records, so the proposed lifecycle binding remains necessary for this Evo-specific state.

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.

Disputed (re-reviewed at 15996de9): We still disagree on this one, and my answer is above, so I'm leaving the call to the maintainers. It no longer blocks this pull request, and I won't raise it again unless a later change brings the problem back.

Comment thread src/validation.cpp Resolved
Comment thread src/validation.cpp Outdated
Comment on lines +6947 to +6969
try {
built = evo::BuildEvoSnapshot(GetParams(), *this, special_tx.DeterministicMNManager(),
special_tx.QuorumBlockProcessor(), special_tx.QuorumSnapshotManager(),
*special_tx.m_cpoolman, *special_tx.m_mnhfman, &index_new, rebuilt, evo_error,
&failure);
} catch (const evo::LocalStateError& e) {
evo_error = e.what();
failure = evo::ClassifyEvoSectionError(e);
} catch (const std::exception& e) {
evo_error = e.what();
failure = evo::ClassifyEvoSectionError(e);
}
if (built && EvoSnapshotHash{evo::GetEvoSnapshotHash(rebuilt)} != au_data.evo_hash) {
built = false;
failure = evo::EvoSectionFailure::DISAGREEMENT;
evo_error = "the rebuilt section differs";
}
if (!built) {
switch (failure) {
case evo::EvoSectionFailure::DISAGREEMENT:
LogPrintf("[snapshot] the evo section differs from the validated state: %s\n", evo_error);
handle_invalid_snapshot();
return SnapshotCompletionResult::EVO_STATE_MISMATCH;

@thepastaclaw thepastaclaw Dec 3, 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; tracked in #8292) at 9772cb7d; see the replies below.

🟡 Suggestion: A readable but damaged block body can make completion reject a good snapshot
Impact: A node can quarantine an honest snapshot if its local copy of the base block is damaged but still deserializes.

After the rewrite removed captured inputs, BuildEvoSnapshot() rereads the base block from disk and constructs a coinbase Merkle branch from its transactions. ReadBlockFromDisk() checks the header hash and proof of work, not the body’s Merkle root, and EvoSnapshot::Validate() does not verify the branch against the indexed header. Damage to a non-coinbase transaction can therefore change the rebuilt section hash while the coins hash and EvoDB best-block markers still match. Completion treats that difference as a proven mismatch and quarantines the snapshot. Verify the body against the indexed Merkle root before using it as rebuild evidence, and classify an integrity failure as local corruption.

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

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.

Not changing this here. The rebuild reads more block bodies than the base: the quorum work blocks and the blocks of the credit-pool window are read the same way, through ReadBlockFromDisk(), which checks the header only. Checking the base coinbase branch alone would not close the case; it needs the body checked against the Merkle root wherever a rebuild reads one, in evo/snapshot_chain.cpp from #7593. That is a separate change.

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 9772cb7d): This moves to a follow-up: I filed #8292 to track it, so it no longer blocks this pull request.

Comment thread src/validation.cpp Resolved
Comment thread src/node/chainstate.cpp Resolved
PastaPastaPasta and others added 3 commits December 4, 2026 02:20
The decoded section was checked against its pin and then dropped, so a snapshot chainstate at a DIP3-active base had none of the Evo state the blocks above its base need. Loading now writes the pinned section into the snapshot chainstate's own EvoDB through each manager's seeding entry point, then runs the chain checks export runs, reading deployment state at or below the base from the carried signal record, and computes from the seeded state alone every quorum the chainstate may need at or right after the base. Any failure rejects the snapshot and with it the EvoDB. These steps run before the shared block index is marked for the snapshot, so a refused section leaves the index as it was, and ActivateSnapshot() cleans up after an exception as after a refusal before passing it on. An unpinned section before DIP3 carries nothing needed and is ignored.

Completion compared the serialized masternode list each chainstate holds at the base. A snapshot numbers its masternodes by the rank of their proTxHash while a chainstate numbers them as their registrations come, so with a seeded list the two serializations differ even when they agree on every masternode. That comparison is removed, with GetDeterministicMNListHash() which served only it; the next commit compares the whole section instead, and until then a snapshot with DIP3 active at its base is still never validated (EVO_DATA_UNAVAILABLE). chainstatemanager_snapshot_completion_incorrect_base_mn_list, which wrote a list into the snapshot chainstate's EvoDB by its key to trigger the comparison, goes with it.

chainstatemanager_evo_snapshot_cold_load loads the honest snapshot on a node with only the headers, extends it past the next rotation cycle from the carried state alone and connects the blocks up to the base in the background. Before that it loads a pinned section whose base coinbase the header does not prove and checks that the refusal left the base's index entry untouched.

Co-authored-by: Konstantin Akimov <[email protected]>
…n a snapshot is rejected

The rejection makes the background chainstate active, but its candidates held only the base and its ancestors. Blocks the snapshot chain had connected above the base were missing, so the next CheckBlockIndex aborted (with -checkblockindex, the regtest default). RestoreBlockIndexCandidates() re-lists them with the rule startup applies.

Inherited from bitcoin#25740; bitcoin/master still has it, so there is no upstream fix to backport.

Co-authored-by: Konstantin Akimov <[email protected]>
Nothing compared the Evo state a snapshot chainstate was seeded with, so a snapshot with DIP3 active at its base was never validated. Completion now rebuilds the whole section at the base from the background chainstate's Evo state and requires its hash to be the pinned one, which the seeded section matched at load. A disagreement rejects the snapshot; data the background chainstate still lacks leaves the snapshot in use, unvalidated, until completion is retried (EVO_DATA_UNAVAILABLE); unreadable or inconsistent local state, or an internal error, stops the node and keeps the snapshot (the new EVO_LOCAL_FAILURE and EVO_INTERNAL_ERROR, with the advice of SnapshotCompletionStopMessage(), which startup reports too). An EvoDB whose best block is not its chainstate's coins tip is such a local failure now, where it used to reject the snapshot.

The honest snapshot of chainstatemanager_evo_snapshot_requires_its_pin, loaded where background validation is already at the base, is validated. chainstatemanager_evo_snapshot_cold_load now validates the snapshot in the background and promotes it at the next start. In chainstatemanager_evo_snapshot_completion_rejects_a_lying_section a pinned section that every load check accepts, with a credit-pool limit the chain does not derive, is rejected at completion.

Co-authored-by: Konstantin Akimov <[email protected]>

@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

Changes requested: 1 blocker

  • A background coins read error can make completion reject a good snapshot — src/validation.cpp:7434-7455 (carried; accepted as a deferral; lifts when a tracking issue is linked on its thread)

New on this head: This head seeds the pinned Evo section into the snapshot chainstate before activation, restores block candidates after rejection, and rebuilds the complete Evo section during background validation. Lint, Cppcheck, and ClangFormat pass; the source-build jobs were still in progress in the supplied CI snapshot.

🔴 1 blocking | 🟡 3 suggestion(s)

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

🟡 Suggestion: A failed cache restore can leave the signal router pointing at a destroyed snapshot
Impact: A storage failure while restoring the original cache allocation can leave the process with a dangling Evo signal route, skip directory cleanup, and replace the original activation error.
src/validation.cpp:6375-6391

If MaybeRebalanceCaches() throws during the refusal path, cleanup unwinds before RouteEHFSignals(..., nullptr), snapshot_chainstate.reset(), and either directory deletion are reached. ResizeCoinsCaches() can throw while reopening the coins database, so the temporary chainstate is then destroyed while the router still points at its CMNHFManager; the exception from cache restoration also masks the original load failure. Detach the route and clear the deployment cache before fallible cache restoration, then perform each cleanup step independently while preserving the original exception.

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

🔴 Blocking: A background coins read error can make completion reject a good snapshot
src/validation.cpp:7434-7455

Completion preserves the snapshot only when ComputeUTXOStats() returns no result. The coins cursor does not expose CDBIterator::HasError(), so a LevelDB scan that skips records or stops early can still yield a successful hash of a partial set. That sends a local read failure down the HASH_MISMATCH path, which rejects the snapshot and shuts down. Propagate iterator status through the coins cursor and fail the stats scan before finalizing the hash. The malformed-coin test covers a GetValue() decode failure, not an iterator error.

Judged fixed at 2bf15411; raised again and confirmed by an independent pass: A C++ caller loads a valid pinned snapshot on disk through ChainstateManager::ActivateSnapshot() and lets background validation reach its base. If a disk read or checksum error makes LevelDB skip a table block containing live coins, ComputeUTXOStats() returns a successful hash of the incomplete set. Completion treats that hash as HASH_MISMATCH, quarantines the good snapshot, and shuts down, losing the ability to resume from the snapshot tip.

source: prior finding (deferral not tracked)

Still open from earlier rounds (1)

  • 🟡 Suggestion: Changing the Evo pin before restart can promote state seeded under the old pin — src/validation.cpp:6992-7018 (thread)

⏸️ Awaiting tracking link (1): A background coins read error can make completion reject a good snapshot. Link an issue on its thread, or ask there and PastaClaw files it.

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 changes to snapshot activation and completion in src/validation.cpp are intricate, but they change how pinned Evo state is loaded and verified, not consensus rules or the on-disk schema.
  • 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:6375-6391: A failed cache restore can leave the signal router pointing at a destroyed snapshot
  Impact: A storage failure while restoring the original cache allocation can leave the process with a dangling Evo signal route, skip directory cleanup, and replace the original activation error.
  If `MaybeRebalanceCaches()` throws during the refusal path, cleanup unwinds before `RouteEHFSignals(..., nullptr)`, `snapshot_chainstate.reset()`, and either directory deletion are reached. `ResizeCoinsCaches()` can throw while reopening the coins database, so the temporary chainstate is then destroyed while the router still points at its `CMNHFManager`; the exception from cache restoration also masks the original load failure. Detach the route and clear the deployment cache before fallible cache restoration, then perform each cleanup step independently while preserving the original exception.
- [SUGGESTION] src/validation.cpp:6982-6989: An unreadable EvoDB best-block marker bypasses completion's recovery advice
  Impact: A LevelDB read failure while checking an EvoDB marker escapes completion's local-failure classification, so startup reports a generic database-opening error instead of retaining the snapshot and providing the intended recovery guidance.
  `VerifyBestBlock()` calls `ReadBestBlock()`, whose database read can throw `dbwrapper_error`; the two marker checks occur before the `BuildEvoSnapshot()` exception boundary. Consequently, an unreadable marker does not become `EVO_LOCAL_FAILURE`, and `LoadChainstate()` cannot use `SnapshotCompletionStopMessage()` to tell the operator that the snapshot was not rejected and which reindex operation to use. Read and classify both markers inside the same local-corruption boundary while retaining the existing mismatch behavior for successfully readable markers.
- [BLOCKING] src/validation.cpp:7434-7455: A background coins read error can make completion reject a good snapshot
  (awaiting a tracking link: link an issue on its thread, or ask there and PastaClaw files it; no code change needed)
- [SUGGESTION] src/validation.cpp:6992-7018: Changing the Evo pin before restart can promote state seeded under the old pin
  (carried; thread: https://github.com/dashpay/dash/pull/8272#discussion_r4789156870)

Comment thread src/validation.cpp Resolved
Comment thread src/validation.cpp Outdated
Comment on lines +6931 to +6935
// Rebuild the whole evo section from the state background validation
// derived: it must be the pinned one, which the snapshot chainstate was
// seeded from. Promotion relies on this check for every seeded record.
const bool dip3_base{DeploymentActiveAt(index_new, GetConsensus(), Consensus::DEPLOYMENT_DIP0003)};
if (dip3_base || au_data.evo_hash != EvoSnapshotHash{uint256::ZERO}) {

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 9772cb7d): The coins comparison policy does not bind the separately seeded EvoDB to the pin accepted during activation. On the current path, changing only the Evo pin lets completion compare the background rebuild with the new pin and then merge the old seeded records, so the proposed lifecycle binding remains necessary for this Evo-specific state.

Comment thread src/validation.cpp Resolved
Comment thread src/validation.cpp Outdated
Comment on lines +6947 to +6969
try {
built = evo::BuildEvoSnapshot(GetParams(), *this, special_tx.DeterministicMNManager(),
special_tx.QuorumBlockProcessor(), special_tx.QuorumSnapshotManager(),
*special_tx.m_cpoolman, *special_tx.m_mnhfman, &index_new, rebuilt, evo_error,
&failure);
} catch (const evo::LocalStateError& e) {
evo_error = e.what();
failure = evo::ClassifyEvoSectionError(e);
} catch (const std::exception& e) {
evo_error = e.what();
failure = evo::ClassifyEvoSectionError(e);
}
if (built && EvoSnapshotHash{evo::GetEvoSnapshotHash(rebuilt)} != au_data.evo_hash) {
built = false;
failure = evo::EvoSectionFailure::DISAGREEMENT;
evo_error = "the rebuilt section differs";
}
if (!built) {
switch (failure) {
case evo::EvoSectionFailure::DISAGREEMENT:
LogPrintf("[snapshot] the evo section differs from the validated state: %s\n", evo_error);
handle_invalid_snapshot();
return SnapshotCompletionResult::EVO_STATE_MISMATCH;

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 9772cb7d): This moves to a follow-up: I filed #8292 to track it, so it no longer blocks this pull request.

Comment thread src/validation.cpp Resolved
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Tracking issue for the carried blocker "A background coins read error can make completion reject a good snapshot" (src/validation.cpp:7434-7455): #8293.

As knst noted, ComputeUTXOStats() ignores the coins cursor's iterator status on develop and in Bitcoin Core, so gettxoutsetinfo and dumptxoutset are affected as well as completion. The fix (CCoinsViewCursor::HasError(), checked before the hash is finalized) will land as its own PR. This finding has no review thread to link the issue on, so the deferral is recorded here.


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

… path on read errors

A refused snapshot load restored the coins caches before detaching the
Evo signal route. If the restore threw (ResizeCoinsCaches reopens the
coins database), the temporary chainstate was destroyed with the route
still pointing at its MNHF manager, the snapshot directories were left
behind, and the restore error replaced the load error. Detach the route
and clear the deployment cache first, and let a restore error wait until
the cleanup has run and any load error has been rethrown.

Completion read both EvoDB best-block markers outside any catch, so a
LevelDB read error there escaped as a generic startup failure. Classify
it as local corruption, as a mismatching marker already is, so the
snapshot is kept and the operator gets the recovery advice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

On the non-inline suggestion "A failed cache restore can leave the signal router pointing at a destroyed snapshot" (src/validation.cpp:6375-6391): fixed in 15996de.

  • The refusal path now detaches the Evo signal route and clears the deployment cache before MaybeRebalanceCaches().
  • A restore error is caught and held, so the chainstate reset and both directory deletions still run.
  • The original load exception is rethrown first; the restore error is rethrown only when there was none.

The snapshot unit suites (validation_chainstatemanager_tests, validation_chainstate_tests, evo_snapshot_tests, evo_db_tests) pass on a Debug -Werror build.


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

@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: The latest commit detaches Evo signal routing before restoring caches on a refused snapshot load and classifies EvoDB marker read errors during completion as local failures rather than snapshot rejection. GitHub reports no failed code checks; ASan tests and multiprocess lint have passed, and only the review check is pending.

🟡 1 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.

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

🟡 Suggestion: The final commit bundles independent fixes for snapshot activation and completion
Impact: Maintainers bisecting either feature can land on an earlier revision that still has the failure path corrected by the final commit.
<commit:15996de9202>:1

Neither feature commit contains its final error handling, and the two corrections do not depend on each other. The ActivateSnapshot() hunk finishes refusal cleanup introduced in 862f00e4801; the marker-read hunk completes the local-failure policy introduced in 9772cb7dbd7. Fold each hunk into the feature commit it corrects so each records one complete change, and leave the independent block-candidate fix in 26d19854f80 separate.

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

Disputed — left to maintainers (1)

  • 🟡 Suggestion: Changing the Evo pin before restart can promote state seeded under the old pin — src/validation.cpp:6931-6935 (thread)
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 changes to snapshot activation and completion in src/validation.cpp are intricate, but they change how Evo state is initialized and verified, not the consensus rules that consume it or the on-disk storage format.
  • 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:15996de9202>`:
- [SUGGESTION] <commit:15996de9202>:1: The final commit bundles independent fixes for snapshot activation and completion
  Impact: Maintainers bisecting either feature can land on an earlier revision that still has the failure path corrected by the final commit.
  Neither feature commit contains its final error handling, and the two corrections do not depend on each other. The `ActivateSnapshot()` hunk finishes refusal cleanup introduced in `862f00e4801`; the marker-read hunk completes the local-failure policy introduced in `9772cb7dbd7`. Fold each hunk into the feature commit it corrects so each records one complete change, and leave the independent block-candidate fix in `26d19854f80` separate.

Comment thread src/validation.cpp Resolved
Comment thread src/validation.cpp Outdated
Comment on lines +6931 to +6935
// Rebuild the whole evo section from the state background validation
// derived: it must be the pinned one, which the snapshot chainstate was
// seeded from. Promotion relies on this check for every seeded record.
const bool dip3_base{DeploymentActiveAt(index_new, GetConsensus(), Consensus::DEPLOYMENT_DIP0003)};
if (dip3_base || au_data.evo_hash != EvoSnapshotHash{uint256::ZERO}) {

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.

Disputed (re-reviewed at 15996de9): We still disagree on this one, and my answer is above, so I'm leaving the call to the maintainers. It no longer blocks this pull request, and I won't raise it again unless a later change brings the problem back.

@knst knst 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.

utACK 15996de

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants