mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:12:38 +00:00
QML Load Snapshot Signet (160,000 height) #424
No reviewers
Labels
No labels
Android
Bug
Build system
Design suggestion
Doc
Needs design review
Needs rebase
Stage
UX
Up for grabs
Upstream
Wallet
duplicate
enhancement
good first issue
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml!424
Loading…
Reference in a new issue
No description provided.
Delete branch "qml-load-snapshot-signet"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Open for review and testing only. Do not merge!
GUI Integration for UTXO Snapshot Loading
Overview
This PR adds initial GUI support for loading a
signetUTXO snapshot at height 160,000, building on Bitcoin Core'sassumeutxoinfrastructure.What This PR Does
Implementation Details
Core Components Modified
src/node/interfaces.cpp)snapshotLoad()based on theloadtxoutsetRPCsrc/qml/models/nodemodel.cpp)src/qml/components/SnapshotSettings.qml)Key Design Decisions
assumeutxochangesTesting Instructions
Ubuntu 22.04 Screenshots
Expected Behavior
Future Work
assumeutxochangestestnetandmainnet)Notes for Reviewers
Snapshot Compatibility
signetUTXO snapshotm_assumeutxo_data(the changes there can be discarded once synced since
m_assumeutxo_datais already hardcoded)feedback welcome on the approach and implementation details.
With cb409e3 rebased and got rid off the extra options_mode settings which are not relevant for this evaluation.
Also deleted the extra loadsnapshot.cpp file and instead added the load snapshot function in src/node/interfaces.cpp
Should I be getting a binary specific for this issue? I tried loading a signet snapshot into the one for #421 but was unable to...
Yes please download the artifact for your system here
That's correct behaviour, 421 is UI only and doesn't not have backend wiring
With b77f7c1 minor tweaks to the src/node/interfaces.cpp snapshotload() function.
It mimics the rpc call loadtxoutset from bitcoin/bitcoin repository
Next will connect the loading to the progress bar
with c59e557 Integrated the UI with the C++ backend, implementing a progress callback function to dynamically update the loading progress based on the number of coins processed.
Touched src/validation.h and src/validation.cpp to extract the coin loading progress.
Next: will update the "Loaded Snapshot" stack with the real info from the snapshot
With e3f8c70 moved the load snapshot functionality from nodeModel to optionsModel since it make it easier to store the snapshot info and reduces redundant variable declarations.
e3f8c70 is a regression because optionsmodel is not an appropriate place for this, and we are now violating the role of settings.json to store the state of a process.
NodeModel and AppMode are more appropriate places for this information. But the entire approach here is still a concept NACK as we are performing unecessary changes to validation and chainparams.
nothing related to assumeutxo should be in the optionsmodel, the optionsmodel is a backend model to simply expose to the GUI the current value or state of options that exist in or are overriden in:
The optionsmodel is not a place to put computation or to represent any ApplicationMode states, only the configuration options for Core.
Although not relevant here, you can get caught up on these config options by reading this file, or the qt widgets optionsmodel, or running the conf generation script.
This would be polluting settings.json that stores read/write configuration options for core -> with a state of a process. We cannot do this.
Ok I tested artefact#235 and functionality & UI seems to work.
Didn't see block clock so couldn't verify easily. Adding some UI feedback below:
Thanks for taking a look at this and for the guidance regarding what can go into the optionsmodel.
It has been address with 90dc0dd
Makes sense, although I have a question for when we would want to allow the user to load a snapshot during onboarding, could the snapshot file path be stored in the settings.json?
with 90dc0dd rebased over main and addressed @jarolrod concerns by reverting back to just a minimal integration of the loading snapshot functionality.
@yashrajd I will address the UI issues next
As a follow up will investigate how to access the snapshot verification progress
Also looking into how to make the snapshot data persist and be available for display (i.e. snapshot block height, date, and merkle hash)
For the chainparams the changes there are only temporary for evaluating and testing within this repo. I checked upstream and the signet snapshot has already been hardcoded so once our repo is synced the changes in chainparams.cpp can be discarded.
with 85592f5 made the snapshot activation persist on node restart by making use of the interface with chain->hasAssumedValidChain
Also changed the green-check icon size to 30 pix
Next looking into how to extract the progress from the ActivateSnapshot process
with 955c65d modified the snapshotLoad() function in src/node/interfaces.cpp and the initializeSnapshot() function in nodemodel.cpp to extract progress information using regular expressions.
This design decision aimed to keep snapshot loading mechanisms self-contained.
However, it looks like the use of
std::stodis triggering some lint failures... will look into how to address that.Perhaps the way to go is to use the handler in src/node/interfaces_ui ... will explore that path then update
with 0eba513 reverted back to minimal snapshot load functionality.
Snapshot loading progress is still not were I want it to be so in the meantime replaced the progress bar with placeholder text.
Also updated the snapshot info display. once successfully loaded, and I'm using the hardcoded info in
chainparamssince if the snapshot has loaded successfully it means the info there has been validated.This is make the info persistent and not rely on the
snapshot.datfile (in case it gets deleted)With cd2ec69 added a section to keep track of snapshot loading, it is not ideal so will look for better ways to achieve it.
Since the core functionality is there will ask for "pre-reviews" before un-drafting
We can't introduce any javascript functions
Can you write documentation on what we test in this PR? How we know a snapshot loaded, how we know that anything is working?
yep will do
Ah ok going to use signals and connections instead
ok added documentation commnents for testing
using nodeModel member variable so that snapshotLoading persist while navigating away from settings page.
with 5d0756c updated
SnapshotSettings.qmlwith comments documenting the loading process.with 262bb03 updated
nodemodelby adding them_snapshot_loadingbool so that the "Snapshot Loading" page persist if the user navigates away from it.Next looking into how to finesse the snapshot loading progress...
with a6bede5 removed comments from
SnapshotSettings.qmldeleted documentation comments and instead update the PR description
with 799b4cd updated
SnapshotSettings.qmlby deleting comments and adding more properties tofiledialog.Also wanted to see if the Win64 CI completed successfully, which it did.
Next will ask for feedback before un-drafting
with 5d2ffb0 updated snapshotLoad() in src/node/interfaces.cpp. Left the polling loop for now as I investigate how to handle loading the snapshot if Pre-syncing and Syncing headers is still happening.
Also removed JS functions and moved the logic to the nodemodel
8beb50a rebased over main
8beb50ab504c6a76daf2b164d6786c2bafa6cba3: the signet snapshot was merged into Bitcoin Core more than a year ago in
github.com/bitcoin/bitcoin@edbed31066. This also seems to be using the older serialization format from before https://github.com/bitcoin/bitcoin/pull/29612.I guess that's all fine for a proof of concept, but it would be better if the main branch of this repo was more up to date.
Hi Sjors! Thanks for taking a look and yes completely agree with:
We are currently taking steps to sync with upstream, meanwhile I wanted to get the ball rolling, although I will pull in the update versions of the assume utxo functionality so that when the sync happens this PR can be merged with minimal refactoring.
A handler similar to handleNotifyBlockTip will be needed to so the UI interface can be event driven instead of polling the interfaces module.
We shouldn't have a blocking component here. If there are any issues we should just fail.
I imagine the actual progress should be owned by the object in charge of doing the processing. ChainStateManager?
Another thing you could do is look into making a PR to the Bitcoin Core repo with your proposed interface changes. One way to go about that is to somehow use them in existing or a new RPC method. E.g. snapshot load progress is probably useful to have available.
It's not really "transactions up to", it's all coins (utxo set) that exist at the snapshot height.
Maybe say something like:
(intentionally leaves it vague what's in the snapshot)
Great suggestion! I will run by the designers...
@yashrajd @GBKS what are your thoughts on the suggestion? Does it make sense?
Yes! Will set it up so that the handler notifies the snapshot progress and that ownership belongs to ChainstateManager.
That's the current medium term plan, once we have an implementation that works and makes sense here we plan to go upstream (bitcoin/bitcoin) and open a PR there.
In the sequence, this is the fourth snapshot-related screen (state) people see:
I think the point that not all historical transactions are in the snapshot is worth clarifying. The first time people are exposed to what this feature does is in 2, so I'd probably start tweaking at that point. We call it a "recent transaction snapshot" there, which is more precise than just "transactions" ("unspent transaction snapshot" would be a little closer).
We don't need to be 100% technically accurate and I'm not sure users are well-served if we're completely vague about this either. They should be able to form a good enough mental model for making decisions and understanding their impact.
So how about this?
Or this?
Either way, we should ensure to tweak the text across the sequence if we make changes here.
We show the block height in a "View details" option below (did not check if it's implemented in this PR already), so not sure whether we need to include that in the text as well.
As for what happens next, my thinking was that we just say that the data will be filled in and verified here (keep it short), and then have indicators contextually in the UI as to what is happening (balance, send and transaction list have respective load states). So less absorption of logic here, and more contextual info in the appropriate places.
Sorry, this has gotten quite long. Hope it's a helpful response.
I think it's better to be incomplete than incorrect. The nice thing about being vague is that it's clear to the reader there's more to learn.
One reason the phrasing "recent / historical transactions" is potentially confusing is that people may think they can recover historical wallet transactions with it. But it has nothing to do with that.
The concept that's useful to explain is that the snapshot allows us to start syncing at block %1, saving time by skipping historical blocks. This way the user can get started (with their wallet) earlier. Meanwhile it's safe, because we do check those historical blocks in the background later.
TL;DR I reviewed the onboarding text again, and it seems like the use of
transactionsterminology in the snapshot section provides context continuity with what's said before...see screenshot below.Unless we come up with something better, I'd be fine with retaining what we have currently though I agree it's inaccurate. Suggestions below:
It does seem like we can strike a better balance between technical accuracy & usefulness to user here, and use vagueness where required.
Agree, this was in the initial mockups I did. edit: removed something here. read on...
Agree.
This screen can omit mention of transactions "The snapshot allows you to start using the application more quickly. Once loaded, it will be automatically verified in the background. Learn more" instead of "You can start using the application more quickly by loading a recent transaction snapshot. It will be automatically verified in the background."
I'd suggest something like "The loaded snapshot contains data up to [some date]. The initial download will continue now. The snapshot is verified in the background." instead of "It contains transactions up to September 10, 2023. Newer transactions still need to be downloaded. The data will be verified in the background."
edit: rephrased my own suggestion slightly.
Should we move this conversation into a separate issue? It's just about text details, and maybe we don't want to weigh down the overall technical development of this feature? Text is easy to replace separately.
@GBKS that makes sense.
Issue created. Let's continue there.
with eb923ff:
Introduced a handler to keep track of the snapshot loading progress
it utilizes the notifications framework, this displays in the GUI as a progress indicator.
Added a worker class in
nodemodelto handle the processing of the snapshot file (i.e. metadata)Got rid of the blocking
forloop that was waiting for the corresponding block header.If the block header is not found the loading just fails and allows the user to wait a try again later.
TODO: in a follow up PR, add error handling and messaging to the user when loading fails.
With 68efab5 this PR is ready to transition from draft status.
The changes are separated into two distinct commits:
Core functionality changes intended for upstream integration into bitcoin/bitcoin (bd0f1204a2057764813f1f63621fde92f32c5c0a)
QML-specific implementations and adaptations (68efab582385135d37e0a79c87d8bd43dfccc37f)
109cf42 rebased over main
with cad966e rebased over main.
Keeping this PR as draft until we get closer to the sync with upstream...
with 6c25cd7 :
Will keep this as draft until we get closer to the sync with upstream
4e43df9 updates the following:
Once the CI completes will undraft since we are not exactly sure when the sync with upstream will happen. And this feature will be demoed at upcoming events.
Feedback welcomed!
will follow up on this in another PR
Opened https://github.com/bitcoin-core/gui/pull/870 as a draft based on this exchange...
Will open a PR in
bitcoin/bitcoinwhen appropriate...I believe this is resolved with 4e43df9
Is this correct @yashrajd and/or @GBKS ?
With bbbbf42 adds error page to handle when a invalid snapshot gets used, this is based on @GBKS feedback in #449
Feedback welcomed!
This is confusing, given that #421 is closed.
e02f382 rebased over main
friendly ping @yashrajd and @johnny9
with d2fccc4 rebased over main
I will try to test this today.
ok I just tested the latest build on signet...following are observations:
tl;dr – snapshot loading worked!
(but shown hash doesn't seem to match file hash from terminal (but maybe I'm barking up the wrong tree)
Did I test it right? Did I miss something I should've tested...lemme know.
Thanks @yashrajd for the attached screenshot showing the two different hashes associated with the loaded UTXO snapshot.
I’d like to clarify the distinction between them to help avoid any confusion:
SHA-256 Hash of the Snapshot Data File
This hash is generated by running a command such as
shasum -a 256 utxo-signet-160000.datdirectly on the snapshot file.Example from the image:
It represents a checksum of the full file contents and is typically used to verify file integrity during download or transfer.
Hash Displayed in the Application (Snapshot Metadata Hash)
5225141cb62dee63ab3be95f9b03d60801f264010b1816d4bd00618b2736e7be) is not the SHA-256 of the file itself.hash_serializedfunction after parsing the file.AssumeutxoHashinchainparams.cppandExpectedAssumeutxoinvalidation.cpp.I hope this helps clarify the purpose and origin of each hash. Please let me know if the above makes sense?
Here's some TLDR answers to @yashrajd experience (let me know if you'd like more details) Also let me know if the descrepency between estimated percentage is something to address from a UX perspective, something to consider messaging the user on initial snapshot load:
Initial snapshot load: Progress is calculated from the snapshot point, so it looks high.
After restart: Progress is recalculated from the beginning of the chain, so it drops.
This is expected behavior and will resolve itself as the node downloads and verifies the missing historical blocks.
yes for this PR this is the expected behavior, in #446 instead of just disappearing it will be replaced by
generate snapshotoptionYes! Thank you for testing and highlighting potential UX issues. Please let me know if there are any design adjustments that should be tracked (i.e. notify the user that the high progress number is only because they are in snapshot mode)
Thanks for the clarification on the hash mismatch @D33r-Gee that's very helpful. Also thanks for explaining the block status widget behaviour, though I need to read it again.
We anticipated the adverse impact on the block status widget in the early stages, and I do think this is something that needs to be addressed. We already have a design issue for this. @GBKS I think it is time work on this if you agree. It might be a good idea to jump on a call to understand this better... Gee do you think that part has a direct bearing on the contents of this PR, which seems to be limited to the Load snapshot functionality?
@yashrajd thanks for testing this one. The percentage display topic seems like a good thing to tackle in a separate PR.
with 508b486 rebased over main
Closing for now.
Feel free to reopen this based on the new default branch.