Update helpers get_indices_for_slot and get_block_hash following spec fixes, see https://github.com/ethereum/beacon_chain/pull/62
This commit is contained in:
parent
9f0fc6817b
commit
0b560f7307
|
@ -31,7 +31,7 @@ type
|
|||
CrystallizedState* = object
|
||||
validators*: seq[ValidatorRecord] # List of active validators
|
||||
last_state_recalc*: int64 # Last CrystallizedState recalculation
|
||||
indices_for_heights*: seq[seq[ShardAndCommittee]]
|
||||
indices_for_slots*: seq[seq[ShardAndCommittee]]
|
||||
# What active validators are part of the attester set
|
||||
# at what height, and in what shard. Starts at slot
|
||||
# last_state_recalc - CYCLE_LENGTH
|
||||
|
|
|
@ -78,20 +78,20 @@ func get_new_shuffling*(seed: Blake2_256_Digest, validators: seq[ValidatorRecord
|
|||
|
||||
result.add committees
|
||||
|
||||
func get_indices_for_slot(crystallized_state: CrystallizedState,
|
||||
func get_indices_for_slot*(crystallized_state: CrystallizedState,
|
||||
slot: int64): seq[ShardAndCommittee] {.noInit.}=
|
||||
# TODO: Spec why is active_state an argument?
|
||||
|
||||
let lsr = crystallized_state.last_state_recalc
|
||||
assert lsr <= slot
|
||||
assert slot < lsr + CYCLE_LENGTH * 2
|
||||
let ifh_start = crystallized_state.last_state_recalc - CYCLE_LENGTH
|
||||
assert ifh_start <= slot
|
||||
assert slot < ifh_start + CYCLE_LENGTH * 2
|
||||
|
||||
result = crystallized_state.indices_for_heights[int slot - lsr]
|
||||
result = crystallized_state.indices_for_slots[int slot - ifh_start]
|
||||
# TODO, slot is an int64 will be an issue on int32 arch.
|
||||
# Clarify with EF if light clients will need the beacon chain
|
||||
|
||||
func get_block_hash(beacon_block: BeaconBlock,
|
||||
active_state: ActiveState, slot: int64): Keccak256_Digest =
|
||||
func get_block_hash*(active_state: ActiveState,
|
||||
beacon_block: BeaconBlock, slot: int64): Keccak256_Digest =
|
||||
|
||||
# TODO: Spec uses crystallized_state as arg and activ_state.slot_number
|
||||
# which doesn't exist
|
||||
|
|
Loading…
Reference in New Issue