-
Notifications
You must be signed in to change notification settings - Fork 35.7k
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
p2p: refactor AlreadyHave(), CInv::type, INV/TX processing #19610
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
…use in net processing c251d71 p2p, refactoring: use CInv helpers in net_processing.cpp (Jon Atack) 4254cd9 p2p: add CInv transaction message helper methods (Jon Atack) Pull request description: Following the merge of wtxid relay in #18044, this is the first of three refactoring PRs (this one, #19610, and #19611) with no change in behavior, tightly scoped to ease review, to simplify the net processing code and improve encapsulation: - add `CInv` transaction message helper methods, defined in the class - use the new helpers in `net_processing.cpp` to simplify the code and improve encapsulation Test coverage is provided by the functional p2p tests, notably (from seeing which tests failed when breaking things to test coverage) `p2p_segwit`, `p2p_tx_download`, `p2p_feefilter`, and `p2p_permissions`. ACKs for top commit: fjahr: Code review ACK c251d71 laanwj: Code review ACK c251d71 vasild: ACK c251d71 theStack: Code-Review ACK c251d71 hebasto: ACK c251d71, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: ead034b3c9e438909b4c5010c570d7930e69063c114290b051b7cebfd9bd5b19f573218bebe8a521256d32e830797f997adad3d85b4539c64ac5762b698e656d
66398c1
to
82c9297
Compare
…lpers; use in net processing c251d71 p2p, refactoring: use CInv helpers in net_processing.cpp (Jon Atack) 4254cd9 p2p: add CInv transaction message helper methods (Jon Atack) Pull request description: Following the merge of wtxid relay in bitcoin#18044, this is the first of three refactoring PRs (this one, bitcoin#19610, and bitcoin#19611) with no change in behavior, tightly scoped to ease review, to simplify the net processing code and improve encapsulation: - add `CInv` transaction message helper methods, defined in the class - use the new helpers in `net_processing.cpp` to simplify the code and improve encapsulation Test coverage is provided by the functional p2p tests, notably (from seeing which tests failed when breaking things to test coverage) `p2p_segwit`, `p2p_tx_download`, `p2p_feefilter`, and `p2p_permissions`. ACKs for top commit: fjahr: Code review ACK c251d71 laanwj: Code review ACK c251d71 vasild: ACK c251d71 theStack: Code-Review ACK c251d71 hebasto: ACK c251d71, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: ead034b3c9e438909b4c5010c570d7930e69063c114290b051b7cebfd9bd5b19f573218bebe8a521256d32e830797f997adad3d85b4539c64ac5762b698e656d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 82c9297
I think a better approach than the changes within |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK. Needs rebase.
CInv
block message helpers; use in net processingbbd5638
to
4789cff
Compare
Rebased with four commits pulled in from @jnewbery's master...jnewbery:2020-07-split-already-have branch as well as the changes in #19611. |
Great idea. The block and transaction paths have drifted apart so much that it no longer makes sense to have a common function there. |
4789cff
to
792d5a4
Compare
and otherwise log that an unknown INV type was received. In INV processing, when handling transaction type inv messages, ToGenTxid() expects that we constructed the CInv ourselves or that we verified that it is for a transaction type CInv. Therefore, change this `else` branch into an `else if (inv.GenMsgTx())` to make this safer and log any INVs that fall through.
533a9a0
to
125468a
Compare
Removed the unused helper methods from the first commit per |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 125468a
Why? This seems unrelated to this PR (the UBSan warning happens before this PR). Changing the type of |
@jnewbery I thought since it was already added previously, it would fit into the scope of the PR. No problem to be added into another PR, either I or somebody else could do that. |
125468a
to
fb56d37
Compare
Dropped the |
Code review ACK fb56d37 |
utACK fb56d37 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fb56d37
…UBSan warning 7984c39 test framework: serialize/deserialize inv type as unsigned int (Jon Atack) 407175e p2p: change CInv::type from int to uint32_t (Jon Atack) Pull request description: Fixes UBSan implicit-integer-sign-change issue per #19610 (comment). Credit to Crypt-iQ for finding and reporting the issue and to vasild for the original review suggestion in #19590 (review). Closes #19678. ACKs for top commit: laanwj: ACK 7984c39 MarcoFalke: ACK 7984c39 🌻 vasild: ACK 7984c39 Tree-SHA512: 59f3a75f40ce066ca6f0bb1927197254238302b4073af1574bdbfe6ed580876437be804be4e47d51467d604f0d9e3a5875159f7f2edbb2351fdb2bb9465100b5
…processing fb56d37 p2p: ensure inv is GenMsgTx before ToGenTxid in inv processing (John Newbery) aa36213 test: use CInv::MSG_WITNESS_TX flag in p2p_segwit (Jon Atack) 24ee4f0 p2p: make gtxid(.hash) and fAlreadyHave localvars const (Jon Atack) b1c8554 p2p: use CInv block message helpers in net_processing.cpp (Jon Atack) acd6642 [net processing] Change AlreadyHaveTx() to take a GenTxid (John Newbery) 5fdfb80 [net processing] Change AlreadyHaveBlock() to take block_hash argument (John Newbery) 430e183 [net processing] Remove mempool argument from AlreadyHaveBlock() (John Newbery) 42ca561 [net processing] Split AlreadyHave() into separate block and tx functions (John Newbery) 39f1dc9 p2p: remove nFetchFlags from NetMsgType TX and INV processing (Jon Atack) 471714e p2p: add CInv block message helper methods (Jon Atack) Pull request description: Building on bitcoin#19590 and the recent `wtxid` and `GenTxid` changes, this is a refactoring and cleanup PR to simplify and improve some of the net processing code. Some of the diffs are best reviewed with `-w` to ignore spacing. Co-authored by John Newbery. ACKs for top commit: laanwj: Code review ACK fb56d37 jnewbery: utACK fb56d37 vasild: ACK fb56d37 Tree-SHA512: ba39b58e6aaf850880a842fe5f6295e9f1870906ef690206acfc17140aae2ac854981e1066dbcd4238062478762fbd040ef772fdc2c50eea6869997c583e6a6d
…`, fix UBSan warning 7984c39 test framework: serialize/deserialize inv type as unsigned int (Jon Atack) 407175e p2p: change CInv::type from int to uint32_t (Jon Atack) Pull request description: Fixes UBSan implicit-integer-sign-change issue per bitcoin#19610 (comment). Credit to Crypt-iQ for finding and reporting the issue and to vasild for the original review suggestion in bitcoin#19590 (review). Closes bitcoin#19678. ACKs for top commit: laanwj: ACK 7984c39 MarcoFalke: ACK 7984c39 🌻 vasild: ACK 7984c39 Tree-SHA512: 59f3a75f40ce066ca6f0bb1927197254238302b4073af1574bdbfe6ed580876437be804be4e47d51467d604f0d9e3a5875159f7f2edbb2351fdb2bb9465100b5
Summary: Partial backport of [[bitcoin/bitcoin#19610 | core#19610]]: bitcoin/bitcoin@471714e Depends on D9500. Test Plan: ninja all check ninja bitcoin-fuzzers Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9501
…ions Summary: Partial backport of [[bitcoin/bitcoin#19610 | core#19610]]: bitcoin/bitcoin@42ca561?diff=split&w=1 This will help narrowing the cs_main scope when introducing the proofs. There are more simplifications and de-duplication to come in follow-up backports. Depends on D9501. Note that the commit bitcoin/bitcoin@39f1dc9 is skipped because it is a segwit only commit. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9502
Summary: Partial backport of [[bitcoin/bitcoin#19610 | core#19610]]: bitcoin/bitcoin@430e183 Depends on D9502. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9503
Summary: Partial backport of [[bitcoin/bitcoin#19610 | core#19610]]: bitcoin/bitcoin@5fdfb80 Depends on D9503. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9504
Summary: Partial backport if [[bitcoin/bitcoin#19610 | core#19610]]: bitcoin/bitcoin@acd6642 Depends on D9504. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9505
Summary: Partial backport of [[bitcoin/bitcoin#19610 | core#19610]]: bitcoin/bitcoin@b1c8554 Depends on D9505. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9506
Summary: Partial backport of [[bitcoin/bitcoin#19610 | core#19610]]: bitcoin/bitcoin@24ee4f0 There is very few remaining when removed the segwit content. Depends on D9506. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9507
Summary: ``` and otherwise log that an unknown INV type was received. In INV processing, when handling transaction type inv messages, ToGenTxid() expects that we constructed the CInv ourselves or that we verified that it is for a transaction type CInv. Therefore, change this `else` branch into an `else if (inv.GenMsgTx())` to make this safer and log any INVs that fall through. ``` Completes backport of [[bitcoin/bitcoin#19610 | core#19610]]: bitcoin/bitcoin@fb56d37 Depends on D9507. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9508
Building on #19590 and the recent
wtxid
andGenTxid
changes, this is a refactoring and cleanup PR to simplify and improve some of the net processing code.Some of the diffs are best reviewed with
-w
to ignore spacing.Co-authored by John Newbery.