Allow broadcasting "ignored" gossip messages

Validator clients such as Vouch can be configured to work with multiple
beacon nodes simultaneously. In this configuration, the validator client
will try to broadcast the gossip messages through each of the connected
beacon nodes which may lead to a situation where some of the nodes see a
message arriving from the network before it arrives through the REST API.

This should not be considered an error and the beacon node should still
broadcast the message as the intented purpose of the Vouch strategy is
to ensure that the message will reach as many peers as possible.
This commit is contained in:
Zahary Karadjov 2021-11-25 21:05:11 +02:00
parent 7902e7684c
commit 4570f6e4ec
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 19 additions and 8 deletions

View File

@ -179,6 +179,17 @@ proc isSynced*(node: BeaconNode, head: BlockRef): bool =
else: else:
true true
func isGoodForSending(validationResult: ValidationRes): bool =
# Validator clients such as Vouch can be configured to work with multiple
# beacon nodes simultaneously. In this configuration, the validator client
# will try to broadcast the gossip messages through each of the connected
# beacon nodes which may lead to a situation where some of the nodes see a
# message arriving from the network before it arrives through the REST API.
# This should not be considered an error and the beacon node should still
# broadcast the message as the intented purpose of the Vouch strategy is
# to ensure that the message will reach as many peers as possible.
validationResult.isOk() or validationResult.error[0] == ValidationResult.Ignore
proc sendAttestation*( proc sendAttestation*(
node: BeaconNode, attestation: Attestation, node: BeaconNode, attestation: Attestation,
subnet_id: SubnetId, checkSignature: bool): Future[SendResult] {.async.} = subnet_id: SubnetId, checkSignature: bool): Future[SendResult] {.async.} =
@ -190,7 +201,7 @@ proc sendAttestation*(
attestation, subnet_id, checkSignature) attestation, subnet_id, checkSignature)
return return
if res.isOk(): if res.isGoodForSending:
node.network.broadcastAttestation(subnet_id, attestation) node.network.broadcastAttestation(subnet_id, attestation)
beacon_attestations_sent.inc() beacon_attestations_sent.inc()
if not(isNil(node.onAttestationSent)): if not(isNil(node.onAttestationSent)):
@ -213,7 +224,7 @@ proc sendSyncCommitteeMessage*(
let res = node.processor.syncCommitteeMessageValidator(msg, subcommitteeIdx, let res = node.processor.syncCommitteeMessageValidator(msg, subcommitteeIdx,
checkSignature) checkSignature)
return return
if res.isOk(): if res.isGoodForSending:
node.network.broadcastSyncCommitteeMessage(msg, subcommitteeIdx) node.network.broadcastSyncCommitteeMessage(msg, subcommitteeIdx)
beacon_sync_committee_messages_sent.inc() beacon_sync_committee_messages_sent.inc()
SendResult.ok() SendResult.ok()
@ -312,7 +323,7 @@ proc sendSyncCommitteeContribution*(
msg, checkSignature) msg, checkSignature)
return return
if res.isOk(): if res.isGoodForSending:
node.network.broadcastSignedContributionAndProof(msg) node.network.broadcastSignedContributionAndProof(msg)
beacon_sync_committee_contributions_sent.inc() beacon_sync_committee_contributions_sent.inc()
ok() ok()
@ -1094,7 +1105,7 @@ proc sendAggregateAndProof*(node: BeaconNode,
# REST/JSON-RPC API helper procedure. # REST/JSON-RPC API helper procedure.
let res = await node.processor.aggregateValidator(proof) let res = await node.processor.aggregateValidator(proof)
return return
if res.isOk(): if res.isGoodForSending:
node.network.broadcastAggregateAndProof(proof) node.network.broadcastAggregateAndProof(proof)
notice "Aggregated attestation sent", notice "Aggregated attestation sent",
@ -1113,7 +1124,7 @@ proc sendVoluntaryExit*(node: BeaconNode,
exit: SignedVoluntaryExit): SendResult = exit: SignedVoluntaryExit): SendResult =
# REST/JSON-RPC API helper procedure. # REST/JSON-RPC API helper procedure.
let res = node.processor[].voluntaryExitValidator(exit) let res = node.processor[].voluntaryExitValidator(exit)
if res.isOk(): if res.isGoodForSending:
node.network.broadcastVoluntaryExit(exit) node.network.broadcastVoluntaryExit(exit)
ok() ok()
else: else:
@ -1125,7 +1136,7 @@ proc sendAttesterSlashing*(node: BeaconNode,
slashing: AttesterSlashing): SendResult = slashing: AttesterSlashing): SendResult =
# REST/JSON-RPC API helper procedure. # REST/JSON-RPC API helper procedure.
let res = node.processor[].attesterSlashingValidator(slashing) let res = node.processor[].attesterSlashingValidator(slashing)
if res.isOk(): if res.isGoodForSending:
node.network.broadcastAttesterSlashing(slashing) node.network.broadcastAttesterSlashing(slashing)
ok() ok()
else: else:
@ -1137,7 +1148,7 @@ proc sendProposerSlashing*(node: BeaconNode,
slashing: ProposerSlashing): SendResult = slashing: ProposerSlashing): SendResult =
# REST/JSON-RPC API helper procedure. # REST/JSON-RPC API helper procedure.
let res = node.processor[].proposerSlashingValidator(slashing) let res = node.processor[].proposerSlashingValidator(slashing)
if res.isOk(): if res.isGoodForSending:
node.network.broadcastProposerSlashing(slashing) node.network.broadcastProposerSlashing(slashing)
ok() ok()
else: else: