From d61876ebca4ea2a481f71dea9b3a47500167b18c Mon Sep 17 00:00:00 2001 From: Lesigh-3100 Date: Thu, 23 Nov 2023 17:09:07 +0200 Subject: [PATCH] Add standalone try except for Access List and improve error logging --- fastlane_bot/helpers/txhelpers.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fastlane_bot/helpers/txhelpers.py b/fastlane_bot/helpers/txhelpers.py index 05c3c487b..7821d09c2 100644 --- a/fastlane_bot/helpers/txhelpers.py +++ b/fastlane_bot/helpers/txhelpers.py @@ -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 @@ -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) @@ -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