Implement the majority of per-epoch processing

This commit is contained in:
Paul Hauner
2019-01-26 14:50:56 +11:00
parent eb77fb75b7
commit 7ee836d118
8 changed files with 959 additions and 29 deletions

View File

@@ -0,0 +1,9 @@
use super::{BeaconChain, ClientDB, DBError, SlotClock};
impl<T, U> BeaconChain<T, U>
where
T: ClientDB,
U: SlotClock,
{
pub fn per_epoch_processing(&self) {}
}

View File

@@ -4,6 +4,7 @@ pub mod block_processing;
pub mod block_production;
mod canonical_head;
pub mod dump;
pub mod epoch_processing;
mod finalized_head;
mod info;
mod lmd_ghost;

View File

@@ -239,12 +239,13 @@ where
}
ensure!(
attestation.data.justified_block_root
== *get_block_root(
&state,
attestation.data.justified_slot,
self.spec.latest_block_roots_length
)
.ok_or(Error::NoBlockRoot)?,
== *state
.get_block_root(
&state,
attestation.data.justified_slot,
self.spec.latest_block_roots_length
)
.ok_or(Error::NoBlockRoot)?,
Error::BadAttestation
);
ensure!(
@@ -376,24 +377,10 @@ fn get_attestation_participants(
_attestation_data: &AttestationData,
_aggregation_bitfield: &BooleanBitfield,
) -> Vec<usize> {
// TODO: stubbed out.
vec![0, 1]
}
fn get_block_root(
state: &BeaconState,
slot: u64,
latest_block_roots_length: u64,
) -> Option<&Hash256> {
// TODO: test
if state.slot <= slot + latest_block_roots_length && slot <= state.slot {
state
.latest_block_roots
.get((slot % latest_block_roots_length) as usize)
} else {
None
}
}
fn penalize_validator(_state: &BeaconState, _proposer_index: usize) {
// TODO: stubbed out.
}