-
Notifications
You must be signed in to change notification settings - Fork 37.7k
net: Encapsulate asmap in NetGroupManager #22910
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
Conversation
64ba743
to
2789177
Compare
2789177
to
d70b354
Compare
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. |
Concept ACK (just judging the PR description) |
Concept ACK |
Concept ACK, light code review ACK d70b354 |
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
853c4ed [net] Remove asmap argument from CNode::CopyStats() (John Newbery) 9fd5618 [asmap] Make DecodeAsmap() a utility function (John Newbery) bfdf4ef [asmap] Remove SanityCheckASMap() from netaddress (John Newbery) 07a9ecc [net] Remove CConnman::Options.m_asmap (John Newbery) Pull request description: These small cleanups to the asmap code are the first 4 commits from #22910. They're minor improvements that are independently useful whether or not 22910 is merged. ACKs for top commit: naumenkogs: ACK 853c4ed theStack: Concept and code-review ACK 853c4ed 🗺️ fanquake: ACK 853c4ed Tree-SHA512: 64783743182592ac165df6ff8d18870b63861e9204ed722c207fca6938687aac43232a5ac4d8228cf8b92130ab0349de1b410a2467bb5a9d60dd9a7221b3b85b
54f6a6a
to
3de73f1
Compare
Rebased and fixed #22910 (comment) |
3de73f1
to
4f89a79
Compare
rerebased |
concept ACK |
14ec5f5
to
3149a8c
Compare
Rebased |
These currently call through to the CNetAddr methods. The logic will be moved in a future commit.
…d GetGroup() Also change parameter/variable names. This makes the next commit mostly move-only.
Reviewer hint: use: `git diff --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space`
asmap no longer needs to be exposed anywhere outside NetGroupManager.
3149a8c
to
36f814c
Compare
Code Review ACK 36f814c Did some light sanity testing, and didn't run into any problems. |
fa4c923
to
36f814c
Compare
CI failure seems spurious. I rebased onto latest master to trigger a new CI run, but whilst I was doing that, mzumsande ACKed 36f814c, so I've reverted to that. |
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 36f814c
} else if (address.IsInternal()) { | ||
// All internal-usage addresses get their own group. | ||
// Skip over the INTERNAL_IN_IPV6_PREFIX returned by CAddress::GetAddrBytes(). | ||
nStartByte = INTERNAL_IN_IPV6_PREFIX.size(); |
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.
nit: i think it would also be possible to keep the prefix and set nBits = (INTERNAL_IN_IPV6_PREFIX.size() + ADDR_INTERNAL_SIZE) * 8;
. Then we wouldn't need to reintroduce nStartByte
, which was previously also used for other address types.
// ...for the last byte, push nBits and for the rest of the byte push 1's | ||
if (nBits > 0) { | ||
assert(num_bytes < addr_bytes.size()); | ||
vchRet.push_back(addr_bytes[num_bytes] | ((1 << (8 - nBits)) - 1)); |
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.
If nStartByte
is ever used for other address types again it might be necessary to do the following:
vchRet.push_back(addr_bytes[num_bytes] | ((1 << (8 - nBits)) - 1)); | |
vchRet.push_back(addr_bytes[num_bytes + nStartByte] | ((1 << (8 - nBits)) - 1)); |
See:
Line 996 in 1017b8a
vchRet.push_back(GetByte(15 - nStartByte) | ((1 << (8 - nBits)) - 1)); |
@dergoegge you might want to open a followup with any suggestions / changes. |
post-merge code review ACK 36f814c |
e5d1831 [netgroup] Use nStartByte as offset for the last byte of the group (dergoegge) Pull request description: This addresses my review [comments](bitcoin/bitcoin#22910 (comment)) I left on #22910. This has no effect on the current logic as `nStartByte` is only used for internal addresses which only ever add 10 whole bytes to the returned group. However to avoid future bugs, I think we should use `nStartByte` as offset for the last byte as well, in case we ever add a new address type that makes makes use of `nStartByte` and adds fractional bytes to the group. ACKs for top commit: jnewbery: Code review ACK e5d1831 theStack: Concept and code-review ACK e5d1831 Tree-SHA512: 4c08c7d6cb38b553e998798b3e3b790177aaa2141a48e277dfd538e01a7fccadf644329e93c5b0fb5e7e4037494c8dfe061b94eb52c6b31dc21bdf99eb0e311a
e5d1831 [netgroup] Use nStartByte as offset for the last byte of the group (dergoegge) Pull request description: This addresses my review [comments](bitcoin#22910 (comment)) I left on bitcoin#22910. This has no effect on the current logic as `nStartByte` is only used for internal addresses which only ever add 10 whole bytes to the returned group. However to avoid future bugs, I think we should use `nStartByte` as offset for the last byte as well, in case we ever add a new address type that makes makes use of `nStartByte` and adds fractional bytes to the group. ACKs for top commit: jnewbery: Code review ACK e5d1831 theStack: Concept and code-review ACK e5d1831 Tree-SHA512: 4c08c7d6cb38b553e998798b3e3b790177aaa2141a48e277dfd538e01a7fccadf644329e93c5b0fb5e7e4037494c8dfe061b94eb52c6b31dc21bdf99eb0e311a
- add NetGroupManager as part of node p2p components after bitcoin/bitcoin#22910 - update AddrMan description
The asmap data is currently owned by addrman, but is used by both addrman and connman. #22791 made the data const and private (so that it can't be updated by other components), but it is still passed out of addrman as a reference to const, and used by
CNetAddress
to calculate the group and AS of the net address.This RFC PR proposes to move all asmap data and logic into a new
NetGroupManager
component. This is initialized at startup, and the client components addrman and connman simply callNetGroupManager::GetGroup(const CAddress&)
andNetGroupManager::GetMappedAS(const CAddress&)
to get the net group and AS of an address.