WIP trash changes

This commit is contained in:
Michael Sproul
2019-05-13 17:32:06 +10:00
parent ac51d7be3b
commit 13ec3d125e
8 changed files with 46 additions and 45 deletions

View File

@@ -1,5 +1,4 @@
use super::errors::InclusionError;
use super::get_attestation_participants::get_attestation_participants;
use types::*;
/// Returns the distance between the first included attestation for some validator and this
@@ -13,7 +12,9 @@ pub fn inclusion_distance(
spec: &ChainSpec,
) -> Result<u64, InclusionError> {
let attestation = earliest_included_attestation(state, attestations, validator_index, spec)?;
Ok((attestation.inclusion_slot - attestation.data.slot).as_u64())
// Ok((attestation.inclusion_slot - attestation.data.slot).as_u64())
// FIXME(sproul)
unimplemented!()
}
/// Returns the slot of the earliest included attestation for some validator.
@@ -25,8 +26,11 @@ pub fn inclusion_slot(
validator_index: usize,
spec: &ChainSpec,
) -> Result<Slot, InclusionError> {
/*
let attestation = earliest_included_attestation(state, attestations, validator_index, spec)?;
Ok(attestation.inclusion_slot)
*/
unimplemented!("FIXME(sproul) inclusion slot")
}
/// Finds the earliest included attestation for some validator.
@@ -38,6 +42,9 @@ fn earliest_included_attestation(
validator_index: usize,
spec: &ChainSpec,
) -> Result<PendingAttestation, InclusionError> {
// FIXME(sproul)
unimplemented!()
/*
let mut included_attestations = vec![];
for (i, a) in attestations.iter().enumerate() {
@@ -53,4 +60,5 @@ fn earliest_included_attestation(
.min_by_key(|i| attestations[**i].inclusion_slot)
.ok_or_else(|| InclusionError::NoAttestationsForValidator)?;
Ok(attestations[*earliest_attestation_index].clone())
*/
}

View File

@@ -1,4 +1,4 @@
use crate::common::exit_validator;
// use crate::common::exit_validator;
use types::{BeaconStateError as Error, *};
/// Iterate through the validator registry and eject active validators with balance below
@@ -12,7 +12,7 @@ pub fn process_ejections(state: &mut BeaconState, spec: &ChainSpec) -> Result<()
.get_cached_active_validator_indices(RelativeEpoch::Current, spec)?
.iter()
.filter_map(|&i| {
if state.validator_balances[i as usize] < spec.ejection_balance {
if state.balances[i as usize] < spec.ejection_balance {
Some(i)
} else {
None
@@ -21,7 +21,8 @@ pub fn process_ejections(state: &mut BeaconState, spec: &ChainSpec) -> Result<()
.collect();
for validator_index in exitable {
exit_validator(state, validator_index, spec)?
// FIXME(sproul)
// exit_validator(state, validator_index, spec)?
}
Ok(())

View File

@@ -22,9 +22,11 @@ pub fn process_exit_queue(state: &mut BeaconState, spec: &ChainSpec) {
eligable_indices.sort_by_key(|i| state.validator_registry[*i].exit_epoch);
for (dequeues, index) in eligable_indices.iter().enumerate() {
/* FIXME(sproul)
if dequeues as u64 >= spec.max_exit_dequeues_per_epoch {
break;
}
*/
prepare_validator_for_withdrawal(state, *index, spec);
}
}

View File

@@ -24,10 +24,10 @@ pub fn process_slashings(
let penalty = std::cmp::max(
effective_balance * std::cmp::min(total_penalities * 3, current_total_balance)
/ current_total_balance,
effective_balance / spec.min_penalty_quotient,
effective_balance / 1, /* FIXME(sproul): spec.min_penalty_quotient, */
);
state.validator_balances[index] -= penalty;
state.balances[index] -= penalty;
}
}