miscellanous cleanups and removing a few funcs/procs from unnecessary global scopes
This commit is contained in:
parent
22adccc917
commit
8d9fdb0afd
|
@ -103,7 +103,7 @@ func process_deposit*(
|
|||
true
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#compute_activation_exit_epoch
|
||||
func compute_activation_exit_epoch*(epoch: Epoch): Epoch =
|
||||
func compute_activation_exit_epoch(epoch: Epoch): Epoch =
|
||||
## Return the epoch during which validator activations and exits initiated in
|
||||
## ``epoch`` take effect.
|
||||
epoch + 1 + MAX_SEED_LOOKAHEAD
|
||||
|
@ -371,7 +371,7 @@ func get_attesting_indices*(state: BeaconState,
|
|||
result.incl index
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#get_indexed_attestation
|
||||
func get_indexed_attestation*(state: BeaconState, attestation: Attestation,
|
||||
func get_indexed_attestation(state: BeaconState, attestation: Attestation,
|
||||
stateCache: var StateCache): IndexedAttestation =
|
||||
# Return the indexed attestation corresponding to ``attestation``.
|
||||
let
|
||||
|
|
|
@ -270,7 +270,7 @@ proc processAttesterSlashings(state: var BeaconState, blck: BeaconBlock,
|
|||
return true
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.4/specs/core/0_beacon-chain.md#attestations
|
||||
proc processAttestations*(
|
||||
proc processAttestations(
|
||||
state: var BeaconState, blck: BeaconBlock, flags: UpdateFlags,
|
||||
stateCache: var StateCache): bool =
|
||||
## Each block includes a number of attestations that the proposer chose. Each
|
||||
|
|
|
@ -13,11 +13,11 @@ import
|
|||
# TODO: Proceed to renaming and signature changes
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#compute_shuffled_index
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#compute_committee
|
||||
func get_shuffled_seq*(seed: Eth2Digest,
|
||||
list_size: uint64,
|
||||
): seq[ValidatorIndex] =
|
||||
func get_shuffled_seq(seed: Eth2Digest,
|
||||
list_size: uint64,
|
||||
): seq[ValidatorIndex] =
|
||||
## Via https://github.com/protolambda/eth2-shuffle/blob/master/shuffle.go
|
||||
## Shuffles ``validators`` into crosslink committees seeded by ``seed`` and
|
||||
## Shuffles ``validators`` into beacon committees, seeded by ``seed`` and
|
||||
## ``slot``.
|
||||
## Returns a list of ``SLOTS_PER_EPOCH * committees_per_slot`` committees
|
||||
## where each committee is itself a list of validator indices.
|
||||
|
@ -147,7 +147,7 @@ func get_empty_per_epoch_cache*(): StateCache =
|
|||
result.committee_count_cache = initTable[Epoch, uint64]()
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#compute_proposer_index
|
||||
func compute_proposer_index*(state: BeaconState, indices: seq[ValidatorIndex],
|
||||
func compute_proposer_index(state: BeaconState, indices: seq[ValidatorIndex],
|
||||
seed: Eth2Digest, stateCache: var StateCache): ValidatorIndex =
|
||||
# Return from ``indices`` a random index sampled by effective balance.
|
||||
const MAX_RANDOM_BYTE = 255
|
||||
|
|
|
@ -10,7 +10,7 @@ type Timers = enum
|
|||
tBlock = "Process non-epoch slot with block"
|
||||
tEpoch = "Process epoch slot with block"
|
||||
tHashBlock = "Tree-hash block"
|
||||
tShuffle = "Retrieve committee once using get_crosslink_committee"
|
||||
tShuffle = "Retrieve committee once using get_beacon_committee"
|
||||
tAttest = "Combine committee attestations"
|
||||
|
||||
template withTimer(stats: var RunningStat, body: untyped) =
|
||||
|
|
|
@ -130,13 +130,13 @@ proc mockAttestation*(
|
|||
|
||||
proc fillAggregateAttestation*(state: BeaconState, attestation: var Attestation) =
|
||||
var cache = get_empty_per_epoch_cache()
|
||||
let crosslink_committee = get_beacon_committee(
|
||||
let beacon_committee = get_beacon_committee(
|
||||
state,
|
||||
attestation.data.slot,
|
||||
attestation.data.index,
|
||||
cache
|
||||
)
|
||||
for i in 0 ..< crosslink_committee.len:
|
||||
for i in 0 ..< beacon_committee.len:
|
||||
attestation.aggregation_bits[i] = true
|
||||
|
||||
proc add*(state: var BeaconState, attestation: Attestation, slot: Slot) =
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# Sanity check on constants
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
{.used.}
|
||||
|
||||
import
|
||||
# Standard library
|
||||
macros, os, strutils, tables, math, json, streams,
|
||||
|
|
|
@ -107,10 +107,6 @@ suite "[Unit - Spec - Block processing] Attestations " & preset():
|
|||
# - source epoch in the future
|
||||
# - invalid current source root
|
||||
# - bad source root
|
||||
# - non-zero crosslink data root
|
||||
# - bad parent crosslink
|
||||
# - bad crosslink start epoch
|
||||
# - bad crosslink end epoch
|
||||
# - inconsistent custody bits length
|
||||
# - non-empty custody bits in phase 0
|
||||
|
||||
|
|
Loading…
Reference in New Issue