software-mansion/starknet.py

[BUG] <Message: Invalid params. Data: {'reason': 'unknown field `simulation_flags`, " "expected `request` or `block_id` at line 1 column 1060'}>

ManutdGTA opened this issue · 3 comments

What happened

code run normal in node server 0_6_0,but the error occured in alchemy and infura

Stack trace

Starknet_RPC_list = [
    # 'https://starknet-mainnet.infura.io/v3/',
    # 'https://starknet-mainnet.g.alchemy.com/v2/'
    # pathfinder'http://192.168.100.181:9545/rpc/v0_6'
    # juno 'http://192.168.100.183:6060/rpc/v0_6'

]

result = random.choice(Starknet_RPC_list)
client = FullNodeClient(result)
estimate = await account.client.estimate_fee(transaction)```

('Traceback (most recent call last):\n'
' File '
'"code//stark_net/projects/starknet_methods.py", '
'line 33, in async_retry\n'
' result = await func(**kwargs)\n'
' File '
'"code//stark_net/projects/starknet_methods.py", '
'line 81, in _build_sign_send\n'
' estimate = await account.client.estimate_fee(transaction)\n'
' File '
'"anaconda3/envs//lib/python3.10/site-packages/starknet_py/net/full_node_client.py", '
'line 360, in estimate_fee\n'
' res = await self._client.call(\n'
' File '
'"anaconda3/envs//lib/python3.10/site-packages/starknet_py/net/http_client.py", '
'line 75, in call\n'
' self.handle_rpc_error(result)\n'
' File '
'"anaconda3/envs//lib/python3.10/site-packages/starknet_py/net/http_client.py", '
'line 82, in handle_rpc_error\n'
' raise ClientError(\n'
'starknet_py.net.client_errors.ClientError: Client failed with code -32602. '
"Message: Invalid params. Data: {'reason': 'unknown field simulation_flags, "
"expected request or block_id at line 1 column 1060'}\n")


### Steps to reproduce

1. user `estimate = await account.client.estimate_fee(transaction)` in infura or alchemy

### SDK Version

0.19.0

### Python version

3.10.13

### What operating system are you using?

Mac

### Is there an existing issue for this?

- [X] I have searched the existing issues and verified no issue exits for this problem.

Are you sure that you use RPC 0.6.0 (alchemy and infura)? simulation_flags was added in 0.6.0. If you want to use RPC 0.5 the recommended version of starknet.py will be 0.18.2

Had the same issue with alchemy provider
Req:

{
  "jsonrpc": "2.0",
  "method": "starknet_estimateFee",
  "id": 0,
  "params": {
    "request": [
      {
        "type": "INVOKE",
        "version": "0x100000000000000000000000000000003",
        "signature": [
          "0x4e66d21d3d7f3114feb4e71e58e45ae0822eab8942770e163a285ed270aad7b",
          "0x7386eeb3be2626b055d6938780ef4a995ec28c51127325abc91d215a47d4278"
        ],
        "nonce": "0x6e",
        "tip": "0x0",
        "nonce_data_availability_mode": "L1",
        "fee_data_availability_mode": "L1",
        "paymaster_data": [],
        "resource_bounds": {
          "l1_gas": {
            "max_amount": "0x0"
          }
        }
      }
    ]
  }
}

Res:

{
  "jsonrpc": "2.0",
  "id": 0,
  "error": {
    "code": -32602,
    "message": "Invalid params",
    "data": {
      "reason": "unknown field `simulation_flags`, expected `request` or `block_id` at line 1 column 2169"
    }
  }
}

In starknet-spec RPC 0.6.0 starknet_estimateFee has required param simulation_flags https://github.com/starkware-libs/starknet-specs/blob/159fb9c887402a96056dc405f374c4df27a14bf8/api/starknet_api_openrpc.json#L638. It seems to be a problem with alchemy. Probably they use an older version of the RPC. I suggest ensuring which version of RPC is used on Alchemy and using the relevant version of starknet.py