1818
1919logger = get_logger (__name__ )
2020
21+ MAX_RETRIES = 30
22+ DELAY_BETWEEN_RETRIES_IN_SEC = 1
23+
2124
2225class LoggedError (Exception ):
2326 """Exception that uses the logger to log the failure."""
@@ -44,8 +47,7 @@ def test_blockchain_via_engine(
4447 # Send a initial forkchoice update
4548 with timing_data .time ("Initial forkchoice update" ):
4649 logger .info ("Sending initial forkchoice update to genesis block..." )
47- delay = 0.5
48- for attempt in range (3 ):
50+ for attempt in range (1 , MAX_RETRIES + 1 ):
4951 forkchoice_response = engine_rpc .forkchoice_updated (
5052 forkchoice_state = ForkchoiceState (
5153 head_block_hash = fixture .genesis .block_hash ,
@@ -54,16 +56,16 @@ def test_blockchain_via_engine(
5456 version = fixture .payloads [0 ].forkchoice_updated_version ,
5557 )
5658 status = forkchoice_response .payload_status .status
57- logger .info (f"Initial forkchoice update response attempt { attempt + 1 } : { status } " )
59+ logger .info (f"Initial forkchoice update response attempt { attempt } : { status } " )
5860 if status != PayloadStatusEnum .SYNCING :
5961 break
60- if attempt < 2 :
61- time . sleep ( delay )
62- delay *= 2
62+
63+ if attempt < MAX_RETRIES :
64+ time . sleep ( DELAY_BETWEEN_RETRIES_IN_SEC )
6365
6466 if forkchoice_response .payload_status .status != PayloadStatusEnum .VALID :
6567 logger .error (
66- f"Client failed to initialize properly after 3 attempts, "
68+ f"Client failed to initialize properly after { MAX_RETRIES } attempts, "
6769 f"final status: { forkchoice_response .payload_status .status } "
6870 )
6971 raise LoggedError (
0 commit comments