Default ASmap file path is not used unless -asmap is set #33386

issue vostrnad openend this issue on September 13, 2025
  1. vostrnad commented at 11:37 pm on September 13, 2025: none

    The -asmap option supposedly has a default value ip_asn.map (as defined by DEFAULT_ASMAP_FILENAME). However, when I tried to put a file with this name into my datadir, nothing happened. It turns out that this default is not actually used unless the -asmap option is set, which seems weird since setting the option normally overrides the default. There is a way to set it without overriding the default on the command line (bitcoind -asmap), but in bitcoin.conf there doesn’t seem to be a way to do that (e.g. asmap=1 sets the file path to 1).

    Some ways this could be resolved:

    • Simply better document this behavior. The help text doesn’t say that the default value is not actually used when the option is not set, and the option itself is introduced as -asmap=<file> which in no way indicates that it can be used without a value.
    • If the option is not set (but not explicitly disabled with -noasmap) try to load the ASmap file using the default path but don’t abort if the file doesn’t exist.
    • Remove the default value to prevent any confusion.
  2. fanquake commented at 12:00 pm on September 16, 2025: member
  3. fjahr commented at 1:22 pm on September 16, 2025: contributor

    I agree that this whole default location thing is a bit odd and it’s not something I think we necessarily need but it was already there when I started to get more involved in ASmap and I didn’t find it so harmful that it needed to be removed. It can be easily ignored by just not putting a file there after all, so if you don’t like it just don’t use it, I guess.

    The -asmap option supposedly has a default value ip_asn.map (as defined by DEFAULT_ASMAP_FILENAME). However, when I tried to put a file with this name into my datadir, nothing happened. It turns out that this default is not actually used unless the -asmap option is set, which seems weird since setting the option normally overrides the default.

    I think the behavior is correct that placing a file in the default location doesn’t activate ASmap automatically. ASmap is off by default and I don’t think we have another feature that gets activated with just a file being in a certain place. I prefer that the feature still needs to be explicitly activated for now.

    FWIW, I am reading -asmap documentation as “activate the feature, then it will look for the file in the default location or the location provided” while you read it as “if the file is in the default location, activate the feature, otherwise also activate the feature if the default location was overridden”. Can you pinpoint which part of the docs gave you this impression? Was it the RPC help or maybe files.md (https://github.com/bitcoin/bitcoin/blob/master/doc/files.md)? Is there a different place where you think this behavior could be better documented?

    Some ways this could be resolved:

    I would suggest to go with option one and add some more documentation. Note that this doesn’t get easier to reason about when there is an additional path available with embedded data, should #28792 be merged. I am giving an explanation of the behavior here: #28792 (comment) and I am expanding the documentation in the PR accordingly, also adding something explicitly on the default file location: https://github.com/bitcoin/bitcoin/pull/28792/files#diff-b1e19192258d83199d8adaa5ac31f067af98f63554bfdd679bd8e8073815e69dR526 There is also some more on the asmap data here: https://github.com/bitcoin/bitcoin/pull/28792/files#diff-7128095523f4b61eba067a48474bdc10b72fe13cf8843408c1154a488fcf6f60

    There is a way to set it without overriding the default on the command line (bitcoind -asmap), but in bitcoin.conf there doesn’t seem to be a way to do that (e.g. asmap=1 sets the file path to 1).

    This is actually a bug (IMO) that is unrelated to ASmap itself, I am fixing it in the embedding PR and it’s also included in this smaller prework PR that I have extracted and there was a little bit of discussion on it there as well: #33026 (review) I am actually happy that you ran into this and see it as an issue too ;)

  4. ryanofsky commented at 5:17 pm on September 16, 2025: contributor

    re: fjahr #33386 (comment)

    Can you pinpoint which part of the docs gave you this impression? Was it the RPC help or maybe files.md (https://github.com/bitcoin/bitcoin/blob/master/doc/files.md)? Is there a different place where you think this behavior could be better documented?

    Since I noted the same issue in #30529#pullrequestreview-2516002191, the part of the doc which gave me that impression was just:

    0(default: ip_asn.map)
    

    When docs specify a default value for an option, I think the implication is that default value is the value which will be used if the option is not specified.

    In this case, no file is loaded when -asmap is not specified, so I don’t think it’s accurate to say that the default value is ip_asn.map. Could address this with a change like:

    0(default: disabled, but if -asmap or -asmap= is specified without a filename, "ip_asn.map" will be used)
    

    re: vostmad #33386#issue-3414291236

    but in bitcoin.conf there doesn’t seem to be a way to do that (e.g. asmap=1 sets the file path to 1).

    I think you can actually do it by specifying asmap= in the configuration file, and maybe the documentation suggestion above would make that clearer. But I’m not actually sure if there is currently a use-case for that. If you have to download a file manually AND you have to update the configuration it seems rational to have to point the configuration file you edit to the file you downloaded. Supporting asmap=1 seems more useful in a future scenario where you don’t have to download any file.

    re: fjahr #33386 (comment)

    I think the behavior is correct that placing a file in the default location doesn’t activate ASmap automatically.

    This is reasonable, but not what I’d would expect given current documentation. And it does seem to me like it would be nice if the file was used by default as long as it existed and the option was not changed (similar to other files in the datadir), but maybe this is not safe.

    This is actually a bug (IMO) that is unrelated to ASmap itself, I am fixing it in the embedding PR

    I wouldn’t say it’s a bug that if you specify “1” as a filename, it’s interpreted as a filename. I do think it probably makes sense to support -asmap=1 as a special case for loading embedded data. But it would seem a little cleaner to me to have separate -asmap/-asmapfile options or some other unambiguous way of passing a filename that is just a filename.

    These are just off-the-cuff opinions, though. You’ve thought about the asmap option more than me and I think different approaches are reasonable here.

  5. vostrnad commented at 9:50 pm on September 16, 2025: none

    To clarify, the docs that confused me was the CLI help text:

    0  -asmap=<file>
    1       Specify asn mapping used for bucketing of the peers (default:
    2       ip_asn.map). Relative paths will be prefixed by the net-specific
    3       datadir location.
    

    As ryanofsky said, this seems to imply that the default value is used when the option is not specified. I would personally be fine with that behavior (it certainly didn’t raise any eyebrows when I thought that was how it worked), but maybe you’re right that it’s not safe.


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: 2025-09-26 15:13 UTC

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