From 3459ea0838da4b82b5f0e9d2fd2662e2c76529a2 Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 11 Mar 2019 22:07:34 +0000 Subject: [PATCH 1/3] Check proposer is not slashed --- specs/core/0_beacon-chain.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index ceca50962..1bbab78dc 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -2247,8 +2247,10 @@ def process_block_header(state: BeaconState, block: BeaconBlock) -> None: assert block.previous_block_root == hash_tree_root(state.latest_block_header) # Save current block as the new latest block state.latest_block_header = get_temporary_block_header(block) - # Verify proposer signature + # Verify proposer proposer = state.validator_registry[get_beacon_proposer_index(state, state.slot)] + assert not proposer.slashed + # Verify proposer signature assert bls_verify( pubkey=proposer.pubkey, message_hash=signed_root(block), From d25c18b320ac9acac0d825f2d1977e313613c1d5 Mon Sep 17 00:00:00 2001 From: Justin Date: Sun, 17 Mar 2019 11:48:47 +0000 Subject: [PATCH 2/3] Update 0_beacon-chain.md --- specs/core/0_beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 1bbab78dc..03a9df2a1 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -2247,7 +2247,7 @@ def process_block_header(state: BeaconState, block: BeaconBlock) -> None: assert block.previous_block_root == hash_tree_root(state.latest_block_header) # Save current block as the new latest block state.latest_block_header = get_temporary_block_header(block) - # Verify proposer + # Verify proposer is not slashed proposer = state.validator_registry[get_beacon_proposer_index(state, state.slot)] assert not proposer.slashed # Verify proposer signature From ad636a8252f83a5e1be2714c3ad3fc5a299da4ed Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Tue, 19 Mar 2019 15:00:29 -0600 Subject: [PATCH 3/3] add no salshed proposer test --- tests/phase0/test_process_block_header.py | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/phase0/test_process_block_header.py diff --git a/tests/phase0/test_process_block_header.py b/tests/phase0/test_process_block_header.py new file mode 100644 index 000000000..83d99e574 --- /dev/null +++ b/tests/phase0/test_process_block_header.py @@ -0,0 +1,26 @@ +from copy import deepcopy +import pytest + + +from build.phase0.spec import ( + get_beacon_proposer_index, + process_block_header, +) +from tests.phase0.helpers import ( + build_empty_block_for_next_slot, +) + +# mark entire file as 'sanity' and 'header' +pytestmark = [pytest.mark.sanity, pytest.mark.header] + + +def test_proposer_slashed(state): + pre_state = deepcopy(state) + + block = build_empty_block_for_next_slot(pre_state) + proposer_index = get_beacon_proposer_index(pre_state, block.slot) + pre_state.validator_registry[proposer_index].slashed = True + with pytest.raises(AssertionError): + process_block_header(pre_state, block) + + return state, [block], None