Skip to content

Commit 1bca1a2

Browse files
authored
chore(consume): retry logic for initial consume engine fcu (#1815)
* chore(consume): add exponential retry logic for initial fcu in consume engine. * chore(docs): changelog.
1 parent 7556b8f commit 1bca1a2

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Users can select any of the artifacts depending on their testing needs for their
4545

4646
- 🔀 `consume` now automatically avoids GitHub API calls when using direct release URLs (better for CI environments), while release specifiers like `stable@latest` continue to use the API for version resolution ([#1788](https://github.com/ethereum/execution-spec-tests/pull/1788)).
4747
- 🔀 Refactor consume simulator architecture to use explicit pytest plugin structure with forward-looking architecture ([#1801](https://github.com/ethereum/execution-spec-tests/pull/1801)).
48+
- 🔀 Add exponential retry logic to initial fcu within consume engine ([#1815](https://github.com/ethereum/execution-spec-tests/pull/1815)).
4849

4950
#### `execute`
5051

src/pytest_plugins/consume/simulators/hive_tests/test_via_engine.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
Each `engine_newPayloadVX` is verified against the appropriate VALID/INVALID responses.
66
"""
77

8+
import time
9+
810
from ethereum_test_exceptions import UndefinedException
911
from ethereum_test_fixtures import BlockchainEngineFixture
1012
from ethereum_test_rpc import EngineRPC, EthRPC
@@ -42,16 +44,28 @@ def test_blockchain_via_engine(
4244
# Send a initial forkchoice update
4345
with timing_data.time("Initial forkchoice update"):
4446
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+
5464
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+
)
5569
raise LoggedError(
5670
f"unexpected status on forkchoice updated to genesis: {forkchoice_response}"
5771
)

0 commit comments

Comments
 (0)