Skip to content

Commit

Permalink
Merge pull request #224 from bancorprotocol/223-access-list-handling-…
Browse files Browse the repository at this point in the history
…in-txhelpers-should-have-its-own-tryexcept

Add standalone try except for Access List and improve error logging
  • Loading branch information
NIXBNT committed Nov 23, 2023
2 parents 947f1e8 + d61876e commit 3a6e5e9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions fastlane_bot/helpers/txhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,11 @@ def build_transaction_with_gas(
nonce=nonce,
flashloan_struct=flashloan_struct)
except Exception as e:
self.ConfigObj.logger.debug(
self.ConfigObj.logger.info(
f"(***2***) Error when building transaction: {e.__class__.__name__} {e}")
else:
self.ConfigObj.logger.info(
f"(***2***) Error when building transaction: {e.__class__.__name__} {e}")
return None
if test_fake_gas:
transaction["gas"] = self.ConfigObj.DEFAULT_GAS
Expand All @@ -557,6 +559,12 @@ def build_transaction_with_gas(
self.web3.eth.estimate_gas(transaction=transaction)
+ self.ConfigObj.DEFAULT_GAS_SAFETY_OFFSET
)
except Exception as e:
self.ConfigObj.logger.info(
f"Failed to estimate gas for transaction because the transaction is likely fail. Most often this is due to an arb opportunity already being closed, but it can include other bugs. Exception: {e}"
)
return None
try:
if access_list:
access_list = self.get_access_list(transaction_data=transaction["data"], expected_gas=estimated_gas)

Expand All @@ -578,9 +586,8 @@ def build_transaction_with_gas(
self.ConfigObj.logger.info(f"Failed to apply access list to transaction")
except Exception as e:
self.ConfigObj.logger.info(
f"Failed to estimate gas due to exception {e}, scrapping transaction :(."
f"Failed to add Access List to transaction. This should not invalidate the transaction. Exception: {e}"
)
return None
transaction["gas"] = estimated_gas
return transaction

Expand Down

0 comments on commit 3a6e5e9

Please sign in to comment.