GolosChain / golos-python

Official Python Library for Golos Blockchain
MIT License
3 stars 4 forks source link

[0.16.4] broadcast_transaction API call not working with LOW_MEM nodes #9

Open bitphage opened 6 years ago

bitphage commented 6 years ago

I tried to use golos-python with my LOWMEM node and I found that sending transactions is not working.

Looks like that:

% ./test_transfer.py -d                                                             
Format GLS unkown. You've been warned!

Format GLS unkown. You've been warned!

Format GLS unkown. You've been warned!

Format GLS unkown. You've been warned!

Format GLS unkown. You've been warned!

Traceback (most recent call last):
  File "./test_transfer.py", line 59, in <module>
    main()
  File "./test_transfer.py", line 56, in main
    c.transfer(me, amount, asset, memo='test', account=to)
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steem/commit.py", line 607, in transfer
    return self.finalizeOp(op, account, "active")
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steem/commit.py", line 128, in finalizeOp
    return tx.broadcast()
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steem/transactionbuilder.py", line 131, in broadcast
    raise e
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steem/transactionbuilder.py", line 129, in broadcast
    self.steemd.broadcast_transaction(self.json())
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steem/steemd.py", line 857, in broadcast_transaction
    return self.exec('broadcast_transaction', signed_transaction, api='network_broadcast_api')
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steembase/http_client.py", line 186, in exec
    return_with_args=return_with_args)
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steembase/http_client.py", line 206, in _return
    raise RPCError(error_message)
steembase.exceptions.RPCError: 10 assert_exception: Assert Exception
itr != _by_name.end(): no method with name 'broadcast_transaction'
    {"name":"broadcast_transaction","api":{"cancel_all_subscriptions":3,"get_account_bandwidth":47,"get_account_count":40,"get_account_history":42,"get_account_references":37,"get_account_votes":60,"get_accounts":36,"get_active_categories":25,"get_active_votes":59,"get_active_witnesses":70,"get_best_categories":24,"get_block":20,"get_block_header":19,"get_chain_properties":29,"get_config":27,"get_content":61,"get_content_replies":62,"get_conversion_requests":41,"get_current_median_history_price":31,"get_discussions_by_active":9,"get_discussions_by_author_before_date":63,"get_discussions_by_blog":16,"get_discussions_by_cashout":10,"get_discussions_by_children":13,"get_discussions_by_comments":17,"get_discussions_by_created":8,"get_discussions_by_feed":15,"get_discussions_by_hot":14,"get_discussions_by_payout":11,"get_discussions_by_promoted":18,"get_discussions_by_trending":6,"get_discussions_by_trending30":7,"get_discussions_by_votes":12,"get_dynamic_global_properties":28,"get_escrow":45,"get_feed_history":30,"get_hardfork_version":33,"get_key_references":35,"get_liquidity_queue":52,"get_miner_queue":71,"get_next_scheduled_hardfork":34,"get_open_orders":51,"get_ops_in_block":21,"get_order_book":50,"get_owner_history":43,"get_potential_signatures":56,"get_recent_categories":26,"get_recovery_request":44,"get_replies_by_last_update":64,"get_required_signatures":55,"get_savings_withdraw_from":48,"get_savings_withdraw_to":49,"get_state":22,"get_tags_used_by_author":5,"get_transaction":54,"get_transaction_hex":53,"get_trending_categories":23,"get_trending_tags":4,"get_withdraw_routes":46,"get_witness_by_account":66,"get_witness_count":69,"get_witness_schedule":32,"get_witnesses":65,"get_witnesses_by_vote":67,"lookup_account_names":38,"lookup_accounts":39,"lookup_witness_accounts":68,"set_block_applied_callback":2,"set_pending_transaction_callback":1,"set_subscribe_callback":0,"verify_account_authority":58,"verify_authority":57}}
    th_a  api_connection.hpp:109 call

    {"call.method":"call","call.params":["network_broadcast_api","broadcast_transaction",[{"ref_block_num":54866,"ref_block_prefix":1732035025,"expiration":"2018-01-31T16:48:33","operations":[["transfer",{"from":"vvk","to":"vvk2","amount":"0.001 GBG","memo":"test"}]],"extensions":[],"signatures":["1f59092e143f6f98ece5a515c0be194cfb0369b8d59ccfb483ea741f87346e6184589bb0bc02f84d398e1902fa4a53b503aa82b58da9f2a4dd173b4d9c3388dbb1"]}]]}
    th_a  websocket_api.cpp:124 on_message

Although piston-lib doesn't have such problems. I added a print() call to grapheneapi/graphenewsrpc.py to compare piston-lib generated call:

{'method': 'call', 'params': [3, 'broadcast_transaction', [{'ref_block_num': 54946, 'ref_block_prefix': 2341132026, 'expiration': '2018-01-31T16:51:54', 'operations': [['transfer', {'from': 'vvk', 'to': 'vvk2', 'amount': '0.001 GBG', 'memo': 'test'}]], 'extensions': [], 'signatures': ['1f3f083d368bc7bacc0e673b95ee0a8210310727f99ee729de3207c31421be14817abe8ef6e25c68518bcf366e583cec8cb679b1e47aed793049ff22840434eb9f']}]], 'jsonrpc': '2.0', 'id': 9}

Interesting that I'm not getting such problem whether use vik's node api.golos.cf.

If I set params[0] to API id, same as piston-lib, I'm getting another error:

b'{"jsonrpc": "2.0", "id": 0, "method": "call", "params": [3, "broadcast_transaction", [{"ref_block_num": 55112, "ref_block_prefix": 2488664819, "expiration": "2018-01-31T17:00:52", "operations": [["transfer", {"from": "vvk", "to": "vvk2", "amount": "0.001 GBG", "memo": "test"}]], "extensions": [], "signatures": ["20299906d2489b183e5aad53ef60452973951e485f7b06542243b9586a7a8b70be3a7ccd143edc8070cb71e6d8e563d8ed5431f5c6c5f2e9dd241af127a4542714"]}]]}'
Traceback (most recent call last):
  File "./test_transfer.py", line 59, in <module>
    main()
  File "./test_transfer.py", line 56, in main
    c.transfer(me, amount, asset, memo='test', account=to)
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steem/commit.py", line 607, in transfer
    return self.finalizeOp(op, account, "active")
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steem/commit.py", line 128, in finalizeOp
    return tx.broadcast()
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steem/transactionbuilder.py", line 131, in broadcast
    raise e
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steem/transactionbuilder.py", line 129, in broadcast
    self.steemd.broadcast_transaction(self.json())
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steem/steemd.py", line 857, in broadcast_transaction
    return self.exec('broadcast_transaction', signed_transaction, api=3)
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steembase/http_client.py", line 187, in exec
    return_with_args=return_with_args)
  File "/home/vvk/devel/golos/scripts/venv/lib/python3.6/site-packages/steembase/http_client.py", line 207, in _return
    raise RPCError(error_message)
steembase.exceptions.RPCError: 10 assert_exception: Assert Exception
_local_apis.size() > api_id: 
    {}
    th_a  api_connection.hpp:229 receive_call
bitphage commented 6 years ago

Success calls by piston-lib:

% ./transfer.py vvk vvk2 0.001 GBG test --broadcast                                 
{'method': 'call', 'params': [1, 'login', ['', '']], 'jsonrpc': '2.0', 'id': 1}        
{'method': 'call', 'params': [1, 'get_api_by_name', ['database_api']], 'jsonrpc': '2.0', 'id': 2}
{'method': 'call', 'params': [1, 'get_api_by_name', ['network_broadcast_api']], 'jsonrpc': '2.0', 'id': 3}
{'method': 'call', 'params': [0, 'get_dynamic_global_properties', []], 'jsonrpc': '2.0', 'id': 4}
{'method': 'call', 'params': [1, 'get_api_by_name', ['account_by_key_api']], 'jsonrpc': '2.0', 'id': 5}
2018-01-31 22:07:24,157 INFO: transferring to vvk2: 0.001 GBG
{'method': 'call', 'params': [0, 'get_dynamic_global_properties', []], 'jsonrpc': '2.0', 'id': 6}
{'method': 'call', 'params': [0, 'get_accounts', [['vvk']]], 'jsonrpc': '2.0', 'id': 7}
{'method': 'call', 'params': [0, 'verify_authority', [{'ref_block_num': 55266, 'ref_block_prefix': 795308792, 'expiration': '2018-01-31T17:07:54', 'operations': [['transfer', {'from': 'vvk', 'to': 'vvk2', 'amount': '0.001 GBG', 'memo': 'test'}]], 'extensions': [], 'signatures': ['1f62d603951d51e29abca0b7c00a609b07c494c4771b357230c10dacf1c62e88197828cb8f9afd7628fcf0703d05826a075a1fcb39f4c20b1330ab2bd48ec7d9d7']}]], 'jsonrpc': '2.0', 'id': 8}
{'method': 'call', 'params': [3, 'broadcast_transaction', [{'ref_block_num': 55266, 'ref_block_prefix': 795308792, 'expiration': '2018-01-31T17:07:54', 'operations': [['transfer', {'from': 'vvk', 'to': 'vvk2', 'amount': '0.001 GBG', 'memo': 'test'}]], 'extensions': [], 'signatures': ['1f62d603951d51e29abca0b7c00a609b07c494c4771b357230c10dacf1c62e88197828cb8f9afd7628fcf0703d05826a075a1fcb39f4c20b1330ab2bd48ec7d9d7']}]], 'jsonrpc': '2.0', 'id': 9}

Failed calls by golos-python:

% ./test_transfer.py -d
Format GLS unkown. You've been warned!                     

Format GLS unkown. You've been warned!

Format GLS unkown. You've been warned!

Format GLS unkown. You've been warned!

Format GLS unkown. You've been warned!

b'{"jsonrpc": "2.0", "id": 0, "method": "call", "params": ["database_api", "get_dynamic_global_properties", []]}'
b'{"jsonrpc": "2.0", "id": 0, "method": "call", "params": ["database_api", "get_block", [13490122]]}'
b'{"jsonrpc": "2.0", "id": 0, "method": "get_accounts", "params": [["vvk"]]}'
b'{"jsonrpc": "2.0", "id": 0, "method": "call", "params": ["database_api", "get_dynamic_global_properties", []]}'
b'{"jsonrpc": "2.0", "id": 0, "method": "call", "params": ["database_api", "get_dynamic_global_properties", []]}'
b'{"jsonrpc": "2.0", "id": 0, "method": "call", "params": ["database_api", "verify_authority", [{"ref_block_num": 55241, "ref_block_prefix": 863592093, "expiration": "2018-01-31T17:07:19", "operations": [["transfer", {"from": "vvk", "to": "vvk2", "amount": "0.001 GBG", "memo": "test"}]], "extensions": [], "signatures": ["1f6f7ace6beb1945a6b793faa45518b0bedbc67d436630da0e9c07c33427e4979a01cd80a8a455fcaf55c655ab44e8a26083a2bbddba66cf9fd1c2a71f220b6789"]}]]}'
b'{"jsonrpc": "2.0", "id": 0, "method": "call", "params": [3, "broadcast_transaction", [{"ref_block_num": 55241, "ref_block_prefix": 863592093, "expiration": "2018-01-31T17:07:19", "operations": [["transfer", {"from": "vvk", "to": "vvk2", "amount": "0.001 GBG", "memo": "test"}]], "extensions": [], "signatures": ["1f6f7ace6beb1945a6b793faa45518b0bedbc67d436630da0e9c07c33427e4979a01cd80a8a455fcaf55c655ab44e8a26083a2bbddba66cf9fd1c2a71f220b6789"]}]]}'
Traceback (most recent call last):