Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AcceptMultipleTransactions: Fix workspace not being set as client_maxfeerate failure #29735

Merged
merged 5 commits into from Apr 11, 2024

Conversation

instagibbs
Copy link
Member

@instagibbs instagibbs commented Mar 26, 2024

Bug causes an Assume() failure due to the expectation that the individual result should be invalid when done over submitpackage via rpc.

Bug introduced by #28950 , and I discovered it rebasing #28984 since it's easier to hit in that test scenario.

Tests in place were only checking AcceptSingleTransaction-level checks due to package evaluation only triggering when minfee is too high for the parent transaction.

Added test along with fix, moving the fill_mempool utility into a common area for re-use.

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 26, 2024

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

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK glozow, theStack, ismaelsadeeq
Stale ACK murchandamus

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #29700 (kernel, refactor: return error status on all fatal errors by ryanofsky)
  • #28970 (p2p: opportunistically accept 1-parent-1-child packages by glozow)
  • #28531 (improve MallocUsage() accuracy by LarryRuane)

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.

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, verified that on master the test fails since the individual result wasn't populated and is "Valid"

test/functional/test_framework/util.py Outdated Show resolved Hide resolved
test/functional/test_framework/util.py Show resolved Hide resolved
test/functional/rpc_packages.py Show resolved Hide resolved
src/validation.cpp Outdated Show resolved Hide resolved
@instagibbs
Copy link
Member Author

instagibbs commented Mar 27, 2024

Added some fuzz coverage which would have likely caught this

edit: yep, 3 minutes: LC1hZGRuCS0Ab2VtZHL1iQHY2NjY2Am//wAAAAD/AACAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAA//8AAABB44MP3NL5/4zzEoz/dpB2dg==

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.

Sorry for the nits, still need to run the fuzzer but otherwise lgtm

test/functional/test_framework/util.py Outdated Show resolved Hide resolved
test/functional/rpc_packages.py Outdated Show resolved Hide resolved
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 14c86ba

Verified the fuzz test catches this problem, seems to run fine with the changes. Thanks for accepting the suggestions.

@glozow glozow mentioned this pull request Apr 4, 2024
53 tasks
Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

ACK 14c86ba with nits.

test_framework.generate(miniwallet, 1 + (num_of_batches * tx_batch_size))

# Mine 99 blocks so that the UTXOs are allowed to be spent
test_framework.generate(node, 99)
Copy link
Contributor

Choose a reason for hiding this comment

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

In "Move fill_mempool to util function" (cc770e4):

Nit: If a commit is described as a move, I would expect no changes in the code beyond what’s necessary to update the callsites. While these changes are minor and obviously do not entail a functional change, I would have expected the updated commentary and refactor to be a separate commit—I’m wondering whether my understanding of the modus operandi is correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

split out the moving and docstring changes, should be minimal now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I don’t feel strongly about it, but the change that made me notice that there were code changes in the move originally was that COINBASE_MATURITY - 1 had gotten replaced with a 99 magic number.

Copy link
Member Author

Choose a reason for hiding this comment

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

bit of an annoying circular reference issue(blocktools requiring utils) so for now at least make it grep-able what the magic value should be(and more greppable)

test/functional/rpc_packages.py Outdated Show resolved Hide resolved
test/functional/rpc_packages.py Show resolved Hide resolved
test/functional/rpc_packages.py Outdated Show resolved Hide resolved
test/functional/rpc_packages.py Show resolved Hide resolved
test/functional/test_framework/util.py Outdated Show resolved Hide resolved
test/functional/test_framework/util.py Outdated Show resolved Hide resolved
test/functional/rpc_packages.py Outdated Show resolved Hide resolved
test/functional/rpc_packages.py Outdated Show resolved Hide resolved
test/functional/rpc_packages.py Outdated Show resolved Hide resolved
Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

ACK 052c67d

Please feel free to ignore nits

test_framework.generate(miniwallet, 1 + (num_of_batches * tx_batch_size))

# Mine 99 blocks so that the UTXOs are allowed to be spent
test_framework.generate(node, 99)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I don’t feel strongly about it, but the change that made me notice that there were code changes in the move originally was that COINBASE_MATURITY - 1 had gotten replaced with a 99 magic number.

src/validation.cpp Show resolved Hide resolved
@DrahtBot DrahtBot requested a review from glozow April 8, 2024 12:23
Copy link
Member

@ismaelsadeeq ismaelsadeeq 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

I will run the new fuzz test with and without 72425bd

"""Fill mempool until eviction."""
"""Fill mempool until eviction.

Allows for simpler testing of scenarios with floating minfee > minrelay
Copy link
Member

Choose a reason for hiding this comment

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

In a466686 "test: expand docstring to fill_mempool"

nit:

Suggested change
Allows for simpler testing of scenarios with floating minfee > minrelay
Allows for simpler testing of scenarios with floating mempoolminfee > minrelayfee

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Comment on lines 510 to 511
# And 1 more to verify that this tx does not get added to the mempool with a fee rate less than the mempoolminfee
# And 2 more for the package cpfp test
Copy link
Member

Choose a reason for hiding this comment

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

In c93f790 " Move fill_mempool to util function"

There should be a commit that will first pull out these two lines from this scope to

Moving fill_mempool to test_framework/util.py makes it clear that the comments do not belong to this scope.

Copy link
Member Author

Choose a reason for hiding this comment

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

done, I think

Comment on lines 505 to 507
It will not ensure mempools become synced as it
is based on a single node and assumes -minrelaytxfee
is 1 sat/vbyte.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe assert for this at the beginning of the fill_mempool

     assert_equal(node.getnetworkinfo()['relayfee'], Decimal('0.00001000'))

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

looking at this again, what do you think about just restarting the node with the -datacarriersize=100000, -maxmempool=5, -minrelaytxfee=0.00001000 after filling the mempool we then restart the node with default node settings?
Are there any advantage of delegating setting this to the caller?
If not then this will reduce duplication of all callers of fill_mempool settings this values.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't restart the node after filling the memopool without resetting the floating minfee.

I could pull in the initial restart if we knew people didn't want any other extra_args.

Alternatively I could assert that datacarrier and maxmempool is set in extra_args?

I think documentation is enough for now, leaving as is.

@instagibbs instagibbs force-pushed the 2024-03-fix-multitx-maxfee branch 2 times, most recently from 4aa47e7 to 4fe7d15 Compare April 8, 2024 13:16
Copy link
Member

@ismaelsadeeq ismaelsadeeq left a comment

Choose a reason for hiding this comment

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

ACK 4fe7d15

I've reviewed 73b68....4fe7d15


I've Ran the fuzz test without f28338b

And verified the crash

Test unit written to ./crash-7fd49c80d3088f672b4bf03ab8a1d7f1aedff0aa
Base64: q6sAIqsA/6sACQCrAAAAANr/+zUBAQENASUABAB5aKqgnQAAAAAlKv8tATUBAQENASUABAB5aKqgnQAAAAAluQAAAMP3AAAAAasAAAAAAAAA2v/7Kv8tATYBAQENASUABAB0aKKgle/f/wAA

I ran functional tests and rpc_packages.py failed.


I then cherry-picked the patch f28338b and run the fuzz test again, it passed successfully.

INFO: seed corpus: files: 728 min: 1b max: 617355b total: 10276044b rss: 232Mb
#128    pulse  cov: 10579 ft: 39305 corp: 108/4319b exec/s: 64 rss: 260Mb
#512    pulse  cov: 11879 ft: 55511 corp: 356/67Kb exec/s: 36 rss: 283Mb
#925    INITED cov: 12041 ft: 66449 corp: 523/8522Kb exec/s: 20 rss: 550Mb
#925    DONE   cov: 12041 ft: 66449 corp: 523/8522Kb lim: 617355 exec/s: 20 rss: 550Mb
Done 925 runs in 46 second(s)

Functional tests are also passing

assert child["txid"] not in node.getrawmempool()

# Reset maxmempool, datacarriersize, ,reset dynamic mempool minimum feerate, and empty mempool.
self.restart_node(0, extra_args=["-persistmempool=0"])
Copy link
Member

Choose a reason for hiding this comment

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

This should be in the extra args above to avoid writing mempool.dat.

Currently the test is fine, but this is because the new datacarriersize causes all the transactions to be rejected.

Copy link
Member Author

Choose a reason for hiding this comment

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

moved and added assertion of empty mempool after restart

@DrahtBot DrahtBot requested a review from glozow April 9, 2024 12:50
If we do not set the Failure for the workspace when
there is a client_maxfeerate related error, we hit
an Assume() to the contrary. Properly set it.
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.

reACK 4ba1d0b

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

ACK 4ba1d0b

Copy link
Member

@ismaelsadeeq ismaelsadeeq left a comment

Choose a reason for hiding this comment

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

re-ACK 4ba1d0b via diff

@glozow glozow merged commit bdb33ec into bitcoin:master Apr 11, 2024
16 checks passed
Pttn added a commit to RiecoinTeam/Riecoin that referenced this pull request Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants