mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 19:32:55 +00:00
Implement committee cache diffs
This commit is contained in:
@@ -1158,8 +1158,7 @@ impl<'a, T: BeaconChainTypes> FullyVerifiedBlock<'a, T> {
|
||||
|
||||
let committee_timer = metrics::start_timer(&metrics::BLOCK_PROCESSING_COMMITTEE);
|
||||
|
||||
state.build_committee_cache(RelativeEpoch::Previous, &chain.spec)?;
|
||||
state.build_committee_cache(RelativeEpoch::Current, &chain.spec)?;
|
||||
state.build_all_committee_caches(&chain.spec)?;
|
||||
|
||||
metrics::stop_timer(committee_timer);
|
||||
|
||||
|
||||
@@ -1066,14 +1066,15 @@ mod test {
|
||||
}
|
||||
|
||||
for v in state.validators() {
|
||||
let creds = v.withdrawal_credentials.as_bytes();
|
||||
let creds = v.withdrawal_credentials();
|
||||
let creds = creds.as_bytes();
|
||||
assert_eq!(
|
||||
creds[0], spec.bls_withdrawal_prefix_byte,
|
||||
"first byte of withdrawal creds should be bls prefix"
|
||||
);
|
||||
assert_eq!(
|
||||
&creds[1..],
|
||||
&hash(&v.pubkey.as_ssz_bytes())[1..],
|
||||
&hash(&v.pubkey().as_ssz_bytes())[1..],
|
||||
"rest of withdrawal creds should be pubkey hash"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ pub fn upgrade_to_v10<T: BeaconChainTypes>(
|
||||
"Converting full state to diff";
|
||||
"prev_state_root" => ?state_root,
|
||||
"state_root" => ?current_state_root,
|
||||
"slot" => slot,
|
||||
"slot" => current_state.slot(),
|
||||
);
|
||||
|
||||
let diff = BeaconStateDiff::compute_diff(&backtrack_state, ¤t_state)?;
|
||||
|
||||
@@ -791,6 +791,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
|
||||
let mut state = self.replay_blocks(prev_state, blocks, slot, state_root_iter)?;
|
||||
state.update_tree_hash_cache()?;
|
||||
state.build_all_caches(&self.spec)?;
|
||||
|
||||
Ok(Some((state, latest_block_root)))
|
||||
} else {
|
||||
@@ -825,6 +826,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
|
||||
// Do a tree hash here so that the cache is fully built.
|
||||
state.update_tree_hash_cache()?;
|
||||
state.build_all_caches(&self.spec)?;
|
||||
|
||||
let latest_block_root = state.get_latest_block_root(*state_root);
|
||||
Ok((state, latest_block_root))
|
||||
@@ -843,6 +845,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
|
||||
// Do a tree hash here so that the cache is fully built.
|
||||
state.update_tree_hash_cache()?;
|
||||
state.build_all_caches(&self.spec)?;
|
||||
|
||||
let latest_block_root = state.get_latest_block_root(state_root);
|
||||
Ok((state, latest_block_root))
|
||||
|
||||
Reference in New Issue
Block a user