Skip to content

Commit

Permalink
Handle out of gas
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Dec 2, 2024
1 parent ae91ae4 commit df69d0f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions eth_defi/confirmation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class BadChainId(NonRetryableBroadcastException):
"""Out of gas funds for an executor."""


def is_out_of_gas(eth_rpc_error_messag: str) -> bool:
return "insufficient funds" in eth_rpc_error_messag


def wait_transactions_to_complete(
web3: Web3,
txs: List[Union[HexBytes, str]],
Expand Down Expand Up @@ -926,6 +930,11 @@ def wait_and_broadcast_multiple_nodes_mev_blocker(
nonce = web3.eth.get_transaction_count(tx.address)
logger.info("No receipt yet, current nonce: %d, exception %s", nonce, e, exc_info=e)
last_exception = e

if is_out_of_gas(str(e)):
# Out of gas situation we can never recover
raise OutOfgGasFunds(f"Run out of gas: {e}") from e

time.sleep(poll_delay.total_seconds())

if time.time() > end:
Expand Down

0 comments on commit df69d0f

Please sign in to comment.