def build_attestation_data(state, slot, shard): assert state.slot >= slot block_root = build_empty_block_for_next_slot(state).previous_block_root epoch_start_slot = get_epoch_start_slot(get_current_epoch(state)) if epoch_start_slot == slot: epoch_boundary_root = block_root else: get_block_root(state, epoch_start_slot) if slot < epoch_start_slot: justified_block_root = state.previous_justified_root else: justified_block_root = state.current_justified_root return AttestationData( slot=slot, shard=shard, beacon_block_root=block_root, source_epoch=state.current_justified_epoch, source_root=justified_block_root, target_root=epoch_boundary_root, crosslink_data_root=spec.ZERO_HASH, previous_crosslink=deepcopy(state.latest_crosslinks[shard]), )
def test_empty_block_transition(state): test_state = deepcopy(state) block = build_empty_block_for_next_slot(test_state) state_transition(test_state, block) assert len(test_state.eth1_data_votes) == len(state.eth1_data_votes) + 1 assert get_block_root(test_state, state.slot) == block.previous_block_root return state, [block], test_state
def test_empty_epoch_transition(state): test_state = deepcopy(state) block = build_empty_block_for_next_slot(test_state) block.slot += spec.SLOTS_PER_EPOCH state_transition(test_state, block) assert test_state.slot == block.slot for slot in range(state.slot, test_state.slot): assert get_block_root(test_state, slot) == block.previous_block_root return state, [block], test_state
def test_skipped_slots(state): test_state = deepcopy(state) block = build_empty_block_for_next_slot(test_state) block.slot += 3 state_transition(test_state, block) assert test_state.slot == block.slot for slot in range(state.slot, test_state.slot): assert get_block_root(test_state, slot) == block.previous_block_root return state, [block], test_state