diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index 7e8eb83e5..ef380b5f9 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -69,7 +69,6 @@ type attachedValidatorBalanceTotal*: uint64 gossipState*: GossipState beaconClock*: BeaconClock - onAttestationSent*: OnAttestationCallback restKeysCache*: Table[ValidatorPubKey, ValidatorIndex] validatorMonitor*: ref ValidatorMonitor stateTtlCache*: StateTtlCache diff --git a/beacon_chain/gossip_processing/eth2_processor.nim b/beacon_chain/gossip_processing/eth2_processor.nim index cb04bd4db..d50b20bec 100644 --- a/beacon_chain/gossip_processing/eth2_processor.nim +++ b/beacon_chain/gossip_processing/eth2_processor.nim @@ -360,7 +360,7 @@ proc aggregateValidator*( wallTime) self.validatorMonitor[].registerAggregate( - src, wallTime, signedAggregateAndProof, attesting_indices) + src, wallTime, signedAggregateAndProof.message, attesting_indices) beacon_aggregates_received.inc() beacon_aggregate_delay.observe(delay.toFloatSeconds()) @@ -518,7 +518,7 @@ proc contributionValidator*( contributionAndProof, v.get()[0]) self.validatorMonitor[].registerSyncContribution( - src, wallTime, contributionAndProof, v.get()[1]) + src, wallTime, contributionAndProof.message, v.get()[1]) beacon_sync_committee_contributions_received.inc() diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index db30594b7..1ec726b97 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -159,8 +159,6 @@ proc init*(T: type BeaconNode, proc onAttestationReceived(data: Attestation) = eventBus.emit("attestation-received", data) - proc onAttestationSent(data: Attestation) = - eventBus.emit("attestation-sent", data) proc onVoluntaryExitAdded(data: SignedVoluntaryExit) = eventBus.emit("voluntary-exit", data) proc onBlockAdded(data: ForkedTrustedSignedBeaconBlock) = @@ -552,7 +550,6 @@ proc init*(T: type BeaconNode, consensusManager: consensusManager, gossipState: {}, beaconClock: beaconClock, - onAttestationSent: onAttestationSent, validatorMonitor: validatorMonitor, stateTtlCache: stateTtlCache ) diff --git a/beacon_chain/validators/validator_duties.nim b/beacon_chain/validators/validator_duties.nim index 186444bb2..e61898d44 100644 --- a/beacon_chain/validators/validator_duties.nim +++ b/beacon_chain/validators/validator_duties.nim @@ -222,8 +222,6 @@ proc sendAttestation*( if res.isGoodForSending: node.network.broadcastAttestation(subnet_id, attestation) beacon_attestations_sent.inc() - if not(isNil(node.onAttestationSent)): - node.onAttestationSent(attestation) ok() else: notice "Produced attestation failed validation", @@ -867,24 +865,26 @@ proc handleProposal(node: BeaconNode, head: BlockRef, slot: Slot): await proposeBlock(node, validator, proposer.get(), head, slot) proc makeAggregateAndProof*( - pool: var AttestationPool, epochRef: EpochRef, slot: Slot, index: CommitteeIndex, - validatorIndex: ValidatorIndex, slot_signature: ValidatorSig): Option[AggregateAndProof] = - doAssert validatorIndex in get_beacon_committee(epochRef, slot, index) + pool: var AttestationPool, epochRef: EpochRef, slot: Slot, + committee_index: CommitteeIndex, + validator_index: ValidatorIndex, + slot_signature: ValidatorSig): Opt[AggregateAndProof] = + doAssert validator_index in get_beacon_committee(epochRef, slot, committee_index) # TODO for testing purposes, refactor this into the condition check # and just calculation # https://github.com/ethereum/consensus-specs/blob/v1.1.9/specs/phase0/validator.md#aggregation-selection - if not is_aggregator(epochRef, slot, index, slot_signature): - return none(AggregateAndProof) + if not is_aggregator(epochRef, slot, committee_index, slot_signature): + return err() - let maybe_slot_attestation = getAggregatedAttestation(pool, slot, index) + let maybe_slot_attestation = getAggregatedAttestation(pool, slot, committee_index) if maybe_slot_attestation.isNone: - return none(AggregateAndProof) + return err() # https://github.com/ethereum/consensus-specs/blob/v1.1.9/specs/phase0/validator.md#construct-aggregate # https://github.com/ethereum/consensus-specs/blob/v1.1.9/specs/phase0/validator.md#aggregateandproof - some(AggregateAndProof( - aggregator_index: validatorIndex.uint64, + ok(AggregateAndProof( + aggregator_index: validator_index.uint64, aggregate: maybe_slot_attestation.get, selection_proof: slot_signature)) @@ -929,43 +929,47 @@ proc sendAggregatedAttestations( doAssert slotSigsData.len == slotSigs.len for i in 0..