diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -9,3 +9,8 @@ `getmempooldescendants` RPCs which have been deprecated for a long time are now removed. They are superseded by the `fees` object field which provides the same information. + - The `descendantcount`, `descendantsize`, `fees.descendant`, `ancestorcount`, + `ancestorsize` and `fees.ancestor` fields from the `getrawmempool`, + `getmempoolentry`, `getmempoolancestors`and `getmempooldescendants` RPCs are + deprecated. To keep using these fields, use the + `-deprecatedrpc=mempool_ancestors_descendants` option. diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -460,6 +460,83 @@ static std::vector MempoolEntryDescription() { const auto &ticker = Currency::get().ticker; + // Deprecated in v0.27.0 + if (IsDeprecatedRPCEnabled(gArgs, "mempool_ancestors_descendants")) { + return { + RPCResult{RPCResult::Type::NUM, "size", "transaction size."}, + RPCResult{ + RPCResult::Type::NUM_TIME, "time", + "local time transaction entered pool in seconds since 1 Jan " + "1970 GMT"}, + RPCResult{RPCResult::Type::NUM, "height", + "block height when transaction entered pool"}, + RPCResult{ + RPCResult::Type::NUM, "descendantcount", + "DEPRECATED: number of in-mempool descendant transactions " + "(including this one). Only displayed if the " + "-deprecatedrpc=mempool_ancestors_descendants option is set"}, + RPCResult{ + RPCResult::Type::NUM, "descendantsize", + "DEPRECATED: transaction size of in-mempool descendants " + "(including this one). Only displayed if the " + "-deprecatedrpc=mempool_ancestors_descendants option is set"}, + RPCResult{ + RPCResult::Type::NUM, "ancestorcount", + "DEPRECATED: number of in-mempool ancestor transactions " + "(including this one). Only displayed if the " + "-deprecatedrpc=mempool_ancestors_descendants option is set"}, + RPCResult{ + RPCResult::Type::NUM, "ancestorsize", + "DEPRECATED: transaction size of in-mempool ancestors " + "(including this one). Only displayed if the " + "-deprecatedrpc=mempool_ancestors_descendants option is set"}, + RPCResult{ + RPCResult::Type::OBJ, + "fees", + "", + { + RPCResult{RPCResult::Type::STR_AMOUNT, "base", + "transaction fee in " + ticker}, + RPCResult{RPCResult::Type::STR_AMOUNT, "modified", + "transaction fee with fee deltas used for " + "mining priority in " + + ticker}, + RPCResult{ + RPCResult::Type::STR_AMOUNT, "ancestor", + "DEPRECATED: modified fees (see above) of in-mempool " + "ancestors (including this one) in " + + ticker + + ". Only displayed if the " + "-deprecatedrpc=mempool_ancestors_descendants " + "option is set"}, + RPCResult{ + RPCResult::Type::STR_AMOUNT, "descendant", + "DEPRECATED: modified fees (see above) of in-mempool " + "descendants (including this one) in " + + ticker + + ". Only displayed if the " + "-deprecatedrpc=mempool_ancestors_descendants " + "option is set"}, + }}, + RPCResult{ + RPCResult::Type::ARR, + "depends", + "unconfirmed transactions used as inputs for this transaction", + {RPCResult{RPCResult::Type::STR_HEX, "transactionid", + "parent transaction id"}}}, + RPCResult{RPCResult::Type::ARR, + "spentby", + "unconfirmed transactions spending outputs from this " + "transaction", + {RPCResult{RPCResult::Type::STR_HEX, "transactionid", + "child transaction id"}}}, + RPCResult{ + RPCResult::Type::BOOL, "unbroadcast", + "Whether this transaction is currently unbroadcast (initial " + "broadcast not yet acknowledged by any peers)"}, + }; + } + return { RPCResult{RPCResult::Type::NUM, "size", "transaction size."}, RPCResult{RPCResult::Type::NUM_TIME, "time", @@ -467,18 +544,6 @@ "1970 GMT"}, RPCResult{RPCResult::Type::NUM, "height", "block height when transaction entered pool"}, - RPCResult{RPCResult::Type::NUM, "descendantcount", - "number of in-mempool descendant transactions (including " - "this one)"}, - RPCResult{RPCResult::Type::NUM, "descendantsize", - "transaction size of in-mempool descendants " - "(including this one)"}, - RPCResult{ - RPCResult::Type::NUM, "ancestorcount", - "number of in-mempool ancestor transactions (including this one)"}, - RPCResult{ - RPCResult::Type::NUM, "ancestorsize", - "transaction size of in-mempool ancestors (including this one)"}, RPCResult{RPCResult::Type::OBJ, "fees", "", @@ -489,14 +554,6 @@ "transaction fee with fee deltas used for " "mining priority in " + ticker}, - RPCResult{RPCResult::Type::STR_AMOUNT, "ancestor", - "modified fees (see above) of in-mempool " - "ancestors (including this one) in " + - ticker}, - RPCResult{RPCResult::Type::STR_AMOUNT, "descendant", - "modified fees (see above) of in-mempool " - "descendants (including this one) in " + - ticker}, }}, RPCResult{ RPCResult::Type::ARR, @@ -521,20 +578,27 @@ EXCLUSIVE_LOCKS_REQUIRED(pool.cs) { AssertLockHeld(pool.cs); + const bool deprecated_ancestors_descendants = + IsDeprecatedRPCEnabled(gArgs, "mempool_ancestors_descendants"); + UniValue fees(UniValue::VOBJ); fees.pushKV("base", e.GetFee()); fees.pushKV("modified", e.GetModifiedFee()); - fees.pushKV("ancestor", e.GetModFeesWithAncestors()); - fees.pushKV("descendant", e.GetModFeesWithDescendants()); + if (deprecated_ancestors_descendants) { + fees.pushKV("ancestor", e.GetModFeesWithAncestors()); + fees.pushKV("descendant", e.GetModFeesWithDescendants()); + } info.pushKV("fees", fees); info.pushKV("size", (int)e.GetTxSize()); info.pushKV("time", count_seconds(e.GetTime())); info.pushKV("height", (int)e.GetHeight()); - info.pushKV("descendantcount", e.GetCountWithDescendants()); - info.pushKV("descendantsize", e.GetSizeWithDescendants()); - info.pushKV("ancestorcount", e.GetCountWithAncestors()); - info.pushKV("ancestorsize", e.GetSizeWithAncestors()); + if (deprecated_ancestors_descendants) { + info.pushKV("descendantcount", e.GetCountWithDescendants()); + info.pushKV("descendantsize", e.GetSizeWithDescendants()); + info.pushKV("ancestorcount", e.GetCountWithAncestors()); + info.pushKV("ancestorsize", e.GetSizeWithAncestors()); + } const CTransaction &tx = e.GetTx(); std::set setDepends; for (const CTxIn &txin : tx.vin) { diff --git a/test/functional/mempool_package_limits.py b/test/functional/mempool_package_limits.py --- a/test/functional/mempool_package_limits.py +++ b/test/functional/mempool_package_limits.py @@ -69,9 +69,6 @@ txid = tx.get_id() if i < mempool_count: node.sendrawtransaction(txhex) - assert_equal( - node.getrawmempool(verbose=True)[txid]["ancestorcount"], - i + 1) else: chain_hex.append(txhex) chain_txns.append(tx) diff --git a/test/functional/mempool_packages.py b/test/functional/mempool_packages.py --- a/test/functional/mempool_packages.py +++ b/test/functional/mempool_packages.py @@ -25,7 +25,9 @@ class MempoolPackagesTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 - common_params = ["-maxorphantx=1000"] + common_params = [ + "-maxorphantx=1000", + "-deprecatedrpc=mempool_ancestors_descendants"] self.extra_args = [ common_params, common_params + ["-limitancestorcount={}".format(MAX_ANCESTORS_CUSTOM)]] @@ -112,7 +114,6 @@ # Check that getmempoolentry is consistent with getrawmempool entry = self.nodes[0].getmempoolentry(x) assert_equal(entry, mempool[x]) - # Check that the descendant calculations are correct assert_equal(mempool[x]['descendantcount'], descendant_count) descendant_fees += mempool[x]['fees']['base'] diff --git a/test/functional/mempool_updatefromblock.py b/test/functional/mempool_updatefromblock.py --- a/test/functional/mempool_updatefromblock.py +++ b/test/functional/mempool_updatefromblock.py @@ -24,6 +24,7 @@ '-limitancestorsize=5000', f'-limitancestorcount={self.limit_ancestor_descendant_count}', f'-limitdescendantcount={self.limit_ancestor_descendant_count}', + '-deprecatedrpc=mempool_ancestors_descendants', ], ]