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

View File

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

View File

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

View File

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