Skip to content

Commit faa2444

Browse files
author
MarcoFalke
committed
policy: Remove promiscuousmempoolflags
1 parent 6579d80 commit faa2444

File tree

5 files changed

+29
-42
lines changed

5 files changed

+29
-42
lines changed

src/miner.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,11 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
133133

134134
// Decide whether to include witness transactions
135135
// This is only needed in case the witness softfork activation is reverted
136-
// (which would require a very deep reorganization) or when
137-
// -promiscuousmempoolflags is used.
136+
// (which would require a very deep reorganization).
137+
// Note that the mempool would accept transactions with witness data before
138+
// IsWitnessEnabled, but we would only ever mine blocks after IsWitnessEnabled
139+
// unless there is a massive block reorganization with the witness softfork
140+
// not activated.
138141
// TODO: replace this with a call to main to assess validity of a mempool
139142
// transaction (which in most cases can be a no-op).
140143
fIncludeWitness = IsWitnessEnabled(pindexPrev, chainparams.GetConsensus()) && fMineWitnessTx;

src/validation.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -897,10 +897,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
897897
}
898898
}
899899

900-
unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS;
901-
if (!chainparams.RequireStandard()) {
902-
scriptVerifyFlags = gArgs.GetArg("-promiscuousmempoolflags", scriptVerifyFlags);
903-
}
900+
constexpr unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS;
904901

905902
// Check against previous transactions
906903
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
@@ -935,20 +932,8 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
935932
// transactions into the mempool can be exploited as a DoS attack.
936933
unsigned int currentBlockScriptVerifyFlags = GetBlockScriptFlags(chainActive.Tip(), Params().GetConsensus());
937934
if (!CheckInputsFromMempoolAndCache(tx, state, view, pool, currentBlockScriptVerifyFlags, true, txdata)) {
938-
// If we're using promiscuousmempoolflags, we may hit this normally
939-
// Check if current block has some flags that scriptVerifyFlags
940-
// does not before printing an ominous warning
941-
if (!(~scriptVerifyFlags & currentBlockScriptVerifyFlags)) {
942-
return error("%s: BUG! PLEASE REPORT THIS! ConnectInputs failed against latest-block but not STANDARD flags %s, %s",
935+
return error("%s: BUG! PLEASE REPORT THIS! CheckInputs failed against latest-block but not STANDARD flags %s, %s",
943936
__func__, hash.ToString(), FormatStateMessage(state));
944-
} else {
945-
if (!CheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, false, txdata)) {
946-
return error("%s: ConnectInputs failed against MANDATORY but not STANDARD flags due to promiscuous mempool %s, %s",
947-
__func__, hash.ToString(), FormatStateMessage(state));
948-
} else {
949-
LogPrintf("Warning: -promiscuousmempool flags set to not include currently enforced soft forks, this may break mining or otherwise cause instability!\n");
950-
}
951-
}
952937
}
953938

954939
if (test_accept) {

test/functional/feature_cltv.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def create_transaction(node, coinbase, to_address, amount):
6262
class BIP65Test(BitcoinTestFramework):
6363
def set_test_params(self):
6464
self.num_nodes = 1
65-
self.extra_args = [['-promiscuousmempoolflags=1', '-whitelist=127.0.0.1']]
65+
self.extra_args = [['-whitelist=127.0.0.1']]
6666
self.setup_clean_chain = True
6767

6868
def run_test(self):
@@ -120,12 +120,13 @@ def run_test(self):
120120
spendtx.rehash()
121121

122122
# First we show that this tx is valid except for CLTV by getting it
123-
# accepted to the mempool (which we can achieve with
124-
# -promiscuousmempoolflags).
125-
self.nodes[0].p2p.send_and_ping(msg_tx(spendtx))
126-
assert spendtx.hash in self.nodes[0].getrawmempool()
123+
# rejected from the mempool for exactly that reason.
124+
assert_equal(
125+
[{'txid': spendtx.hash, 'allowed': False, 'reject-reason': '64: non-mandatory-script-verify-flag (Negative locktime)'}],
126+
self.nodes[0].testmempoolaccept(rawtxs=[bytes_to_hex_str(spendtx.serialize())], allowhighfees=True)
127+
)
127128

128-
# Now we verify that a block with this transaction is invalid.
129+
# Now we verify that a block with this transaction is also invalid.
129130
block.vtx.append(spendtx)
130131
block.hashMerkleRoot = block.calc_merkle_root()
131132
block.solve()

test/functional/feature_dersig.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ 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
def set_test_params(self):
5253
self.num_nodes = 1
53-
self.extra_args = [['-promiscuousmempoolflags=1', '-whitelist=127.0.0.1']]
54+
self.extra_args = [['-whitelist=127.0.0.1']]
5455
self.setup_clean_chain = True
5556

5657
def run_test(self):
@@ -110,12 +111,13 @@ def run_test(self):
110111
spendtx.rehash()
111112

112113
# First we show that this tx is valid except for DERSIG by getting it
113-
# accepted to the mempool (which we can achieve with
114-
# -promiscuousmempoolflags).
115-
self.nodes[0].p2p.send_and_ping(msg_tx(spendtx))
116-
assert spendtx.hash in self.nodes[0].getrawmempool()
114+
# rejected from the mempool for exactly that reason.
115+
assert_equal(
116+
[{'txid': spendtx.hash, 'allowed': False, 'reject-reason': '64: non-mandatory-script-verify-flag (Non-canonical DER signature)'}],
117+
self.nodes[0].testmempoolaccept(rawtxs=[bytes_to_hex_str(spendtx.serialize())], allowhighfees=True)
118+
)
117119

118-
# Now we verify that a block with this transaction is invalid.
120+
# Now we verify that a block with this transaction is also invalid.
119121
block.vtx.append(spendtx)
120122
block.hashMerkleRoot = block.calc_merkle_root()
121123
block.rehash()

test/functional/feature_segwit.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def set_test_params(self):
4343
self.num_nodes = 3
4444
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
4545
self.extra_args = [["-rpcserialversion=0", "-vbparams=segwit:0:999999999999", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"],
46-
["-blockversion=4", "-promiscuousmempoolflags=517", "-rpcserialversion=1", "-vbparams=segwit:0:999999999999", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"],
47-
["-blockversion=536870915", "-promiscuousmempoolflags=517", "-vbparams=segwit:0:999999999999", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"]]
46+
["-blockversion=4", "-rpcserialversion=1", "-vbparams=segwit:0:999999999999", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"],
47+
["-blockversion=536870915", "-vbparams=segwit:0:999999999999", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"]]
4848

4949
def setup_network(self):
5050
super().setup_network()
@@ -64,12 +64,8 @@ def skip_mine(self, node, txid, sign, redeem_script=""):
6464
sync_blocks(self.nodes)
6565

6666
def fail_accept(self, node, error_msg, txid, sign, redeem_script=""):
67-
assert_raises_rpc_error(-26, error_msg, send_to_witness, 1, node, getutxo(txid), self.pubkey[0], False, Decimal("49.998"), sign, redeem_script)
67+
assert_raises_rpc_error(-26, error_msg, send_to_witness, use_p2wsh=1, node=node, utxo=getutxo(txid), pubkey=self.pubkey[0], encode_p2sh=False, amount=Decimal("49.998"), sign=sign, insert_redeem_script=redeem_script)
6868

69-
def fail_mine(self, node, txid, sign, redeem_script=""):
70-
send_to_witness(1, node, getutxo(txid), self.pubkey[0], False, Decimal("49.998"), sign, redeem_script)
71-
assert_raises_rpc_error(-1, "CreateNewBlock: TestBlockValidity failed", node.generate, 1)
72-
sync_blocks(self.nodes)
7369

7470
def run_test(self):
7571
self.nodes[0].generate(161) #block 161
@@ -171,10 +167,10 @@ def run_test(self):
171167
assert(self.nodes[0].getrawtransaction(segwit_tx_list[i]) == bytes_to_hex_str(tx.serialize_without_witness()))
172168

173169
self.log.info("Verify witness txs without witness data are invalid after the fork")
174-
self.fail_mine(self.nodes[2], wit_ids[NODE_2][WIT_V0][2], False)
175-
self.fail_mine(self.nodes[2], wit_ids[NODE_2][WIT_V1][2], False)
176-
self.fail_mine(self.nodes[2], p2sh_ids[NODE_2][WIT_V0][2], False, witness_script(False, self.pubkey[2]))
177-
self.fail_mine(self.nodes[2], p2sh_ids[NODE_2][WIT_V1][2], False, witness_script(True, self.pubkey[2]))
170+
self.fail_accept(self.nodes[2], 'non-mandatory-script-verify-flag (Witness program hash mismatch) (code 64)', wit_ids[NODE_2][WIT_V0][2], sign=False)
171+
self.fail_accept(self.nodes[2], 'non-mandatory-script-verify-flag (Witness program was passed an empty witness) (code 64)', wit_ids[NODE_2][WIT_V1][2], sign=False)
172+
self.fail_accept(self.nodes[2], 'non-mandatory-script-verify-flag (Witness program hash mismatch) (code 64)', p2sh_ids[NODE_2][WIT_V0][2], sign=False, redeem_script=witness_script(False, self.pubkey[2]))
173+
self.fail_accept(self.nodes[2], 'non-mandatory-script-verify-flag (Witness program was passed an empty witness) (code 64)', p2sh_ids[NODE_2][WIT_V1][2], sign=False, redeem_script=witness_script(True, self.pubkey[2]))
178174

179175
self.log.info("Verify default node can now use witness txs")
180176
self.success_mine(self.nodes[0], wit_ids[NODE_0][WIT_V0][0], True) #block 432

0 commit comments

Comments
 (0)