More variable-variable lists

This commit is contained in:
Michael Sproul
2021-11-26 13:13:46 +11:00
parent 238ac98d7c
commit 4b808d3c72
17 changed files with 91 additions and 53 deletions

View File

@@ -14,9 +14,6 @@ use types::{
SignedVoluntaryExit, SigningData, Slot, SyncAggregate, SyncAggregatorSelectionData, Unsigned,
};
#[cfg(feature = "milhouse")]
use types::milhouse::prelude::*;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, PartialEq, Clone)]

View File

@@ -21,9 +21,6 @@ use types::{
BeaconState, BeaconStateError, ChainSpec, Epoch, EthSpec, ParticipationFlags, RelativeEpoch,
};
#[cfg(feature = "milhouse")]
use types::milhouse::prelude::*;
#[derive(Debug, PartialEq)]
pub enum Error {
InvalidFlagIndex(usize),

View File

@@ -6,9 +6,6 @@ use types::eth_spec::EthSpec;
use types::participation_flags::ParticipationFlags;
use types::VariableList;
#[cfg(feature = "milhouse")]
use types::milhouse::prelude::*;
pub fn process_participation_flag_updates<T: EthSpec>(
state: &mut BeaconState<T>,
) -> Result<(), EpochProcessingError> {

View File

@@ -6,9 +6,6 @@ use types::consts::altair::{
};
use types::{BeaconState, ChainSpec, EthSpec};
#[cfg(feature = "milhouse")]
use types::milhouse::prelude::*;
use crate::common::{altair::get_base_reward, decrease_balance, increase_balance};
use crate::per_epoch_processing::{Delta, Error};

View File

@@ -7,9 +7,6 @@ use safe_arith::SafeArith;
use std::array::IntoIter as ArrayIter;
use types::{BeaconState, ChainSpec, EthSpec};
#[cfg(feature = "milhouse")]
use types::milhouse::prelude::*;
/// Combination of several deltas for different components of an attestation reward.
///
/// Exists only for compatibility with EF rewards tests.

View File

@@ -2,9 +2,6 @@ use crate::common::get_attesting_indices;
use safe_arith::SafeArith;
use types::{BeaconState, BeaconStateError, ChainSpec, Epoch, EthSpec, PendingAttestation};
#[cfg(feature = "milhouse")]
use types::milhouse::prelude::*;
#[cfg(feature = "arbitrary-fuzz")]
use arbitrary::Arbitrary;

View File

@@ -1,6 +1,9 @@
use crate::per_epoch_processing::altair::participation_cache::Error as ParticipationCacheError;
use types::{BeaconStateError, InconsistentFork};
#[cfg(feature = "milhouse")]
use types::milhouse;
#[derive(Debug, PartialEq)]
pub enum EpochProcessingError {
UnableToDetermineProducer,
@@ -25,6 +28,8 @@ pub enum EpochProcessingError {
InvalidJustificationBit(ssz_types::Error),
InvalidFlagIndex(usize),
ParticipationCache(ParticipationCacheError),
#[cfg(feature = "milhouse")]
MilhouseError(milhouse::Error),
}
impl From<InclusionError> for EpochProcessingError {
@@ -57,6 +62,13 @@ impl From<ParticipationCacheError> for EpochProcessingError {
}
}
#[cfg(feature = "milhouse")]
impl From<milhouse::Error> for EpochProcessingError {
fn from(e: milhouse::Error) -> Self {
Self::MilhouseError(e)
}
}
#[derive(Debug, PartialEq)]
pub enum InclusionError {
/// The validator did not participate in an attestation in this period.

View File

@@ -1,10 +1,8 @@
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};
use types::{Unsigned, VList};
pub fn process_eth1_data_reset<T: EthSpec>(
state: &mut BeaconState<T>,
@@ -15,7 +13,7 @@ pub fn process_eth1_data_reset<T: EthSpec>(
.safe_rem(T::SlotsPerEth1VotingPeriod::to_u64())?
== 0
{
*state.eth1_data_votes_mut() = VariableList::empty();
*state.eth1_data_votes_mut() = VList::empty();
}
Ok(())
}

View File

@@ -3,16 +3,13 @@ use std::mem;
use std::sync::Arc;
use types::{
BeaconState, BeaconStateAltair, BeaconStateError as Error, ChainSpec, EthSpec, Fork,
ParticipationFlags, PendingAttestation, RelativeEpoch, SyncCommittee, VariableList,
ParticipationFlags, PendingAttestation, RelativeEpoch, SyncCommittee, VList, VariableList,
};
#[cfg(feature = "milhouse")]
use types::milhouse::prelude::*;
/// Translate the participation information from the epoch prior to the fork into Altair's format.
pub fn translate_participation<E: EthSpec>(
state: &mut BeaconState<E>,
pending_attestations: &VariableList<PendingAttestation<E>, E::MaxPendingAttestations>,
pending_attestations: &VList<PendingAttestation<E>, E::MaxPendingAttestations>,
spec: &ChainSpec,
) -> Result<(), Error> {
// Previous epoch committee cache is required for `get_attesting_indices`.