Merge pull request #1862 from terencechain/patch-100

Tidying up `shard_state_transition`
This commit is contained in:
Danny Ryan 2020-06-02 14:19:31 -06:00 committed by GitHub
commit 09b387bdc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -71,22 +71,23 @@ 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
shard_state.gasprice = compute_updated_gasprice(prev_gasprice, len(block.body))
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
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
shard_state.latest_block_root = latest_block_root
```
We have a pure function `get_post_shard_state` for describing the fraud proof verification and honest validator behavior.