-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: handle failed tx execution #153
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IMO we should add console colors in another PR |
nerfZael
reviewed
Apr 8, 2024
self.manager.send_tx_batch(self.transactions, require_approval=not non_interactive) | ||
try: | ||
self.manager.send_tx_batch(self.transactions, require_approval=not non_interactive) | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this if we have the other catch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah - otherwise the error shows like this:
Batched transactions:
1. Transfer 1000 USDC to vitalik.eth(0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045) (nonce: 8)
Do you want to execute the above transactions? (y/n): y
Executing transactions...
Traceback (most recent call last):
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/gnosis/safe/safe.py", line 819, in estimate_tx_gas
self.estimate_tx_gas_by_trying(to, value, data, operation)
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/gnosis/safe/safe.py", line 760, in estimate_tx_gas_by_trying
gas_estimated = self.estimate_tx_gas_with_safe(to, value, data, operation)
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/gnosis/safe/safe.py", line 716, in estimate_tx_gas_with_safe
return parse_revert_data(
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/gnosis/safe/safe.py", line 673, in parse_revert_data
raise CannotEstimateGas("Received %s for tx=%s" % (result.hex(), tx))
gnosis.safe.exceptions.CannotEstimateGas: Received 0x for tx={'value': 0, 'chainId': 1, 'from': '0x4eB0b19553A892589CF21aAB9A22E82188EE90bA', 'gas': 0, 'gasPrice': 0, 'to': '0x4eB0b19553A892589CF21aAB9A22E82188EE90bA', 'data': '0xc4ca3a9c000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045000000000000000000000000000000000000000000000000000000003b9aca0000000000000000000000000000000000000000000000000000000000'}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/gnosis/safe/safe.py", line 732, in estimate_tx_gas_with_web3
return self.ethereum_client.estimate_gas(
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/gnosis/eth/ethereum_client.py", line 1497, in estimate_gas
return self.w3.eth.estimate_gas(tx, block_identifier=block_identifier)
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/web3/eth/eth.py", line 316, in estimate_gas
return self._estimate_gas(transaction, block_identifier, state_override)
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/web3/module.py", line 75, in caller
result = w3.manager.request_blocking(
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/web3/manager.py", line 329, in request_blocking
return self.formatted_response(
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/web3/manager.py", line 290, in formatted_response
apply_error_formatters(error_formatters, response)
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/web3/manager.py", line 103, in apply_error_formatters
formatted_resp = pipe(response, error_formatters)
File "cytoolz/functoolz.pyx", line 680, in cytoolz.functoolz.pipe
File "cytoolz/functoolz.pyx", line 655, in cytoolz.functoolz.c_pipe
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/web3/_utils/error_formatters_utils.py", line 162, in raise_contract_logic_error_on_revert
raise ContractLogicError(message, data=data)
web3.exceptions.ContractLogicError: ('execution reverted: revert: ERC20: transfer amount exceeds balance', '0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002645524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63650000000000000000000000000000000000000000000000000000')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/cesar/dev/polywrap/auto-tx/autotx/utils/ethereum/SafeManager.py", line 157, in execute_tx
safe_tx = self.build_tx(tx, safe_nonce)
File "/home/cesar/dev/polywrap/auto-tx/autotx/utils/ethereum/SafeManager.py", line 147, in build_tx
safe_tx.safe_tx_gas = self.safe.estimate_tx_gas(safe_tx.to, safe_tx.value, safe_tx.data, safe_tx.operation)
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/gnosis/safe/safe.py", line 824, in estimate_tx_gas
self.estimate_tx_gas_with_web3(to, value, data)
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/gnosis/safe/safe.py", line 736, in estimate_tx_gas_with_web3
raise CannotEstimateGas(
gnosis.safe.exceptions.CannotEstimateGas: Cannot estimate gas with `eth_estimateGas`: ('execution reverted: revert: ERC20: transfer amount exceeds balance', '0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002645524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63650000000000000000000000000000000000000000000000000000')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/cesar/dev/polywrap/auto-tx/autotx/utils/ethereum/SafeManager.py", line 274, in send_tx_batch
self.send_tx(prepared_tx.tx, start_nonce + i)
File "/home/cesar/dev/polywrap/auto-tx/autotx/utils/ethereum/SafeManager.py", line 223, in send_tx
hash = self.execute_tx(tx, safe_nonce)
File "/home/cesar/dev/polywrap/auto-tx/autotx/utils/ethereum/SafeManager.py", line 173, in execute_tx
raise ExecutionRevertedError(extracted_message.group(0))
autotx.utils.ethereum.SafeManager.ExecutionRevertedError: revert: ERC20: transfer amount exceeds balance'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/bin/ask", line 6, in <module>
sys.exit(run())
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/cesar/.cache/pypoetry/virtualenvs/autotx-qxA8drhO-py3.10/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/home/cesar/dev/polywrap/auto-tx/autotx/cli.py", line 72, in run
autotx.run(prompt, non_interactive)
File "/home/cesar/dev/polywrap/auto-tx/autotx/AutoTx.py", line 80, in run
self.manager.send_tx_batch(self.transactions, require_approval=not non_interactive)
File "/home/cesar/dev/polywrap/auto-tx/autotx/utils/ethereum/SafeManager.py", line 276, in send_tx_batch
raise Exception(f"{prepared_tx.summary} failed with error: {e}")
Exception: Transfer 1000 USDC to vitalik.eth(0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045) failed with error: revert: ERC20: transfer amount exceeds balance'
nerfZael
approved these changes
Apr 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this PR aims to show the error thrown from contract, instead of showing the entire logs
example:
send transfer without enough balance
swap token without enough balance
this is a first iteration, i am thinking how we might improve this... i tried to do an LLM call passing the error but it might not be very efficient