Ensure per_epoch trans. happens before per_slot.

This commit is contained in:
Paul Hauner 2019-01-31 18:32:23 +11:00
parent c1b3d1b63e
commit 02a962d35d
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6

View File

@ -16,6 +16,10 @@ impl BeaconState {
previous_block_root: Hash256,
spec: &ChainSpec,
) -> Result<(), Error> {
if (self.slot + 1) % spec.epoch_length == 0 {
self.per_epoch_processing(spec)?;
}
self.slot += 1;
let block_proposer = self.get_beacon_proposer_index(self.slot, spec)?;
@ -32,10 +36,6 @@ impl BeaconState {
let root = merkle_root(&self.latest_block_roots[..]);
self.batched_block_roots.push(root);
}
if self.slot % spec.epoch_length == 0 {
self.per_epoch_processing(spec)?;
}
Ok(())
}