pkahly / bitcoin-monitor

Monitors a full Bitcoin node and sends status emails and alerts
MIT License
0 stars 0 forks source link

Intermittent Decimal Conversion Error #146

Closed pkahly closed 5 years ago

pkahly commented 5 years ago

<class 'decimal.InvalidOperation'>

pkahly commented 5 years ago

Added a print statement to bitcoin_node_api.getnetworkhashps

Output and error

num_blocks: 144. height: None num_blocks: 144. height: 594252 num_blocks: 144. height: 594251 num_blocks: 144. height: 594250 num_blocks: 144. height: 594249 num_blocks: 144. height: 594248 num_blocks: 144. height: 594247 num_blocks: 144. height: 594246 Traceback (most recent call last): File "./main.py", line 68, in bitcoin_alerter.run_bitcoin_alerter(config) File "/home/philip/git/bitcoin-monitor/lib/bitcoin_alerter.py", line 16, in run_bitcoin_alerter _run(config, alertgen) File "/home/philip/git/bitcoin-monitor/lib/bitcoin_alerter.py", line 22, in _run info = info_collector.get_info(config, previous_info) File "/home/philip/git/bitcoin-monitor/lib/info_collector.py", line 69, in get_info reorg_info = reorg.add_blocks(config, bitcoin_client) File "/home/philip/git/bitcoin-monitor/lib/reorg.py", line 135, in add_blocks _overwrite_blocks(bitcoin_client, config, connection, cursor, start, end) File "/home/philip/git/bitcoin-monitor/lib/reorg.py", line 150, in _overwrite_blocks networkhashps = bitcoin_client.get_network_hashrate(config.network_hash_duration, height) File "/home/philip/git/bitcoin-monitor/lib/bitcoin_node_api.py", line 43, in get_network_hashrate return self.client.getnetworkhashps(num_blocks, height) File "/home/philip/.local/lib/python3.6/site-packages/bitcoinrpc/authproxy.py", line 139, in call response = self._get_response() File "/home/philip/.local/lib/python3.6/site-packages/bitcoinrpc/authproxy.py", line 192, in _get_response log.debug("<-%s- %s"%(response["id"], json.dumps(response["result"], default=EncodeDecimal))) File "/usr/lib/python3.6/json/init.py", line 238, in dumps **kw).encode(obj) File "/usr/lib/python3.6/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/home/philip/.local/lib/python3.6/site-packages/bitcoinrpc/authproxy.py", line 77, in EncodeDecimal return float(round(o, 8))

pkahly commented 5 years ago

Commandline results for these arguments:

$ bitcoin-cli getnetworkhashps 144 594246 1.001339980466565e+20

pkahly commented 5 years ago

Error seems to be coming from BitcoinRPC

https://github.com/jgarzik/python-bitcoinrpc/blob/master/bitcoinrpc/authproxy.py#L77

pkahly commented 5 years ago

This is a bug in bitcoinrpc. https://github.com/jgarzik/python-bitcoinrpc/issues/92

pkahly commented 5 years ago

Will patch my local bitcoinrpc installation and add a note to the instructions.