Refactor block helper

This commit is contained in:
Alex Stokes 2021-05-20 11:40:25 -07:00
parent df742ea8af
commit 1dfca0e677
No known key found for this signature in database
GPG Key ID: 99B3D88FD6C55A69
2 changed files with 3 additions and 2 deletions

View File

@ -61,6 +61,7 @@ def transition_unsigned_block(spec, state, block):
assert state.latest_block_header.slot < block.slot # There may not already be a block in this slot or past it.
assert state.slot == block.slot # The block must be for this slot
spec.process_block(state, block)
return block
def apply_empty_block(spec, state, slot=None):
@ -68,7 +69,7 @@ def apply_empty_block(spec, state, slot=None):
Transition via an empty block (on current slot, assuming no block has been applied yet).
"""
block = build_empty_block(spec, state, slot)
transition_unsigned_block(spec, state, block)
return transition_unsigned_block(spec, state, block)
def build_empty_block(spec, state, slot=None):

View File

@ -62,7 +62,7 @@ def next_epoch_via_block(spec, state):
"""
Transition to the start slot of the next epoch via a full block transition
"""
apply_empty_block(spec, state, state.slot + spec.SLOTS_PER_EPOCH - state.slot % spec.SLOTS_PER_EPOCH)
return apply_empty_block(spec, state, state.slot + spec.SLOTS_PER_EPOCH - state.slot % spec.SLOTS_PER_EPOCH)
def get_state_root(spec, state, slot) -> bytes: