romanz / electrs

An efficient re-implementation of Electrum Server in Rust
MIT License
1.06k stars 390 forks source link

Feature: Support to run electrs offline #410

Closed jr682 closed 1 year ago

jr682 commented 3 years ago

Is your feature request related to a problem? Please describe. Runnin bitcoind and electrs in an offline machine. No internet. Copy of blockchain on machine for bitcoind. When blockchain is old, maybe some hours, electrs refuse all requests. Message about IBD, initial block download.

Describe the solution you'd like Option to ignore IBD and serve all requests.

Describe alternatives you've considered Other option to answer all request when blockchain is out of date would also work.

Additional context Performance of electrs is excellent in offline machine.

Kixunil commented 3 years ago

I think the solution for this is the same as for listening during sync. I swear I've seen an issue about it, can't find it right now.

sjkjs commented 1 year ago

I agree that this is a useful feature. There are legitimate reasons to run it offline with no internet connection.

The check for whether or not it's doing an initial block download is done by bitcoind, not electrs. However electrs then refuses to progress any further until bitcoind says that the initial block download is complete.

A workaround while we wait for a fix is to edit src/daemon.rs, and in the function rpc_poll(), change:

if info.initial_block_download || left_blocks > 0 {

to:

if left_blocks > 0 {

romanz commented 1 year ago

The reason electrs is waiting for IBD to finish is to make sure it won't "compete" with bitcoind on CPU/IO resources during the IBD process, which is preferable when running on modest hardware.

Kixunil commented 1 year ago

Interesting. I think it could be configurable but I'm wondering how much does it even help. At least the blocks which verify signatures are CPU-bound and bitcoind isn't very parallelized, so if you have many cores it'd be probably better to run them in parallel at that time. There may be other weird cases, like user having two dedicated storages for chain and electrs index...

romanz commented 1 year ago

@jr682 @sjkjs Could you please try #888 (using the new --skip-block-download-wait flag)?

sjkjs commented 1 year ago

Thanks romanz. I can confirm that it works after putting skip-block-download-wait=true into the config file. I didn't try with the flag but I assume it's the same thing.