net: (de)serialize CSubNet in addrv2 format #20904

pull vasild wants to merge 3 commits into bitcoin:master from vasild:subnet_ser_addrv2 changing 3 files +102 −31
  1. vasild commented at 4:34 pm on January 11, 2021: member

    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 old versions (before this commit) will not be able to read a file written by new versions (after this commit).

  2. net: (de)serialize CSubNet in addrv2 format
    This is a followup to https://github.com/bitcoin/bitcoin/pull/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).
    10b3e429a4
  3. test: ensure banlist.dat can be read after restart
    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.
    bc28dc9a0c
  4. test: add test to ensure non-IP peers are properly misbehaved
    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.
    e1fe658705
  5. vasild commented at 4:38 pm on January 11, 2021: member

    TODO:

    • See if we ser/deser CSubNet somewhere else in the code, other than in BanMan and if yes, then what are the implications for that other code.
    • See what is the relationship between this and other changes that alter the format of banlist.dat, e.g. #19825.
  6. DrahtBot added the label P2P on Jan 11, 2021
  7. in src/test/denialofservice_tests.cpp:226 in e1fe658705
    222@@ -223,47 +223,84 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
    223 {
    224     const CChainParams& chainparams = Params();
    225     auto banman = MakeUnique<BanMan>(GetDataDir() / "banlist.dat", nullptr, DEFAULT_MISBEHAVING_BANTIME);
    226-    auto connman = MakeUnique<CConnman>(0x1337, 0x1337);
    227+    auto connman = MakeUnique<CConnmanTest>(0x1337, 0x1337);
    


    MarcoFalke commented at 5:30 pm on January 11, 2021:
    nit: Would be nice to split the “rafactor” part from the “new-tests” part in this commit

    vasild commented at 10:59 am on January 20, 2021:
    Done and copied the tests to #20966 (since this PR is closed without merge).
  8. MarcoFalke commented at 5:30 pm on January 11, 2021: member
    Concept ACK, didn’t look at the code changes
  9. DrahtBot commented at 6:31 pm on January 11, 2021: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #20811 (refactor: move net_processing implementation details out of header by ajtowns)
    • #20228 (addrman: Make addrman a top-level component by jnewbery)

    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.

  10. sipa commented at 6:52 pm on January 11, 2021: member
    How does this maintain forward compatibility (new versions being able to read subnets written by old versions)?
  11. MarcoFalke added the label Needs backport (0.21) on Jan 11, 2021
  12. MarcoFalke added this to the milestone 0.21.1 on Jan 11, 2021
  13. vasild commented at 8:05 am on January 12, 2021: member

    How does this maintain forward compatibility (new versions being able to read subnets written by old versions)?

    I does not, but it should.

  14. vasild referenced this in commit 790727eeaf on Jan 19, 2021
  15. vasild commented at 7:08 pm on January 19, 2021: member
    Closing in favor of #20966.
  16. vasild closed this on Jan 19, 2021

  17. MarcoFalke deleted a comment on Jan 19, 2021
  18. vasild referenced this in commit e1db22bd54 on Jan 28, 2021
  19. vasild referenced this in commit 899a8c3307 on Feb 15, 2021
  20. vasild referenced this in commit 304aa85825 on Mar 10, 2021
  21. vasild referenced this in commit 8372aad9cc on Mar 15, 2021
  22. fanquake removed the label Needs backport (0.21) on Mar 24, 2021
  23. fanquake removed this from the milestone 0.21.1 on Mar 24, 2021
  24. vasild referenced this in commit e2a5584e77 on Mar 24, 2021
  25. vasild referenced this in commit ec1c4f4ad3 on Apr 6, 2021
  26. vasild referenced this in commit cdeb38a2ea on Apr 6, 2021
  27. vasild referenced this in commit 51909ded1e on Apr 19, 2021
  28. vasild referenced this in commit c7cb9fc74d on Apr 20, 2021
  29. vasild referenced this in commit 31001540e2 on Apr 20, 2021
  30. vasild referenced this in commit 391b4d5e84 on Apr 26, 2021
  31. vasild referenced this in commit d586283296 on May 18, 2021
  32. vasild referenced this in commit cd9da1b2a2 on May 24, 2021
  33. vasild referenced this in commit e5774fac4d on Jun 14, 2021
  34. vasild referenced this in commit d197977ae2 on Jun 21, 2021
  35. MarcoFalke referenced this in commit d6e0d78c31 on Jun 23, 2021
  36. josibake referenced this in commit 152d72ab89 on Jul 21, 2021
  37. janus referenced this in commit 03063373d5 on Nov 5, 2021
  38. stickies-v referenced this in commit 51c3f65e70 on Mar 24, 2022
  39. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me