No Branch/Tag Specified
chat
custom_themes
danger
dev
duke
importviewkey
master
no_mining_until_synced
old_duke
onryo
recurring
0.4.0
0.4.1
0.4.2
0.4.3
0.5.0
0.5.1
0.5.10
0.5.11
0.5.3
0.5.4
0.5.5
0.6.0
0.6.1
0.6.10
0.6.11
0.6.2
0.6.3
0.6.4
0.6.5
0.6.6
0.6.7
0.6.8
0.6.9
0.7.0
0.7.1
0.7.2
0.7.3
0.7.4
0.7.5
0.7.6
0.7.7
0.7.9
1.4.2
v0.1.5
v0.1.6
v0.1.7
v0.1.8
v0.1.9
v0.2.0
v0.2.1
v0.2.2
v0.2.3
v0.2.4
v0.2.5
v0.2.6
v0.2.7
v0.2.8
v0.2.9
v0.3.0
v0.3.1
v0.3.2
v0.5.2
v0.5.6
v0.5.7
v0.5.8
v0.5.9
v0.7.5
v0.7.6
v0.7.7
v0.7.8
v0.8.0
v0.8.1
v0.8.2
v0.8.3
v0.9.0
v0.9.1
v0.9.2
v1.0.0
v1.1.0
v1.2.0
v1.3.0
v1.3.1
v1.4.0
v1.4.1
v1.4.2
Labels
bounty up to 500 HUSH 2001-5000 bounty
bounty between 2001 and 5000 HUSH 501-2000 bounty
bounty between 501 and 2000 HUSH arm
something doesn't work on arm beginners
for new developers bug
may or may not be a bug build
problems building documentation
not enough information feature
new feature high priority
high priority i2p
related to i2p low priority
low priority medium priority
medium priority question
something is not clear release
release label or issue related to it tor
related to tor translation
translation update windows
related to windows wontfix
this won't be fixed
Apply labels
Clear labels
0-500 bounty
bounty up to 500 HUSH 2001-5000 bounty
bounty between 2001 and 5000 HUSH 501-2000 bounty
bounty between 501 and 2000 HUSH arm
something doesn't work on arm beginners
for new developers bug
may or may not be a bug build
problems building documentation
not enough information feature
new feature high priority
high priority i2p
related to i2p low priority
low priority medium priority
medium priority question
something is not clear release
release label or issue related to it tor
related to tor translation
translation update windows
related to windows wontfix
this won't be fixed
No Label
0-500 bounty
2001-5000 bounty
501-2000 bounty
arm
beginners
bug
build
documentation
feature
high priority
i2p
low priority
medium priority
question
release
tor
translation
windows
wontfix
Milestone
Set milestone
Clear milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
Assign users
Clear assignees
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.
No due date set.
Dependencies
This issue currently doesn't have any dependencies.
Reference in new issue
There is no content yet.
Delete Branch '%!s(MISSING)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
No
Yes
The current rescan functionality of SD was inherited from ZecWallet and ZEC, which did not have a rescan RPC. Now that Hush has a rescan RPC, we don't need to restart the node and write rescan=1 to the config file, then remove it.
The code to do a full rescan should use the rescan RPC with optional height parameter.
I am looking at this now. Planning to replace the rescan checkbox under the current troubleshooting settings with a button that opens dialog for block height. Let me know if you were thinking something different.
I have some UI for this but when I tried calling
rescan
RPC it gave this error:JSON value is not an integer as expected
This is what it logs for request:
RPC: "rescan" QJsonValue(object, QJsonObject({"id":"42","jsonrpc":"1.0","method":"rescan","params":["1109400"]}))
I am passing an integer that's 1109400 in this example. I had to add another
makePayload
that accepts integer instead of string so it's not wrapped in quotes.It seems to work and starts scanning at submitted blockheight but I need to look into how to update the progress while it's rescanning. You can see it rescanning in log and restarting SD will keep splash screen open with no indication of rescanning like #87 Taking break for now.
@fekt just to be sure, are you using hushd 3.9.2 in this example? Older hushd's have a bug where rescanning from a height doesn't work. You also sometimes need to deal with issues where something is a string in JSON but hush-cli wants integers.
As for keeping progress updated, the
rescan
RPC gives no progress updates, the only way to tell is for us to look at debug.log and extract the info from there.Yes, 3.9.2. hush-cli seems to complain about the height being wrapped in quotes from payload. Adding payload that accepts integer and doesn't wrap in quotes works but let me know if doing it wrong. Latest commit has changes for this.
I am looking into QFileSystemWatcher or something else to read debug.log when it changes. Rescan appears to work and I'll see something like this in debug.log:
Specifying an older height does the same, but takes longer and will have something like:
2022-10-09 15:04:15 Still rescanning. At block 802930. Progress=0.589521
So need something that reads the file and sees rescanning starting and keeps checking and displaying progress until it sees it's done.
@fekt yes, making a new makePayload() variant sounds like the right way to do it.
And yes, the best/only way to do what we want is I think to read lines of debug.log that match a regex (QT has them) and then extract the "at block XXX, progress=yyy" data and render that to the user
I am going to try and work on this more late tonight or over the weekend. Do you think it makes most sense to display splash screen that can't be closed for this showing progress or where would you want progress to show? Another option is status bar in lower left, but if wallet is doing anything else, the status may change to something else. If still rescanning it'll probably show again on next progress check though.
I was seeing some different behavior on testing rescans too and not sure if reproducible. If you restart the wallet or maybe kill hushd, it might force a rescan from height 0. Possibly weird stuff with deletetx and zsweep or other RPCs still running too. After one rescan supposedly finished, I was only seeing some weird txs for mining. They were showing an address I hadn't used for some time but saying the rewards were for yesterday. Another rescan from a height before then did fix it and I disabled deletetx before running it again.
On the splash screen when restarting before a rescan finished, I'd sometimes see nothing like #87 while other times it would say "Rescanning". I need to look into what determines if the text is set or not when rescanning. I know there is a check to display "popcorn" message or not.
@fekt really good question. Here is my idea:
@fekt as for the bugs with killing
hushd
, they are somewhat expected. C++ destructors and cleanup code are not executed when you kill a process withkill -9
or hit a coredump or similar. So if an async zaddr operation was running (like z_sweep or z_sendmany or z_migratetoaddress), it either marked a zutxo as spent when it isn't, or vice versa. This is because the process might have exited before writing data to wallet.dat and then gets out of sync with the network. Rescanning from a height before the loss of syncedness fixes the problem. As for deletetx, it does a lot of wallet.dat writing, so it has a similar issue@fekt just to explain a bit more about why I suggest stopping all the polling functions during a rescan: Just about every RPC will "hang" and wait for a rescan to complete before returning data, and will almost always timeout. So running RPC's during a rescan just wastes resources and could lead to rare bugs if too many RPC's queue up waiting on each other. We had issues with that a long time ago which is why we increased our RPC queue max depth. It's much better to just not run them at all during a rescan and it's more performant for users.
@fekt one more thing to mention is that the
rescan
RPC was fixed in the 3.6.1 release. I found this out by runninggit log -S rescan -p src/rpc/
and finding the commit id of it being fixed, which is cff8d114eaeab5ab0ae97ef1eae912c7b8bcbb9e and then doinggit describe cff8d114eaeab5ab0ae97ef1eae912c7b8bcbb9e
which returnsv3.6.0-380-gcff8d114e
which meansthis commit is 380 commits past git tag v3.8.0 in the git commit starting with cff8d
. The letterg
is not a valid hex character, and denotes that what is after it is a shortened commit id.I think it's reasonable to not support older hushd's that do not support the fixed
rescan
RPC (which are 2+ years old), but also it's pretty simple to see thatrescan HEIGHT
returns an error immediately and then use the old way of doing things. I am fine with with either way. If we choose not to support hushd 3.6.0 and older, we should remove all the SD code that doesrescan
the old way and document in release notes that SD requires hushd 3.6.1 or higher.@duke I like your idea and stopping all other functions from polling makes sense. I'm just not sure how easy it is to implement a read only mode without potentially breaking things or causing unexpected behavior since I don't know all the code.
I have code for reading debug.log and showing percent status and height in splash screen. It is more for fixing #87 and showing rescan progress on a restart but can be adapted. I have been testing by submitting height to rescan at and then restarting SD. It works, but it's probably not the best implementation for processing the file and has some issues.
Related to other things polling, it causes issues with reading debug.log to grep rescan data due to those functions writing to the log. On an SD restart that is still rescanning, there is something that keeps trying to connect while rescanning and keeps logging connection errors. On another system, if I start the rescan in SD, then close SD and never restart, hushd will still run while rescanning, but only log rescan data lines.
I am trying to read as little of the log as possible to grab next rescan data. The issue with this is if I don't look at enough data, what I'm looking at may contain nothing related to rescanning. If I look at too much data, then it's going to potentially match an older line in log and not necessarily show the latest progress until log is written to more. Along with this, it is hard to grep when rescanning is done without reading a lot of the file due to a bunch of calls that happen right after finishing that write to the log. If I don't read enough of the file, I miss it entirely.
I am doing this in a timer currently but may need to change things around to use QFileSystemWatcher and only read when the file changes. It looked like rescan data is written every 1 minute. It might work better if I stop whatever keeps trying to connect so only rescan progress is being logged.
@fekt I was wrong about when
rescan
was fixed, it didn't work correctly until 3.9.1, so we should keep the old way around of doing a rescan with restart. We don't need to check versions, we can simply do the old way of doing things ifrescan HEIGHT
returns an error.@fekt what if I can write an RPC that would return current rescan height, during a rescan? Would that avoid a huge amount of complication? Seems like it might.
If we go that route, we might need to make SD use a binary from the
dev
branch of hushd, but sincemaster
anddev
are basically the same in hush3.git, that seems OK@fekt according to https://developer.bitcoin.org/reference/rpc/rescanblockchain.html the rescan progress is part of
getwalletinfo
output, we could do the same and avoid another RPC, since we need to callgetwalletinfo
alreadyNice! That would be better than reading debug.log and probably where it's getting that data to begin with. I saw this code but didn't look into where "rescan" gets passed to it. https://git.hush.is/hush/SilentDragon/src/branch/dev/src/connection.cpp#L528
getwalletinfo
doc says it returns like thisI'll try to get my code working with this instead. Won't have current block height it's at and only progress percentage.
Our
getwalletinfo
currently doesn't have this support. When I try calling it when rescanning, it also just hangs.@fekt yeah, this stuff was added in BTC Core 0.17.x which is after our internals forked, so we don't have the stuff in those docs, but it shows it's possible.
I believe BTC Core made some changes that allow some RPCs to return data even during a rescan, I am looking into it.
This is the BTC Core PR that adds rescan data to getwalletinfo: https://github.com/bitcoin/bitcoin/pull/15730
See hush/hush3#222 for details about the new RPC
getrescaninfo
Latest commit to dev branch has this implemented. For the time being, it will update in bottom left status bar only when using rescan option under settings. Need to figure out how to handle on startup or when restarting.
I also need to test on a large wallet to see what happens with other timers and look into pausing them for performance while rescanning or see if they create issues.
The status will update every 1 second but can be changed to not be as frequent. I had to set it fast for testing to see progress because rescans are too quick on a small wallet with not a lot of txs.
@fekt super awesome, I will test soon
@duke I tested on a large wallet and it's a bit janky. Seems like starting the rescan never even happens possibly due to other RPCs/timers running and causing it to timeout or something. I tried multiple times where it never showed it starting in log and transaction data kept trying to load at same time. The times it did start, it seemed like getrescaninfo was slow in being called or responding too. Probably need to look into and implement pausing everything else when starting rescan. On small wallets it seems to work as intended.
@fekt I think we should put your code onto a
rescan
branch and yes, we probably want to pause other timers for it to work well with large wallets. This is a big enough change that we should get testing from a few different people on different wallets to make sure it works correctly.Thanks for working on this, I think it will end up being a huge improvement, once we shake out some bugs.
@duke I can create a rescan branch that's a copy of current dev and then revert rescan option back to original behavior if that's what you want. Let me know. I may have some time tonight or should be free tomorrow.
@fekt I am in the process of reviewing the code and testing. I think it's ok to leave it on the
dev
branch right now, since it makes it easier for others to test it together with all the other recent SD changes. If we want to make an SD release and the code isn't ready for "prime time" yet, then we can put it on it's own branch and work on it for the next release.@jahway603 @onryo do you have time to help test these rescan changes?
@fekt with my latest commits to
dev
, I think this works "good enough". Users can rescan from an arbitrary height without a restart. I did not implement pausing other timers because I was seeing issues with that, at least with my large wallet I used for testing. I am still not seeing the statusbar update correctly but I am thinking that is an issue with my large wallet. I want to do some testing with a small wallet before closing this.@duke Seems to work fine on my small Mac wallet. I tested pausing other timers previously and didn't seem to help on large wallets. I can test latest changes on a larger wallet. The height initialization should at least fix the issue of it sometimes showing 100% at first.
@fekt the problem with large wallets seems to be that we don't have enough QThread's doing different things, so some stuff blocks the UI updating. https://doc.qt.io/qt-5/qthread.html This is related to how we inherit from SingleApplication : https://git.hush.is/hush/SilentDragon/src/branch/master/singleapplication
We might want to fiddle with that stuff for a future release, but it seems to be a bigger can of worms than we want to open for our next SD release.
Yeah, large wallet still funky with updating status and a possible new issue. I tried a rescan a couple of times and getrescaninfo shows it's 100% complete but keeps saying rescanning is true for awhile. The UI status in bottom right seems to stop updating and stays on block height from when rescan started unless right clicking to refresh. I didn't check code but maybe just from stopping other timers if you did that. Once I refresh once, it continues to update regularly.
@fekt not sure which code you are using, but my latest dev branch code does not pause the main UI timer. Maybe it should, not sure. I haven't tried right clicking the statusbar and refreshing, I should try that.
@fekt going to call this "done" and we can open up specific issues for improving it, as it definitely could be improved