Skip to content

feat: pin AssumeUTXO snapshots for mainnet and testnet - #8276

Open
PastaPastaPasta wants to merge 128 commits into
dashpay:developfrom
PastaPastaPasta:feat/assumeutxo-network-pins
Open

PastaPastaPasta wants to merge 128 commits into
dashpay:developfrom
PastaPastaPasta:feat/assumeutxo-network-pins

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

The AssumeUTXO stack lets a node load a UTXO snapshot together with the Dash evo state at its base, sync to the tip from there, and validate the history in the background. Until now it was usable only on regtest: mainnet and testnet had no m_assumeutxo_data entries, and loadtxoutset and getchainstates refused to run outside regtest. This PR pins one snapshot each for mainnet and testnet and makes the RPCs available there.

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 → this PR. The stack is rebased onto develop b2d64c27c7, which merged #8235, so #8237 is now the bottom layer. Every layer stays a draft until the one below it merges. New on top of #8079: the four commits from 678205698a (feat(chainparams): pin AssumeUTXO snapshots for mainnet and testnet) onward.

Update (2026-11-28). Rebased onto develop 7f4b217 (#8256: DataStream/HashWriter/NetMsg conversions squashed into the commits that introduced the code). No change to this PR's own commits. No change to this PR's own commits in the CodeRabbit round; rebased onto the fixups below it.

What was done?

  • src/kernel/chainparams.cpp: one m_assumeutxo_data entry each for mainnet and testnet. Each entry has the base height, base block hash, UTXO set hash (hash_serialized), v4 evo section hash (evo_hash) and nChainTx:
    • mainnet, height 2579482: block 000000000000001cfbe4751211d7e753bab093e5d63de1fa947cf20714a0e727, txoutset 9f04690bf3ef7a4917eace719ac558cd6896a8bd22e905a74f19d76ce83d5811, evo 5fe390df978e8e5ac259e02a0b0690a6e3a757f45177025cf5f4d864e59ebc6e, nChainTx 71739012
    • testnet, height 1599687: block 0000006e4b85a1f38f3224ead2865de8e7f29d98229b58b00a1b1bedab624872, txoutset 4ba6fb243e38624fac1f2f434027b381c3cdf900f3da981e996d113be148d772, evo 574ddf5486e18f81998b2a49a37b7ba9562ac4e134d14a7225bdd04b0c1b4afd, nChainTx 9019675
  • src/rpc/blockchain.cpp:
    • Removed the regtest-only guards from loadtxoutset and getchainstates, and the "regression testing only" sentences from their help.
    • Moved dumptxoutset, loadtxoutset and getchainstates from the hidden category to blockchain.
    • dumptxoutset help now says that its output can be loaded only if its height is pinned.
  • -assumeutxodata stays regtest-only. It adds snapshot authorizations at runtime, so on mainnet or testnet it would let a user trust a snapshot nobody reviewed. Outside regtest, snapshot authorizations are reviewed chain parameters. No other chain-type check exists on the snapshot load, activation, validation or promotion paths. The refusals for pruned nodes, masternodes and -addressindex/-spentindex/-timestampindex already apply on every network.
  • doc/design/assumeutxo.md:
    • The pinned heights, base hashes, file sizes and file sha256s.
    • How to load a snapshot and how to reproduce the pinned file.
    • Release note doc/release-notes-8276.md.

Devnets get no pin; they are short-lived and their chains differ.

How the values were generated

The values come from dumptxoutset on the AssumeUTXO stack with the canonical masternode numbering fix. They were dumped on long-synced testnet and mainnet nodes.

  • To reach the base without rolling back the live node, each dump ran on a copy of the datadir with the network off, after invalidateblock of the block after the base.
  • The snapshot file is deterministic. Datadirs with different sync histories gave byte-identical files:
    • testnet: three datadirs (an IBD on v24.0.3 followed by this stack, a plain IBD from genesis, and a node whose MN state was built as a background chainstate)
    • mainnet: two datadirs
  • Files:
    • mainnet: 289606403 bytes, sha256 bf65a65ef575989e58df25f5781187a6b4dec25e0211b329fb2413b203dc952f, 4513970 coins, 3006 masternodes
    • testnet: 64126131 bytes, sha256 651e5b29b8c9ff9b50606cbd95c515e7877fb0004432bfa9d4bdce228fc99786, 996268 coins, 413 masternodes

The evo_hash pins hold for the v4 evo section encoding. Any later change to that canonical encoding changes evo_hash and needs new pins. hash_serialized and nChainTx do not depend on it.

How the values were verified

On each network, a fresh datadir ran a build with exactly these pins and the guards removed.

  • Load. loadtxoutset ran once headers passed the base.
    • testnet: 17.6 s; the node's own tip was at 2868
    • mainnet: 30.3 s; the node's own tip was at 195
  • Background validation. It reached the base with no UTXO or evo mismatch: 22 min on testnet, 1 h 14 min on mainnet.
  • Promotion. A restart promoted the snapshot chainstate, and RecalculateAndRepairDiffs repaired 0 masternode list diffs.
  • Comparison with the source node (a normally synced node) after promotion:
    • The tip was the same.
    • protx list registered true H was identical at eight heights around and after the base.
    • protx diff was byte-identical for five ranges, including 1 to the tip.
    • The base, base+1 and tip cbTx were the same, and so was quorum list.
    • The log had no payee, invalid-block or ERROR: lines.
  • Following the chain. Both nodes kept following the chain after promotion. A watcher compared them every 10 minutes, with matching tips and masternode lists.

How Has This Been Tested?

  • validation_tests/test_assumeutxo now also checks that mainnet and testnet each have exactly the pinned entry. It looks the entry up by height and by block hash, and checks that the neighbouring heights have none.
  • feature_assumeutxo_refusals.py: the existing scenario that starts the node on other networks now also starts it on mainnet and testnet without -assumeutxodata. There it checks that getchainstates answers and that loadtxoutset of the regtest snapshot fails with "assumeutxo block hash in snapshot metadata not recognized" instead of the old regtest-only error.
  • Without the src/rpc/blockchain.cpp change, the functional test fails with getchainstates is for regression testing (-regtest mode) only (-1). With the change, it passes.
  • At this head, on Linux x86_64 (Debug, GCC 13, depends): ctest 185/185 passed, and feature_assumeutxo.py, feature_assumeutxo_dash.py, feature_assumeutxo_refusals.py, wallet_assumeutxo.py, rpc_dumptxoutset.py, rpc_help.py, p2p_instantsend.py, feature_llmq_is_cl_conflicts.py, feature_llmq_chainlocks.py, rpc_invalidateblock.py and feature_pruning.py all passed.

Breaking Changes

  • loadtxoutset and getchainstates now work on mainnet and testnet. Before, they failed there with "... is for regression testing (-regtest mode) only".
  • dumptxoutset, loadtxoutset and getchainstates are listed in help under Blockchain instead of being hidden.

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 (if you have permission to set one)

🤖 Generated with Claude Code

@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 commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 2d8a07b) · triage: critical

@PastaPastaPasta
PastaPastaPasta force-pushed the feat/assumeutxo-network-pins branch from 5e1d32c to 93e8702 Compare November 28, 2026 07:23
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.

Final validation — Phase 2 only (queue backlog)

This change pins reviewed AssumeUTXO snapshots for mainnet and testnet, exposes the snapshot RPCs on those networks, and documents the supported files and loading procedure. The completed main and ClangFormat checks passed; the review check remains in progress, with no completed code check failures.

🟡 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 (GitHub refused the PR diff as too large)

🟡 Suggestion: The release-note correction is split from the commit that introduced the release note
Impact: Anyone tracing the AssumeUTXO documentation history sees a standalone corrective commit instead of one commit that introduces the correctly named release note.
<commit:93e8702>:1

The final commit only renames the release-note file and replaces (#pins) with (#8276), while the preceding commit creates the file with that temporary name and marker. This leaves an unnecessary historical seam without an independent behavioral change; fold this correction into 23c82575810 so the release note is introduced correctly in one logical commit.

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) — This very large, intricate diff changes consensus validation and chainstate/UTXO snapshot loading and promotion paths in validation.cpp, node/chainstate.cpp, and related storage code, directly affecting trusted state initialization and persistent blockchain state.
  • Phase 1 reviewers: not run (skipped for throughput: 14 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 `<commit:93e8702>`:
- [SUGGESTION] <commit:93e8702>:1: The release-note correction is split from the commit that introduced the release note
  Impact: Anyone tracing the AssumeUTXO documentation history sees a standalone corrective commit instead of one commit that introduces the correctly named release note.
  The final commit only renames the release-note file and replaces `(#pins)` with `(#8276)`, while the preceding commit creates the file with that temporary name and marker. This leaves an unnecessary historical seam without an independent behavioral change; fold this correction into `23c82575810` so the release note is introduced correctly in one logical commit.

@thepastaclaw thepastaclaw added the pastaclaw:approved thepastaclaw's latest review approved this PR label 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.

CI failed after approval — commit 93e8702

The standing review approved this commit; this follow-up moves the verdict to COMMENT: checks that failed after the review look related to this change.

Failing checks:

Why they look related: The lint failure is in test/functional/feature_assumeutxo.py, a file changed by this PR. The ASAN failure is an undefined-behavior sanitizer error in validation_chainstatemanager_tests.cpp, also changed by this PR, and occurs in an AssumeUTXO snapshot test.

Nothing was re-reviewed: the findings of the standing review are unchanged. The next push gets a full review; a re-run that passes does not restore the approval.

Review provenance

Source: CI-check lane gpt-6.2-sol (agent: triage); no reviewer or verifier lanes ran for this follow-up

  • Verdict moved because CI failed on this commit after the review; failure logs read: 2 GitHub Actions job(s)

@thepastaclaw thepastaclaw added pastaclaw:commented thepastaclaw's latest review was comment-only and removed pastaclaw:approved thepastaclaw's latest review approved this PR labels Nov 28, 2026
@PastaPastaPasta
PastaPastaPasta force-pushed the feat/assumeutxo-network-pins branch from 93e8702 to 0d6782e Compare November 28, 2026 09:38
@thepastaclaw thepastaclaw removed the pastaclaw:commented thepastaclaw's latest review was comment-only label Nov 28, 2026
@PastaPastaPasta
PastaPastaPasta force-pushed the feat/assumeutxo-network-pins branch from 0d6782e to f74a6e5 Compare November 28, 2026 11:16
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 1 + Phase 2

New on this head: This head rebases the AssumeUTXO snapshot pinning and RPC exposure changes onto the updated develop base; the pull request's own substantive commits remain unchanged. No code checks are failing: ClangFormat and title validation passed, while build jobs are skipped or still queued.

🟡 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 (GitHub refused the PR diff as too large)

🟡 Suggestion: The release-note correction is split from the commit that introduced the release note
Impact: The permanent history retains an avoidable documentation fixup: the release note is introduced under a temporary filename and placeholder reference, then corrected in a separate commit.
<commit:f74a6e5>:1

The final tree is correct, but commit 328ddd5f62b introduces the note as doc/release-notes-pins.md with (#pins), while f74a6e5181a separately renames it to doc/release-notes-8276.md and changes the reference to (#8276). Fold the rename and reference correction into the introducing documentation commit so the feature history contains one coherent release-note change.

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

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-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) — This is a large, intricate change that modifies consensus validation and chainstate/storage snapshot activation paths in files such as src/validation.cpp, src/node/chainstate.cpp, src/evo/snapshot.cpp, and src/rpc/blockchain.cpp.
  • 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)
  • 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:f74a6e5>`:
- [SUGGESTION] <commit:f74a6e5>:1: The release-note correction is split from the commit that introduced the release note
  Impact: The permanent history retains an avoidable documentation fixup: the release note is introduced under a temporary filename and placeholder reference, then corrected in a separate commit.
  The final tree is correct, but commit `328ddd5f62b` introduces the note as `doc/release-notes-pins.md` with `(#pins)`, while `f74a6e5181a` separately renames it to `doc/release-notes-8276.md` and changes the reference to `(#8276)`. Fold the rename and reference correction into the introducing documentation commit so the feature history contains one coherent release-note change.

PastaPastaPasta and others added 28 commits November 30, 2026 02:21
…ground validation completes

The tip form of getassetunlockstatuses reads the credit pool at the best
ChainLock, which can be at or below the snapshot base; refuse it there like
the explicit-height form instead of failing on the missing history.

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

9315754 test: assumeutxo: spend coin from snapshot chainstate after loading

Pull request description:

  Submit a transaction that spends a coin only the snapshot chainstate knows
  (the coinbase of the first block the loading node lacks) and check that it
  enters the mempool and spends the coin.

Dash adaptations:
- The output pays the coinbase value less a 0.001 DASH fee, instead of
  upstream's fixed 24.99, which is specific to Bitcoin's subsidy.
- The coin is the coinbase of block START_HEIGHT + 1, which n0 mines to its
  deterministic key; the MiniWallet transactions at EXTRA_TX_HEIGHTS spend
  other coins.

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

9d9a745 assumeutxo: Remove BLOCK_ASSUMED_VALID flag
ef174e9 test: assumeutxo snapshot block CheckBlockIndex crash test
0391458 test: assumeutxo stale block CheckBlockIndex crash test
ef29c8b assumeutxo: Get rid of faked nTx and nChainTx values
9b97d5b doc: Improve comments describing setBlockIndexCandidates checks
0fd915e validation: Check GuessVerificationProgress is not called with disconnected block
63e8fc9 ci: add getchaintxstats ubsan suppressions
f252e68 assumeutxo test: Add RPC test for fake nTx and nChainTx values

Pull request description:

  Snapshot activation no longer fakes nTx and nChainTx for the blocks below
  the base, and BLOCK_ASSUMED_VALID goes. nTx and nChainTx stay 0 until a
  block's transactions are known; only the base gets the pinned nChainTx.
  CheckBlockIndex() checks the exact nChainTx sum and restarts its "first
  missing/invalid" tracking at the snapshot base.

Dash adaptations:
- This removes the interim the bitcoin#27596 commit added while counts were faked:
  CheckBlockIndex()'s two exceptions to the monotonic nChainTx check and
  BlockManager::m_faked_tx_height. The monotonic check gives way to bitcoin#28562's
  exact sum check (73700fb), which the bitcoin#28562 commit left out, in its
  bitcoin#29370 form.
- BLOCK_ASSUMED_VALID also covered the block index a dropped snapshot leaves
  behind (-reindex-chainstate, or a restart after a rejection): blocks it
  connected above a base whose ancestors were never validated keep CHAIN and
  SCRIPTS validity, which CheckBlockIndex now rejects. LoadBlockIndex lowers
  such blocks to the level their ancestors back up, and never below
  TRANSACTIONS. bitcoin/master has the same gap after -reindex-chainstate.
- CheckBlockIndex() keeps tracking ChainLock-conflicting ancestors beside
  the invalid ones, and the candidate checks skip both.
- BLOCK_STATUS_RESERVED keeps the value 256. No released version of this
  tree loads a snapshot, so no block index on disk has faked counts and no
  compatibility code is needed (upstream's compatibility note).
- The loop at the snapshot switch keeps marking the chain's entries dirty
  but changes none of them: the BLOCK_OPT_WITNESS faking that upstream
  keeps there is SegWit-only.
- clientversion.h is included for FormatFullVersion() in the new warnings.
- Dash unit tests: the cold-importer fixture (ForgetBlocks) resets the
  forgotten entries as CreateAndActivateUTXOSnapshot() now does; the
  switch-recheck case no longer looks for the removed flag; the failed-
  preparation case checks that only the switch sets a count, the base's
  pinned nChainTx.
- feature_assumeutxo.py counts the transactions of each block from its
  EXTRA_TX_HEIGHTS rows rather than upstream's every third block, checks the
  dump's nChainTx against that count, and adds the stale block as upstream.
- The ubsan suppressions use this tree's file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A snapshot rejected before background validation reached its base left the
base with the transaction count from the snapshot metadata, and the blocks
above it counted from that. Restoring the validated chainstate's candidates
then offered it blocks above an unlinked gap: the next block in the shutdown
window failed FindMostWorkChain's assert, and -checkblockindex failed on the
counts and on validity.

Give the base and the blocks above it the state the next startup derives
without the snapshot: counts only through linked parents, unlinked blocks with
data back in m_blocks_unlinked, and CHAIN/SCRIPTS validity only where
validated ancestors back it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2342b46 test: Add coverage for getchaintxstats in assumeutxo context
faf2a67 rpc: Reorder getchaintxstats output
fa2dada rpc: Avoid getchaintxstats invalid results

Pull request description:

  getchaintxstats computed its window from nChainTx values that are unset
  while an assumeutxo snapshot is being validated, and reported wrong or
  wrapped counts. Omit txcount, window_tx_count and txrate when they are
  unknown, and drop the ubsan suppressions bitcoin#29370 added for this RPC.

Dash adaptations:
- The window count is a plain value with a flag instead of std::optional:
  gcc-11 reports -Wmaybe-uninitialized on upstream's form, which
  --enable-werror turns into an error.
- The RPC holds cs_main while it reads the window's nChainTx values, not
  only while it selects the block: a rejected snapshot's base and the blocks
  above it get their counts rewritten under cs_main here.

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

b7ba60f test: add coverage for -reindex and assumeutxo
e57f951 init, validation: Fix -reindex option with an existing snapshot

Pull request description:

  Restarting with -reindex or -reindex-chainstate while a snapshot
  chainstate exists must delete it, and a snapshot can be loaded again
  afterwards.

Dash adaptations:
- e57f951 is equivalent in this tree and not applied: node::LoadChainstate()
  deletes the snapshot chainstate directory with
  DeleteSnapshotChainstateFromDisk() before it detects a snapshot, when
  reindexing, so no snapshot chainstate is created that would need
  deleting, and the validated chainstate is initialized with the node's
  mempool from the start. Upstream's DeleteSnapshotChainstate() and its
  mempool handover therefore have no counterpart.
- The test's coin count comes from the dump, as in the rest of the file.

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

ee67bba test: added test coverage to loadtxoutset

Pull request description:

  Check that loadtxoutset fails with a clear error for a path that does
  not exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
faa30a4 rpc: Do not wait for headers inside loadtxoutset

Pull request description:

  loadtxoutset waited up to ten minutes for the snapshot base's header
  before activating. Fail immediately instead, asking the caller to sync
  headers and call it again.

Dash adaptations:
- contrib/devtools/test_utxo_snapshots.sh is not in this tree, so its hunk
  is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1ec6684 test: Add test for loadtxoutset when headers are not synced
2bc1ecf test: Remove unnecessary sync_blocks in assumeutxo tests

Pull request description:

  Test that loadtxoutset fails right away when the node lacks the snapshot
  base's header, which bitcoin#29345 changed from a ten-minute wait. Also drop a
  sync_blocks call that compared the disconnected nodes' identical cached
  chains.

Dash adaptations:
- The loading nodes here receive the new headers while n0 mines the
  snapshot chain, so the check runs on n3 after its datadir is wiped for
  the startup block import scenario, before it gets the headers, instead
  of on nodes 1 and 2 before the headers are ferried over.

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

2f9bde6 test: Remove unnecessary restart in assumeutxo test
19ce3d4 assumeutxo: Check snapshot base block is not marked invalid
80315c0 refactor: Move early loadtxoutset checks into ActiveSnapshot

Pull request description:

  ActivateSnapshot() returns a util::Result, so loadtxoutset reports why a
  load failed, and the checks that loadtxoutset made before calling it move
  into it. A base block in an invalid chain is refused.

Dash adaptations:
- 19ce3d4 is equivalent here: SnapshotActivationRefusal() already
  refuses a base whose chain has a block marked failed or ChainLock-
  conflicting, at load and again at the switch, so no second check is added.
  test_snapshot_block_invalidated runs on n0, the node with the downloaded
  chain, restarted with the pin for this check only (it never loads a
  snapshot), and matches the refusal's message.
- The snapshot metadata has no base height in this tree (bitcoin#29612 is not
  ported), so the unrecognized-hash error names the hash only, without the
  available heights.
- The refusals that this tree logs keep their log lines, which its tests and
  operators read; each now also returns its reason. Dash's own failures
  (another activation running, an earlier rejected snapshot, the Evo
  publication) return theirs too.
- loadtxoutset looks the base up after activation for its tip_hash and
  base_height: without bitcoin#29612 the metadata has no base height.
- test_invalid_mempool_state comes from bitcoin#29394, which this file lacked, in
  its bitcoin#30267 form, with n2 started with -persistmempool=0 as there. It
  overlaps a unit case of the refusals commit; both are kept.
- 2f9bde6 and the hunks for bitcoin#29428's test_snapshot_with_less_work,
  bitcoin#29612's metadata rows and bitcoin#29973's double load are not applicable: those
  tests are not in this file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ent chain + test

5b7f70b test: loadtxoutset in divergent chain with less work
d35efe1 p2p: Start downloading historical blocks from common ancestor

Pull request description:

  When the active chain tip is not an ancestor of the snapshot base, the
  background chainstate must download the snapshot's history from the last
  common ancestor of its tip and the base, not from its own tip.

Dash adaptations:
- The divergent-chain node is a fifth node (n4): n3 is the node that drops
  its snapshot with -reindex-chainstate. It is authorized with the same
  -assumeutxodata pin as the other loading nodes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Invalidating a block moves m_best_header back to the active tip or the
block's parent, and nothing moved it forward again when the block was
reconsidered: reconsiderblock, the temporary invalidation InstantSend
undoes when it lacks the locked transaction, and ChainLock enforcement
all clear the failure flags through ResetBlockFailureFlags(). The node
went on reporting a lower header, and a snapshot load that checks its
base against the best header (bitcoin#30320) would refuse a reconsidered
base.

ResetBlockFailureFlags() now moves the best header up to the most-work
header descending from the reconsidered block, skipping any header that
is itself, or descends from a block, marked invalid or in conflict with
a ChainLock. Headers known only beyond a block a ChainLock ruled out
carry no flag of their own, so their ancestors are checked too. The best
header only ever moves up here, as when a new header arrives; on every
network that is the only change.

Upstream fixes this as part of bitcoin#30666, which also recalculates
the best header from the whole block index whenever an invalid block is
found and marks every known descendant BLOCK_FAILED_CHILD, and needs its
follow-ups bitcoin#31405 and bitcoin#31835. Those change invalidation on
every network and replace this tree's own best-header stepping in
InvalidateBlock (dash#2029), and the matching stepping in
MarkConflictingBlock would need the same treatment; they are left to be
backported together. Until then a best header that already sits on
headers beyond a block a ChainLock rules out stays there, as before.

The rpc_invalidateblock.py checks are the reconsideration ones from
bitcoin#30666; its checks right after an invalidation need the rest of
that PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the best header chain

55b6d7b validation: Don't load a snapshot if it's not in the best header chain.

Pull request description:

  Refuse a snapshot whose base is not an ancestor of the best known header:
  the node could not reorg away from it before background validation ends.

Dash adaptations:
- The snapshot metadata carries no base height in this tree (bitcoin#29612 is not
  ported), so the check takes the height from the base's block index entry.
- As upstream, the check runs once at load; it is not part of
  SnapshotActivationRefusal(), which is repeated at the switch. It follows
  that function's checks, so an invalid base is reported as such first, as
  upstream orders its invalid-chain check before this one.
- The unit cases reconsider the base through reconsiderblock or
  ResetBlockFailureFlags(), which restores the best header that
  invalidating it moved back (the previous commit). Invalidating an
  equal-work sibling of the base still leaves the best header below the
  base, as the rest of bitcoin#30666 is not ported, so that case reconsiders the
  base again before loading.

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

49d569c p2p: For assumeutxo, download snapshot chain before background chain
7a88551 p2p: Restrict downloading of blocks for snapshot chain

Pull request description:

  Download the snapshot chain's blocks first by resetting the last common
  block of each peer to at least the snapshot base, and do not download
  from peers whose best chain lacks the snapshot base, since the node could
  not reorg to their chain before background validation ends.

Upstream adds no test; the functional rows that sync a snapshot node from
n0 cover the download order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…operate on snapshot chainstate

917e70a test: assumeutxo: check that UTXO-querying RPCs operate on snapshot chainstate

Pull request description:

  Inspired by some manual testing I did for bitcoin#28553, this PR checks that RPCs which explicitly query the UTXO set database (i.e. `gettxoutsetinfo`, `scantxoutset` and `gettxout`) operate on the snapshot chainstate as expected.

Applies unchanged. In Dash both RPCs also flush the snapshot chainstate's
Evo state from the RPC thread while the background chainstate runs.

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

992f83b test: add coverage for assumeUTXO honest peers disconnection
6d5812e assumeUTXO: fix peers disconnection during sync

Pull request description:

  A node with a snapshot chainstate advertised NODE_NETWORK although it
  cannot serve the blocks below the base, so IBD peers requested them, got
  no answer and disconnected it as stalling. loadtxoutset now replaces
  NODE_NETWORK with NODE_NETWORK_LIMITED, startup does not set NODE_NETWORK
  while background sync is in progress, and NODE_NETWORK returns when
  background validation completes (restart_indexes becomes
  snapshot_download_completed).

Dash adaptations:
- Snapshots are refused on pruned nodes here, so feature_assumeutxo.py's n1
  is a full node: its checks expect NODE_NETWORK_LIMITED only while it is in
  dual mode and NODE_NETWORK again after completion, as for n2, instead of
  upstream's pruned-node checks.
- The waits for NODE_NETWORK in test_sync_from_assumeutxo_node, after the
  base block is stored, and in the n2 row, after completion, are
  bitcoin#30880's 19f4a7c (test: Wait for local services to
  update in feature_assumeutxo), folded in here. The n1 row waits the same
  way: the callback that restores NODE_NETWORK runs after the step that
  disabled the background chainstate, which getchainstates can already
  reflect.
- A snapshot rejected at completion does not restore NODE_NETWORK: the
  rejection requests a shutdown, and the next startup computes the service
  flags again.

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

c0a0c72 validation: Disable CheckForkWarningConditions for background chainstate

Pull request description:

  The background chainstate's tip lags far behind, so comparing it with the
  best invalid block raised a fork warning for a fork that the active chain
  does not have.

Dash adaptations:
- feature_assumeutxo_dash.py's dual-mode scenario invalidates the block
  with the spend conflicting with an InstantSend lock and checks that the
  warnings lack "We do not appear to fully agree" after the background
  chainstate connected blocks below it.
- As upstream until bitcoin#30214, the step that completes background validation
  reports NORMAL, so that one step still evaluates the condition; the next
  active step resets it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_tx_count, Improve wallet RPC errors

9d2d9f7 rpc: Include assumeutxo as a failure reason of rescanblockchain
595edee test, assumeutxo: import descriptors during background sync
d73ae60 rpc: Improve importdescriptor RPC error messages
27f99b6 validation: Don't assume m_chain_tx_count in GuessVerificationProgress
42d5d53 interfaces: Add helper function for wallet on pruning

Pull request description:

  GuessVerificationProgress() can legitimately see a block without a
  transaction count, e.g. a wallet rescan below a snapshot base, so it
  returns 0 with a debug log instead of an Assume. importdescriptors and
  rescanblockchain name the assumeutxo background sync as the likely cause
  when blocks are unavailable.

Dash adaptations:
- 42d5d53 (Chain::getPruneHeight) is not ported: it needs GetPruneHeight()
  from bitcoin#29668, which this tree lacks. rescanblockchain therefore reports
  pruning whenever the node has pruned, as before; a node with a snapshot
  chainstate never prunes here, so the assumeutxo message is unaffected.
- m_chain_tx_count is nChainTx in this tree; the log names dashd.

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

bitcoin#33604 is not adopted. Before the restart that promotes a validated
snapshot, Dash cannot disconnect below the base's carried Evo state, so
downloading from such peers only stalls and churns the chain. bitcoin#29519's
refusal, which keys on the snapshot base, already lasts until promotion here,
because no snapshot base exists after the promoting restart.

Its test is replaced by this one. The snapshot node, validated but not yet
restarted, still reports its snapshot base in getchainstates. It refuses a
peer whose more-work chain forks below the base, without an Evo state error,
and keeps its tip. The restart promotes it, so getchainstates no longer
reports a snapshot base, and it then reorgs to that chain below the old base,
through the validated chainstate's Evo state. The fork is mined to a fresh
address: with the mock time fixed, the usual address would rebuild the block
just invalidated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bitcoin#29519's download refusal only covers FindNextBlocksToDownload. A chain
forking below the snapshot base still reaches the snapshot chainstate's
candidates when its blocks arrive another way (direct fetch of a short
fork, submitblock, blocks already on disk) once their parents below the
base are linked, which the background chainstate's progress provides. The
snapshot chainstate then disconnected its blocks down towards the base
until it stalled on Evo state below the base that it does not have, before
or after background validation reached the base, and reconnected them.

FindMostWorkChain now passes over candidates that do not descend from the
base while the snapshot chainstate's chain contains it. They stay in
setBlockIndexCandidates, and after the restart that promotes the snapshot
there is no base and the node follows them.

The test submits a more-work chain forking below the base to a snapshot
node whose background chainstate has not reached the base, and to one
that has validated it; both keep their tip without disconnecting a
block. After the promoting restart the node downloads a block of that
chain it has not seen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5cd5794 test: verify node state after restart in assumeutxo

Pull request description:

  Replace the TODO after the restart during background sync with checks of
  the chainstates and of wallet loading, which still needs the blocks below
  the snapshot.

Dash adaptations:
- The pruned-node rows that use the same error helper are absent: a node
  does not load snapshots with -prune in this tree.
- A blank line precedes the nested helper, for this tree's flake8 (E306).

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

faa68ed test: Fix intermittent issue in wallet_assumeutxo.py

Pull request description:

  -stopatheight may let a few more blocks through during shutdown. Sync the
  node to the pause height with submitblock instead of restarting it, and
  unload the wallets so the loading checks still apply.

Dash adaptations:
- setup_network() keeps its form; the pruned-node rows are absent, as for
  bitcoin#34286.

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

faf71d6 test: [refactor] Use verbosity=0 named arg
99996f6 test: Fix intermittent issue in feature_assumeutxo.py

Pull request description:

  Sync n1 to the pause height with submitblock instead of a -stopatheight
  restart, which could stop a few blocks later than expected.

Dash adaptations:
- The blockfile segmentation checks between the two hunks are absent, as
  the segmentation is not part of this tree (bitcoin#27596's commit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions for background chainstate

Invalidate the block before the background chainstate connects its blocks,
so each of its fork-warning checks sees an invalid chain with more work
than its tip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mainnet at height 2579482 and testnet at height 1599687, each with the
UTXO set hash, the v4 evo section hash, the chain transaction count and
the base block hash of a dumptxoutset run.

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

With pinned snapshots for mainnet and testnet, loadtxoutset is useful
outside regtest. Drop the regtest-only guards of loadtxoutset and
getchainstates and list them, together with dumptxoutset, in the
blockchain category instead of hiding them.

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

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

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

New on this head: This head pins one AssumeUTXO snapshot for mainnet and testnet, exposes the snapshot RPCs on supported networks, and documents the resulting behavior after the rebase. The main and ClangFormat checks passed; no code check has failed, while the review and skip-condition checks remain in progress or queued.

🟡 2 suggestion(s)

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

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

🟡 Suggestion: The release-note correction is split from the commit that introduced the release note
Impact: Future git log and git blame users see the release note as an initially incorrect file that is corrected only in a later commit.
<commit:2d8a07b>:1

The final tree is correct, but the current history still introduces doc/release-notes-pins.md with (#pins) in a896e94de97, then renames it to doc/release-notes-8276.md and changes the marker to (#8276) in 2d8a07bab49. These documentation edits have no independent milestone, so fold the final filename and PR reference into the introducing commit before the stack becomes permanent.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-astra (phase2-reviewer: general)

🟡 Suggestion: Twelve review-only fixup! commits remain between the logical changes
Impact: Maintainers bisecting or tracing the AssumeUTXO and Evo changes must traverse numerous corrective commits that do not represent durable history boundaries.
<commit:f35e0f2>:1

The current stack still contains 51 fixup! or amend! commits interleaved with substantive Evo, validation, LLMQ, and AssumeUTXO changes. These commits are corrections to earlier commits in the same stack rather than independently meaningful milestones, which makes git log, git blame, and future bisection noisier; autosquash the review corrections into their substantive targets before merging.

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: gpt-6.2-astra (agent: phase2-reviewer, role: dash-core-commit-history); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This is a large, intricate change that modifies consensus validation and chainstate/storage behavior in validation.cpp, src/node/chainstate.cpp, and related AssumeUTXO snapshot loading and promotion paths.
  • 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)
  • 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:2d8a07b>`:
- [SUGGESTION] <commit:2d8a07b>:1: The release-note correction is split from the commit that introduced the release note
  Impact: Future git log and git blame users see the release note as an initially incorrect file that is corrected only in a later commit.
  The final tree is correct, but the current history still introduces `doc/release-notes-pins.md` with `(#pins)` in `a896e94de97`, then renames it to `doc/release-notes-8276.md` and changes the marker to `(#8276)` in `2d8a07bab49`. These documentation edits have no independent milestone, so fold the final filename and PR reference into the introducing commit before the stack becomes permanent.

In `<commit:f35e0f2>`:
- [SUGGESTION] <commit:f35e0f2>:1: Twelve review-only `fixup!` commits remain between the logical changes
  Impact: Maintainers bisecting or tracing the AssumeUTXO and Evo changes must traverse numerous corrective commits that do not represent durable history boundaries.
  The current stack still contains 51 `fixup!` or `amend!` commits interleaved with substantive Evo, validation, LLMQ, and AssumeUTXO changes. These commits are corrections to earlier commits in the same stack rather than independently meaningful milestones, which makes `git log`, `git blame`, and future bisection noisier; autosquash the review corrections into their substantive targets before merging.

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

Labels

pastaclaw:approved thepastaclaw's latest review approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants