safe-eth-py: estimate_tx_gas failing on xDai with AttributeError: 'str' object has no attribute 'keys'
Describe the bug
The estimation of gas fees for Safe transactions fails on xDai with the following exception: AttributeError: 'str' object has no attribute 'keys'. This error is also occurring in the relayer breaking all estimates.
To Reproduce
Use the following code to reproduce:
from gnosis.eth import EthereumClient
from gnosis.safe import Safe
ethereum_client = EthereumClient('https://xdai.poanetwork.dev')
safe = Safe('0x9a0bbbbd3789f184CA88f2F6A40F42406cb842AC', ethereum_client)
result = safe.estimate_tx_gas('0x333d72F54CF17BA7A1971e7C7E9acB91C8B709d2', 0, '0xa2e62045', 0)
print(result)
Executing this code throws the following exception:
Traceback (most recent call last):
File "/home/adz/.pyenv/versions/safe-estimate-issue/lib/python3.8/site-packages/gnosis/safe/safe.py", line 436, in estimate_tx_gas_with_safe
result: HexBytes = self.w3.eth.call(tx, block_identifier=block_identifier)
File "/home/adz/.pyenv/versions/safe-estimate-issue/lib/python3.8/site-packages/web3/module.py", line 58, in caller
result = w3.manager.request_blocking(method_str, params, error_formatters)
File "/home/adz/.pyenv/versions/safe-estimate-issue/lib/python3.8/site-packages/web3/manager.py", line 158, in request_blocking
raise ValueError(response["error"])
ValueError: {'code': -32015, 'message': 'VM execution error.', 'data': 'revert: \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00??'}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 14, in <module>
result = safe.estimate_tx_gas('0x333d72F54CF17BA7A1971e7C7E9acB91C8B709d2', 0, '0xa2e62045', 0)
File "/home/adz/.pyenv/versions/safe-estimate-issue/lib/python3.8/site-packages/gnosis/safe/safe.py", line 521, in estimate_tx_gas
return self.estimate_tx_gas_by_trying(to, value, data, operation) + PROXY_GAS + OLD_CALL_GAS
File "/home/adz/.pyenv/versions/safe-estimate-issue/lib/python3.8/site-packages/gnosis/safe/safe.py", line 490, in estimate_tx_gas_by_trying
gas_estimated = self.estimate_tx_gas_with_safe(to, value, data, operation)
File "/home/adz/.pyenv/versions/safe-estimate-issue/lib/python3.8/site-packages/gnosis/safe/safe.py", line 456, in estimate_tx_gas_with_safe
key = list(data_dict.keys())[0]
AttributeError: 'str' object has no attribute 'keys'
Expected behavior
The revert is happening as expected but seems to be not parseable in the catch phrase. I assume that the revert message looks slightly different on xDai than on mainnet?
Some more observations
- The code in
gnosis-pychecks for an capitalized “Reverted …” data message, the xdai response is lowercase and “revert: …”? https://github.com/gnosis/gnosis-py/blob/master/gnosis/safe/safe.py#L451 - The returned bytecode in
datacontains invalid values (here it is??).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (9 by maintainers)
Commits related to this issue
- Handle Geth v1.9.25 revert issue Relates to #26 — committed to safe-global/safe-eth-py by Uxio0 3 years ago
@Uxio0 thx for your response. Yes, I think we have something wrong there. I will analyze it 😃
@adzialocha I’m closing this as there’s nothing I can do. This should be reported to the Geth team, but they might tell you you need to run an updated version of the node
I’m trying:
POST https://rpc.xdaichain.com/Result:
Version of the node
Geth/v1.8.15-omnibus-255989da/linux-amd64/go1.10.1Looks like this bug is related to Geth. I will push a fix to gnosis-py so it raises a controlled exception
Hi @adzialocha @Uxio0
I’m from the Nethermind - eth client team.
“The code in gnosis-py checks for an capitalized “Reverted …” data message, the xdai response is lowercase and “revert: …”? https://github.com/gnosis/gnosis-py/blob/master/gnosis/safe/safe.py#L451”
It could be a lack of standardization of Etherheum clients. Different clients could return different error messages. There is a lot of discussion in the ethereum community to standardize JSON RPC more. You can observe this project and propose your improvements here: https://github.com/ethereum-oasis/eth1.x-JSON-RPC-API-standard Our client returns an error message like: “revert” and I suppose that the parity client return “Reverted”.
“The returned bytecode in data contains invalid values (here it is ??).”
That is interesting I checked with @adzialocha parameters that Nethermind returns a concrete number. I am not sure if it was our node or the parity node. However, if @Uxio0 you debug this issue and you will have a JSON RPC request I am eager to check it on our side too.
Currently all requests calling
POST@https://relay.circles.garden/api/v2/safes/:safeAddress/transactions/estimate/are failing with this error.A request which fails:
Method:
POSTURL:
https://relay.circles.garden/api/v2/safes/0x9a0bbbbd3789f184CA88f2F6A40F42406cb842AC/transactions/estimate/Body:
Response: