rename get_epoch_start_shard(...) to 0.8.0 get_start_shard(...)
This commit is contained in:
parent
e4321dc4ed
commit
607a7de5eb
|
@ -277,7 +277,7 @@ func get_attestation_data_slot*(state: BeaconState,
|
|||
data: AttestationData, committee_count: uint64): Slot =
|
||||
let
|
||||
offset = (data.crosslink.shard + SHARD_COUNT -
|
||||
get_epoch_start_shard(state, data.target_epoch)) mod SHARD_COUNT
|
||||
get_start_shard(state, data.target_epoch)) mod SHARD_COUNT
|
||||
|
||||
compute_start_slot_of_epoch(data.target_epoch) + offset div
|
||||
(committee_count div SLOTS_PER_EPOCH)
|
||||
|
@ -595,7 +595,7 @@ proc makeAttestationData*(
|
|||
target_epoch: compute_epoch_of_slot(state.slot),
|
||||
crosslink: Crosslink(
|
||||
# Alternative is to put this offset into all callers
|
||||
shard: shard + get_epoch_start_shard(state, compute_epoch_of_slot(state.slot)),
|
||||
shard: shard + get_start_shard(state, compute_epoch_of_slot(state.slot)),
|
||||
parent_root: hash_tree_root(state.current_crosslinks[shard]),
|
||||
data_root: Eth2Digest(), # Stub in phase0
|
||||
)
|
||||
|
|
|
@ -378,7 +378,9 @@ template ethTimeUnit(typ: type) {.dirty.} =
|
|||
|
||||
proc `*`*(x: typ, y: uint64): uint64 {.borrow.}
|
||||
|
||||
proc `+=`*(x: var typ, y: typ) {.borrow.}
|
||||
proc `+=`*(x: var typ, y: uint64) {.borrow.}
|
||||
proc `-=`*(x: var typ, y: typ) {.borrow.}
|
||||
proc `-=`*(x: var typ, y: uint64) {.borrow.}
|
||||
|
||||
# Comparison operators
|
||||
|
|
|
@ -221,7 +221,7 @@ func process_crosslinks(state: var BeaconState, stateCache: var StateCache) =
|
|||
let epoch = epoch_int.Epoch
|
||||
for offset in 0'u64 ..< get_epoch_committee_count(state, epoch):
|
||||
let
|
||||
shard = (get_epoch_start_shard(state, epoch) + offset) mod SHARD_COUNT
|
||||
shard = (get_start_shard(state, epoch) + offset) mod SHARD_COUNT
|
||||
crosslink_committee =
|
||||
get_crosslink_committee(state, epoch, shard, stateCache)
|
||||
# In general, it'll loop over the same shards twice, and
|
||||
|
@ -327,7 +327,7 @@ func get_crosslink_deltas(state: BeaconState, cache: var StateCache):
|
|||
let epoch = get_previous_epoch(state)
|
||||
for offset in 0'u64 ..< get_epoch_committee_count(state, epoch):
|
||||
let
|
||||
shard = (get_epoch_start_shard(state, epoch) + offset) mod SHARD_COUNT
|
||||
shard = (get_start_shard(state, epoch) + offset) mod SHARD_COUNT
|
||||
crosslink_committee =
|
||||
get_crosslink_committee(state, epoch, shard, cache)
|
||||
(winning_crosslink, attesting_indices) =
|
||||
|
|
|
@ -96,8 +96,10 @@ func get_shard_delta*(state: BeaconState, epoch: Epoch): uint64 =
|
|||
min(get_epoch_committee_count(state, epoch),
|
||||
(SHARD_COUNT - SHARD_COUNT div SLOTS_PER_EPOCH).uint64)
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#get_epoch_start_shard
|
||||
func get_epoch_start_shard*(state: BeaconState, epoch: Epoch): Shard =
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#get_start_shard
|
||||
func get_start_shard*(state: BeaconState, epoch: Epoch): Shard =
|
||||
# Return the start shard of the 0th committee at ``epoch``.
|
||||
|
||||
doAssert epoch <= get_current_epoch(state) + 1
|
||||
var
|
||||
check_epoch = get_current_epoch(state) + 1
|
||||
|
@ -105,7 +107,7 @@ func get_epoch_start_shard*(state: BeaconState, epoch: Epoch): Shard =
|
|||
(state.latest_start_shard +
|
||||
get_shard_delta(state, get_current_epoch(state))) mod SHARD_COUNT
|
||||
while check_epoch > epoch:
|
||||
check_epoch -= 1
|
||||
check_epoch -= 1.Epoch
|
||||
shard = (shard + SHARD_COUNT - get_shard_delta(state, check_epoch)) mod
|
||||
SHARD_COUNT
|
||||
return shard
|
||||
|
@ -140,7 +142,7 @@ func get_crosslink_committee*(state: BeaconState, epoch: Epoch, shard: Shard,
|
|||
|
||||
doAssert shard >= 0'u64
|
||||
# This seems to be required, basically, to be true? But I'm not entirely sure
|
||||
#doAssert shard >= get_epoch_start_shard(state, epoch)
|
||||
#doAssert shard >= get_start_shard(state, epoch)
|
||||
doAssert shard < SHARD_COUNT
|
||||
|
||||
## This is a somewhat more fragile, but high-ROI, caching setup --
|
||||
|
@ -153,7 +155,7 @@ func get_crosslink_committee*(state: BeaconState, epoch: Epoch, shard: Shard,
|
|||
compute_committee(
|
||||
stateCache.active_validator_indices_cache[epoch],
|
||||
generate_seed(state, epoch),
|
||||
(shard + SHARD_COUNT - get_epoch_start_shard(state, epoch)) mod SHARD_COUNT,
|
||||
(shard + SHARD_COUNT - get_start_shard(state, epoch)) mod SHARD_COUNT,
|
||||
get_epoch_committee_count(state, epoch),
|
||||
stateCache
|
||||
)
|
||||
|
@ -177,7 +179,7 @@ func get_beacon_proposer_index*(state: BeaconState, stateCache: var StateCache):
|
|||
committees_per_slot =
|
||||
get_epoch_committee_count(state, epoch) div SLOTS_PER_EPOCH
|
||||
offset = committees_per_slot * (state.slot mod SLOTS_PER_EPOCH)
|
||||
shard = (get_epoch_start_shard(state, epoch) + offset) mod SHARD_COUNT
|
||||
shard = (get_start_shard(state, epoch) + offset) mod SHARD_COUNT
|
||||
first_committee = get_crosslink_committee(state, epoch, shard, stateCache)
|
||||
seed = generate_seed(state, epoch)
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ cli do(slots = 448,
|
|||
mapIt(
|
||||
0'u64 .. (get_epoch_committee_count(state, epoch) - 1),
|
||||
get_crosslink_committee(state, epoch,
|
||||
(it + get_epoch_start_shard(state, epoch)) mod SHARD_COUNT,
|
||||
(it + get_start_shard(state, epoch)) mod SHARD_COUNT,
|
||||
cache))
|
||||
|
||||
for scas in scass:
|
||||
|
|
|
@ -147,7 +147,7 @@ proc find_shard_committee(
|
|||
var cache = get_empty_per_epoch_cache()
|
||||
for shard in 0'u64 ..< get_epoch_committee_count(state, epoch):
|
||||
let committee = get_crosslink_committee(state, epoch,
|
||||
(shard + get_epoch_start_shard(state, epoch)) mod SHARD_COUNT, cache)
|
||||
(shard + get_start_shard(state, epoch)) mod SHARD_COUNT, cache)
|
||||
if validator_index in committee:
|
||||
return (committee, shard)
|
||||
doAssert false
|
||||
|
|
Loading…
Reference in New Issue