From b9285b8fe75da43f9142c6643cfac60f8ebf179b Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Thu, 26 Oct 2023 22:39:24 +0800 Subject: [PATCH] Add `validator_is_connected` --- .../test_should_override_forkchoice_update.py | 15 ++++++++++++--- tests/formats/fork_choice/README.md | 11 +++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_should_override_forkchoice_update.py b/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_should_override_forkchoice_update.py index 617e0909c8..465a00f1a9 100644 --- a/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_should_override_forkchoice_update.py +++ b/tests/core/pyspec/eth2spec/test/bellatrix/fork_choice/test_should_override_forkchoice_update.py @@ -63,7 +63,10 @@ def test_should_override_forkchoice_update__false(spec, state): output_store_checks(spec, store, test_steps) test_steps.append({ 'checks': { - 'should_override_forkchoice_update': should_override, + 'should_override_forkchoice_update': { + 'validator_is_connected': True, + 'result': should_override, + }, } }) @@ -153,7 +156,10 @@ def test_should_override_forkchoice_update__true(spec, state): assert spec.is_ffg_competitive(store, head_root, parent_root) assert spec.is_finalization_ok(store, proposal_slot) - # TODO: proposing_reorg_slot + parent_state_advanced = store.block_states[parent_root].copy() + spec.process_slots(parent_state_advanced, proposal_slot) + proposer_index = spec.get_beacon_proposer_index(parent_state_advanced) + assert spec.validator_is_connected(proposer_index) # Single slot re-org. parent_slot_ok = parent_block.slot + 1 == head_block.slot @@ -170,7 +176,10 @@ def test_should_override_forkchoice_update__true(spec, state): output_store_checks(spec, store, test_steps) test_steps.append({ 'checks': { - 'should_override_forkchoice_update': should_override, + 'should_override_forkchoice_update': { + 'validator_is_connected': True, + 'result': should_override, + }, } }) diff --git a/tests/formats/fork_choice/README.md b/tests/formats/fork_choice/README.md index 1d8b9cfb39..1258a66c06 100644 --- a/tests/formats/fork_choice/README.md +++ b/tests/formats/fork_choice/README.md @@ -142,7 +142,7 @@ Optional step for optimistic sync tests. } ``` -This step sets the [`payloadStatus`](https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md#PayloadStatusV1) +This step sets the [`payloadStatus`](https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#payloadstatusv1) value that Execution Layer client mock returns in responses to the following Engine API calls: * [`engine_newPayloadV1(payload)`](https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#engine_newpayloadv1) if `payload.blockHash == payload_info.block_hash` * [`engine_forkchoiceUpdatedV1(forkchoiceState, ...)`](https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#engine_forkchoiceupdatedv1) if `forkchoiceState.headBlockHash == payload_info.block_hash` @@ -182,8 +182,11 @@ proposer_boost_root: string -- Encoded 32-byte value from store.proposer_boost Additionally, these fields if `get_proposer_head` and `should_override_forkchoice_update` features are implemented: ```yaml -get_proposer_head: string -- Encoded 32-byte value from get_proposer_head(store) -should_override_forkchoice_update: bool -- [New in Bellatrix] the result of `should_override_forkchoice_update(store, head_root)`, where head_root is the result value from get_head(store) +get_proposer_head: string -- Encoded 32-byte value from get_proposer_head(store) +should_override_forkchoice_update: { -- [New in Bellatrix] + validator_is_connected: bool, -- The mocking result of `validator_is_connected(proposer_index)` in this call + result: bool, -- The result of `should_override_forkchoice_update(store, head_root)`, where head_root is the result value from get_head(store) +} ``` For example: @@ -195,7 +198,7 @@ For example: finalized_checkpoint: {epoch: 2, root: '0x40d32d6283ec11c53317a46808bc88f55657d93b95a1af920403187accf48f4f'} proposer_boost_root: '0xdaa1d49d57594ced0c35688a6da133abb086d191a2ebdfd736fad95299325aeb' get_proposer_head: '0xdaa1d49d57594ced0c35688a6da133abb086d191a2ebdfd736fad95299325aeb' - should_override_forkchoice_update: false + should_override_forkchoice_update: {validator_is_connected: false, result: false} ``` *Note*: Each `checks` step may include one or multiple items. Each item has to be checked against the current store.