op-pool: check previous epoch in get_attestations

This commit is contained in:
Michael Sproul 2019-03-25 11:56:30 +11:00
parent e512f7c0e1
commit 22a90a0224
No known key found for this signature in database
GPG Key ID: 77B1309D2E54E914

View File

@ -145,13 +145,17 @@ impl OperationPool {
/// Get a list of attestations for inclusion in a block.
pub fn get_attestations(&self, state: &BeaconState, spec: &ChainSpec) -> Vec<Attestation> {
// Attestations for the current fork...
// FIXME: should we also check domain bytes for the previous epoch?
let current_epoch = state.slot.epoch(spec.slots_per_epoch);
let domain_bytes = AttestationId::compute_domain_bytes(current_epoch, state, spec);
// Attestations for the current fork, which may be from the current or previous epoch.
let prev_epoch = state.previous_epoch(spec);
let current_epoch = state.current_epoch(spec);
let prev_domain_bytes = AttestationId::compute_domain_bytes(prev_epoch, state, spec);
let curr_domain_bytes = AttestationId::compute_domain_bytes(current_epoch, state, spec);
self.attestations
.iter()
.filter(|(key, _)| key.domain_bytes_match(&domain_bytes))
.filter(|(key, _)| {
key.domain_bytes_match(&prev_domain_bytes)
|| key.domain_bytes_match(&curr_domain_bytes)
})
.flat_map(|(_, attestations)| attestations)
// That are valid...
.filter(|attestation| validate_attestation(state, attestation, spec).is_ok())