diff --git a/beacon_chain/attestation_aggregation.nim b/beacon_chain/attestation_aggregation.nim index 64e0d24f5..87bbe8ea8 100644 --- a/beacon_chain/attestation_aggregation.nim +++ b/beacon_chain/attestation_aggregation.nim @@ -12,9 +12,8 @@ import ./attestation_pool, ./beacon_node_types, ./ssz # https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#aggregation-selection -func is_aggregator(state: BeaconState, slot: Slot, index: uint64, +func is_aggregator(state: BeaconState, slot: Slot, index: CommitteeIndex, slot_signature: ValidatorSig): bool = - # TODO index is a CommitteeIndex, aka uint64 var cache = get_empty_per_epoch_cache() let @@ -23,10 +22,8 @@ func is_aggregator(state: BeaconState, slot: Slot, index: uint64, bytes_to_int(eth2hash(slot_signature.toRaw()).data[0..7]) mod modulo == 0 proc aggregate_attestations*( - pool: AttestationPool, state: BeaconState, index: uint64, + pool: AttestationPool, state: BeaconState, index: CommitteeIndex, privkey: ValidatorPrivKey, trailing_distance: uint64): Option[AggregateAndProof] = - # TODO alias CommitteeIndex to actual type then convert various uint64's here - doAssert state.slot >= trailing_distance # https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/p2p-interface.md#configuration @@ -41,7 +38,7 @@ proc aggregate_attestations*( doAssert state.slot >= slot # TODO performance issue for future, via get_active_validator_indices(...) - doAssert index < get_committee_count_at_slot(state, slot) + doAssert index.uint64 < get_committee_count_at_slot(state, slot) # TODO for testing purposes, refactor this into the condition check # and just calculation @@ -54,7 +51,7 @@ proc aggregate_attestations*( # TODO this won't actually match anything let attestation_data = AttestationData( slot: slot, - index: index, + index: index.uint64, beacon_block_root: get_block_root_at_slot(state, slot)) # https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#construct-aggregate @@ -65,7 +62,7 @@ proc aggregate_attestations*( if attestation.data == attestation_data: # https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#aggregateandproof return some(AggregateAndProof( - aggregator_index: index, + aggregator_index: index.uint64, aggregate: attestation, selection_proof: slot_signature)) diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index 0268ec0b9..ff58e59c9 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -546,8 +546,8 @@ proc handleAttestations(node: BeaconNode, head: BlockRef, slot: Slot) = let committees_per_slot = get_committee_count_at_slot(state, slot) for committee_index in 0'u64..= 1