Fix invalid attestation verification condition (#1321)

* Fix bug with attestation target

* Change comment wording
This commit is contained in:
Paul Hauner
2020-07-01 12:45:34 +10:00
committed by GitHub
parent 314c077870
commit ac89bb190a
2 changed files with 39 additions and 2 deletions

View File

@@ -608,10 +608,20 @@ where
beacon_block_root: indexed_attestation.data.beacon_block_root,
})?;
if block.target_root != target.root {
// If an attestation points to a block that is from an earlier slot than the attestation,
// then all slots between the block and attestation must be skipped. Therefore if the block
// is from a prior epoch to the attestation, then the target root must be equal to the root
// of the block that is being attested to.
let expected_target = if target.epoch > block.slot.epoch(E::slots_per_epoch()) {
indexed_attestation.data.beacon_block_root
} else {
block.target_root
};
if expected_target != target.root {
return Err(InvalidAttestation::InvalidTarget {
attestation: target.root,
local: block.target_root,
local: expected_target,
});
}