From 0b560f7307ba3e63428eb11850e2f60d99e51eaf Mon Sep 17 00:00:00 2001 From: mratsim Date: Tue, 21 Aug 2018 14:45:35 +0200 Subject: [PATCH] Update helpers get_indices_for_slot and get_block_hash following spec fixes, see https://github.com/ethereum/beacon_chain/pull/62 --- beacon_chain/datatypes.nim | 2 +- beacon_chain/private/helpers.nim | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/beacon_chain/datatypes.nim b/beacon_chain/datatypes.nim index a740947d5..2f1374120 100644 --- a/beacon_chain/datatypes.nim +++ b/beacon_chain/datatypes.nim @@ -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 diff --git a/beacon_chain/private/helpers.nim b/beacon_chain/private/helpers.nim index 5cc1e0612..b7705d21a 100644 --- a/beacon_chain/private/helpers.nim +++ b/beacon_chain/private/helpers.nim @@ -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