Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: electrs p2p disconnects on "Broken pipe (os error 32)" and exits #1011

Open
iyusaf opened this issue Feb 28, 2024 · 5 comments
Open

Bug: electrs p2p disconnects on "Broken pipe (os error 32)" and exits #1011

iyusaf opened this issue Feb 28, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@iyusaf
Copy link

iyusaf commented Feb 28, 2024

Describe the bug
electrs fails on p2p disconnects running against Satoshi:26.0.0 on Debian bullseye with "Broken pipe (os error 32)".

Electrs version
electrs v0.10.3

To Reproduce
Steps to reproduce the behavior:

  1. Configure and start electrs
  2. Connect with Sparrow wallet via SSH tunnel
  3. Explore wallet addresses
  4. See error

Expected behavior
electrs should not exit.

Configuration

electrs.service
[Unit]
Description=Electrs
After=bitcoind.service

[Service]
WorkingDirectory=/home/bitcoin/.electrs
ExecStart=/usr/local/bin/electrs --log-filters WARN --db-dir ./db --electrum-rpc-addr="127.0.0.1:50001"
User=bitcoin
Group=bitcoin
Type=simple
KillMode=process
TimeoutSec=60
Restart=always
RestartSec=60

Environment="RUST_BACKTRACE=1"

# Hardening measures
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
MemoryDenyWriteExecute=true

[Install]
WantedBy=multi-user.target
electrs error log
Feb 28 07:01:35 zeus systemd[1]: Started Electrs.
Feb 28 07:01:35 zeus electrs[3058]: Starting electrs 0.10.3 on x86_64 linux with Config { network: Bitcoin, db_path: "./db/bitcoin", db_log_dir: None, daemon_dir: "/home/bitcoin/.bitcoin", daemon_auth: CookieFile("/home/bitcoin/.bitcoin/.cookie"), daemon_rpc_addr: 127.0.0.1:8332, daemon_p2p_addr: 127.0.0.1:8333, electrum_rpc_addr: 127.0.0.1:50001, monitoring_addr: 127.0.0.1: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.3 (Electrum Rust Server)!", signet_magic: f9beb4d9, args: [] }
Feb 28 07:04:35 zeus electrs[3058]: [2024-02-28T12:04:35.317Z WARN  electrs::thread] p2p_send thread failed: p2p failed to send
Feb 28 07:04:35 zeus electrs[3058]: [2024-02-28T12:04:35.317Z WARN  electrs::thread] because: Broken pipe (os error 32)
Feb 28 07:04:35 zeus electrs[3058]: [2024-02-28T12:04:35.317Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: failed to get block 000000000000000000083b1f4b5bdc0a589f7637ad6de6f578ddbb1cbe21bc92: receiving on an empty and disconnected channel
Feb 28 07:04:35 zeus electrs[3058]: Error: electrs failed
Feb 28 07:04:35 zeus electrs[3058]: Caused by:
Feb 28 07:04:35 zeus electrs[3058]:     0: sync failed
Feb 28 07:04:35 zeus electrs[3058]:     1: sending on a disconnected channel
Feb 28 07:04:35 zeus systemd[1]: electrs.service: Main process exited, code=exited, status=1/FAILURE
Feb 28 07:04:35 zeus systemd[1]: electrs.service: Failed with result 'exit-code'.
Feb 28 07:04:35 zeus systemd[1]: electrs.service: Consumed 20.130s CPU time.
bitcoin.conf
rpcauth=XXX

[main]
rpcbind=127.0.0.1
rpcbind=X.X.X.X
rpcallowip=127.0.0.1
rpcallowip=X.X.X.0/24

## Whitelisting is intended for 'electrs'
whitelist=download@127.0.0.1
whitelist=download@X.X.X.X

Environment variables: N/A
Arguments: see above

System running electrs

  • Compiled natively
  • 5.10.0-28-amd64 No. 1 SMP Debian 5.10.209-2 (2024-01-31) x86_64 GNU/Linux

Electrum client
Sparrow on macOS Sonoma 14.2.1

Additional context
Sparrow is connecting via SSH tunnel.
Trace file is attached. Apologies for the large file.
problem.log

Many thanks for your help. Cheers!

@iyusaf iyusaf added the bug Something isn't working label Feb 28, 2024
@romanz romanz self-assigned this Feb 28, 2024
@su-sd
Copy link

su-sd commented Aug 11, 2024

The same happened on my end with a direct connection on the same server.
I have a script which analyzes a lot of transactions and balances. If the electrs server crashes after several days, it is quite annoying.

[2024-08-11T03:45:38.331Z DEBUG electrs::server] 16: recv [{"method": "blockchain.scripthash.get_history", "params": ["03308ec8dd9f3324db5fef4e83a268abcabbafd247ae53e7bcfec51002c236e9"], "id": 39398, "jsonrpc": "2.0"}]
[2024-08-11T03:45:38.331Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2024-08-11T03:45:40.159Z DEBUG electrs::p2p] loading 216003 blocks
[2024-08-11T03:45:40.202Z DEBUG electrs::p2p] closing p2p_loop thread: peer has disconnected
[2024-08-11T03:45:40.202Z WARN  electrs::thread] p2p_send thread failed: p2p failed to send
[2024-08-11T03:45:40.202Z WARN  electrs::thread] p2p_recv thread failed: failed to recv a message from peer: IO error
[2024-08-11T03:45:40.203Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: failed to get block 00000000000000000012206336bbb49aca889479cae2877399756ad5798d4ffb: receiving on an empty and disconnected channel
[2024-08-11T03:45:40.203Z DEBUG electrs::server] 16: send [{"error":{"code":1,"message":"failed to get block 00000000000000000012206336bbb49aca889479cae2877399756ad5798d4ffb"},"id":39398,"jsonrpc":"2.0"}]
[2024-08-11T03:45:40.204Z INFO  electrs::db] closing DB at ./db/bitcoin
[2024-08-11T03:45:40.203Z WARN  electrs::thread] because: Broken pipe (os error 32)
[2024-08-11T03:46:03.905Z DEBUG electrs::server] 16: disconnected
Error: electrs failed

Caused by:
    0: sync failed
    1: sending on a disconnected channel

@su-sd
Copy link

su-sd commented Aug 11, 2024

This is easy reproducible with
``blockchain.scripthash.get_history scripthash(1N52wHoVR79PMDishab2XmRHsbekCdGquK)`

@Freeben666
Copy link

Any news on this ? Electrs keeps crashing everytime I lookup transactions in Sparrow...

@romanz
Copy link
Owner

romanz commented Mar 2, 2025

Sorry for the (very) delayed response.

@su-sd Please note that https://mempool.space/address/1N52wHoVR79PMDishab2XmRHsbekCdGquK has >450k transactions' history - electrs is not optimized for such "popular" addresses, so it will probably will take a lot of resources (CPU & memory) to respond.

@Freeben666 could you please share electrs logs?

@Freeben666
Copy link

Freeben666 commented Mar 3, 2025

Hello @romanz ,

Sure, here are the logs :

[2025-03-03T21:47:33.921Z INFO  electrs::index] indexing 1 blocks: [886191..886191]
[2025-03-03T21:47:34.181Z INFO  electrs::chain] chain updated: tip=00000000000000000001b98f918fdd3621fa8e05dac6a7e693537f2a4a74caed, height=886191
[2025-03-03T21:49:40.656Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:47.488Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:47.683Z WARN  electrs::thread] p2p_send thread failed: p2p failed to send
[2025-03-03T21:49:47.683Z WARN  electrs::thread] because: Broken pipe (os error 32)
[2025-03-03T21:49:47.684Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: failed to get block 00000000000000000000b71ed0d9bec536d4fbbfa4da8dece0edb25324d11db0: receiving on an empty and disconnected channel
[2025-03-03T21:49:47.684Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:47.858Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:47.858Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:47.915Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:47.915Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:48.051Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:48.051Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:48.313Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:48.313Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:48.436Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:48.436Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:48.557Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:48.557Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:48.672Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:48.672Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:48.795Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:48.795Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:48.831Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:48.831Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:48.873Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:48.873Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:49.119Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:49.119Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:49.281Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:49.281Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:49.469Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:49.469Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:49.625Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:49.625Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:49.714Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:49.714Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:49.781Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:49.781Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:49.855Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:49.855Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:49.908Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:49.908Z INFO  electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash
[2025-03-03T21:49:49.988Z WARN  electrs::electrum] RPC blockchain.scripthash.get_history failed: sending on a disconnected channel
[2025-03-03T21:49:49.988Z INFO  electrs::server] disconnected from bitcoind
[2025-03-03T21:49:49.988Z INFO  electrs::db] closing DB at /var/db/electrs/db/bitcoin
Error: electrs failed

Caused by:
    0: sync failed
    1: sending on a disconnected channel

For context:

  • electrs is running on FreeBSD 13 (inside a jail)
  • I'm using the latest version of Sparrow Wallet
  • electrs works perfectly well, up until the point where I open a transaction in Sparrow

Here is my electrs.conf:

# Bitcoin Core settings
network = "bitcoin"
daemon_dir= "/var/db/bitcoin"
daemon_rpc_addr = "127.0.0.1:8332"
daemon_p2p_addr = "127.0.0.1:8333"

# Electrs settings
electrum_rpc_addr = "127.0.0.1:50001"
db_dir = "/var/db/electrs/db"

# Logging
log_filters = "INFO"

Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants