Single-pass epoch processing (#4483)

This commit is contained in:
Michael Sproul
2023-07-18 16:59:55 +10:00
committed by GitHub
parent 079cd67df2
commit 5d2063d262
42 changed files with 1558 additions and 730 deletions

View File

@@ -51,6 +51,7 @@ use environment::Environment;
use eth2::{types::StateId, BeaconNodeHttpClient, SensitiveUrl, Timeouts};
use ssz::Encode;
use state_processing::state_advance::{complete_state_advance, partial_state_advance};
use state_processing::AllCaches;
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
@@ -109,7 +110,7 @@ pub fn run<T: EthSpec>(env: Environment<T>, matches: &ArgMatches) -> Result<(),
let target_slot = initial_slot + slots;
state
.build_caches(spec)
.build_all_caches(spec)
.map_err(|e| format!("Unable to build caches: {:?}", e))?;
let state_root = if let Some(root) = cli_state_root.or(state_root) {

View File

@@ -72,10 +72,9 @@ use eth2::{
BeaconNodeHttpClient, SensitiveUrl, Timeouts,
};
use ssz::Encode;
use state_processing::epoch_cache::initialize_epoch_cache;
use state_processing::{
block_signature_verifier::BlockSignatureVerifier, per_block_processing, per_slot_processing,
BlockSignatureStrategy, ConsensusContext, StateProcessingStrategy, VerifyBlockRoot,
AllCaches, BlockSignatureStrategy, ConsensusContext, StateProcessingStrategy, VerifyBlockRoot,
};
use std::borrow::Cow;
use std::fs::File;
@@ -209,7 +208,7 @@ pub fn run<T: EthSpec>(env: Environment<T>, matches: &ArgMatches) -> Result<(),
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()
@@ -313,7 +312,7 @@ fn do_transition<T: EthSpec>(
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());
@@ -343,9 +342,12 @@ fn do_transition<T: EthSpec>(
}
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());
@@ -355,11 +357,6 @@ fn do_transition<T: EthSpec>(
let ctxt = ConsensusContext::new(pre_state.slot())
.set_current_block_root(block_root)
.set_proposer_index(block.message().proposer_index());
if config.exclude_cache_builds {
let epoch = pre_state.current_epoch();
initialize_epoch_cache(&mut pre_state, epoch, spec).map_err(|e| format!("{e:?}"))?;
}
ctxt
};