Skip to content

Conversation

ritickgoenka
Copy link
Contributor

@ritickgoenka ritickgoenka commented Jul 29, 2021

This PR adds a new functional test to test the new descendant limits for packages that were proposed in #21800.

+----------------------+
|                      |
|         M1           |
|        ^  ^          |
|       M2   ^         |
|      .      ^        |
|     .        ^       |
|    .          ^      |
|   .            ^     |
|  M24            ^    |
|                  ^   |
|                  P1  |
|                  ^   |
|                  P2  |
|                      |
+----------------------+

This test is for checking a transaction to fail its descendant count limits because of a combination of mempool descendants, package direct descendants, and package indirect descendants.

In this test, P1 has M1 as a mempool ancestor, P2 has no in-mempool ancestors, but when combined P2 has M1 as an ancestor and M1 exceeds descendant_limits (23 in-mempool descendants + 2 in-package descendants, a total of 26 including itself)

@fanquake fanquake added the Tests label Jul 29, 2021
@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 29, 2021

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

Conflicts

No conflicts as of last run.

@tryphe
Copy link
Contributor

tryphe commented Jul 30, 2021

Concept ACK

@fanquake fanquake requested a review from glozow July 30, 2021 06:01
Copy link
Member

@glozow glozow 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 to more testing.

The commit message for c18188e seems to contain some squash comments? Would be better to describe exactly what edge case you're testing / coverage you're adding.

@glozow
Copy link
Member

glozow commented Aug 9, 2021

Will review again after rebase - note that the mempool tests have been moved to mempool_package_limits.py

@ritickgoenka ritickgoenka force-pushed the test_descendant_limit_bushy branch from 0dab0ac to fc42d4f Compare August 10, 2021 16:46
@ritickgoenka ritickgoenka marked this pull request as draft August 10, 2021 17:31
@ritickgoenka ritickgoenka force-pushed the test_descendant_limit_bushy branch from fc42d4f to 2bc8b5a Compare August 10, 2021 18:35
@ritickgoenka ritickgoenka marked this pull request as ready for review August 11, 2021 04:10
Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

Thanks for rebasing, the test is well-written and does what the comment says it does.

Suggestion: label your commit message with [test] and add a short description about why this test is an improvement.

@glozow
Copy link
Member

glozow commented Aug 11, 2021

Another suggestion (probably for a different PR): This doesn't matter that much, but we have quite a few of the same lines repeated in this test. Given how many OP_TRUE spends there are, I think it'd be good to either add a OP_TRUE variation of make_chain to wallet.py or, better yet, make all those functions methods of MiniWallet.

@ritickgoenka ritickgoenka requested a review from glozow August 11, 2021 16:31
@ritickgoenka ritickgoenka force-pushed the test_descendant_limit_bushy branch from 2bc8b5a to 4fd7979 Compare August 11, 2021 17:25
@ritickgoenka ritickgoenka force-pushed the test_descendant_limit_bushy branch 2 times, most recently from c03c6d3 to 5a7050c Compare August 12, 2021 18:10
Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

utACK 5a7050c

@glozow
Copy link
Member

glozow commented Aug 16, 2021

PR description needs to be updated

@jnewbery
Copy link
Contributor

I still don't understand what logic this is testing that isn't already covered by the test_desc_count_limits() subtest.

@ritickgoenka
Copy link
Contributor Author

I still don't understand what logic this is testing that isn't already covered by the test_desc_count_limits() subtest.

It is testing if the second generation in Package transactions are considered while checking Descendant count limits. It is analogous to the 'test_anc_count_limits_2()' subtest for Ancestor count limits.

@ritickgoenka ritickgoenka force-pushed the test_descendant_limit_bushy branch from 5a7050c to e0f92f3 Compare August 17, 2021 13:00
@jnewbery
Copy link
Contributor

@glozow has pointed out that this scenario is for a transaction to fail its descendant limit count due to a combination of mempool descendants, package direct descendants, and package indirect descendants, which seems like a reasonable thing to test.

I think the transaction P3 is unnecessary, since the package would fail with just P2. It's good for a test to fail at the edge case (i.e. the package would be accepted if you removed just one transaction).

I'd also recommend you remove the image from the PR description and replace it with an ascii drawing. The PR description is included in the merge commit, so it's best if it's plain text without attachments.

@ritickgoenka ritickgoenka force-pushed the test_descendant_limit_bushy branch 2 times, most recently from 97cf2d3 to 2ef27b5 Compare August 19, 2021 16:08
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK e0f92f3. Seems like a useful and straightforward test case, assuming it doesn't duplicate existing coverage.

@ritickgoenka ritickgoenka force-pushed the test_descendant_limit_bushy branch from 2ef27b5 to fa7db1c Compare August 26, 2021 18:11
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK fa7db1c. Only were suggested changes since last review: simplifying test and dropping P3 transaction as John suggested, and adding assert_equal I suggested

@fanquake fanquake requested a review from glozow September 8, 2021 00:57
Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

ACK fa7db1c

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

ACK fa7db1c

I've left a couple of comments inline, but they can be picked up in #22901.

If you have to touch this again, I'd suggest changing the commit log:

-[test] checks descendants limtis for second generation Package descendants
+[test] check descendant limits for second generation package descendants

value = parent_value
txid = parent_txid
for i in range(23): # M2...M24
(tx, txhex, value, spk) = make_chain(node, self.address, self.privkeys, txid, value, 0, spk)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(tx, txhex, value, spk) = make_chain(node, self.address, self.privkeys, txid, value, 0, spk)
tx, txhex, value, spk = make_chain(node, self.address, self.privkeys, txid, value, 0, spk)

first_coin_a = self.coins.pop()
parent_value = (first_coin_a["amount"] - DEFAULT_FEE) / 2 # Deduct reasonable fee and make 2 outputs
inputs = [{"txid": first_coin_a["txid"], "vout": 0}]
outputs = [{self.address : parent_value}, {ADDRESS_BCRT1_P2WSH_OP_TRUE : parent_value}]
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using a linter like flake8 or a formatter like black to catch/fix PEP8 violations:

Suggested change
outputs = [{self.address : parent_value}, {ADDRESS_BCRT1_P2WSH_OP_TRUE : parent_value}]
outputs = [{self.address: parent_value}, {ADDRESS_BCRT1_P2WSH_OP_TRUE: parent_value}]

@maflcko maflcko merged commit fac7181 into bitcoin:master Sep 9, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 11, 2021
fa7db1c [test] checks descendants limtis for second generation Package descendants (ritickgoenka)

Pull request description:

  This PR adds a new functional test to test the new descendant limits for packages that were proposed in bitcoin#21800.
   ```
  +----------------------+
  |                      |
  |         M1           |
  |        ^  ^          |
  |       M2   ^         |
  |      .      ^        |
  |     .        ^       |
  |    .          ^      |
  |   .            ^     |
  |  M24            ^    |
  |                  ^   |
  |                  P1  |
  |                  ^   |
  |                  P2  |
  |                      |
  +----------------------+
  ```

  This test is for checking a transaction to fail its descendant count limits because of a combination of mempool descendants, package direct descendants, and package indirect descendants.

  In this test,  P1 has M1 as a mempool ancestor, P2 has no in-mempool ancestors, but when combined P2 has M1 as an ancestor and M1 exceeds descendant_limits (23 in-mempool descendants + 2 in-package descendants, a total of 26 including itself)

ACKs for top commit:
  ryanofsky:
    Code review ACK fa7db1c. Only were suggested changes since last review: simplifying test and dropping P3 transaction as John suggested, and adding assert_equal I suggested
  glozow:
    ACK fa7db1c
  jnewbery:
    ACK fa7db1c

Tree-SHA512: d1eb993550ac8ce31cbe42e17c6522a213ede66970d5d9391f31a116477ab5889fefa6ff2df6ceadd63a28c1be1ad893b0e8e449247e9ade2ca61dc636508d68
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 25, 2022
Summary:
```
This test is for checking a transaction to fail its descendant count limits because of a combination of mempool descendants, package direct descendants, and package indirect descendants.
```

Backport of [[bitcoin/bitcoin#22582 | core#22582]].

Also remove a debug print leftover from D12162.

Test Plan:
  ./test/functional/test_runner.py mempool_package_limits

Reviewers: #bitcoin_abc, sdulfari

Reviewed By: #bitcoin_abc, sdulfari

Subscribers: sdulfari

Differential Revision: https://reviews.bitcoinabc.org/D12365
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
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.

8 participants