Skip to content

Commit

Permalink
Add validator_is_connected
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed Oct 26, 2023
1 parent 9ce8e3d commit b9285b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
})

Expand Down Expand Up @@ -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
Expand All @@ -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,
},
}
})

Expand Down
11 changes: 7 additions & 4 deletions tests/formats/fork_choice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand Down

0 comments on commit b9285b8

Please sign in to comment.