In-memory tree states (#5533)

* Consensus changes

* EF tests

* lcli

* common and watch

* account manager

* cargo

* fork choice

* promise cache

* beacon chain

* interop genesis

* http api

* lighthouse

* op pool

* beacon chain misc

* parallel state cache

* store

* fix issues in store

* IT COMPILES

* Remove some unnecessary module qualification

* Revert Arced pubkey optimization (#5536)

* Merge remote-tracking branch 'origin/unstable' into tree-states-memory

* Fix caching, rebasing and some tests

* Remove unused deps

* Merge remote-tracking branch 'origin/unstable' into tree-states-memory

* Small cleanups

* Revert shuffling cache/promise cache changes

* Fix state advance bugs

* Fix shuffling tests

* Remove some resolved FIXMEs

* Remove StateProcessingStrategy

* Optimise withdrawals calculation

* Don't reorg if state cache is missed

* Remove inconsistent state func

* Fix beta compiler

* Rebase early, rebase often

* Fix state caching behaviour

* Update to milhouse release

* Fix on-disk consensus context format

* Merge remote-tracking branch 'origin/unstable' into tree-states-memory

* Squashed commit of the following:

commit 3a16649023
Author: Michael Sproul <michael@sigmaprime.io>
Date:   Thu Apr 18 14:26:09 2024 +1000

    Fix on-disk consensus context format

* Keep indexed attestations, thanks Sean

* Merge branch 'on-disk-consensus-context' into tree-states-memory

* Merge branch 'unstable' into tree-states-memory

* Address half of Sean's review

* More simplifications from Sean's review

* Cache state after get_advanced_hot_state
This commit is contained in:
Michael Sproul
2024-04-24 11:22:36 +10:00
committed by GitHub
parent 4cad1fcbbe
commit 61962898e2
108 changed files with 2038 additions and 2762 deletions

View File

@@ -82,6 +82,7 @@ pub enum BlockProcessingError {
},
ExecutionInvalid,
ConsensusContext(ContextError),
MilhouseError(milhouse::Error),
EpochCacheError(EpochCacheError),
WithdrawalsRootMismatch {
expected: Hash256,
@@ -138,6 +139,12 @@ impl From<EpochCacheError> for BlockProcessingError {
}
}
impl From<milhouse::Error> for BlockProcessingError {
fn from(e: milhouse::Error) -> Self {
Self::MilhouseError(e)
}
}
impl From<BlockOperationError<HeaderInvalid>> for BlockProcessingError {
fn from(e: BlockOperationError<HeaderInvalid>) -> BlockProcessingError {
match e {

View File

@@ -128,7 +128,7 @@ pub mod altair_deneb {
let previous_epoch = ctxt.previous_epoch;
let current_epoch = ctxt.current_epoch;
let attesting_indices = &verify_attestation_for_block_inclusion(
let attesting_indices = verify_attestation_for_block_inclusion(
state,
attestation,
ctxt,
@@ -136,7 +136,8 @@ pub mod altair_deneb {
spec,
)
.map_err(|e| e.into_with_index(att_index))?
.attesting_indices;
.attesting_indices
.clone();
// Matching roots, participation flag indices
let data = &attestation.data;
@@ -146,7 +147,7 @@ pub mod altair_deneb {
// Update epoch participation flags.
let mut proposer_reward_numerator = 0;
for index in attesting_indices {
for index in &attesting_indices {
let index = *index as usize;
let validator_effective_balance = state.epoch_cache().get_effective_balance(index)?;

View File

@@ -5,7 +5,7 @@ use crate::per_block_processing::errors::{
DepositInvalid, HeaderInvalid, IndexedAttestationInvalid, IntoWithIndex,
ProposerSlashingInvalid,
};
use crate::{per_block_processing, BlockReplayError, BlockReplayer, StateProcessingStrategy};
use crate::{per_block_processing, BlockReplayError, BlockReplayer};
use crate::{
per_block_processing::{process_operations, verify_exit::verify_exit},
BlockSignatureStrategy, ConsensusContext, VerifyBlockRoot, VerifySignatures,
@@ -72,7 +72,6 @@ async fn valid_block_ok() {
&mut state,
&block,
BlockSignatureStrategy::VerifyIndividual,
StateProcessingStrategy::Accurate,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
@@ -98,7 +97,6 @@ async fn invalid_block_header_state_slot() {
&mut state,
&SignedBeaconBlock::from_block(block, signature),
BlockSignatureStrategy::VerifyIndividual,
StateProcessingStrategy::Accurate,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
@@ -131,7 +129,6 @@ async fn invalid_parent_block_root() {
&mut state,
&SignedBeaconBlock::from_block(block, signature),
BlockSignatureStrategy::VerifyIndividual,
StateProcessingStrategy::Accurate,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
@@ -165,7 +162,6 @@ async fn invalid_block_signature() {
&mut state,
&SignedBeaconBlock::from_block(block, Signature::empty()),
BlockSignatureStrategy::VerifyIndividual,
StateProcessingStrategy::Accurate,
VerifyBlockRoot::True,
&mut ctxt,
&spec,
@@ -199,7 +195,6 @@ async fn invalid_randao_reveal_signature() {
&mut state,
&signed_block,
BlockSignatureStrategy::VerifyIndividual,
StateProcessingStrategy::Accurate,
VerifyBlockRoot::True,
&mut ctxt,
&spec,