Skip to content
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

[DRAFT] WIP QML Generate Snapshot Signet #446

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

D33r-Gee
Copy link
Contributor

@D33r-Gee D33r-Gee commented Mar 4, 2025

Based on #424. For evaluation purposes only!

GUI Integration for Generating UTXO Snapshots

Overview

This PR adds initial GUI support for generating a signet UTXO snapshot at height 160,000, building on Bitcoin Core's assumeutxo infrastructure.

What This PR Does

  1. Adds a basic GUI interface for generating UTXO snapshots via the Connection Settings panel
  2. Implements non-blocking snapshot generation via QT Thread
  3. Provides visual confirmation of snapshot generation
  4. Adds a snapshot progress notifications accessible via a handler

Implementation Details

Core Components Modified

  1. Node Interface (src/node/interfaces.cpp)
  • Implements a notification handler for snapshot generation progress (rewind and restore)
  1. Snapshot Qml (src/qml/models/snapshotqml.h)
  • Introduces a worker class to manage snapshot generation
  1. QML Integration (src/qml/models/nodemodel.cpp)
  • Manages snapshot generation state and progress
  • Uses Qt's thread system to prevent UI blocking
  • Provides progress updates via Qt signals
  1. UI Components (src/qml/components/SnapshotGenSettings.qml)
  • File view for snapshot generation
  • Snapshot generation progress and completion

Key Design Decisions

  1. Non-blocking Implementation
  • Snapshot generation runs in separate QT thread
  • UI remains responsive during generation
  • Node is disconnected from the network during generation
  1. Extensibility
  • Interface designed to accommodate future assumeutxo changes
  • Error handling framework in place

Testing Instructions

  1. Build
  2. Launch Bitcoin Core QML GUI
  3. Navigate to Connection Settings
  4. Wait for IBD to complete
  5. Click "Generate Snapshot"
  6. Verify (see screenshots below):
    • "Snapshot Generated" confirmation appears
    • snapshot file is created in the signet data directory
Ubuntu 22.04 Screenshots

Screenshot 2025-03-04 115218
Screenshot 2025-03-04 115246
Screenshot 2025-03-04 115309
Screenshot 2025-03-04 115323
Screenshot 2025-03-04 115356
Screenshot 2025-03-04 115641
Screenshot 2025-03-04 gen file view

Expected Behavior

  • File selection dialog works
  • Success/failure state properly displayed
  • Node is disconnected from the network during generation

Future Work

  1. Cancel Snapshot Generation
  • Add ability to cancel snapshot generation
  1. Integration
  • Coordinate with upstream assumeutxo changes
  • Add support for network-specific snapshots (testnet and mainnet)

Notes for Reviewers

Snapshot Compatibility

  • Currently only works with signet
  • Limited to specific 160,000 height
  • Validates against chain parameters m_assumeutxo_data
    (the changes there can be discarded once synced since m_assumeutxo_data is already hardcoded)

This is a work in progress - feedback welcome on the approach and implementation details.

@D33r-Gee D33r-Gee force-pushed the qml-gen-snapshot-signet branch from d44eb7f to abc189a Compare March 5, 2025 16:20
@yashrajd
Copy link

yashrajd commented Mar 5, 2025

Great start! Thanks for continuing to do this man. I have not tested on my machine, responding to screenshots below.

What This PR Does

  1. Adds a basic GUI interface for generating UTXO snapshots via the Connection Settings panel
  2. Implements non-blocking snapshot generation via QT Thread
  3. Provides visual confirmation of snapshot generation
  4. Adds a snapshot progress notifications accessible via a handler

...

  1. UI Components (src/qml/components/SnapshotGenSettings.qml)
  • File view for snapshot generation
  • Snapshot generation progress and completion

Key Design Decisions

  1. Non-blocking Implementation
  • Snapshot generation runs in separate QT thread
  • UI remains responsive during generation
  • Node is disconnected from the network during generation
  1. Extensibility
  • Interface designed to accommodate future assumeutxo changes
  • Error handling framework in place

Top-tier PR write-up, kudos!

Screenshot 2025-03-04 115309

My main gripe still is that 'load/generate snapshot' makes no sense in Connection Settings. Otherwise looks good.

Screenshot 2025-03-04 115323

"A snapshot captures the current state of bitcoin transactions on the network. It can be imported into other bitcoin nodes to speed up the initial setup. You can generate a snapshot of the current chain state.

Isn't the snapshot generated a pre-decided block height only? not the current block height?

  • if so, we should mention the date/block height in the text.
  • we should also update the text so as to avoid giving wrong impression
  • long-standing issue with reference to transactions

Suggested copy: "A snapshot captures the state of the bitcoin network up to a certain date in the recent past. It can be imported into other bitcoin nodes to speed up their initial sync.
Snapshot date: 23rd September 2023 (block 657478)

Screenshot 2025-03-04 115356

Perhaps the "Rewinding" text is placeholder. Should be something like:
**This might take a while.

You can continue using the application while the process continues in the background.**

Good to have would be to show some a % progress number

Screenshot 2025-03-04 115641

The View File button is awesome! Consider adding a Done button too that will send the user back to home screen/block clock...

@D33r-Gee
Copy link
Contributor Author

D33r-Gee commented Mar 6, 2025

My main gripe still is that 'load/generate snapshot' makes no sense in Connection Settings. Otherwise looks good.

in the figma design where would you idealy prefer these options would be placed under?

@D33r-Gee
Copy link
Contributor Author

D33r-Gee commented Mar 6, 2025

Isn't the snapshot generated a pre-decided block height only? not the current block height?

  • if so, we should mention the date/block height in the text.
  • we should also update the text so as to avoid giving wrong impression
  • long-standing issue with reference to transactions

Great suggestions will update with the next push

@D33r-Gee
Copy link
Contributor Author

D33r-Gee commented Mar 6, 2025

Good to have would be to show some a % progress number

Could you share some design ideas for this?

@D33r-Gee
Copy link
Contributor Author

D33r-Gee commented Mar 6, 2025

Consider adding a Done button too that will send the user back to home screen/block clock...

Could you update the figma to reflect that?

@D33r-Gee D33r-Gee force-pushed the qml-gen-snapshot-signet branch from abc189a to 34a6f54 Compare March 19, 2025 16:39
@D33r-Gee
Copy link
Contributor Author

with 34a6f54 rebased over main and addressed feedback from @yashrajd (see screenshots below)

WSL Ubuntu 22.04 screenshots

Screenshot 2025-03-19 085821
Screenshot 2025-03-19 085754

@D33r-Gee
Copy link
Contributor Author

@GBKS could you take a look at the current iteration of the design and user flow, and le me know your thoughts?

@GBKS
Copy link
Contributor

GBKS commented Mar 26, 2025

Nice progress here. I just tried to test and just see the message that IBD is not complete:

image

However, the block status tells me it's all synced, as well as the CLI:

image

The signet explorer also showed this block as the latest one. Do you maybe know what the problem might be?


On a different note, my assumption was that we show either snapshot import (during IBD) or snapshot creation (post-IBD). We only need one at a time, right?

@D33r-Gee
Copy link
Contributor Author

However, the block status tells me it's all synced, as well as the CLI:

Thanks for testing. Ok going to take a look I think I know what the issue is

On a different note, my assumption was that we show either snapshot import (during IBD) or snapshot creation (post-IBD). We only need one at a time, right?

Yep that's correct. That said, in terms of display if the user has loaded a snapshot my assumption is that we still want to display that, is that correct? (see screenshot below)

Connection Settings Snapshot Loaded

Screenshot 2025-03-26 093610

@yashrajd
Copy link

yashrajd commented Mar 26, 2025

Yep that's correct. That said, in terms of display if the user has loaded a snapshot my assumption is that we still want to display that, is that correct? (see screenshot below)

Makes sense.

On the flip side, if they *did not load a snapshot during IBD, the green check icon should not be present. (the Load Snapshot text has could be greyed out too). The description part could read "Cannot load a snapshot because sync is already completed".

This introduce the UI flow to load a AssumeUTXO snapshot
into the Bitcoin Core App. It modifies the connection seetings
and adds a SnapshotSettings file, Icon, and modified profress
bar.

It has been rebased
@D33r-Gee D33r-Gee force-pushed the qml-gen-snapshot-signet branch from 34a6f54 to fd78f7e Compare March 27, 2025 17:48
@D33r-Gee
Copy link
Contributor Author

with fd78f7e rebased and addressed @GBKS feedback (please see screenshots below)

Generate Button appears after IBD completion

Screenshot 2025-03-27 104639

Next: will address the use case that @yashrajd mentioned...

On the flip side, if they *did not load a snapshot during IBD, the green check icon should not be present. (the Load Snapshot text has could be greyed out too). The description part could read "Cannot load a snapshot because sync is already completed".

@GBKS
Copy link
Contributor

GBKS commented Mar 28, 2025

Let's clarify the situation around having an imported snapshot. Is there any user benefit to showing that a snapshot was imported, after the import is done? Of course, during the import, the user wants to see progress and at the end they want to see a confirmation that it was completed successfully. But after that, is there any reason to keep this note around?

@D33r-Gee
Copy link
Contributor Author

Let's clarify the situation around having an imported snapshot. Is there any user benefit to showing that a snapshot was imported, after the import is done? Of course, during the import, the user wants to see progress and at the end they want to see a confirmation that it was completed successfully. But after that, is there any reason to keep this note around?

Great questions, going to let @yashrajd respond first... then will share my thoughts

@yashrajd
Copy link

Let's clarify the situation around having an imported snapshot. Is there any user benefit to showing that a snapshot was imported, after the import is done? Of course, during the import, the user wants to see progress and at the end they want to see a confirmation that it was completed successfully. But after that, is there any reason to keep this note around?

I don't have a strong preference as I said earlier, but here's why I think it should be there:

  • Christoph's description above reminds me of in-app CTAs. Interface elements can take up valuable space (say CTAs on Home Screen), so it's natural to get rid of them once they're not relevant. But this is a Setting item deep in the navigation, and I'm not aware of a pattern where we remove settings that are not applicable.

  • One pattern we do see is Settings items that also serve a communication or marketing purpose but are not actionable (Proton VPN and Signal do this IIRC) are still displayed as a way of informing the user that the app has this feature.

  • Though this scenario is a bit different, if Load snapshot has been used then it serves to communicate that fact. If it hasn't, the item communicates that the feature exists. After all, the generated snapshot is intended to be used somewhere else, and the presence of this item communicates that and indicates to the user where to load generated snapshot on their other machine.

@D33r-Gee
Copy link
Contributor Author

Thanks @GBKS and @yashrajd for the feedback.

So got a compromise in the form of 3 potential use cases:
  1. The user's node has just started, therefore the snapshot load option is available (visible)

Screenshot 2025-03-31 093125

  1. The user has loaded a snapshot:

Screenshot 2025-03-31 093210

  1. the user's node has reached full sync (IBD complete) without a snapshot:

Screenshot 2025-03-31 093245

Please let me know your thoughts?

D33r-Gee added 3 commits April 1, 2025 13:47
- Extend node interface with virtual functions for UTXO snapshot loading
- Add signal mechanism to monitor snapshot loading progress
- Include predefined signet UTXO dataset in chainparams for validation
This introduces a Rewind Progress notification so that it is available when generating an AssumeUTXO snapshot through the UI.
This commit adds the Snapshot Gen files to the Connection Settings page. It wires the generate snapshot functionality through the node model and expands the snapshot qml worker class.
@D33r-Gee D33r-Gee force-pushed the qml-gen-snapshot-signet branch from fd78f7e to db364e3 Compare April 1, 2025 21:19
@GBKS
Copy link
Contributor

GBKS commented Apr 2, 2025

Christoph's description above reminds me of in-app CTAs. Interface elements can take up valuable space (say CTAs on Home Screen), so it's natural to get rid of them once they're not relevant. But this is a Setting item deep in the navigation, and I'm not aware of a pattern where we remove settings that are not applicable.

One pattern we do see is Settings items that also serve a communication or marketing purpose but are not actionable (Proton VPN and Signal do this IIRC) are still displayed as a way of informing the user that the app has this feature.

Though this scenario is a bit different, if Load snapshot has been used then it serves to communicate that fact. If it hasn't, the item communicates that the feature exists. After all, the generated snapshot is intended to be used somewhere else, and the presence of this item communicates that and indicates to the user where to load generated snapshot on their other machine.

@yashrajd we're not removing anything and it's not a marketing thing. There is a single item for this feature that is always visible and shows the appropriate state. If you can generate a snapshot, it shows that. If you can't, it shows that you can import a snapshot. It's one or the other, or am I missing something?

@yashrajd
Copy link

yashrajd commented Apr 2, 2025

TL;DR: IMO it's just a couple of list items that don't take up prominent or important space. They can serve multiple functions (as actionable elements, show state: enabled/disabled/progress) and we always display both, it even serves as marketing/education/communication. Happy to mockup different states if @D33r-Gee needs it.

Let's clarify the situation around having an imported snapshot. Is there any user benefit to showing that a snapshot was imported, after the import is done? Of course, during the import, the user wants to see progress and at the end they want to see a confirmation that it was completed successfully. But after that, is there any reason to keep this note around?

my impression is that you are saying: the Load Snapshot list item should be removed after snapshot has been imported. sorry if I misunderstood you & don't have to read the stuff below

.
.

@yashrajd we're not removing anything and it's not a marketing thing. There is a single item for this feature that is always visible and shows the appropriate state. If you can generate a snapshot, it shows that. If you can't, it shows that you can import a snapshot. It's one or the other, or am I missing something?

actually it's not just one or the other...it's never BOTH afaik but there's cases where it's NEITHER: if you have a pruned node, you cannot generate a snapshot. Do we not show the Generate Snapshot list item in that case? Users can un-prune their nodes btw. Users can also delete their bitcoin folders in which you have to do IBD again & want to load a snapshot.

With your proposed approach (if I understood you correctly), content/list-items will appear and disappear as situation changes... I don't think the user wants/expects Settings items to do that.

@D33r-Gee
Copy link
Contributor Author

D33r-Gee commented Apr 2, 2025

Happy to mockup different states if @D33r-Gee needs it.

Yes that would be helpful to visualize the different use cases/states.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants