Export embedded ASMap RPC #33920

pull fjahr wants to merge 2 commits into bitcoin:master from fjahr:2025-11-asmap-export changing 4 files +100 −7
  1. fjahr commented at 11:53 PM on November 20, 2025: contributor

    This depends on the embedded data PR itself (#28792), until merge this will remain in draft status. All commit but the last one are from there.

    There has been interest in exporting the embedded data back into a file. This is implemented here with a simple exportasmap RPC which provides this functionality. The exported file can be used to verify the data integrity or statistical analysis using e.g. contrib/asmap-tool.py.

  2. DrahtBot commented at 11:53 PM on November 20, 2025: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33920.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK sedited, seduless, achow101

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35040 (Remove CNode dependency for local address functions and introduce LocalAddressManager by theuni)

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. fjahr force-pushed on Nov 20, 2025
  4. DrahtBot added the label CI failed on Nov 20, 2025
  5. fjahr force-pushed on Nov 21, 2025
  6. fjahr force-pushed on Nov 21, 2025
  7. fjahr force-pushed on Nov 21, 2025
  8. DrahtBot removed the label CI failed on Nov 21, 2025
  9. DrahtBot added the label Needs rebase on Nov 22, 2025
  10. fjahr force-pushed on Feb 19, 2026
  11. fjahr commented at 8:59 AM on February 19, 2026: contributor

    Rebased and taken out of draft status since embedding asmap was merged.

  12. fjahr marked this as ready for review on Feb 19, 2026
  13. in src/rpc/net.cpp:1132 in 8b4b8a3d26
    1127 | +        "exportasmap",
    1128 | +        "Export the embedded ASMap data to a file.\n",
    1129 | +            {
    1130 | +                {"filepath", RPCArg::Type::STR, RPCArg::Optional::NO, "The path where the ASMap file is saved"},
    1131 | +            },
    1132 | +            RPCResult{RPCResult::Type::NONE, "", ""},
    


    maflcko commented at 9:39 AM on February 19, 2026:

    According to the dev notes:

    • Try to make the RPC response a JSON object.

      • Rationale: If a RPC response is not a JSON object, then it is harder to avoid API breakage if new data in the response is needed.

    Also, could clang-format new code?


    fjahr commented at 10:04 AM on February 19, 2026:

    Made it return an empty json object and ran clang-format

  14. fjahr force-pushed on Feb 19, 2026
  15. DrahtBot added the label CI failed on Feb 19, 2026
  16. DrahtBot removed the label Needs rebase on Feb 19, 2026
  17. DrahtBot removed the label CI failed on Feb 19, 2026
  18. seduless commented at 6:15 PM on February 19, 2026: contributor

    Tested b065ec9acc98112f4ea9a6d2bae9a7a6187ee2a8

    Built with and without embedded asmap. Ran feature_asmap.py, passes in both configurations. Commented out file << asmap_data and confirmed the test fails.

  19. in src/rpc/net.cpp:1130 in b065ec9acc
    1125 | +{
    1126 | +    return RPCHelpMan{
    1127 | +        "exportasmap",
    1128 | +        "Export the embedded ASMap data to a file.\n",
    1129 | +        {
    1130 | +            {"filepath", RPCArg::Type::STR, RPCArg::Optional::NO, "The path where the ASMap file is saved"},
    


    maflcko commented at 8:15 AM on February 20, 2026:

    should clarify that this will overwrite any prior file?


    fjahr commented at 12:37 PM on February 27, 2026:

    Added, thanks!

  20. fjahr force-pushed on Feb 27, 2026
  21. DrahtBot added the label CI failed on Feb 27, 2026
  22. DrahtBot removed the label CI failed on Mar 2, 2026
  23. sedited commented at 11:07 AM on March 13, 2026: contributor

    Concept ACK

  24. sedited added this to the milestone 32.0 on Mar 18, 2026
  25. sedited requested review from sipa on Mar 19, 2026
  26. sedited requested review from sipa on Mar 19, 2026
  27. in src/rpc/net.cpp:1139 in 24fabb2030
    1134 | +            HelpExampleCli("exportasmap", "\"/tmp/asmap.dat\"") + HelpExampleRpc("exportasmap", "\"/tmp/asmap.dat\"")},
    1135 | +        [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
    1136 | +#ifndef ENABLE_EMBEDDED_ASMAP
    1137 | +            throw JSONRPCError(RPC_MISC_ERROR, "No embedded ASMap data available");
    1138 | +#else
    1139 | +            std::span<const std::byte> asmap_data{node::data::ip_asn};
    


    sedited commented at 7:52 AM on April 21, 2026:

    Nit: I guess you are declaring this as an alias to the data? Not sure how useful that is, seems clearer to just point to the embedded data directly.


    fjahr commented at 11:29 AM on April 21, 2026:

    Sure, done.

  28. in src/rpc/net.cpp:1132 in 24fabb2030
    1127 | +        "exportasmap",
    1128 | +        "Export the embedded ASMap data to a file.\n",
    1129 | +        {
    1130 | +            {"filepath", RPCArg::Type::STR, RPCArg::Optional::NO, "The path where the ASMap file is saved. Existing file will be overwritten."},
    1131 | +        },
    1132 | +        RPCResult{RPCResult::Type::OBJ, "", ""},
    


    sedited commented at 7:57 AM on April 21, 2026:

    In e.g. dumptxoutset we return a path and some meta information in the result. Might make sense to add that here too?


    fjahr commented at 11:29 AM on April 21, 2026:

    Ok, returning the path, bytes written and file hash now.

  29. in src/rpc/net.cpp:1130 in 24fabb2030
    1125 | +{
    1126 | +    return RPCHelpMan{
    1127 | +        "exportasmap",
    1128 | +        "Export the embedded ASMap data to a file.\n",
    1129 | +        {
    1130 | +            {"filepath", RPCArg::Type::STR, RPCArg::Optional::NO, "The path where the ASMap file is saved. Existing file will be overwritten."},
    


    sedited commented at 8:00 AM on April 21, 2026:

    I think it would be good to clarify if this takes relative and absolute paths, as done in dumptxoutset. Maybe it can just directly mimic the file handling mechanics from that endpoint?


    fjahr commented at 11:29 AM on April 21, 2026:

    Ok, I aligned file handling with dumptxoutset except for the override part. I think it is fine to override here because this is just single file that comes out of of specific core version and this happens almost instantly. For dumptxoutset the RPC can potentially run a long time and there can be dumps for many different height generated from a single bitcoin core node. Does this distinction make sense to you? I am not feeling super passionate about this though.


    sedited commented at 11:39 AM on April 21, 2026:

    Yes, overwriting seems fine to me too.

  30. fjahr force-pushed on Apr 21, 2026
  31. fjahr force-pushed on Apr 21, 2026
  32. DrahtBot added the label CI failed on Apr 21, 2026
  33. DrahtBot commented at 11:33 AM on April 21, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task FreeBSD Cross: https://github.com/bitcoin/bitcoin/actions/runs/24719866520/job/72305651214</sub> <sub>LLM reason (✨ experimental): CI failed because the C++ build failed to compile rpc/net.cpp due to an unknown/undeclared RPCHelpMan type.</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  34. fjahr commented at 11:39 AM on April 21, 2026: contributor

    Addressed comments from @sedited . Thanks for the review!

    This also needed a rebase since this hadn't picked up on the RPCMethod rename yet.

    I have also added a short release note since we seem to always have them for newly introduced RPCs.

  35. rpc: Add exportasmap RPC 8cb2d926b4
  36. Add release notes for exportasmap 2a90b6132a
  37. fjahr force-pushed on Apr 21, 2026
  38. DrahtBot removed the label CI failed on Apr 21, 2026
  39. sedited approved
  40. sedited commented at 10:52 AM on April 23, 2026: contributor

    ACK 2a90b6132a58325e5260dcaaa2560b7f8ad5622e

  41. in src/rpc/net.cpp:1170 in 2a90b6132a
    1165 | +            HashWriter hasher;
    1166 | +            hasher.write(node::data::ip_asn);
    1167 | +
    1168 | +            UniValue result(UniValue::VOBJ);
    1169 | +            result.pushKV("path", export_path.utf8string());
    1170 | +            result.pushKV("bytes_written", (uint64_t)node::data::ip_asn.size());
    


    seduless commented at 9:23 PM on April 24, 2026:

    fjahr commented at 10:44 AM on April 25, 2026:

    Yeah, should have, will try to address this with the next asmap-related code change

  42. seduless commented at 9:26 PM on April 24, 2026: contributor

    Tested ACK 2a90b6132a58325e5260dcaaa2560b7f8ad5622e

    Rebuilt with and without embedded asmap and verified feature_asmap.py passes in both builds. One style guide nit, but feel free to ignore.

  43. achow101 commented at 10:55 PM on April 24, 2026: member

    ACK 2a90b6132a58325e5260dcaaa2560b7f8ad5622e

  44. achow101 merged this on Apr 24, 2026
  45. achow101 closed this on Apr 24, 2026

  46. sedited referenced this in commit 75f2bf1011 on Apr 25, 2026

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-28 21:13 UTC

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