mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Cargo.lock fixes and EF test fixes
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -3728,7 +3728,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "milhouse"
|
name = "milhouse"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/sigp/milhouse?branch=main#30c87f256deacc381fb15e39ccc4a281445f98da"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derivative",
|
"derivative",
|
||||||
"eth2_hashing 0.2.0",
|
"eth2_hashing 0.2.0",
|
||||||
@@ -3741,6 +3740,7 @@ dependencies = [
|
|||||||
"tree_hash",
|
"tree_hash",
|
||||||
"triomphe",
|
"triomphe",
|
||||||
"typenum",
|
"typenum",
|
||||||
|
"vec_map",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5964,6 +5964,7 @@ dependencies = [
|
|||||||
"smallvec",
|
"smallvec",
|
||||||
"tree_hash",
|
"tree_hash",
|
||||||
"types",
|
"types",
|
||||||
|
"vec_map",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ arbitrary = { version = "1.0", features = ["derive"], optional = true }
|
|||||||
lighthouse_metrics = { path = "../../common/lighthouse_metrics", optional = true }
|
lighthouse_metrics = { path = "../../common/lighthouse_metrics", optional = true }
|
||||||
lazy_static = { version = "1.4.0", optional = true }
|
lazy_static = { version = "1.4.0", optional = true }
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
|
vec_map = "0.8.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["legacy-arith", "metrics"]
|
default = ["legacy-arith", "metrics"]
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
use crate::common::altair::get_base_reward;
|
use crate::common::altair::get_base_reward;
|
||||||
use safe_arith::{ArithError, SafeArith};
|
use safe_arith::{ArithError, SafeArith};
|
||||||
use std::collections::BTreeMap;
|
use types::milhouse::update_map::{MaxMap, UpdateMap};
|
||||||
use types::{
|
use types::{
|
||||||
consts::altair::{
|
consts::altair::{
|
||||||
NUM_FLAG_INDICES, TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX,
|
NUM_FLAG_INDICES, TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX,
|
||||||
@@ -22,6 +22,7 @@ use types::{
|
|||||||
BeaconState, BeaconStateError, ChainSpec, Epoch, EthSpec, ParticipationFlags, RelativeEpoch,
|
BeaconState, BeaconStateError, ChainSpec, Epoch, EthSpec, ParticipationFlags, RelativeEpoch,
|
||||||
Unsigned, Validator,
|
Unsigned, Validator,
|
||||||
};
|
};
|
||||||
|
use vec_map::VecMap;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
@@ -198,7 +199,7 @@ pub struct ParticipationCache {
|
|||||||
/// `process_slashings`.
|
/// `process_slashings`.
|
||||||
process_slashings_indices: Vec<(usize, u64)>,
|
process_slashings_indices: Vec<(usize, u64)>,
|
||||||
/// Updates to the inactivity scores if we are definitely not in an inactivity leak.
|
/// Updates to the inactivity scores if we are definitely not in an inactivity leak.
|
||||||
pub inactivity_score_updates: Option<BTreeMap<usize, u64>>,
|
pub inactivity_score_updates: Option<MaxMap<VecMap<u64>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ParticipationCache {
|
impl ParticipationCache {
|
||||||
@@ -237,7 +238,7 @@ impl ParticipationCache {
|
|||||||
let definitely_not_in_inactivity_leak =
|
let definitely_not_in_inactivity_leak =
|
||||||
state.finalized_checkpoint().epoch + spec.min_epochs_to_inactivity_penalty + 1
|
state.finalized_checkpoint().epoch + spec.min_epochs_to_inactivity_penalty + 1
|
||||||
>= state.current_epoch();
|
>= state.current_epoch();
|
||||||
let mut inactivity_score_updates = BTreeMap::new();
|
let mut inactivity_score_updates = MaxMap::default();
|
||||||
|
|
||||||
// Iterate through all validators, updating:
|
// Iterate through all validators, updating:
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ impl<E: EthSpec> EpochTransition<E> for InactivityUpdates {
|
|||||||
BeaconState::Base(_) => Ok(()),
|
BeaconState::Base(_) => Ok(()),
|
||||||
BeaconState::Altair(_) | BeaconState::Merge(_) => altair::process_inactivity_updates(
|
BeaconState::Altair(_) | BeaconState::Merge(_) => altair::process_inactivity_updates(
|
||||||
state,
|
state,
|
||||||
&altair::ParticipationCache::new(state, spec).unwrap(),
|
&mut altair::ParticipationCache::new(state, spec).unwrap(),
|
||||||
spec,
|
spec,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@@ -278,19 +278,22 @@ impl<E: EthSpec, T: EpochTransition<E>> Case for EpochProcessing<E, T> {
|
|||||||
fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> {
|
fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> {
|
||||||
self.metadata.bls_setting.unwrap_or_default().check()?;
|
self.metadata.bls_setting.unwrap_or_default().check()?;
|
||||||
|
|
||||||
let mut state = self.pre.clone();
|
let spec = &testing_spec::<E>(fork_name);
|
||||||
|
let mut pre_state = self.pre.clone();
|
||||||
|
|
||||||
|
// Processing requires the committee caches.
|
||||||
|
pre_state.build_all_committee_caches(spec).unwrap();
|
||||||
|
|
||||||
|
let mut state = pre_state.clone();
|
||||||
let mut expected = self.post.clone();
|
let mut expected = self.post.clone();
|
||||||
|
|
||||||
let spec = &testing_spec::<E>(fork_name);
|
expected.as_mut().map(|post_state| {
|
||||||
|
post_state.build_all_committee_caches(spec).unwrap();
|
||||||
|
});
|
||||||
|
|
||||||
let mut result = (|| {
|
let mut result = T::run(&mut state, spec).map(|_| state);
|
||||||
// Processing requires the committee caches.
|
|
||||||
state.build_all_committee_caches(spec)?;
|
|
||||||
|
|
||||||
T::run(&mut state, spec).map(|_| state)
|
check_state_diff(&pre_state, &expected)?;
|
||||||
})();
|
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||||
|
|
||||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)?;
|
|
||||||
check_state_diff(&self.pre, &self.post)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -323,14 +323,20 @@ impl<E: EthSpec, O: Operation<E>> Case for Operations<E, O> {
|
|||||||
|
|
||||||
fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> {
|
fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> {
|
||||||
let spec = &testing_spec::<E>(fork_name);
|
let spec = &testing_spec::<E>(fork_name);
|
||||||
let mut state = self.pre.clone();
|
|
||||||
let mut expected = self.post.clone();
|
|
||||||
|
|
||||||
|
let mut pre_state = self.pre.clone();
|
||||||
// Processing requires the committee caches.
|
// Processing requires the committee caches.
|
||||||
state
|
pre_state
|
||||||
.build_all_committee_caches(spec)
|
.build_all_committee_caches(spec)
|
||||||
.expect("committee caches OK");
|
.expect("committee caches OK");
|
||||||
|
|
||||||
|
let mut state = pre_state.clone();
|
||||||
|
let mut expected = self.post.clone();
|
||||||
|
|
||||||
|
expected
|
||||||
|
.as_mut()
|
||||||
|
.map(|post_state| post_state.build_all_committee_caches(spec).unwrap());
|
||||||
|
|
||||||
let mut result = self
|
let mut result = self
|
||||||
.operation
|
.operation
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@@ -338,7 +344,7 @@ impl<E: EthSpec, O: Operation<E>> Case for Operations<E, O> {
|
|||||||
.apply_to(&mut state, spec, self)
|
.apply_to(&mut state, spec, self)
|
||||||
.map(|()| state);
|
.map(|()| state);
|
||||||
|
|
||||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)?;
|
check_state_diff(&pre_state, &expected)?;
|
||||||
check_state_diff(&self.pre, &self.post)
|
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user