ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
897 stars 133 forks source link

Error handling revert during gas estimation #2341

Closed fubuloubu closed 1 month ago

fubuloubu commented 1 month ago

Have you ensured that all of these are up to date?

What version of Ape are you on?

0.8.17

What command(s) is the bug in?

silverback

Operating System

Windows

Description

Traceback (most recent call last):
  File "site-packages/ape_ethereum/provider.py", line 343, in estimate_gas_cost
    return self.web3.eth.estimate_gas(txn_params, block_identifier=block_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/web3/eth/eth.py", line 316, in estimate_gas
    return self._estimate_gas(transaction, block_identifier, state_override)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/web3/module.py", line 75, in caller
    result = w3.manager.request_blocking(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/web3/manager.py", line 330, in request_blocking
    return self.formatted_response(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/web3/manager.py", line 291, in formatted_response
    apply_error_formatters(error_formatters, response)
  File "site-packages/web3/manager.py", line 104, in apply_error_formatters
    formatted_resp = pipe(response, error_formatters)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "cytoolz/functoolz.pyx", line 685, in cytoolz.functoolz.pipe
  File "cytoolz/functoolz.pyx", line 660, in cytoolz.functoolz.c_pipe
  File "site-packages/web3/_utils/error_formatters_utils.py", line 165, in raise_contract_logic_error_on_revert
    raise ContractLogicError("execution reverted", data=data)
web3.exceptions.ContractLogicError: ('execution reverted', 'no data')

During handling of the above exception, another exception occurred:
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "~/.local/bin/silverback", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/ape/cli/commands.py", line 98, in invoke
    return self._invoke(ctx, provider=provider)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/ape/cli/commands.py", line 135, in _invoke
    return ctx.invoke(self.callback or (lambda: None), **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/silverback/_click_ext.py", line 216, in add_auth
    return ctx.invoke(f, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/silverback/_click_ext.py", line 250, in get_platform_client
    return ctx.invoke(f, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/silverback/_cli.py", line 591, in cancel_payment_stream
    stream.cancel(sender=account)
  File "site-packages/ape/contracts/base.py", line 431, in __call__
    return contract_transaction(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/ape/contracts/base.py", line 364, in __call__
    return kwargs["sender"].call(txn, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/ape/api/accounts.py", line 147, in call
    txn = self.prepare_transaction(txn)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/ape/api/accounts.py", line 399, in prepare_transaction
    txn = self.provider.prepare_transaction(txn)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/ape_ethereum/provider.py", line 982, in prepare_transaction
    gas = self.estimate_gas_cost(txn)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/ape_ethereum/provider.py", line 354, in estimate_gas_cost
    tx_error = self.get_virtual_machine_error(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/ape_ethereum/provider.py", line 1213, in get_virtual_machine_error
    return self._handle_execution_reverted(exception, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages/ape_ethereum/provider.py", line 1281, in _handle_execution_reverted
    if trace is not None and (revert_message := trace.revert_message):
                                                ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'function' object has no attribute 'revert_message'

Reproduction code

was using the new silverback cluster pay commands (specifically cancelling prior to the 1hr cooldown on first funding)

linear[bot] commented 1 month ago

APE-1846 Error handling revert during gas estimation

fubuloubu commented 1 month ago

By the way, this is using uv tool

antazoey commented 1 month ago

Specifically this bug occurs when the revert has no message.