remove superfluous TODOs/not-really-TODOs, type conversion, imports (#2025)

This commit is contained in:
tersec 2020-11-16 17:10:51 +01:00 committed by GitHub
parent 7473d83ea3
commit 21c4ce8fd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 13 additions and 15 deletions

View File

@ -162,7 +162,7 @@ type
parent*: BlockRef ##\ parent*: BlockRef ##\
## Not nil, except for the tail ## Not nil, except for the tail
slot*: Slot # TODO could calculate this by walking to root, but.. slot*: Slot # could calculate this by walking to root, but..
epochRefs*: seq[EpochRef] ##\ epochRefs*: seq[EpochRef] ##\
## Cached information about the epochs starting at this block. ## Cached information about the epochs starting at this block.

View File

@ -139,7 +139,6 @@ proc is_valid_indexed_attestation*(
# Verify aggregate signature # Verify aggregate signature
if skipBLSValidation notin flags: if skipBLSValidation notin flags:
# TODO: fuse loops with blsFastAggregateVerify
let pubkeys = mapIt( let pubkeys = mapIt(
indexed_attestation.attesting_indices, epochRef.validator_keys[it]) indexed_attestation.attesting_indices, epochRef.validator_keys[it])
if not verify_attestation_signature( if not verify_attestation_signature(
@ -164,7 +163,6 @@ proc is_valid_indexed_attestation*(
# Verify aggregate signature # Verify aggregate signature
if skipBLSValidation notin flags: if skipBLSValidation notin flags:
# TODO: fuse loops with blsFastAggregateVerify
let pubkeys = mapIt( let pubkeys = mapIt(
attesting_indices, epochRef.validator_keys[it]) attesting_indices, epochRef.validator_keys[it])
if not verify_attestation_signature( if not verify_attestation_signature(

View File

@ -494,7 +494,7 @@ template errorMsgLit(x: static string): ErrorMsg =
const val = ErrorMsg toBytes(x) const val = ErrorMsg toBytes(x)
val val
proc formatErrorMsg(msg: ErrorMSg): string = func formatErrorMsg(msg: ErrorMSg): string =
let candidate = string.fromBytes(asSeq(msg)) let candidate = string.fromBytes(asSeq(msg))
for c in candidate: for c in candidate:
# TODO UTF-8 - but let's start with ASCII # TODO UTF-8 - but let's start with ASCII

View File

@ -29,7 +29,7 @@ import
beacon_node_common, beacon_node_types, beacon_node_status, beacon_node_common, beacon_node_types, beacon_node_status,
block_pools/[chain_dag, quarantine, clearance, block_pools_types], block_pools/[chain_dag, quarantine, clearance, block_pools_types],
nimbus_binary_common, network_metadata, nimbus_binary_common, network_metadata,
eth1_monitor, version, ssz/[merkleization], merkle_minimal, eth1_monitor, version, ssz/merkleization,
sync_protocol, request_manager, keystore_management, interop, statusbar, sync_protocol, request_manager, keystore_management, interop, statusbar,
sync_manager, validator_duties, filepath, sync_manager, validator_duties, filepath,
validator_slashing_protection, ./eth2_processor validator_slashing_protection, ./eth2_processor

View File

@ -201,7 +201,7 @@ proc onSlotStart(vc: ValidatorClient, lastSlot, scheduledSlot: Slot) {.gcsafe, a
# TODO I don't like these (u)int64-to-int conversions... # TODO I don't like these (u)int64-to-int conversions...
let attestation = await validator.produceAndSignAttestation( let attestation = await validator.produceAndSignAttestation(
ad, a.committee_length.int, a.validator_committee_index.int, ad, a.committee_length.int, a.validator_committee_index,
vc.fork, vc.beaconGenesis.genesis_validators_root) vc.fork, vc.beaconGenesis.genesis_validators_root)
discard await vc.client.post_v1_beacon_pool_attestations(attestation) discard await vc.client.post_v1_beacon_pool_attestations(attestation)

View File

@ -187,7 +187,7 @@ proc installBeaconApiHandlers*(rpcServer: RpcServer, node: BeaconNode) =
proc forSlot(slot: Slot, res: var seq[BeaconStatesCommitteesTuple]) = proc forSlot(slot: Slot, res: var seq[BeaconStatesCommitteesTuple]) =
let committees_per_slot = let committees_per_slot =
get_committee_count_per_slot(state, slot.epoch, cache) get_committee_count_per_slot(state, slot.epoch, cache)
if index == 0: # TODO this means if the parameter is missing (its optional) if index == 0: # parameter is missing (it's optional)
for committee_index in 0'u64..<committees_per_slot: for committee_index in 0'u64..<committees_per_slot:
res.add(getCommittee(slot, committee_index.CommitteeIndex)) res.add(getCommittee(slot, committee_index.CommitteeIndex))
else: else:
@ -195,7 +195,7 @@ proc installBeaconApiHandlers*(rpcServer: RpcServer, node: BeaconNode) =
raise newException(ValueError, "Committee index out of bounds") raise newException(ValueError, "Committee index out of bounds")
res.add(getCommittee(slot, index.CommitteeIndex)) res.add(getCommittee(slot, index.CommitteeIndex))
if slot == 0: # TODO this means if the parameter is missing (its optional) if slot == 0: # parameter is missing (it's optional)
for i in 0 ..< SLOTS_PER_EPOCH: for i in 0 ..< SLOTS_PER_EPOCH:
forSlot(compute_start_slot_at_epoch(epoch.Epoch) + i, result) forSlot(compute_start_slot_at_epoch(epoch.Epoch) + i, result)
else: else:

View File

@ -93,7 +93,7 @@ template loopOverWords(lhs, rhs: BitSeq,
var rhsWord: WordType var rhsWord: WordType
var firstByteOfLastWord, lastByteOfLastWord: int var firstByteOfLastWord, lastByteOfLastWord: int
# TODO: Returing a `var` value from an iterator is always safe due to # TODO: Returning a `var` value from an iterator is always safe due to
# the way inlining works, but currently the compiler reports an error # the way inlining works, but currently the compiler reports an error
# when a local variable escapes. We have to cheat it with this location # when a local variable escapes. We have to cheat it with this location
# obfuscation through pointers: # obfuscation through pointers:

View File

@ -131,8 +131,8 @@ template bytes*(x: BitList): auto = seq[byte](x)
template `[]`*(x: BitList, idx: auto): auto = BitSeq(x)[idx] template `[]`*(x: BitList, idx: auto): auto = BitSeq(x)[idx]
template `[]=`*(x: var BitList, idx: auto, val: bool) = BitSeq(x)[idx] = val template `[]=`*(x: var BitList, idx: auto, val: bool) = BitSeq(x)[idx] = val
template `==`*(a, b: BitList): bool = BitSeq(a) == BitSeq(b) template `==`*(a, b: BitList): bool = BitSeq(a) == BitSeq(b)
template setBit*(x: var BitList, idx: int) = setBit(BitSeq(x), idx) template setBit*(x: var BitList, idx: Natural) = setBit(BitSeq(x), idx)
template clearBit*(x: var BitList, idx: int) = clearBit(BitSeq(x), idx) template clearBit*(x: var BitList, idx: Natural) = clearBit(BitSeq(x), idx)
template overlaps*(a, b: BitList): bool = overlaps(BitSeq(a), BitSeq(b)) template overlaps*(a, b: BitList): bool = overlaps(BitSeq(a), BitSeq(b))
template combine*(a: var BitList, b: BitList) = combine(BitSeq(a), BitSeq(b)) template combine*(a: var BitList, b: BitList) = combine(BitSeq(a), BitSeq(b))
template isSubsetOf*(a, b: BitList): bool = isSubsetOf(BitSeq(a), BitSeq(b)) template isSubsetOf*(a, b: BitList): bool = isSubsetOf(BitSeq(a), BitSeq(b))

View File

@ -74,7 +74,7 @@ proc signAttestation*(v: AttachedValidator,
proc produceAndSignAttestation*(validator: AttachedValidator, proc produceAndSignAttestation*(validator: AttachedValidator,
attestationData: AttestationData, attestationData: AttestationData,
committeeLen: int, indexInCommittee: int, committeeLen: int, indexInCommittee: Natural,
fork: Fork, genesis_validators_root: Eth2Digest): fork: Fork, genesis_validators_root: Eth2Digest):
Future[Attestation] {.async.} = Future[Attestation] {.async.} =
let validatorSignature = await validator.signAttestation(attestationData, let validatorSignature = await validator.signAttestation(attestationData,

View File

@ -10,7 +10,7 @@
import import
# Standard library # Standard library
math, random, math,
# Specs # Specs
../../beacon_chain/spec/[datatypes, crypto, digest, ../../beacon_chain/spec/[datatypes, crypto, digest,

View File

@ -2,7 +2,7 @@
import import
unittest, stint, ./testutil, stew/byteutils, unittest, stint, ./testutil, stew/byteutils,
../beacon_chain/[interop, merkle_minimal, ssz], ../beacon_chain/[interop, ssz],
../beacon_chain/spec/[beaconstate, crypto, datatypes, presets] ../beacon_chain/spec/[beaconstate, crypto, datatypes, presets]
# Interop test yaml, found here: # Interop test yaml, found here:

View File

@ -7,7 +7,7 @@
import import
options, stew/endians2, options, stew/endians2,
../beacon_chain/[extras, merkle_minimal, validator_pool], ../beacon_chain/[extras, validator_pool],
../beacon_chain/ssz/merkleization, ../beacon_chain/ssz/merkleization,
../beacon_chain/spec/[beaconstate, crypto, datatypes, digest, presets, ../beacon_chain/spec/[beaconstate, crypto, datatypes, digest, presets,
helpers, validator, signatures, state_transition] helpers, validator, signatures, state_transition]