Introduce new V4 format addrman #23354

pull sipa wants to merge 1 commits into bitcoin:master from sipa:202110_v4addrman changing 3 files +5 −4
  1. sipa commented at 3:43 PM on October 25, 2021: member

    #23306 effectively changed the on-disk format in an incompatible way: old deserializers cannot deal with multiple entries for the same IP.

    Introduce a V4_MULTIPORT format, and increment the compatibility base, so that old versions correctly recognize it as an incompatible future version, rather than corruption.

  2. laanwj commented at 3:53 PM on October 25, 2021: member

    Concept ACK

  3. DrahtBot added the label P2P on Oct 25, 2021
  4. Introduce new V4 format addrman
    92617b7a758c0425330fba4b886296730567927c effectively changed the
    on-disk format in an incompatible way: old deserializers cannot
    deal with multiple entries for the same IP.
    
    Introduce a V4_MULTIPORT format, and increment the compatibility base,
    so that old versions correctly recognize it as an incompatible future
    version.
    d891ae7681
  5. sipa force-pushed on Oct 25, 2021
  6. naumenkogs commented at 8:05 AM on October 26, 2021: member

    ACK d891ae768185b464cae476c16c74c365372d4a3c

  7. ajtowns commented at 8:32 AM on October 26, 2021: member

    utACK d891ae768185b464cae476c16c74c365372d4a3c

  8. MarcoFalke commented at 12:44 PM on October 26, 2021: member

    I tested the "correct" error message (failing to load because of version). Testing the "wrong" error message (corruption) might be harder, as it requires -checkaddrman (or the implicit check), both of which are only in master, thus require re-compilation. So I think a regression-test with previous releases is not possible, at least not in the functional test framework.

    So I tested the new format manually:

    $ ./src/bitcoin-cli -regtest -datadir=/tmp/test_23354/ addpeeraddress "250.1.1.2" 12345 
    {
      "success": true
    }
    $ ./src/bitcoin-cli -regtest -datadir=/tmp/test_23354/ addpeeraddress "250.1.1.2" 12367 
    {
      "success": true
    }
    

    Start with previous versions prints the correct error now:

    Bitcoin Core version v22.0.0 (release build)
    ...
    ERROR: DeserializeDB: Deserialize or I/O error - Unsupported format of addrman database: 4. It is compatible with formats >=4, but the maximum supported by this version of Bitcoin Core is 3.: iostream error
    Recreating peers.dat
    

    or going back even further:

    Bitcoin Core version v0.20.1 (release build)
    ...
    ERROR: DeserializeDB: Deserialize or I/O error - Incorrect keysize in addrman deserialization: iostream error
    Invalid or missing peers.dat; recreating
    
  9. vasild approved
  10. vasild commented at 2:53 PM on October 28, 2021: member

    ACK d891ae768185b464cae476c16c74c365372d4a3c

    I tested #23306 which is essentially the same:

    1. Start latest code (with and without this PR) and use addpeeraddress RPC to create peers.dat with duplicates (either V3 or V4)
    2. Recompile 92617b7~ and start it on the new peers.dat

    It works as expected.

  11. jnewbery commented at 9:22 AM on October 29, 2021: member

    Concept ACK

  12. MarcoFalke merged this on Oct 29, 2021
  13. MarcoFalke closed this on Oct 29, 2021

  14. sidhujag referenced this in commit 827e54c8e7 on Oct 29, 2021
  15. Fabcien referenced this in commit 0db06b504d on Oct 21, 2022
  16. DrahtBot locked this on Oct 30, 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: 2026-04-14 18:14 UTC

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