diff --git a/src/gtest/test_checktransaction.cpp b/src/gtest/test_checktransaction.cpp index 481f021f71f..7ad3f07ded6 100644 --- a/src/gtest/test_checktransaction.cpp +++ b/src/gtest/test_checktransaction.cpp @@ -167,8 +167,8 @@ TEST(checktransaction_tests, BadTxnsOversize) { MockCValidationState state; EXPECT_TRUE(CheckTransactionWithoutProofVerification(tx, state)); - // ... but fails contextual ones! (Force IBD off: ZClassic skips - // ContextualCheckTransaction during initial block download.) + // ... but fails contextual ones! (isInitBlockDownload() is forced false + // here; with the CR-01 fix the contextual checks also run during IBD.) EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-oversize", false, ::testing::_)).Times(1); EXPECT_FALSE(ContextualCheckTransaction(tx, state, 1, 100, []() { return false; })); } @@ -528,10 +528,9 @@ TEST(checktransaction_tests, bad_txns_invalid_joinsplit_signature) { CTransaction tx(mtx); MockCValidationState state; - // ZClassic skips ContextualCheckTransaction entirely during initial block - // download (see commit "speed up initial sync"), so no DoS is reported in - // IBD. Once IBD has finished, the invalid joinsplit signature is rejected - // with the full DoS ban score. + // Contextual checks now run during IBD too (CR-01 fix); only the DoS ban + // score is reduced while syncing. The invalid joinsplit signature is + // rejected with the full DoS ban score. EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false, ::testing::_)).Times(1); ContextualCheckTransaction(tx, state, 0, 100, []() { return false; }); } @@ -565,10 +564,9 @@ TEST(checktransaction_tests, non_canonical_ed25519_signature) { CTransaction tx(mtx); MockCValidationState state; - // ZClassic skips ContextualCheckTransaction entirely during initial block - // download (see commit "speed up initial sync"), so no DoS is reported in - // IBD. Once IBD has finished, the non-canonical signature is rejected with - // the full DoS ban score. + // Contextual checks now run during IBD too (CR-01 fix); only the DoS ban + // score is reduced while syncing. The non-canonical signature is rejected + // with the full DoS ban score. EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false, ::testing::_)).Times(1); ContextualCheckTransaction(tx, state, 0, 100, []() { return false; }); } diff --git a/src/main.cpp b/src/main.cpp index eb98a68c72d..49068552a14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -955,9 +955,14 @@ bool ContextualCheckTransaction( const int dosLevel, bool (*isInitBlockDownload)()) { - if (isInitBlockDownload()) { - return true; - } + // CR-01 fix: never skip contextual consensus checks during IBD / import / + // reindex. The previous early return here (when isInitBlockDownload() was + // true) bypassed tx version/activation enforcement, JoinSplit Ed25519 + // signature verification, and ALL Sapling spend/output/binding checks — a + // node-state-dependent consensus validation bypass (a syncing node could + // accept a block path a fully-synced node would reject). The DoS ban scores + // below stay reduced while syncing (isInitBlockDownload() ? 0 : ...), but + // the consensus checks themselves now always run. bool overwinterActive = Params().GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_OVERWINTER); bool saplingActive = Params().GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_SAPLING); bool isSprout = !overwinterActive;