net: (de)serialize CSubNet in addrv2 format#20904
Closed
vasild wants to merge 3 commits intobitcoin:masterfrom
Closed
net: (de)serialize CSubNet in addrv2 format#20904vasild wants to merge 3 commits intobitcoin:masterfrom
vasild wants to merge 3 commits intobitcoin:masterfrom
Conversation
This is a followup to bitcoin#20852 which allowed non-IP subnets, but some of them, e.g. torv3, cannot be serialized in 16 bytes (addrv1) and must use addrv2. This commit changes the format of `banlist.dat` in such a way that old versions (before this commit) will not be able to read a file written by new versions (after this commit).
If we would try to write a torv3 subnet in addrv1 format, it would serialize as a dummy-all-0s IPv6 address and subsequently, when deserialized will not result in the same subnet.
Change the `peer_discouragement` test to use `CNode` pointers so that the nodes it uses can be added to `CConnman::vNodes` and cleaned up properly. Make it use `CConnmanTest` instead of `CConnman`. This is needed because we want to check `CNode::fDisconnect` and for this flag to be flipped by `CConnman::DisconnectNode()` the node must be in `CConnman::vNodes`. Extend the test with one torv3 peer and check that it is discouraged and disconnected as expected.
Contributor
Author
|
TODO:
|
This was referenced Jan 11, 2021
maflcko
reviewed
Jan 11, 2021
Member
maflcko
left a comment
There was a problem hiding this comment.
Concept ACK, didn't look at the code changes
Contributor
|
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. |
Member
|
How does this maintain forward compatibility (new versions being able to read subnets written by old versions)? |
Contributor
Author
I does not, but it should. |
Closed
Contributor
Author
|
Closing in favor of #20966. |
vasild
added a commit
to vasild/bitcoin
that referenced
this pull request
Jun 21, 2021
Save the banlist in `banlist.json` instead of `banlist.dat`. This makes it possible to store Tor v3 entries in the banlist on disk (and any other addresses that cannot be serialized in addrv1 format). Only read `banlist.dat` if it exists and `banlist.json` does not exist (first start after an upgrade). Supersedes bitcoin#20904 Resolves bitcoin#19748
maflcko
pushed a commit
to bitcoin-core/gui
that referenced
this pull request
Jun 23, 2021
…t on disk bb719a0 style: remove () from assert in rpc_setban.py (Vasil Dimov) 24b10eb doc: fix grammar in doc/files.md (Vasil Dimov) dd4e957 test: ensure banlist can be read from disk after restart (Vasil Dimov) d197977 banman: save the banlist in a JSON format on disk (Vasil Dimov) Pull request description: Save the banlist in `banlist.json` instead of `banlist.dat`. This makes it possible to store Tor v3 entries in the banlist on disk (and any other addresses that cannot be serialized in addrv1 format). Only read `banlist.dat` if it exists and `banlist.json` does not exist (first start after an upgrade). Supersedes bitcoin/bitcoin#20904 Resolves bitcoin/bitcoin#19748 ACKs for top commit: jonatack: Code review re-ACK bb719a0 per `git range-diff 6a67366 4b52c72 bb719a0` achow101: Code Review ACK bb719a0 Tree-SHA512: fc135c3a1fe20bcf5d008ce6bea251b4135e56c78bf8f750b4bd8144c095b81ffe165133cdc7e4715875eec7e7c4e13ad9f5d2450b21102af063d7c8abf716b6
janus
pushed a commit
to BitgesellOfficial/bitgesell
that referenced
this pull request
Nov 5, 2021
Save the banlist in `banlist.json` instead of `banlist.dat`. This makes it possible to store Tor v3 entries in the banlist on disk (and any other addresses that cannot be serialized in addrv1 format). Only read `banlist.dat` if it exists and `banlist.json` does not exist (first start after an upgrade). Supersedes bitcoin/bitcoin#20904 Resolves bitcoin/bitcoin#19748
stickies-v
pushed a commit
to stickies-v/bitcoin-devwiki
that referenced
this pull request
Mar 24, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a followup to #20852
which allowed non-IP subnets, but some of them, e.g. torv3, cannot be
serialized in 16 bytes (addrv1) and must use addrv2.
This PR changes the format of
banlist.datin such a way that oldversions (before this commit) will not be able to read a file written by
new versions (after this commit).