mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 20:22:02 +00:00
Rename BeaconStateTypes to EthSpec
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user