mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 19:32:55 +00:00
Altair consensus changes and refactors (#2279)
## Proposed Changes Implement the consensus changes necessary for the upcoming Altair hard fork. ## Additional Info This is quite a heavy refactor, with pivotal types like the `BeaconState` and `BeaconBlock` changing from structs to enums. This ripples through the whole codebase with field accesses changing to methods, e.g. `state.slot` => `state.slot()`. Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
use super::errors::EpochProcessingError;
|
||||
use core::result::Result;
|
||||
use core::result::Result::Ok;
|
||||
use safe_arith::SafeArith;
|
||||
use types::beacon_state::BeaconState;
|
||||
use types::eth_spec::EthSpec;
|
||||
use types::{Unsigned, VariableList};
|
||||
|
||||
pub fn process_eth1_data_reset<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
) -> Result<(), EpochProcessingError> {
|
||||
if state
|
||||
.slot()
|
||||
.safe_add(1)?
|
||||
.safe_rem(T::SlotsPerEth1VotingPeriod::to_u64())?
|
||||
== 0
|
||||
{
|
||||
*state.eth1_data_votes_mut() = VariableList::empty();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn process_slashings_reset<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
) -> Result<(), EpochProcessingError> {
|
||||
let next_epoch = state.next_epoch()?;
|
||||
state.set_slashings(next_epoch, 0)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn process_randao_mixes_reset<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
) -> Result<(), EpochProcessingError> {
|
||||
let current_epoch = state.current_epoch();
|
||||
let next_epoch = state.next_epoch()?;
|
||||
state.set_randao_mix(next_epoch, *state.get_randao_mix(current_epoch)?)?;
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user