polkascan / py-substrate-interface

Python Substrate Interface
https://polkascan.github.io/py-substrate-interface/
Apache License 2.0
240 stars 116 forks source link

SubstrateRequestException: Unknown error occurred on get_block_extrinsics() #69

Closed skinderis closed 3 years ago

skinderis commented 3 years ago

I get SubstrateRequestException errors on Westend node while trying to call get_block_extrinsics.

substrate.get_block_extrinsics(block_id=4138353)

SubstrateRequestException                 Traceback (most recent call last)
<ipython-input-27-167946c23dbb> in <module>
----> 1 substrate.get_block_extrinsics(block_id=4138353)

/usr/local/lib/python3.8/site-packages/substrateinterface/base.py in get_block_extrinsics(self, block_hash, block_id, ignore_decoding_errors)
   2183         list
   2184         """
-> 2185         self.init_runtime(block_hash=block_hash, block_id=block_id)
   2186 
   2187         response = self.rpc_request("chain_getBlock", [self.block_hash])

/usr/local/lib/python3.8/site-packages/substrateinterface/base.py in init_runtime(self, block_hash, block_id)
   1062             runtime_block_hash = parent_block_hash
   1063 
-> 1064         runtime_info = self.get_block_runtime_version(block_hash=runtime_block_hash)
   1065 
   1066         if runtime_info is None:

/usr/local/lib/python3.8/site-packages/substrateinterface/base.py in get_block_runtime_version(self, block_hash)
    920 
    921         if 'error' in response:
--> 922             raise SubstrateRequestException(response['error']['message'])
    923 
    924         return response.get('result')

SubstrateRequestException: Unknown error occurred

I think it because it's another runtime, but how can I access blocks data of past runtimes?

skinderis commented 3 years ago

It because here:

    917 
    918         """
--> 919         response = self.rpc_request("chain_getRuntimeVersion", [block_hash])
    920 
    921         if 'error' in response:

response is: {'jsonrpc': '2.0', 'error': {'code': -32603, 'message': 'Unknown error occurred', 'data': 'Client(UnknownBlock("State already discarded for BlockId::Hash(0x39fd73b41d6fc74e390e00c5c43b458ee56feb21a37b951af0643edf661f1ab7)"))'}, 'id': 4}

How can I get decoded data from blocks that are returning this response?

skinderis commented 3 years ago

Closing, as it's not related to py-substrate-interface, this happens because I am running light node