Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13711151
D15789.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
18 KB
Subscribers
None
D15789.id.diff
View Options
diff --git a/src/bench/chained_tx.cpp b/src/bench/chained_tx.cpp
--- a/src/bench/chained_tx.cpp
+++ b/src/bench/chained_tx.cpp
@@ -182,13 +182,9 @@
entry.nFee = 1337 * SATOSHI;
for (const auto &chain : chains) {
{
- entry.spendsCoinbase = true;
LOCK2(cs_main, mempool.cs);
for (const auto &tx : chain) {
mempool.addUnchecked(entry.FromTx(tx));
- // Setting spendCoinbase to false here assumes it's a chain of
- // 1-in-1-out transaction chain.
- entry.spendsCoinbase = false;
}
}
assert(mempool.size() == chain.size());
@@ -252,13 +248,9 @@
// Fill mempool
size_t txCount = 0;
for (const auto &chain : chains) {
- entry.spendsCoinbase = true;
LOCK2(cs_main, mempool.cs);
for (const auto &tx : chain) {
mempool.addUnchecked(entry.FromTx(tx));
- // Setting spendCoinbase to false here assumes it's a chain of
- // 1-in-1-out transaction chain.
- entry.spendsCoinbase = false;
++txCount;
}
}
@@ -302,7 +294,6 @@
const Amount feeBump =
revFee ? int64_t(-1) * SATOSHI : int64_t(1) * SATOSHI;
for (const auto &chain : chains) {
- entry.spendsCoinbase = true;
if (revFee) {
entry.nFee += int64_t(chain.size()) * SATOSHI;
}
@@ -312,7 +303,6 @@
entry.nFee += feeBump;
// Setting spendCoinbase to false here assumes it's a chain of
// 1-in-1-out transaction chain.
- entry.spendsCoinbase = false;
++txCount;
}
if (revFee) {
diff --git a/src/bench/mempool_eviction.cpp b/src/bench/mempool_eviction.cpp
--- a/src/bench/mempool_eviction.cpp
+++ b/src/bench/mempool_eviction.cpp
@@ -12,11 +12,10 @@
CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs) {
int64_t nTime = 0;
unsigned int nHeight = 1;
- bool spendsCoinbase = false;
unsigned int nSigChecks = 1;
LockPoints lp;
- pool.addUnchecked(CTxMemPoolEntryRef::make(tx, nFee, nTime, nHeight,
- spendsCoinbase, nSigChecks, lp));
+ pool.addUnchecked(
+ CTxMemPoolEntryRef::make(tx, nFee, nTime, nHeight, nSigChecks, lp));
}
// Right now this is only testing eviction performance in an extremely small
diff --git a/src/bench/mempool_stress.cpp b/src/bench/mempool_stress.cpp
--- a/src/bench/mempool_stress.cpp
+++ b/src/bench/mempool_stress.cpp
@@ -15,11 +15,10 @@
EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs) {
int64_t nTime = 0;
unsigned int nHeight = 1;
- bool spendsCoinbase = false;
unsigned int sigChecks = 1;
LockPoints lp;
- pool.addUnchecked(CTxMemPoolEntryRef::make(
- tx, 1000 * SATOSHI, nTime, nHeight, spendsCoinbase, sigChecks, lp));
+ pool.addUnchecked(CTxMemPoolEntryRef::make(tx, 1000 * SATOSHI, nTime,
+ nHeight, sigChecks, lp));
}
struct Available {
diff --git a/src/bench/rpc_mempool.cpp b/src/bench/rpc_mempool.cpp
--- a/src/bench/rpc_mempool.cpp
+++ b/src/bench/rpc_mempool.cpp
@@ -16,7 +16,6 @@
LockPoints lp;
pool.addUnchecked(CTxMemPoolEntryRef::make(tx, fee, /*time=*/0,
/*height=*/1,
- /*spendsCoinbase=*/false,
/*_sigChecks=*/1, lp));
}
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp
--- a/src/test/miner_tests.cpp
+++ b/src/test/miner_tests.cpp
@@ -134,29 +134,23 @@
// This tx has a low fee: 1000 satoshis.
// Save this txid for later use.
TxId parentTxId = tx.GetId();
- m_node.mempool->addUnchecked(entry.Fee(1000 * SATOSHI)
- .Time(GetTime())
- .SpendsCoinbase(true)
- .FromTx(tx));
+ m_node.mempool->addUnchecked(
+ entry.Fee(1000 * SATOSHI).Time(GetTime()).FromTx(tx));
// This tx has a medium fee: 10000 satoshis.
tx.vin[0].prevout = COutPoint(txFirst[1]->GetId(), 0);
tx.vout[0].nValue = int64_t(5000000000LL - 10000) * SATOSHI;
TxId mediumFeeTxId = tx.GetId();
- m_node.mempool->addUnchecked(entry.Fee(10000 * SATOSHI)
- .Time(GetTime())
- .SpendsCoinbase(true)
- .FromTx(tx));
+ m_node.mempool->addUnchecked(
+ entry.Fee(10000 * SATOSHI).Time(GetTime()).FromTx(tx));
// This tx has a high fee, but depends on the first transaction.
tx.vin[0].prevout = COutPoint(parentTxId, 0);
// 50k satoshi fee.
tx.vout[0].nValue = int64_t(5000000000LL - 1000 - 50000) * SATOSHI;
TxId highFeeTxId = tx.GetId();
- m_node.mempool->addUnchecked(entry.Fee(50000 * SATOSHI)
- .Time(GetTime())
- .SpendsCoinbase(false)
- .FromTx(tx));
+ m_node.mempool->addUnchecked(
+ entry.Fee(50000 * SATOSHI).Time(GetTime()).FromTx(tx));
std::unique_ptr<CBlockTemplate> pblocktemplate =
AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
@@ -267,12 +261,8 @@
for (unsigned int i = 0; i < 128; ++i) {
tx.vout[0].nValue -= LOWFEE;
const TxId txid = tx.GetId();
- // Only first tx spends coinbase.
- bool spendsCoinbase = i == 0;
- m_node.mempool->addUnchecked(entry.Fee(LOWFEE)
- .Time(GetTime())
- .SpendsCoinbase(spendsCoinbase)
- .FromTx(tx));
+ m_node.mempool->addUnchecked(
+ entry.Fee(LOWFEE).Time(GetTime()).FromTx(tx));
tx.vin[0].prevout = COutPoint(txid, 0);
}
@@ -292,8 +282,7 @@
tx.vin[0].prevout = COutPoint(txFirst[1]->GetId(), 0);
tx.vout[0].nValue = BLOCKSUBSIDY - HIGHFEE;
TxId txid = tx.GetId();
- m_node.mempool->addUnchecked(
- entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
+ m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).FromTx(tx));
tx.vin[0].prevout = COutPoint(txid, 0);
tx.vin.resize(2);
tx.vin[1].scriptSig = CScript() << OP_1;
@@ -302,7 +291,7 @@
tx.vout[0].nValue = tx.vout[0].nValue + BLOCKSUBSIDY - HIGHERFEE;
txid = tx.GetId();
m_node.mempool->addUnchecked(
- entry.Fee(HIGHERFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
+ entry.Fee(HIGHERFEE).Time(GetTime()).FromTx(tx));
BOOST_CHECK(pblocktemplate =
AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey));
m_node.mempool->clear();
@@ -314,8 +303,7 @@
tx.vout[0].nValue = Amount::zero();
txid = tx.GetId();
// Give it a fee so it'll get mined.
- m_node.mempool->addUnchecked(
- entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
+ m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).FromTx(tx));
// Should throw bad-tx-coinbase
BOOST_CHECK_EXCEPTION(
AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey),
@@ -328,12 +316,10 @@
tx.vout[0].nValue = BLOCKSUBSIDY - HIGHFEE;
tx.vout[0].scriptPubKey = CScript() << OP_1;
txid = tx.GetId();
- m_node.mempool->addUnchecked(
- entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
+ m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).FromTx(tx));
tx.vout[0].scriptPubKey = CScript() << OP_2;
txid = tx.GetId();
- m_node.mempool->addUnchecked(
- entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
+ m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).FromTx(tx));
BOOST_CHECK_EXCEPTION(
AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey),
std::runtime_error, HasReason("bad-txns-inputs-missingorspent"));
@@ -378,15 +364,13 @@
CScript script = CScript() << OP_0;
tx.vout[0].scriptPubKey = GetScriptForDestination(ScriptHash(script));
txid = tx.GetId();
- m_node.mempool->addUnchecked(
- entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
+ m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).FromTx(tx));
tx.vin[0].prevout = COutPoint(txid, 0);
tx.vin[0].scriptSig = CScript()
<< std::vector<uint8_t>(script.begin(), script.end());
tx.vout[0].nValue -= LOWFEE;
txid = tx.GetId();
- m_node.mempool->addUnchecked(
- entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
+ m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).FromTx(tx));
// Should throw blk-bad-inputs
BOOST_CHECK_EXCEPTION(
AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey),
@@ -424,8 +408,7 @@
tx.vout[0].scriptPubKey = CScript() << OP_1;
tx.nLockTime = 0;
txid = tx.GetId();
- m_node.mempool->addUnchecked(
- entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
+ m_node.mempool->addUnchecked(entry.Fee(HIGHFEE).Time(GetTime()).FromTx(tx));
const Consensus::Params ¶ms = chainparams.GetConsensus();
@@ -613,10 +596,8 @@
// 0 fee
tx.vout[0].nValue = fiveBillion * SATOSHI;
const TxId hashFreePrioritisedTx = tx.GetId();
- m_node.mempool->addUnchecked(entry.Fee(Amount::zero())
- .Time(GetTime())
- .SpendsCoinbase(true)
- .FromTx(tx));
+ m_node.mempool->addUnchecked(
+ entry.Fee(Amount::zero()).Time(GetTime()).FromTx(tx));
m_node.mempool->PrioritiseTransaction(hashFreePrioritisedTx, 5 * COIN);
// This tx has a low fee: 1000 satoshis
@@ -624,19 +605,15 @@
tx.vout[0].nValue = (fiveBillion - 1000) * SATOSHI;
// save this txid for later use
const TxId hashParentTx = tx.GetId();
- m_node.mempool->addUnchecked(entry.Fee(1000 * SATOSHI)
- .Time(GetTime())
- .SpendsCoinbase(true)
- .FromTx(tx));
+ m_node.mempool->addUnchecked(
+ entry.Fee(1000 * SATOSHI).Time(GetTime()).FromTx(tx));
// This tx has a medium fee: 10000 satoshis
tx.vin[0].prevout = COutPoint{txFirst[2]->GetId(), 0};
tx.vout[0].nValue = (fiveBillion - 10000) * SATOSHI;
const TxId hashMediumFeeTx = tx.GetId();
- m_node.mempool->addUnchecked(entry.Fee(10000 * SATOSHI)
- .Time(GetTime())
- .SpendsCoinbase(true)
- .FromTx(tx));
+ m_node.mempool->addUnchecked(
+ entry.Fee(10000 * SATOSHI).Time(GetTime()).FromTx(tx));
m_node.mempool->PrioritiseTransaction(hashMediumFeeTx, -5 * COIN);
// This tx also has a low fee, but is prioritised
@@ -644,10 +621,8 @@
// 1000 satoshi fee
tx.vout[0].nValue = (fiveBillion - 1000 - 1000) * SATOSHI;
const TxId hashPrioritisedChild = tx.GetId();
- m_node.mempool->addUnchecked(entry.Fee(1000 * SATOSHI)
- .Time(GetTime())
- .SpendsCoinbase(false)
- .FromTx(tx));
+ m_node.mempool->addUnchecked(
+ entry.Fee(1000 * SATOSHI).Time(GetTime()).FromTx(tx));
m_node.mempool->PrioritiseTransaction(hashPrioritisedChild, 2 * COIN);
// Test that transaction selection properly updates ancestor fee
@@ -662,24 +637,21 @@
// 0 fee
tx.vout[0].nValue = fiveBillion * SATOSHI;
const TxId hashFreeParent = tx.GetId();
- m_node.mempool->addUnchecked(
- entry.Fee(Amount::zero()).SpendsCoinbase(true).FromTx(tx));
+ m_node.mempool->addUnchecked(entry.Fee(Amount::zero()).FromTx(tx));
m_node.mempool->PrioritiseTransaction(hashFreeParent, 10 * COIN);
tx.vin[0].prevout = COutPoint{hashFreeParent, 0};
// 0 fee
tx.vout[0].nValue = fiveBillion * SATOSHI;
const TxId hashFreeChild = tx.GetId();
- m_node.mempool->addUnchecked(
- entry.Fee(Amount::zero()).SpendsCoinbase(false).FromTx(tx));
+ m_node.mempool->addUnchecked(entry.Fee(Amount::zero()).FromTx(tx));
m_node.mempool->PrioritiseTransaction(hashFreeChild, 1 * COIN);
tx.vin[0].prevout = COutPoint{hashFreeChild, 0};
// 0 fee
tx.vout[0].nValue = fiveBillion * SATOSHI;
const TxId hashFreeGrandchild = tx.GetId();
- m_node.mempool->addUnchecked(
- entry.Fee(Amount::zero()).SpendsCoinbase(false).FromTx(tx));
+ m_node.mempool->addUnchecked(entry.Fee(Amount::zero()).FromTx(tx));
auto pblocktemplate =
AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
--- a/src/test/util/setup_common.h
+++ b/src/test/util/setup_common.h
@@ -243,12 +243,10 @@
Amount nFee;
int64_t nTime;
unsigned int nHeight;
- bool spendsCoinbase;
unsigned int nSigChecks;
uint64_t entryId = 0;
- TestMemPoolEntryHelper()
- : nFee(), nTime(0), nHeight(1), spendsCoinbase(false), nSigChecks(1) {}
+ TestMemPoolEntryHelper() : nFee(), nTime(0), nHeight(1), nSigChecks(1) {}
CTxMemPoolEntryRef FromTx(const CMutableTransaction &tx) const;
CTxMemPoolEntryRef FromTx(const CTransactionRef &tx) const;
@@ -266,10 +264,6 @@
nHeight = _height;
return *this;
}
- TestMemPoolEntryHelper &SpendsCoinbase(bool _flag) {
- spendsCoinbase = _flag;
- return *this;
- }
TestMemPoolEntryHelper &SigChecks(unsigned int _nSigChecks) {
nSigChecks = _nSigChecks;
return *this;
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -498,8 +498,8 @@
if (submit) {
LOCK2(m_node.mempool->cs, cs_main);
LockPoints lp;
- m_node.mempool->addUnchecked(CTxMemPoolEntryRef::make(
- ptx, 1000 * SATOSHI, 0, 1, false, 4, lp));
+ m_node.mempool->addUnchecked(
+ CTxMemPoolEntryRef::make(ptx, 1000 * SATOSHI, 0, 1, 4, lp));
}
--num_transactions;
}
@@ -513,8 +513,7 @@
CTxMemPoolEntryRef
TestMemPoolEntryHelper::FromTx(const CTransactionRef &tx) const {
- CTxMemPoolEntry ret(tx, nFee, nTime, nHeight, spendsCoinbase, nSigChecks,
- LockPoints());
+ CTxMemPoolEntry ret(tx, nFee, nTime, nHeight, nSigChecks, LockPoints());
ret.SetEntryId(entryId);
return CTxMemPoolEntryRef::make(std::move(ret));
}
diff --git a/src/txmempool.h b/src/txmempool.h
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -115,8 +115,6 @@
const int64_t nTime;
//! Chain height when entering the mempool
const unsigned int entryHeight;
- //! keep track of transactions that spend a coinbase
- const bool spendsCoinbase;
//! Total sigChecks
const int64_t sigChecks;
//! Used for determining the priority of the transaction for mining in a
@@ -129,8 +127,8 @@
public:
CTxMemPoolEntry(const CTransactionRef &_tx, const Amount fee, int64_t time,
- unsigned int entry_height, bool spends_coinbase,
- int64_t sigchecks, LockPoints lp);
+ unsigned int entry_height, int64_t sigchecks,
+ LockPoints lp);
CTxMemPoolEntry(const CTxMemPoolEntry &other) = delete;
CTxMemPoolEntry(CTxMemPoolEntry &&other)
@@ -139,8 +137,8 @@
m_children(std::move(other.m_children)), nFee(other.nFee),
nTxSize(other.nTxSize), nUsageSize(other.nUsageSize),
nTime(other.nTime), entryHeight(other.entryHeight),
- spendsCoinbase(other.spendsCoinbase), sigChecks(other.sigChecks),
- feeDelta(other.feeDelta), lockPoints(std::move(other.lockPoints)),
+ sigChecks(other.sigChecks), feeDelta(other.feeDelta),
+ lockPoints(std::move(other.lockPoints)),
refcount(other.refcount.load()){};
uint64_t GetEntryId() const { return entryId; }
@@ -167,8 +165,6 @@
// Updates the fee delta used for mining priority score
void UpdateFeeDelta(Amount feeDelta);
- bool GetSpendsCoinbase() const { return spendsCoinbase; }
-
const Parents &GetMemPoolParentsConst() const { return m_parents; }
const Children &GetMemPoolChildrenConst() const { return m_children; }
Parents &GetMemPoolParents() const { return m_parents; }
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -28,12 +28,11 @@
CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef &_tx, const Amount fee,
int64_t time, unsigned int entry_height,
- bool spends_coinbase, int64_t _sigChecks,
- LockPoints lp)
+ int64_t _sigChecks, LockPoints lp)
: tx{_tx}, nFee{fee},
nTxSize(tx->GetTotalSize()), nUsageSize{RecursiveDynamicUsage(tx)},
- nTime(time), entryHeight{entry_height}, spendsCoinbase(spends_coinbase),
- sigChecks(_sigChecks), lockPoints(lp) {}
+ nTime(time), entryHeight{entry_height}, sigChecks(_sigChecks),
+ lockPoints(lp) {}
size_t CTxMemPoolEntry::GetTxVirtualSize() const {
return GetVirtualTransactionSize(nTxSize, sigChecks, ::nBytesPerSigCheck);
diff --git a/src/validation.cpp b/src/validation.cpp
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -611,17 +611,6 @@
ws.m_modified_fees = ws.m_base_fees;
m_pool.ApplyDelta(txid, ws.m_modified_fees);
- // Keep track of transactions that spend a coinbase, which we re-scan
- // during reorgs to ensure COINBASE_MATURITY is still met.
- bool fSpendsCoinbase = false;
- for (const CTxIn &txin : tx.vin) {
- const Coin &coin = m_view.AccessCoin(txin.prevout);
- if (coin.IsCoinBase()) {
- fSpendsCoinbase = true;
- break;
- }
- }
-
unsigned int nSize = tx.GetTotalSize();
// No transactions are allowed below the min relay feerate except from
@@ -649,7 +638,7 @@
ws.m_entry = std::make_unique<CTxMemPoolEntry>(
ptx, ws.m_base_fees, nAcceptTime,
heightOverride ? heightOverride : m_active_chainstate.m_chain.Height(),
- fSpendsCoinbase, ws.m_sig_checks_standard, lp);
+ ws.m_sig_checks_standard, lp);
ws.m_vsize = ws.m_entry->GetTxVirtualSize();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 26, 10:37 (5 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5570917
Default Alt Text
D15789.id.diff (18 KB)
Attached To
D15789: remove coinbase spend tracking in CTxMemPoolEntry
Event Timeline
Log In to Comment