Tidying up shard_state_transition

This commit is contained in:
terence tsao 2020-06-01 14:31:45 -07:00 committed by GitHub
parent 09d8636e7e
commit 2a218520a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,21 +71,22 @@ def verify_shard_block_signature(beacon_state: BeaconState,
def shard_state_transition(beacon_state: BeaconState,
shard_state: ShardState,
block: ShardBlock) -> None:
# Update shard state
"""
Update ``shard_state`` with shard ``block`` and ``beacon_state`.
"""
shard_state.slot = block.slot
prev_gasprice = shard_state.gasprice
if len(block.body) == 0:
latest_block_root = shard_state.latest_block_root
else:
latest_block_root = hash_tree_root(block)
shard_state.gasprice = compute_updated_gasprice(prev_gasprice, len(block.body))
shard_state.transition_digest = compute_shard_transition_digest(
beacon_state,
shard_state,
block.beacon_parent_root,
hash_tree_root(block.body),
)
shard_state.gasprice = compute_updated_gasprice(prev_gasprice, len(block.body))
shard_state.slot = block.slot
if len(block.body) == 0:
latest_block_root = shard_state.latest_block_root
else:
latest_block_root = hash_tree_root(block)
shard_state.latest_block_root = latest_block_root
```