Skip to content

Conversation

@instagibbs
Copy link
Member

Not entirely persuaded this needs coverage, but was behavior I hadn't considered before.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 9, 2025

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

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31628.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK rkrux
Concept ACK glozow

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:

  • #31829 (p2p: improve TxOrphanage denial of service bounds and increase -maxorphantxs 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.

Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

Seems like a very specific condition is being tested. Would it be possible to add this inside the test_max_orphan_amount test instead of creating a new one?

Here right after the orphanage length is asserted and right before the orphanage is cleared.
https://github.com/bitcoin/bitcoin/pull/31628/files#diff-f7a7f89dc6ff73d829dbf856a922767096b11fe34ffcae1a482ca1c544611981R649

@instagibbs
Copy link
Member Author

@rkrux If you can suggest alternative code that deterministically picks the right orphan to auto-evict, I would appreciate it.

@rkrux
Copy link
Contributor

rkrux commented Jan 15, 2025

Oh yeah I recall that a randomly chosen orphan is evicted, I see the issue with adding this portion in the test_max_orphan_amount test now.

Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

tACK 6836d428199c0c19f7034bf6ea0855b8ec0a69d0

build, functional tests pass. In agreement with the approach.

@instagibbs
Copy link
Member Author

instagibbs commented Jan 16, 2025

https://github.com/bitcoin/bitcoin/actions/runs/12815476373/job/35734215113

having a real test failure that I can't seem to replicate, investigating

edit: mocktime is being logged as happening before the orphan tx being received, need to sync.

2025-01-16T19:57:07.4089701Z �[0;34m node0 2025-01-16T19:17:06.119184Z [httpworker.5] [rpc/request.cpp:241] [parse] [rpc] ThreadRPCServer method=setmocktime user=__cookie__ �[0m
2025-01-16T19:57:07.4090684Z �[0;34m node0 2025-01-16T19:17:06.140209Z (mocktime: 2025-01-16T19:18:00Z) [msghand] [txmempool.cpp:700] [check] [mempool] Checking mempool with 0 transactions and 0 inputs �[0m
2025-01-16T19:57:07.4092466Z �[0;34m node0 2025-01-16T19:17:06.140514Z (mocktime: 2025-01-16T19:18:00Z) [msghand] [net_processing.cpp:2974] [ProcessInvalidTx] [mempoolrej] e74691cbd1b181269301baed4266a2174cd4198fcf95591048c4ad17640f9f5b (wtxid=b1326a3ec4d996c0684c69414f627666690b7350fae829586f3b3f302a662a6f) from peer=0 was not accepted: bad-txns-inputs-missingorspent �[0m
2025-01-16T19:57:07.4094799Z �[0;34m node0 2025-01-16T19:17:06.140650Z (mocktime: 2025-01-16T19:18:00Z) [msghand] [txorphanage.cpp:47] [AddTx] [txpackages] stored orphan tx e74691cbd1b181269301baed4266a2174cd4198fcf95591048c4ad17640f9f5b (wtxid=b1326a3ec4d996c0684c69414f627666690b7350fae829586f3b3f302a662a6f), weight: 415 (mapsz 1 outsz 1) �[0m
2025-01-16T19:57:07.4096652Z �[0;34m node0 2025-01-16T19:17:06.140755Z (mocktime: 2025-01-16T19:18:00Z) [msghand] [node/txdownloadman_impl.cpp:414] [operator()] [txpackages] added peer=0 as a candidate for resolving orphan b1326a3ec4d996c0684c69414f627666690b7350fae829586f3b3f302a662a6f �[0m
2025-01-16T19:57:07.4098462Z �[0;34m node0 2025-01-16T19:17:06.140853Z (mocktime: 2025-01-16T19:18:00Z) [msghand] [txorphanage.cpp:93] [EraseTx] [txpackages]    removed orphan tx e74691cbd1b181269301baed4266a2174cd4198fcf95591048c4ad17640f9f5b (wtxid=b1326a3ec4d996c0684c69414f627666690b7350fae829586f3b3f302a662a6f) after 0s �[0m
2025-01-16T19:57:07.4099909Z �[0;34m node0 2025-01-16T19:17:06.140924Z (mocktime: 2025-01-16T19:18:00Z) [msghand] [txorphanage.cpp:152] [LimitOrphans] [txpackages] orphanage overflow, removed 1 tx �[0m
2025-01-16T19:57:07.4100971Z �[0;34m node0 2025-01-16T19:17:49.758568Z (mocktime: 2025-01-16T19:18:00Z) [scheduler] [net.cpp:2404] [StartExtraBlockRelayPeers] [net] enabling extra block-relay-only peers �[0m
2025-01-16T19:57:07.4101985Z �[0;34m node0 2025-01-16T19:32:04.757492Z (mocktime: 2025-01-16T19:18:00Z) [scheduler] [net.cpp:2367] [DumpAddresses] [net] Flushed 0 addresses to peers.dat  1ms �[0m
2025-01-16T19:57:07.4102951Z �[0;34m node0 2025-01-16T19:47:04.759071Z (mocktime: 2025-01-16T19:18:00Z) [scheduler] [net.cpp:2367] [DumpAddresses] [net] Flushed 0 addresses to peers.dat  1ms �[0m

@instagibbs instagibbs force-pushed the 2025-01-immediate-orphan-evict branch 2 times, most recently from 396c418 to 691752c Compare January 17, 2025 14:49
@instagibbs
Copy link
Member Author

pushed what I think the fix is: make sure we sync the node with a ping/pong before bumping the mocktime.

@instagibbs instagibbs force-pushed the 2025-01-immediate-orphan-evict branch from 691752c to cbf131c Compare January 17, 2025 14:54
Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

reACK cbf131c

Main diff is the usage of send_and_ping over send_message.

@fanquake
Copy link
Member

Not entirely persuaded this needs coverage, but was behavior I hadn't considered before.

Thoughts @glozow ?

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.

I don't think it hurts to have coverage for this. Gripes would be (1) this isn't necessarily the behavior we want, just the behavior we have (2) it uses -maxorphantxs=0 and imo we probably don't care to keep this config option / a limit on count long term? So ACK assuming we are relaxed about removing it later.

peer = self.nodes[0].add_p2p_connection(P2PInterface())

peer.send_and_ping(msg_tx(tx_child["tx"]))
assert_equal(len(self.nodes[0].getorphantxs()), 0)
Copy link
Member

Choose a reason for hiding this comment

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

Would probably move this to the very end, given what we know about getorphantxs taking a while to update

@instagibbs
Copy link
Member Author

I'm not convinced this is the right approach in the end. As @glozow mentions this isn't testing desired behavior, and the behavior will likely dramatically change soon, requiring ripping out much of the test.

I think it's better to use fuzzers to get coverage of this and check the invariants like "don't crash".

@instagibbs instagibbs closed this Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants