mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Fix various compile errors and warnings
This commit is contained in:
@@ -106,7 +106,7 @@ fn get_builder(spec: &ChainSpec) -> (BlockProcessingBuilder<MainnetEthSpec>) {
|
||||
// Set the state and block to be in the last slot of the 4th epoch.
|
||||
let last_slot_of_epoch =
|
||||
(MainnetEthSpec::genesis_epoch() + 4).end_slot(MainnetEthSpec::slots_per_epoch());
|
||||
builder.set_slot(last_slot_of_epoch, &spec);
|
||||
builder.set_slot(last_slot_of_epoch);
|
||||
builder.build_caches(&spec);
|
||||
|
||||
(builder)
|
||||
|
||||
@@ -42,7 +42,7 @@ pub fn per_epoch_processing<T: EthSpec>(
|
||||
validator_statuses.process_attestations(&state, spec)?;
|
||||
|
||||
// Justification and finalization.
|
||||
process_justification_and_finalization(state, &validator_statuses.total_balances, spec)?;
|
||||
process_justification_and_finalization(state, &validator_statuses.total_balances)?;
|
||||
|
||||
// Crosslinks.
|
||||
let winning_root_for_shards = process_crosslinks(state, spec)?;
|
||||
@@ -84,7 +84,6 @@ pub fn per_epoch_processing<T: EthSpec>(
|
||||
pub fn process_justification_and_finalization<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
total_balances: &TotalBalances,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
if state.current_epoch() == T::genesis_epoch() {
|
||||
return Ok(());
|
||||
@@ -104,14 +103,14 @@ pub fn process_justification_and_finalization<T: EthSpec>(
|
||||
if total_balances.previous_epoch_target_attesters * 3 >= total_balances.previous_epoch * 2 {
|
||||
state.current_justified_epoch = previous_epoch;
|
||||
state.current_justified_root =
|
||||
*state.get_block_root_at_epoch(state.current_justified_epoch, spec)?;
|
||||
*state.get_block_root_at_epoch(state.current_justified_epoch)?;
|
||||
state.justification_bitfield |= 2;
|
||||
}
|
||||
// If the current epoch gets justified, fill the last bit.
|
||||
if total_balances.current_epoch_target_attesters * 3 >= total_balances.current_epoch * 2 {
|
||||
state.current_justified_epoch = current_epoch;
|
||||
state.current_justified_root =
|
||||
*state.get_block_root_at_epoch(state.current_justified_epoch, spec)?;
|
||||
*state.get_block_root_at_epoch(state.current_justified_epoch)?;
|
||||
state.justification_bitfield |= 1;
|
||||
}
|
||||
|
||||
@@ -120,22 +119,22 @@ pub fn process_justification_and_finalization<T: EthSpec>(
|
||||
// The 2nd/3rd/4th most recent epochs are all justified, the 2nd using the 4th as source.
|
||||
if (bitfield >> 1) % 8 == 0b111 && old_previous_justified_epoch == current_epoch - 3 {
|
||||
state.finalized_epoch = old_previous_justified_epoch;
|
||||
state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch, spec)?;
|
||||
state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch)?;
|
||||
}
|
||||
// The 2nd/3rd most recent epochs are both justified, the 2nd using the 3rd as source.
|
||||
if (bitfield >> 1) % 4 == 0b11 && state.previous_justified_epoch == current_epoch - 2 {
|
||||
state.finalized_epoch = old_previous_justified_epoch;
|
||||
state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch, spec)?;
|
||||
state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch)?;
|
||||
}
|
||||
// The 1st/2nd/3rd most recent epochs are all justified, the 1st using the 2nd as source.
|
||||
if bitfield % 8 == 0b111 && state.current_justified_epoch == current_epoch - 2 {
|
||||
state.finalized_epoch = old_current_justified_epoch;
|
||||
state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch, spec)?;
|
||||
state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch)?;
|
||||
}
|
||||
// The 1st/2nd most recent epochs are both justified, the 1st using the 2nd as source.
|
||||
if bitfield % 4 == 0b11 && state.current_justified_epoch == current_epoch - 1 {
|
||||
state.finalized_epoch = old_current_justified_epoch;
|
||||
state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch, spec)?;
|
||||
state.finalized_root = *state.get_block_root_at_epoch(state.finalized_epoch)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -15,7 +15,7 @@ fn runs_without_error() {
|
||||
|
||||
let target_slot =
|
||||
(MinimalEthSpec::genesis_epoch() + 4).end_slot(MinimalEthSpec::slots_per_epoch());
|
||||
builder.teleport_to_slot(target_slot, &spec);
|
||||
builder.teleport_to_slot(target_slot);
|
||||
|
||||
let (mut state, _keypairs) = builder.build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user