mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-04 21:34:36 +00:00
Fix ups and Clippy
This commit is contained in:
59
Cargo.lock
generated
59
Cargo.lock
generated
@@ -614,7 +614,7 @@ dependencies = [
|
||||
"task_executor",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"types",
|
||||
"unused_port",
|
||||
]
|
||||
@@ -761,6 +761,7 @@ version = "0.2.0"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"blst",
|
||||
"criterion",
|
||||
"ethereum-types 0.14.1",
|
||||
"ethereum_hashing",
|
||||
"ethereum_serde_utils",
|
||||
@@ -770,7 +771,7 @@ dependencies = [
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@@ -1632,7 +1633,7 @@ dependencies = [
|
||||
"reqwest",
|
||||
"serde_json",
|
||||
"sha2 0.10.6",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"types",
|
||||
]
|
||||
|
||||
@@ -1925,7 +1926,7 @@ dependencies = [
|
||||
"state_processing",
|
||||
"store",
|
||||
"swap_or_not_shuffle",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"tree_hash_derive",
|
||||
"types",
|
||||
]
|
||||
@@ -2081,7 +2082,7 @@ dependencies = [
|
||||
"superstruct",
|
||||
"task_executor",
|
||||
"tokio",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"types",
|
||||
"web3",
|
||||
]
|
||||
@@ -2360,9 +2361,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ethereum_ssz"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29d6b56a74d435691764a6e8b635dab1cca4fcf15d7ec8f265c73d3b98cdd889"
|
||||
checksum = "8012d097c5b4f4915c84c672a397a2ca4124e1900737f1393b3ba0c87d8fa489"
|
||||
dependencies = [
|
||||
"ethereum-types 0.14.1",
|
||||
"itertools",
|
||||
@@ -2371,9 +2372,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ethereum_ssz_derive"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44f51ce7a63b03c9ee2ea8e0e7078e948846dc227331e50fa2124c0fa872b1fc"
|
||||
checksum = "9f421142049c25d52d7c38124af054e235f4898355282069ef37e4d031565fb8"
|
||||
dependencies = [
|
||||
"darling 0.13.4",
|
||||
"proc-macro2",
|
||||
@@ -2514,7 +2515,7 @@ dependencies = [
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"tree_hash_derive",
|
||||
"triehash",
|
||||
"types",
|
||||
@@ -2864,7 +2865,7 @@ dependencies = [
|
||||
"slog",
|
||||
"state_processing",
|
||||
"tokio",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"types",
|
||||
]
|
||||
|
||||
@@ -3230,7 +3231,7 @@ dependencies = [
|
||||
"task_executor",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"types",
|
||||
"unused_port",
|
||||
"warp",
|
||||
@@ -3739,7 +3740,7 @@ dependencies = [
|
||||
"snap",
|
||||
"state_processing",
|
||||
"store",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"types",
|
||||
"validator_dir",
|
||||
"web3",
|
||||
@@ -4701,7 +4702,7 @@ dependencies = [
|
||||
"rayon",
|
||||
"serde",
|
||||
"smallvec",
|
||||
"tree_hash 0.5.0",
|
||||
"tree_hash",
|
||||
"triomphe",
|
||||
"typenum",
|
||||
"vec_map",
|
||||
@@ -7078,7 +7079,7 @@ dependencies = [
|
||||
"sloggers",
|
||||
"strum",
|
||||
"tempfile",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"tree_hash_derive",
|
||||
"types",
|
||||
]
|
||||
@@ -7341,6 +7342,12 @@ dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "state_processing"
|
||||
version = "0.2.0"
|
||||
@@ -7365,7 +7372,7 @@ dependencies = [
|
||||
"smallvec",
|
||||
"ssz_types",
|
||||
"tokio",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"types",
|
||||
"vec_map",
|
||||
]
|
||||
@@ -7402,6 +7409,7 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"leveldb",
|
||||
"lighthouse_metrics",
|
||||
"logging",
|
||||
"lru 0.7.8",
|
||||
"parking_lot 0.12.1",
|
||||
"safe_arith",
|
||||
@@ -7414,7 +7422,7 @@ dependencies = [
|
||||
"strum",
|
||||
"take-until",
|
||||
"tempfile",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"types",
|
||||
"zstd",
|
||||
]
|
||||
@@ -8138,17 +8146,6 @@ dependencies = [
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree_hash"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87bb13ce6641dabdb9983d3cadd77d9320eb81102abeb15220eb98db12d58eb6"
|
||||
dependencies = [
|
||||
"ethereum-types 0.14.1",
|
||||
"ethereum_hashing",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree_hash_derive"
|
||||
version = "0.5.0"
|
||||
@@ -8355,7 +8352,7 @@ dependencies = [
|
||||
"tempfile",
|
||||
"test_random_derive",
|
||||
"tokio",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"tree_hash_derive",
|
||||
]
|
||||
|
||||
@@ -8549,7 +8546,7 @@ dependencies = [
|
||||
"task_executor",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"types",
|
||||
"url",
|
||||
"validator_dir",
|
||||
@@ -8570,7 +8567,7 @@ dependencies = [
|
||||
"lockfile",
|
||||
"rand 0.8.5",
|
||||
"tempfile",
|
||||
"tree_hash 0.4.1",
|
||||
"tree_hash",
|
||||
"types",
|
||||
]
|
||||
|
||||
|
||||
@@ -87,9 +87,6 @@ members = [
|
||||
fixed-hash = { git = "https://github.com/paritytech/parity-common", rev="df638ab0885293d21d656dc300d39236b69ce57d" }
|
||||
warp = { git = "https://github.com/macladson/warp", rev="7e75acc368229a46a236a8c991bf251fe7fe50ef" }
|
||||
|
||||
[patch."https://github.com/sigp/milhouse"]
|
||||
milhouse = { path = "../milhouse" }
|
||||
|
||||
[profile.maxperf]
|
||||
inherits = "release"
|
||||
lto = "fat"
|
||||
|
||||
@@ -3456,7 +3456,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
};
|
||||
let (state, state_root_opt) = if head_slot < slot {
|
||||
// Attempt an aggressive re-org if configured and the conditions are right.
|
||||
if let Some(re_org_state) = self.get_state_for_re_org(slot, head_slot, head_block_root)
|
||||
if let Some((re_org_state, re_org_state_root)) =
|
||||
self.get_state_for_re_org(slot, head_slot, head_block_root)
|
||||
{
|
||||
info!(
|
||||
self.log,
|
||||
@@ -3464,7 +3465,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
"slot" => slot,
|
||||
"head_to_reorg" => %head_block_root,
|
||||
);
|
||||
(re_org_state.pre_state, re_org_state.state_root)
|
||||
(re_org_state, Some(re_org_state_root))
|
||||
} else {
|
||||
// Fetch the head state advanced through to `slot`, which should be present in the
|
||||
// state cache thanks to the state advance timer.
|
||||
@@ -3594,7 +3595,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
"Error loading block production state";
|
||||
"error" => ?e,
|
||||
);
|
||||
)
|
||||
})
|
||||
.ok()??;
|
||||
|
||||
info!(
|
||||
|
||||
@@ -192,11 +192,7 @@ where
|
||||
balances_cache: <_>::default(),
|
||||
time: anchor_state.slot(),
|
||||
justified_checkpoint,
|
||||
<<<<<<< HEAD
|
||||
justified_balances: anchor_state.balances().to_vec(),
|
||||
=======
|
||||
justified_balances,
|
||||
>>>>>>> origin/unstable
|
||||
finalized_checkpoint,
|
||||
best_justified_checkpoint: justified_checkpoint,
|
||||
unrealized_justified_checkpoint: justified_checkpoint,
|
||||
|
||||
@@ -530,7 +530,7 @@ pub fn signature_verify_chain_segment<T: BeaconChainTypes>(
|
||||
}
|
||||
|
||||
let (first_root, first_block) = chain_segment.remove(0);
|
||||
let (mut parent, first_block) = load_parent(first_root, first_block, chain)?;
|
||||
let (mut parent, first_block) = load_parent(first_block, chain)?;
|
||||
let slot = first_block.slot();
|
||||
chain_segment.insert(0, (first_root, first_block));
|
||||
|
||||
@@ -795,7 +795,7 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
|
||||
} else {
|
||||
// The proposer index was *not* cached and we must load the parent in order to determine
|
||||
// the proposer index.
|
||||
let (mut parent, block) = load_parent(block_root, block, chain)?;
|
||||
let (mut parent, block) = load_parent(block, chain)?;
|
||||
|
||||
debug!(
|
||||
chain.log,
|
||||
@@ -933,7 +933,7 @@ impl<T: BeaconChainTypes> SignatureVerifiedBlock<T> {
|
||||
// Check the anchor slot before loading the parent, to avoid spurious lookups.
|
||||
check_block_against_anchor_slot(block.message(), chain)?;
|
||||
|
||||
let (mut parent, block) = load_parent(block_root, block, chain)?;
|
||||
let (mut parent, block) = load_parent(block, chain)?;
|
||||
|
||||
// Reject any block that exceeds our limit on skipped slots.
|
||||
check_block_skip_slots(chain, parent.beacon_block.slot(), block.message())?;
|
||||
@@ -986,7 +986,7 @@ impl<T: BeaconChainTypes> SignatureVerifiedBlock<T> {
|
||||
let (mut parent, block) = if let Some(parent) = from.parent {
|
||||
(parent, from.block)
|
||||
} else {
|
||||
load_parent(from.block_root, from.block, chain)?
|
||||
load_parent(from.block, chain)?
|
||||
};
|
||||
|
||||
let state = cheap_state_advance_to_obtain_committees(
|
||||
@@ -1046,7 +1046,7 @@ impl<T: BeaconChainTypes> IntoExecutionPendingBlock<T> for SignatureVerifiedBloc
|
||||
let (parent, block) = if let Some(parent) = self.parent {
|
||||
(parent, self.block)
|
||||
} else {
|
||||
load_parent(self.block_root, self.block, chain)
|
||||
load_parent(self.block, chain)
|
||||
.map_err(|e| BlockSlashInfo::SignatureValid(header.clone(), e))?
|
||||
};
|
||||
|
||||
@@ -1655,7 +1655,6 @@ fn verify_parent_block_is_known<T: BeaconChainTypes>(
|
||||
/// whilst attempting the operation.
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn load_parent<T: BeaconChainTypes>(
|
||||
block_root: Hash256,
|
||||
block: Arc<SignedBeaconBlock<T::EthSpec>>,
|
||||
chain: &BeaconChain<T>,
|
||||
) -> Result<
|
||||
|
||||
@@ -7,6 +7,7 @@ edition = "2021"
|
||||
[dev-dependencies]
|
||||
tempfile = "3.1.0"
|
||||
beacon_chain = {path = "../beacon_chain"}
|
||||
logging = { path = "../../common/logging" }
|
||||
|
||||
[dependencies]
|
||||
db-key = "0.0.5"
|
||||
@@ -26,7 +27,7 @@ lighthouse_metrics = { path = "../../common/lighthouse_metrics" }
|
||||
lru = "0.7.1"
|
||||
sloggers = { version = "2.1.1", features = ["json"] }
|
||||
directory = { path = "../../common/directory" }
|
||||
tree_hash = "0.4.0"
|
||||
tree_hash = "0.5.0"
|
||||
take-until = "0.1.0"
|
||||
zstd = "0.11.0"
|
||||
strum = { version = "0.24.0", features = ["derive"] }
|
||||
|
||||
@@ -1729,6 +1729,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
}
|
||||
|
||||
/// Load the state root of a restore point.
|
||||
#[allow(unused)]
|
||||
fn load_restore_point_hash(&self, restore_point_index: u64) -> Result<Hash256, Error> {
|
||||
let key = Self::restore_point_key(restore_point_index);
|
||||
self.cold_db
|
||||
@@ -1738,6 +1739,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
}
|
||||
|
||||
/// Store the state root of a restore point.
|
||||
#[allow(unused)]
|
||||
fn store_restore_point_hash(
|
||||
&self,
|
||||
restore_point_index: u64,
|
||||
@@ -1751,6 +1753,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
}
|
||||
|
||||
/// Convert a `restore_point_index` into a database key.
|
||||
#[allow(unused)]
|
||||
fn restore_point_key(restore_point_index: u64) -> Hash256 {
|
||||
Hash256::from_low_u64_be(restore_point_index)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::*;
|
||||
use ssz::{DecodeError, Encode};
|
||||
use ssz::Encode;
|
||||
use ssz_derive::Encode;
|
||||
use std::io::{Read, Write};
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -146,7 +146,7 @@ impl<E: EthSpec> StateCache<E> {
|
||||
.iter()
|
||||
.rev()
|
||||
.find_map(|(ancestor_slot, state_root)| {
|
||||
(*ancestor_slot <= slot).then(|| *state_root)
|
||||
(*ancestor_slot <= slot).then_some(*state_root)
|
||||
})?;
|
||||
|
||||
let state = self.get_by_state_root(state_root)?;
|
||||
|
||||
@@ -218,6 +218,7 @@ impl DatabaseValidator {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
fn into_immutable_validator(&self) -> Result<(PublicKey, ValidatorImmutable), Error> {
|
||||
let pubkey = PublicKey::deserialize_uncompressed(&self.pubkey)
|
||||
.map_err(Error::InvalidValidatorPubkeyBytes)?;
|
||||
@@ -236,14 +237,14 @@ impl DatabaseValidator {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::test_utils::{BeaconChainHarness, EphemeralHarnessType};
|
||||
use crate::{HotColdDB, KeyValueStore, MemoryStore};
|
||||
use beacon_chain::test_utils::BeaconChainHarness;
|
||||
use logging::test_logger;
|
||||
use std::sync::Arc;
|
||||
use store::HotColdDB;
|
||||
use types::{BeaconState, EthSpec, Keypair, MainnetEthSpec};
|
||||
|
||||
type E = MainnetEthSpec;
|
||||
type T = EphemeralHarnessType<E>;
|
||||
type Store = MemoryStore<E>;
|
||||
|
||||
fn get_state(validator_count: usize) -> (BeaconState<E>, Vec<Keypair>) {
|
||||
let harness = BeaconChainHarness::builder(MainnetEthSpec)
|
||||
@@ -257,14 +258,14 @@ mod test {
|
||||
(harness.get_current_state(), harness.validator_keypairs)
|
||||
}
|
||||
|
||||
fn get_store() -> BeaconStore<T> {
|
||||
fn get_store() -> Arc<HotColdDB<E, Store, Store>> {
|
||||
Arc::new(
|
||||
HotColdDB::open_ephemeral(<_>::default(), E::default_spec(), test_logger()).unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(clippy::needless_range_loop)]
|
||||
fn check_cache_get(cache: &ValidatorPubkeyCache<T>, keypairs: &[Keypair]) {
|
||||
fn check_cache_get(cache: &ValidatorPubkeyCache<E, Store, Store>, keypairs: &[Keypair]) {
|
||||
let validator_count = keypairs.len();
|
||||
|
||||
for i in 0..validator_count + 1 {
|
||||
@@ -297,7 +298,7 @@ mod test {
|
||||
|
||||
let store = get_store();
|
||||
|
||||
let mut cache = ValidatorPubkeyCache::new(&state, store).expect("should create cache");
|
||||
let mut cache = ValidatorPubkeyCache::new(&state, &store).expect("should create cache");
|
||||
|
||||
check_cache_get(&cache, &keypairs[..]);
|
||||
|
||||
@@ -330,13 +331,12 @@ mod test {
|
||||
let store = get_store();
|
||||
|
||||
// Create a new cache.
|
||||
let cache = ValidatorPubkeyCache::new(&state, store.clone()).expect("should create cache");
|
||||
let cache = ValidatorPubkeyCache::new(&state, &store).expect("should create cache");
|
||||
check_cache_get(&cache, &keypairs[..]);
|
||||
drop(cache);
|
||||
|
||||
// Re-init the cache from the store.
|
||||
let mut cache =
|
||||
ValidatorPubkeyCache::load_from_store(store.clone()).expect("should open cache");
|
||||
let mut cache = ValidatorPubkeyCache::load_from_store(&store).expect("should open cache");
|
||||
check_cache_get(&cache, &keypairs[..]);
|
||||
|
||||
// Add some more keypairs.
|
||||
@@ -349,7 +349,7 @@ mod test {
|
||||
drop(cache);
|
||||
|
||||
// Re-init the cache from the store.
|
||||
let cache = ValidatorPubkeyCache::load_from_store(store).expect("should open cache");
|
||||
let cache = ValidatorPubkeyCache::load_from_store(&store).expect("should open cache");
|
||||
check_cache_get(&cache, &keypairs[..]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ impl JustifiedBalances {
|
||||
.iter()
|
||||
.map(|validator| {
|
||||
if validator.is_active_at(current_epoch) {
|
||||
total_effective_balance.safe_add_assign(validator.effective_balance)?;
|
||||
total_effective_balance.safe_add_assign(validator.effective_balance())?;
|
||||
num_active_validators.safe_add_assign(1)?;
|
||||
|
||||
Ok(validator.effective_balance)
|
||||
Ok(validator.effective_balance())
|
||||
} else {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ impl ParticipationCache {
|
||||
eligible_indices,
|
||||
process_slashings_indices,
|
||||
inactivity_score_updates: definitely_not_in_inactivity_leak
|
||||
.then(|| inactivity_score_updates),
|
||||
.then_some(inactivity_score_updates),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ use crate::validator::ValidatorTrait;
|
||||
use crate::*;
|
||||
use compare_fields::CompareFields;
|
||||
use compare_fields_derive::CompareFields;
|
||||
use derivative::Derivative;
|
||||
use ethereum_hashing::hash;
|
||||
use int_to_bytes::{int_to_bytes4, int_to_bytes8};
|
||||
use metastruct::{metastruct, NumFields};
|
||||
@@ -1711,6 +1710,7 @@ impl<T: EthSpec, GenericValidator: ValidatorTrait> BeaconState<T, GenericValidat
|
||||
))
|
||||
}
|
||||
|
||||
#[allow(clippy::integer_arithmetic)]
|
||||
pub fn apply_pending_mutations(&mut self) -> Result<(), Error> {
|
||||
match self {
|
||||
Self::Base(inner) => {
|
||||
@@ -1754,6 +1754,7 @@ impl<T: EthSpec, GenericValidator: ValidatorTrait> BeaconState<T, GenericValidat
|
||||
|
||||
// 2. Get all `BeaconState` leaves.
|
||||
let mut leaves = vec![];
|
||||
#[allow(clippy::integer_arithmetic)]
|
||||
match self {
|
||||
BeaconState::Base(state) => {
|
||||
map_beacon_state_base_fields!(state, |_, field| {
|
||||
|
||||
@@ -6,12 +6,9 @@ use beacon_chain::types::{
|
||||
BeaconStateMerge, ChainSpec, Domain, Epoch, EthSpec, FixedVector, Hash256, Keypair,
|
||||
MainnetEthSpec, MinimalEthSpec, RelativeEpoch, Slot,
|
||||
};
|
||||
use safe_arith::SafeArith;
|
||||
use ssz::{Decode, Encode};
|
||||
use state_processing::per_slot_processing;
|
||||
use ssz::Encode;
|
||||
use std::ops::Mul;
|
||||
use swap_or_not_shuffle::compute_shuffled_index;
|
||||
use tree_hash::TreeHash;
|
||||
|
||||
pub const MAX_VALIDATOR_COUNT: usize = 129;
|
||||
pub const SLOT_OFFSET: Slot = Slot::new(1);
|
||||
|
||||
@@ -246,7 +246,7 @@ impl ChainSpec {
|
||||
pub fn fork_activated_at_slot<E: EthSpec>(&self, slot: Slot) -> Option<ForkName> {
|
||||
let prev_slot_fork = self.fork_name_at_slot::<E>(slot - 1);
|
||||
let slot_fork = self.fork_name_at_slot::<E>(slot);
|
||||
(slot_fork != prev_slot_fork).then(|| slot_fork)
|
||||
(slot_fork != prev_slot_fork).then_some(slot_fork)
|
||||
}
|
||||
|
||||
/// Returns the fork version for a named fork.
|
||||
|
||||
@@ -19,6 +19,7 @@ pub struct LightClientFinalityUpdate<T: EthSpec> {
|
||||
/// The last `BeaconBlockHeader` from the last attested finalized block (end of epoch).
|
||||
pub finalized_header: BeaconBlockHeader,
|
||||
/// Merkle proof attesting finalized header.
|
||||
#[test_random(default)]
|
||||
pub finality_branch: FixedVector<Hash256, FinalizedRootProofLen>,
|
||||
/// current sync aggreggate
|
||||
pub sync_aggregate: SyncAggregate<T>,
|
||||
|
||||
@@ -26,6 +26,7 @@ pub const NEXT_SYNC_COMMITTEE_PROOF_LEN: usize = 5;
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum Error {
|
||||
SszTypesError(ssz_types::Error),
|
||||
MilhouseError(milhouse::Error),
|
||||
BeaconStateError(beacon_state::Error),
|
||||
ArithError(ArithError),
|
||||
AltairForkNotActive,
|
||||
@@ -52,6 +53,12 @@ impl From<ArithError> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<milhouse::Error> for Error {
|
||||
fn from(e: milhouse::Error) -> Error {
|
||||
Error::MilhouseError(e)
|
||||
}
|
||||
}
|
||||
|
||||
/// A LightClientUpdate is the update we request solely to either complete the bootstraping process,
|
||||
/// or to sync up to the last committee period, we need to have one ready for each ALTAIR period
|
||||
/// we go over, note: there is no need to keep all of the updates from [ALTAIR_PERIOD, CURRENT_PERIOD].
|
||||
|
||||
@@ -98,11 +98,20 @@ impl Validator {
|
||||
self.mutable.activation_epoch
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn activation_epoch_mut(&mut self) -> &mut Epoch {
|
||||
&mut self.mutable.activation_epoch
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn exit_epoch(&self) -> Epoch {
|
||||
self.mutable.exit_epoch
|
||||
}
|
||||
|
||||
pub fn exit_epoch_mut(&mut self) -> &mut Epoch {
|
||||
&mut self.mutable.exit_epoch
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn withdrawable_epoch(&self) -> Epoch {
|
||||
self.mutable.withdrawable_epoch
|
||||
|
||||
@@ -198,7 +198,7 @@ pub fn run<T: EthSpec>(env: Environment<T>, matches: &ArgMatches) -> Result<(),
|
||||
let validator_pubkey_cache = store.immutable_validators.clone();
|
||||
validator_pubkey_cache
|
||||
.write()
|
||||
.import_new_pubkeys(&pre_state, &store)
|
||||
.import_new_pubkeys(&pre_state)
|
||||
.map_err(|e| format!("Failed to create pubkey cache: {:?}", e))?;
|
||||
|
||||
/*
|
||||
@@ -298,6 +298,7 @@ pub fn run<T: EthSpec>(env: Environment<T>, matches: &ArgMatches) -> Result<(),
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn do_transition<T: EthSpec>(
|
||||
mut pre_state: BeaconState<T>,
|
||||
block_root: Hash256,
|
||||
|
||||
@@ -294,9 +294,9 @@ impl<E: EthSpec, T: EpochTransition<E>> Case for EpochProcessing<E, T> {
|
||||
let mut state = pre_state.clone();
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
expected.as_mut().map(|post_state| {
|
||||
if let Some(post_state) = expected.as_mut() {
|
||||
post_state.build_all_committee_caches(spec).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
let mut result = T::run(&mut state, spec).map(|_| state);
|
||||
|
||||
|
||||
@@ -386,9 +386,9 @@ impl<E: EthSpec, O: Operation<E>> Case for Operations<E, O> {
|
||||
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());
|
||||
if let Some(post_state) = expected.as_mut() {
|
||||
post_state.build_all_committee_caches(spec).unwrap();
|
||||
}
|
||||
|
||||
let mut result = self
|
||||
.operation
|
||||
|
||||
@@ -170,7 +170,7 @@ vectors_and_tests!(
|
||||
invalid_exit_already_initiated,
|
||||
ExitTest {
|
||||
state_modifier: Box::new(|state| {
|
||||
state.validators_mut().get_mut(0).unwrap().exit_epoch = STATE_EPOCH + 1;
|
||||
*state.validators_mut().get_mut(0).unwrap().exit_epoch_mut() = STATE_EPOCH + 1;
|
||||
}),
|
||||
expected: Err(BlockProcessingError::ExitInvalid {
|
||||
index: 0,
|
||||
@@ -189,8 +189,11 @@ vectors_and_tests!(
|
||||
invalid_not_active_before_activation_epoch,
|
||||
ExitTest {
|
||||
state_modifier: Box::new(|state| {
|
||||
state.validators_mut().get_mut(0).unwrap().activation_epoch =
|
||||
E::default_spec().far_future_epoch;
|
||||
*state
|
||||
.validators_mut()
|
||||
.get_mut(0)
|
||||
.unwrap()
|
||||
.activation_epoch_mut() = E::default_spec().far_future_epoch;
|
||||
}),
|
||||
expected: Err(BlockProcessingError::ExitInvalid {
|
||||
index: 0,
|
||||
@@ -209,7 +212,7 @@ vectors_and_tests!(
|
||||
invalid_not_active_after_exit_epoch,
|
||||
ExitTest {
|
||||
state_modifier: Box::new(|state| {
|
||||
state.validators_mut().get_mut(0).unwrap().exit_epoch = STATE_EPOCH;
|
||||
*state.validators_mut().get_mut(0).unwrap().exit_epoch_mut() = STATE_EPOCH;
|
||||
}),
|
||||
expected: Err(BlockProcessingError::ExitInvalid {
|
||||
index: 0,
|
||||
|
||||
Reference in New Issue
Block a user