Repository navigation
net: deduplicate private broadcast state and snapshot types - #35016
kenji-yamam0to wants to merge 1 commit into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35016. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
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. |
|
Looks like this was pulled out of the conversation here #34707 (comment). cc @vasild |
[ 21%] Building CXX object src/CMakeFiles/bitcoin_node.dir/rpc/mempool.cpp.o
cd /home/admin/actions-runner/_work/bitcoin/bitcoin/ci_build/src && /usr/bin/ccache /usr/bin/clang++ -DABORT_ON_FAILED_ASSUME -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_CXX98_FUNCTION_BASE -DDEBUG -DDEBUG_LOCKCONTENTION -DDEBUG_LOCKORDER -DENABLE_EMBEDDED_ASMAP=1 -DENABLE_ZMQ=1 -DRPC_DOC_CHECK -I/home/admin/actions-runner/_work/bitcoin/bitcoin/ci_build/src -I/home/admin/actions-runner/_work/bitcoin/bitcoin/src -I/home/admin/actions-runner/_work/bitcoin/bitcoin/src/leveldb/include -I/home/admin/actions-runner/_work/bitcoin/bitcoin/src/minisketch/include -I/home/admin/actions-runner/_work/bitcoin/bitcoin/src/univalue/include -Wno-error=unused-member-function -O0 -ftrapv -g3 -std=c++20 -fPIC -fmacro-prefix-map=/home/admin/actions-runner/_work/bitcoin/bitcoin/src=. -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wgnu -Wcovered-switch-default -Wformat -Wformat-security -Wvla -Wshadow-field -Wthread-safety -Wloop-analysis -Wredundant-decls -Wunused-member-function -Wdate-time -Wconditional-uninitialized -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wdocumentation -Wself-assign -Wundef -Wno-unused-parameter -Werror -MD -MT src/CMakeFiles/bitcoin_node.dir/rpc/mempool.cpp.o -MF CMakeFiles/bitcoin_node.dir/rpc/mempool.cpp.o.d -o CMakeFiles/bitcoin_node.dir/rpc/mempool.cpp.o -c /home/admin/actions-runner/_work/bitcoin/bitcoin/src/rpc/mempool.cpp -O3 -g2
/home/admin/actions-runner/_work/bitcoin/bitcoin/src/rpc/mempool.cpp:187:86: error: no member named 'time_added' in 'PrivateBroadcast::TxBroadcastInfo'
187 | o.pushKV("time_added", TicksSinceEpoch<std::chrono::seconds>(tx_info.time_added));
| ~~~~~~~ ^
/home/admin/actions-runner/_work/bitcoin/bitcoin/src/rpc/mempool.cpp:189:49: error: no member named 'peers' in 'PrivateBroadcast::TxBroadcastInfo'
189 | for (const auto& peer : tx_info.peers) {
| ~~~~~~~ ^
2 errors generated.
|
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
236822f to
887fa7e
Compare
|
Fixed. The CI failure was due to a non-atomic commit split: the first commit changed the I also noticed this PR overlaps with the dedup suggested by @vasild in #34707 (comment). Happy to rebase on top of #34707 or close this if it becomes redundant after that PR lands. |
6275b82 to
86643bb
Compare
vasild
left a comment
There was a problem hiding this comment.
Concept ACK
It is convenient if you cross link a PR in case it has a specific motivator. In this case "This PR is inspired by #34707 (comment).
Thanks!
|
Addressed the remaining review comments in 4a89e31da7. Tested:
|
There was a problem hiding this comment.
Update: see #35016 (comment)
A relatively straightforward merging of duplicated structs, done in two stages to minimize diffs. An existing unit test has been also extended with some extra checks.
I have verified by reimplementing the moves and updates.
Left some remarks, none major.
4a89e31 to
9bb2e40
Compare
|
Thanks for the review. I've cleaned up the history to remove the transient |
|
Thanks for the changes.
By suggesting to remove the adding of a large 'temporary' test that is removed in the next commit, I didn't mean to squash to two commits, but I had in mind changing the first commit (and the second too, but that's an automatic merge-type operation). In this particular case the squashed commit is fine, but in general in such cases it's better to preserve the original commits (unless there is an explicit motivation for squash). So it's OK, this remark is more for the future. |
There was a problem hiding this comment.
cr 9bb2e40
My previous concerns have been addressed, LGTM. (#35016 (review))
danielabrozzoni
left a comment
There was a problem hiding this comment.
tACK 9bb2e40
The cleanup looks good to me. The PR is removing TxSendStatus and PeerSendInfo, in favor of using TxBroadcastInfo and SendStatus everywhere in the code. As a consequence, SendStatus is moved to public scope.
Also nice to see the private_broadcasts tests use NodeClockContext instead of SetMockTime, as far as I understand this is preferred in unit tests as it doesn't need to be manually cleaned up at the end of the test.
|
Concept ACK |
|
Ping @danielabrozzoni @optout21 to take another look here. |
|
ACK c307e64b3f3942ec24b91ea3d3cc41a0a89ac310 Re-reviewed after rebase, no significant changes (prev: #35016 (comment)) |
There was a problem hiding this comment.
EDIT: ouch! rebase conflict! oh well, I will review again after rebase :)
tACK c307e64b3f3942ec24b91ea3d3cc41a0a89ac310
Deduplicating the structures makes the code easier to follow and reason about.
Changes introduced in this PR:
SendStatusis unchanged, but moved from private to public insidePrivateBroadcastTxSendStatusis renamed toStatus, unchanged, and moved from private to public insidePrivateBroadcastPeerSendInfoandTxBroadcastInfoare removed:- Instead of building a
vector<TxBroadcastInfo>,GetBroadcastInfo()now returns a copy ofm_transactions. This also exposes theNodeIdof each peer, which is ok. CTransactionRefHash/CTransactionRefCompare made public (needed in order to returnm_transactions)- Instead of using
PeerSendInfo, we useSendStatus
- Instead of building a
Also, in the test:
- Drop
find_tx_info: now thatGetBroadcastInforeturnsm_transactions, we can just call.at() - Check that
time_addedmatches the expected value
c307e64 to
70f6026
Compare
Store private broadcast entries in a transaction-keyed map and return that map as the snapshot from GetBroadcastInfo(). Remove the snapshot-only wrapper types and avoid storing the same CTransactionRef in both the map key and value. Callers use the CTransactionRef key for transaction data, while Status keeps the per-transaction broadcast state. The getprivatebroadcastinfo JSON output is unchanged. No behavior change intended.
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
70f6026 to
32e24b1
Compare
|
No behavior or RPC JSON changes intended. Rebased on current Range-diff reviewed: |
|
reACK 32e24b1 Re-reviewed, no significant change. (prev: #35016 (comment)) ( |
It should be in all remotes. You can fetch a commit via: |
|
cc @instagibbs |
|
could be wrong, but I think this will directly conflict with the stated goals of #35680 (comment) |
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
After looking at #35680 and #35016, I'm approach NACK on this, sorry. #35680 is fixing an unbounded state issue, which directly conflicts with this approach which is just a refactor. This also exposes more internal state to callers, which I think is the wrong direction. We should try and keep state encapsulated so callsites can't depend on internal layout. |
|
Closing for now, as it's not clear this is the correct direction to take. |
Follow-up cleanup in the private broadcast subsystem.
This PR is inspired by #34707 (comment).
This change removes duplication between the internal private broadcast state
and the snapshot used by PeerManager, RPC, and tests.
PeerSendInfoandTxSendStatus.SendStatusdirectly for per-peer broadcast status.PrivateBroadcast::Transactionsas the snapshot type.getprivatebroadcastinfoJSON output unchanged.No behavior change intended.