Skip to content

Commit 6fd3556

Browse files
laanwjPastaPastaPasta
authored andcommitted
Merge bitcoin#13527: policy: Remove promiscuousmempoolflags
faa2444 policy: Remove promiscuousmempoolflags (MarcoFalke) Pull request description: It seems odd to clutter validation code with features that can only ever be used for testing (testnet or regtest). Removing that test-only code makes the mempool logic less painful to understand and easier to reason about when changed or refactored in the future. Tree-SHA512: 3b897aa9604ac8d82ebe9573c6efd468c93ddaa08d378ebc902e247b7aa6c68fcde71e5b449c08f17a067146cdc66dc50a67ce06d07607c27e5189a49c3fba3f
1 parent 9b8df2f commit 6fd3556

File tree

3 files changed

+13
-27
lines changed

3 files changed

+13
-27
lines changed

src/validation.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
704704
// If we aren't going to actually accept it but just were verifying it, we are fine already
705705
if(fDryRun) return true;
706706

707+
constexpr unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS;
708+
707709
// Check against previous transactions
708710
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
709711
PrecomputedTransactionData txdata(tx);
@@ -726,22 +728,9 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
726728
// invalid blocks (using TestBlockValidity), however allowing such
727729
// transactions into the mempool can be exploited as a DoS attack.
728730
unsigned int currentBlockScriptVerifyFlags = GetBlockScriptFlags(chainActive.Tip(), Params().GetConsensus());
729-
if (!CheckInputsFromMempoolAndCache(tx, state, view, pool, currentBlockScriptVerifyFlags, true, txdata))
730-
{
731-
// If we're using promiscuousmempoolflags, we may hit this normally
732-
// Check if current block has some flags that scriptVerifyFlags
733-
// does not before printing an ominous warning
734-
if (!(~scriptVerifyFlags & currentBlockScriptVerifyFlags)) {
735-
return error("%s: BUG! PLEASE REPORT THIS! ConnectInputs failed against latest-block but not STANDARD flags %s, %s",
731+
if (!CheckInputsFromMempoolAndCache(tx, state, view, pool, currentBlockScriptVerifyFlags, true, txdata)) {
732+
return error("%s: BUG! PLEASE REPORT THIS! CheckInputs failed against latest-block but not STANDARD flags %s, %s",
736733
__func__, hash.ToString(), FormatStateMessage(state));
737-
} else {
738-
if (!CheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, false, txdata)) {
739-
return error("%s: ConnectInputs failed against MANDATORY but not STANDARD flags due to promiscuous mempool %s, %s",
740-
__func__, hash.ToString(), FormatStateMessage(state));
741-
} else {
742-
LogPrintf("Warning: -promiscuousmempool flags set to not include currently enforced soft forks, this may break mining or otherwise cause instability!\n");
743-
}
744-
}
745734
}
746735

747736
// This transaction should only count for fee estimation if the

test/functional/bip65-cltv-p2p.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class BIP65Test(BitcoinTestFramework):
6464
def __init__(self):
6565
super().__init__()
6666
self.num_nodes = 1
67-
self.extra_args = [['-promiscuousmempoolflags=1', '-whitelist=127.0.0.1', '-dip3params=9000:9000']]
67+
self.extra_args = [['-whitelist=127.0.0.1', '-dip3params=9000:9000']]
6868
self.setup_clean_chain = True
6969

7070
def run_test(self):
@@ -125,12 +125,10 @@ def run_test(self):
125125
spendtx.rehash()
126126

127127
# First we show that this tx is valid except for CLTV by getting it
128-
# accepted to the mempool (which we can achieve with
129-
# -promiscuousmempoolflags).
130-
node0.send_and_ping(msg_tx(spendtx))
131-
assert spendtx.hash in self.nodes[0].getrawmempool()
128+
# rejected from the mempool for exactly that reason.
129+
assert_raises_jsonrpc(-26, '64: non-mandatory-script-verify-flag (Negative locktime)', self.nodes[0].sendrawtransaction, bytes_to_hex_str(spendtx.serialize()), True)
132130

133-
# Now we verify that a block with this transaction is invalid.
131+
# Now we verify that a block with this transaction is also invalid.
134132
block.vtx.append(spendtx)
135133
block.hashMerkleRoot = block.calc_merkle_root()
136134
block.solve()

test/functional/bipdersig-p2p.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ def create_transaction(node, coinbase, to_address, amount):
4747
tx.deserialize(BytesIO(hex_str_to_bytes(signresult['hex'])))
4848
return tx
4949

50+
5051
class BIP66Test(BitcoinTestFramework):
5152

5253
def __init__(self):
5354
super().__init__()
5455
self.num_nodes = 1
55-
self.extra_args = [['-promiscuousmempoolflags=1', '-whitelist=127.0.0.1', '-dip3params=9000:9000']]
56+
self.extra_args = [['-whitelist=127.0.0.1', '-dip3params=9000:9000']]
5657
self.setup_clean_chain = True
5758

5859
def run_test(self):
@@ -114,12 +115,10 @@ def run_test(self):
114115
spendtx.rehash()
115116

116117
# First we show that this tx is valid except for DERSIG by getting it
117-
# accepted to the mempool (which we can achieve with
118-
# -promiscuousmempoolflags).
119-
node0.send_and_ping(msg_tx(spendtx))
120-
assert spendtx.hash in self.nodes[0].getrawmempool()
118+
# rejected from the mempool for exactly that reason.
119+
assert_raises_jsonrpc(-26, '64: non-mandatory-script-verify-flag (Non-canonical DER signature)', self.nodes[0].sendrawtransaction, bytes_to_hex_str(spendtx.serialize()), True)
121120

122-
# Now we verify that a block with this transaction is invalid.
121+
# Now we verify that a block with this transaction is also invalid.
123122
block.vtx.append(spendtx)
124123
block.hashMerkleRoot = block.calc_merkle_root()
125124
block.rehash()

0 commit comments

Comments
 (0)