mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Consensus context with proposer index caching (#3604)
## Issue Addressed Closes https://github.com/sigp/lighthouse/issues/2371 ## Proposed Changes Backport some changes from `tree-states` that remove duplicated calculations of the `proposer_index`. With this change the proposer index should be calculated only once for each block, and then plumbed through to every place it is required. ## Additional Info In future I hope to add more data to the consensus context that is cached on a per-epoch basis, like the effective balances of validators and the base rewards. There are some other changes to remove indexing in tests that were also useful for `tree-states` (the `tree-states` types don't implement `Index`).
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::decode::{ssz_decode_file_with, ssz_decode_state, yaml_decode_file};
|
||||
use serde_derive::Deserialize;
|
||||
use state_processing::{
|
||||
per_block_processing, per_slot_processing, BlockProcessingError, BlockSignatureStrategy,
|
||||
VerifyBlockRoot,
|
||||
ConsensusContext, VerifyBlockRoot,
|
||||
};
|
||||
use types::{BeaconState, EthSpec, ForkName, RelativeEpoch, SignedBeaconBlock};
|
||||
|
||||
@@ -91,26 +91,28 @@ impl<E: EthSpec> Case for SanityBlocks<E> {
|
||||
.build_committee_cache(RelativeEpoch::Current, spec)
|
||||
.unwrap();
|
||||
|
||||
let mut ctxt = ConsensusContext::new(indiv_state.slot());
|
||||
per_block_processing(
|
||||
&mut indiv_state,
|
||||
signed_block,
|
||||
None,
|
||||
BlockSignatureStrategy::VerifyIndividual,
|
||||
VerifyBlockRoot::True,
|
||||
&mut ctxt,
|
||||
spec,
|
||||
)?;
|
||||
|
||||
let mut ctxt = ConsensusContext::new(indiv_state.slot());
|
||||
per_block_processing(
|
||||
&mut bulk_state,
|
||||
signed_block,
|
||||
None,
|
||||
BlockSignatureStrategy::VerifyBulk,
|
||||
VerifyBlockRoot::True,
|
||||
&mut ctxt,
|
||||
spec,
|
||||
)?;
|
||||
|
||||
if block.state_root() == bulk_state.canonical_root()
|
||||
&& block.state_root() == indiv_state.canonical_root()
|
||||
if block.state_root() == bulk_state.update_tree_hash_cache().unwrap()
|
||||
&& block.state_root() == indiv_state.update_tree_hash_cache().unwrap()
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user