Skip to content

Commit

Permalink
Merge pull request #757 from ethereum/JustinDrake-patch-8
Browse files Browse the repository at this point in the history
Check proposer is not slashed
  • Loading branch information
djrtwo committed Mar 19, 2019
2 parents 333b9a3 + ad636a8 commit 8098af4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion specs/core/0_beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -2242,8 +2242,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 is not slashed
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),
Expand Down
26 changes: 26 additions & 0 deletions tests/phase0/test_process_block_header.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8098af4

Please sign in to comment.