log attestation/block when slashing protection is activated (#4148)

This commit is contained in:
Jacek Sieka 2022-09-19 21:50:19 +02:00 committed by GitHub
parent 5a32dacfc5
commit f9a2860a61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 23 deletions

View File

@ -100,7 +100,7 @@ iterator get_attesting_indices*(
slot =
check_attestation_slot_target(attestation.data).valueOr:
warn "Invalid attestation slot in trusted attestation",
attestation = shortLog(attestation.data)
attestation = shortLog(attestation)
doAssert strictVerification notin dag.updateFlags
break
blck =
@ -112,14 +112,14 @@ iterator get_attesting_indices*(
blck.atCheckpoint(attestation.data.target).valueOr:
warn "Unknown attestation target in trusted attestation",
blck = shortLog(blck),
attestation = shortLog(attestation.data)
attestation = shortLog(attestation)
doAssert strictVerification notin dag.updateFlags
break
shufflingRef =
dag.getShufflingRef(target.blck, target.slot.epoch, false).valueOr:
warn "Attestation shuffling not found",
blck = shortLog(blck),
attestation = shortLog(attestation.data)
attestation = shortLog(attestation)
doAssert strictVerification notin dag.updateFlags
break
@ -129,7 +129,7 @@ iterator get_attesting_indices*(
CommitteeIndex.init(attestation.data.index, committeesPerSlot).valueOr:
warn "Unexpected committee index in trusted attestation",
blck = shortLog(blck),
attestation = shortLog(attestation.data)
attestation = shortLog(attestation)
doAssert strictVerification notin dag.updateFlags
break

View File

@ -47,7 +47,6 @@ proc serveAttestation(service: AttestationServiceRef, adata: AttestationData,
let signingRoot =
compute_attestation_signing_root(
fork, vc.beaconGenesis.genesis_validators_root, adata)
let attestationRoot = adata.hash_tree_root()
let notSlashable = vc.attachedValidators[].slashingProtection
.registerAttestation(vindex, validator.pubkey,
@ -55,7 +54,8 @@ proc serveAttestation(service: AttestationServiceRef, adata: AttestationData,
adata.target.epoch, signingRoot)
if notSlashable.isErr():
warn "Slashing protection activated for attestation",
slot = duty.data.slot,
attestationData = shortLog(adata),
signingRoot = shortLog(signingRoot),
validator = shortLog(validator),
validator_index = vindex, badVoteDetails = $notSlashable.error
return false
@ -85,7 +85,6 @@ proc serveAttestation(service: AttestationServiceRef, adata: AttestationData,
debug "Sending attestation", attestation = shortLog(attestation),
validator = shortLog(validator), validator_index = vindex,
attestation_root = shortLog(attestationRoot),
delay = vc.getDelay(adata.slot.attestation_deadline())
let res =
@ -115,8 +114,7 @@ proc serveAttestation(service: AttestationServiceRef, adata: AttestationData,
notice "Attestation published", attestation = shortLog(attestation),
validator = shortLog(validator),
validator_index = vindex,
delay = delay,
attestation_root = attestationRoot
delay = delay
else:
warn "Attestation was not accepted by beacon node",
attestation = shortLog(attestation),

View File

@ -69,13 +69,12 @@ proc publishBlock(vc: ValidatorClientRef, currentSlot, slot: Slot,
return
let blockRoot = withBlck(beaconBlock): hash_tree_root(blck)
# TODO: signing_root is recomputed in getBlockSignature just after
let signing_root = compute_block_signing_root(fork, genesisRoot, slot,
blockRoot)
# TODO: signingRoot is recomputed in getBlockSignature just after
let signingRoot = compute_block_signing_root(fork, genesisRoot, slot,
blockRoot)
let notSlashable = vc.attachedValidators[]
.slashingProtection
.registerBlock(ValidatorIndex(beaconBlock.proposer_index),
validator.pubkey, slot, signing_root)
.registerBlock(vindex, validator.pubkey, slot, signingRoot)
if notSlashable.isOk():
let signature =
@ -138,6 +137,7 @@ proc publishBlock(vc: ValidatorClientRef, currentSlot, slot: Slot,
else:
warn "Slashing protection activated for block proposal",
blockRoot = shortLog(blockRoot), blck = shortLog(beaconBlock),
signingRoot = shortLog(signingRoot),
validator = shortLog(validator),
wall_slot = currentSlot,
existingProposal = notSlashable.error

View File

@ -259,7 +259,7 @@ proc createAndSendAttestation(node: BeaconNode,
fork, genesis_validators_root, data)
if res.isErr():
warn "Unable to sign attestation", validator = shortLog(validator),
data = shortLog(data), error_msg = res.error()
attestatingData = shortLog(data), error_msg = res.error()
return
res.get()
attestation =
@ -619,14 +619,16 @@ proc getBlindedBeaconBlock[T](
fork = node.dag.forkAtEpoch(slot.epoch)
genesis_validators_root = node.dag.genesis_validators_root
blockRoot = hash_tree_root(blindedBlock.message)
signing_root = compute_block_signing_root(
signingRoot = compute_block_signing_root(
fork, genesis_validators_root, slot, blockRoot)
notSlashable = node.attachedValidators
.slashingProtection
.registerBlock(validator_index, validator.pubkey, slot, signing_root)
.registerBlock(validator_index, validator.pubkey, slot, signingRoot)
if notSlashable.isErr:
warn "Slashing protection activated for MEV block",
blockRoot = shortLog(blockRoot), blck = shortLog(blindedBlock),
signingRoot = shortLog(signingRoot),
validator = validator.pubkey,
slot = slot,
existingProposal = notSlashable.error
@ -832,15 +834,17 @@ proc proposeBlock(node: BeaconNode,
withBlck(forkedBlck):
let
blockRoot = hash_tree_root(blck)
signing_root = compute_block_signing_root(
signingRoot = compute_block_signing_root(
fork, genesis_validators_root, slot, blockRoot)
notSlashable = node.attachedValidators
.slashingProtection
.registerBlock(validator_index, validator.pubkey, slot, signing_root)
.registerBlock(validator_index, validator.pubkey, slot, signingRoot)
if notSlashable.isErr:
warn "Slashing protection activated",
warn "Slashing protection activated for block proposal",
blockRoot = shortLog(blockRoot), blck = shortLog(blck),
signingRoot = shortLog(signingRoot),
validator = validator.pubkey,
slot = slot,
existingProposal = notSlashable.error
@ -947,7 +951,7 @@ proc handleAttestations(node: BeaconNode, head: BlockRef, slot: Slot) =
let
data = makeAttestationData(epochRef, attestationHead, committee_index)
# TODO signing_root is recomputed in produceAndSignAttestation/signAttestation just after
signing_root = compute_attestation_signing_root(
signingRoot = compute_attestation_signing_root(
fork, genesis_validators_root, data)
registered = node.attachedValidators
.slashingProtection
@ -956,7 +960,7 @@ proc handleAttestations(node: BeaconNode, head: BlockRef, slot: Slot) =
validator.pubkey,
data.source.epoch,
data.target.epoch,
signing_root)
signingRoot)
if registered.isOk():
let subnet_id = compute_subnet_for_attestation(
committees_per_slot, data.slot, committee_index)
@ -965,7 +969,10 @@ proc handleAttestations(node: BeaconNode, head: BlockRef, slot: Slot) =
committee.len(), index_in_committee, subnet_id)
else:
warn "Slashing protection activated for attestation",
validator = validator.pubkey,
attestationData = shortLog(data),
signingRoot = shortLog(signingRoot),
validator_index,
validator = shortLog(validator),
badVoteDetails = $registered.error()
proc createAndSendSyncCommitteeMessage(node: BeaconNode,