Skip to content
Snippets Groups Projects
Commit c64cdfbe authored by Wei Tang's avatar Wei Tang
Browse files

beacon: process randao

parent 09c0ae01
Branches
No related merge requests found
mod header;
mod randao;
use crate::primitives::*;
use crate::types::*;
use crate::{Config, BeaconState, Error};
use bm_le::tree_root;
impl<C: Config> BeaconState<C> {
/// Process randao information given in a block.
pub fn process_randao(&mut self, body: &BeaconBlockBody<C>) -> Result<(), Error> {
let proposer = &self.validators[
self.beacon_proposer_index()? as usize
];
if !C::bls_verify(
&proposer.pubkey,
&tree_root::<C::Digest, _>(&self.current_epoch()),
&body.randao_reveal,
self.domain(C::domain_randao(), None)
) {
return Err(Error::RandaoSignatureInvalid)
}
let current_epoch = self.current_epoch();
self.randao_mixes[
(current_epoch % C::epochs_per_historical_vector()) as usize
] = self.randao_mix(current_epoch) ^
C::hash(&[&body.randao_reveal[..]]);
Ok(())
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment