Interfaces: Expose UTXO Snapshot Loading and Add Progress Notifications #33117

pull D33r-Gee wants to merge 2 commits into bitcoin:master from D33r-Gee:interface-load-snapshot changing 9 files +102 −0
  1. D33r-Gee commented at 3:31 pm on August 1, 2025: none

    Add UTXO Snapshot Loading Interface and Progress Notifications

    This PR implements a complete interface for loading UTXO snapshots through the GUI, including progress notifications to provide user feedback during the loading process.


    Changes

    Commit 1: interfaces: expose UTXO snapshot loading in node interface

    • Added a new virtual method loadSnapshot to the node interface for loading UTXO snapshots.
    • Updated the implementation in interfaces.cpp to activate the snapshot using the provided file and metadata.
    • This change enhances the user’s ability to load UTXO snapshots through the GUI.

    Commit 2: notifications: Implement snapshot load progress notifications

    • Added a new signal SnapshotLoadProgress for snapshot load progress in the UI interface.
    • Updated the notifications interface to include a method for reporting snapshot loading progress.
    • Enhanced the ChainstateManager to report progress during snapshot loading.
    • Implemented the necessary handler in the kernel notifications to relay progress updates.
    • This change improves user feedback during the snapshot loading process.

    Technical Details

    The implementation includes:

    • UI Interface Enhancement Added SnapshotLoadProgress signal to CClientUIInterface with corresponding signal declaration and implementation.

    • Node Interface Added loadSnapshot virtual method to the node interface with implementation in interfaces.cpp.

    • Progress Notifications Implemented snapshotLoadProgress method in KernelNotifications class to relay progress updates to the UI.

    • Base Interface Added snapshotLoadProgress virtual method to the kernel notifications interface.


    Benefits

    • User Experience Provides real-time feedback during UTXO snapshot loading operations.

    • GUI Integration Enables loading UTXO snapshots directly through the Bitcoin Core GUI.

    • Progress Tracking Users can monitor the progress of snapshot loading operations.

    • Consistent Interface Follows the existing pattern for progress notifications in the codebase.

    Testing

    • QT Widgets: build and run this draft PR in legacy gui repo
    • QML version: for a modern look build and run this PR in the newly updated gui-qml repo
  2. DrahtBot added the label interfaces on Aug 1, 2025
  3. DrahtBot commented at 3:31 pm on August 1, 2025: contributor

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

    Code Coverage & Benchmarks

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK pinheadmz

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #bitcoin-core/gui/870 ([DRAFT] Expose AssumeUTXO Load Snapshot Functionality To The GUI by D33r-Gee)
    • #32297 (bitcoin-cli: Add -ipcconnect option by ryanofsky)

    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.

  4. D33r-Gee referenced this in commit 26a2e0fccb on Aug 1, 2025
  5. D33r-Gee referenced this in commit 5e561eff75 on Aug 1, 2025
  6. Sjors commented at 6:41 pm on August 1, 2025: member
    I plan to test this soon(tm).
  7. D33r-Gee commented at 8:54 pm on August 1, 2025: none

    I plan to test this soon(tm).

    Thanks @Sjors !

  8. in src/interfaces/node.h:209 in de11e3b89f outdated
    204@@ -204,6 +205,9 @@ class Node
    205     //! List rpc commands.
    206     virtual std::vector<std::string> listRpcCommands() = 0;
    207 
    208+    //! Load UTXO Snapshot.
    209+    virtual bool loadSnapshot(AutoFile& afile, const node::SnapshotMetadata& metadata, bool in_memory) = 0;
    


    ryanofsky commented at 10:00 pm on August 1, 2025:

    In commit “interfaces: expose UTXO snapshot loading in node interface” (de11e3b89f8aba9a90a3419086807e5fee0f941d)

    Note with #10102 if the GUI & node are running in separate processes, it could be a awkward for the gui process to create an AutoFile object and pass it to the node like this. Technically it could probably work: the AutoFile could be passed as a file descriptor or a (path, position) tuple. But it doesn’t seem like a clean separation of responsibilities if the GUI process is reading the beginning of the snapshot file and the node process is reading the rest of the file.

    Probably current interface is ok, but it might be more ideal if node provided a more generic loadSnapshot method and the GUI didn’t directly access the file:

     0class Node
     1{
     2    // ...
     3    std::unique_ptr<Snapshot> loadSnapshot(const fs::path& path) = 0;
     4    // ...
     5};
     6
     7class Snapshot
     8{
     9public:
    10    virtual ~Snapshot() = default;
    11    node::SnapshotMetadata getMetadata() = 0;
    12    bool activate() = 0;
    13};
    

    D33r-Gee commented at 11:35 pm on August 1, 2025:
    Thanks for the review… will update soon addressing this

    D33r-Gee commented at 4:24 pm on August 4, 2025:
    with e79c50c updated the node.h and added snapshot.h to the /interfaces. Also updated interfaces.cpp with a SnapshotImpl class to process the path and extracts the metada and activate the snapshot. @ryanofsky let me know if that’s what you had in mind?

    ryanofsky commented at 4:46 pm on August 4, 2025:

    re: #33117 (review)

    Thanks! I think b464f388197c5c31937d309d817d38c4b4849a91 is an improvement over previous de11e3b89f8aba9a90a3419086807e5fee0f941d because it passes an fs::path argument from the GUI to the node instead of an AutoFile file argument. This is nice because it lets node be fully responsible for parsing the snapshot file instead of relying on the GUI.

    One comment on b464f388197c5c31937d309d817d38c4b4849a91 is that it looks like the Snapshot class is not actually necessary in its current form. The reason I suggested adding a Snapshot class above was that I thought GUI wanted to display SnapshotMetadata information before activating the snapshot, and a Snapshot class could provide separate getMetadata() and activate() methods to allow that. But since the Snapshot class only has a single activate() method in b464f388197c5c31937d309d817d38c4b4849a91, it looks like the class is unnecessary, and you could just have a plain Node::activateSnapshot(fs::path) method that returns bool instead of a Snapshot.

    Any approach is fine though, so you should choose whatever seems to make the most sense.


    D33r-Gee commented at 3:23 pm on August 6, 2025:

    Thanks for taking a look! RE:

    The reason I suggested adding a Snapshot class above was that I thought GUI wanted to display SnapshotMetadata information before activating the snapshot, and a Snapshot class could provide separate getMetadata()

    I took some time to test various scenarios downstream in the gui-qml project. While we aren’t directly utilizing the snapshot data at the moment, I believe your initial instincts about introducing a Snapshot class were well-founded. This abstraction will become increasingly valuable as we begin to expose the dump/generate snapshot functionalities trough the GUI.

  9. D33r-Gee force-pushed on Aug 4, 2025
  10. pinheadmz commented at 2:37 pm on August 5, 2025: member
    concept ACK, tested the mainnet snapshot load with the QML gui branch built on top of this
  11. fanquake commented at 1:09 pm on August 6, 2025: member

    https://github.com/bitcoin/bitcoin/actions/runs/16728433539/job/47504424705?pr=33117#step:10:445:

    0D:\a\bitcoin\bitcoin\src\node\interfaces.cpp(115,40): error C2220: the following warning is treated as an error [D:\a\bitcoin\bitcoin\build\src\bitcoin_node.vcxproj]
    1D:\a\bitcoin\bitcoin\src\node\interfaces.cpp(115,40): warning C4101: 'e': unreferenced local variable [D:\a\bitcoin\bitcoin\build\src\bitcoin_node.vcxproj]
    
  12. interfaces: expose UTXO snapshot loading in node interface
    - Added a new virtual method `loadSnapshot` to the node interface for loading UTXO snapshots.
    - Updated the implementation in `interfaces.cpp` to activate the snapshot using a path.
    - Added `snapshot.h` to src/interfaces to process the path and extract the metada
    
    This change enhances the user ability to load utxo snapshots through the gui
    3c8b578836
  13. notifications: Implement snapshot load progress notifications
    - Added a new signal for snapshot load progress in the UI interface.
    - Updated the notifications interface to include a method for reporting snapshot loading progress.
    - Enhanced the ChainstateManager to report progress during snapshot loading.
    - Implemented the necessary handler in the kernel notifications to relay progress updates.
    
    This change improves user feedback during the snapshot loading process.
    8bc4035570
  14. D33r-Gee force-pushed on Aug 6, 2025
  15. D33r-Gee commented at 4:48 pm on August 7, 2025: none
    with 8bc4035 it has been rebased and the fuzzing CI error has been addressed

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-08-12 09:13 UTC

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