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
|
CrystallizedState* = object
|
||||||
validators*: seq[ValidatorRecord] # List of active validators
|
validators*: seq[ValidatorRecord] # List of active validators
|
||||||
last_state_recalc*: int64 # Last CrystallizedState recalculation
|
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
|
# What active validators are part of the attester set
|
||||||
# at what height, and in what shard. Starts at slot
|
# at what height, and in what shard. Starts at slot
|
||||||
# last_state_recalc - CYCLE_LENGTH
|
# last_state_recalc - CYCLE_LENGTH
|
||||||
|
|
|
@ -78,20 +78,20 @@ func get_new_shuffling*(seed: Blake2_256_Digest, validators: seq[ValidatorRecord
|
||||||
|
|
||||||
result.add committees
|
result.add committees
|
||||||
|
|
||||||
func get_indices_for_slot(crystallized_state: CrystallizedState,
|
func get_indices_for_slot*(crystallized_state: CrystallizedState,
|
||||||
slot: int64): seq[ShardAndCommittee] {.noInit.}=
|
slot: int64): seq[ShardAndCommittee] {.noInit.}=
|
||||||
# TODO: Spec why is active_state an argument?
|
# TODO: Spec why is active_state an argument?
|
||||||
|
|
||||||
let lsr = crystallized_state.last_state_recalc
|
let ifh_start = crystallized_state.last_state_recalc - CYCLE_LENGTH
|
||||||
assert lsr <= slot
|
assert ifh_start <= slot
|
||||||
assert slot < lsr + CYCLE_LENGTH * 2
|
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.
|
# TODO, slot is an int64 will be an issue on int32 arch.
|
||||||
# Clarify with EF if light clients will need the beacon chain
|
# Clarify with EF if light clients will need the beacon chain
|
||||||
|
|
||||||
func get_block_hash(beacon_block: BeaconBlock,
|
func get_block_hash*(active_state: ActiveState,
|
||||||
active_state: ActiveState, slot: int64): Keccak256_Digest =
|
beacon_block: BeaconBlock, slot: int64): Keccak256_Digest =
|
||||||
|
|
||||||
# TODO: Spec uses crystallized_state as arg and activ_state.slot_number
|
# TODO: Spec uses crystallized_state as arg and activ_state.slot_number
|
||||||
# which doesn't exist
|
# which doesn't exist
|
||||||
|
|
Loading…
Reference in New Issue