-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Interfaces: Expose UTXO Snapshot Loading and Add Progress Notifications #33117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33117. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
I plan to test this soon(tm). |
Thanks @Sjors ! |
src/interfaces/node.h
Outdated
@@ -204,6 +205,9 @@ class Node | |||
//! List rpc commands. | |||
virtual std::vector<std::string> listRpcCommands() = 0; | |||
|
|||
//! Load UTXO Snapshot. | |||
virtual bool loadSnapshot(AutoFile& afile, const node::SnapshotMetadata& metadata, bool in_memory) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "interfaces: expose UTXO snapshot loading in node interface" (de11e3b)
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:
class Node
{
// ...
std::unique_ptr<Snapshot> loadSnapshot(const fs::path& path) = 0;
// ...
};
class Snapshot
{
public:
virtual ~Snapshot() = default;
node::SnapshotMetadata getMetadata() = 0;
bool activate() = 0;
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review... will update soon addressing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #33117 (comment)
Thanks! I think b464f38 is an improvement over previous de11e3b 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 b464f38 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 b464f38, 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
c29a5df
to
e79c50c
Compare
concept ACK, tested the mainnet snapshot load with the QML gui branch built on top of this |
https://github.com/bitcoin/bitcoin/actions/runs/16728433539/job/47504424705?pr=33117#step:10:445: D:\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]
D:\a\bitcoin\bitcoin\src\node\interfaces.cpp(115,40): warning C4101: 'e': unreferenced local variable [D:\a\bitcoin\bitcoin\build\src\bitcoin_node.vcxproj] |
- 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
- 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.
e79c50c
to
8bc4035
Compare
with 8bc4035 it has been rebased and the fuzzing CI error has been addressed |
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
loadSnapshot
to the node interface for loading UTXO snapshots.interfaces.cpp
to activate the snapshot using the provided file and metadata.Commit 2:
notifications: Implement snapshot load progress notifications
SnapshotLoadProgress
for snapshot load progress in the UI interface.ChainstateManager
to report progress during snapshot loading.Technical Details
The implementation includes:
UI Interface Enhancement
Added
SnapshotLoadProgress
signal toCClientUIInterface
with corresponding signal declaration and implementation.Node Interface
Added
loadSnapshot
virtual method to the node interface with implementation ininterfaces.cpp
.Progress Notifications
Implemented
snapshotLoadProgress
method inKernelNotifications
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