rpc: remove deprecated fee fields from mempool entries

This commit is contained in:
Sebastian Falbesoner 2022-05-25 01:59:23 +02:00
parent 345457b542
commit 387ae8bc09
3 changed files with 0 additions and 91 deletions

View File

@ -229,23 +229,12 @@ static std::vector<RPCResult> MempoolEntryDescription()
return {
RPCResult{RPCResult::Type::NUM, "vsize", "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", "transaction weight as defined in BIP 141."},
RPCResult{RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true,
"transaction fee, denominated in " + CURRENCY_UNIT + " (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
RPCResult{RPCResult::Type::STR_AMOUNT, "modifiedfee", /*optional=*/true,
"transaction fee with fee deltas used for mining priority, denominated in " + CURRENCY_UNIT +
" (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
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", "number of in-mempool descendant transactions (including this one)"},
RPCResult{RPCResult::Type::NUM, "descendantsize", "virtual transaction size of in-mempool descendants (including this one)"},
RPCResult{RPCResult::Type::STR_AMOUNT, "descendantfees", /*optional=*/true,
"transaction fees of in-mempool descendants (including this one) with fee deltas used for mining priority, denominated in " +
CURRENCY_ATOM + "s (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
RPCResult{RPCResult::Type::NUM, "ancestorcount", "number of in-mempool ancestor transactions (including this one)"},
RPCResult{RPCResult::Type::NUM, "ancestorsize", "virtual transaction size of in-mempool ancestors (including this one)"},
RPCResult{RPCResult::Type::STR_AMOUNT, "ancestorfees", /*optional=*/true,
"transaction fees of in-mempool ancestors (including this one) with fee deltas used for mining priority, denominated in " +
CURRENCY_ATOM + "s (DEPRECATED, returned only if config option -deprecatedrpc=fees is passed)"},
RPCResult{RPCResult::Type::STR_HEX, "wtxid", "hash of serialized transaction, including witness data"},
RPCResult{RPCResult::Type::OBJ, "fees", "",
{
@ -269,24 +258,12 @@ static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPool
info.pushKV("vsize", (int)e.GetTxSize());
info.pushKV("weight", (int)e.GetTxWeight());
// TODO: top-level fee fields are deprecated. deprecated_fee_fields_enabled blocks should be removed in v24
const bool deprecated_fee_fields_enabled{IsDeprecatedRPCEnabled("fees")};
if (deprecated_fee_fields_enabled) {
info.pushKV("fee", ValueFromAmount(e.GetFee()));
info.pushKV("modifiedfee", ValueFromAmount(e.GetModifiedFee()));
}
info.pushKV("time", count_seconds(e.GetTime()));
info.pushKV("height", (int)e.GetHeight());
info.pushKV("descendantcount", e.GetCountWithDescendants());
info.pushKV("descendantsize", e.GetSizeWithDescendants());
if (deprecated_fee_fields_enabled) {
info.pushKV("descendantfees", e.GetModFeesWithDescendants());
}
info.pushKV("ancestorcount", e.GetCountWithAncestors());
info.pushKV("ancestorsize", e.GetSizeWithAncestors());
if (deprecated_fee_fields_enabled) {
info.pushKV("ancestorfees", e.GetModFeesWithAncestors());
}
info.pushKV("wtxid", pool.vTxHashes[e.vTxHashesIdx].first.ToString());
UniValue fees(UniValue::VOBJ);

View File

@ -1,67 +0,0 @@
#!/usr/bin/env python3
# Copyright (c) 2021 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test deprecation of fee fields from top level mempool entry object"""
from test_framework.blocktools import COIN
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
from test_framework.wallet import MiniWallet
def assertions_helper(new_object, deprecated_object, deprecated_fields):
for field in deprecated_fields:
assert field in deprecated_object
assert field not in new_object
class MempoolFeeFieldsDeprecationTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.extra_args = [[], ["-deprecatedrpc=fees"]]
def run_test(self):
# we get spendable outputs from the premined chain starting
# at block 76. see BitcoinTestFramework._initialize_chain() for details
self.wallet = MiniWallet(self.nodes[0])
self.wallet.rescan_utxos()
# we create the tx on the first node and wait until it syncs to node_deprecated
# thus, any differences must be coming from getmempoolentry or getrawmempool
tx = self.wallet.send_self_transfer(from_node=self.nodes[0])
self.nodes[1].sendrawtransaction(tx["hex"])
deprecated_fields = ["ancestorfees", "descendantfees", "modifiedfee", "fee"]
self.test_getmempoolentry(tx["txid"], deprecated_fields)
self.test_getrawmempool(tx["txid"], deprecated_fields)
self.test_deprecated_fields_match(tx["txid"])
def test_getmempoolentry(self, txid, deprecated_fields):
self.log.info("Test getmempoolentry rpc")
entry = self.nodes[0].getmempoolentry(txid)
deprecated_entry = self.nodes[1].getmempoolentry(txid)
assertions_helper(entry, deprecated_entry, deprecated_fields)
def test_getrawmempool(self, txid, deprecated_fields):
self.log.info("Test getrawmempool rpc")
entry = self.nodes[0].getrawmempool(verbose=True)[txid]
deprecated_entry = self.nodes[1].getrawmempool(verbose=True)[txid]
assertions_helper(entry, deprecated_entry, deprecated_fields)
def test_deprecated_fields_match(self, txid):
self.log.info("Test deprecated fee fields match new fees object")
entry = self.nodes[0].getmempoolentry(txid)
deprecated_entry = self.nodes[1].getmempoolentry(txid)
assert_equal(deprecated_entry["fee"], entry["fees"]["base"])
assert_equal(deprecated_entry["modifiedfee"], entry["fees"]["modified"])
assert_equal(deprecated_entry["descendantfees"], entry["fees"]["descendant"] * COIN)
assert_equal(deprecated_entry["ancestorfees"], entry["fees"]["ancestor"] * COIN)
if __name__ == "__main__":
MempoolFeeFieldsDeprecationTest().main()

View File

@ -328,7 +328,6 @@ BASE_SCRIPTS = [
'feature_presegwit_node_upgrade.py',
'feature_settings.py',
'rpc_getdescriptorinfo.py',
'rpc_mempool_entry_fee_fields_deprecation.py',
'rpc_mempool_info.py',
'rpc_help.py',
'feature_dirsymlinks.py',