Skip to content

Commit d8cbca7

Browse files
authored
Merge pull request #3877 from fradamt/dev
remove redundant copy()
2 parents f4e3908 + 75e601a commit d8cbca7

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

specs/capella/fork-choice.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
7575
block = signed_block.message
7676
# Parent block must be known
7777
assert block.parent_root in store.block_states
78-
# Make a copy of the state to avoid mutability issues
79-
pre_state = copy(store.block_states[block.parent_root])
8078
# Blocks cannot be in the future. If they are, their consideration must be delayed until they are in the past.
8179
assert get_current_slot(store) >= block.slot
8280

@@ -92,7 +90,8 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
9290
assert store.finalized_checkpoint.root == finalized_checkpoint_block
9391

9492
# Check the block is valid and compute the post-state
95-
state = pre_state.copy()
93+
# Make a copy of the state to avoid mutability issues
94+
state = copy(store.block_states[block.parent_root])
9695
block_root = hash_tree_root(block)
9796
state_transition(state, signed_block, True)
9897

specs/deneb/fork-choice.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
7474
block = signed_block.message
7575
# Parent block must be known
7676
assert block.parent_root in store.block_states
77-
# Make a copy of the state to avoid mutability issues
78-
pre_state = copy(store.block_states[block.parent_root])
7977
# Blocks cannot be in the future. If they are, their consideration must be delayed until they are in the past.
8078
assert get_current_slot(store) >= block.slot
8179

@@ -98,7 +96,8 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
9896
assert is_data_available(hash_tree_root(block), block.body.blob_kzg_commitments)
9997

10098
# Check the block is valid and compute the post-state
101-
state = pre_state.copy()
99+
# Make a copy of the state to avoid mutability issues
100+
state = copy(store.block_states[block.parent_root])
102101
block_root = hash_tree_root(block)
103102
state_transition(state, signed_block, True)
104103

0 commit comments

Comments
 (0)