Skip to content

refactor: drop dependency of evo/specialtxman on validation.h - #7668

Open
knst wants to merge 15 commits into
dashpay:developfrom
knst:refactor-specialtx-validation
Open

refactor: drop dependency of evo/specialtxman on validation.h#7668
knst wants to merge 15 commits into
dashpay:developfrom
knst:refactor-specialtx-validation

Conversation

@knst

@knst knst commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

One more circular dependency is trivial to avoid.

What was done?

  • make CheckSpecialTxInner member of CSpecialTxProcessor
  • use m_consensus_params instead of m_chainman.GetConsensus() in CSpecialTxProcessor
  • pass GetBlockSubsidy to CSpecialTxProcessor and avoid its recalculation twice
  • hold BlockManager in CSpecialTxProcessor instead of chainman.m_blockman
  • pass BlockManager to CheckMNHFTx instead of ChainstateManager
  • drop validation.h from mnhftx.cpp
  • pass consensus params and is_v24_active to CheckPro-Txs
  • pass is_v24_active into CheckSpecialTx
  • pass is_v24_active into BuildNewListFromBlock/RebuildListFromBlock
  • pass is_v24_active into ProcessSpecialTxsInBlock
  • pass CChain into ProcessSpecialTxsInBlock
  • record the background MN list hash from ConnectBlock
  • return the MN list once through MNListUpdates
  • break circular dependency over specialtxman and validation.h
  • remove unused includes from specialtxman.cpp and related files

It helps to break circular dependency over evo/specialtxman <-> validation and reveal other circular dependencies that has been hidden by this short cycle.

NOTE: once v24 is buried deployment, some code could be re-refactored and simplified because chainman is not needed for buried deployments.

How Has This Been Tested?

Run & updated test/lint/lint-circular-dependencies.py

Breaking Changes

N/A

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

knst added 10 commits September 8, 2026 23:29
It doesn't change logic but simplify further refactoring and reduces conflicts with other PRs in the future
…ecalculation twice

GetBlockSubsidy is leightful helper and appears in perf as responsible for only 0.01% of calculation, so, commit is not threated as any noticeable performance improvement
CheckSpecialTxInner still evaluates the flag from m_chainman for now and the next step is moving that to its callers
@knst knst added this to the 24 milestone Sep 8, 2026
@thepastaclaw

thepastaclaw commented Sep 8, 2026

Copy link
Copy Markdown

🕓 Queued for automated review — 52nd in line, estimated start in ~48 h (commit 4a1b3b7)
Estimated review time once started: ~1.9 h (two-phase automated review; median of recent runs).

  • Request priority review — tick this box and the review moves to the front of the queue.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4aabba1a-5dc1-447c-a89e-ad46e2deb9f4

📥 Commits

Reviewing files that changed from the base of the PR and between 08525d6 and 4a1b3b7.

📒 Files selected for processing (21)
  • src/evo/chainhelper.cpp
  • src/evo/chainhelper.h
  • src/evo/creditpool.h
  • src/evo/deterministicmns.cpp
  • src/evo/deterministicmns.h
  • src/evo/mnhftx.cpp
  • src/evo/mnhftx.h
  • src/evo/providertx_service.cpp
  • src/evo/specialtxman.cpp
  • src/evo/specialtxman.h
  • src/init.cpp
  • src/node/chainstate.cpp
  • src/node/miner.cpp
  • src/rpc/evo.cpp
  • src/test/evo_deterministicmns_tests.cpp
  • src/test/evo_mnhf_tests.cpp
  • src/test/evo_trivialvalidation.cpp
  • src/test/util/setup_common.cpp
  • src/test/validation_chainstatemanager_tests.cpp
  • src/validation.cpp
  • test/lint/lint-circular-dependencies.py

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


Walkthrough

The change removes several ChainstateManager dependencies from masternode and special-transaction processing. APIs now receive node::BlockManager, Consensus::Params, V24 activation state, block subsidy, chain context, and direct MNListUpdates outputs. Block validation records masternode-list hashes explicitly and notifies listeners only when diffs contain changes. Constructors and call sites were updated across initialization, mining, RPC repair, validation, and tests.

Priority: ➖ Normal — Schedule the special-transaction refactor because it changes consensus validation, masternode-list processing, deployment handling, and block-context plumbing across core paths.

Estimated code review effort: 4 (Complex) | ~60 minutes

Merge Risk: ⚪ Minimal · up to 4a1b3

The explicit consensus-context refactor has no identified merge-blocking behavior regression.

Sequence Diagram(s)

sequenceDiagram
  participant MemPoolAccept
  participant CSpecialTxProcessor
  participant ConsensusParams
  participant Chainstate
  MemPoolAccept->>ConsensusParams: Determine V24 activation
  MemPoolAccept->>CSpecialTxProcessor: Check special transaction
  CSpecialTxProcessor->>Chainstate: Validate against chain context
  CSpecialTxProcessor-->>MemPoolAccept: Return validation result
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.49% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 78 functions across 21 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the primary change: removing the dependency of evo/specialtxman on validation.h through a refactor.
Description check ✅ Passed The description directly explains the dependency refactor, API changes, masternode list updates, circular-dependency lint changes, and testing performed.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Potential PR merge conflicts

This is advisory only. It does not block CI, but it marks PRs that will likely need a rebase depending on merge order.

If these PRs merge first

This PR will likely need a rebase:

knst added 5 commits September 9, 2026 02:53
ProcessSpecialTxsInBlock called Chainstate::RecordBackgroundMNListHash, the last reason it needed the complete Chainstate type.
Make MNListUpdates the single non-optional result: ProcessBlock always fill it and consumers checks if there's actually diff non-empty by call of diff.HasChanges() instead of the checking optional.
Copying an unchanged list is leightful operation due to using immer maps data-structure.
There's several new exception has been added to the list of existing circular dependencies: all of them had been pre-existing but now they are discovered by removing the shorter loop specialtxman <-> validation
@knst
knst force-pushed the refactor-specialtx-validation branch from 4a1b3b7 to f932324 Compare September 8, 2026 19:54
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