mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 10:11:44 +00:00
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:
@@ -39,6 +39,9 @@ pub fn compare_beacon_state_results_without_caches<E: EthSpec, T: Debug>(
|
||||
if let (Ok(ref mut result), Some(ref mut expected)) = (result.as_mut(), expected.as_mut()) {
|
||||
result.drop_all_caches().unwrap();
|
||||
expected.drop_all_caches().unwrap();
|
||||
|
||||
result.apply_pending_mutations().unwrap();
|
||||
expected.apply_pending_mutations().unwrap();
|
||||
}
|
||||
|
||||
compare_result_detailed(result, expected)
|
||||
|
||||
@@ -51,7 +51,7 @@ impl<E: EthSpec> LoadCase for MerkleProofValidity<E> {
|
||||
impl<E: EthSpec> Case for MerkleProofValidity<E> {
|
||||
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
|
||||
let mut state = self.state.clone();
|
||||
state.initialize_tree_hash_cache();
|
||||
state.update_tree_hash_cache().unwrap();
|
||||
let Ok(proof) = state.compute_merkle_proof(self.merkle_proof.leaf_index) else {
|
||||
return Err(Error::FailedToParseTest(
|
||||
"Could not retrieve merkle proof".to_string(),
|
||||
@@ -77,9 +77,6 @@ impl<E: EthSpec> Case for MerkleProofValidity<E> {
|
||||
}
|
||||
}
|
||||
|
||||
// Tree hash cache should still be initialized (not dropped).
|
||||
assert!(state.tree_hash_cache().is_initialized());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::decode::{ssz_decode_file_with, ssz_decode_state, yaml_decode_file};
|
||||
use serde::Deserialize;
|
||||
use state_processing::{
|
||||
per_block_processing, per_slot_processing, BlockProcessingError, BlockSignatureStrategy,
|
||||
ConsensusContext, StateProcessingStrategy, VerifyBlockRoot,
|
||||
ConsensusContext, VerifyBlockRoot,
|
||||
};
|
||||
use types::{BeaconState, RelativeEpoch, SignedBeaconBlock};
|
||||
|
||||
@@ -96,7 +96,6 @@ impl<E: EthSpec> Case for SanityBlocks<E> {
|
||||
&mut indiv_state,
|
||||
signed_block,
|
||||
BlockSignatureStrategy::VerifyIndividual,
|
||||
StateProcessingStrategy::Accurate,
|
||||
VerifyBlockRoot::True,
|
||||
&mut ctxt,
|
||||
spec,
|
||||
@@ -107,7 +106,6 @@ impl<E: EthSpec> Case for SanityBlocks<E> {
|
||||
&mut bulk_state,
|
||||
signed_block,
|
||||
BlockSignatureStrategy::VerifyBulk,
|
||||
StateProcessingStrategy::Accurate,
|
||||
VerifyBlockRoot::True,
|
||||
&mut ctxt,
|
||||
spec,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use super::*;
|
||||
use crate::cases::common::{TestU128, TestU256};
|
||||
use crate::decode::{snappy_decode_file, yaml_decode_file};
|
||||
use serde::Deserialize;
|
||||
use serde::{de::Error as SerdeError, Deserializer};
|
||||
use crate::cases::common::{SszStaticType, TestU128, TestU256};
|
||||
use crate::cases::ssz_static::{check_serialization, check_tree_hash};
|
||||
use crate::decode::{log_file_access, snappy_decode_file, yaml_decode_file};
|
||||
use serde::{de::Error as SerdeError, Deserialize, Deserializer};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use tree_hash_derive::TreeHash;
|
||||
use types::typenum::*;
|
||||
use types::{BitList, BitVector, FixedVector, VariableList};
|
||||
use types::{BitList, BitVector, FixedVector, ForkName, VariableList, Vector};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
struct Metadata {
|
||||
@@ -125,6 +125,20 @@ impl Case for SszGeneric {
|
||||
let elem_ty = parts[1];
|
||||
let length = parts[2];
|
||||
|
||||
// Skip length 0 tests. Milhouse doesn't have any checks against 0-capacity lists.
|
||||
if length == "0" {
|
||||
log_file_access(self.path.join("serialized.ssz_snappy"));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
type_dispatch!(
|
||||
ssz_generic_test,
|
||||
(&self.path),
|
||||
Vector,
|
||||
<>,
|
||||
[elem_ty => primitive_type]
|
||||
[length => typenum]
|
||||
)?;
|
||||
type_dispatch!(
|
||||
ssz_generic_test,
|
||||
(&self.path),
|
||||
@@ -263,8 +277,8 @@ struct ComplexTestStruct {
|
||||
#[serde(deserialize_with = "byte_list_from_hex_str")]
|
||||
D: VariableList<u8, U256>,
|
||||
E: VarTestStruct,
|
||||
F: FixedVector<FixedTestStruct, U4>,
|
||||
G: FixedVector<VarTestStruct, U2>,
|
||||
F: Vector<FixedTestStruct, U4>,
|
||||
G: Vector<VarTestStruct, U2>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)]
|
||||
|
||||
@@ -118,7 +118,6 @@ impl<E: EthSpec> Case for SszStaticTHC<BeaconState<E>> {
|
||||
check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_bytes())?;
|
||||
|
||||
let mut state = self.value.clone();
|
||||
state.initialize_tree_hash_cache();
|
||||
let cached_tree_hash_root = state.update_tree_hash_cache().unwrap();
|
||||
check_tree_hash(&self.roots.root, cached_tree_hash_root.as_bytes())?;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::decode::{ssz_decode_file_with, ssz_decode_state, yaml_decode_file};
|
||||
use serde::Deserialize;
|
||||
use state_processing::{
|
||||
per_block_processing, state_advance::complete_state_advance, BlockSignatureStrategy,
|
||||
ConsensusContext, StateProcessingStrategy, VerifyBlockRoot,
|
||||
ConsensusContext, VerifyBlockRoot,
|
||||
};
|
||||
use std::str::FromStr;
|
||||
use types::{BeaconState, Epoch, SignedBeaconBlock};
|
||||
@@ -114,7 +114,6 @@ impl<E: EthSpec> Case for TransitionTest<E> {
|
||||
&mut state,
|
||||
block,
|
||||
BlockSignatureStrategy::VerifyBulk,
|
||||
StateProcessingStrategy::Accurate,
|
||||
VerifyBlockRoot::True,
|
||||
&mut ctxt,
|
||||
spec,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::*;
|
||||
use state_processing::{
|
||||
per_block_processing, per_block_processing::errors::ExitInvalid, BlockProcessingError,
|
||||
BlockSignatureStrategy, ConsensusContext, StateProcessingStrategy, VerifyBlockRoot,
|
||||
BlockSignatureStrategy, ConsensusContext, VerifyBlockRoot,
|
||||
};
|
||||
use types::{BeaconBlock, Epoch};
|
||||
|
||||
@@ -68,7 +68,6 @@ impl ExitTest {
|
||||
state,
|
||||
block,
|
||||
BlockSignatureStrategy::VerifyIndividual,
|
||||
StateProcessingStrategy::Accurate,
|
||||
VerifyBlockRoot::True,
|
||||
&mut ctxt,
|
||||
&E::default_spec(),
|
||||
@@ -332,7 +331,7 @@ mod custom_tests {
|
||||
fn assert_exited(state: &BeaconState<E>, validator_index: usize) {
|
||||
let spec = E::default_spec();
|
||||
|
||||
let validator = &state.validators()[validator_index];
|
||||
let validator = &state.validators().get(validator_index).unwrap();
|
||||
assert_eq!(
|
||||
validator.exit_epoch,
|
||||
// This is correct until we exceed the churn limit. If that happens, we
|
||||
|
||||
Reference in New Issue
Block a user