mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 22:34:45 +00:00
* Single-pass epoch processing (#4483, #4573) Co-authored-by: Michael Sproul <michael@sigmaprime.io> * Delete unused epoch processing code (#5170) * Delete unused epoch processing code * Compare total deltas * Remove unnecessary apply_pending * cargo fmt * Remove newline * Use epoch cache in block packing (#5223) * Remove progressive balances mode (#5224) * inline inactivity_penalty_quotient_for_state * drop previous_epoch_total_active_balance * fc lint * spec compliant process_sync_aggregate (#15) * spec compliant process_sync_aggregate * Update consensus/state_processing/src/per_block_processing/altair/sync_committee.rs Co-authored-by: Michael Sproul <micsproul@gmail.com> --------- Co-authored-by: Michael Sproul <micsproul@gmail.com> * Delete the participation cache (#16) * update help * Fix op_pool tests * Fix fork choice tests * Merge remote-tracking branch 'sigp/unstable' into epoch-single-pass * Simplify exit cache (#5280) * Fix clippy on exit cache * Clean up single-pass a bit (#5282) * Address Mark's review of single-pass (#5386) * Merge remote-tracking branch 'origin/unstable' into epoch-single-pass * Address Sean's review comments (#5414) * Address most of Sean's review comments * Simplify total balance cache building * Clean up unused junk * Merge remote-tracking branch 'origin/unstable' into epoch-single-pass * More self-review * Merge remote-tracking branch 'origin/unstable' into epoch-single-pass * Merge branch 'unstable' into epoch-single-pass * Fix imports for beta compiler * Fix tests, probably
51 lines
1.7 KiB
Rust
51 lines
1.7 KiB
Rust
mod deposit_data_tree;
|
|
mod get_attestation_participation;
|
|
mod get_attesting_indices;
|
|
mod get_indexed_attestation;
|
|
mod initiate_validator_exit;
|
|
mod slash_validator;
|
|
|
|
pub mod altair;
|
|
pub mod base;
|
|
pub mod update_progressive_balances_cache;
|
|
|
|
pub use deposit_data_tree::DepositDataTree;
|
|
pub use get_attestation_participation::get_attestation_participation_flag_indices;
|
|
pub use get_attesting_indices::{get_attesting_indices, get_attesting_indices_from_state};
|
|
pub use get_indexed_attestation::get_indexed_attestation;
|
|
pub use initiate_validator_exit::initiate_validator_exit;
|
|
pub use slash_validator::slash_validator;
|
|
|
|
use safe_arith::SafeArith;
|
|
use types::{BeaconState, BeaconStateError, EthSpec};
|
|
|
|
/// Increase the balance of a validator, erroring upon overflow, as per the spec.
|
|
pub fn increase_balance<E: EthSpec>(
|
|
state: &mut BeaconState<E>,
|
|
index: usize,
|
|
delta: u64,
|
|
) -> Result<(), BeaconStateError> {
|
|
increase_balance_directly(state.get_balance_mut(index)?, delta)
|
|
}
|
|
|
|
/// Decrease the balance of a validator, saturating upon overflow, as per the spec.
|
|
pub fn decrease_balance<E: EthSpec>(
|
|
state: &mut BeaconState<E>,
|
|
index: usize,
|
|
delta: u64,
|
|
) -> Result<(), BeaconStateError> {
|
|
decrease_balance_directly(state.get_balance_mut(index)?, delta)
|
|
}
|
|
|
|
/// Increase the balance of a validator, erroring upon overflow, as per the spec.
|
|
pub fn increase_balance_directly(balance: &mut u64, delta: u64) -> Result<(), BeaconStateError> {
|
|
balance.safe_add_assign(delta)?;
|
|
Ok(())
|
|
}
|
|
|
|
/// Decrease the balance of a validator, saturating upon overflow, as per the spec.
|
|
pub fn decrease_balance_directly(balance: &mut u64, delta: u64) -> Result<(), BeaconStateError> {
|
|
*balance = balance.saturating_sub(delta);
|
|
Ok(())
|
|
}
|