steemit / steem-python

The official Python (3) library for the Steem Blockchain.
https://steem.io
MIT License
153 stars 98 forks source link

unspecified error from node (Invalid Request) in get_dynamic_global_properties #254

Closed officiallymarky closed 6 years ago

officiallymarky commented 6 years ago

Version of Python you are running

Python 3.6.5

Version of steem-python you are running

1.0.1

Expected Behavior

steem-python working with Jussi node

Actual Behavior

When connecting steem-python 1.0.1 a Jussi node that is not one of the Steemit Inc ones (api, dev, staging) I get the following error after doing Steem(nodes=[''])

steembase.exceptions.RPCError: unspecified error from api.usesteem.com (Invalid Request) in get_dynamic_global_properties

Doesn't matter what node the Jussi server is pointed to, and happens with a fresh install of Jussi with default configuration. Using Furion's version of Steem-python works, but has other issues.

Steps to reproduce

Install Jussi, use steem-python to do anything. Oddly it has no problems with Steemit Inc provided Jussi nodes.

Stack Trace

Unexpected exception! Please report at https://github.com/steemit/steem-python/issues -- RPCError: unspecified error from api.usesteem.com (Invalid Request) in get_dynamic_global_properties
Traceback (most recent call last):
  File "testnode.py", line 3, in <module>
    s = Steem(nodes=['https://api.usesteem.com'])
  File "/home/mal/anaconda3/lib/python3.6/site-packages/steem/steem.py", line 59, in __init__
    steemd_instance=self.steemd, no_broadcast=no_broadcast, **kwargs)
  File "/home/mal/anaconda3/lib/python3.6/site-packages/steem/commit.py", line 96, in __init__
    self.wallet = Wallet(self.steemd, **kwargs)
  File "/home/mal/anaconda3/lib/python3.6/site-packages/steem/wallet.py", line 61, in __init__
    self.prefix = self.steemd.chain_params["prefix"]
  File "/home/mal/anaconda3/lib/python3.6/site-packages/steem/steemd.py", line 65, in chain_params
    props = self.get_dynamic_global_properties()
  File "/home/mal/anaconda3/lib/python3.6/site-packages/steem/steemd.py", line 419, in get_dynamic_global_properties
    return self.call('get_dynamic_global_properties', api='database_api')
  File "/home/mal/anaconda3/lib/python3.6/site-packages/steembase/http_client.py", line 303, in call
    raise e
  File "/home/mal/anaconda3/lib/python3.6/site-packages/steembase/http_client.py", line 278, in call
    raise RPCError(detail)
steembase.exceptions.RPCError: unspecified error from api.usesteem.com (Invalid Request) in get_dynamic_global_properties
holgern commented 6 years ago

api.usesteem.com shows a blockchain version number of 0.19.10 but does not support the new appbase json format. Thus, it works for Furion's version of Steem-python and not for 1.0.1.

stm.rpc.current_rpc=1 sets the steem-object to the old json format:

stm = Steem(node="https://api.usesteem.com")
stm.rpc.current_rpc=1
stm.get_dynamic_global_properties()
{'average_block_size': 13158,
 'confidential_sbd_supply': '0.000 SBD',
 'confidential_supply': '0.000 STEEM',
 'current_aslot': 24481578,
 'current_reserve_ratio': 200000000,
 'current_sbd_supply': '15564519.367 SBD',
 'current_supply': '272076901.522 STEEM',
 'current_witness': 'jesta',
 'head_block_id': '017461d1aef91b2f510fa578edf24ab4993d0860',
 'head_block_number': 24404433,
 'last_irreversible_block_num': 24404418,
 'max_virtual_bandwidth': '264241152000000000000',
 'maximum_block_size': 65536,
 'num_pow_witnesses': 172,
 'participation_count': 128,
 'pending_rewarded_vesting_shares': '380064561.448550 VESTS',
 'pending_rewarded_vesting_steem': '185763.563 STEEM',
 'recent_slots_filled': '340282366920938463463374607431768211455',
 'sbd_interest_rate': 0,
 'sbd_print_rate': 3933,
 'time': '2018-07-22T17:18:54',
 'total_pow': 514415,
 'total_reward_fund_steem': '0.000 STEEM',
 'total_reward_shares2': '0',
 'total_vesting_fund_steem': '192936786.204 STEEM',
 'total_vesting_shares': '391224302733.522646 VESTS',
 'virtual_supply': '282900628.480 STEEM',
 'vote_power_reserve_rate': 10}
officiallymarky commented 6 years ago

I am using Jussi with translate AppBase option True. Which I believe api.steemit.com does. I tried with and without this.

Right now api.usesteem.com points to api.steemit.com and is not using translate appbase because it already translates and the errors using my own appbase nodes.

The other reason it is not currently pointing to my own nodes is Jussi does not specifying port numbers and I was trying to eliminate nginx from the equation.

officiallymarky commented 6 years ago

It seems the error only happens when using s = Steem(nodes=['']) but not s = Steem(node="")

holgern commented 6 years ago
s = Steem(node="https://api.usesteem.com")
s.url

'https://api.steemit.com'

s = Steem(node=["https://api.usesteem.com"])
s.url

'https://api.steemit.com'

from steembase.http_client import HttpClient
rpc = HttpClient("https://api.usesteem.com")
rpc.url

'h'

So only Steem(nodes=["https://api.usesteem.com"]) or Steem(["https://api.usesteem.com"]) will work