Skip to content

Commit e80e4c6

Browse files
committed
validation: Remove RECENT_CONSENSUS_CHANGE validation result
The *_RECENT_CONSENSUS_CHANGE variants in the validation result enumerations were always unused. They seem to have been kept around speculatively for a soft fork after segwit, however they were never used for taproot either. This points at them not having a clear purpose. Based on the original pull requests' comments their usage was never entirely clear: bitcoin/bitcoin#11639 (comment) bitcoin/bitcoin#15141 (comment) Since they are part of the validation interface and need to exposed by the kernel library keeping them around may also be confusing to future users of the library.
1 parent 018e5fc commit e80e4c6

7 files changed

+2
-32
lines changed

src/bitcoin-chainstate.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,6 @@ int main(int argc, char* argv[])
253253
case BlockValidationResult::BLOCK_CONSENSUS:
254254
std::cerr << "invalid by consensus rules (excluding any below reasons)" << std::endl;
255255
break;
256-
case BlockValidationResult::BLOCK_RECENT_CONSENSUS_CHANGE:
257-
std::cerr << "Invalid by a change to consensus rules more recent than SegWit." << std::endl;
258-
break;
259256
case BlockValidationResult::BLOCK_CACHED_INVALID:
260257
std::cerr << "this block was cached as being invalid and we didn't store the reason why" << std::endl;
261258
break;

src/consensus/validation.h

-16
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ static constexpr size_t MINIMUM_WITNESS_COMMITMENT{38};
2323
enum class TxValidationResult {
2424
TX_RESULT_UNSET = 0, //!< initial value. Tx has not yet been rejected
2525
TX_CONSENSUS, //!< invalid by consensus rules
26-
/**
27-
* Invalid by a change to consensus rules more recent than SegWit.
28-
* Currently unused as there are no such consensus rule changes, and any download
29-
* sources realistically need to support SegWit in order to provide useful data,
30-
* so differentiating between always-invalid and invalid-by-pre-SegWit-soft-fork
31-
* is uninteresting.
32-
*/
33-
TX_RECENT_CONSENSUS_CHANGE,
3426
TX_INPUTS_NOT_STANDARD, //!< inputs (covered by txid) failed policy rules
3527
TX_NOT_STANDARD, //!< otherwise didn't meet our local policy rules
3628
TX_MISSING_INPUTS, //!< transaction was missing some of its inputs
@@ -65,14 +57,6 @@ enum class TxValidationResult {
6557
enum class BlockValidationResult {
6658
BLOCK_RESULT_UNSET = 0, //!< initial value. Block has not yet been rejected
6759
BLOCK_CONSENSUS, //!< invalid by consensus rules (excluding any below reasons)
68-
/**
69-
* Invalid by a change to consensus rules more recent than SegWit.
70-
* Currently unused as there are no such consensus rule changes, and any download
71-
* sources realistically need to support SegWit in order to provide useful data,
72-
* so differentiating between always-invalid and invalid-by-pre-SegWit-soft-fork
73-
* is uninteresting.
74-
*/
75-
BLOCK_RECENT_CONSENSUS_CHANGE,
7660
BLOCK_CACHED_INVALID, //!< this block was cached as being invalid and we didn't store the reason why
7761
BLOCK_INVALID_HEADER, //!< invalid proof of work or time too old
7862
BLOCK_MUTATED, //!< the block's data didn't match the data committed to by the PoW

src/net_processing.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,6 @@ void PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
17901790
case BlockValidationResult::BLOCK_MISSING_PREV:
17911791
if (peer) Misbehaving(*peer, message);
17921792
return;
1793-
case BlockValidationResult::BLOCK_RECENT_CONSENSUS_CHANGE:
17941793
case BlockValidationResult::BLOCK_TIME_FUTURE:
17951794
break;
17961795
}
@@ -1810,7 +1809,6 @@ void PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationStat
18101809
if (peer) Misbehaving(*peer, "");
18111810
return;
18121811
// Conflicting (but not necessarily invalid) data or different policy:
1813-
case TxValidationResult::TX_RECENT_CONSENSUS_CHANGE:
18141812
case TxValidationResult::TX_INPUTS_NOT_STANDARD:
18151813
case TxValidationResult::TX_NOT_STANDARD:
18161814
case TxValidationResult::TX_MISSING_INPUTS:

src/test/fuzz/partially_downloaded_block.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ FUZZ_TARGET(partially_downloaded_block, .init = initialize_pdb)
114114
fuzzed_data_provider.PickValueInArray(
115115
{BlockValidationResult::BLOCK_RESULT_UNSET,
116116
BlockValidationResult::BLOCK_CONSENSUS,
117-
BlockValidationResult::BLOCK_RECENT_CONSENSUS_CHANGE,
118117
BlockValidationResult::BLOCK_CACHED_INVALID,
119118
BlockValidationResult::BLOCK_INVALID_HEADER,
120119
BlockValidationResult::BLOCK_MUTATED,

src/test/fuzz/txdownloadman.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ COutPoint COINS[NUM_COINS];
3232
static TxValidationResult TESTED_TX_RESULTS[] = {
3333
// Skip TX_RESULT_UNSET
3434
TxValidationResult::TX_CONSENSUS,
35-
TxValidationResult::TX_RECENT_CONSENSUS_CHANGE,
3635
TxValidationResult::TX_INPUTS_NOT_STANDARD,
3736
TxValidationResult::TX_NOT_STANDARD,
3837
TxValidationResult::TX_MISSING_INPUTS,

src/test/txdownload_tests.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ struct Behaviors {
5858
// Txid and Wtxid are assumed to be different here. For a nonsegwit transaction, use the wtxid results.
5959
static std::map<TxValidationResult, Behaviors> expected_behaviors{
6060
{TxValidationResult::TX_CONSENSUS, {/*txid_rejects*/0,/*wtxid_rejects*/1,/*txid_recon*/0,/*wtxid_recon*/0,/*keep*/1,/*txid_inv*/0,/*wtxid_inv*/1}},
61-
{TxValidationResult::TX_RECENT_CONSENSUS_CHANGE, { 0, 1, 0, 0, 1, 0, 1}},
6261
{TxValidationResult::TX_INPUTS_NOT_STANDARD, { 1, 1, 0, 0, 1, 1, 1}},
6362
{TxValidationResult::TX_NOT_STANDARD, { 0, 1, 0, 0, 1, 0, 1}},
6463
{TxValidationResult::TX_MISSING_INPUTS, { 0, 0, 0, 0, 1, 0, 1}},

src/validation.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -2201,15 +2201,9 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
22012201
// string by reporting the error from the second check.
22022202
error = check2.GetScriptError();
22032203
}
2204+
22042205
// MANDATORY flag failures correspond to
2205-
// TxValidationResult::TX_CONSENSUS. Because CONSENSUS
2206-
// failures are the most serious case of validation
2207-
// failures, we may need to consider using
2208-
// RECENT_CONSENSUS_CHANGE for any script failure that
2209-
// could be due to non-upgraded nodes which we may want to
2210-
// support, to avoid splitting the network (but this
2211-
// depends on the details of how net_processing handles
2212-
// such errors).
2206+
// TxValidationResult::TX_CONSENSUS.
22132207
return state.Invalid(TxValidationResult::TX_CONSENSUS, strprintf("mandatory-script-verify-flag-failed (%s)", ScriptErrorString(error)));
22142208
}
22152209
}

0 commit comments

Comments
 (0)