Skip to content

Commit 69c0313

Browse files
committed
Merge bitcoin/bitcoin#31269: validation: Remove RECENT_CONSENSUS_CHANGE validation result
e80e4c6 validation: Remove RECENT_CONSENSUS_CHANGE validation result (TheCharlatan) Pull request description: 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 be exposed by the kernel library keeping them around may also be confusing to future users of the library. ACKs for top commit: sipa: ACK e80e4c6 naumenkogs: ACK bitcoin/bitcoin@e80e4c6 dergoegge: ACK e80e4c6 ajtowns: ACK e80e4c6 Tree-SHA512: 0af17c4435bb1b5a4f43600da30545cbbe95a7d642419cabdefabfb82b9335d92262c1c48be7ca2f2a024078ae9447161228b6f951d2f508a51159a31947fb54
2 parents 4228259 + e80e4c6 commit 69c0313

File tree

7 files changed

+2
-32
lines changed

7 files changed

+2
-32
lines changed

src/bitcoin-chainstate.cpp

Lines changed: 0 additions & 3 deletions
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

Lines changed: 0 additions & 16 deletions
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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,6 @@ void PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati
17921792
case BlockValidationResult::BLOCK_MISSING_PREV:
17931793
if (peer) Misbehaving(*peer, message);
17941794
return;
1795-
case BlockValidationResult::BLOCK_RECENT_CONSENSUS_CHANGE:
17961795
case BlockValidationResult::BLOCK_TIME_FUTURE:
17971796
break;
17981797
}
@@ -1812,7 +1811,6 @@ void PeerManagerImpl::MaybePunishNodeForTx(NodeId nodeid, const TxValidationStat
18121811
if (peer) Misbehaving(*peer, "");
18131812
return;
18141813
// Conflicting (but not necessarily invalid) data or different policy:
1815-
case TxValidationResult::TX_RECENT_CONSENSUS_CHANGE:
18161814
case TxValidationResult::TX_INPUTS_NOT_STANDARD:
18171815
case TxValidationResult::TX_NOT_STANDARD:
18181816
case TxValidationResult::TX_MISSING_INPUTS:

src/test/fuzz/partially_downloaded_block.cpp

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,15 +2217,9 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
22172217
// string by reporting the error from the second check.
22182218
error = check2.GetScriptError();
22192219
}
2220+
22202221
// MANDATORY flag failures correspond to
2221-
// TxValidationResult::TX_CONSENSUS. Because CONSENSUS
2222-
// failures are the most serious case of validation
2223-
// failures, we may need to consider using
2224-
// RECENT_CONSENSUS_CHANGE for any script failure that
2225-
// could be due to non-upgraded nodes which we may want to
2226-
// support, to avoid splitting the network (but this
2227-
// depends on the details of how net_processing handles
2228-
// such errors).
2222+
// TxValidationResult::TX_CONSENSUS.
22292223
return state.Invalid(TxValidationResult::TX_CONSENSUS, strprintf("mandatory-script-verify-flag-failed (%s)", ScriptErrorString(error)));
22302224
}
22312225
}

0 commit comments

Comments
 (0)