From 75e601a16761249d514e61ce1294998e92245912 Mon Sep 17 00:00:00 2001 From: fradamt Date: Fri, 9 Aug 2024 09:13:13 +0200 Subject: [PATCH] remove redundant copy() --- specs/capella/fork-choice.md | 5 ++--- specs/deneb/fork-choice.md | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/specs/capella/fork-choice.md b/specs/capella/fork-choice.md index 85b9d2475..a66410cf0 100644 --- a/specs/capella/fork-choice.md +++ b/specs/capella/fork-choice.md @@ -75,8 +75,6 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None: block = signed_block.message # Parent block must be known assert block.parent_root in store.block_states - # Make a copy of the state to avoid mutability issues - pre_state = copy(store.block_states[block.parent_root]) # Blocks cannot be in the future. If they are, their consideration must be delayed until they are in the past. assert get_current_slot(store) >= block.slot @@ -92,7 +90,8 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None: assert store.finalized_checkpoint.root == finalized_checkpoint_block # Check the block is valid and compute the post-state - state = pre_state.copy() + # Make a copy of the state to avoid mutability issues + state = copy(store.block_states[block.parent_root]) block_root = hash_tree_root(block) state_transition(state, signed_block, True) diff --git a/specs/deneb/fork-choice.md b/specs/deneb/fork-choice.md index 101e07a0f..836fe6174 100644 --- a/specs/deneb/fork-choice.md +++ b/specs/deneb/fork-choice.md @@ -74,8 +74,6 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None: block = signed_block.message # Parent block must be known assert block.parent_root in store.block_states - # Make a copy of the state to avoid mutability issues - pre_state = copy(store.block_states[block.parent_root]) # Blocks cannot be in the future. If they are, their consideration must be delayed until they are in the past. assert get_current_slot(store) >= block.slot @@ -98,7 +96,8 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None: assert is_data_available(hash_tree_root(block), block.body.blob_kzg_commitments) # Check the block is valid and compute the post-state - state = pre_state.copy() + # Make a copy of the state to avoid mutability issues + state = copy(store.block_states[block.parent_root]) block_root = hash_tree_root(block) state_transition(state, signed_block, True)