18
18
19
19
logger = get_logger (__name__ )
20
20
21
+ MAX_RETRIES = 30
22
+ DELAY_BETWEEN_RETRIES_IN_SEC = 1
23
+
21
24
22
25
class LoggedError (Exception ):
23
26
"""Exception that uses the logger to log the failure."""
@@ -44,8 +47,7 @@ def test_blockchain_via_engine(
44
47
# Send a initial forkchoice update
45
48
with timing_data .time ("Initial forkchoice update" ):
46
49
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 ):
49
51
forkchoice_response = engine_rpc .forkchoice_updated (
50
52
forkchoice_state = ForkchoiceState (
51
53
head_block_hash = fixture .genesis .block_hash ,
@@ -54,16 +56,16 @@ def test_blockchain_via_engine(
54
56
version = fixture .payloads [0 ].forkchoice_updated_version ,
55
57
)
56
58
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 } " )
58
60
if status != PayloadStatusEnum .SYNCING :
59
61
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 )
63
65
64
66
if forkchoice_response .payload_status .status != PayloadStatusEnum .VALID :
65
67
logger .error (
66
- f"Client failed to initialize properly after 3 attempts, "
68
+ f"Client failed to initialize properly after { MAX_RETRIES } attempts, "
67
69
f"final status: { forkchoice_response .payload_status .status } "
68
70
)
69
71
raise LoggedError (
0 commit comments