LedgerHQ / satstack

Bitcoin full node with Ledger Live
BSD 2-Clause "Simplified" License
156 stars 32 forks source link

Importing descriptors process in a loop #86

Open chuegel opened 2 years ago

chuegel commented 2 years ago

OS: MacOS 12.6 satstack: 0.16.1_macOS-amd64

lss seems to run in a loop every time it is started. I completed the account import successfully but when lss is stopped:

^C[2022/10/18 - 07:18:20]  INFO Shutdown server: in progress
[2022/10/18 - 07:18:20]  INFO Unloaded wallet successfully                  wallet=satstack
[2022/10/18 - 07:18:20]  INFO Shutdown server: done

the wallet is also released from the node:

2022-10-18T05:18:20Z [satstack] Releasing wallet 

and restarted, the account import process runs again from scratch:

./lss
[2022/10/18 - 07:18:53]  INFO Ledger SatStack (lss) v0.16.1                 arch=darwin amd64 build= commit= runtime=go1.17.13
[2022/10/18 - 07:18:53]  INFO Config file detected                          path=/Users/user/Library/Application Support/Ledger Live/lss.json
[2022/10/18 - 07:18:53]  INFO Warming up...
[2022/10/18 - 07:18:56]  INFO Loaded existing wallet                        wallet=satstack
[2022/10/18 - 07:18:56]  INFO RPC connection established                    blockFilter=false chain=main pruned=false txindex=true
 __________________________________________
/ We define an electronic coin as a chain  \
| of digital signatures. Each owner        |
| transfers the coin to the next by        |
| digitally signing a hash of the previous |
| transaction and the public key of the    |
| next owner and adding these to the end   |
| of the coin. A payee can verify the      |
| signatures to verify the chain of        |
| ownership.                               |
|                                          |
\         -- Satoshi Nakamoto, 2010        /
 ------------------------------------------
        \   ^__^
         \  (₿₿)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /timestamp                --> github.com/ledgerhq/satstack/httpd/handlers.GetTimestamp.func1 (3 handlers)
[GIN-debug] GET    /control/descriptors/import --> github.com/ledgerhq/satstack/httpd/handlers.ImportAccounts.func1 (3 handlers)
[GIN-debug] POST   /control/descriptors/has  --> github.com/ledgerhq/satstack/httpd/handlers.HasDescriptor.func1 (3 handlers)
[GIN-debug] GET    /blockchain/:version/explorer/_health --> github.com/ledgerhq/satstack/httpd/handlers.GetHealth.func1 (3 handlers)
[GIN-debug] GET    /blockchain/:version/explorer/status --> github.com/ledgerhq/satstack/httpd/handlers.GetStatus.func1 (3 handlers)
[GIN-debug] GET    /blockchain/:version/btc/network --> github.com/ledgerhq/satstack/httpd/handlers.GetNetwork.func1 (3 handlers)
[GIN-debug] GET    /blockchain/:version/btc/fees --> github.com/ledgerhq/satstack/httpd/handlers.GetFees.func1 (3 handlers)
[GIN-debug] GET    /blockchain/:version/btc/blocks/:block --> github.com/ledgerhq/satstack/httpd/handlers.GetBlock.func1 (3 handlers)
[GIN-debug] GET    /blockchain/:version/btc/transactions/:hash/hex --> github.com/ledgerhq/satstack/httpd/handlers.GetTransactionHex.func1 (3 handlers)
[GIN-debug] POST   /blockchain/:version/btc/transactions/send --> github.com/ledgerhq/satstack/httpd/handlers.SendTransaction.func1 (3 handlers)
[GIN-debug] GET    /blockchain/:version/btc/addresses/:addresses/transactions --> github.com/ledgerhq/satstack/httpd/handlers.GetAddresses.func1 (3 handlers)
[2022/10/18 - 07:18:56]  INFO worker: Initial Block Download complete               blockHash=000000000000000000051ad07f5a11b6701fb954648b0dc44ca41c8a3d6eba92 blockHeight=759179
[2022/10/18 - 07:18:56]  INFO worker: Computing circulating supply...
[2022/10/18 - 07:22:47]  INFO worker: #RunTheNumbers successful                     actualSupply=19182160.91854672 BTC expectedSupply=19182368.75 BTC height=759179
[2022/10/18 - 07:22:47]  INFO worker: Importing descriptors                         duration=0s progress=0.00%
[2022/10/18 - 07:22:54]  INFO worker: Importing descriptors                         duration=7s progress=0.11%
[2022/10/18 - 07:23:01]  INFO worker: Importing descriptors                         duration=14s progress=0.23%
[2022/10/18 - 07:23:08]  INFO worker: Importing descriptors                         duration=21s progress=0.35%
[2022/10/18 - 07:23:15]  INFO worker: Importing descriptors                         duration=28s progress=0.47%
[2022/10/18 - 07:23:22]  INFO worker: Importing descriptors                         duration=35s progress=0.60%
[2022/10/18 - 07:23:29]  INFO worker: Importing descriptors                         duration=42s progress=0.72%
[2022/10/18 - 07:23:36]  INFO worker: Importing descriptors                         duration=49s progress=0.84%
[2022/10/18 - 07:23:43]  INFO worker: Importing descriptors                         duration=56s progress=0.96%
[2022/10/18 - 07:23:50]  INFO worker: Importing descriptors                         duration=1m3s progress=1.08%
[2022/10/18 - 07:23:57]  INFO worker: Importing descriptors                         duration=1m10s progress=1.21%
[2022/10/18 - 07:24:04]  INFO worker: Importing descriptors                         duration=1m17s progress=1.34%
[2022/10/18 - 07:24:11]  INFO worker: Importing descriptors                         duration=1m24s progress=1.45%
[2022/10/18 - 07:24:18]  INFO worker: Importing descriptors                         duration=1m31s progress=1.57%
[2022/10/18 - 07:24:25]  INFO worker: Importing descriptors                         duration=1m38s progress=1.67%
[2022/10/18 - 07:24:32]  INFO worker: Importing descriptors                         duration=1m45s progress=1.77%
[2022/10/18 - 07:24:39]  INFO worker: Importing descriptors                         duration=1m52s progress=1.89%
[2022/10/18 - 07:24:47]  INFO worker: Importing descriptors                         duration=1m59s progress=2.00%
adrienlacombe commented 2 years ago

hi @chuegel can you see if the same descriptors are being imported, or are they new ones? thank you

chuegel commented 2 years ago

@adrienlacombe-ledger how can I check that?

Also, I must mention that I'm running a Lightning node on the same machine

adrienlacombe commented 2 years ago

@adrienlacombe-ledger how can I check that?

Also, I must mention that I'm running a Lightning node on the same machine

do you have a multiple descriptors in your lss.json?

chuegel commented 2 years ago

No, just one (external/internal)

ziggie1984 commented 2 years ago

The scan will repeat for every descriptor, so in your case 2 times (1 for internal 1 for external)

chuegel commented 2 years ago

Thanks for your reply. Yes, but why does the import process starts from scratch as the descriptors in the lss.jsondidn't change?

ziggie1984 commented 2 years ago

thats a bitcoin-core thing, lss imports the descriptors everytime it restarts, which forces bitcoind to rescan the wallet, need to check whether bitcoinds wallet information persist after a scan

ziggie1984 commented 2 years ago

ok, I just checked, core keeps the latest state of the wallet after reloading, so its should be easy to fix this

ziggie1984 commented 2 years ago

As a quick fix for the rescanning wallet problem can be to put the birthday in the lss.json to the current date and everything should work find. Only prerequisite for this is that the syncing already happened before. In practical it would look like this: First let ledger and bitcoin-core sync with the real birthday date, if that happened and you need to restart the bridge, change the birthday to the current date.

"external" : "",
"internal" : "",
"birthday": "2022/11/07"
chuegel commented 2 years ago

Probably related to https://github.com/LedgerHQ/satstack/issues/90