Merge pull request #3877 from fradamt/dev

remove redundant copy()
This commit is contained in:
Hsiao-Wei Wang 2024-08-12 18:39:54 +09:00 committed by GitHub
commit d8cbca76b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 6 deletions

View File

@ -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)

View File

@ -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)