Skip to content

Commit fa3e0da

Browse files
author
MarcoFalke
committed
policy: Treat taproot as always active
1 parent 15d1098 commit fa3e0da

File tree

13 files changed

+42
-58
lines changed

13 files changed

+42
-58
lines changed

src/bench/ccoins_caching.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static void CCoinsCaching(benchmark::Bench& bench)
4545
// Benchmark.
4646
const CTransaction tx_1(t1);
4747
bench.run([&] {
48-
bool success = AreInputsStandard(tx_1, coins, false);
48+
bool success{AreInputsStandard(tx_1, coins)};
4949
assert(success);
5050
});
5151
ECC_Stop();

src/interfaces/chain.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,6 @@ class Chain
287287
//! to be prepared to handle this by ignoring notifications about unknown
288288
//! removed transactions and already added new transactions.
289289
virtual void requestMempoolTransactions(Notifications& notifications) = 0;
290-
291-
//! Check if Taproot has activated
292-
virtual bool isTaprootActive() = 0;
293290
};
294291

295292
//! Interface to let node manage chain clients (wallets, or maybe tools for

src/node/interfaces.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,12 +713,6 @@ class ChainImpl : public Chain
713713
notifications.transactionAddedToMempool(entry.GetSharedTx(), 0 /* mempool_sequence */);
714714
}
715715
}
716-
bool isTaprootActive() override
717-
{
718-
LOCK(::cs_main);
719-
const CBlockIndex* tip = Assert(m_node.chainman)->ActiveChain().Tip();
720-
return DeploymentActiveAfter(tip, Params().GetConsensus(), Consensus::DEPLOYMENT_TAPROOT);
721-
}
722716
NodeContext& m_node;
723717
};
724718
} // namespace

src/policy/policy.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeR
161161
*
162162
* Note that only the non-witness portion of the transaction is checked here.
163163
*/
164-
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, bool taproot_active)
164+
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
165165
{
166-
if (tx.IsCoinBase())
166+
if (tx.IsCoinBase()) {
167167
return true; // Coinbases don't use vin normally
168+
}
168169

169-
for (unsigned int i = 0; i < tx.vin.size(); i++)
170-
{
170+
for (unsigned int i = 0; i < tx.vin.size(); i++) {
171171
const CTxOut& prev = mapInputs.AccessCoin(tx.vin[i].prevout).out;
172172

173173
std::vector<std::vector<unsigned char> > vSolutions;
@@ -189,9 +189,6 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs,
189189
if (subscript.GetSigOpCount(true) > MAX_P2SH_SIGOPS) {
190190
return false;
191191
}
192-
} else if (whichType == TxoutType::WITNESS_V1_TAPROOT) {
193-
// Don't allow Taproot spends unless Taproot is active.
194-
if (!taproot_active) return false;
195192
}
196193
}
197194

src/policy/policy.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,9 @@ bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeR
105105
/**
106106
* Check for standard transaction types
107107
* @param[in] mapInputs Map of previous transactions that have outputs we're spending
108-
* @param[in] taproot_active Whether or taproot consensus rules are active (used to decide whether spends of them are permitted)
109108
* @return True if all inputs (scriptSigs) use only standard transaction forms
110109
*/
111-
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, bool taproot_active);
110+
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs);
112111
/**
113112
* Check if the transaction is over standard P2WSH resources limit:
114113
* 3600bytes witnessScript size, 80bytes per witness stack element, 100 witness stack elements

src/test/fuzz/coins_view.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
221221
assert(expected_code_path);
222222
},
223223
[&] {
224-
(void)AreInputsStandard(CTransaction{random_mutable_transaction}, coins_view_cache, false);
225-
(void)AreInputsStandard(CTransaction{random_mutable_transaction}, coins_view_cache, true);
224+
(void)AreInputsStandard(CTransaction{random_mutable_transaction}, coins_view_cache);
226225
},
227226
[&] {
228227
TxValidationState state;

src/test/fuzz/transaction.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ FUZZ_TARGET_INIT(transaction, initialize_transaction)
9898

9999
CCoinsView coins_view;
100100
const CCoinsViewCache coins_view_cache(&coins_view);
101-
(void)AreInputsStandard(tx, coins_view_cache, false);
102-
(void)AreInputsStandard(tx, coins_view_cache, true);
101+
(void)AreInputsStandard(tx, coins_view_cache);
103102
(void)IsWitnessStandard(tx, coins_view_cache);
104103

105104
UniValue u(UniValue::VOBJ);

src/test/script_p2sh_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
343343
txTo.vin[3].scriptSig << OP_11 << OP_11 << std::vector<unsigned char>(oneAndTwo.begin(), oneAndTwo.end());
344344
txTo.vin[4].scriptSig << std::vector<unsigned char>(fifteenSigops.begin(), fifteenSigops.end());
345345

346-
BOOST_CHECK(::AreInputsStandard(CTransaction(txTo), coins, false));
346+
BOOST_CHECK(::AreInputsStandard(CTransaction(txTo), coins));
347347
// 22 P2SH sigops for all inputs (1 for vin[0], 6 for vin[3], 15 for vin[4]
348348
BOOST_CHECK_EQUAL(GetP2SHSigOpCount(CTransaction(txTo), coins), 22U);
349349

@@ -356,7 +356,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
356356
txToNonStd1.vin[0].prevout.hash = txFrom.GetHash();
357357
txToNonStd1.vin[0].scriptSig << std::vector<unsigned char>(sixteenSigops.begin(), sixteenSigops.end());
358358

359-
BOOST_CHECK(!::AreInputsStandard(CTransaction(txToNonStd1), coins, false));
359+
BOOST_CHECK(!::AreInputsStandard(CTransaction(txToNonStd1), coins));
360360
BOOST_CHECK_EQUAL(GetP2SHSigOpCount(CTransaction(txToNonStd1), coins), 16U);
361361

362362
CMutableTransaction txToNonStd2;
@@ -368,7 +368,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
368368
txToNonStd2.vin[0].prevout.hash = txFrom.GetHash();
369369
txToNonStd2.vin[0].scriptSig << std::vector<unsigned char>(twentySigops.begin(), twentySigops.end());
370370

371-
BOOST_CHECK(!::AreInputsStandard(CTransaction(txToNonStd2), coins, false));
371+
BOOST_CHECK(!::AreInputsStandard(CTransaction(txToNonStd2), coins));
372372
BOOST_CHECK_EQUAL(GetP2SHSigOpCount(CTransaction(txToNonStd2), coins), 20U);
373373
}
374374

src/test/transaction_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ BOOST_AUTO_TEST_CASE(test_Get)
406406
t1.vout[0].nValue = 90*CENT;
407407
t1.vout[0].scriptPubKey << OP_1;
408408

409-
BOOST_CHECK(AreInputsStandard(CTransaction(t1), coins, false));
409+
BOOST_CHECK(AreInputsStandard(CTransaction(t1), coins));
410410
}
411411

412412
static void CreateCreditAndSpend(const FillableSigningProvider& keystore, const CScript& outscript, CTransactionRef& output, CMutableTransaction& input, bool success = true)

src/validation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
723723
}
724724

725725
// Check for non-standard pay-to-script-hash in inputs
726-
const bool taproot_active = DeploymentActiveAfter(m_active_chainstate.m_chain.Tip(), args.m_chainparams.GetConsensus(), Consensus::DEPLOYMENT_TAPROOT);
727-
if (fRequireStandard && !AreInputsStandard(tx, m_view, taproot_active)) {
726+
if (fRequireStandard && !AreInputsStandard(tx, m_view)) {
728727
return state.Invalid(TxValidationResult::TX_INPUTS_NOT_STANDARD, "bad-txns-nonstandard-inputs");
729728
}
730729

0 commit comments

Comments
 (0)