Repository: rotki/rotki

Issue:
Polygon RPC node connection: '<' not supported between instances of 'AttributeDict' and 'int'
## Problem Definition

This frontend popup happened once for 2 polygon RPC nodes in my laptop(slow + bad connection) but not in the desktop. Also same nodes.

![2023-06-29_08-06](https://github.com/rotki/rotki/assets/1658405/971fc94b-50be-4ba1-9601-72627492be04)


```
Attempt connection to polygon_pos node DefiLlama died with exception: '<' not supported between instances of 'AttributeDict' and 'int'. Check the logs for more details
```

Note the discrepancy in the logs. It's possible the logs are wrong in the name of the chain.

## Logs

```
[29/06/2023 07:52:08 CEST] DEBUG rotkehlchen.chain.ethereum.node_inquirer Greenlet-7: ETH highest block result block=17582995
[29/06/2023 07:52:08 CEST] ERROR rotkehlchen.greenlets.manager Greenlet with id 139743897168128: Attempt connection to ethereum node LlamaNodes died with exception: '<' not supported between instances of 'AttributeDict' and 'int'.
Exception Name: <class 'TypeError'>
Exception Info: '<' not supported between instances of 'AttributeDict' and 'int'
Traceback:
   File "src/gevent/greenlet.py", line 908, in gevent._gevent_cgreenlet.Greenlet.run
  File "rotkehlchen/chain/evm/node_inquirer.py", line 449, in attempt_connect
  File "rotkehlchen/chain/evm/node_inquirer.py", line 89, in _is_synchronized

[29/06/2023 07:52:08 CEST] ERROR rotkehlchen.user_messages Greenlet with id 139743897168128: Attempt connection to ethereum node LlamaNodes died with exception: '<' not supported between instances of 'AttributeDict' and 'int'. Check the logs for more details
[29/06/2023 07:52:08 CEST] DEBUG web3.providers.HTTPProvider Getting response HTTP. URI: https://eth-mainnet.alchemyapi.io/v2/xxx, Method: net_version, Response: {'jsonrpc': '2.0', 'id': 1, 'result': '1'}
[29/06/2023 07:52:08 CEST] DEBUG web3.RequestManager Making request. Method: eth_blockNumber
```


### System Description


Operating system: Linux
Rotki version: 1.29



Discussion:
Okay so this is not really a problem with us. I would say it's a problem with llamanodes (as it happened for all of them) and with web3.py

1. I would expect web3.py to fail if `web3.eth.block_number` does not return an int. We should not have to check that type in our code.
2. Llama nodes returned a dictionary with lots more info instead of just an int as the rpc endpoint standard is supposed to.

Normal rpc call for blocknumber:
```
[29/06/2023 08:02:59 CEST] DEBUG web3.providers.HTTPProvider Getting response HTTP. URI: https://rpc.ankr.com/polygon, Method: eth_blockNumber, Response: {'jsonrpc': '2.0', 'id': 2, 'result': '0x2a680c4'}
```

Llamanodes:

```
[29/06/2023 08:02:59 CEST] DEBUG web3.providers.HTTPProvider Getting response HTTP. URI: https://polygon.llamarpc.com, Method: eth_blockNumber, Response: {'jsonrpc': '2.0', 'id': 2, 'result': {'age': {'nanos': 0, 'secs': 2}, 'block': {'hash': '0x61a47e4261e03831b80f4831acbdf45b516e2ca67eec6943a0adad9fdcc8cfb3', 'number': '0x2a680c4', 'parent_hash': '0x7a2c17f0d6c711ffc668956cae044cde68b3d4bfee416b929230aca2871e7735', 'timestamp': '0x649d1e91'}}}
```

Resolving patch:
diff --git a/rotkehlchen/chain/evm/node_inquirer.py b/rotkehlchen/chain/evm/node_inquirer.py
--- a/rotkehlchen/chain/evm/node_inquirer.py
+++ b/rotkehlchen/chain/evm/node_inquirer.py
@@ -440,6 +440,8 @@ def attempt_connect(
 
                     try:
                         current_block = web3.eth.block_number  # pylint: disable=no-member
+                        if isinstance(current_block, int) is False:  # Check for https://github.com/rotki/rotki/issues/6350  # TODO: Check if web3.py v6 has a check for this # noqa: E501
+                            raise RemoteError(f'Found non-int current block:{current_block}')
                         latest_block = self.query_highest_block()
                     except (requests.exceptions.RequestException, RemoteError) as e:
                         msg = f'Could not query latest block due to {e!s}'


Test patch: