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

scripthash_subscribe: TypeError: 'NoneType' object is not reversible #552

Closed
SomberNight opened this issue Aug 2, 2018 · 1 comment

Comments

@SomberNight
Copy link
Contributor

commented Aug 2, 2018

mainnet BTC server crashed
On commit 2c07939

ERROR:ElectrumX:[384280] exception raised processing request: RPCRequest('blockchain.scripthash.subscribe', ['b07883bd7db18e7780ddaa8e6d13050e3e7bb4fbe59a3566c045bba0abe75140'], 36317)
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/rpc.py", line 376, in _response_message
    result = task.result()
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/rpc.py", line 470, in _process_request
    return await rpc_call()
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/session.py", line 858, in scripthash_subscribe
    return await self.hashX_subscribe(hashX, scripthash)
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/session.py", line 776, in hashX_subscribe
    return await self.address_status(hashX)
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/session.py", line 737, in address_status
    for tx_hash, height in history)
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/session.py", line 737, in <genexpr>
    for tx_hash, height in history)
  File "/usr/local/lib/python3.7/site-packages/electrumx/lib/hash.py", line 75, in hash_to_hex_str
    return bytes(reversed(x)).hex()
TypeError: 'NoneType' object is not reversible
INFO:BlockProcessor:flush #30,927 took 0.5s.  Height 534,825 txs: 332,124,089
INFO:BlockProcessor:processed 1 block in 4.0s
INFO:ElectrumX:[379193] notified of 2 addresses
INFO:ElectrumX:[384974] notified of 2 addresses
ERROR:TaskGroup:task crashed: <Task finished coro=<ElectrumX.notify() done, defined at /usr/local/lib/python3.7/site-packages/electrumx/server/session.py:653> exception=TypeError("'NoneType' object is not reversible")>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/curio.py", line 138, in _on_done
    task.result()
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/session.py", line 672, in notify
    await self.notify_touched(touched)
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/session.py", line 628, in notify_touched
    status = await self.address_status(hashX)
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/session.py", line 737, in address_status
    for tx_hash, height in history)
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/session.py", line 737, in <genexpr>
    for tx_hash, height in history)
  File "/usr/local/lib/python3.7/site-packages/electrumx/lib/hash.py", line 75, in hash_to_hex_str
    return bytes(reversed(x)).hex()
TypeError: 'NoneType' object is not reversible
ERROR:TaskGroup:task crashed: <Task finished coro=<BlockProcessor._process_prefetched_blocks() done, defined at /usr/local/lib/python3.7/site-packages/electrumx/server/block_processor.py:741> exception=TaskGroupError([<Task finished coro=<ElectrumX.notify() done, defined at /usr/local/lib/python3.7/site-packages/electrumx/server/session.py:653> exception=TypeError("'NoneType' object is not reversible")>])>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/curio.py", line 138, in _on_done
    task.result()
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/block_processor.py", line 755, in _process_prefetched_blocks
    await self.check_and_advance_blocks(blocks)
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/block_processor.py", line 212, in check_and_advance_blocks
    await self.notifications.on_block(self.touched, self.height)
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/controller.py", line 71, in on_block
    await self._maybe_notify()
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/controller.py", line 59, in _maybe_notify
    await notify_func(height, touched)
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/session.py", line 443, in _notify_sessions
    await group.spawn(session.notify(height, touched))
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/curio.py", line 254, in __aexit__
    await self.join(wait=self._wait)
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/curio.py", line 228, in join
    raise TaskGroupError(bad_tasks)
aiorpcx.curio.TaskGroupError: TaskGroupError(TypeError)
INFO:BlockProcessor:flushing to DB for a clean shutdown...
ERROR:TaskGroup:task crashed: <Task finished coro=<BlockProcessor.fetch_and_process_blocks() done, defined at /usr/local/lib/python3.7/site-packages/electrumx/server/block_processor.py:792> exception=TaskGroupError([<Task finished coro=<BlockProcessor._process_prefetched_blocks() done, defined at /usr/local/lib/python3.7/site-packages/electrumx/server/block_processor.py:741> exception=TaskGroupError([<Task finished coro=<ElectrumX.notify() done, defined at /usr/local/lib/python3.7/site-packages/electrumx/server/session.py:653> exception=TypeError("'NoneType' object is not reversible")>])>])>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/curio.py", line 138, in _on_done
    task.result()
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/block_processor.py", line 812, in fetch_and_process_blocks
    await group.spawn(self._process_prefetched_blocks())
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/curio.py", line 254, in __aexit__
    await self.join(wait=self._wait)
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/curio.py", line 228, in join
    raise TaskGroupError(bad_tasks)
aiorpcx.curio.TaskGroupError: TaskGroupError(TaskGroupError)
INFO:SessionManager:closing down RPC, TCP, SSL listening servers
ERROR:TaskGroup:task crashed: <Task finished coro=<Controller.serve() done, defined at /usr/local/lib/python3.7/site-packages/electrumx/server/controller.py:80> exception=TaskGroupError([<Task finished coro=<BlockProcessor.fetch_and_process_blocks() done, defined at /usr/local/lib/python3.7/site-packages/electrumx/server/block_processor.py:792> exception=TaskGroupError([<Task finished coro=<BlockProcessor._process_prefetched_blocks() done, defined at /usr/local/lib/python3.7/site-packages/electrumx/server/block_processor.py:741> exception=TaskGroupError([<Task finished coro=<ElectrumX.notify() done, defined at /usr/local/lib/python3.7/site-packages/electrumx/server/session.py:653> exception=TypeError("'NoneType' object is not reversible")>])>])>])>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/curio.py", line 138, in _on_done
    task.result()
  File "/usr/local/lib/python3.7/site-packages/electrumx/server/controller.py", line 116, in serve
    serve_externally_event.set()
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/curio.py", line 254, in __aexit__
    await self.join(wait=self._wait)
  File "/usr/local/lib/python3.7/site-packages/aiorpcx/curio.py", line 228, in join
    raise TaskGroupError(bad_tasks)
aiorpcx.curio.TaskGroupError: TaskGroupError(TaskGroupError)
@kyuupichan

This comment has been minimized.

Copy link
Owner

commented Aug 2, 2018

Hmm, that seems to be a very rare corner-case. Can you tell me if you had a reorg at that time?

@kyuupichan kyuupichan added the bug label Aug 2, 2018

shyba added a commit to lbryio/electrumx that referenced this issue Oct 16, 2018

Handle flush races gracefully
Fixes kyuupichan#552

I cannot see how these can occur other than during a reorg, but
the submitter didn't seem to think there was a reorg.  So log it
and recover gracefully; let's see if many report these.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.