fix(evo): validate ProUpServTx nType at mempool acceptance - #7488
Draft
PastaPastaPasta wants to merge 2 commits into
Draft
fix(evo): validate ProUpServTx nType at mempool acceptance#7488PastaPastaPasta wants to merge 2 commits into
PastaPastaPasta wants to merge 2 commits into
Conversation
Add unit coverage for the mempool-vs-block consensus divergence: CProUpServTx::IsTriviallyValid and CheckProUpServTx must reject out-of-range and mismatched nType the same way BuildNewListFromBlock already does.
Mirror CProRegTx and BuildNewListFromBlock: reject out-of-range nType in CProUpServTx::IsTriviallyValid, and reject type mismatches in CheckProUpServTx. Closes the mempool/block divergence that let a single ProUpServTx stall getblocktemplate.
|
This pull request has conflicts, please rebase. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue being fixed or feature implemented
CProUpServTx::IsTriviallyValid()never validatesnType, andCheckProUpServTx()neverchecks it against the registered masternode.
BuildNewListFromBlock()checks both(
specialtxman.cpp:413-417).That asymmetry is a mempool-vs-block divergence. A ProUpServTx with an out-of-range
nType,or one whose
nTypedisagrees with the masternode it targets, is accepted into the mempoolbut can never be mined. Once such a transaction is in a miner's mempool, block assembly
throws and
getblocktemplatestops producing templates — for every node that accepted thetransaction, from a single relayed message.
What was done?
Added the two checks that
BuildNewListFromBlock()already performs, at mempool acceptance:CProUpServTx::IsTriviallyValid()rejects an out-of-rangenTypewithbad-protx-type.This mirrors what
CProRegTx::IsTriviallyValid()already does (providertx.cpp:144), sothe two payload types are now consistent.
CheckProUpServTx()rejectsnTypemismatch against the registered masternode withbad-protx-type-mismatch, and re-checks validity withbad-protx-type.Both reject reasons are deliberately identical to the ones
BuildNewListFromBlock()alreadyuses, so a rejection reads the same regardless of which layer catches it.
Why this is not a consensus change
The block-connect path already rejected exactly these transactions, so nothing that was
previously block-valid becomes block-invalid. The change only moves the rejection earlier,
to the layer that was missing it. No transaction with these properties can exist in any
chain's history, because it could never have been connected.
How Has This Been Tested?
Unit tests added in the commit preceding the fix:
src/test/evo_trivialvalidation.cpp—proupserv_rejects_invalid_ntype, coveringnTypevalues 42 and 65535.src/test/evo_deterministicmns_tests.cpp—proupserv_invalid_ntype_basic, which drivesthe transaction through real mempool acceptance and asserts both the rejection and the
reject reason, then confirms
CheckProUpServTx()agrees.Without the fix these produce 6 and 9 failures respectively; notably the mempool test shows
the transaction being accepted, and the mismatch case reporting
protx-dupinstead ofbad-protx-type-mismatch. With the fix,evo_trivialvalidation(4 cases) andevo_dip3_activation_tests(19 cases) both pass.Built and run on macOS/arm64 against current
develop.Breaking Changes
None. Relaying such a transaction now earns a
TX_CONSENSUSrejection, which is theintended treatment — it could never have been mined.
Known follow-up
Coverage here is C++ unit level only. A functional test driving the divergence through a
real miner's
getblocktemplatewould be a worthwhile addition; happy to add one in this PRif reviewers would prefer it before merge.
Checklist: