From 8e3c5d1524133eaf1a4c243533a37ed38040f5c7 Mon Sep 17 00:00:00 2001 From: chonghe <44791194+chong-he@users.noreply.github.com> Date: Wed, 25 Jun 2025 13:33:17 +0800 Subject: [PATCH] Rust 1.89 compiler lint fix (#7644) Fix lints for Rust 1.89 beta compiler --- .../src/attestation_verification.rs | 6 +++--- beacon_node/beacon_chain/src/beacon_chain.rs | 2 +- .../beacon_chain/src/block_verification.rs | 2 +- .../src/block_verification_types.rs | 10 +++++----- beacon_node/beacon_chain/src/canonical_head.rs | 12 ++++++------ beacon_node/beacon_chain/src/kzg_utils.rs | 2 +- beacon_node/execution_layer/src/engine_api.rs | 2 +- .../network_beacon_processor/gossip_methods.rs | 4 ++-- .../operation_pool/src/attestation_storage.rs | 4 ++-- beacon_node/store/src/database/interface.rs | 10 +++++++--- beacon_node/store/src/database/leveldb_impl.rs | 14 +++++++++----- beacon_node/store/src/hot_cold_store.rs | 4 ++-- beacon_node/store/src/lib.rs | 8 ++++---- beacon_node/store/src/memory_store.rs | 6 +++--- .../proto_array/src/proto_array_fork_choice.rs | 2 +- .../state_processing/src/consensus_context.rs | 4 ++-- .../src/per_block_processing/signature_sets.rs | 2 +- consensus/types/src/attestation.rs | 2 +- consensus/types/src/attester_slashing.rs | 4 ++-- consensus/types/src/beacon_state.rs | 17 +++++++++++------ .../types/src/beacon_state/committee_cache.rs | 9 ++++++--- consensus/types/src/slot_epoch.rs | 2 +- consensus/types/src/sqlite.rs | 2 +- slasher/src/array.rs | 6 +++--- slasher/src/database.rs | 2 +- slasher/src/database/interface.rs | 10 +++++----- slasher/src/database/lmdb_impl.rs | 6 +++--- .../initialized_validators/src/lib.rs | 2 +- 28 files changed, 86 insertions(+), 70 deletions(-) diff --git a/beacon_node/beacon_chain/src/attestation_verification.rs b/beacon_node/beacon_chain/src/attestation_verification.rs index 2f7c0be229..f057c0619d 100644 --- a/beacon_node/beacon_chain/src/attestation_verification.rs +++ b/beacon_node/beacon_chain/src/attestation_verification.rs @@ -353,7 +353,7 @@ impl Clone for IndexedUnaggregatedAttestation<'_, T> { /// A helper trait implemented on wrapper types that can be progressed to a state where they can be /// verified for application to fork choice. pub trait VerifiedAttestation: Sized { - fn attestation(&self) -> AttestationRef; + fn attestation(&self) -> AttestationRef<'_, T::EthSpec>; fn indexed_attestation(&self) -> &IndexedAttestation; @@ -366,7 +366,7 @@ pub trait VerifiedAttestation: Sized { } impl VerifiedAttestation for VerifiedAggregatedAttestation<'_, T> { - fn attestation(&self) -> AttestationRef { + fn attestation(&self) -> AttestationRef<'_, T::EthSpec> { self.attestation() } @@ -376,7 +376,7 @@ impl VerifiedAttestation for VerifiedAggregatedAttestati } impl VerifiedAttestation for VerifiedUnaggregatedAttestation<'_, T> { - fn attestation(&self) -> AttestationRef { + fn attestation(&self) -> AttestationRef<'_, T::EthSpec> { self.attestation.to_ref() } diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index e6cdd84b40..de377dab97 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -7080,7 +7080,7 @@ impl BeaconChain { &self, block_root: Hash256, block_data: AvailableBlockData, - ) -> Result>, String> { + ) -> Result>, String> { match block_data { AvailableBlockData::NoData => Ok(None), AvailableBlockData::Blobs(blobs) => { diff --git a/beacon_node/beacon_chain/src/block_verification.rs b/beacon_node/beacon_chain/src/block_verification.rs index 317ec02cc1..d42855794b 100644 --- a/beacon_node/beacon_chain/src/block_verification.rs +++ b/beacon_node/beacon_chain/src/block_verification.rs @@ -2042,7 +2042,7 @@ pub fn cheap_state_advance_to_obtain_committees<'a, E: EthSpec, Err: BlockBlobEr /// Obtains a read-locked `ValidatorPubkeyCache` from the `chain`. pub fn get_validator_pubkey_cache( chain: &BeaconChain, -) -> Result>, BeaconChainError> { +) -> Result>, BeaconChainError> { Ok(chain.validator_pubkey_cache.read()) } diff --git a/beacon_node/beacon_chain/src/block_verification_types.rs b/beacon_node/beacon_chain/src/block_verification_types.rs index 681e90aebc..5917e6f6be 100644 --- a/beacon_node/beacon_chain/src/block_verification_types.rs +++ b/beacon_node/beacon_chain/src/block_verification_types.rs @@ -365,7 +365,7 @@ pub trait AsBlock { fn parent_root(&self) -> Hash256; fn state_root(&self) -> Hash256; fn signed_block_header(&self) -> SignedBeaconBlockHeader; - fn message(&self) -> BeaconBlockRef; + fn message(&self) -> BeaconBlockRef<'_, E>; fn as_block(&self) -> &SignedBeaconBlock; fn block_cloned(&self) -> Arc>; fn canonical_root(&self) -> Hash256; @@ -392,7 +392,7 @@ impl AsBlock for Arc> { SignedBeaconBlock::signed_block_header(self) } - fn message(&self) -> BeaconBlockRef { + fn message(&self) -> BeaconBlockRef<'_, E> { SignedBeaconBlock::message(self) } @@ -425,7 +425,7 @@ impl AsBlock for MaybeAvailableBlock { fn signed_block_header(&self) -> SignedBeaconBlockHeader { self.as_block().signed_block_header() } - fn message(&self) -> BeaconBlockRef { + fn message(&self) -> BeaconBlockRef<'_, E> { self.as_block().message() } fn as_block(&self) -> &SignedBeaconBlock { @@ -466,7 +466,7 @@ impl AsBlock for AvailableBlock { self.block().signed_block_header() } - fn message(&self) -> BeaconBlockRef { + fn message(&self) -> BeaconBlockRef<'_, E> { self.block().message() } @@ -499,7 +499,7 @@ impl AsBlock for RpcBlock { fn signed_block_header(&self) -> SignedBeaconBlockHeader { self.as_block().signed_block_header() } - fn message(&self) -> BeaconBlockRef { + fn message(&self) -> BeaconBlockRef<'_, E> { self.as_block().message() } fn as_block(&self) -> &SignedBeaconBlock { diff --git a/beacon_node/beacon_chain/src/canonical_head.rs b/beacon_node/beacon_chain/src/canonical_head.rs index a6f5179fdc..f96b59aec4 100644 --- a/beacon_node/beacon_chain/src/canonical_head.rs +++ b/beacon_node/beacon_chain/src/canonical_head.rs @@ -73,11 +73,11 @@ impl CanonicalHeadRwLock { Self::from(RwLock::new(item)) } - fn read(&self) -> RwLockReadGuard { + fn read(&self) -> RwLockReadGuard<'_, T> { self.0.read() } - fn write(&self) -> RwLockWriteGuard { + fn write(&self) -> RwLockWriteGuard<'_, T> { self.0.write() } } @@ -369,7 +369,7 @@ impl CanonicalHead { /// /// This function is **not safe** to be public. See the module-level documentation for more /// information about protecting from deadlocks. - fn cached_head_read_lock(&self) -> RwLockReadGuard> { + fn cached_head_read_lock(&self) -> RwLockReadGuard<'_, CachedHead> { self.cached_head.read() } @@ -377,18 +377,18 @@ impl CanonicalHead { /// /// This function is **not safe** to be public. See the module-level documentation for more /// information about protecting from deadlocks. - fn cached_head_write_lock(&self) -> RwLockWriteGuard> { + fn cached_head_write_lock(&self) -> RwLockWriteGuard<'_, CachedHead> { self.cached_head.write() } /// Access a read-lock for fork choice. - pub fn fork_choice_read_lock(&self) -> RwLockReadGuard> { + pub fn fork_choice_read_lock(&self) -> RwLockReadGuard<'_, BeaconForkChoice> { let _timer = metrics::start_timer(&metrics::FORK_CHOICE_READ_LOCK_AQUIRE_TIMES); self.fork_choice.read() } /// Access a write-lock for fork choice. - pub fn fork_choice_write_lock(&self) -> RwLockWriteGuard> { + pub fn fork_choice_write_lock(&self) -> RwLockWriteGuard<'_, BeaconForkChoice> { let _timer = metrics::start_timer(&metrics::FORK_CHOICE_WRITE_LOCK_AQUIRE_TIMES); self.fork_choice.write() } diff --git a/beacon_node/beacon_chain/src/kzg_utils.rs b/beacon_node/beacon_chain/src/kzg_utils.rs index d2354d5f11..4ac00a6e9b 100644 --- a/beacon_node/beacon_chain/src/kzg_utils.rs +++ b/beacon_node/beacon_chain/src/kzg_utils.rs @@ -25,7 +25,7 @@ fn ssz_blob_to_crypto_blob_boxed(blob: &Blob) -> Result(cell: &Cell) -> Result { +fn ssz_cell_to_crypto_cell(cell: &Cell) -> Result, KzgError> { let cell_bytes: &[u8] = cell.as_ref(); Ok(cell_bytes .try_into() diff --git a/beacon_node/execution_layer/src/engine_api.rs b/beacon_node/execution_layer/src/engine_api.rs index 4bfee223ff..3c82e6251b 100644 --- a/beacon_node/execution_layer/src/engine_api.rs +++ b/beacon_node/execution_layer/src/engine_api.rs @@ -380,7 +380,7 @@ pub enum GetPayloadResponseType { } impl GetPayloadResponse { - pub fn execution_payload_ref(&self) -> ExecutionPayloadRef { + pub fn execution_payload_ref(&self) -> ExecutionPayloadRef<'_, E> { self.to_ref().into() } } diff --git a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs index fcab34c93e..ea9a5db1af 100644 --- a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs @@ -67,7 +67,7 @@ struct VerifiedUnaggregate { /// This implementation allows `Self` to be imported to fork choice and other functions on the /// `BeaconChain`. impl VerifiedAttestation for VerifiedUnaggregate { - fn attestation(&self) -> AttestationRef { + fn attestation(&self) -> AttestationRef<'_, T::EthSpec> { self.attestation.to_ref() } @@ -100,7 +100,7 @@ struct VerifiedAggregate { /// This implementation allows `Self` to be imported to fork choice and other functions on the /// `BeaconChain`. impl VerifiedAttestation for VerifiedAggregate { - fn attestation(&self) -> AttestationRef { + fn attestation(&self) -> AttestationRef<'_, T::EthSpec> { self.signed_aggregate.message().aggregate() } diff --git a/beacon_node/operation_pool/src/attestation_storage.rs b/beacon_node/operation_pool/src/attestation_storage.rs index 67c24b9c7a..13ef94c18d 100644 --- a/beacon_node/operation_pool/src/attestation_storage.rs +++ b/beacon_node/operation_pool/src/attestation_storage.rs @@ -96,7 +96,7 @@ impl SplitAttestation { } } - pub fn as_ref(&self) -> CompactAttestationRef { + pub fn as_ref(&self) -> CompactAttestationRef<'_, E> { CompactAttestationRef { checkpoint: &self.checkpoint, data: &self.data, @@ -438,7 +438,7 @@ impl AttestationMap { } /// Iterate all attestations in the map. - pub fn iter(&self) -> impl Iterator> { + pub fn iter(&self) -> impl Iterator> { self.checkpoint_map .iter() .flat_map(|(checkpoint_key, attestation_map)| attestation_map.iter(checkpoint_key)) diff --git a/beacon_node/store/src/database/interface.rs b/beacon_node/store/src/database/interface.rs index bccf799617..e405c6227d 100644 --- a/beacon_node/store/src/database/interface.rs +++ b/beacon_node/store/src/database/interface.rs @@ -114,7 +114,11 @@ impl KeyValueStore for BeaconNodeBackend { } } - fn iter_column_keys_from(&self, _column: DBColumn, from: &[u8]) -> ColumnKeyIter { + fn iter_column_keys_from( + &self, + _column: DBColumn, + from: &[u8], + ) -> ColumnKeyIter<'_, K> { match self { #[cfg(feature = "leveldb")] BeaconNodeBackend::LevelDb(txn) => { @@ -127,7 +131,7 @@ impl KeyValueStore for BeaconNodeBackend { } } - fn iter_column_keys(&self, column: DBColumn) -> ColumnKeyIter { + fn iter_column_keys(&self, column: DBColumn) -> ColumnKeyIter<'_, K> { match self { #[cfg(feature = "leveldb")] BeaconNodeBackend::LevelDb(txn) => leveldb_impl::LevelDB::iter_column_keys(txn, column), @@ -136,7 +140,7 @@ impl KeyValueStore for BeaconNodeBackend { } } - fn iter_column_from(&self, column: DBColumn, from: &[u8]) -> ColumnIter { + fn iter_column_from(&self, column: DBColumn, from: &[u8]) -> ColumnIter<'_, K> { match self { #[cfg(feature = "leveldb")] BeaconNodeBackend::LevelDb(txn) => { diff --git a/beacon_node/store/src/database/leveldb_impl.rs b/beacon_node/store/src/database/leveldb_impl.rs index e990333fa3..54d7175089 100644 --- a/beacon_node/store/src/database/leveldb_impl.rs +++ b/beacon_node/store/src/database/leveldb_impl.rs @@ -47,7 +47,7 @@ impl LevelDB { }) } - pub fn read_options(&self) -> ReadOptions { + pub fn read_options(&self) -> ReadOptions<'_, BytesKey> { ReadOptions::new() } @@ -207,7 +207,7 @@ impl LevelDB { Ok(()) } - pub fn iter_column_from(&self, column: DBColumn, from: &[u8]) -> ColumnIter { + pub fn iter_column_from(&self, column: DBColumn, from: &[u8]) -> ColumnIter<'_, K> { let start_key = BytesKey::from_vec(get_key_for_col(column, from)); let iter = self.db.iter(self.read_options()); iter.seek(&start_key); @@ -231,7 +231,11 @@ impl LevelDB { ) } - pub fn iter_column_keys_from(&self, column: DBColumn, from: &[u8]) -> ColumnKeyIter { + pub fn iter_column_keys_from( + &self, + column: DBColumn, + from: &[u8], + ) -> ColumnKeyIter<'_, K> { let start_key = BytesKey::from_vec(get_key_for_col(column, from)); let iter = self.db.keys_iter(self.read_options()); @@ -253,11 +257,11 @@ impl LevelDB { } /// Iterate through all keys and values in a particular column. - pub fn iter_column_keys(&self, column: DBColumn) -> ColumnKeyIter { + pub fn iter_column_keys(&self, column: DBColumn) -> ColumnKeyIter<'_, K> { self.iter_column_keys_from(column, &vec![0; column.key_size()]) } - pub fn iter_column(&self, column: DBColumn) -> ColumnIter { + pub fn iter_column(&self, column: DBColumn) -> ColumnIter<'_, K> { self.iter_column_from(column, &vec![0; column.key_size()]) } diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 4d94042b5b..80974df6e7 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -1125,7 +1125,7 @@ impl, Cold: ItemStore> HotColdDB start_slot: Slot, end_slot: Slot, get_state: impl FnOnce() -> Result<(BeaconState, Hash256), Error>, - ) -> Result, Error> { + ) -> Result, Error> { HybridForwardsBlockRootsIterator::new( self, DBColumn::BeaconBlockRoots, @@ -1155,7 +1155,7 @@ impl, Cold: ItemStore> HotColdDB start_slot: Slot, end_slot: Slot, get_state: impl FnOnce() -> Result<(BeaconState, Hash256), Error>, - ) -> Result, Error> { + ) -> Result, Error> { HybridForwardsStateRootsIterator::new( self, DBColumn::BeaconStateRoots, diff --git a/beacon_node/store/src/lib.rs b/beacon_node/store/src/lib.rs index ede4b4435e..e996b47b72 100644 --- a/beacon_node/store/src/lib.rs +++ b/beacon_node/store/src/lib.rs @@ -92,17 +92,17 @@ pub trait KeyValueStore: Sync + Send + Sized + 'static { } /// Iterate through all keys and values in a particular column. - fn iter_column(&self, column: DBColumn) -> ColumnIter { + fn iter_column(&self, column: DBColumn) -> ColumnIter<'_, K> { self.iter_column_from(column, &vec![0; column.key_size()]) } /// Iterate through all keys and values in a column from a given starting point that fulfill the given predicate. - fn iter_column_from(&self, column: DBColumn, from: &[u8]) -> ColumnIter; + fn iter_column_from(&self, column: DBColumn, from: &[u8]) -> ColumnIter<'_, K>; - fn iter_column_keys(&self, column: DBColumn) -> ColumnKeyIter; + fn iter_column_keys(&self, column: DBColumn) -> ColumnKeyIter<'_, K>; /// Iterate through all keys in a particular column. - fn iter_column_keys_from(&self, column: DBColumn, from: &[u8]) -> ColumnKeyIter; + fn iter_column_keys_from(&self, column: DBColumn, from: &[u8]) -> ColumnKeyIter<'_, K>; fn delete_batch(&self, column: DBColumn, ops: HashSet<&[u8]>) -> Result<(), Error>; diff --git a/beacon_node/store/src/memory_store.rs b/beacon_node/store/src/memory_store.rs index e53417ef0e..a87d4f7f3f 100644 --- a/beacon_node/store/src/memory_store.rs +++ b/beacon_node/store/src/memory_store.rs @@ -80,7 +80,7 @@ impl KeyValueStore for MemoryStore { Ok(()) } - fn iter_column_from(&self, column: DBColumn, from: &[u8]) -> ColumnIter { + fn iter_column_from(&self, column: DBColumn, from: &[u8]) -> ColumnIter<'_, K> { // We use this awkward pattern because we can't lock the `self.db` field *and* maintain a // reference to the lock guard across calls to `.next()`. This would be require a // struct with a field (the iterator) which references another field (the lock guard). @@ -101,7 +101,7 @@ impl KeyValueStore for MemoryStore { })) } - fn iter_column_keys(&self, column: DBColumn) -> ColumnKeyIter { + fn iter_column_keys(&self, column: DBColumn) -> ColumnKeyIter<'_, K> { Box::new(self.iter_column(column).map(|res| res.map(|(k, _)| k))) } @@ -109,7 +109,7 @@ impl KeyValueStore for MemoryStore { Ok(()) } - fn iter_column_keys_from(&self, column: DBColumn, from: &[u8]) -> ColumnKeyIter { + fn iter_column_keys_from(&self, column: DBColumn, from: &[u8]) -> ColumnKeyIter<'_, K> { // We use this awkward pattern because we can't lock the `self.db` field *and* maintain a // reference to the lock guard across calls to `.next()`. This would be require a // struct with a field (the iterator) which references another field (the lock guard). diff --git a/consensus/proto_array/src/proto_array_fork_choice.rs b/consensus/proto_array/src/proto_array_fork_choice.rs index dde2411787..76a07ac6be 100644 --- a/consensus/proto_array/src/proto_array_fork_choice.rs +++ b/consensus/proto_array/src/proto_array_fork_choice.rs @@ -856,7 +856,7 @@ impl ProtoArrayForkChoice { } /// See `ProtoArray::iter_nodes` - pub fn iter_nodes(&self, block_root: &Hash256) -> Iter { + pub fn iter_nodes(&self, block_root: &Hash256) -> Iter<'_> { self.proto_array.iter_nodes(block_root) } diff --git a/consensus/state_processing/src/consensus_context.rs b/consensus/state_processing/src/consensus_context.rs index 0c176d4ab1..d0086c1041 100644 --- a/consensus/state_processing/src/consensus_context.rs +++ b/consensus/state_processing/src/consensus_context.rs @@ -148,12 +148,12 @@ impl ConsensusContext { } #[allow(unknown_lints)] - #[allow(elided_named_lifetimes)] + #[allow(mismatched_lifetime_syntaxes)] pub fn get_indexed_attestation<'a>( &'a mut self, state: &BeaconState, attestation: AttestationRef<'a, E>, - ) -> Result, BlockOperationError> { + ) -> Result, BlockOperationError> { let key = attestation.tree_hash_root(); match attestation { AttestationRef::Base(attn) => match self.indexed_attestations.entry(key) { diff --git a/consensus/state_processing/src/per_block_processing/signature_sets.rs b/consensus/state_processing/src/per_block_processing/signature_sets.rs index 39f438f97f..dafd0d79ea 100644 --- a/consensus/state_processing/src/per_block_processing/signature_sets.rs +++ b/consensus/state_processing/src/per_block_processing/signature_sets.rs @@ -56,7 +56,7 @@ impl From for Error { pub fn get_pubkey_from_state( state: &BeaconState, validator_index: usize, -) -> Option> +) -> Option> where E: EthSpec, { diff --git a/consensus/types/src/attestation.rs b/consensus/types/src/attestation.rs index e9a1ab4ceb..569d73820c 100644 --- a/consensus/types/src/attestation.rs +++ b/consensus/types/src/attestation.rs @@ -511,7 +511,7 @@ pub enum AttestationOnDisk { } impl AttestationOnDisk { - pub fn to_ref(&self) -> AttestationRefOnDisk { + pub fn to_ref(&self) -> AttestationRefOnDisk<'_, E> { match self { AttestationOnDisk::Base(att) => AttestationRefOnDisk::Base(att), AttestationOnDisk::Electra(att) => AttestationRefOnDisk::Electra(att), diff --git a/consensus/types/src/attester_slashing.rs b/consensus/types/src/attester_slashing.rs index 8fb5862f21..f671a43c9c 100644 --- a/consensus/types/src/attester_slashing.rs +++ b/consensus/types/src/attester_slashing.rs @@ -141,7 +141,7 @@ impl<'a, E: EthSpec> AttesterSlashingRef<'a, E> { } impl AttesterSlashing { - pub fn attestation_1(&self) -> IndexedAttestationRef { + pub fn attestation_1(&self) -> IndexedAttestationRef<'_, E> { match self { AttesterSlashing::Base(attester_slashing) => { IndexedAttestationRef::Base(&attester_slashing.attestation_1) @@ -152,7 +152,7 @@ impl AttesterSlashing { } } - pub fn attestation_2(&self) -> IndexedAttestationRef { + pub fn attestation_2(&self) -> IndexedAttestationRef<'_, E> { match self { AttesterSlashing::Base(attester_slashing) => { IndexedAttestationRef::Base(&attester_slashing.attestation_2) diff --git a/consensus/types/src/beacon_state.rs b/consensus/types/src/beacon_state.rs index 599d0fe8e9..31bc949583 100644 --- a/consensus/types/src/beacon_state.rs +++ b/consensus/types/src/beacon_state.rs @@ -808,7 +808,7 @@ impl BeaconState { &self, slot: Slot, index: CommitteeIndex, - ) -> Result { + ) -> Result, Error> { let epoch = slot.epoch(E::slots_per_epoch()); let relative_epoch = RelativeEpoch::from_epoch(self.current_epoch(), epoch)?; let cache = self.committee_cache(relative_epoch)?; @@ -823,7 +823,10 @@ impl BeaconState { /// Utilises the committee cache. /// /// Spec v0.12.1 - pub fn get_beacon_committees_at_slot(&self, slot: Slot) -> Result, Error> { + pub fn get_beacon_committees_at_slot( + &self, + slot: Slot, + ) -> Result>, Error> { let cache = self.committee_cache_at_slot(slot)?; cache.get_beacon_committees_at_slot(slot) } @@ -836,7 +839,7 @@ impl BeaconState { pub fn get_beacon_committees_at_epoch( &self, relative_epoch: RelativeEpoch, - ) -> Result, Error> { + ) -> Result>, Error> { let cache = self.committee_cache(relative_epoch)?; cache.get_all_beacon_committees() } @@ -1016,7 +1019,9 @@ impl BeaconState { } /// Convenience accessor for the `execution_payload_header` as an `ExecutionPayloadHeaderRef`. - pub fn latest_execution_payload_header(&self) -> Result, Error> { + pub fn latest_execution_payload_header( + &self, + ) -> Result, Error> { match self { BeaconState::Base(_) | BeaconState::Altair(_) => Err(Error::IncorrectStateVariant), BeaconState::Bellatrix(state) => Ok(ExecutionPayloadHeaderRef::Bellatrix( @@ -1039,7 +1044,7 @@ impl BeaconState { pub fn latest_execution_payload_header_mut( &mut self, - ) -> Result, Error> { + ) -> Result, Error> { match self { BeaconState::Base(_) | BeaconState::Altair(_) => Err(Error::IncorrectStateVariant), BeaconState::Bellatrix(state) => Ok(ExecutionPayloadHeaderRefMut::Bellatrix( @@ -1713,7 +1718,7 @@ impl BeaconState { pub fn get_validator_cow( &mut self, validator_index: usize, - ) -> Result, Error> { + ) -> Result, Error> { self.validators_mut() .get_cow(validator_index) .ok_or(Error::UnknownValidator(validator_index)) diff --git a/consensus/types/src/beacon_state/committee_cache.rs b/consensus/types/src/beacon_state/committee_cache.rs index 161f854157..e3fb339c87 100644 --- a/consensus/types/src/beacon_state/committee_cache.rs +++ b/consensus/types/src/beacon_state/committee_cache.rs @@ -159,7 +159,7 @@ impl CommitteeCache { &self, slot: Slot, index: CommitteeIndex, - ) -> Option { + ) -> Option> { if self.initialized_epoch.is_none() || !self.is_initialized_at(slot.epoch(self.slots_per_epoch)) || index >= self.committees_per_slot @@ -185,7 +185,10 @@ impl CommitteeCache { /// Get all the Beacon committees at a given `slot`. /// /// Committees are sorted by ascending index order 0..committees_per_slot - pub fn get_beacon_committees_at_slot(&self, slot: Slot) -> Result, Error> { + pub fn get_beacon_committees_at_slot( + &self, + slot: Slot, + ) -> Result>, Error> { if self.initialized_epoch.is_none() { return Err(Error::CommitteeCacheUninitialized(None)); } @@ -199,7 +202,7 @@ impl CommitteeCache { } /// Returns all committees for `self.initialized_epoch`. - pub fn get_all_beacon_committees(&self) -> Result, Error> { + pub fn get_all_beacon_committees(&self) -> Result>, Error> { let initialized_epoch = self .initialized_epoch .ok_or(Error::CommitteeCacheUninitialized(None))?; diff --git a/consensus/types/src/slot_epoch.rs b/consensus/types/src/slot_epoch.rs index 0391756047..66790a9641 100644 --- a/consensus/types/src/slot_epoch.rs +++ b/consensus/types/src/slot_epoch.rs @@ -118,7 +118,7 @@ impl Epoch { .as_u64()) } - pub fn slot_iter(&self, slots_per_epoch: u64) -> SlotIter { + pub fn slot_iter(&self, slots_per_epoch: u64) -> SlotIter<'_> { SlotIter { current_iteration: 0, epoch: self, diff --git a/consensus/types/src/sqlite.rs b/consensus/types/src/sqlite.rs index aa20666ae1..2f3f6d1c80 100644 --- a/consensus/types/src/sqlite.rs +++ b/consensus/types/src/sqlite.rs @@ -8,7 +8,7 @@ use rusqlite::{ macro_rules! impl_to_from_sql { ($type:ty) => { impl ToSql for $type { - fn to_sql(&self) -> Result { + fn to_sql(&self) -> Result, Error> { let val_i64 = i64::try_from(self.as_u64()) .map_err(|e| Error::ToSqlConversionFailure(Box::new(e)))?; Ok(ToSqlOutput::from(val_i64)) diff --git a/slasher/src/array.rs b/slasher/src/array.rs index 77ddceb85f..c61b9b5414 100644 --- a/slasher/src/array.rs +++ b/slasher/src/array.rs @@ -147,7 +147,7 @@ pub trait TargetArrayChunk: Sized + serde::Serialize + serde::de::DeserializeOwn fn next_start_epoch(start_epoch: Epoch, config: &Config) -> Epoch; - fn select_db(db: &SlasherDB) -> &Database; + fn select_db(db: &SlasherDB) -> &Database<'_>; fn load( db: &SlasherDB, @@ -290,7 +290,7 @@ impl TargetArrayChunk for MinTargetChunk { start_epoch / chunk_size * chunk_size - 1 } - fn select_db(db: &SlasherDB) -> &Database { + fn select_db(db: &SlasherDB) -> &Database<'_> { &db.databases.min_targets_db } } @@ -389,7 +389,7 @@ impl TargetArrayChunk for MaxTargetChunk { (start_epoch / chunk_size + 1) * chunk_size } - fn select_db(db: &SlasherDB) -> &Database { + fn select_db(db: &SlasherDB) -> &Database<'_> { &db.databases.max_targets_db } } diff --git a/slasher/src/database.rs b/slasher/src/database.rs index 071109e00c..d5e0ed5d24 100644 --- a/slasher/src/database.rs +++ b/slasher/src/database.rs @@ -331,7 +331,7 @@ impl SlasherDB { Ok(db) } - pub fn begin_rw_txn(&self) -> Result { + pub fn begin_rw_txn(&self) -> Result, Error> { self.env.begin_rw_txn() } diff --git a/slasher/src/database/interface.rs b/slasher/src/database/interface.rs index af72006caa..dcbb82fe93 100644 --- a/slasher/src/database/interface.rs +++ b/slasher/src/database/interface.rs @@ -83,7 +83,7 @@ impl Environment { } } - pub fn create_databases(&self) -> Result { + pub fn create_databases(&self) -> Result, Error> { match self { #[cfg(feature = "mdbx")] Self::Mdbx(env) => env.create_databases(), @@ -95,7 +95,7 @@ impl Environment { } } - pub fn begin_rw_txn(&self) -> Result { + pub fn begin_rw_txn(&self) -> Result, Error> { match self { #[cfg(feature = "mdbx")] Self::Mdbx(env) => env.begin_rw_txn().map(RwTransaction::Mdbx), @@ -194,7 +194,7 @@ impl<'env> RwTransaction<'env> { impl Cursor<'_> { /// Return the first key in the current database while advancing the cursor's position. - pub fn first_key(&mut self) -> Result, Error> { + pub fn first_key(&mut self) -> Result>, Error> { match self { #[cfg(feature = "mdbx")] Cursor::Mdbx(cursor) => cursor.first_key(), @@ -207,7 +207,7 @@ impl Cursor<'_> { } /// Return the last key in the current database while advancing the cursor's position. - pub fn last_key(&mut self) -> Result, Error> { + pub fn last_key(&mut self) -> Result>, Error> { match self { #[cfg(feature = "mdbx")] Cursor::Mdbx(cursor) => cursor.last_key(), @@ -219,7 +219,7 @@ impl Cursor<'_> { } } - pub fn next_key(&mut self) -> Result, Error> { + pub fn next_key(&mut self) -> Result>, Error> { match self { #[cfg(feature = "mdbx")] Cursor::Mdbx(cursor) => cursor.next_key(), diff --git a/slasher/src/database/lmdb_impl.rs b/slasher/src/database/lmdb_impl.rs index 74342968cf..a2ef298830 100644 --- a/slasher/src/database/lmdb_impl.rs +++ b/slasher/src/database/lmdb_impl.rs @@ -41,7 +41,7 @@ impl Environment { Ok(Environment { env }) } - pub fn create_databases(&self) -> Result { + pub fn create_databases(&self) -> Result, Error> { let indexed_attestation_db = self .env .create_db(Some(INDEXED_ATTESTATION_DB), Self::db_flags())?; @@ -80,7 +80,7 @@ impl Environment { }) } - pub fn begin_rw_txn(&self) -> Result { + pub fn begin_rw_txn(&self) -> Result, Error> { let txn = self.env.begin_rw_txn()?; Ok(RwTransaction { txn }) } @@ -137,7 +137,7 @@ impl<'env> RwTransaction<'env> { } impl<'env> Cursor<'env> { - pub fn first_key(&mut self) -> Result, Error> { + pub fn first_key(&mut self) -> Result>, Error> { let opt_key = self .cursor .get(None, None, MDB_FIRST) diff --git a/validator_client/initialized_validators/src/lib.rs b/validator_client/initialized_validators/src/lib.rs index cbc1287a85..957430fa57 100644 --- a/validator_client/initialized_validators/src/lib.rs +++ b/validator_client/initialized_validators/src/lib.rs @@ -159,7 +159,7 @@ pub struct InitializedValidator { impl InitializedValidator { /// Return a reference to this validator's lockfile if it has one. - pub fn keystore_lockfile(&self) -> Option> { + pub fn keystore_lockfile(&self) -> Option> { match self.signing_method.as_ref() { SigningMethod::LocalKeystore { ref voting_keystore_lockfile,