mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Rust 1.84 lints (#6781)
* Fix few lints * Fix remaining lints * Use fully qualified syntax
This commit is contained in:
@@ -53,7 +53,7 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
|
||||
// https://github.com/ethereum/eth2.0-specs/pull/2323
|
||||
if spec
|
||||
.altair_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
.is_some_and(|fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
{
|
||||
upgrade_to_altair(&mut state, spec)?;
|
||||
|
||||
@@ -63,7 +63,7 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
|
||||
// Similarly, perform an upgrade to the merge if configured from genesis.
|
||||
if spec
|
||||
.bellatrix_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
.is_some_and(|fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
{
|
||||
// this will set state.latest_execution_payload_header = ExecutionPayloadHeaderBellatrix::default()
|
||||
upgrade_to_bellatrix(&mut state, spec)?;
|
||||
@@ -81,7 +81,7 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
|
||||
// Upgrade to capella if configured from genesis
|
||||
if spec
|
||||
.capella_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
.is_some_and(|fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
{
|
||||
upgrade_to_capella(&mut state, spec)?;
|
||||
|
||||
@@ -98,7 +98,7 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
|
||||
// Upgrade to deneb if configured from genesis
|
||||
if spec
|
||||
.deneb_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
.is_some_and(|fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
{
|
||||
upgrade_to_deneb(&mut state, spec)?;
|
||||
|
||||
@@ -115,7 +115,7 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
|
||||
// Upgrade to electra if configured from genesis.
|
||||
if spec
|
||||
.electra_fork_epoch
|
||||
.map_or(false, |fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
.is_some_and(|fork_epoch| fork_epoch == E::genesis_epoch())
|
||||
{
|
||||
let post = upgrade_state_to_electra(&mut state, Epoch::new(0), Epoch::new(0), spec)?;
|
||||
state = post;
|
||||
@@ -153,7 +153,7 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
|
||||
pub fn is_valid_genesis_state<E: EthSpec>(state: &BeaconState<E>, spec: &ChainSpec) -> bool {
|
||||
state
|
||||
.get_active_validator_indices(E::genesis_epoch(), spec)
|
||||
.map_or(false, |active_validators| {
|
||||
.is_ok_and(|active_validators| {
|
||||
state.genesis_time() >= spec.min_genesis_time
|
||||
&& active_validators.len() as u64 >= spec.min_genesis_active_validator_count
|
||||
})
|
||||
|
||||
@@ -38,7 +38,7 @@ pub fn process_sync_aggregate<E: EthSpec>(
|
||||
)?;
|
||||
|
||||
// If signature set is `None` then the signature is valid (infinity).
|
||||
if signature_set.map_or(false, |signature| !signature.verify()) {
|
||||
if signature_set.is_some_and(|signature| !signature.verify()) {
|
||||
return Err(SyncAggregateInvalid::SignatureInvalid.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ impl<E: EthSpec> EpochProcessingSummary<E> {
|
||||
match self {
|
||||
EpochProcessingSummary::Base { statuses, .. } => statuses
|
||||
.get(val_index)
|
||||
.map_or(false, |s| s.is_active_in_current_epoch && !s.is_slashed),
|
||||
.is_some_and(|s| s.is_active_in_current_epoch && !s.is_slashed),
|
||||
EpochProcessingSummary::Altair { participation, .. } => {
|
||||
participation.is_active_and_unslashed(val_index, participation.current_epoch)
|
||||
}
|
||||
@@ -176,7 +176,7 @@ impl<E: EthSpec> EpochProcessingSummary<E> {
|
||||
match self {
|
||||
EpochProcessingSummary::Base { statuses, .. } => Ok(statuses
|
||||
.get(val_index)
|
||||
.map_or(false, |s| s.is_current_epoch_target_attester)),
|
||||
.is_some_and(|s| s.is_current_epoch_target_attester)),
|
||||
EpochProcessingSummary::Altair { participation, .. } => participation
|
||||
.is_current_epoch_unslashed_participating_index(
|
||||
val_index,
|
||||
@@ -247,7 +247,7 @@ impl<E: EthSpec> EpochProcessingSummary<E> {
|
||||
match self {
|
||||
EpochProcessingSummary::Base { statuses, .. } => statuses
|
||||
.get(val_index)
|
||||
.map_or(false, |s| s.is_active_in_previous_epoch && !s.is_slashed),
|
||||
.is_some_and(|s| s.is_active_in_previous_epoch && !s.is_slashed),
|
||||
EpochProcessingSummary::Altair { participation, .. } => {
|
||||
participation.is_active_and_unslashed(val_index, participation.previous_epoch)
|
||||
}
|
||||
@@ -267,7 +267,7 @@ impl<E: EthSpec> EpochProcessingSummary<E> {
|
||||
match self {
|
||||
EpochProcessingSummary::Base { statuses, .. } => Ok(statuses
|
||||
.get(val_index)
|
||||
.map_or(false, |s| s.is_previous_epoch_target_attester)),
|
||||
.is_some_and(|s| s.is_previous_epoch_target_attester)),
|
||||
EpochProcessingSummary::Altair { participation, .. } => participation
|
||||
.is_previous_epoch_unslashed_participating_index(
|
||||
val_index,
|
||||
@@ -294,7 +294,7 @@ impl<E: EthSpec> EpochProcessingSummary<E> {
|
||||
match self {
|
||||
EpochProcessingSummary::Base { statuses, .. } => Ok(statuses
|
||||
.get(val_index)
|
||||
.map_or(false, |s| s.is_previous_epoch_head_attester)),
|
||||
.is_some_and(|s| s.is_previous_epoch_head_attester)),
|
||||
EpochProcessingSummary::Altair { participation, .. } => participation
|
||||
.is_previous_epoch_unslashed_participating_index(val_index, TIMELY_HEAD_FLAG_INDEX),
|
||||
}
|
||||
@@ -318,7 +318,7 @@ impl<E: EthSpec> EpochProcessingSummary<E> {
|
||||
match self {
|
||||
EpochProcessingSummary::Base { statuses, .. } => Ok(statuses
|
||||
.get(val_index)
|
||||
.map_or(false, |s| s.is_previous_epoch_attester)),
|
||||
.is_some_and(|s| s.is_previous_epoch_attester)),
|
||||
EpochProcessingSummary::Altair { participation, .. } => participation
|
||||
.is_previous_epoch_unslashed_participating_index(
|
||||
val_index,
|
||||
|
||||
Reference in New Issue
Block a user