<p>Can anyone help me to debug this issue?</p>
<h3>What I Am Trying to Do</h3>
<p>I am attempting to run a bitcoind regtest node and connect it to electrumx_server</p>
<h3>The Problem</h3>
<p>When I run electrumx_server, it connects to bitcoind successfully but it crashes when it starts to read the first block giving this error:
<code>RuntimeError: truncated block file</code></p>
<h3>Environment Details</h3>
<p><strong>Operating System:</strong> Ubuntu 22.04
<strong>ElectrumX Version:</strong> 1.20.2
<strong>bitcoind Version:</strong> v27.0</p>
<p>These are the logs when I run <code>electrumx_server</code> command:</p>
<pre><code>INFO:electrumx:ElectrumX server starting
WARNING:Env:lowered maximum sessions from 1,000 to 674 because your open file limit is 1,024
INFO:electrumx:logging level: INFO
INFO:Controller:Python version: 3.10.12 (main, Nov  6 2024, 20:22:13) [GCC 11.4.0]
INFO:Controller:software version: ElectrumX 1.20.2
INFO:Controller:aiorpcX version: 0.22.1
INFO:Controller:supported protocol versions: 1.4-1.4.2
INFO:Controller:event loop policy: None
INFO:Controller:reorg limit is 8,000 blocks
INFO:Daemon:daemon #1 at 127.0.0.1:18443/ (current)
INFO:DB:switching current directory to /home/omarosman23/.electrumx/db
INFO:DB:using leveldb for DB backend
INFO:DB:opened UTXO DB (for sync: True)
INFO:DB:UTXO DB version: 8
INFO:DB:coin: BitcoinSV
INFO:DB:network: regtest
INFO:DB:height: 0
INFO:DB:tip: 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206
INFO:DB:tx count: 1
INFO:DB:chain size: 0 GB (285 bytes)
INFO:DB:flushing DB cache at 1,200 MB
INFO:History:history DB version: 1
INFO:History:flush count: 1
INFO:BlockProcessor:scanning block directory meta/blocks...
INFO:BlockProcessor:deleted 1 stale block files, total size 285 bytes
INFO:BlockProcessor:catching up to daemon height 101 (101 blocks behind)
INFO:BlockProcessor:height 1 of 101 6962336134cc551e47876c1bcc436986489b8c0d9b6008c34b8781f87bbf3544 2024-12-04 01:07:08 0.000GB 1 txs chain 0GB
INFO:SessionManager:stopping servers
INFO:SessionManager:closing connections...
INFO:SessionManager:connections closed
ERROR:BlockProcessor:error prefetching 0610f78b45cdcb8f3acc06bb6c0fa976ef79e824360058ef1ba76ee119c7cc21: Session is closed
ERROR:BlockProcessor:error prefetching 11575e4c2dd2b786ffe24ab0439f7fec21a6860d9485b63a06273401a37d9f32: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 60c69f7f4fd78479c376cd06163c198aa5e45df053ac90918e9f90b43d69f73a: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 359d3818b64039b05e6552f272c1fb6c98fb713b6f4d3ba8e736dde9e159d0cd: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 46a16268710b51639eec8173bd8cb90ed20bdc45c067824f3c14ccb8941d1bf9: 'NoneType' object has no attribute 'get'
INFO:Controller:shutting down
INFO:Controller:shutdown complete
ERROR:BlockProcessor:error prefetching 55b9ba7f176fdcdd90be70816b12e7e387e2c301993d7190833410d63e910af4: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 70a1e31ab0606cb04a3972005ce708c933a47c39678585de9c7a5a762c40fb19: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 0cecb7ba4ffec37b3da27536c5ef35b87946fe09a6551e515f9a7f09b0896023: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 641e359e27b8d10d4c11b316fab5935dfaa26cc073aeb68a4117005013a1e176: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 208ab8575cb81cee12fdaf920656eb37e3bf1202a80a208bb3dcf9490280bc4d: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 071e7faf308ed9b5d10700bd10aba36f483b08410ba95ccc7bf5ca4120211e00: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 38fc7e85297feb287d1fdcc142976a925611bed841b2aceebe7aa27394759c97: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 2602d075e6764d6f111ab702658d7663746d4c30ab43258d0baf3523d28fac6b: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 78b3b683bd21f3ef3bdba8e6af1b8d331e6b70f5062549a2df4371c92ac1dc33: 'NoneType' object has no attribute 'get'
ERROR:electrumx:ElectrumX server terminated abnormally
Traceback (most recent call last):
  File &quot;/home/omarosman23/.local/bin/electrumx_server&quot;, line 35, in main
    asyncio.run(controller.run())
  File &quot;/usr/lib/python3.10/asyncio/runners.py&quot;, line 44, in run
    return loop.run_until_complete(main)
  File &quot;/usr/lib/python3.10/asyncio/base_events.py&quot;, line 649, in run_until_complete
    return future.result()
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/lib/server_base.py&quot;, line 125, in run
    await server_task
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/lib/server_base.py&quot;, line 98, in serve
    await self.serve(shutdown_event)
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/controller.py&quot;, line 143, in serve
    task.result()
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py&quot;, line 758, in fetch_and_process_blocks
    await self.advance_blocks(hex_hashes)
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py&quot;, line 476, in advance_blocks
    await self.run_with_lock(advance_and_maybe_flush(block))
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py&quot;, line 320, in run_with_lock
    return await asyncio.shield(run_locked())
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py&quot;, line 319, in run_locked
    return await coro
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py&quot;, line 466, in advance_and_maybe_flush
    await run_in_thread(self.advance_block, block)
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/aiorpcx/curio.py&quot;, line 57, in run_in_thread
    return await get_event_loop().run_in_executor(None, func, *args)
  File &quot;/usr/lib/python3.10/concurrent/futures/thread.py&quot;, line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py&quot;, line 510, in advance_block
    for tx, tx_hash in block.iter_txs():
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py&quot;, line 113, in iter_txs
    raw = raw[cursor:] + self._read(self.chunk_size)
  File &quot;/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py&quot;, line 71, in _read
    raise RuntimeError(f'truncated block file for block {self.hex_hash} '
RuntimeError: truncated block file for block 6962336134cc551e47876c1bcc436986489b8c0d9b6008c34b8781f87bbf3544 height 1
</code></pre>
<h3>Configuration Details</h3>
<p><strong>ElectrumX Configuration (config):</strong></p>
<pre><code>DB_DIRECTORY = /home/omarosman23/.electrumx/db
DB_ENGINE = rocksdb
DAEMON_URL = http://rpcuser:rpcpassword@127.0.0.1:18443
COIN = BitcoinSVRegtest
NET= regtest
SSL_CERTFILE = /home/omarosman23/.electrumx/electrumx.crt
SSL_KEYFILE = /home/omarosman23/.electrumx/electrumx.key
</code></pre>
<p><strong>Bitcoin Daemon Configuration (bitcoin.conf):</strong></p>
<pre><code>server=1
txindex=1
rpcuser=rpcuser
rpcpassword=rpcpassword
rpcallowip=0.0.0.0/0

[regtest]
rpcbind=0.0.0.0
rpcport=18443
</code></pre>
<h3>Expected Behavior</h3>
<p>The electrumx_server should connect to the bitcoind node, scans the blocks and does not crash</p>

CC BY-SA 4.0
2024-12-05T13:50:23.897Z
Is this question about Bitcoin or BSV?
Murch
CC BY-SA 4.0
2024-12-06T11:27:42.820Z
I am trying to run on Bitcoin, but I always get this error: electrumx.lib.coins.CoinError: unknown coin Bitcoin and network regtest combination
Omar Osman
CC BY-SA 4.0
2024-12-06T14:55:21.700Z
Your Environment Details says "coin: BitcoinSV", and your config says "COIN = BitcoinSVRegtest". So if you are trying to run Bitcoin, this might be an error source.
Murch
<bitcoin-core><bitcoind><electrum><bitcoin-cli>
ElectrumX Crashes on Reading blocks from Bitcoind regtest node
Omar Osman
# ElectrumX Crashes on Reading blocks from Bitcoind regtest node

(Asked by: username_0 on 2024-12-05)

Can anyone help me to debug this issue?

### What I Am Trying to Do

I am attempting to run a bitcoind regtest node and connect it to electrumx\_server

### The Problem

When I run electrumx\_server, it connects to bitcoind successfully but it crashes when it starts to read the first block giving this error:
`RuntimeError: truncated block file`

### Environment Details

**Operating System:** Ubuntu 22.04
**ElectrumX Version:** 1.20.2
**bitcoind Version:** v27.0

These are the logs when I run `electrumx_server` command:

```
INFO:electrumx:ElectrumX server starting
WARNING:Env:lowered maximum sessions from 1,000 to 674 because your open file limit is 1,024
INFO:electrumx:logging level: INFO
INFO:Controller:Python version: 3.10.12 (main, Nov  6 2024, 20:22:13) [GCC 11.4.0]
INFO:Controller:software version: ElectrumX 1.20.2
INFO:Controller:aiorpcX version: 0.22.1
INFO:Controller:supported protocol versions: 1.4-1.4.2
INFO:Controller:event loop policy: None
INFO:Controller:reorg limit is 8,000 blocks
INFO:Daemon:daemon #1 at 127.0.0.1:18443/ (current)
INFO:DB:switching current directory to /home/omarosman23/.electrumx/db
INFO:DB:using leveldb for DB backend
INFO:DB:opened UTXO DB (for sync: True)
INFO:DB:UTXO DB version: 8
INFO:DB:coin: BitcoinSV
INFO:DB:network: regtest
INFO:DB:height: 0
INFO:DB:tip: 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206
INFO:DB:tx count: 1
INFO:DB:chain size: 0 GB (285 bytes)
INFO:DB:flushing DB cache at 1,200 MB
INFO:History:history DB version: 1
INFO:History:flush count: 1
INFO:BlockProcessor:scanning block directory meta/blocks...
INFO:BlockProcessor:deleted 1 stale block files, total size 285 bytes
INFO:BlockProcessor:catching up to daemon height 101 (101 blocks behind)
INFO:BlockProcessor:height 1 of 101 6962336134cc551e47876c1bcc436986489b8c0d9b6008c34b8781f87bbf3544 2024-12-04 01:07:08 0.000GB 1 txs chain 0GB
INFO:SessionManager:stopping servers
INFO:SessionManager:closing connections...
INFO:SessionManager:connections closed
ERROR:BlockProcessor:error prefetching 0610f78b45cdcb8f3acc06bb6c0fa976ef79e824360058ef1ba76ee119c7cc21: Session is closed
ERROR:BlockProcessor:error prefetching 11575e4c2dd2b786ffe24ab0439f7fec21a6860d9485b63a06273401a37d9f32: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 60c69f7f4fd78479c376cd06163c198aa5e45df053ac90918e9f90b43d69f73a: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 359d3818b64039b05e6552f272c1fb6c98fb713b6f4d3ba8e736dde9e159d0cd: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 46a16268710b51639eec8173bd8cb90ed20bdc45c067824f3c14ccb8941d1bf9: 'NoneType' object has no attribute 'get'
INFO:Controller:shutting down
INFO:Controller:shutdown complete
ERROR:BlockProcessor:error prefetching 55b9ba7f176fdcdd90be70816b12e7e387e2c301993d7190833410d63e910af4: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 70a1e31ab0606cb04a3972005ce708c933a47c39678585de9c7a5a762c40fb19: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 0cecb7ba4ffec37b3da27536c5ef35b87946fe09a6551e515f9a7f09b0896023: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 641e359e27b8d10d4c11b316fab5935dfaa26cc073aeb68a4117005013a1e176: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 208ab8575cb81cee12fdaf920656eb37e3bf1202a80a208bb3dcf9490280bc4d: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 071e7faf308ed9b5d10700bd10aba36f483b08410ba95ccc7bf5ca4120211e00: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 38fc7e85297feb287d1fdcc142976a925611bed841b2aceebe7aa27394759c97: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 2602d075e6764d6f111ab702658d7663746d4c30ab43258d0baf3523d28fac6b: 'NoneType' object has no attribute 'get'
ERROR:BlockProcessor:error prefetching 78b3b683bd21f3ef3bdba8e6af1b8d331e6b70f5062549a2df4371c92ac1dc33: 'NoneType' object has no attribute 'get'
ERROR:electrumx:ElectrumX server terminated abnormally
Traceback (most recent call last):
  File "/home/omarosman23/.local/bin/electrumx_server", line 35, in main
    asyncio.run(controller.run())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/lib/server_base.py", line 125, in run
    await server_task
  File "/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/lib/server_base.py", line 98, in serve
    await self.serve(shutdown_event)
  File "/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/controller.py", line 143, in serve
    task.result()
  File "/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py", line 758, in fetch_and_process_blocks
    await self.advance_blocks(hex_hashes)
  File "/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py", line 476, in advance_blocks
    await self.run_with_lock(advance_and_maybe_flush(block))
  File "/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py", line 320, in run_with_lock
    return await asyncio.shield(run_locked())
  File "/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py", line 319, in run_locked
    return await coro
  File "/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py", line 466, in advance_and_maybe_flush
    await run_in_thread(self.advance_block, block)
  File "/home/omarosman23/.local/lib/python3.10/site-packages/aiorpcx/curio.py", line 57, in run_in_thread
    return await get_event_loop().run_in_executor(None, func, *args)
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py", line 510, in advance_block
    for tx, tx_hash in block.iter_txs():
  File "/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py", line 113, in iter_txs
    raw = raw[cursor:] + self._read(self.chunk_size)
  File "/home/omarosman23/.local/lib/python3.10/site-packages/electrumx/server/block_processor.py", line 71, in _read
    raise RuntimeError(f'truncated block file for block {self.hex_hash} '
RuntimeError: truncated block file for block 6962336134cc551e47876c1bcc436986489b8c0d9b6008c34b8781f87bbf3544 height 1

```

### Configuration Details

**ElectrumX Configuration (config):**

```
DB_DIRECTORY = /home/omarosman23/.electrumx/db
DB_ENGINE = rocksdb
DAEMON_URL = http://rpcuser:rpcpassword@127.0.0.1:18443
COIN = BitcoinSVRegtest
NET= regtest
SSL_CERTFILE = /home/omarosman23/.electrumx/electrumx.crt
SSL_KEYFILE = /home/omarosman23/.electrumx/electrumx.key

```

**Bitcoin Daemon Configuration (bitcoin.conf):**

```
server=1
txindex=1
rpcuser=rpcuser
rpcpassword=rpcpassword
rpcallowip=0.0.0.0/0

[regtest]
rpcbind=0.0.0.0
rpcport=18443

```

### Expected Behavior

The electrumx\_server should connect to the bitcoind node, scans the blocks and does not crash

**Tags:** bitcoin-core, bitcoind, electrum, bitcoin-cli

> **Comments:**
> **username_1**: Is this question about Bitcoin or BSV?  
> **username_0**: I am trying to run on Bitcoin, but I always get this error: electrumx.lib.coins.CoinError: unknown coin Bitcoin and network regtest combination  
> **username_1**: Your Environment Details says "coin: BitcoinSV", and your config says "COIN = BitcoinSVRegtest". So if you are trying to run Bitcoin, this might be an error source.  

---

## 0 answers

