From f3576a51b45015d43177d2f2696afd554142064b Mon Sep 17 00:00:00 2001 From: siddharth0a Date: Tue, 18 Mar 2025 15:44:21 +0900 Subject: [PATCH 1/2] add errhandling on cancle bundle --- examples/simple.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/simple.py b/examples/simple.py index 21e83c2..f87eb8c 100644 --- a/examples/simple.py +++ b/examples/simple.py @@ -170,7 +170,7 @@ def main() -> None: block = w3.eth.block_number # Simulation is only supported on mainnet - if network == "mainnet": + if network == Network.MAINNET: # Simulate bundle on current block. # If your RPC provider is not fast enough, you may get "block extrapolation negative" # error message triggered by "extrapolate_timestamp" function in "flashbots.py". @@ -207,8 +207,16 @@ def main() -> None: break except TransactionNotFound: logger.info(f"Bundle not found in block {block + 1}") - cancel_res = w3.flashbots.cancel_bundles(replacement_uuid) - logger.info(f"Canceled {cancel_res}") + try: + cancel_res = w3.flashbots.cancel_bundles(replacement_uuid) + logger.info(f"Canceled {cancel_res}") + except Exception as e: + if "400" in str(e): + logger.warning( + f"Bundle cancellation returned 400 error (bundle may not exist), ignoring: {e}" + ) + else: + raise log_account_balances(w3, sender.address, receiver) From 1df9600f211549f5403db88f0e05dfc0dea8594e Mon Sep 17 00:00:00 2001 From: siddharth0a <99310385+siddharth0a@users.noreply.github.com> Date: Tue, 18 Mar 2025 16:14:29 +0900 Subject: [PATCH 2/2] Update simple.py --- examples/simple.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/simple.py b/examples/simple.py index f87eb8c..aca1720 100644 --- a/examples/simple.py +++ b/examples/simple.py @@ -215,8 +215,8 @@ def main() -> None: logger.warning( f"Bundle cancellation returned 400 error (bundle may not exist), ignoring: {e}" ) - else: - raise + else: + raise log_account_balances(w3, sender.address, receiver)