spec: remove unused code, fix state_sim speed
This commit is contained in:
parent
d75b6bc3a8
commit
976e1e1f10
|
@ -156,7 +156,9 @@ proc makeAttestation(node: BeaconNode,
|
||||||
if get_current_epoch(node.beaconState) == node.beaconState.justified_epoch:
|
if get_current_epoch(node.beaconState) == node.beaconState.justified_epoch:
|
||||||
return
|
return
|
||||||
|
|
||||||
let justifiedBlockRoot = get_block_root(node.beaconState, get_epoch_start_slot(node.beaconState.justified_epoch))
|
let justifiedBlockRoot =
|
||||||
|
get_block_root(node.beaconState,
|
||||||
|
get_epoch_start_slot(node.beaconState.justified_epoch))
|
||||||
|
|
||||||
var attestationData = AttestationData(
|
var attestationData = AttestationData(
|
||||||
slot: slot,
|
slot: slot,
|
||||||
|
@ -294,10 +296,6 @@ proc scheduleEpochActions(node: BeaconNode, epoch: uint64) =
|
||||||
# missing blocks if necessary
|
# missing blocks if necessary
|
||||||
scheduleBlockProposal(node, slot, validator)
|
scheduleBlockProposal(node, slot, validator)
|
||||||
|
|
||||||
# Schedule attestations
|
|
||||||
let
|
|
||||||
committeesIdx = get_shard_committees_index(nextState, slot)
|
|
||||||
|
|
||||||
#for shard in node.beaconState.shard_committees_at_slots[committees_idx]:
|
#for shard in node.beaconState.shard_committees_at_slots[committees_idx]:
|
||||||
for crosslink_committee in get_crosslink_committees_at_slot(
|
for crosslink_committee in get_crosslink_committees_at_slot(
|
||||||
node.beaconState, committees_idx):
|
node.beaconState, committees_idx):
|
||||||
|
|
|
@ -31,9 +31,6 @@ func verify_bitfield*(bitfield: openarray[byte], committee_size: int): bool =
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
||||||
func mod_get[T](arr: openarray[T], pos: Natural): T =
|
|
||||||
arr[pos mod arr.len]
|
|
||||||
|
|
||||||
func shuffle*[T](values: seq[T], seed: Eth2Digest): seq[T] =
|
func shuffle*[T](values: seq[T], seed: Eth2Digest): seq[T] =
|
||||||
## Returns the shuffled ``values`` with seed as entropy.
|
## Returns the shuffled ``values`` with seed as entropy.
|
||||||
## TODO: this calls out for tests, but I odn't particularly trust spec
|
## TODO: this calls out for tests, but I odn't particularly trust spec
|
||||||
|
@ -114,15 +111,6 @@ func repeat_hash*(v: Eth2Digest, n: SomeInteger): Eth2Digest =
|
||||||
result = eth2hash(result.data)
|
result = eth2hash(result.data)
|
||||||
dec n
|
dec n
|
||||||
|
|
||||||
func get_shard_committees_index*(state: BeaconState, slot: uint64): uint64 =
|
|
||||||
# TODO temporary adapter; remove when all users gone
|
|
||||||
## Warning: as it stands, this helper only works during state updates _after_
|
|
||||||
## state.slot has been incremented but before shard_committees_at_slots has
|
|
||||||
## been updated!
|
|
||||||
# TODO spec unsigned-unsafe here
|
|
||||||
doAssert slot + (state.slot mod EPOCH_LENGTH) + EPOCH_LENGTH > state.slot
|
|
||||||
slot + (state.slot mod EPOCH_LENGTH) + EPOCH_LENGTH - state.slot
|
|
||||||
|
|
||||||
func integer_squareroot*(n: SomeInteger): SomeInteger =
|
func integer_squareroot*(n: SomeInteger): SomeInteger =
|
||||||
## The largest integer ``x`` such that ``x**2`` is less than ``n``.
|
## The largest integer ``x`` such that ``x**2`` is less than ``n``.
|
||||||
var
|
var
|
||||||
|
|
|
@ -66,13 +66,6 @@ func get_previous_epoch_committee_count(state: BeaconState): uint64 =
|
||||||
)
|
)
|
||||||
get_epoch_committee_count(len(previous_active_validators))
|
get_epoch_committee_count(len(previous_active_validators))
|
||||||
|
|
||||||
func get_current_epoch_committee_count_per_slot(state: BeaconState): uint64 =
|
|
||||||
let current_active_validators = get_active_validator_indices(
|
|
||||||
state.validator_registry,
|
|
||||||
state.current_calculation_epoch,
|
|
||||||
)
|
|
||||||
get_epoch_committee_count(len(current_active_validators))
|
|
||||||
|
|
||||||
func get_crosslink_committees_at_slot*(state: BeaconState, slot: uint64):
|
func get_crosslink_committees_at_slot*(state: BeaconState, slot: uint64):
|
||||||
seq[CrosslinkCommittee] =
|
seq[CrosslinkCommittee] =
|
||||||
## Returns the list of ``(committee, shard)`` tuples for the ``slot``.
|
## Returns the list of ``(committee, shard)`` tuples for the ``slot``.
|
||||||
|
@ -86,7 +79,7 @@ func get_crosslink_committees_at_slot*(state: BeaconState, slot: uint64):
|
||||||
assert previous_epoch <= epoch
|
assert previous_epoch <= epoch
|
||||||
assert epoch < next_epoch
|
assert epoch < next_epoch
|
||||||
|
|
||||||
func get_epoch_specific_params() : auto =
|
template get_epoch_specific_params(): auto =
|
||||||
if epoch < current_epoch:
|
if epoch < current_epoch:
|
||||||
let
|
let
|
||||||
committees_per_epoch = get_previous_epoch_committee_count(state)
|
committees_per_epoch = get_previous_epoch_committee_count(state)
|
||||||
|
@ -102,7 +95,8 @@ func get_crosslink_committees_at_slot*(state: BeaconState, slot: uint64):
|
||||||
shuffling_start_shard = state.current_epoch_start_shard
|
shuffling_start_shard = state.current_epoch_start_shard
|
||||||
(committees_per_epoch, seed, shuffling_epoch, shuffling_start_shard)
|
(committees_per_epoch, seed, shuffling_epoch, shuffling_start_shard)
|
||||||
|
|
||||||
let (committees_per_epoch, seed, shuffling_epoch, shuffling_start_shard) = get_epoch_specific_params()
|
let (committees_per_epoch, seed, shuffling_epoch, shuffling_start_shard) =
|
||||||
|
get_epoch_specific_params()
|
||||||
|
|
||||||
let
|
let
|
||||||
shuffling = get_shuffling(
|
shuffling = get_shuffling(
|
||||||
|
|
Loading…
Reference in New Issue