Skip to content

Commit 5b4d7bf

Browse files
Merge #7447: test: cover DIP-0023 MnEHF version-bit reuse in IsValidMNActivation
06b90f3 test: cover DIP-0023 MnEHF version-bit reuse in IsValidMNActivation (UdjinM6) Pull request description: ## Issue being fixed or feature implemented Add a unit test asserting that a historical MnEHF signal for a buried deployment stays valid on reindex after its version bit is reused by a newer deployment whose window has not started yet, as DIP-0023 permits. ## What was done? The test reconfigures the permanent `testdummy` deployment (never buried) as an EHF deployment with a future window and checks that a query before that window is still accepted. It passes on current behavior and fails if `IsValidMNActivation()` starts rejecting known-but-out-of-range bits. ## How Has This Been Tested? ## Breaking Changes ## 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)_ ACKs for top commit: PastaPastaPasta: utACK 06b90f3 Tree-SHA512: 2ef42df67635bb1aae595ff440bd463f211013a55a3af1fc7f0d8ae7b62aa83035c28d6c7b71362e888627bd409ca492cde8658ad7683a5537ce41bc0eb0438c
2 parents ecf2382 + 06b90f3 commit 5b4d7bf

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

src/test/evo_mnhf_tests.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <bls/bls.h>
6+
#include <chainparams.h>
7+
#include <consensus/params.h>
68
#include <consensus/validation.h>
79
#include <evo/mnhftx.h>
810
#include <evo/specialtx.h>
@@ -83,4 +85,52 @@ BOOST_AUTO_TEST_CASE(verify_mnhf_specialtx_tests)
8385
}
8486
}
8587

88+
/**
89+
* Reconfigure the permanent "testdummy" deployment (never buried, present on
90+
* every network) as an EHF deployment with a window entirely in the future.
91+
* This stands in for a version bit that has just been *reused* by a newer
92+
* deployment: DIP-0023 allows a later deployment to reuse a bit as long as its
93+
* window is later than the previous one's. We deliberately avoid referencing a
94+
* real deployment such as v24 here, since those get buried and removed from
95+
* vDeployments over time, which would break this fixture.
96+
*/
97+
struct MnhfBitReuseSetup : public RegTestingSetup {
98+
MnhfBitReuseSetup()
99+
: RegTestingSetup{{"-vbparams=testdummy:2000000000:9223372036854775807:0:250:200:150:5:1"}}
100+
{
101+
}
102+
};
103+
104+
/**
105+
* DIP-0023 bit reuse: Dash buries old deployments and drops them from
106+
* vDeployments, so on reindex a historical MnEHF signal for a buried deployment
107+
* must stay valid even after its bit is reused by a newer deployment whose
108+
* window has not started yet.
109+
*
110+
* Here the reused bit (testdummy) has a future window. A query at a time before
111+
* that window represents revalidating a buried signal mined by the earlier (now
112+
* removed) deployment that owned the bit. The out-of-range check runs before the
113+
* useEHF check, so this exercises the same code path regardless of useEHF; we
114+
* still set useehf=1 above so the scenario matches a reused EHF bit exactly.
115+
*
116+
* On unpatched develop IsValidMNActivation() returns true for this case (the
117+
* out-of-range deployment is skipped and the unknown-bit fallback accepts it),
118+
* so the block stays valid on reindex. PR #7446 makes it return false, which
119+
* rejects a block that was accepted before the reuse -> consensus divergence.
120+
*/
121+
BOOST_FIXTURE_TEST_CASE(mnhf_bit_reuse_reindex_tests, MnhfBitReuseSetup)
122+
{
123+
const CChainParams& params = Params();
124+
const auto& reused = params.GetConsensus().vDeployments[Consensus::DEPLOYMENT_TESTDUMMY];
125+
const int reused_bit = reused.bit;
126+
const int64_t before_window = reused.nStartTime - 1; // buried-signal era, before the reuse window
127+
128+
// Sanity: a genuinely unknown/retired bit still validates (unchanged fallback).
129+
BOOST_CHECK(params.IsValidMNActivation(/*nBit=*/5, before_window));
130+
131+
// Bit reuse: the buried signal predates the reused deployment's window.
132+
// DIP-0023 compatibility requires it to remain valid on reindex.
133+
BOOST_CHECK(params.IsValidMNActivation(reused_bit, before_window));
134+
}
135+
86136
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)