Skip to content

Commit

Permalink
Rename Functions to More Closely Match Spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ethDreamer committed Apr 16, 2024
1 parent f689898 commit fa51aec
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions beacon_node/genesis/src/eth1_genesis_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use eth1::{DepositLog, Eth1Block, Service as Eth1Service};
use slog::{debug, error, info, trace, Logger};
use state_processing::{
eth2_genesis_time, initialize_beacon_state_from_eth1, is_valid_genesis_state,
per_block_processing::process_operations::process_deposit, process_activations,
per_block_processing::process_operations::apply_deposit, process_activations,
};
use std::sync::{
atomic::{AtomicU64, AtomicUsize, Ordering},
Expand Down Expand Up @@ -433,7 +433,7 @@ impl Eth1GenesisService {
// is reached _prior_ to `MIN_ACTIVE_VALIDATOR_COUNT`. I suspect this won't be the
// case for mainnet, so we defer this optimization.

process_deposit(&mut state, &deposit, spec, PROOF_VERIFICATION)
apply_deposit(&mut state, &deposit, spec, PROOF_VERIFICATION)
.map_err(|e| format!("Error whilst processing deposit: {:?}", e))
})?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn initiate_validator_exit<E: EthSpec>(
.map_or(delayed_epoch, |epoch| max(epoch, delayed_epoch));
let exit_queue_churn = state.exit_cache().get_churn_at(exit_queue_epoch)?;

if exit_queue_churn >= state.get_churn_limit(spec)? {
if exit_queue_churn >= state.get_validator_churn_limit(spec)? {
exit_queue_epoch.safe_add_assign(1)?;
}

Expand Down
4 changes: 2 additions & 2 deletions consensus/state_processing/src/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::per_block_processing::{
errors::BlockProcessingError, process_operations::process_deposit,
errors::BlockProcessingError, process_operations::apply_deposit,
};
use crate::common::DepositDataTree;
use crate::upgrade::{
Expand Down Expand Up @@ -37,7 +37,7 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
.push_leaf(deposit.data.tree_hash_root())
.map_err(BlockProcessingError::MerkleTreeError)?;
state.eth1_data_mut().deposit_root = deposit_tree.root();
process_deposit(&mut state, deposit, spec, true)?;
apply_deposit(&mut state, deposit, spec, true)?;
}

process_activations(&mut state, spec)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,14 @@ pub fn process_deposits<E: EthSpec>(

// Update the state in series.
for deposit in deposits {
process_deposit(state, deposit, spec, false)?;
apply_deposit(state, deposit, spec, false)?;
}

Ok(())
}

/// Process a single deposit, optionally verifying its merkle proof.
pub fn process_deposit<E: EthSpec>(
pub fn apply_deposit<E: EthSpec>(
state: &mut BeaconState<E>,
deposit: &Deposit,
spec: &ChainSpec,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub fn process_epoch_single_pass<E: EthSpec>(
let next_epoch = state.next_epoch()?;
let is_in_inactivity_leak = state.is_in_inactivity_leak(previous_epoch, spec)?;
let total_active_balance = state.get_total_active_balance()?;
let churn_limit = state.get_churn_limit(spec)?;
let churn_limit = state.get_validator_churn_limit(spec)?;
let activation_churn_limit = state.get_activation_churn_limit(spec)?;
let finalized_checkpoint = state.finalized_checkpoint();
let fork_name = state.fork_name_unchecked();
Expand Down
6 changes: 3 additions & 3 deletions consensus/types/src/beacon_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ impl<E: EthSpec> BeaconState<E> {
/// Return the churn limit for the current epoch (number of validators who can leave per epoch).
///
/// Uses the current epoch committee cache, and will error if it isn't initialized.
pub fn get_churn_limit(&self, spec: &ChainSpec) -> Result<u64, Error> {
pub fn get_validator_churn_limit(&self, spec: &ChainSpec) -> Result<u64, Error> {
Ok(std::cmp::max(
spec.min_per_epoch_churn_limit,
(self
Expand All @@ -1462,10 +1462,10 @@ impl<E: EthSpec> BeaconState<E> {
BeaconState::Base(_)
| BeaconState::Altair(_)
| BeaconState::Merge(_)
| BeaconState::Capella(_) => self.get_churn_limit(spec)?,
| BeaconState::Capella(_) => self.get_validator_churn_limit(spec)?,
BeaconState::Deneb(_) | BeaconState::Electra(_) => std::cmp::min(
spec.max_per_epoch_activation_churn_limit,
self.get_churn_limit(spec)?,
self.get_validator_churn_limit(spec)?,
),
})
}
Expand Down

0 comments on commit fa51aec

Please sign in to comment.