Open 7hacker opened 3 years ago
Interesting test! On the one hand, it would be good to reflect what's in the user's mempool, and on the other, in the general case broadcasting a transaction means it can never truly be considered lost.
What happens when you refresh the wallet in this state (View menu)?
DEBUG bitcoincore_rpc > JSON-RPC request: getwalletinfo []
2021-03-11 20:15:14,281 ERROR Error in version check address
com.sparrowwallet.drongo.address.InvalidAddressException: Could not parse invalid address 1LiJx1HQ49L2LzhBwbgwXdHiGodvPg5YaV
at com.sparrowwallet.drongo@0.9/com.sparrowwallet.drongo.address.Address.fromString(Address.java:132)
at com.sparrowwallet.drongo@0.9/com.sparrowwallet.drongo.address.Address.fromString(Address.java:67)
at com.sparrowwallet.sparrow@1.2.0/com.sparrowwallet.sparrow.net.VersionCheckService.verifySignature(VersionCheckService.java:68)
at com.sparrowwallet.sparrow@1.2.0/com.sparrowwallet.sparrow.net.VersionCheckService$1.call(VersionCheckService.java:35)
at com.sparrowwallet.sparrow@1.2.0/com.sparrowwallet.sparrow.net.VersionCheckService$1.call(VersionCheckService.java:31)
at javafx.graphics/javafx.concurrent.Task$TaskCallable.call(Task.java:1425)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at javafx.graphics/javafx.concurrent.Service.lambda$executeTask$6(Service.java:725)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/javafx.concurrent.Service.lambda$executeTask$7(Service.java:724)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
<===========--> 88% EXECUTING [3m 8s]
> :run
Which also fails to return
DEBUG bwt::indexer > failed fetching mempool entry for bbe825871e49a284d86f323238415d7d105c9f56a9bb9ed0c1a36606ad1903f8: JSON-RPC error: RPC error response: RpcError { code: -5, message: "Transaction not in mempool", data: None }
2021-03-11 20:18:54,885 ERROR Error in version check address
com.sparrowwallet.drongo.address.InvalidAddressException: Could not parse invalid address 1LiJx1HQ49L2LzhBwbgwXdHiGodvPg5YaV
at com.sparrowwallet.drongo@0.9/com.sparrowwallet.drongo.address.Address.fromString(Address.java:132)
at com.sparrowwallet.drongo@0.9/com.sparrowwallet.drongo.address.Address.fromString(Address.java:67)
at com.sparrowwallet.sparrow@1.2.0/com.sparrowwallet.sparrow.net.VersionCheckService.verifySignature(VersionCheckService.java:68)
at com.sparrowwallet.sparrow@1.2.0/com.sparrowwallet.sparrow.net.VersionCheckService$1.call(VersionCheckService.java:35)
at com.sparrowwallet.sparrow@1.2.0/com.sparrowwallet.sparrow.net.VersionCheckService$1.call(VersionCheckService.java:31)
at javafx.graphics/javafx.concurrent.Task$TaskCallable.call(Task.java:1425)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at javafx.graphics/javafx.concurrent.Service.lambda$executeTask$6(Service.java:725)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/javafx.concurrent.Service.lambda$executeTask$7(Service.java:724)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
DEBUG bitcoincore_rpc > JSON-RPC request: getblockhash [1733]
The InvalidAddressException
is unrelated - it's just caused by Sparrow failing to parse a mainnet address with a signet configuration. Fixed in 3e287bf.
If Sparrow is disconnecting on a wallet refresh, then it seems bwt (the library Sparrow is using to connect to the node) is experiencing a terminal error. Are there any logs that might indicate why this happening? bwt's debug logging is included inside Sparrow's logging, so it should be present. The bwt logs look similar to the first line in the log excerpts above.
I think I know whats happening here. Just to be sure i recreated the last result again, but this time captured the full log which is attached below. Reading the logs top to bottom should ideally reflect the events described below but if i missed something let me know. Also curious if you find something additional too
dev.bwt.libbwt.BwtException: JSON-RPC error: RPC error response: RpcError { code: -35, message: "Wallet file verification failed. Refusing to load database. Data file \'/Users/nirmal/code/bitcoin/src/signet-custom/signet/wallets/sparrow/wallet.dat\' is already loaded.", data: None }
Sparrow.log sparrow.log
@craigraw
Its possible that this issue concerns a case that is rare/improbable? As you mentioned previously, that broadcasted transactions are not considered 'lost' . However I am puzzled of why the entry switched from "Unconfirmed" to "Unconfirmed Parent". Should it continue staying "Unconfirmed"?
I believe your thinking is correct - this is a rare/improbable use case, but nevertheless I have been suspicious for some time that there is a subtle bug causing the "Unconfirmed Parent" situation when it is not always correct. That bug might be in bwt however - note that in the Electrum server protocol specification for blockchain.scripthash.get_mempool, the server notifies the client by returning -1
when some of the inputs of a mempool transaction are unconfirmed. Sparrow uses this information to add the "Unconfirmed Parent" label.
Although it should be present in the bwt logging too, may I suggest adding debug logging to SubscriptionService to see how bwt is following the protocol on this - strictly, it should notify the script hashes attached to the transaction to return them to their original states (prior to initiating the test). I should note that Sparrow does not handle that situation as you would expect - a bug in electrs means that Sparrow needs to ignore old script hash statuses, or be overwhelmed with unnecessary server queries after invalid notifications.
It would also be interesting to know if normal situation where a transaction has an unconfirmed parent are working correctly.
cc'ing @shesek (author of bwt)
bwt should be handling transactions with unconfirmed parents correctly and report them with a height of -1
, as of v0.1.4. Confirmation of the parent transactions should result in a status hash change and a notification.
If something still seems off on bwt's side, let me know and I'll look into this. It probably wouldn't hurt to add some tests around this at least.
Edit: It's not strictly related, but maybe also worth noting that bwt reports the effective feerate of transactions with unconfirmed parents, calculated as MIN(own_fee/own_vsize, (own_fee+ancestor_fee)/(own_vsize+ancestor_vsize))
. It is the only Electrum server implementation that does it, which may result in some different/unexpected behaviors.
hi @craigraw @shesek thanks for the discussion, here's what I'll do as next steps: check the wallet behavior for an actual unconfirmed parent.
Meanwhile if there's a patch you'd like me to build with that will provide additional logs for Sparrow or BWT, I'm happy to re-run this flow and provide the data for further debugging
Great - bwt's debug logging is also turned on when Sparrow's is.
@7hacker did you find time to perform this test with an unconfirmed parent?
Outstanding Action: Identify whether problem still exists. Identify whether fix can be applied to bwt and if so talk to shesek. Proposed Priority: Low
@6102bitcoin no i haven't had a chance to try this but I can spend some time on it. Do you have a suggestion of how to generate an unconfirmed parent? I'm using a custom signet here
I don't. @craigraw might know how
I'm not sure if this is correct but assuming that no txn would ever come then this entry would be unncessary?