From ba7dd8bf6f41de647a8df0c4570df6ac20b08e48 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Mon, 3 Apr 2017 15:48:55 -0400 Subject: [PATCH 1/2] Test prioritisetransaction and ancestor fee state There is already a similar test for descendant fee state. --- test/functional/mempool_packages.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/functional/mempool_packages.py b/test/functional/mempool_packages.py index 17e3a9a96..feec8a7fd 100755 --- a/test/functional/mempool_packages.py +++ b/test/functional/mempool_packages.py @@ -101,6 +101,18 @@ class MempoolPackagesTest(BitcoinTestFramework): assert_equal(mempool[x], v_descendants[x]) assert(chain[0] not in v_descendants.keys()) + # Check that ancestor modified fees includes fee deltas from + # prioritisetransaction + self.nodes[0].prioritisetransaction(chain[0], 1000) + mempool = self.nodes[0].getrawmempool(True) + ancestor_fees = 0 + for x in chain: + ancestor_fees += mempool[x]['fee'] + assert_equal(mempool[x]['ancestorfees'], ancestor_fees * COIN + 1000) + + # Undo the prioritisetransaction for later tests + self.nodes[0].prioritisetransaction(chain[0], -1000) + # Check that descendant modified fees includes fee deltas from # prioritisetransaction self.nodes[0].prioritisetransaction(chain[-1], 1000) From 9bef02e36525d0eed4e2e31678b3ff04bbb0b8cb Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Mon, 3 Apr 2017 15:50:15 -0400 Subject: [PATCH 2/2] Bugfix: ancestor modifed fees were incorrect for descendants If prioritisetransaction was called for a tx with in-mempool descendants, the modified ancestor fee values for those descendants was incorrect. --- src/txmempool.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 36a046ed2..0794a3902 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -912,6 +912,13 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD BOOST_FOREACH(txiter ancestorIt, setAncestors) { mapTx.modify(ancestorIt, update_descendant_state(0, nFeeDelta, 0)); } + // Now update all descendants' modified fees with ancestors + setEntries setDescendants; + CalculateDescendants(it, setDescendants); + setDescendants.erase(it); + BOOST_FOREACH(txiter descendantIt, setDescendants) { + mapTx.modify(descendantIt, update_ancestor_state(0, nFeeDelta, 0, 0)); + } } } LogPrintf("PrioritiseTransaction: %s feerate += %s\n", hash.ToString(), FormatMoney(nFeeDelta));