Update to spec v0.9.0

This commit is contained in:
Michael Sproul
2019-11-11 15:00:10 +11:00
parent 613fdbeda6
commit aaa5f2042f
93 changed files with 651 additions and 2203 deletions

View File

@@ -6,8 +6,8 @@ use crate::type_name;
use crate::type_name::TypeName;
use serde_derive::Deserialize;
use state_processing::per_epoch_processing::{
errors::EpochProcessingError, process_crosslinks, process_final_updates,
process_justification_and_finalization, process_registry_updates, process_slashings,
errors::EpochProcessingError, process_final_updates, process_justification_and_finalization,
process_registry_updates, process_rewards_and_penalties, process_slashings,
validator_statuses::ValidatorStatuses,
};
use std::marker::PhantomData;
@@ -38,7 +38,7 @@ pub trait EpochTransition<E: EthSpec>: TypeName + Debug + Sync {
#[derive(Debug)]
pub struct JustificationAndFinalization;
#[derive(Debug)]
pub struct Crosslinks;
pub struct RewardsAndPenalties;
#[derive(Debug)]
pub struct RegistryUpdates;
#[derive(Debug)]
@@ -50,7 +50,7 @@ type_name!(
JustificationAndFinalization,
"justification_and_finalization"
);
type_name!(Crosslinks, "crosslinks");
type_name!(RewardsAndPenalties, "rewards_and_penalties");
type_name!(RegistryUpdates, "registry_updates");
type_name!(Slashings, "slashings");
type_name!(FinalUpdates, "final_updates");
@@ -63,10 +63,11 @@ impl<E: EthSpec> EpochTransition<E> for JustificationAndFinalization {
}
}
impl<E: EthSpec> EpochTransition<E> for Crosslinks {
impl<E: EthSpec> EpochTransition<E> for RewardsAndPenalties {
fn run(state: &mut BeaconState<E>, spec: &ChainSpec) -> Result<(), EpochProcessingError> {
process_crosslinks(state, spec)?;
Ok(())
let mut validator_statuses = ValidatorStatuses::new(state, spec)?;
validator_statuses.process_attestations(state, spec)?;
process_rewards_and_penalties(state, &mut validator_statuses, spec)
}
}

View File

@@ -8,13 +8,13 @@ use ssz::Decode;
use state_processing::per_block_processing::{
errors::BlockProcessingError, process_attestations, process_attester_slashings,
process_block_header, process_deposits, process_exits, process_proposer_slashings,
process_transfers, VerifySignatures,
VerifySignatures,
};
use std::fmt::Debug;
use std::path::Path;
use types::{
Attestation, AttesterSlashing, BeaconBlock, BeaconState, ChainSpec, Deposit, EthSpec,
ProposerSlashing, Transfer, VoluntaryExit,
ProposerSlashing, VoluntaryExit,
};
#[derive(Debug, Clone, Default, Deserialize)]
@@ -95,16 +95,6 @@ impl<E: EthSpec> Operation<E> for ProposerSlashing {
}
}
impl<E: EthSpec> Operation<E> for Transfer {
fn apply_to(
&self,
state: &mut BeaconState<E>,
spec: &ChainSpec,
) -> Result<(), BlockProcessingError> {
process_transfers(state, &[self.clone()], VerifySignatures::True, spec)
}
}
impl<E: EthSpec> Operation<E> for VoluntaryExit {
fn handler_name() -> String {
"voluntary_exit".into()

View File

@@ -3,7 +3,7 @@ use types::EthSpec;
pub use case_result::CaseResult;
pub use cases::Case;
pub use cases::{
Crosslinks, FinalUpdates, JustificationAndFinalization, RegistryUpdates, Slashings,
FinalUpdates, JustificationAndFinalization, RegistryUpdates, RewardsAndPenalties, Slashings,
};
pub use error::Error;
pub use handler::*;

View File

@@ -45,8 +45,6 @@ type_name_generic!(BeaconBlockBody);
type_name!(BeaconBlockHeader);
type_name_generic!(BeaconState);
type_name!(Checkpoint);
type_name_generic!(CompactCommittee);
type_name!(Crosslink);
type_name!(Deposit);
type_name!(DepositData);
type_name!(Eth1Data);
@@ -55,6 +53,5 @@ type_name_generic!(HistoricalBatch);
type_name_generic!(IndexedAttestation);
type_name_generic!(PendingAttestation);
type_name!(ProposerSlashing);
type_name!(Transfer);
type_name!(Validator);
type_name!(VoluntaryExit);