mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-19 23:19:28 +00:00
PR feedback from danny: simplify verify_shard_block_message
params
This commit is contained in:
parent
7e67aaeb35
commit
e03a970eaf
@ -169,7 +169,7 @@ def on_shard_block(store: Store, shard_store: ShardStore, signed_shard_block: Si
|
||||
)
|
||||
|
||||
# Check the block is valid and compute the post-state
|
||||
assert verify_shard_block_message(beacon_parent_state, shard_parent_state, shard_block, shard_block.slot, shard)
|
||||
assert verify_shard_block_message(beacon_parent_state, shard_parent_state, shard_block)
|
||||
assert verify_shard_block_signature(beacon_parent_state, signed_shard_block)
|
||||
|
||||
post_state = get_post_shard_state(beacon_parent_state, shard_parent_state, shard_block)
|
||||
|
@ -43,27 +43,26 @@ def compute_shard_transition_digest(beacon_parent_state: BeaconState,
|
||||
### Shard block verification functions
|
||||
|
||||
```python
|
||||
def verify_shard_block_message(beacon_state: BeaconState,
|
||||
def verify_shard_block_message(beacon_parent_state: BeaconState,
|
||||
shard_parent_state: ShardState,
|
||||
block: ShardBlock,
|
||||
slot: Slot,
|
||||
shard: Shard) -> bool:
|
||||
block: ShardBlock) -> bool:
|
||||
# Check `shard_parent_root` field
|
||||
assert block.shard_parent_root == shard_parent_state.latest_block_root
|
||||
# Check `beacon_parent_root` field
|
||||
beacon_parent_block_header = beacon_state.latest_block_header.copy()
|
||||
beacon_parent_block_header = beacon_parent_state.latest_block_header.copy()
|
||||
if beacon_parent_block_header.state_root == Root():
|
||||
beacon_parent_block_header.state_root = hash_tree_root(beacon_state)
|
||||
beacon_parent_block_header.state_root = hash_tree_root(beacon_parent_state)
|
||||
beacon_parent_root = hash_tree_root(beacon_parent_block_header)
|
||||
assert block.beacon_parent_root == beacon_parent_root
|
||||
# Check `slot` field
|
||||
next_slot = Slot(slot + 1)
|
||||
offset_slots = compute_offset_slots(get_latest_slot_for_shard(beacon_state, shard), next_slot)
|
||||
assert slot in offset_slots
|
||||
shard = block.shard
|
||||
next_slot = Slot(block.slot + 1)
|
||||
offset_slots = compute_offset_slots(get_latest_slot_for_shard(beacon_parent_state, shard), next_slot)
|
||||
assert block.slot in offset_slots
|
||||
# Check `shard` field
|
||||
assert block.shard == shard
|
||||
# Check `proposer_index` field
|
||||
assert block.proposer_index == get_shard_proposer_index(beacon_state, slot, shard)
|
||||
assert block.proposer_index == get_shard_proposer_index(beacon_parent_state, block.slot, shard)
|
||||
# Check `body` field
|
||||
assert 0 < len(block.body) <= MAX_SHARD_BLOCK_SIZE
|
||||
return True
|
||||
|
Loading…
x
Reference in New Issue
Block a user