Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/gtest/test_checktransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }));
}
Expand Down Expand Up @@ -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; });
}
Expand Down Expand Up @@ -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; });
}
Expand Down
11 changes: 8 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading