Gets this module to compile, at expense of deviating from old spec

Some changes to integrate with the newer `ValidatorRecord` type.

Deviates from the old spec but should be updated shortly with newer logic
so the breaking change is only temporary.
This commit is contained in:
Alex Stokes 2019-01-10 14:49:06 -06:00
parent 2d1b61522b
commit b09d44c235
No known key found for this signature in database
GPG Key ID: 51CE1721B245C086

View File

@ -1,6 +1,6 @@
use bls::verify_proof_of_possession; use bls::verify_proof_of_possession;
use spec::ChainSpec; use spec::ChainSpec;
use types::{BeaconState, Deposit, ValidatorRecord, ValidatorStatus}; use types::{BeaconState, Deposit, ValidatorRecord};
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone)]
pub enum ValidatorInductionError { pub enum ValidatorInductionError {
@ -43,13 +43,10 @@ pub fn process_deposit(
pubkey: deposit_input.pubkey.clone(), pubkey: deposit_input.pubkey.clone(),
withdrawal_credentials: deposit_input.withdrawal_credentials, withdrawal_credentials: deposit_input.withdrawal_credentials,
randao_commitment: deposit_input.randao_commitment, randao_commitment: deposit_input.randao_commitment,
randao_layers: 0,
status: ValidatorStatus::PendingActivation,
latest_status_change_slot: state.validator_registry_latest_change_slot,
exit_count: 0,
custody_commitment: deposit_input.custody_commitment, custody_commitment: deposit_input.custody_commitment,
latest_custody_reseed_slot: 0, latest_custody_reseed_slot: 0,
penultimate_custody_reseed_slot: 0, penultimate_custody_reseed_slot: 0,
..std::default::Default::default()
}; };
match min_empty_validator_index(state, spec) { match min_empty_validator_index(state, spec) {
@ -68,13 +65,11 @@ pub fn process_deposit(
} }
} }
fn min_empty_validator_index(state: &BeaconState, spec: &ChainSpec) -> Option<usize> { // NOTE: this has been modified from the spec to get tests working
// this function is no longer used in the latest spec so this is simply a transition step
fn min_empty_validator_index(state: &BeaconState, _spec: &ChainSpec) -> Option<usize> {
for i in 0..state.validator_registry.len() { for i in 0..state.validator_registry.len() {
if state.validator_balances[i] == 0 if state.validator_balances[i] == 0 {
&& state.validator_registry[i].latest_status_change_slot
+ spec.zero_balance_validator_ttl
<= state.slot
{
return Some(i); return Some(i);
} }
} }
@ -187,8 +182,7 @@ mod tests {
let mut state = BeaconState::default(); let mut state = BeaconState::default();
let spec = ChainSpec::foundation(); let spec = ChainSpec::foundation();
let mut validator = get_validator(); let validator = get_validator();
validator.latest_status_change_slot = 0;
state.validator_registry.push(validator); state.validator_registry.push(validator);
state.validator_balances.push(0); state.validator_balances.push(0);