Skip to content

Conversation

glozow
Copy link
Member

@glozow glozow commented Jul 22, 2022

Test each RBF rule more thoroughly and in isolation so we're not relying on things like overall mempool acceptance logic, ordering of mempool checks, RPC results, etc.

RBF was pretty recently refactored out, so there isn't much unit test coverage. From https://marcofalke.github.io/btc_cov/test_bitcoin.coverage/src/policy/rbf.cpp.gcov.html:
image

@glozow glozow added the Tests label Jul 22, 2022
@jonatack
Copy link
Member

Concept ACK and code looks good on first read.

test/rbf_tests.cpp:47:14: error: calling function 'addUnchecked' requires holding mutex 'pool.cs' exclusively [-Werror,-Wthread-safety-analysis]
        pool.addUnchecked(entry.FromTx(next_tx));
             ^
test/rbf_tests.cpp:47:14: error: calling function 'addUnchecked' requires holding mutex 'cs_main' exclusively [-Werror,-Wthread-safety-analysis]

@glozow glozow force-pushed the 2022-07-rbf-unit-tests branch from b707bfe to 645c593 Compare July 22, 2022 16:26
Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crACK 645c593

Just a few improvements suggested

@DrahtBot
Copy link
Contributor

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #25038 (policy: nVersion=3 and Package RBF by glozow)

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.

@glozow glozow force-pushed the 2022-07-rbf-unit-tests branch from 645c593 to 433411a Compare July 25, 2022 07:48
@fanquake fanquake requested a review from instagibbs July 25, 2022 14:16
@instagibbs
Copy link
Member

reACK 433411a

Copy link
Member

@darosior darosior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

@glozow glozow force-pushed the 2022-07-rbf-unit-tests branch from 433411a to 520657a Compare July 26, 2022 10:25
@jamesob
Copy link
Contributor

jamesob commented Jul 26, 2022

Concept ACK, will review soon

Copy link
Member

@darosior darosior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 520657a

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looking at this but seeing tests green with very different values for low_fee and normal_fee and high_fee. Only when low_fee > high_fee do I start to see some red (which may make sense given the RBF rules, but then maybe use test values that highlight the minimum necessary value deltas). The tests pass with these values, for instance:

-    const CAmount low_fee{100};
-    const CAmount normal_fee{10000};
-    const CAmount high_fee{1 * COIN};
+    const CAmount low_fee{1000000};
+    const CAmount normal_fee{100};
+    const CAmount high_fee{1000000};

Various minor comments follow, feel free to pick/choose/ignore.

@@ -117,6 +117,7 @@ BITCOIN_TESTS =\
test/prevector_tests.cpp \
test/raii_event_tests.cpp \
test/random_tests.cpp \
test/rbf_tests.cpp \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional, feel free to ignore, maybe add this file to the RUN_TIDY include-what-you-use list in ci/test/06_script_b.sh and update the headers with any relevant suggestions in the tidy CI output.

Copy link
Contributor

@t-bast t-bast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 520657a

@glozow
Copy link
Member Author

glozow commented Jul 28, 2022

Still looking at this but seeing tests green with very different values for low_fee and normal_fee and high_fee.

The fees should now be 10x apart each, so hopefully less arbitrary.

Also, apologies for the confusion, I should have mentioned that I pulled this out of #25038 which includes a new check for ancestor feerate. The low-high fees are essentially CPFPs and make a significant difference there, but are largely ignored in the current rules (hence all the "notice how ancestor feerate is not checked here" test cases in this PR). There's probably still room to make the values tighter, but hopefully this background helps.

@glozow glozow force-pushed the 2022-07-rbf-unit-tests branch from 520657a to 2a29c84 Compare July 28, 2022 10:51
Test each component of the RBF policy in isolation. Unlike the RBF
functional tests, these do not rely on things like RPC results, mempool
submission, etc.
@glozow glozow force-pushed the 2022-07-rbf-unit-tests branch from 2a29c84 to c320cdd Compare July 28, 2022 11:05
Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK c320cdd

@instagibbs
Copy link
Member

reACK c320cdd

@jonatack
Copy link
Member

Thanks for the context.

ACK c320cdd

(modulo I haven't yet looked at #25038)

@glozow
Copy link
Member Author

glozow commented Jul 28, 2022

This has 3 ACKs (thanks @w0xlt, @instagibbs, @jonatack) and the previous state had 2 other ACKs (thanks @darosior, @t-bast). This PR is just adding test coverage and doesn't conflict with anything other than my draft PR it's pulled out from. As such, it seems there is sufficient review to merge even though I am the author.

@glozow glozow merged commit 41205bf into bitcoin:master Jul 28, 2022
@glozow glozow deleted the 2022-07-rbf-unit-tests branch July 28, 2022 16:23
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 29, 2022
c320cdd [unit tests] individual RBF Rules in isolation (glozow)

Pull request description:

  Test each RBF rule more thoroughly and in isolation so we're not relying on things like overall mempool acceptance logic, ordering of mempool checks, RPC results, etc.

  RBF was pretty recently refactored out, so there isn't much unit test coverage. From https://marcofalke.github.io/btc_cov/test_bitcoin.coverage/src/policy/rbf.cpp.gcov.html:
  ![image](https://user-images.githubusercontent.com/25183001/180783280-6777f4b4-ef95-462a-b414-1a9e268836a6.png)

ACKs for top commit:
  instagibbs:
    reACK bitcoin@c320cdd
  jonatack:
    ACK c320cdd
  w0xlt:
    ACK bitcoin@c320cdd

Tree-SHA512: dab555214496255801b9ea92b7bf708bba1ff23edf055c85e29be5eab7d7a863440ee19588aacdce54b2c03feaa4b5963eb159ed89473560bd228737cbfec160
@ghost
Copy link

ghost commented Aug 11, 2022

This PR is just adding test coverage and doesn't conflict with anything other than my draft PR it's pulled out from. As such, it seems there is sufficient review to merge even though I am the author.

It seems review was insufficient. Adding wrong or low quality test coverage could lead to things not being tested but assumed to be tested.

fanquake added a commit that referenced this pull request Aug 11, 2022
49db42c [test] make tx6 child of tx5, not tx3, in rbf_tests (glozow)

Pull request description:

  A small overlooked oopsie from #25674.
  There is no effect on the test results because tx3 and tx5 pay the same fee, but this was the intended configuration, as the comment suggests.

ACKs for top commit:
  instagibbs:
    ACK 49db42c
  darosior:
    Github diff ACK 49db42c. Should have catched this. :/

Tree-SHA512: 2f54337ac3edc38707115cde5b466a85b8a6ac0a0a507effa0e9fecb12c9be196ecd1b16702bc23ba617cfb6a3b5db27d3b71616b3c2dadb186c699c4609831e
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 11, 2022
49db42c [test] make tx6 child of tx5, not tx3, in rbf_tests (glozow)

Pull request description:

  A small overlooked oopsie from bitcoin#25674.
  There is no effect on the test results because tx3 and tx5 pay the same fee, but this was the intended configuration, as the comment suggests.

ACKs for top commit:
  instagibbs:
    ACK bitcoin@49db42c
  darosior:
    Github diff ACK 49db42c. Should have catched this. :/

Tree-SHA512: 2f54337ac3edc38707115cde5b466a85b8a6ac0a0a507effa0e9fecb12c9be196ecd1b16702bc23ba617cfb6a3b5db27d3b71616b3c2dadb186c699c4609831e
@bitcoin bitcoin locked and limited conversation to collaborators Aug 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants