mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:12:38 +00:00
Wiring for Custom Datadir #408
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!408
Loading…
Reference in a new issue
No description provided.
Delete branch "qml-datadir-custom-wiring"
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?
This pull request builds upon previous issues (#390, #392, and #397) by re-introducing the functionality for users to specify a custom data directory (
datadir) during the onboarding process.The majority of changes in
qml/bitcoin.cppare mainly splitting the onboarding and node creation so that the user can set their preferreddatatdirit's inspired by theqt/bitcoin.cpphowever it uses the anonymous namespace instead of using a class. The intention came from feedback on https://github.com/bitcoin-core/gui-qml/pull/390In the QML pages, the
node_modelcontext property is no longer been initialized during onboarding. We're now usingoptions_modelinstead. This means the code has been updated to use theoptions_modelfor settings that were previously set with thenode_modelcontext property.Support for the Android version is being added to this PR.
https://github.com/bitcoin-core/gui-qml/actions/runs/9523738145/job/26255610402?pr=408
Android builds are failing. Will need that fixed.
My testing on desktop seemed to work well. I had one odd thing happening. After onboarding, I tried again with using -resetguisettings and the onboarding page had a strange Custom path as the initial selection. I imagine this is maybe just resetguisettings not clearing out the datadir in QSettings but haven't dug in yet.
Thanks @johnny9 for testing
addressed it for now with the latest push 679818a
Addressed the above for now... although there are a few issues when using the -resetguisettings flag, so a question I have is is it crucial to address them here or can they be addressed in later PRs that specifically tackle them?
679818a1d289f7d76f463b6deb13dd1c828eb486
Custom datadirit gives this output in terminalsome are defined but not used
and give compile warning
qrc:/qml/components/StorageLocations.qml:19:5: QML OptionButton: Binding loop detected for property "customDir"select custom datadir -> select default -> select custom datadir -> default keeps being selected in GUI
Thanks testing and reviewing @MarnixCroes
Hmmm... not sure what that is... will look into it
Yes some refinement can be done there... will look into how best approach it
Currently tackling a strange beahvior involving the custom
datadirand reading the settings files:when going through first setup it up it works great and the
settings.jsonfile is created in the the proper place...However on restart it seems like it doesn't read the
settings.jsonfile from the newdatadirand only looks in the default directory.Right now trying to see how that can be addressed... will update soon with what I find
with aebfc89 addressed the
settings.jsonfile not being read on restart by moving thegArgs.ReadSettingsFileright before node creation inqml/bitcoin.cppNow will tackle the
-resetguisettingsnot updating thedatadirlocation right awaywith the latest update 5ef5d19 addressed the
-resetguisettingsdiscrepencies.It now resets to defaults and allows for changing the
datadirNext will tackle code optimization...
This update 6d4c111 is the first pass at optimizing the qml/bitcoin.cpp code.
There are no major functionality updates, mainly code consolidation.
done! Used new function to mitigate "default reset" issues
Thanks for catching those!
removed unused member variables...
@MarnixCroes are you still seeing the above pop-up with 6d4c111?
tACK 6d4c111c4028525a4071cf03f6d73c8b2e579b8f
Normal use case, running
bitcoin-qtand setting the custom data dir in one go, works as expected.A use case that has an issue I think, which is selecting a custom datadir, going back to the default, I can't manage to set a custom datadir back, the default remains selected and this is working in
main.I got this crash (not always but quite common) when I click on the "Custom" component:
To reproduce it delete any
settings.jsonand any "BitcoinCore-App*.conf" inhome/.config/BitcoinCore.Code-wise I need more time to check the changes, especially the last commit, cannot be split? It would be useful to add a brief description of the intention, what's the intention of the changes in the protocol of
bitcoin.cpp(re-structuring it for clarity? something was missing/ needed?).On the first commit, the commit name doesn't explain much either (eg , it seems there's a refactoring within, what's the motivation behind making node a pointer instead of a reference? If you check the code in core/ qt it's always defined as &. Is there an issue you are trying to solve or just syntax or semantic?).
Every commit should pass compilation and all tests so if the failure occurs on the previous commit you should include it there (we are missing the "
CI / test each commit (pull_request)" that exists on the other repos and I think @hebasto has it pending with other things he wanted to merge here into this repo).Why not delete it?
I do not
this is still an issue
(6d4c111c4028525a4071cf03f6d73c8b2e579b8f)
Thanks @pablomartin4btc for testing and for your questions.
The majority of changes in qml/bitcoin.cpp are mainly splitting the onboarding and node creation so that the user can set their preferred
datatdirit's inspired by the qt/bitcoin.cpp however it uses the anonymous namespace instead of using a class. The intention came from feedback on #390I'm assuming you are referencing:
github.com/bitcoin-core/gui-qml@f3b8c5a625/src/qml/models/options_model.cpp (L27)if so the logic there came from having to initiate the
options_modelinqml/bitcoin.cppwith the node as anullptr. And this was a way for it to work with the least amount of changes.Yes in
qt/bitcoin.cppthe OptionsModel is initiated through a reference because node creation doesn't happen until the splashscreen/intro have gone through and no settings are being set with the OptionsModel.On the other hand in
qml/bitcoin.cpptheoptions_modelis needed for onboarding so initiating it with anullptris allowing the QML context property to be set withoutNodeinitiation.left in case there's another way... removing it on the next push
Thanks for checking this... The issue is now addressed in 7a34b0d
commented out sections are now deleted with 7a34b0d
7a34b0da39c0fe63b56981787a8177f492febd1a
did some manual testing, so far works ok
some commits could be squashed imo, also as Pablo mentioned here https://github.com/bitcoin-core/gui-qml/pull/408#discussion_r1658350670
what's your idea behind commenting them out, instead of removing?
also at other places
they could be removed as you already did at few other places
what's up with this?
Thanks @MarnixCroes for testing and @hebasto for the comments.
Will update once more with cleaner and clearer commits...
Also working on the Android version... Found a workaround for QSettings not working with Android, will post Android related commits soon...
removed with latest push
removed it with latest update
This update 2cf64dd introduces Android functionality by creating qml/androidcustomdatadir files. This allows the app to retrieve the custom data directory path, if previously set by the user.
statically defining all of these pointers is concerning. Eventhough it is redundant it feels safer to keep a lot of these withing the function scopes.
Ok thanks for looking into it... will refactor further to use arguments instead of pointers
After our online chat, let's keep things as is with the caveat that if any issues arise due to the static pointers we'll have to refactor further. Resolving for now...
tACK 2cf64dd91420b6b18af3af14f249956b2e4167ee
Onboarded with a custom directory, started IBD, then restarted the application to make sure the application continued to use the custom directory. Worked on both Linux Desktop and Android.
The https://github.com/bitcoin-core/gui-qml/pull/408/files#r1658350670 still needs to be addressed.
Why this change is required? Is it safe?
Comments like that seem add no value. However, this sentence is more suitable for a commit message.
Could the main points from that discussion be posted here?
Comments like that seem add no value. However, this sentence is more suitable for a commit message.
To summarize our convo: We talked about the safety of static pointers in the code. We thought about adding a class like in #390, however decided to leave them for now, since there might be issues raised by @Jarold that we need to consider first. That said we both agreed that having a clear owner for pointers is usually a good idea for better code management. Is there anything I missed @johnny9 ?
Looking into it...
With the latest push 28ab2a0 reverted the
AppModedefinition inqml/bitcoin.cppto the original. Also cleaned out comments based on @hebasto feedback.Thanks for catching that, no it is not safe! While refactoring ran into some compiling errors and thought (mistakenly) that turning
AppModeinto a pointer would be the way to go. That’s not necessary so reverting back to the original definition.Removed. Thanks for pointing that out.
Also removed. Thanks for pointing it out.
28ab2a0a06571f4ec500fa500ec0cab738dd0694
Data Directoryindicated in the GUI can be different from the actual used data direcory: run with resetguisettings -> select custom data dir -> let it create some of the files (don't have to finish IBD) -> shutdown -> delete the data (not the dir) -> launch app again (without resetguisettings) -> it uses the previous data dir (as supposed to) but in the Storage Settings it indicates it is using the default data dir which is inccorect as it is not using this.I did not delete any files, just ran and clicked on the
CustomThanks @MarnixCroes for testing and discovering:
I've addressed it for both desktop (tested on Ubuntu 22.04) and Android with the latest push 834d8ac
Now the address persist even in the case of data deletion and not not the directory.
haven't been able to repro will investigate further...
with the latest push b67ae97 got rid off the check mark happening when clicking the
custombutton inStorageLocations.qml@MarnixCroes please let me know if that fixes the
GTKcrash issue?I can still repro it on b67ae97f5091726db2694d591ffb342db8ebcd1a
b67ae97f5091726db2694d591ffb342db8ebcd1a
the Data Directory in the GUI is also incorrect (displays the default one) when user runs with -datadir start up param
nit
or maybe even
2023-present, which seems to be used in the main repo now.Ah that's a great find... hadn't tested that... ok will update
good catch...
updated to 94215e5 it now displays the proper
datadirwhen using the-datadirargok that's a bummer... will keep investigating although it's difficult to know since I'm not able to repro... will ask around
@MarnixCroes RE: the GTK crash, are you using the depends (static build) or are you using dynamic to compile?
yes using the depends
(Pablo also encountered it earlier https://github.com/bitcoin-core/gui-qml/pull/408#pullrequestreview-2146000827)
ok when you run
dpkg -l "*gtk*" | grep iido you get this :ii qt5-gtk-platformtheme:amd64 5.15.3+dfsg-2ubuntu0.2 amd64 Qt 5 GTK+ 3 platform theme?yes
Please rebase to resolve conflicts.
rebased over main with 8d53c44
tested out on WSL Ubuntu 22.04 however didn't tested out on Android...
comment could be more general, without the "moved this"
same as https://github.com/bitcoin-core/gui-qml/pull/408#discussion_r1675628865
8d53c44ad99c7844762dde5caf3aba03339bb8f4
apart from the know crash issue (which happens occasionally) the previous issues are fixed and it works as expected.
commit history could still be improved (commits like https://github.com/bitcoin-core/gui-qml/pull/408/commits/c1067d10740fd4c3fbba89445bcfd129893e3c0b) which was also previously mentioned https://github.com/bitcoin-core/gui-qml/pull/408/commits/c1067d10740fd4c3fbba89445bcfd129893e3c0b#r1658350670
makes sense
rebased over main with 370bc64
Addressed @MarnixCroes comment.
Tested on both Ubuntu 22.04 and Android
ACK 370bc643be09c49a945eed3ca13e792cfafb385e
tested the flow on Desktop and Android and both worked as expected without any crashing.
Desktop


Android:


tested
d76761d306on Ubuntu 22.04.I found a few inconsistencies regarding the commits structure:
fullClientVersionfrom the node model but you didn't update the reference until the next commit.src/qml/androidcustomdatadir.cppthat is being added 2 commits later. Commit "android: permissions for custom datadir" is not for custom datadir specific but for android "external" storage in general.I think the PR should have 4 commits in total (maybe 5 if you want to have the android storage permission one separate).
Regarding the UI and the wiring/ persistence of the datadir configuration, it works as expected. As I mentioned in the UI only PR earlier, we need to think about the different chain-nets or when user specify -datadir, perhaps this is more related with the onboarding, do we need to trigger the onboarding if it's the first time on those situations?
Somehow I got different numbers in the storage estimation:
As it can be seen as well, regarding the Gtk error, this time didn't crash but it appears after the 6th time of
bitcoin-qtexecution.(bitcoin-qt:276616): Gtk-CRITICAL **: 23:44:35.670: gtk_image_set_from_gicon: assertion 'GTK_IS_IMAGE (image)' failedThis is happening when the file dialog pops up, started to happen in the UI only PR #397.
Please try to re-org the commits, let me know if you need any help on this, so I can do another code review ASAP and we can merge this as I also need to touch the options model, onboarding and
bitcoin.cpp.Thanks @johnny9, @MarnixCroes, @pablomartin4btc and @hebasto for testing and reviewing this PR.
@pablomartin4btc , thanks for pointing the commit inconsistencies I will keep your feedback in mind as I publish future PRs.
After speaking with @jarolrod it is now clear that the code is not up to par (to put it politely).
I am closing it, so I can focus on AssumeUTXO integration, however I opened issue #426 so whoever takes it on can learn from my mistakes.