mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Use rustc-hash in participation cache
This commit is contained in:
@@ -25,6 +25,7 @@ smallvec = "1.6.1"
|
|||||||
arbitrary = { version = "1.0", features = ["derive"], optional = true }
|
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"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["legacy-arith", "metrics"]
|
default = ["legacy-arith", "metrics"]
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
//! Additionally, this cache is returned from the `altair::process_epoch` function and can be used
|
//! Additionally, this cache is returned from the `altair::process_epoch` function and can be used
|
||||||
//! to get useful summaries about the validator participation in an epoch.
|
//! to get useful summaries about the validator participation in an epoch.
|
||||||
|
|
||||||
|
use rustc_hash::FxHashMap as HashMap;
|
||||||
use safe_arith::{ArithError, SafeArith};
|
use safe_arith::{ArithError, SafeArith};
|
||||||
use std::collections::HashMap;
|
|
||||||
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,
|
||||||
@@ -82,7 +82,10 @@ impl SingleEpochParticipationCache {
|
|||||||
let zero_balance = Balance::zero(spec.effective_balance_increment);
|
let zero_balance = Balance::zero(spec.effective_balance_increment);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
unslashed_participating_indices: HashMap::with_capacity(hashmap_len),
|
unslashed_participating_indices: HashMap::with_capacity_and_hasher(
|
||||||
|
hashmap_len,
|
||||||
|
Default::default(),
|
||||||
|
),
|
||||||
total_flag_balances: [zero_balance; NUM_FLAG_INDICES],
|
total_flag_balances: [zero_balance; NUM_FLAG_INDICES],
|
||||||
total_active_balance: zero_balance,
|
total_active_balance: zero_balance,
|
||||||
}
|
}
|
||||||
@@ -200,7 +203,8 @@ impl ParticipationCache {
|
|||||||
let mut previous_epoch_participation =
|
let mut previous_epoch_participation =
|
||||||
SingleEpochParticipationCache::new(num_previous_epoch_active_vals, spec);
|
SingleEpochParticipationCache::new(num_previous_epoch_active_vals, spec);
|
||||||
|
|
||||||
let mut effective_balances = HashMap::with_capacity(num_current_epoch_active_vals);
|
let mut effective_balances =
|
||||||
|
HashMap::with_capacity_and_hasher(num_current_epoch_active_vals, Default::default());
|
||||||
|
|
||||||
// Contains the set of validators which are either:
|
// Contains the set of validators which are either:
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ use clap::ArgMatches;
|
|||||||
use eth2_network_config::Eth2NetworkConfig;
|
use eth2_network_config::Eth2NetworkConfig;
|
||||||
use ssz::Encode;
|
use ssz::Encode;
|
||||||
use state_processing::{
|
use state_processing::{
|
||||||
per_block_processing, per_slot_processing, BlockSignatureStrategy, VerifyBlockRoot,
|
per_block_processing, per_slot_processing, BlockSignatureStrategy, ConsensusContext,
|
||||||
|
VerifyBlockRoot,
|
||||||
};
|
};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
@@ -94,12 +95,14 @@ fn do_transition<T: EthSpec>(
|
|||||||
.map_err(|e| format!("Unable to build caches: {:?}", e))?;
|
.map_err(|e| format!("Unable to build caches: {:?}", e))?;
|
||||||
|
|
||||||
let t = std::time::Instant::now();
|
let t = std::time::Instant::now();
|
||||||
|
let mut ctxt =
|
||||||
|
ConsensusContext::new(block.slot()).set_proposer_index(block.message().proposer_index());
|
||||||
per_block_processing(
|
per_block_processing(
|
||||||
&mut pre_state,
|
&mut pre_state,
|
||||||
&block,
|
&block,
|
||||||
None,
|
|
||||||
BlockSignatureStrategy::NoVerification,
|
BlockSignatureStrategy::NoVerification,
|
||||||
VerifyBlockRoot::True,
|
VerifyBlockRoot::True,
|
||||||
|
&mut ctxt,
|
||||||
spec,
|
spec,
|
||||||
)
|
)
|
||||||
.map_err(|e| format!("State transition failed: {:?}", e))?;
|
.map_err(|e| format!("State transition failed: {:?}", e))?;
|
||||||
|
|||||||
Reference in New Issue
Block a user