mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-10 22:36:01 +00:00
call out inefficiencies and quirks for future consideration
This commit is contained in:
parent
4d6b068697
commit
a661e5afd8
@ -114,16 +114,26 @@ func append_to_recent_block_hashes*(old_block_hashes: seq[Eth2Digest],
|
|||||||
proc get_attestation_participants*(state: BeaconState,
|
proc get_attestation_participants*(state: BeaconState,
|
||||||
attestation_data: AttestationSignedData,
|
attestation_data: AttestationSignedData,
|
||||||
attester_bitfield: seq[byte]): seq[int] =
|
attester_bitfield: seq[byte]): seq[int] =
|
||||||
let
|
## Attestation participants in the attestation data are called out in a
|
||||||
sncs_for_slot = get_shards_and_committees_for_slot(
|
## bit field that corresponds to the committee of the shard at the time - this
|
||||||
state, attestation_data.slot)
|
## function converts it to list of indices in to BeaconState.validators
|
||||||
|
## Returns empty list if the shard is not found
|
||||||
|
# XXX Linear search through shard list? borderline ok, it's a small list
|
||||||
|
# XXX bitfield type needed, once bit order settles down
|
||||||
|
# XXX iterator candidate
|
||||||
|
let
|
||||||
|
sncs_for_slot = get_shards_and_committees_for_slot(
|
||||||
|
state, attestation_data.slot)
|
||||||
|
|
||||||
for snc in sncs_for_slot:
|
for snc in sncs_for_slot:
|
||||||
if snc.shard == attestation_data.shard:
|
if snc.shard != attestation_data.shard:
|
||||||
assert len(attester_bitfield) == ceil_div8(len(snc.committee))
|
continue
|
||||||
for i, vindex in snc.committee:
|
|
||||||
let
|
# XXX investigate functional library / approach to help avoid loop bugs
|
||||||
bit = (attester_bitfield[i div 8] shr (7 - (i mod 8))) mod 2
|
assert len(attester_bitfield) == ceil_div8(len(snc.committee))
|
||||||
if bit == 1:
|
for i, vindex in snc.committee:
|
||||||
result.add(vindex)
|
let
|
||||||
return
|
bit = (attester_bitfield[i div 8] shr (7 - (i mod 8))) mod 2
|
||||||
|
if bit == 1:
|
||||||
|
result.add(vindex)
|
||||||
|
return # found the shard, we're done
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
#
|
#
|
||||||
# How wrong the code is:
|
# How wrong the code is:
|
||||||
# https://github.com/ethereum/eth2.0-specs/compare/126a7abfa86448091a0e037f52966b6a9531a857...master
|
# https://github.com/ethereum/eth2.0-specs/compare/126a7abfa86448091a0e037f52966b6a9531a857...master
|
||||||
|
#
|
||||||
|
# These datatypes are used as specifications for serialization - thus should not
|
||||||
|
# be altered outside of what the spec says. Likewise, they should not be made
|
||||||
|
# `ref` - this can be achieved by wrapping them in higher-level
|
||||||
|
# types / composition
|
||||||
|
|
||||||
import
|
import
|
||||||
intsets, eth_common, math,
|
intsets, eth_common, math,
|
||||||
|
@ -76,4 +76,4 @@ func get_new_recent_block_hashes*(old_block_hashes: seq[Eth2Digest],
|
|||||||
for _ in 0 ..< min(d, old_block_hashes.len):
|
for _ in 0 ..< min(d, old_block_hashes.len):
|
||||||
result.add parent_hash
|
result.add parent_hash
|
||||||
|
|
||||||
func ceil_div8*(v: int): int = (v + 7) div 8
|
func ceil_div8*(v: int): int = (v + 7) div 8 # XXX use a proper bitarray!
|
||||||
|
@ -26,6 +26,8 @@ func get_new_validators*(current_validators: seq[ValidatorRecord],
|
|||||||
status: ValidatorStatusCodes,
|
status: ValidatorStatusCodes,
|
||||||
current_slot: uint64
|
current_slot: uint64
|
||||||
): tuple[validators: seq[ValidatorRecord], index: int] =
|
): tuple[validators: seq[ValidatorRecord], index: int] =
|
||||||
|
# XXX Spec candidate: inefficient API
|
||||||
|
#
|
||||||
# Check that validator really did register
|
# Check that validator really did register
|
||||||
# let signed_message = signed_message = bytes32(pubkey) + withdrawal_credentials + randao_commitment
|
# let signed_message = signed_message = bytes32(pubkey) + withdrawal_credentials + randao_commitment
|
||||||
# assert BLSVerify(pub=pubkey,
|
# assert BLSVerify(pub=pubkey,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user