From 22a90a0224c38c7b7913d520d9c90bc0fa5005c1 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 25 Mar 2019 11:56:30 +1100 Subject: [PATCH] op-pool: check previous epoch in get_attestations --- eth2/operation_pool/src/lib.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/eth2/operation_pool/src/lib.rs b/eth2/operation_pool/src/lib.rs index 6d276600a..fc894da27 100644 --- a/eth2/operation_pool/src/lib.rs +++ b/eth2/operation_pool/src/lib.rs @@ -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 { - // 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())