Ignore attestations to zero hash

This commit is contained in:
Paul Hauner 2019-06-15 19:11:02 -04:00
parent f4621a9f1a
commit 1128de535d
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C

View File

@ -103,7 +103,20 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
let block_hash = attestation.data.target_root;
// TODO: what happens when the target root is not the same slot as the block?
// Ignore any attestations to the zero hash.
//
// This is an edge case that results from the spec aliasing the zero hash to the genesis
// block. Attesters may attest to the zero hash if they have never seen a block.
//
// We have two options here:
//
// 1. Apply all zero-hash attestations to the zero hash.
// 2. Ignore all attestations to the zero hash.
//
// (1) becomes weird once we hit finality and fork choice drops the genesis block. (2) is
// fine becuase votes to the genesis block are not usefully, all validators already
// implicitly attest to genesis just by being present in the chain.
if block_hash != Hash256::zero() {
let block_slot = attestation
.data
.target_epoch
@ -113,6 +126,7 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
self.backend
.process_message(validator_index, block_hash, block_slot)?;
}
}
Ok(())
}