|
5 | 5 | Each `engine_newPayloadVX` is verified against the appropriate VALID/INVALID responses.
|
6 | 6 | """
|
7 | 7 |
|
| 8 | +import time |
| 9 | + |
8 | 10 | from ethereum_test_exceptions import UndefinedException
|
9 | 11 | from ethereum_test_fixtures import BlockchainEngineFixture
|
10 | 12 | from ethereum_test_rpc import EngineRPC, EthRPC
|
@@ -42,16 +44,28 @@ def test_blockchain_via_engine(
|
42 | 44 | # Send a initial forkchoice update
|
43 | 45 | with timing_data.time("Initial forkchoice update"):
|
44 | 46 | logger.info("Sending initial forkchoice update to genesis block...")
|
45 |
| - forkchoice_response = engine_rpc.forkchoice_updated( |
46 |
| - forkchoice_state=ForkchoiceState( |
47 |
| - head_block_hash=fixture.genesis.block_hash, |
48 |
| - ), |
49 |
| - payload_attributes=None, |
50 |
| - version=fixture.payloads[0].forkchoice_updated_version, |
51 |
| - ) |
52 |
| - status = forkchoice_response.payload_status.status |
53 |
| - logger.info(f"Initial forkchoice update response: {status}") |
| 47 | + delay = 0.5 |
| 48 | + for attempt in range(3): |
| 49 | + forkchoice_response = engine_rpc.forkchoice_updated( |
| 50 | + forkchoice_state=ForkchoiceState( |
| 51 | + head_block_hash=fixture.genesis.block_hash, |
| 52 | + ), |
| 53 | + payload_attributes=None, |
| 54 | + version=fixture.payloads[0].forkchoice_updated_version, |
| 55 | + ) |
| 56 | + status = forkchoice_response.payload_status.status |
| 57 | + logger.info(f"Initial forkchoice update response attempt {attempt + 1}: {status}") |
| 58 | + if status != PayloadStatusEnum.SYNCING: |
| 59 | + break |
| 60 | + if attempt < 2: |
| 61 | + time.sleep(delay) |
| 62 | + delay *= 2 |
| 63 | + |
54 | 64 | if forkchoice_response.payload_status.status != PayloadStatusEnum.VALID:
|
| 65 | + logger.error( |
| 66 | + f"Client failed to initialize properly after 3 attempts, " |
| 67 | + f"final status: {forkchoice_response.payload_status.status}" |
| 68 | + ) |
55 | 69 | raise LoggedError(
|
56 | 70 | f"unexpected status on forkchoice updated to genesis: {forkchoice_response}"
|
57 | 71 | )
|
|
0 commit comments