rpc: calculate fees in getblock using BlockUndo data #18772

pull robot-visions wants to merge 2 commits into bitcoin:master from robot-visions:getblock-fee changing 4 files +85 −11
  1. robot-visions commented at 8:48 am on April 26, 2020: contributor

    This change is progress towards #18771 . It adapts the fee calculation part of #16083 and addresses some feedback. The additional “verbosity level 3” features are planned for a future PR.

    Original PR description:

    Using block undo data (like in #14802) we can now show fee information for each transaction in a block without the need for additional -txindex and/or a ton of costly lookups. For a start we’ll add transaction fee information to getblock verbosity level 2. This comes at a negligible speed penalty (<1%).

  2. robot-visions force-pushed on Apr 26, 2020
  3. robot-visions renamed this:
    rpc: calculate fee in getblock using BlockUndo data
    rpc: calculate fees in getblock using BlockUndo data
    on Apr 26, 2020
  4. robot-visions commented at 8:54 am on April 26, 2020: contributor

    The documentation for getblock refers to the tx format of getrawtransaction. Any thoughts on what would be a reasonable approach here?

    • Also update getrawtransaction (and the documentation) to include a fee if possible (this might be slow since the cost of loading undo data is no longer amortized over many transactions in a block)
    • Update the getblock documentation to mention that unlike getrawtransaction, it might also include fees
    • Leave the documentation alone and let the unfortunate user figure out the semantics themselves :)
  5. robot-visions force-pushed on Apr 26, 2020
  6. fanquake added the label RPC/REST/ZMQ on Apr 26, 2020
  7. MarcoFalke commented at 11:51 am on April 26, 2020: member
    Please add the right co-author to your commit, if your work is based on someone else’s work
  8. robot-visions force-pushed on Apr 26, 2020
  9. robot-visions commented at 5:50 pm on April 26, 2020: contributor
    Updated, thanks! I didn’t know about Co-authored-by feature before.
  10. robot-visions force-pushed on Apr 26, 2020
  11. DrahtBot commented at 6:13 pm on April 30, 2020: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #20406 (util: Avoid invalid integer negation in FormatMoney and ValueFromAmount by practicalswift)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  12. brakmic commented at 10:44 am on May 1, 2020: contributor

    ACK 732554a8a64ad5c9d49505272d225626566898de

    Built, run and tested on macOS Catalina 10.15.4

  13. in src/core_write.cpp:192 in 732554a8a6 outdated
    186@@ -186,6 +187,10 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
    187     entry.pushKV("locktime", (int64_t)tx.nLockTime);
    188 
    189     UniValue vin(UniValue::VARR);
    190+
    191+    CAmount nTotalIn = 0;
    192+    CAmount nTotalOut = 0;
    


    luke-jr commented at 3:34 pm on May 10, 2020:
    Why did you revert these back to the old variable name style? (I had changed them to amt_total_in/amt_total_out in my rebase…)

    robot-visions commented at 6:55 pm on May 10, 2020:
    No particular reason; I’d be happy with either way.
  14. in src/core_write.cpp:218 in 732554a8a6 outdated
    209@@ -205,6 +210,13 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
    210                 }
    211                 in.pushKV("txinwitness", txinwitness);
    212             }
    213+            if (txundo) {
    214+                CAmount nPrevOut = txundo->vprevout[i].out.nValue;
    215+                // Sanity check to avoid overflow
    216+                if (MoneyRange(nPrevOut)) {
    217+                    nTotalIn += nPrevOut;
    218+                }
    


    luke-jr commented at 3:35 pm on May 10, 2020:
    This seems unnecessary.

    robot-visions commented at 6:55 pm on May 10, 2020:
    Yeah, I agree it seems unnecessary. I added this in order to fix a failing fuzz test.
  15. in src/core_write.cpp:247 in 732554a8a6 outdated
    235@@ -224,9 +236,21 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
    236         ScriptPubKeyToUniv(txout.scriptPubKey, o, true);
    237         out.pushKV("scriptPubKey", o);
    238         vout.push_back(out);
    239+
    240+        // Sanity check to avoid overflow
    241+        if (MoneyRange(txout.nValue)) {
    242+            nTotalOut += txout.nValue;
    243+        }
    


    luke-jr commented at 3:36 pm on May 10, 2020:
    This won’t work right… nTotalOut would just be missing part of its amount, and the result calculated later will still be wrong.
  16. in src/core_write.cpp:250 in 732554a8a6 outdated
    245     entry.pushKV("vout", vout);
    246 
    247+    // For coinbase transactions we have txundo == nullptr
    248+    if (txundo) {
    249+        CAmount nFee = nTotalIn - nTotalOut;
    250+        assert(MoneyRange(nFee));
    


    luke-jr commented at 3:37 pm on May 10, 2020:
    CHECK_NONFATAL in RPC code
  17. in src/core_write.cpp:249 in 732554a8a6 outdated
    244     }
    245     entry.pushKV("vout", vout);
    246 
    247+    // For coinbase transactions we have txundo == nullptr
    248+    if (txundo) {
    249+        CAmount nFee = nTotalIn - nTotalOut;
    


    luke-jr commented at 3:37 pm on May 10, 2020:
    fees
  18. in src/rpc/blockchain.cpp:148 in 732554a8a6 outdated
    147-    {
    148-        if(txDetails)
    149-        {
    150+    if (txDetails) {
    151+        CBlockUndo blockUndo;
    152+        bool hasUndo = !IsBlockPruned(blockindex) && UndoReadFromDisk(blockUndo, blockindex);
    


    luke-jr commented at 3:40 pm on May 10, 2020:
    have_undo
  19. in src/rpc/blockchain.cpp:150 in 732554a8a6 outdated
    149-        {
    150+    if (txDetails) {
    151+        CBlockUndo blockUndo;
    152+        bool hasUndo = !IsBlockPruned(blockindex) && UndoReadFromDisk(blockUndo, blockindex);
    153+        for (size_t i = 0; i < block.vtx.size(); ++i) {
    154+            const auto& tx = block.vtx[i];
    


    luke-jr commented at 3:40 pm on May 10, 2020:
    .at(i)
  20. luke-jr commented at 3:42 pm on May 10, 2020: member
    Looks like it was based on the original PR rather than my rebase, and therefore missed some fixups.
  21. luke-jr commented at 5:03 pm on May 10, 2020: member
  22. robot-visions commented at 7:01 pm on May 10, 2020: contributor

    Thanks for the review and the update @luke-jr ! I’m happy to go with your proposed update (we can close this PR).

    Quick notes:

    • I didn’t include the verbosity 3 changes because I wanted to move things over incrementally
    • In your updates it might still be necessary to introduce some way to prevent the fuzz tests from failing (it was causing an integer overflow when adding a large value to amt_total_out); I added a halfhearted check (which you correctly pointed out doesn’t always work) but maybe it makes more sense to just update the fuzz test
  23. luke-jr commented at 2:35 am on May 14, 2020: member

    We don’t need to close this PR, you’re doing fine.

    If you want to adopt my branch as-is, you can just checkout yours, git reset --hard 0b46eb7ac63, and re-push it here.

  24. robot-visions force-pushed on May 17, 2020
  25. DrahtBot added the label Needs rebase on Jun 8, 2020
  26. in test/functional/rpc_getblock_fee.py:25 in 0b46eb7ac6 outdated
    20+
    21+    def run_test(self):
    22+        node = self.nodes[0]
    23+        address = node.getnewaddress()
    24+        node.generatetoaddress(101, address)
    25+        txid = node.sendtoaddress(address, 1)
    


    luke-jr commented at 0:08 am on June 10, 2020:

    txid is unused.

    (Feel free to update from my branch again)

  27. in src/core_write.cpp:244 in 0b46eb7ac6 outdated
    233@@ -224,9 +234,18 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
    234         ScriptPubKeyToUniv(txout.scriptPubKey, o, true);
    235         out.pushKV("scriptPubKey", o);
    236         vout.push_back(out);
    237+
    238+        amt_total_out += txout.nValue;
    


    luke-jr commented at 8:55 pm on June 14, 2020:
    The fuzzer can trigger undefined behaviour here with an overflow, which causes CI to fail even though it’s harmless. Not sure what the solution should be - seems like overkill to actually prevent.

    practicalswift commented at 2:54 pm on June 15, 2020:
    @luke-jr Functions are assumed to be robust as long as they are fed with inputs fulfilling their documented preconditions, so I think the only robust alternative to preventing it is to make the implicit precondition explicit by documenting it. However, in this case it seems easy to just use MoneyRange(…) and be done with it, no? :)
  28. robot-visions force-pushed on Sep 11, 2020
  29. DrahtBot removed the label Needs rebase on Sep 11, 2020
  30. robot-visions force-pushed on Sep 12, 2020
  31. in src/rpc/blockchain.cpp:171 in 1298f0fca7 outdated
    170+        CBlockUndo blockUndo;
    171+        const bool have_undo = !IsBlockPruned(blockindex) && UndoReadFromDisk(blockUndo, blockindex);
    172+        for (size_t i = 0; i < block.vtx.size(); ++i) {
    173+            const auto& tx = block.vtx.at(i);
    174+            // coinbase transaction (i == 0) doesn't have undo data
    175+            const CTxUndo* ptr_txundo = (have_undo && i) ? &blockUndo.vtxundo.at(i - 1) : nullptr;
    


    jnewbery commented at 1:29 pm on September 25, 2020:
    Just txundo is fine for the var name. Our style isn’t to prefix variable names with the type.
  32. in src/rpc/blockchain.cpp:169 in 1298f0fca7 outdated
    168-        {
    169+    if (txDetails) {
    170+        CBlockUndo blockUndo;
    171+        const bool have_undo = !IsBlockPruned(blockindex) && UndoReadFromDisk(blockUndo, blockindex);
    172+        for (size_t i = 0; i < block.vtx.size(); ++i) {
    173+            const auto& tx = block.vtx.at(i);
    


    jnewbery commented at 1:43 pm on September 25, 2020:
    I think auto should only be used when it’s immediately obvious from looking at the code what the type is, and when not using auto would be annoyingly verbose. Here, you’d need to look at the definition of a CBlock to determine that tx is a CTransactionRef object, and you’re not saving my characters by not typing CTransactionRef, so I’d recommend avoiding auto.
  33. in test/functional/rpc_getblock_fee.py:6 in 1298f0fca7 outdated
    0@@ -0,0 +1,44 @@
    1+#!/usr/bin/env python3
    2+# Copyright (c) 2020 The Bitcoin Core developers
    3+# Distributed under the MIT software license, see the accompanying
    4+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
    5+'''Test getblock rpc fee calculation.
    6+'''
    


    jnewbery commented at 1:43 pm on September 25, 2020:
    Join with line above

    glozow commented at 5:15 pm on September 30, 2020:
    nit: I think we also usually do double quotes? """
  34. in test/functional/rpc_getblock_fee.py:32 in 1298f0fca7 outdated
    27+
    28+        self.log.info('Ensure that getblock with verbosity 2 includes fee')
    29+        block = node.getblock(blockhash, 2)
    30+        assert 'fee' in block['tx'][1]
    31+
    32+        self.log.info('Ensure that getblock with verbosity 1 doesn\'t include fee')
    


    jnewbery commented at 1:45 pm on September 25, 2020:

    Use double quotes to avoid having to escape the quote inside the log:

    0        self.log.info("Ensure that getblock with verbosity 1 doesn't include fee")
    

    Same in the log below.

  35. in src/core_write.cpp:220 in 1298f0fca7 outdated
    214@@ -209,6 +215,11 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
    215                 txinwitness.push_back(HexStr(item));
    216             }
    217             in.pushKV("txinwitness", txinwitness);
    218+            if (txundo) {
    219+                const CTxOut& txout = txundo->vprevout[i].out;
    220+                // Suppress fuzz test failures by ignoring nonsense values
    


    jnewbery commented at 2:00 pm on September 25, 2020:
    It seems strange to me to have code in the produce that exists only to work around shortcomings in the fuzz tests. Which fuzz test fails if you don’t do this? (the only fuzz tester that calls TxToUniv() doesn’t provide a txundo param).

    MarcoFalke commented at 6:17 pm on September 28, 2020:
    Agree with @jnewbery . It is impossible to hit this condition in production, so an assert or just nothing at all might be more appropriate.

    practicalswift commented at 6:59 pm on September 28, 2020:
    I suggest stating the pre-condition in the form of an assertion or documentation. Then it is the fuzzer’s responsibility the fulfil all explicitly stated pre-conditions.
  36. jnewbery commented at 2:00 pm on September 25, 2020: member
    Looks good. It’d be nice if the test checked that the fee returned was correct rather than just testing that any value is returned.
  37. in src/core_write.cpp:219 in a05fe7f59e outdated
    214@@ -209,6 +215,11 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
    215                 txinwitness.push_back(HexStr(item));
    216             }
    217             in.pushKV("txinwitness", txinwitness);
    218+            if (txundo) {
    219+                const CTxOut& txout = txundo->vprevout[i].out;
    


    fjahr commented at 8:28 pm on September 29, 2020:
    maybe call this prev_txout or so
  38. in src/core_write.cpp:250 in a05fe7f59e outdated
    245     }
    246     entry.pushKV("vout", vout);
    247 
    248+    // For coinbase transactions we have txundo == nullptr
    249+    if (txundo) {
    250+        CAmount fee = amt_total_in - amt_total_out;
    


    fjahr commented at 8:29 pm on September 29, 2020:

    nit

    0        const CAmount fee = amt_total_in - amt_total_out;
    
  39. in src/rpc/blockchain.cpp:167 in a05fe7f59e outdated
    166-    {
    167-        if(txDetails)
    168-        {
    169+    if (txDetails) {
    170+        CBlockUndo blockUndo;
    171+        const bool have_undo = !IsBlockPruned(blockindex) && UndoReadFromDisk(blockUndo, blockindex);
    


    fjahr commented at 8:35 pm on September 29, 2020:

    I think you should use GetUndoChecked here and the RPC should fail if the details are requested but the undo data can not be found. Otherwise, the users can not trust that they get the fees in the response and they will have no way to know why they weren’t included, it will just seem random to them.

    BTW, I am unsure in which cases we are missing the undo data. Is that only in the case of data corruption or are there reasons that make this common? Or is pruning unreliable there in some sense? I couldn’t find anything on the topic.


    robot-dreams commented at 9:36 pm on October 1, 2020:

    Great idea!

    Yes, according to https://github.com/bitcoin/bitcoin/blob/1b313cacc99a1b372238f9036abed5491f9d28f7/src/validation.h#L370 it looks like block and undo data are always deleted together.

    I definitely might be missing something, but from a quick search I couldn’t find any other reason we’d delete rev but not blk files.


    sipa commented at 9:38 pm on October 1, 2020:
    I think it’s not unreasonable to delete undo data while keeping block data (that means you could still serve it to other syncing nodes, and rescan, but can’t reorg out of it). That just was never implemented.

    robot-dreams commented at 4:29 am on October 2, 2020:

    OK, you both make some great points. I can think of three approaches at the moment:

    • Use GetUndoChecked which means if someone deletes undo data in the future, they’ll cause this RPC to fail
    • Silently leave out the fee if block data is present but undo data is missing
    • Add some verbose documentation that says “we’ll include the fee if we have the data needed to efficiently calculate it”

    Do any of these approaches seem reasonable to both of you?


    fjahr commented at 9:55 pm on October 2, 2020:
    As @sipa says it’s not implemented and I think there is no one working on something like that (Side-note: I will look into that now :) ). So I would say the first option would still be my first choice if we could have a test that would reliably fail when the change comes. But that seems unrealistic, at least if it is implemented the way I envision it now and generally it would be poking around in the dark. So, I guess I would be happy if you add some docs but you don’t have to since with the current state of the code the fee should be there reliably.

    jnewbery commented at 8:33 am on October 5, 2020:
    I think either leaving it like it is now, or returning an error when the undo file is not available but the block file is (since that’s currently an unexpected condition) are both fine.
  40. in test/functional/rpc_getblock_fee.py:24 in 1298f0fca7 outdated
    19+        self.skip_if_no_wallet()
    20+
    21+    def run_test(self):
    22+        node = self.nodes[0]
    23+        address = node.getnewaddress()
    24+        node.generatetoaddress(101, address)
    


    fjahr commented at 8:52 pm on September 29, 2020:
    You don’t need to do this to have coins to spend. This is done for you automatically by default (see docs on setup_clean_chain) and this uses fewer resources by loading the chain from cache.
  41. in test/functional/rpc_getblock_fee.py:14 in 1298f0fca7 outdated
     9+
    10+from test_framework.test_framework import BitcoinTestFramework
    11+from test_framework.util import get_datadir_path
    12+
    13+
    14+class GetblockFeeTest(BitcoinTestFramework):
    


    fjahr commented at 9:14 pm on September 29, 2020:
    I think rpc_blockchain.py is the natural place for these tests. A new file is not necessary for such a specific and small test IMO.
  42. fjahr commented at 9:44 pm on September 29, 2020: member
    Concept ACK
  43. troygiorshev commented at 4:47 pm on September 30, 2020: contributor

    Approach ACK.

    Reviewed changes, ran tests. Need to manually test further. 💻

    I agree with the previous review comments.

    Feel free to add a commit at the beginning cleaning up the code around your changes! For example:

  44. Emzy commented at 10:34 am on October 1, 2020: contributor

    I get following error:

    0$ bitcoin-cli getblock "$(bitcoin-cli getblockhash 650684)" 2
    1error code: -1
    2error message:
    3core_write.cpp:251 (TxToUniv)
    4Internal bug detected: 'MoneyRange(fee)'
    5You may report this issue here: https://github.com/bitcoin/bitcoin/issues
    

    A block with only a Coinbase transaction works, for example 650026.

  45. robot-visions force-pushed on Oct 1, 2020
  46. robot-visions force-pushed on Oct 1, 2020
  47. robot-visions force-pushed on Oct 2, 2020
  48. Emzy commented at 12:54 pm on October 2, 2020: contributor

    I get following error:

    0$ bitcoin-cli getblock "$(bitcoin-cli getblockhash 650684)" 2
    1error code: -1
    2error message:
    3core_write.cpp:251 (TxToUniv)
    4Internal bug detected: 'MoneyRange(fee)'
    5You may report this issue here: https://github.com/bitcoin/bitcoin/issues
    

    A block with only a Coinbase transaction works, for example 650026.

    8a7229e2e5c306e86a6a589c1ab0e4c58ea49545 fixed it.

  49. robot-visions force-pushed on Oct 3, 2020
  50. robot-visions force-pushed on Oct 3, 2020
  51. in src/core_write.cpp:198 in 8e38a27c69 outdated
    190@@ -189,13 +191,20 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
    191     entry.pushKV("weight", GetTransactionWeight(tx));
    192     entry.pushKV("locktime", (int64_t)tx.nLockTime);
    193 
    194-    UniValue vin(UniValue::VARR);
    195+    UniValue vin{UniValue::VARR};
    196+
    197+    // If available, use Undo data to calculate the fee. Note that txundo == nullptr
    198+    // for coinbase transactions and for transactions in pruned blocks.
    199+    bool calculate_fee = txundo != nullptr;
    


    fjahr commented at 3:58 pm on October 4, 2020:
    nit: could be const
  52. in src/rpc/blockchain.cpp:934 in 8e38a27c69 outdated
    930@@ -926,6 +931,7 @@ static RPCHelpMan getblock()
    931                         {RPCResult::Type::OBJ, "", "",
    932                         {
    933                             {RPCResult::Type::ELISION, "", "The transactions in the format of the getrawtransaction RPC. Different from verbosity = 1 \"tx\" result"},
    934+                            {RPCResult::Type::NUM, "fee", "The transaction fee in " + CURRENCY_UNIT + ", omitted if efficient calculation isn't possible (due to pruning)"},
    


    fjahr commented at 4:26 pm on October 4, 2020:

    Hm, I think since with the currently available version of pruning the block wouldn’t be found anyway this would be slightly better and also more precise:

    0                            {RPCResult::Type::NUM, "fee", "The transaction fee in " + CURRENCY_UNIT + ", omitted if efficient calculation isn't possible (due to block undo data being unavailable)"},
    
  53. in src/core_write.cpp:197 in 8e38a27c69 outdated
    190@@ -189,13 +191,20 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
    191     entry.pushKV("weight", GetTransactionWeight(tx));
    192     entry.pushKV("locktime", (int64_t)tx.nLockTime);
    193 
    194-    UniValue vin(UniValue::VARR);
    195+    UniValue vin{UniValue::VARR};
    196+
    197+    // If available, use Undo data to calculate the fee. Note that txundo == nullptr
    198+    // for coinbase transactions and for transactions in pruned blocks.
    


    fjahr commented at 4:28 pm on October 4, 2020:

    I think it’s slightly better to be a bit more precise here. There may be other reason (in the future) why there is no undo data.

    0    // for coinbase transactions and for transactions where undo data is unavailable.
    
  54. fjahr commented at 4:30 pm on October 4, 2020: member

    utACK 8ccfbde6fafa9f862bc21a8337a86f0cc465967f

    Feel free to ignore my comments unless you have to make other changes.

  55. robot-visions force-pushed on Oct 4, 2020
  56. in src/rpc/blockchain.cpp:934 in aae692c3e2 outdated
    930@@ -926,6 +931,7 @@ static RPCHelpMan getblock()
    931                         {RPCResult::Type::OBJ, "", "",
    932                         {
    933                             {RPCResult::Type::ELISION, "", "The transactions in the format of the getrawtransaction RPC. Different from verbosity = 1 \"tx\" result"},
    934+                            {RPCResult::Type::NUM, "fee", "The transaction fee in " + CURRENCY_UNIT + ", omitted if efficient calculation isn't possible (due to unavailable block undo data)"},
    


    jnewbery commented at 8:37 am on October 5, 2020:
    I think this would be fine as just “omitted if block undo data is not available”. I don’t think users would care about or understand what you mean by ’efficient calculation'.
  57. in test/functional/rpc_blockchain.py:359 in aae692c3e2 outdated
    354@@ -352,6 +355,42 @@ def assert_waitforheight(height, timeout=2):
    355         assert_waitforheight(current_height)
    356         assert_waitforheight(current_height + 1)
    357 
    358+    def _test_getblock(self):
    359+        if not self.is_wallet_compiled():
    


    jnewbery commented at 8:39 am on October 5, 2020:
    Did you look at using miniwallet.py to manually create the transactions? That would avoid a dependency on a compiled wallet to test this functionality.
  58. in test/functional/rpc_blockchain.py:375 in aae692c3e2 outdated
    370+        assert 'fee' not in block['tx'][1]
    371+
    372+        self.log.info('Test that getblock with verbosity 2 includes expected fee')
    373+        block = node.getblock(blockhash, 2)
    374+        assert 'fee' in block['tx'][1]
    375+        assert_equal(block['tx'][1]['fee'], Decimal('0.00004380'))
    


    jnewbery commented at 8:40 am on October 5, 2020:
    Unless you’re setting amounts/fee explicitly, this feels brittle (i.e. this test would break if an unrelated change was made in how the wallet code sets fees).
  59. robot-visions force-pushed on Oct 8, 2020
  60. jnewbery commented at 9:49 am on October 9, 2020: member

    utACK dd4ec0704c66c23d207bb7394823469a1b59b060

    Since the first commit is very different from the version in 16083, you should feel free to set yourself as the commit author and add felix as a co-author (or just add yourself as co-author).

    Also feel free to set the review comments above as ‘resolved’ if you think they’re addressed. I went through and resolved my own review comments, but didn’t resolve comments from other reviewers. Setting all comments to resolved signals to other reviewers that you’ve addressed all the outstanding issues.

  61. RPC: getblock: tx fee calculation for verbosity 2 via Undo data
    Co-authored-by: Felix Weis <mail@felixweis.com>
    bf7d6e31b1
  62. test: RPC: getblock fee calculations 66d012ad7f
  63. robot-visions force-pushed on Oct 9, 2020
  64. luke-jr commented at 5:37 pm on November 8, 2020: member
    tACK 66d012ad7f9381bacfc9b8388fa2ebf82cb86c9e
  65. fjahr commented at 5:16 pm on December 23, 2020: member

    tACK 66d012ad7f9381bacfc9b8388fa2ebf82cb86c9e

    Changes since last review were a small refactoring of the functional test using MiniWallet and some improvements on comments/docs.

  66. in test/functional/rpc_blockchain.py:379 in 66d012ad7f
    374+        assert 'fee' not in block['tx'][1]
    375+
    376+        self.log.info('Test that getblock with verbosity 2 includes expected fee')
    377+        block = node.getblock(blockhash, 2)
    378+        tx = block['tx'][1]
    379+        assert 'fee' in tx
    


    MarcoFalke commented at 2:05 pm on December 24, 2020:
    no need for this check. The next line would already fail with KeyError
  67. in test/functional/rpc_blockchain.py:383 in 66d012ad7f
    378+        tx = block['tx'][1]
    379+        assert 'fee' in tx
    380+        assert_equal(tx['fee'], tx['vsize'] * fee_per_byte)
    381+
    382+        self.log.info("Test that getblock with verbosity 2 still works with pruned Undo data")
    383+        datadir = get_datadir_path(self.options.tmpdir, 0)
    


    MarcoFalke commented at 2:06 pm on December 24, 2020:
    no need for the import node.datadir should suffice
  68. MarcoFalke approved
  69. MarcoFalke commented at 2:31 pm on December 24, 2020: member

    Untitled pnggg

    review ACK 66d012ad7f9381bacfc9b8388fa2ebf82cb86c9e 🗜

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3review ACK 66d012ad7f9381bacfc9b8388fa2ebf82cb86c9e 🗜
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUiUbgwAzPzceMugFaUVExZY36XvjsXenEtSk7a/xjrn8+SkZOd1gPtb852CYkQF
     8CuWb42KnECcFnSw+BvesBuHqn6lcOdHlD8yqNaA3IJdW1UJREN0ik8rScuBnNigS
     97PrsiSJVESlXP16YcvlcFl/z/OmZ15tY+p+6IIed5/tp1CC5SYvkx2qUgLFXomU3
    10pbiuzE6rePULNjthMcS+CO8/8id2hPT4UoJdRxEZJ5pAqaIAtdwe0XFAUEFt6jwM
    112gkafeYnfk3c/lz/oIschVRrwFI/Hff7H/yuVPDzXebzQvHyMOATSyguB4xSVtyD
    12tXOUlVovzdCkm6pTXn2gFLm59NbPDW0VbfJcFrhTEFdFV70MQ3scqgckTu74TZ4p
    13cCQtQxt+bL4yHh3/CaiFon/OCK2kusAnajjqXCjwp8fmhbve5gI1t9QZXLy2QN9i
    144cs6ppl+i/e+Ts0yl0xziwecso7Xcx3UwXbzfNK+UQ1p8UhSLm8xaU0LVu6aNEcz
    15+E+TevCn
    16=deRF
    17-----END PGP SIGNATURE-----
    

    Timestamp of file with hash 3dfd17a565ae7ddbda9eaa8abb03935bc4380ceae2f4f25005f5f9c93ad5a7c8 -

  70. MarcoFalke merged this on Dec 24, 2020
  71. MarcoFalke closed this on Dec 24, 2020

  72. sidhujag referenced this in commit c3b8e845b1 on Dec 24, 2020
  73. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-05 19:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me