anchors.dat doesn’t support V2 addresses #20511

issue sipa openend this issue on November 26, 2020
  1. sipa commented at 7:41 pm on November 26, 2020: member

    The new anchors.dat file stores a vector of CAddress objects, and doesn’t set ADDRV2_FORMAT. That means that torv3 and other addrv2 network types won’t be serialized correctly in it. It would be good to address this in 0.21.

    Now, CAddress does have a version field, which can be used to signal the encoding. In the current code, on serialization that value stores whether ADDRV2_FORMAT is set or not, and on deserialization that value is inspected to determine which deserializer to use. #20509 was just opened to change this, and that may complicate matters.

    That means there are a number of possible solutions here:

    • Make CAddress deserialization use the context version rather than the disk version (20509) and make anchors.dat always use ADDRV2_FORMAT. This means potential problems too if there is ever an addrv3.
    • Make anchors.dat always set ADDRV2_FORMAT, but keep using the stored disk version at deserialization time. That’s incompatible with 20509, but an easier fix for 0.21.
    • Change the anchors.dat file format to have a version number. That could be done now (but is a pretty invasive change at rc3…), or could be done later by encoding it as an “invalid CAddress” first as a marker…
  2. sipa added the label Bug on Nov 26, 2020
  3. sipa added this to the milestone 0.21.0 on Nov 26, 2020
  4. sipa commented at 8:14 pm on November 26, 2020: member
    Thinking this over a bit more, I think the best solution is the second one.
  5. jnewbery removed this from the milestone 0.21.0 on Dec 3, 2020
  6. pinheadmz commented at 7:48 pm on March 31, 2023: member
    @sipa was this closed by #20516 ?
  7. sipa commented at 3:35 pm on April 9, 2023: member
    @pinheadmz I think so.
  8. pinheadmz commented at 2:44 pm on April 12, 2023: member

    @pinheadmz I think so.

    Confirmed with tests! See https://github.com/bitcoin/bitcoin/pull/27452

  9. pinheadmz closed this on Apr 12, 2023

  10. fanquake referenced this in commit 2fa60f0b68 on Aug 2, 2023
  11. bitcoin locked this on Apr 11, 2024


sipa pinheadmz

Labels
Bug


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-10-05 01:12 UTC

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