Fix bug with attestation production

It was being produced with the wrong source root. I will raise an issue
on the spec as it's a tricky one.
This commit is contained in:
Paul Hauner 2019-03-30 17:12:43 +11:00
parent 397e104f9b
commit 7b3f317abf
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6

View File

@ -475,11 +475,7 @@ where
/// Produce an `AttestationData` that is valid for the present `slot` and given `shard`. /// Produce an `AttestationData` that is valid for the present `slot` and given `shard`.
pub fn produce_attestation_data(&self, shard: u64) -> Result<AttestationData, Error> { pub fn produce_attestation_data(&self, shard: u64) -> Result<AttestationData, Error> {
trace!("BeaconChain::produce_attestation: shard: {}", shard); trace!("BeaconChain::produce_attestation: shard: {}", shard);
let source_epoch = self.state.read().current_justified_epoch; let state = self.state.read();
let source_root = *self.state.read().get_block_root(
source_epoch.start_slot(self.spec.slots_per_epoch),
&self.spec,
)?;
let target_root = *self.state.read().get_block_root( let target_root = *self.state.read().get_block_root(
self.state self.state
@ -500,8 +496,8 @@ where
epoch: self.state.read().slot.epoch(self.spec.slots_per_epoch), epoch: self.state.read().slot.epoch(self.spec.slots_per_epoch),
crosslink_data_root: Hash256::zero(), crosslink_data_root: Hash256::zero(),
}, },
source_epoch, source_epoch: state.current_justified_epoch,
source_root, source_root: state.current_justified_root,
}) })
} }