Skip to content

test: wait for the ChainLocked block to connect in feature_llmq_is_cl_conflicts - #8274

Merged
PastaPastaPasta merged 1 commit into
dashpay:developfrom
PastaPastaPasta:fix/is-cl-conflicts-race
Nov 28, 2026
Merged

PastaPastaPasta merged 1 commit into
dashpay:developfrom
PastaPastaPasta:fix/is-cl-conflicts-race

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

feature_llmq_is_cl_conflicts.py fails in CI's ASan job at line 271 (assert tip["status"] == "active"), three attempts in a row, on PRs based on current develop. Two races on develop cause failures in this test; neither is a node bug.

  1. A node reports a new best ChainLock before it has reconnected the locked block. EnforceBestChainLock marks the conflicting tip and calls ActivateBestChain in separate cs_main sections, and ActivateBestChain first waits for the validation queue when more than ten callbacks are pending. test_chainlock_overrides_islock waits for getbestchainlock, then checks getchaintips, and can land in that gap. Since fix: reject InstantSend locks with a noncanonical version or cycle hash #8101 added test_isdlock_encoding, about eleven unmined transactions reach this subtest's reorg, which returns them to the mempool, so the gap lasts about 100-200 ms under ASan. In the CI logs, getchaintips ran 70 ms before the locked block was connected.
  2. test_chainlock_overrides_islock_overrides_nonchainlock sends the CLSIG while the re-enabled SPORK_19_CHAINLOCKS_ENABLED is still propagating. A node that gets the CLSIG before the spork drops it and never requests it again, so the test times out waiting for the ChainLocked block.

What was done?

  • After the best ChainLock is visible, wait until the locked block is on every node's active chain (wait_for_chainlocked_block_all_nodes) before checking the chain tips. Only when the nodes already have the block (test_block_conflict).
  • Re-enable ChainLocks with SPORK_19_CHAINLOCKS_ENABLED=1 (accept and enforce, but don't sign), so no node can lock the InstantSend-locked tip first, and send the CLSIG over P2P only once every node has the spork.

How Has This Been Tested?

On a 16-vCPU Linux box with CI's ASan/UBSan flags (clang 19, --timeout-factor=4, datadirs on /dev/shm):

  • A variant that polls node0 right after the CLSIG saw the gap (best ChainLock set, block still valid-headers) in every run, on develop and on this branch's base alike.
  • With the first change plus a direct submitchainlock to every node (the earlier version of the second change), 39 runs had no failure of either assertion. With the current P2P version, 4 of 4 local runs passed. The only failures were test_isdlock_encoding InstantSend-lock timeouts, which happen at the same rate on develop and are not touched here.
  • The unmodified test did not fail the line-271 assertion locally in about 90 runs; CI runners are slower, which is where it shows up.

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

🤖 Generated with Claude Code

@PastaPastaPasta PastaPastaPasta added this to the 24.1 milestone Nov 27, 2026
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The tests now wait for every node to recognize a conflicting block as ChainLocked. In another test, they set the ChainLocks spork value to 1, wait for the update to propagate to all nodes, and then relay the ChainLock.

Estimated code review effort: 2 (Simple) | ~8 minutes

Merge Risk: Minimal · up to b6315

This change only makes a functional test more reliable by removing two timing races. It does not alter production behavior, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a test fix in feature_llmq_is_cl_conflicts that waits for the ChainLocked block to connect. The raw summary and objectives confirm the test now waits for the locked bl…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is specific and relevant to the changeset. It names the test file feature_llmq_is_cl_conflicts.py and the two races it addresses. It describes the changes: waiting for the locked block…
Full details: Title check

Explanation

The title names the main change: a test fix in feature_llmq_is_cl_conflicts that waits for the ChainLocked block to connect. The raw summary and objectives confirm the test now waits for the locked block on all nodes before checking chain tips. It is specific and matches the changeset.

Full details: Description check

Explanation

The description is specific and relevant to the changeset. It names the test file feature_llmq_is_cl_conflicts.py and the two races it addresses. It describes the changes: waiting for the locked block on all nodes via wait_for_chainlocked_block_all_nodes before checking chain tips, and re-enabling ChainLocks with SPORK_19_CHAINLOCKS_ENABLED=1 before sending the CLSIG over P2P. It also gives test evidence. The raw summary matches these claims. The description therefore passes the lenient relatedness check.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 90d5f6d0-b0bb-44ed-834a-8f62077951b8
Commits

Reviewing files that changed from the base of the PR and between 88d7dd4 and b6315f3.

Files selected for processing: 1

  • test/functional/feature_llmq_is_cl_conflicts.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@thepastaclaw

thepastaclaw commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit b6315f3) · triage: low · Phase 2 only (queue backlog)

thepastaclaw
thepastaclaw previously approved these changes Nov 27, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 2 only (queue backlog)

The conflict test now waits for the ChainLocked block to enter every node’s active chain before checking chain tips, and submits the final ChainLock directly after the spork update propagates. ClangFormat and the CI skip-condition check are queued, with no completed build or functional-test result on this head. The recorded milestone failure is a PR policy check, not a code failure.

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

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: low by gpt-6.2-sol (effort low) — The six-line change is confined to one functional test and addresses two timing races by waiting for block activation and submitting the ChainLock after spork propagation, without changing node behavior.
  • Phase 1 reviewers: not run (skipped for throughput: 18 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 medium); agent phase2-reviewer, gpt-6.2-sol — dash-core-commit-history (completed, effort medium); 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 `test/functional/feature_llmq_is_cl_conflicts.py`:
- [SUGGESTION] test/functional/feature_llmq_is_cl_conflicts.py:394-399: The final conflict subtest can pass without any peer receiving the ChainLock over P2P
  Impact: A regression that prevents peers from receiving the ChainLock after re-enablement would no longer fail this subtest.
  The final assertions can pass even if the P2P announcement never delivers the signature. The new loop calls `submitchainlock` on every node, which invokes `ProcessNewChainLock` directly and bypasses the P2P receive path. Set `SPORK_19_CHAINLOCKS_ENABLED` to `1` instead: this existing mode lets nodes receive and enforce ChainLocks without automatically signing the competing tip. Wait for the spork to propagate, then announce the signature once over P2P and keep the per-node assertions.

@thepastaclaw thepastaclaw added the pastaclaw:approved thepastaclaw's latest review approved this PR label Nov 27, 2026
…_conflicts

A node reports the new best ChainLock before enforcing it reconnects the
locked block: EnforceBestChainLock marks the conflicting tip and calls
ActivateBestChain in separate cs_main sections, and ActivateBestChain
first waits for the validation queue when a reorg put more than ten
callbacks on it. test_chainlock_overrides_islock checked getchaintips in
that gap and could find the locked block not yet active. Since
test_isdlock_encoding leaves unmined transactions that this subtest's
reorg returns to the mempool, the gap is long enough to hit under ASan.
Wait until the locked block is on every node's active chain.

test_chainlock_overrides_islock_overrides_nonchainlock sent the CLSIG
while the re-enabled SPORK_19 was still propagating, and a node that
received it first dropped it and never asked again. Enable ChainLocks
without signing instead, so no node locks the InstantSend-locked tip
first, and send the CLSIG only once every node has the spork.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PastaPastaPasta
PastaPastaPasta force-pushed the fix/is-cl-conflicts-race branch from 88d7dd4 to b6315f3 Compare November 27, 2026 23:55
@thepastaclaw thepastaclaw removed the pastaclaw:approved thepastaclaw's latest review approved this PR label Nov 27, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

New on this head: This revision waits for every node to activate the ChainLocked block before checking chain tips. In the final subtest, it waits for the accept-without-signing spork value to reach every node before announcing the ChainLock over P2P. GitHub reports no failed checks; ClangFormat and Check skip conditions are pending, and no build or functional-test result is reported yet.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

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: low by gpt-6.2-sol (effort low) — This is a small, self-contained functional-test synchronization fix that changes no production behavior or critical code paths.
  • Phase 1 reviewers: not run (skipped for throughput: 17 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 medium); agent phase2-reviewer, gpt-6.2-sol — dash-core-commit-history (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@thepastaclaw thepastaclaw added the pastaclaw:approved thepastaclaw's latest review approved this PR label Nov 28, 2026
@PastaPastaPasta
PastaPastaPasta merged commit e6309da into dashpay:develop Nov 28, 2026
54 checks passed
@thepastaclaw thepastaclaw removed the pastaclaw:approved thepastaclaw's latest review approved this PR label Nov 28, 2026
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
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.

2 participants