diff --git a/specs/phase1/shard-fork-choice.md b/specs/phase1/shard-fork-choice.md index 1a449e3e9..b6d5c5ad4 100644 --- a/specs/phase1/shard-fork-choice.md +++ b/specs/phase1/shard-fork-choice.md @@ -170,7 +170,7 @@ def on_shard_block(store: Store, shard_store: ShardStore, signed_shard_block: Si # Check the block is valid and compute the post-state shard_state = shard_parent_state.copy() - shard_state_transition(beacon_parent_state, shard_state, shard_block) + shard_state_transition(shard_state, shard_block, validate_message=True, beacon_parent_state=beacon_parent_state) # Add new block to the store shard_store.blocks[hash_tree_root(shard_block)] = shard_block diff --git a/specs/phase1/shard-transition.md b/specs/phase1/shard-transition.md index 1433b0837..d725cd8bf 100644 --- a/specs/phase1/shard-transition.md +++ b/specs/phase1/shard-transition.md @@ -61,11 +61,12 @@ def verify_shard_block_signature(beacon_state: BeaconState, ## Shard state transition ```python -def shard_state_transition(beacon_parent_state: BeaconState, - shard_state: ShardState, +def shard_state_transition(shard_state: ShardState, block: ShardBlock, - validate_message: bool = True) -> bool: + validate_message: bool = True, + beacon_parent_state: Optional[BeaconState] = None) -> bool: if validate_message: + assert beacon_parent_state is not None assert verify_shard_block_message(beacon_parent_state, shard_state, block) process_shard_block(shard_state, block) @@ -126,7 +127,7 @@ def is_valid_fraud_proof(beacon_state: BeaconState, else: shard_state = transition.shard_states[offset_index - 1] # Not doing the actual state updates here. - shard_state_transition(beacon_state, shard_state, block, validate_message=False) + shard_state_transition(shard_state, block, validate_message=False) if shard_state != transition.shard_states[offset_index]: return True diff --git a/specs/phase1/validator.md b/specs/phase1/validator.md index 39ada7891..d78726bc2 100644 --- a/specs/phase1/validator.md +++ b/specs/phase1/validator.md @@ -280,13 +280,12 @@ def get_shard_transition_fields( beacon_state: BeaconState, shard: Shard, shard_blocks: Sequence[SignedShardBlock], - validate_signature: bool=True, ) -> Tuple[Sequence[uint64], Sequence[Root], Sequence[ShardState]]: shard_states = [] shard_data_roots = [] shard_block_lengths = [] - shard_state = beacon_state.shard_states[shard].copy() + shard_state = beacon_state.shard_states[shard] shard_block_slots = [shard_block.message.slot for shard_block in shard_blocks] offset_slots = compute_offset_slots( get_latest_slot_for_shard(beacon_state, shard), @@ -299,7 +298,8 @@ def get_shard_transition_fields( else: shard_block = SignedShardBlock(message=ShardBlock(slot=slot, shard=shard)) shard_data_roots.append(Root()) - shard_state_transition(beacon_state, shard_state, shard_block.message, validate_message=False) + shard_state = shard_state.copy() + shard_state_transition(shard_state, shard_block.message, validate_message=False) shard_states.append(shard_state) shard_block_lengths.append(len(shard_block.message.body))