romanz / electrs

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

Getting receiving on an empty and disconnected channel running in docker #1055

Open punithbm opened 1 week ago

punithbm commented 1 week ago

Getting following error in the electrs, can you please help me what might be the wrong

electrs error log,

Starting electrs 0.10.5 on x86_64 linux with Config { network: Signet, db_path: "/data/signet", db_log_dir: None, daemon_dir: "/bitcoin/signet", daemon_auth: CookieFile("/bitcoin/.cookie"), daemon_rpc_addr: 68.183.80.225:38332, daemon_p2p_addr: 68.183.80.225:38333, electrum_rpc_addr: 0.0.0.0:50001, monitoring_addr: 0.0.0.0:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: None, reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, skip_block_download_wait: false, disable_electrum_rpc: false, server_banner: "Welcome to electrs 0.10.5 (Electrum Rust Server)!", signet_magic: 0a03cf40, args: [] }
[2024-06-17T17:08:04.305Z INFO  electrs::metrics::metrics_impl] serving Prometheus metrics on 0.0.0.0:4224
[2024-06-17T17:08:04.305Z INFO  electrs::server] serving Electrum RPC on 0.0.0.0:50001
[2024-06-17T17:08:04.324Z INFO  electrs::db] "/data/signet": 20 SST files, 0.00002062 GB, 0.00000002 Grows
[2024-06-17T17:08:04.325Z DEBUG electrs::db] DB Some(Config { compacted: false, format: 0 })
[2024-06-17T17:08:04.329Z TRACE electrs::p2p] send: Version(VersionMessage { version: 70001, services: ServiceFlags(0), timestamp: 1718644084, receiver: Address {services: ServiceFlags(NONE), address: 0.0.0.0, port: 0}, sender: Address {services: ServiceFlags(NONE), address: 0.0.0.0, port: 0}, nonce: 11582491815844596145, user_agent: "/electrs:0.10.5/", start_height: 0, relay: false })
[2024-06-17T17:08:04.330Z DEBUG electrs::p2p] closing p2p_recv thread: connection closed
[2024-06-17T17:08:04.330Z DEBUG electrs::p2p] closing p2p_loop thread: peer has disconnected
[2024-06-17T17:08:04.330Z DEBUG electrs::p2p] closing p2p_send thread: no more messages to send
[2024-06-17T17:08:04.330Z INFO  electrs::db] closing DB at /data/signet
Error: electrs failed

Caused by:
    receiving on an empty and disconnected channel

bitcoin.conf file

signet=1
rpccookiefile=/root/.bitcoin/.cookie
rpcauth=bitcoin:xxxxxxxxxxxxxxxxxxxxxxxxxx
txindex=1
blockfilterindex=1
peerblockfilters=1
coinstatsindex=1
dnsseed=0
persistmempool=1
uacomment=CustomSignet
[signet]
daemon=1
listen=1
server=1
debug=net
discover=1
signetchallenge=512102de2d9ca0a9a584ee89ef099d3c4aff9710e257251c4a030a6fa878b7eecef94751ae
signetblocktime=10
zmqpubrawblock=tcp://0.0.0.0:28332
zmqpubrawtx=tcp://0.0.0.0:28333
zmqpubhashblock=tcp://0.0.0.0:28334
rpcbind=0.0.0.0:38332
rpcallowip=0.0.0.0/0
whitelist=0.0.0.0/0
fallbackfee=0.0002
bind=0.0.0.0
port=38333
Kixunil commented 1 week ago

Looks like your bitcoind got shutdown, can you check its logs?

punithbm commented 1 week ago

No, Its running - http://68.183.80.225:38332

Screenshot 2024-06-17 at 11 49 09 PM

wondering what could've gone wrong

Kixunil commented 1 week ago

Please check the logs from around 17:08:04, bitcoind should say some reason why it disconnects.

punithbm commented 1 week ago

tried again now, same error. How can check the required logs for this ?

Screenshot 2024-06-17 at 11 57 17 PM
Kixunil commented 1 week ago

I guess you need to increase verbosity of bitcoind somehow.

Kixunil commented 1 week ago

Is it possible that you're missing signet_magic configuration option?

punithbm commented 1 week ago

but it takes default value for signet_magic: 0a03cf40 if not set right ?

Kixunil commented 1 week ago

Yes but you've set signet challenge which might affect it but I don't really have much knowledge here. Just guessing.

punithbm commented 1 week ago

Ok, do you think may be due to this error ? Error: Cannot obtain a lock on data directory /root/.bitcoin/signet. Bitcoin Core is probably already running.

i can see this error on startup.. do you know how to clear that ?

antonilol commented 1 week ago

bitcoin core probably disconnects electrs because the network magic is wrong, see https://en.bitcoin.it/wiki/Signet the magic in the electrs config is the default signet magic, but you use a custom signet challenge, so you need to calculate your own network magic and put it in the config for electrs

"The protocol message header bytes are dynamically generated based on the block challenge" ('message header bytes' is the exact same thing as 'network magic')

punithbm commented 1 week ago

Thanks a lot for your response, do you know how to calculate and set network magic in bitcoin conf ?

Kixunil commented 1 week ago

You need to set it in electrs, not bitcoin.conf. I don't know how to calculate it.

punithbm commented 1 week ago

its available in the signet debug logs as well, Got it thanks for the help

antonilol commented 1 week ago

The same Bitcoin wiki page also mentions how to calculate the megic bytes from the signet challenge, the first 4 bytes of sha256d(challenge_len || challenge) (length is encoded as a typical bitcoin consensus varint)

https://en.bitcoin.it/wiki/Signet#Genesis_Block_and_Message_Header