From 15a4ec906976e0728224cc37cf78b997c88550d5 Mon Sep 17 00:00:00 2001 From: glozow Date: Thu, 15 May 2025 09:59:23 -0400 Subject: [PATCH] [prep/rpc] remove entry and expiry time from getorphantxs Expiry is going away in a later commit. This is only an RPC change. Behavior of the orphanage does not change. Note that getorphantxs is marked experimental. --- src/node/txorphanage.cpp | 4 ++-- src/node/txorphanage.h | 2 +- src/rpc/mempool.cpp | 4 ---- test/functional/rpc_orphans.py | 8 -------- test/functional/test_framework/mempool_util.py | 2 -- 5 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/node/txorphanage.cpp b/src/node/txorphanage.cpp index 6ffd17ce637..6c6c4a48840 100644 --- a/src/node/txorphanage.cpp +++ b/src/node/txorphanage.cpp @@ -37,7 +37,7 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer) return false; } - auto ret = m_orphans.emplace(wtxid, OrphanTx{{tx, {peer}, Now() + ORPHAN_TX_EXPIRE_TIME}, m_orphan_list.size()}); + auto ret = m_orphans.emplace(wtxid, OrphanTx{{tx, {peer}}, Now() + ORPHAN_TX_EXPIRE_TIME, m_orphan_list.size()}); assert(ret.second); m_orphan_list.push_back(ret.first); for (const CTxIn& txin : tx->vin) { @@ -318,7 +318,7 @@ std::vector TxOrphanage::GetOrphanTransactions() cons std::vector ret; ret.reserve(m_orphans.size()); for (auto const& o : m_orphans) { - ret.push_back({o.second.tx, o.second.announcers, o.second.nTimeExpire}); + ret.push_back({o.second.tx, o.second.announcers}); } return ret; } diff --git a/src/node/txorphanage.h b/src/node/txorphanage.h index 502d19106d0..686c5f5ab3d 100644 --- a/src/node/txorphanage.h +++ b/src/node/txorphanage.h @@ -84,7 +84,6 @@ public: CTransactionRef tx; /** Peers added with AddTx or AddAnnouncer. */ std::set announcers; - NodeSeconds nTimeExpire; /** Get the weight of this transaction, an approximation of its memory usage. */ unsigned int GetUsage() const { @@ -112,6 +111,7 @@ public: protected: struct OrphanTx : public OrphanTxBase { + NodeSeconds nTimeExpire; size_t list_pos; }; diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp index 820c6a6a737..55104e4c766 100644 --- a/src/rpc/mempool.cpp +++ b/src/rpc/mempool.cpp @@ -832,8 +832,6 @@ static std::vector OrphanDescription() RPCResult{RPCResult::Type::NUM, "bytes", "The serialized transaction size in bytes"}, RPCResult{RPCResult::Type::NUM, "vsize", "The virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted."}, RPCResult{RPCResult::Type::NUM, "weight", "The transaction weight as defined in BIP 141."}, - RPCResult{RPCResult::Type::NUM_TIME, "entry", "The entry time into the orphanage expressed in " + UNIX_EPOCH_TIME}, - RPCResult{RPCResult::Type::NUM_TIME, "expiration", "The orphan expiration time expressed in " + UNIX_EPOCH_TIME}, RPCResult{RPCResult::Type::ARR, "from", "", { RPCResult{RPCResult::Type::NUM, "peer_id", "Peer ID"}, @@ -849,8 +847,6 @@ static UniValue OrphanToJSON(const node::TxOrphanage::OrphanTxBase& orphan) o.pushKV("bytes", orphan.tx->GetTotalSize()); o.pushKV("vsize", GetVirtualTransactionSize(*orphan.tx)); o.pushKV("weight", GetTransactionWeight(*orphan.tx)); - o.pushKV("entry", int64_t{TicksSinceEpoch(orphan.nTimeExpire - node::ORPHAN_TX_EXPIRE_TIME)}); - o.pushKV("expiration", int64_t{TicksSinceEpoch(orphan.nTimeExpire)}); UniValue from(UniValue::VARR); for (const auto fromPeer: orphan.announcers) { from.push_back(fromPeer); diff --git a/test/functional/rpc_orphans.py b/test/functional/rpc_orphans.py index 02e8dda1704..20e9b1cee84 100755 --- a/test/functional/rpc_orphans.py +++ b/test/functional/rpc_orphans.py @@ -4,10 +4,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Tests for orphan related RPCs.""" -import time - from test_framework.mempool_util import ( - ORPHAN_TX_EXPIRE_TIME, tx_in_orphanage, ) from test_framework.messages import ( @@ -101,8 +98,6 @@ class OrphanRPCsTest(BitcoinTestFramework): tx_child_2 = self.wallet.create_self_transfer(utxo_to_spend=tx_parent_2["new_utxo"]) peer_1 = node.add_p2p_connection(P2PInterface()) peer_2 = node.add_p2p_connection(P2PInterface()) - entry_time = int(time.time()) - node.setmocktime(entry_time) peer_1.send_and_ping(msg_tx(tx_child_1["tx"])) peer_2.send_and_ping(msg_tx(tx_child_2["tx"])) @@ -128,9 +123,6 @@ class OrphanRPCsTest(BitcoinTestFramework): assert_equal(len(node.getorphantxs()), 1) orphan_1 = orphanage[0] self.orphan_details_match(orphan_1, tx_child_1, verbosity=1) - self.log.info("Checking orphan entry/expiration times") - assert_equal(orphan_1["entry"], entry_time) - assert_equal(orphan_1["expiration"], entry_time + ORPHAN_TX_EXPIRE_TIME) self.log.info("Checking orphan details (verbosity 2)") orphanage = node.getorphantxs(verbosity=2) diff --git a/test/functional/test_framework/mempool_util.py b/test/functional/test_framework/mempool_util.py index 1955b2637ea..86946019c33 100644 --- a/test/functional/test_framework/mempool_util.py +++ b/test/functional/test_framework/mempool_util.py @@ -19,8 +19,6 @@ from .wallet import ( MiniWallet, ) -ORPHAN_TX_EXPIRE_TIME = 1200 - def assert_mempool_contents(test_framework, node, expected=None, sync=True): """Assert that all transactions in expected are in the mempool, and no additional ones exist. 'expected' is an array of