mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 02:12:33 +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:
@@ -5,6 +5,7 @@ use crate::decode::{ssz_decode_file, ssz_decode_file_with, ssz_decode_state, yam
|
||||
use serde::Deserialize;
|
||||
use ssz::Decode;
|
||||
use state_processing::common::update_progressive_balances_cache::initialize_progressive_balances_cache;
|
||||
use state_processing::epoch_cache::initialize_epoch_cache;
|
||||
use state_processing::{
|
||||
per_block_processing::{
|
||||
errors::BlockProcessingError,
|
||||
@@ -87,6 +88,7 @@ impl<E: EthSpec> Operation<E> for Attestation<E> {
|
||||
spec: &ChainSpec,
|
||||
_: &Operations<E, Self>,
|
||||
) -> Result<(), BlockProcessingError> {
|
||||
initialize_epoch_cache(state, spec)?;
|
||||
let mut ctxt = ConsensusContext::new(state.slot());
|
||||
match state {
|
||||
BeaconState::Base(_) => base::process_attestations(
|
||||
@@ -101,7 +103,7 @@ impl<E: EthSpec> Operation<E> for Attestation<E> {
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => {
|
||||
initialize_progressive_balances_cache(state, None, spec)?;
|
||||
initialize_progressive_balances_cache(state, spec)?;
|
||||
altair_deneb::process_attestation(
|
||||
state,
|
||||
self,
|
||||
@@ -131,7 +133,7 @@ impl<E: EthSpec> Operation<E> for AttesterSlashing<E> {
|
||||
_: &Operations<E, Self>,
|
||||
) -> Result<(), BlockProcessingError> {
|
||||
let mut ctxt = ConsensusContext::new(state.slot());
|
||||
initialize_progressive_balances_cache(state, None, spec)?;
|
||||
initialize_progressive_balances_cache(state, spec)?;
|
||||
process_attester_slashings(
|
||||
state,
|
||||
&[self.clone()],
|
||||
@@ -182,7 +184,7 @@ impl<E: EthSpec> Operation<E> for ProposerSlashing {
|
||||
_: &Operations<E, Self>,
|
||||
) -> Result<(), BlockProcessingError> {
|
||||
let mut ctxt = ConsensusContext::new(state.slot());
|
||||
initialize_progressive_balances_cache(state, None, spec)?;
|
||||
initialize_progressive_balances_cache(state, spec)?;
|
||||
process_proposer_slashings(
|
||||
state,
|
||||
&[self.clone()],
|
||||
@@ -484,14 +486,22 @@ impl<E: EthSpec, O: Operation<E>> Case for Operations<E, O> {
|
||||
|
||||
fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> {
|
||||
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.
|
||||
// NOTE: some of the withdrawals tests have 0 active validators, do not try
|
||||
// to build the commitee cache in this case.
|
||||
if O::handler_name() != "withdrawals" {
|
||||
state.build_all_committee_caches(spec).unwrap();
|
||||
pre_state.build_all_committee_caches(spec).unwrap();
|
||||
}
|
||||
|
||||
let mut state = pre_state.clone();
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
if O::handler_name() != "withdrawals" {
|
||||
if let Some(post_state) = expected.as_mut() {
|
||||
post_state.build_all_committee_caches(spec).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
let mut result = self
|
||||
|
||||
Reference in New Issue
Block a user