-
Notifications
You must be signed in to change notification settings - Fork 37.7k
net: (de)serialize CSubNet in addrv2 format #20904
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
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.
TODO:
|
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, didn't look at the code changes
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. |
How does this maintain forward compatibility (new versions being able to read subnets written by old versions)? |
I does not, but it should. |
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). Still read `banlist.dat` (if it exists) and merge its contents with `banlist.json` (if it exists). This is because we need to read `banlist.dat` at least once in order to convert it and it is easier to read it every time (not just once). Supersedes bitcoin#20904 Resolves bitcoin#19748
Closing in favor of #20966. |
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). Still read `banlist.dat` (if it exists) and merge its contents with `banlist.json` (if it exists). This is because we need to read `banlist.dat` at least once in order to convert it and it is easier to read it every time (not just once). Supersedes bitcoin#20904 Resolves bitcoin#19748
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). Still read `banlist.dat` (if it exists) and merge its contents with `banlist.json` (if it exists). This is because we need to read `banlist.dat` at least once in order to convert it and it is easier to read it every time (not just once). Supersedes bitcoin#20904 Resolves bitcoin#19748
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). Still read `banlist.dat` (if it exists) and merge its contents with `banlist.json` (if it exists). This is because we need to read `banlist.dat` at least once in order to convert it and it is easier to read it every time (not just once). Supersedes bitcoin#20904 Resolves bitcoin#19748
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). Still read `banlist.dat` (if it exists) and merge its contents with `banlist.json` (if it exists). This is because we need to read `banlist.dat` at least once in order to convert it and it is easier to read it every time (not just once). Supersedes bitcoin#20904 Resolves bitcoin#19748
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
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
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
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
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
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
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
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
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
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
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
…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
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
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
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.dat
in such a way that oldversions (before this commit) will not be able to read a file written by
new versions (after this commit).