diff --git a/specs/phase1/shard-fork-choice.md b/specs/phase1/shard-fork-choice.md index 39e957819..ce71ea7de 100644 --- a/specs/phase1/shard-fork-choice.md +++ b/specs/phase1/shard-fork-choice.md @@ -142,13 +142,10 @@ def get_pending_shard_blocks(store: Store, shard: Shard) -> Sequence[SignedShard #### `on_shard_block` ```python -def on_shard_block(store: Store, shard: Shard, signed_shard_block: SignedShardBlock) -> None: - shard_store = store.shard_stores[shard] +def on_shard_block(store: Store, signed_shard_block: SignedShardBlock) -> None: shard_block = signed_shard_block.message - - # Check shard - # TODO: check it in networking spec - assert shard_block.shard == shard + shard = shard_block.shard + shard_store = store.shard_stores[shard] # Check shard parent exists assert shard_block.shard_parent_root in shard_store.block_states diff --git a/tests/core/pyspec/eth2spec/test/fork_choice/test_on_shard_block.py b/tests/core/pyspec/eth2spec/test/fork_choice/test_on_shard_block.py index d08f6393b..0b33517c1 100644 --- a/tests/core/pyspec/eth2spec/test/fork_choice/test_on_shard_block.py +++ b/tests/core/pyspec/eth2spec/test/fork_choice/test_on_shard_block.py @@ -13,16 +13,17 @@ from eth2spec.test.helpers.state import state_transition_and_sign_block from eth2spec.test.helpers.block import build_empty_block -def run_on_shard_block(spec, store, shard, signed_block, valid=True): +def run_on_shard_block(spec, store, signed_block, valid=True): + shard = signed_block.message.shard if not valid: try: - spec.on_shard_block(store, shard, signed_block) + spec.on_shard_block(store, signed_block) except AssertionError: return else: assert False - spec.on_shard_block(store, shard, signed_block) + spec.on_shard_block(store, signed_block) shard_store = store.shard_stores[shard] assert shard_store.signed_blocks[hash_tree_root(signed_block.message)] == signed_block @@ -53,7 +54,7 @@ def create_and_apply_shard_block(spec, store, shard, beacon_parent_state, shard_ shard_parent_state=shard_parent_state, slot=beacon_parent_state.slot, body=body, signed=True ) shard_blocks_buffer.append(shard_block) - run_on_shard_block(spec, store, shard, shard_block) + run_on_shard_block(spec, store, shard_block) assert spec.get_shard_head(store, shard) == shard_block.message.hash_tree_root() @@ -183,7 +184,7 @@ def create_simple_fork(spec, state, store, shard): spec, beacon_parent_state, shard, shard_parent_state=shard_parent_state, slot=beacon_parent_state.slot, body=body, signed=True ) - run_on_shard_block(spec, store, shard, forking_block_child) + run_on_shard_block(spec, store, forking_block_child) # Shard block B body = b'\x78' * 4 # different body @@ -191,7 +192,7 @@ def create_simple_fork(spec, state, store, shard): spec, beacon_parent_state, shard, shard_parent_state=shard_parent_state, slot=beacon_parent_state.slot, body=body, signed=True ) - run_on_shard_block(spec, store, shard, shard_block_b) + run_on_shard_block(spec, store, shard_block_b) # Set forking_block current_head = spec.get_shard_head(store, shard)