autonity / aut

A command-line RPC client for Autonity
MIT License
11 stars 10 forks source link

unexpected behaviour of `aut node info` while node is syncing #94

Closed lorenzo-dev1 closed 1 year ago

lorenzo-dev1 commented 1 year ago

aut node info works fine if the node is already synced. However if called while syncing up a node it produces this output:

$ aut node info --rpc-endpoint="http://localhost:8560"
TypeError: Object of type AttributeDict is not JSON serializable

I suspect it is because eth_syncing returns the result in a different format based on whether the node is syncing or not.

if the node is syncing:

$ curl --silent --location --request GET 'localhost:8560' --header 'Content-Type: application/json' --data-raw '{
        "jsonrpc":"2.0",
        "method":"eth_syncing", "params":[],
        "id":1}' | jq
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "currentBlock": "0x18000",
    "healedBytecodeBytes": "0x0",
    "healedBytecodes": "0x0",
    "healedTrienodeBytes": "0x800",
    "healedTrienodes": "0xa",
    "healingBytecode": "0x0",
    "healingTrienodes": "0x0",
    "highestBlock": "0xbe253",
    "startingBlock": "0x0",
    "syncedAccountBytes": "0x1227",
    "syncedAccounts": "0x11",
    "syncedBytecodeBytes": "0x0",
    "syncedBytecodes": "0x0",
    "syncedStorage": "0xa3",
    "syncedStorageBytes": "0x9514"
  }
}

If the node is not syncing:

$ curl --silent --location --request GET 'localhost:8560' --header 'Content-Type: application/json' --data-raw '{
        "jsonrpc":"2.0",
        "method":"eth_syncing", "params":[],
        "id":1}' | jq
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": false
}
cmjc commented 1 year ago

Fixed by PR https://github.com/autonity/aut/pull/109#event-9060232026 merged into develop.