mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
Rename BeaconStateTypes to EthSpec
This commit is contained in:
@@ -3,7 +3,7 @@ use types::{BeaconStateError as Error, *};
|
||||
/// Exit the validator of the given `index`.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn exit_validator<T: BeaconStateTypes>(
|
||||
pub fn exit_validator<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
validator_index: usize,
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -4,7 +4,7 @@ use types::{BeaconStateError as Error, *};
|
||||
/// Slash the validator with index ``index``.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn slash_validator<T: BeaconStateTypes>(
|
||||
pub fn slash_validator<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
validator_index: usize,
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -10,7 +10,7 @@ pub enum GenesisError {
|
||||
/// Returns the genesis `BeaconState`
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn get_genesis_state<T: BeaconStateTypes>(
|
||||
pub fn get_genesis_state<T: EthSpec>(
|
||||
genesis_validator_deposits: &[Deposit],
|
||||
genesis_time: u64,
|
||||
genesis_eth1_data: Eth1Data,
|
||||
|
||||
@@ -40,7 +40,7 @@ const VERIFY_DEPOSIT_MERKLE_PROOFS: bool = false;
|
||||
/// returns an error describing why the block was invalid or how the function failed to execute.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn per_block_processing<T: BeaconStateTypes>(
|
||||
pub fn per_block_processing<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
block: &BeaconBlock,
|
||||
spec: &ChainSpec,
|
||||
@@ -55,7 +55,7 @@ pub fn per_block_processing<T: BeaconStateTypes>(
|
||||
/// returns an error describing why the block was invalid or how the function failed to execute.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn per_block_processing_without_verifying_block_signature<T: BeaconStateTypes>(
|
||||
pub fn per_block_processing_without_verifying_block_signature<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
block: &BeaconBlock,
|
||||
spec: &ChainSpec,
|
||||
@@ -70,7 +70,7 @@ pub fn per_block_processing_without_verifying_block_signature<T: BeaconStateType
|
||||
/// returns an error describing why the block was invalid or how the function failed to execute.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn per_block_processing_signature_optional<T: BeaconStateTypes>(
|
||||
fn per_block_processing_signature_optional<T: EthSpec>(
|
||||
mut state: &mut BeaconState<T>,
|
||||
block: &BeaconBlock,
|
||||
should_verify_block_signature: bool,
|
||||
@@ -100,7 +100,7 @@ fn per_block_processing_signature_optional<T: BeaconStateTypes>(
|
||||
/// Processes the block header.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_block_header<T: BeaconStateTypes>(
|
||||
pub fn process_block_header<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
block: &BeaconBlock,
|
||||
spec: &ChainSpec,
|
||||
@@ -125,7 +125,7 @@ pub fn process_block_header<T: BeaconStateTypes>(
|
||||
/// Verifies the signature of a block.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_block_signature<T: BeaconStateTypes>(
|
||||
pub fn verify_block_signature<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
block: &BeaconBlock,
|
||||
spec: &ChainSpec,
|
||||
@@ -153,7 +153,7 @@ pub fn verify_block_signature<T: BeaconStateTypes>(
|
||||
/// `state.latest_randao_mixes`.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_randao<T: BeaconStateTypes>(
|
||||
pub fn process_randao<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
block: &BeaconBlock,
|
||||
spec: &ChainSpec,
|
||||
@@ -184,7 +184,7 @@ pub fn process_randao<T: BeaconStateTypes>(
|
||||
/// Update the `state.eth1_data_votes` based upon the `eth1_data` provided.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_eth1_data<T: BeaconStateTypes>(
|
||||
pub fn process_eth1_data<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
eth1_data: &Eth1Data,
|
||||
) -> Result<(), Error> {
|
||||
@@ -213,7 +213,7 @@ pub fn process_eth1_data<T: BeaconStateTypes>(
|
||||
/// an `Err` describing the invalid object or cause of failure.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_proposer_slashings<T: BeaconStateTypes>(
|
||||
pub fn process_proposer_slashings<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
proposer_slashings: &[ProposerSlashing],
|
||||
spec: &ChainSpec,
|
||||
@@ -246,7 +246,7 @@ pub fn process_proposer_slashings<T: BeaconStateTypes>(
|
||||
/// an `Err` describing the invalid object or cause of failure.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_attester_slashings<T: BeaconStateTypes>(
|
||||
pub fn process_attester_slashings<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
attester_slashings: &[AttesterSlashing],
|
||||
spec: &ChainSpec,
|
||||
@@ -304,7 +304,7 @@ pub fn process_attester_slashings<T: BeaconStateTypes>(
|
||||
/// an `Err` describing the invalid object or cause of failure.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_attestations<T: BeaconStateTypes>(
|
||||
pub fn process_attestations<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
attestations: &[Attestation],
|
||||
spec: &ChainSpec,
|
||||
@@ -346,7 +346,7 @@ pub fn process_attestations<T: BeaconStateTypes>(
|
||||
/// an `Err` describing the invalid object or cause of failure.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_deposits<T: BeaconStateTypes>(
|
||||
pub fn process_deposits<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
deposits: &[Deposit],
|
||||
spec: &ChainSpec,
|
||||
@@ -416,7 +416,7 @@ pub fn process_deposits<T: BeaconStateTypes>(
|
||||
/// an `Err` describing the invalid object or cause of failure.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_exits<T: BeaconStateTypes>(
|
||||
pub fn process_exits<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
voluntary_exits: &[VoluntaryExit],
|
||||
spec: &ChainSpec,
|
||||
@@ -448,7 +448,7 @@ pub fn process_exits<T: BeaconStateTypes>(
|
||||
/// an `Err` describing the invalid object or cause of failure.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_transfers<T: BeaconStateTypes>(
|
||||
pub fn process_transfers<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
transfers: &[Transfer],
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -9,7 +9,7 @@ use types::*;
|
||||
/// Returns `Ok(())` if the `Attestation` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn validate_attestation<T: BeaconStateTypes>(
|
||||
pub fn validate_attestation<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attestation: &Attestation,
|
||||
spec: &ChainSpec,
|
||||
@@ -18,7 +18,7 @@ pub fn validate_attestation<T: BeaconStateTypes>(
|
||||
}
|
||||
|
||||
/// Like `validate_attestation` but doesn't run checks which may become true in future states.
|
||||
pub fn validate_attestation_time_independent_only<T: BeaconStateTypes>(
|
||||
pub fn validate_attestation_time_independent_only<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attestation: &Attestation,
|
||||
spec: &ChainSpec,
|
||||
@@ -32,7 +32,7 @@ pub fn validate_attestation_time_independent_only<T: BeaconStateTypes>(
|
||||
/// Returns `Ok(())` if the `Attestation` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn validate_attestation_without_signature<T: BeaconStateTypes>(
|
||||
pub fn validate_attestation_without_signature<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attestation: &Attestation,
|
||||
spec: &ChainSpec,
|
||||
@@ -45,7 +45,7 @@ pub fn validate_attestation_without_signature<T: BeaconStateTypes>(
|
||||
///
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn validate_attestation_parametric<T: BeaconStateTypes>(
|
||||
fn validate_attestation_parametric<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attestation: &Attestation,
|
||||
spec: &ChainSpec,
|
||||
@@ -168,7 +168,7 @@ fn validate_attestation_parametric<T: BeaconStateTypes>(
|
||||
/// match the current (or previous) justified epoch and root from the state.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn verify_justified_epoch_and_root<T: BeaconStateTypes>(
|
||||
fn verify_justified_epoch_and_root<T: EthSpec>(
|
||||
attestation: &Attestation,
|
||||
state: &BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
@@ -223,7 +223,7 @@ fn verify_justified_epoch_and_root<T: BeaconStateTypes>(
|
||||
/// - A `validator_index` in `committee` is not in `state.validator_registry`.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn verify_attestation_signature<T: BeaconStateTypes>(
|
||||
fn verify_attestation_signature<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
committee: &[usize],
|
||||
a: &Attestation,
|
||||
|
||||
@@ -8,7 +8,7 @@ use types::*;
|
||||
/// Returns `Ok(())` if the `AttesterSlashing` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_attester_slashing<T: BeaconStateTypes>(
|
||||
pub fn verify_attester_slashing<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attester_slashing: &AttesterSlashing,
|
||||
should_verify_slashable_attestations: bool,
|
||||
@@ -42,7 +42,7 @@ pub fn verify_attester_slashing<T: BeaconStateTypes>(
|
||||
/// Returns Ok(indices) if `indices.len() > 0`.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn gather_attester_slashing_indices<T: BeaconStateTypes>(
|
||||
pub fn gather_attester_slashing_indices<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attester_slashing: &AttesterSlashing,
|
||||
spec: &ChainSpec,
|
||||
@@ -57,7 +57,7 @@ pub fn gather_attester_slashing_indices<T: BeaconStateTypes>(
|
||||
|
||||
/// Same as `gather_attester_slashing_indices` but allows the caller to specify the criteria
|
||||
/// for determining whether a given validator should be considered slashed.
|
||||
pub fn gather_attester_slashing_indices_modular<F, T: BeaconStateTypes>(
|
||||
pub fn gather_attester_slashing_indices_modular<F, T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attester_slashing: &AttesterSlashing,
|
||||
is_slashed: F,
|
||||
|
||||
@@ -16,7 +16,7 @@ use types::*;
|
||||
/// Note: this function is incomplete.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_deposit<T: BeaconStateTypes>(
|
||||
pub fn verify_deposit<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
deposit: &Deposit,
|
||||
verify_merkle_branch: bool,
|
||||
@@ -47,7 +47,7 @@ pub fn verify_deposit<T: BeaconStateTypes>(
|
||||
/// Verify that the `Deposit` index is correct.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_deposit_index<T: BeaconStateTypes>(
|
||||
pub fn verify_deposit_index<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
deposit: &Deposit,
|
||||
) -> Result<(), Error> {
|
||||
@@ -68,7 +68,7 @@ pub fn verify_deposit_index<T: BeaconStateTypes>(
|
||||
/// ## Errors
|
||||
///
|
||||
/// Errors if the state's `pubkey_cache` is not current.
|
||||
pub fn get_existing_validator_index<T: BeaconStateTypes>(
|
||||
pub fn get_existing_validator_index<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
deposit: &Deposit,
|
||||
) -> Result<Option<u64>, Error> {
|
||||
@@ -92,7 +92,7 @@ pub fn get_existing_validator_index<T: BeaconStateTypes>(
|
||||
/// Verify that a deposit is included in the state's eth1 deposit root.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn verify_deposit_merkle_proof<T: BeaconStateTypes>(
|
||||
fn verify_deposit_merkle_proof<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
deposit: &Deposit,
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -8,7 +8,7 @@ use types::*;
|
||||
/// Returns `Ok(())` if the `Exit` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_exit<T: BeaconStateTypes>(
|
||||
pub fn verify_exit<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
exit: &VoluntaryExit,
|
||||
spec: &ChainSpec,
|
||||
@@ -17,7 +17,7 @@ pub fn verify_exit<T: BeaconStateTypes>(
|
||||
}
|
||||
|
||||
/// Like `verify_exit` but doesn't run checks which may become true in future states.
|
||||
pub fn verify_exit_time_independent_only<T: BeaconStateTypes>(
|
||||
pub fn verify_exit_time_independent_only<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
exit: &VoluntaryExit,
|
||||
spec: &ChainSpec,
|
||||
@@ -26,7 +26,7 @@ pub fn verify_exit_time_independent_only<T: BeaconStateTypes>(
|
||||
}
|
||||
|
||||
/// Parametric version of `verify_exit` that skips some checks if `time_independent_only` is true.
|
||||
fn verify_exit_parametric<T: BeaconStateTypes>(
|
||||
fn verify_exit_parametric<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
exit: &VoluntaryExit,
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -8,7 +8,7 @@ use types::*;
|
||||
/// Returns `Ok(())` if the `ProposerSlashing` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_proposer_slashing<T: BeaconStateTypes>(
|
||||
pub fn verify_proposer_slashing<T: EthSpec>(
|
||||
proposer_slashing: &ProposerSlashing,
|
||||
state: &BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -11,7 +11,7 @@ use types::*;
|
||||
/// Returns `Ok(())` if the `SlashableAttestation` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_slashable_attestation<T: BeaconStateTypes>(
|
||||
pub fn verify_slashable_attestation<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
slashable_attestation: &SlashableAttestation,
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -11,7 +11,7 @@ use types::*;
|
||||
/// Note: this function is incomplete.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_transfer<T: BeaconStateTypes>(
|
||||
pub fn verify_transfer<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
transfer: &Transfer,
|
||||
spec: &ChainSpec,
|
||||
@@ -20,7 +20,7 @@ pub fn verify_transfer<T: BeaconStateTypes>(
|
||||
}
|
||||
|
||||
/// Like `verify_transfer` but doesn't run checks which may become true in future states.
|
||||
pub fn verify_transfer_time_independent_only<T: BeaconStateTypes>(
|
||||
pub fn verify_transfer_time_independent_only<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
transfer: &Transfer,
|
||||
spec: &ChainSpec,
|
||||
@@ -29,7 +29,7 @@ pub fn verify_transfer_time_independent_only<T: BeaconStateTypes>(
|
||||
}
|
||||
|
||||
/// Parametric version of `verify_transfer` that allows some checks to be skipped.
|
||||
fn verify_transfer_parametric<T: BeaconStateTypes>(
|
||||
fn verify_transfer_parametric<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
transfer: &Transfer,
|
||||
spec: &ChainSpec,
|
||||
@@ -123,7 +123,7 @@ fn verify_transfer_parametric<T: BeaconStateTypes>(
|
||||
/// Does not check that the transfer is valid, however checks for overflow in all actions.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn execute_transfer<T: BeaconStateTypes>(
|
||||
pub fn execute_transfer<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
transfer: &Transfer,
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -33,7 +33,7 @@ pub type WinningRootHashSet = HashMap<u64, WinningRoot>;
|
||||
/// returned, a state might be "half-processed" and therefore in an invalid state.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn per_epoch_processing<T: BeaconStateTypes>(
|
||||
pub fn per_epoch_processing<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
@@ -90,7 +90,7 @@ pub fn per_epoch_processing<T: BeaconStateTypes>(
|
||||
/// Maybe resets the eth1 period.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn maybe_reset_eth1_period<T: BeaconStateTypes>(state: &mut BeaconState<T>, spec: &ChainSpec) {
|
||||
pub fn maybe_reset_eth1_period<T: EthSpec>(state: &mut BeaconState<T>, spec: &ChainSpec) {
|
||||
let next_epoch = state.next_epoch(spec);
|
||||
let voting_period = spec.epochs_per_eth1_voting_period;
|
||||
|
||||
@@ -112,7 +112,7 @@ pub fn maybe_reset_eth1_period<T: BeaconStateTypes>(state: &mut BeaconState<T>,
|
||||
/// - `previous_justified_epoch`
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn update_justification_and_finalization<T: BeaconStateTypes>(
|
||||
pub fn update_justification_and_finalization<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
total_balances: &TotalBalances,
|
||||
spec: &ChainSpec,
|
||||
@@ -182,7 +182,7 @@ pub fn update_justification_and_finalization<T: BeaconStateTypes>(
|
||||
/// Also returns a `WinningRootHashSet` for later use during epoch processing.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_crosslinks<T: BeaconStateTypes>(
|
||||
pub fn process_crosslinks<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<WinningRootHashSet, Error> {
|
||||
@@ -225,7 +225,7 @@ pub fn process_crosslinks<T: BeaconStateTypes>(
|
||||
/// Finish up an epoch update.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn finish_epoch_update<T: BeaconStateTypes>(
|
||||
pub fn finish_epoch_update<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
@@ -33,7 +33,7 @@ impl std::ops::AddAssign for Delta {
|
||||
/// Apply attester and proposer rewards.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn apply_rewards<T: BeaconStateTypes>(
|
||||
pub fn apply_rewards<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
validator_statuses: &mut ValidatorStatuses,
|
||||
winning_root_for_shards: &WinningRootHashSet,
|
||||
@@ -80,7 +80,7 @@ pub fn apply_rewards<T: BeaconStateTypes>(
|
||||
/// attestation in the previous epoch.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn get_proposer_deltas<T: BeaconStateTypes>(
|
||||
fn get_proposer_deltas<T: EthSpec>(
|
||||
deltas: &mut Vec<Delta>,
|
||||
state: &mut BeaconState<T>,
|
||||
validator_statuses: &mut ValidatorStatuses,
|
||||
@@ -121,7 +121,7 @@ fn get_proposer_deltas<T: BeaconStateTypes>(
|
||||
/// Apply rewards for participation in attestations during the previous epoch.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn get_justification_and_finalization_deltas<T: BeaconStateTypes>(
|
||||
fn get_justification_and_finalization_deltas<T: EthSpec>(
|
||||
deltas: &mut Vec<Delta>,
|
||||
state: &BeaconState<T>,
|
||||
validator_statuses: &ValidatorStatuses,
|
||||
@@ -262,7 +262,7 @@ fn compute_inactivity_leak_delta(
|
||||
/// Calculate the deltas based upon the winning roots for attestations during the previous epoch.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn get_crosslink_deltas<T: BeaconStateTypes>(
|
||||
fn get_crosslink_deltas<T: EthSpec>(
|
||||
deltas: &mut Vec<Delta>,
|
||||
state: &BeaconState<T>,
|
||||
validator_statuses: &ValidatorStatuses,
|
||||
@@ -296,7 +296,7 @@ fn get_crosslink_deltas<T: BeaconStateTypes>(
|
||||
/// Returns the base reward for some validator.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn get_base_reward<T: BeaconStateTypes>(
|
||||
fn get_base_reward<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
index: usize,
|
||||
previous_total_balance: u64,
|
||||
@@ -313,7 +313,7 @@ fn get_base_reward<T: BeaconStateTypes>(
|
||||
/// Returns the inactivity penalty for some validator.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn get_inactivity_penalty<T: BeaconStateTypes>(
|
||||
fn get_inactivity_penalty<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
index: usize,
|
||||
epochs_since_finality: u64,
|
||||
@@ -329,6 +329,6 @@ fn get_inactivity_penalty<T: BeaconStateTypes>(
|
||||
/// Returns the epochs since the last finalized epoch.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn epochs_since_finality<T: BeaconStateTypes>(state: &BeaconState<T>, spec: &ChainSpec) -> Epoch {
|
||||
fn epochs_since_finality<T: EthSpec>(state: &BeaconState<T>, spec: &ChainSpec) -> Epoch {
|
||||
state.current_epoch(spec) + 1 - state.finalized_epoch
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use types::*;
|
||||
/// Returns validator indices which participated in the attestation.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn get_attestation_participants<T: BeaconStateTypes>(
|
||||
pub fn get_attestation_participants<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attestation_data: &AttestationData,
|
||||
bitfield: &Bitfield,
|
||||
|
||||
@@ -6,7 +6,7 @@ use types::*;
|
||||
/// slot.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn inclusion_distance<T: BeaconStateTypes>(
|
||||
pub fn inclusion_distance<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attestations: &[&PendingAttestation],
|
||||
validator_index: usize,
|
||||
@@ -19,7 +19,7 @@ pub fn inclusion_distance<T: BeaconStateTypes>(
|
||||
/// Returns the slot of the earliest included attestation for some validator.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn inclusion_slot<T: BeaconStateTypes>(
|
||||
pub fn inclusion_slot<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attestations: &[&PendingAttestation],
|
||||
validator_index: usize,
|
||||
@@ -32,7 +32,7 @@ pub fn inclusion_slot<T: BeaconStateTypes>(
|
||||
/// Finds the earliest included attestation for some validator.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn earliest_included_attestation<T: BeaconStateTypes>(
|
||||
fn earliest_included_attestation<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
attestations: &[&PendingAttestation],
|
||||
validator_index: usize,
|
||||
|
||||
@@ -5,7 +5,7 @@ use types::{BeaconStateError as Error, *};
|
||||
/// ``EJECTION_BALANCE``.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_ejections<T: BeaconStateTypes>(
|
||||
pub fn process_ejections<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
@@ -3,7 +3,7 @@ use types::*;
|
||||
/// Process the exit queue.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_exit_queue<T: BeaconStateTypes>(state: &mut BeaconState<T>, spec: &ChainSpec) {
|
||||
pub fn process_exit_queue<T: EthSpec>(state: &mut BeaconState<T>, spec: &ChainSpec) {
|
||||
let current_epoch = state.current_epoch(spec);
|
||||
|
||||
let eligible = |index: usize| {
|
||||
@@ -32,7 +32,7 @@ pub fn process_exit_queue<T: BeaconStateTypes>(state: &mut BeaconState<T>, spec:
|
||||
/// Initiate an exit for the validator of the given `index`.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn prepare_validator_for_withdrawal<T: BeaconStateTypes>(
|
||||
fn prepare_validator_for_withdrawal<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
validator_index: usize,
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -3,7 +3,7 @@ use types::{BeaconStateError as Error, *};
|
||||
/// Process slashings.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_slashings<T: BeaconStateTypes>(
|
||||
pub fn process_slashings<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
current_total_balance: u64,
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -8,9 +8,9 @@ use types::*;
|
||||
fn runs_without_error() {
|
||||
Builder::from_env(Env::default().default_filter_or("error")).init();
|
||||
|
||||
let spec = FewValidatorsStateTypes::spec();
|
||||
let spec = FewValidatorsEthSpec::spec();
|
||||
|
||||
let mut builder: TestingBeaconStateBuilder<FewValidatorsStateTypes> =
|
||||
let mut builder: TestingBeaconStateBuilder<FewValidatorsEthSpec> =
|
||||
TestingBeaconStateBuilder::from_deterministic_keypairs(8, &spec);
|
||||
|
||||
let target_slot = (spec.genesis_epoch + 4).end_slot(spec.slots_per_epoch);
|
||||
|
||||
@@ -5,7 +5,7 @@ use types::*;
|
||||
/// Peforms a validator registry update, if required.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn update_registry_and_shuffling_data<T: BeaconStateTypes>(
|
||||
pub fn update_registry_and_shuffling_data<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
current_total_balance: u64,
|
||||
spec: &ChainSpec,
|
||||
@@ -50,7 +50,7 @@ pub fn update_registry_and_shuffling_data<T: BeaconStateTypes>(
|
||||
/// Returns `true` if the validator registry should be updated during an epoch processing.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn should_update_validator_registry<T: BeaconStateTypes>(
|
||||
pub fn should_update_validator_registry<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<bool, BeaconStateError> {
|
||||
@@ -79,7 +79,7 @@ pub fn should_update_validator_registry<T: BeaconStateTypes>(
|
||||
/// Note: Utilizes the cache and will fail if the appropriate cache is not initialized.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn update_validator_registry<T: BeaconStateTypes>(
|
||||
pub fn update_validator_registry<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
current_total_balance: u64,
|
||||
spec: &ChainSpec,
|
||||
@@ -134,7 +134,7 @@ pub fn update_validator_registry<T: BeaconStateTypes>(
|
||||
/// Activate the validator of the given ``index``.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn activate_validator<T: BeaconStateTypes>(
|
||||
pub fn activate_validator<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
validator_index: usize,
|
||||
is_genesis: bool,
|
||||
|
||||
@@ -161,7 +161,7 @@ impl ValidatorStatuses {
|
||||
/// - Total balances for the current and previous epochs.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn new<T: BeaconStateTypes>(
|
||||
pub fn new<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<Self, BeaconStateError> {
|
||||
@@ -199,7 +199,7 @@ impl ValidatorStatuses {
|
||||
/// `total_balances` fields.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_attestations<T: BeaconStateTypes>(
|
||||
pub fn process_attestations<T: EthSpec>(
|
||||
&mut self,
|
||||
state: &BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
@@ -265,7 +265,7 @@ impl ValidatorStatuses {
|
||||
/// "winning" shard block root for the previous epoch.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn process_winning_roots<T: BeaconStateTypes>(
|
||||
pub fn process_winning_roots<T: EthSpec>(
|
||||
&mut self,
|
||||
state: &BeaconState<T>,
|
||||
winning_roots: &WinningRootHashSet,
|
||||
@@ -316,7 +316,7 @@ fn is_from_epoch(a: &PendingAttestation, epoch: Epoch, spec: &ChainSpec) -> bool
|
||||
/// the first slot of the given epoch.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn has_common_epoch_boundary_root<T: BeaconStateTypes>(
|
||||
fn has_common_epoch_boundary_root<T: EthSpec>(
|
||||
a: &PendingAttestation,
|
||||
state: &BeaconState<T>,
|
||||
epoch: Epoch,
|
||||
@@ -332,7 +332,7 @@ fn has_common_epoch_boundary_root<T: BeaconStateTypes>(
|
||||
/// the current slot of the `PendingAttestation`.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn has_common_beacon_block_root<T: BeaconStateTypes>(
|
||||
fn has_common_beacon_block_root<T: EthSpec>(
|
||||
a: &PendingAttestation,
|
||||
state: &BeaconState<T>,
|
||||
) -> Result<bool, BeaconStateError> {
|
||||
|
||||
@@ -35,7 +35,7 @@ impl WinningRoot {
|
||||
/// per-epoch processing.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn winning_root<T: BeaconStateTypes>(
|
||||
pub fn winning_root<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
shard: u64,
|
||||
spec: &ChainSpec,
|
||||
@@ -90,7 +90,7 @@ pub fn winning_root<T: BeaconStateTypes>(
|
||||
/// Returns `true` if pending attestation `a` is eligible to become a winning root.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn is_eligible_for_winning_root<T: BeaconStateTypes>(
|
||||
fn is_eligible_for_winning_root<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
a: &PendingAttestation,
|
||||
shard: Shard,
|
||||
@@ -105,7 +105,7 @@ fn is_eligible_for_winning_root<T: BeaconStateTypes>(
|
||||
/// Returns all indices which voted for a given crosslink. Does not contain duplicates.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn get_attesting_validator_indices<T: BeaconStateTypes>(
|
||||
fn get_attesting_validator_indices<T: EthSpec>(
|
||||
state: &BeaconState<T>,
|
||||
shard: u64,
|
||||
crosslink_data_root: &Hash256,
|
||||
|
||||
@@ -11,7 +11,7 @@ pub enum Error {
|
||||
/// Advances a state forward by one slot, performing per-epoch processing if required.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn per_slot_processing<T: BeaconStateTypes>(
|
||||
pub fn per_slot_processing<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
@@ -26,10 +26,7 @@ pub fn per_slot_processing<T: BeaconStateTypes>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn cache_state<T: BeaconStateTypes>(
|
||||
state: &mut BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
fn cache_state<T: EthSpec>(state: &mut BeaconState<T>, spec: &ChainSpec) -> Result<(), Error> {
|
||||
let previous_slot_state_root = state.update_tree_hash_cache()?;
|
||||
|
||||
// Note: increment the state slot here to allow use of our `state_root` and `block_root`
|
||||
|
||||
Reference in New Issue
Block a user