Fix issue with conflicted mempool tx in listsinceblock #17258

pull adamjonas wants to merge 1 commits into bitcoin:master from adamjonas:listsinceblock-filter-conflicts changing 2 files +50 −1
  1. adamjonas commented at 7:08 pm on October 25, 2019: member

    Closes #8752 by bringing back abandoned #10470 originally written by @mchrostowski.

    This now checks that returned transactions are not conflicting with any transactions that are filtered out by the given blockhash and add a functional test to prevent this in the future.

    For more context, #8757 was closed in favor of #10470.

  2. fanquake added the label Wallet on Oct 25, 2019
  3. fanquake added the label RPC/REST/ZMQ on Oct 25, 2019
  4. fanquake commented at 7:17 pm on October 25, 2019: member
    Was the intention to cherry-pick / attribute the original author here? You could add a Co-Authored-By: Author Name <email@address.com> to the commit body.
  5. adamjonas force-pushed on Oct 25, 2019
  6. adamjonas commented at 8:01 pm on October 25, 2019: member
    Thanks @fanquake. It was extra work to rebase original commits since listsinceblock.py was merged into wallet_listsinceblock.py. Updated to reflect the contribution of the original author.
  7. DrahtBot commented at 8:32 pm on October 25, 2019: 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:

    • #15931 (Remove GetDepthInMainChain dependency on locked chain interface by ariard)

    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.

  8. fanquake requested review from TheBlueMatt on Oct 25, 2019
  9. fanquake requested review from instagibbs on Oct 25, 2019
  10. in test/functional/wallet_listsinceblock.py:17 in 700a288906 outdated
    10@@ -11,6 +11,10 @@
    11     assert_raises_rpc_error,
    12     connect_nodes,
    13 )
    14+from decimal import Decimal
    15+
    16+# Sequence number that is BIP 125 opt-in and BIP 68-compliant
    17+BIP125_SEQUENCE_NUMBER = 0xfffffffd
    


    instagibbs commented at 1:13 pm on October 28, 2019:
    That should already be in test_framework.messages module

    adamjonas commented at 2:29 pm on October 28, 2019:
    Right. Updated.
  11. in test/functional/wallet_listsinceblock.py:331 in 700a288906 outdated
    326+            if tx['txid'] == double_tx['txid']:
    327+                double_found = True
    328+        assert_equal(original_found, True)
    329+        assert_equal(double_found, True)
    330+
    331+        lastblockhash = spending_node.generate(6)[5]
    


    instagibbs commented at 1:20 pm on October 28, 2019:
    why 6?

    adamjonas commented at 2:34 pm on October 28, 2019:
    This was copied from the test_reorg test, but that doesn’t seem necessary here, so knocked it down to 1.
  12. instagibbs commented at 1:21 pm on October 28, 2019: member
    Looks ok enough. Test seems to make sense too, but I’m not the guy to ask about listsinceblock. @kallewoof I recollect you filing issues on the topic, could you tag in?
  13. Fix issue with conflicted mempool tx in listsinceblock
    listsinceblock now checks that returned transactions are not
    conflicting with any transactions that are filtered out by
    the given blockhash
    
    Co-Authored-By: Michael Chrostowski <michael.chrostowski@gmail.com>
    436ad43643
  14. adamjonas force-pushed on Oct 28, 2019
  15. instagibbs commented at 2:41 pm on October 28, 2019: member

    utACK https://github.com/bitcoin/bitcoin/pull/17258/commits/436ad436434b94982bcb7dc1d13a21949263ef73

    but someone with more history with the RPC call should review

  16. fanquake requested review from kallewoof on Oct 29, 2019
  17. kallewoof commented at 11:31 am on November 2, 2019: member
    utACK 436ad436434b94982bcb7dc1d13a21949263ef73
  18. kallewoof approved
  19. in src/wallet/rpcwallet.cpp:1594 in 436ad43643
    1590@@ -1591,7 +1591,7 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
    1591     for (const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
    1592         CWalletTx tx = pairWtx.second;
    1593 
    1594-        if (depth == -1 || tx.GetDepthInMainChain(*locked_chain) < depth) {
    1595+        if (depth == -1 || abs(tx.GetDepthInMainChain(*locked_chain)) < depth) {
    


    jonatack commented at 5:35 pm on November 4, 2019:
    Perhaps document in the code here why this works. To borrow from the original author, that this takes advantage of CMerkleTx::GetDepthInMainChain() returning a negative value for conflicted transactions. The negative value represents the depth of the transaction with which it is conflicted. Taking abs() of this allows using the same logic for filtering un-conflicted transactions to filter the conflicted ones.
  20. in test/functional/wallet_listsinceblock.py:16 in 436ad43643
    11     assert_equal,
    12     assert_raises_rpc_error,
    13     connect_nodes,
    14 )
    15 
    16+from decimal import Decimal
    


    jonatack commented at 5:37 pm on November 4, 2019:
    nit: IIRC the codebase convention is to place language imports above codebase ones
  21. jonatack commented at 5:59 pm on November 4, 2019: member

    I’m not qualifed to give an ACK here but 436ad436434b94982bcb7dc1d13a21949263ef73 appears reasonable. Built/ran tests/verified that this test fails without the change in rpcwallet.cpp:

    0File "./wallet_listsinceblock.py", line 340, in double_spends_filtered
    1  assert_equal(original_found, False)
    

    Feel free to ignore the comments below.

  22. meshcollider commented at 8:54 am on November 5, 2019: contributor
    LGTM 436ad436434b94982bcb7dc1d13a21949263ef73
  23. meshcollider referenced this in commit bfc4c896d6 on Nov 5, 2019
  24. meshcollider merged this on Nov 5, 2019
  25. meshcollider closed this on Nov 5, 2019

  26. mchrostowski commented at 6:45 pm on November 5, 2019: contributor

    I’m still confused as to why you put your name on my work.

    Good job getting the fix in. @adamjonas I see now this was not possible with a rebase and my comment was out of line. Thanks for the attribution!

  27. adamjonas deleted the branch on Nov 5, 2019
  28. kallewoof commented at 8:27 am on November 6, 2019: member

    I’m still confused as to why you put your name on my work.

    Good job getting the fix in.

    You didn’t respond to requests on your pull request for two years, that’s probably why. And your name is on the commit, it just now has another user’s name as well, which is fair since they did work to get it merged after all.

  29. laanwj commented at 12:07 pm on November 6, 2019: member

    I’m still confused as to why you put your name on my work.

    I don’t think that complaint is warranted. Looking at the commit it’s attributed in every way possible.

    0Fix issue with conflicted mempool tx in listsinceblock
    1[@adamjonas](/bitcoin-bitcoin/contributor/adamjonas/)
    2[@mchrostowski](/bitcoin-bitcoin/contributor/mchrostowski/)
    3adamjonas and mchrostowski committed 16 days ago
    4
    5listsinceblock now checks that returned transactions are not
    6conflicting with any transactions that are filtered out by
    7the given blockhash
    8
    9Co-Authored-By: Michael Chrostowski <michael.chrostowski@gmail.com>
    

    It’s also bad etiquette to change a commit and not add your own name, because it’s no longer the original work.

    If you disagree with this kind of use of your code, please do not contribute it under the MIT license (even implicitly by contributing it a repository licensed thus) in the first place.

  30. ryanofsky commented at 4:47 pm on November 6, 2019: member

    I don’t think that complaint is warranted. Looking at the commit it’s attributed in every way possible.

    Basically agree, but it is possible to give credit beyond adding the original author name to metadata. You can say, “This idea was originally proposed by [person] in [url]”, “This was originally implemented by [person] at [url] and the following changes have been made here […]”

  31. mchrostowski commented at 9:23 pm on November 6, 2019: contributor

    Looking at the commit it’s attributed in every way possible.

    That happened after it was called out. Attribution has been important everywhere I’ve been in my life and I want to be sure the parties involved are aware of each other.

    It’s also bad etiquette to change a commit and not add your own name, because it’s no longer the original work.

    I fully agree and did not mean to suggest otherwise. It actually looks like it was a lot more changes than I anticipated so I see why he nuked my commits and made one so I should not have made the comment.

    I am greatly appreciative of @adamjonas for fixing the issue, referencing the original code, and the attribution as well as @fanquake for getting attention to the pull request. The code, though only 5 characters, took some time and I’m grateful to see it was not in vain. Seriously, when I had to rebase this thing I gave up (scary sneks) so it was exciting to see someone else grab it up.

  32. adamjonas commented at 10:01 pm on November 6, 2019: member
    @mchrostowski I agree that I was in the wrong when I opened the PR and mentioned the previous PR but didn’t attribute you as the original author as fanquake pointed out (I was unaware of that tag). All I can say is that it wasn’t meant as a slight and I’ll be more intentional going forward.
  33. sidhujag referenced this in commit c06d5017eb on Nov 7, 2019
  34. MarcoFalke commented at 8:32 pm on November 11, 2019: member
    @laanwj Does the “generate release notes contributors” read the Co-Authored-By: tag from commit bodies as well?
  35. MarcoFalke commented at 8:32 pm on November 11, 2019: member
    Also, this should probably be backported to 0.19.1?
  36. luke-jr referenced this in commit afcb823d4d on Nov 15, 2019
  37. MarkLTZ referenced this in commit 92a27c32fb on Nov 17, 2019
  38. fanquake added the label Needs backport (0.19) on Jan 13, 2020
  39. promag referenced this in commit 88729d804e on Jan 14, 2020
  40. fanquake removed the label Needs backport (0.19) on Jan 14, 2020
  41. fanquake commented at 9:41 am on January 14, 2020: member
    Being backported in 17792.
  42. laanwj referenced this in commit 98159132c3 on Jan 20, 2020
  43. laanwj commented at 8:02 pm on January 23, 2020: member

    @laanwj Does the “generate release notes contributors” read the Co-Authored-By: tag from commit bodies as well?

    No, it doesn’t at the moment (probably should…).

  44. sidhujag referenced this in commit cc82e86c7f on Nov 10, 2020
  45. 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-11-25 21:12 UTC

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