Merge remote-tracking branch 'origin/master' into spec-v0.12

This commit is contained in:
Michael Sproul
2020-06-26 12:08:46 +10:00
34 changed files with 196 additions and 227 deletions

View File

@@ -1229,14 +1229,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
}
}
while !filtered_chain_segment.is_empty() {
while let Some((_root, block)) = filtered_chain_segment.first() {
// Determine the epoch of the first block in the remaining segment.
let start_epoch = filtered_chain_segment
.first()
.map(|(_root, block)| block)
.expect("chain_segment cannot be empty")
.slot()
.epoch(T::EthSpec::slots_per_epoch());
let start_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch());
// The `last_index` indicates the position of the last block that is in the current
// epoch of `start_epoch`.

View File

@@ -197,7 +197,7 @@ impl<T: Item, E: EthSpec> AutoPruningContainer<T, E> {
.map(|(_epoch, item)| item.len())
.fold((0, 0), |(count, sum), len| (count + 1, sum + len));
let initial_capacity = sum.checked_div(count).unwrap_or(T::default_capacity());
let initial_capacity = sum.checked_div(count).unwrap_or_else(T::default_capacity);
let mut item = T::with_capacity(initial_capacity);
item.insert(validator_index);

View File

@@ -504,7 +504,7 @@ where
};
let sk = &self.keypairs[proposer_index].sk;
let fork = &state.fork.clone();
let fork = &state.fork;
let randao_reveal = {
let epoch = slot.epoch(E::slots_per_epoch());
@@ -676,7 +676,7 @@ where
selection_proof.is_aggregator(bc.committee.len(), spec).unwrap_or(false)
})
.copied()
.expect(&format!(
.unwrap_or_else(|| panic!(
"Committee {} at slot {} with {} attesting validators does not have any aggregators",
bc.index, state.slot, bc.committee.len()
));