mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 19:02:42 +00:00
Single-pass epoch processing and optimised block processing (#5279)
* Single-pass epoch processing (#4483, #4573) Co-authored-by: Michael Sproul <michael@sigmaprime.io> * Delete unused epoch processing code (#5170) * Delete unused epoch processing code * Compare total deltas * Remove unnecessary apply_pending * cargo fmt * Remove newline * Use epoch cache in block packing (#5223) * Remove progressive balances mode (#5224) * inline inactivity_penalty_quotient_for_state * drop previous_epoch_total_active_balance * fc lint * spec compliant process_sync_aggregate (#15) * spec compliant process_sync_aggregate * Update consensus/state_processing/src/per_block_processing/altair/sync_committee.rs Co-authored-by: Michael Sproul <micsproul@gmail.com> --------- Co-authored-by: Michael Sproul <micsproul@gmail.com> * Delete the participation cache (#16) * update help * Fix op_pool tests * Fix fork choice tests * Merge remote-tracking branch 'sigp/unstable' into epoch-single-pass * Simplify exit cache (#5280) * Fix clippy on exit cache * Clean up single-pass a bit (#5282) * Address Mark's review of single-pass (#5386) * Merge remote-tracking branch 'origin/unstable' into epoch-single-pass * Address Sean's review comments (#5414) * Address most of Sean's review comments * Simplify total balance cache building * Clean up unused junk * Merge remote-tracking branch 'origin/unstable' into epoch-single-pass * More self-review * Merge remote-tracking branch 'origin/unstable' into epoch-single-pass * Merge branch 'unstable' into epoch-single-pass * Fix imports for beta compiler * Fix tests, probably
This commit is contained in:
@@ -75,8 +75,8 @@ use eth2_network_config::Eth2NetworkConfig;
|
||||
use ssz::Encode;
|
||||
use state_processing::state_advance::complete_state_advance;
|
||||
use state_processing::{
|
||||
block_signature_verifier::BlockSignatureVerifier, per_block_processing, BlockSignatureStrategy,
|
||||
ConsensusContext, StateProcessingStrategy, VerifyBlockRoot,
|
||||
block_signature_verifier::BlockSignatureVerifier, per_block_processing, AllCaches,
|
||||
BlockSignatureStrategy, ConsensusContext, StateProcessingStrategy, VerifyBlockRoot,
|
||||
};
|
||||
use std::borrow::Cow;
|
||||
use std::fs::File;
|
||||
@@ -211,7 +211,7 @@ pub fn run<E: EthSpec>(
|
||||
|
||||
if config.exclude_cache_builds {
|
||||
pre_state
|
||||
.build_caches(spec)
|
||||
.build_all_caches(spec)
|
||||
.map_err(|e| format!("Unable to build caches: {:?}", e))?;
|
||||
let state_root = pre_state
|
||||
.update_tree_hash_cache()
|
||||
@@ -232,6 +232,7 @@ pub fn run<E: EthSpec>(
|
||||
*/
|
||||
|
||||
let mut output_post_state = None;
|
||||
let mut saved_ctxt = None;
|
||||
for i in 0..runs {
|
||||
let pre_state = pre_state.clone_with(CloneConfig::all());
|
||||
let block = block.clone();
|
||||
@@ -245,6 +246,7 @@ pub fn run<E: EthSpec>(
|
||||
state_root_opt,
|
||||
&config,
|
||||
&validator_pubkey_cache,
|
||||
&mut saved_ctxt,
|
||||
spec,
|
||||
)?;
|
||||
|
||||
@@ -294,9 +296,12 @@ pub fn run<E: EthSpec>(
|
||||
.map_err(|e| format!("Unable to write to output file: {:?}", e))?;
|
||||
}
|
||||
|
||||
drop(pre_state);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn do_transition<E: EthSpec>(
|
||||
mut pre_state: BeaconState<E>,
|
||||
block_root: Hash256,
|
||||
@@ -304,12 +309,13 @@ fn do_transition<E: EthSpec>(
|
||||
mut state_root_opt: Option<Hash256>,
|
||||
config: &Config,
|
||||
validator_pubkey_cache: &ValidatorPubkeyCache<EphemeralHarnessType<E>>,
|
||||
saved_ctxt: &mut Option<ConsensusContext<E>>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<BeaconState<E>, String> {
|
||||
if !config.exclude_cache_builds {
|
||||
let t = Instant::now();
|
||||
pre_state
|
||||
.build_caches(spec)
|
||||
.build_all_caches(spec)
|
||||
.map_err(|e| format!("Unable to build caches: {:?}", e))?;
|
||||
debug!("Build caches: {:?}", t.elapsed());
|
||||
|
||||
@@ -337,15 +343,23 @@ fn do_transition<E: EthSpec>(
|
||||
.map_err(|e| format!("Unable to perform complete advance: {e:?}"))?;
|
||||
debug!("Slot processing: {:?}", t.elapsed());
|
||||
|
||||
// Slot and epoch processing should keep the caches fully primed.
|
||||
assert!(pre_state.all_caches_built());
|
||||
|
||||
let t = Instant::now();
|
||||
pre_state
|
||||
.build_caches(spec)
|
||||
.build_all_caches(spec)
|
||||
.map_err(|e| format!("Unable to build caches: {:?}", e))?;
|
||||
debug!("Build all caches (again): {:?}", t.elapsed());
|
||||
|
||||
let mut ctxt = ConsensusContext::new(pre_state.slot())
|
||||
.set_current_block_root(block_root)
|
||||
.set_proposer_index(block.message().proposer_index());
|
||||
let mut ctxt = if let Some(ctxt) = saved_ctxt {
|
||||
ctxt.clone()
|
||||
} else {
|
||||
let ctxt = ConsensusContext::new(pre_state.slot())
|
||||
.set_current_block_root(block_root)
|
||||
.set_proposer_index(block.message().proposer_index());
|
||||
ctxt
|
||||
};
|
||||
|
||||
if !config.no_signature_verification {
|
||||
let get_pubkey = move |validator_index| {
|
||||
|
||||
Reference in New Issue
Block a user