Several changes

* Fix state cache pruning of finalized state from block map
* Update to latest `milhouse`
* Check beacon state diffs in EF tests
This commit is contained in:
Michael Sproul
2022-03-01 15:49:40 +11:00
parent 143cf59504
commit 98629ce741
17 changed files with 115 additions and 50 deletions

View File

@@ -26,7 +26,7 @@ pub fn initialize_beacon_state_from_eth1<T: EthSpec>(
let mut state = BeaconState::new(genesis_time, eth1_data, spec);
// Seed RANDAO with Eth1 entropy
state.fill_randao_mixes_with(eth1_block_hash);
state.fill_randao_mixes_with(eth1_block_hash)?;
let mut deposit_tree = DepositDataTree::create(&[], 0, DEPOSIT_TREE_DEPTH);

View File

@@ -13,7 +13,7 @@ pub fn process_eth1_data_reset<T: EthSpec>(
.safe_rem(T::SlotsPerEth1VotingPeriod::to_u64())?
== 0
{
*state.eth1_data_votes_mut() = VList::empty()?;
*state.eth1_data_votes_mut() = VList::empty();
}
Ok(())
}

View File

@@ -363,8 +363,8 @@ impl<T: EthSpec> BeaconState<T> {
// History
latest_block_header: BeaconBlock::<T>::empty(spec).temporary_block_header(),
block_roots: FixedVector::from_elem(Hash256::zero()),
state_roots: FixedVector::from_elem(Hash256::zero()),
block_roots: FixedVector::default(),
state_roots: FixedVector::default(),
historical_roots: VList::default(),
// Eth1
@@ -377,10 +377,10 @@ impl<T: EthSpec> BeaconState<T> {
balances: VList::default(), // Set later.
// Randomness
randao_mixes: FixedVector::from_elem(Hash256::zero()),
randao_mixes: FixedVector::default(),
// Slashings
slashings: FixedVector::from_elem(0),
slashings: FixedVector::default(),
// Attestations
previous_epoch_attestations: VList::default(),
@@ -970,8 +970,9 @@ impl<T: EthSpec> BeaconState<T> {
}
/// Fill `randao_mixes` with
pub fn fill_randao_mixes_with(&mut self, index_root: Hash256) {
*self.randao_mixes_mut() = FixedVector::from_elem(index_root);
pub fn fill_randao_mixes_with(&mut self, index_root: Hash256) -> Result<(), Error> {
*self.randao_mixes_mut() = FixedVector::from_elem(index_root)?;
Ok(())
}
/// Safely obtains the index for `randao_mixes`