Skip to content

Commit

Permalink
Fix Rust beta compiler errors 1.78.0-beta.1 (#5439)
Browse files Browse the repository at this point in the history
* remove redundant imports

* fix test

* contains key

* fmt

* Merge branch 'unstable' into fix-beta-compiler
  • Loading branch information
eserilev authored Mar 20, 2024
1 parent 4449627 commit 01ec42e
Show file tree
Hide file tree
Showing 148 changed files with 104 additions and 301 deletions.
5 changes: 2 additions & 3 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ use crate::{
kzg_utils, metrics, AvailabilityPendingExecutedBlock, BeaconChainError, BeaconForkChoiceStore,
BeaconSnapshot, CachedHead,
};
use eth2::types::{EventKind, SseBlobSidecar, SseBlock, SseExtendedPayloadAttributes, SyncDuty};
use eth2::types::{EventKind, SseBlobSidecar, SseBlock, SseExtendedPayloadAttributes};
use execution_layer::{
BlockProposalContents, BlockProposalContentsType, BuilderParams, ChainHealth, ExecutionLayer,
FailedCondition, PayloadAttributes, PayloadStatus,
Expand Down Expand Up @@ -120,8 +120,7 @@ use store::{
use task_executor::{ShutdownReason, TaskExecutor};
use tokio_stream::Stream;
use tree_hash::TreeHash;
use types::beacon_state::CloneConfig;
use types::blob_sidecar::{BlobSidecarList, FixedBlobSidecarList};
use types::blob_sidecar::FixedBlobSidecarList;
use types::payload::BlockProductionVersion;
use types::*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ mod test {
use store::{HotColdDB, ItemStore, LevelDB, StoreConfig};
use tempfile::{tempdir, TempDir};
use types::non_zero_usize::new_non_zero_usize;
use types::{ChainSpec, ExecPayload, MinimalEthSpec};
use types::{ExecPayload, MinimalEthSpec};

const LOW_VALIDATOR_COUNT: usize = 32;

Expand Down
1 change: 0 additions & 1 deletion beacon_node/beacon_chain/src/early_attester_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{
use parking_lot::RwLock;
use proto_array::Block as ProtoBlock;
use std::sync::Arc;
use types::blob_sidecar::BlobSidecarList;
use types::*;

pub struct CacheItem<E: EthSpec> {
Expand Down
3 changes: 1 addition & 2 deletions beacon_node/beacon_chain/src/eth1_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use ssz_derive::{Decode, Encode};
use state_processing::per_block_processing::get_new_eth1_data;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::iter::DoubleEndedIterator;
use std::marker::PhantomData;
use std::time::{SystemTime, UNIX_EPOCH};
use store::{DBColumn, Error as StoreError, StoreItem};
Expand Down Expand Up @@ -736,7 +735,7 @@ mod test {
mod eth1_chain_json_backend {
use super::*;
use eth1::DepositLog;
use types::{test_utils::generate_deterministic_keypair, EthSpec, MainnetEthSpec};
use types::{test_utils::generate_deterministic_keypair, MainnetEthSpec};

fn get_eth1_chain() -> Eth1Chain<CachingEth1Backend<E>, E> {
let eth1_config = Eth1Config {
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/observed_blob_sidecars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mod tests {
use super::*;
use bls::Hash256;
use std::sync::Arc;
use types::{BlobSidecar, MainnetEthSpec};
use types::MainnetEthSpec;

type E = MainnetEthSpec;

Expand Down
5 changes: 1 addition & 4 deletions beacon_node/beacon_chain/src/snapshot_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,7 @@ impl<T: EthSpec> SnapshotCache<T> {
mod test {
use super::*;
use crate::test_utils::{BeaconChainHarness, EphemeralHarnessType};
use types::{
test_utils::generate_deterministic_keypair, BeaconBlock, Epoch, MainnetEthSpec,
SignedBeaconBlock, Slot,
};
use types::{test_utils::generate_deterministic_keypair, BeaconBlock, MainnetEthSpec};

fn get_harness() -> BeaconChainHarness<EphemeralHarnessType<MainnetEthSpec>> {
let harness = BeaconChainHarness::builder(MainnetEthSpec)
Expand Down
1 change: 0 additions & 1 deletion beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ use task_executor::TaskExecutor;
use task_executor::{test_utils::TestRuntime, ShutdownReason};
use tree_hash::TreeHash;
use types::payload::BlockProductionVersion;
use types::sync_selection_proof::SyncSelectionProof;
pub use types::test_utils::generate_deterministic_keypairs;
use types::test_utils::TestRandom;
use types::{typenum::U4294967296, *};
Expand Down
1 change: 0 additions & 1 deletion beacon_node/beacon_chain/src/validator_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use state_processing::per_epoch_processing::{
errors::EpochProcessingError, EpochProcessingSummary,
};
use std::collections::{HashMap, HashSet};
use std::convert::TryFrom;
use std::io;
use std::marker::PhantomData;
use std::str::Utf8Error;
Expand Down
3 changes: 1 addition & 2 deletions beacon_node/beacon_chain/src/validator_pubkey_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::errors::BeaconChainError;
use crate::{BeaconChainTypes, BeaconStore};
use ssz::{Decode, Encode};
use std::collections::HashMap;
use std::convert::TryInto;
use std::marker::PhantomData;
use store::{DBColumn, Error as StoreError, StoreItem, StoreOp};
use types::{BeaconState, Hash256, PublicKey, PublicKeyBytes};
Expand Down Expand Up @@ -195,7 +194,7 @@ mod test {
use logging::test_logger;
use std::sync::Arc;
use store::HotColdDB;
use types::{BeaconState, EthSpec, Keypair, MainnetEthSpec};
use types::{EthSpec, Keypair, MainnetEthSpec};

type E = MainnetEthSpec;
type T = EphemeralHarnessType<E>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,6 @@ impl<S: SlotClock> ReprocessQueue<S> {
mod tests {
use super::*;
use slot_clock::TestingSlotClock;
use types::Slot;

#[test]
fn backfill_processing_schedule_calculation() {
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Default for Config {
impl Config {
/// Updates the data directory for the Client.
pub fn set_data_dir(&mut self, data_dir: PathBuf) {
self.data_dir = data_dir.clone();
self.data_dir.clone_from(&data_dir);
self.http_api.data_dir = data_dir;
}

Expand Down
1 change: 0 additions & 1 deletion beacon_node/eth1/src/block_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ impl BlockCache {
#[cfg(test)]
mod tests {
use super::*;
use types::Hash256;

fn get_block(i: u64, interval_secs: u64) -> Eth1Block {
Eth1Block {
Expand Down
1 change: 0 additions & 1 deletion beacon_node/eth1/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ async fn new_anvil_instance() -> Result<AnvilEth1Instance, String> {

mod eth1_cache {
use super::*;
use types::{EthSpec, MainnetEthSpec};

#[tokio::test]
async fn simple_scenario() {
Expand Down
1 change: 0 additions & 1 deletion beacon_node/execution_layer/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub use json_structures::{JsonWithdrawal, TransitionConfigurationV1};
use pretty_reqwest_error::PrettyReqwestError;
use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use strum::IntoStaticStr;
use superstruct::superstruct;
pub use types::{
Expand Down
3 changes: 1 addition & 2 deletions beacon_node/execution_layer/src/engine_api/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::collections::HashSet;
use tokio::sync::Mutex;

use std::time::{Duration, Instant};
use types::EthSpec;

pub use deposit_log::{DepositLog, Log};
pub use reqwest::Client;
Expand Down Expand Up @@ -1191,7 +1190,7 @@ mod test {
use std::future::Future;
use std::str::FromStr;
use std::sync::Arc;
use types::{ExecutionPayloadMerge, MainnetEthSpec, Transactions, Unsigned, VariableList};
use types::{MainnetEthSpec, Unsigned};

struct Tester {
server: MockServer<MainnetEthSpec>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ use strum::EnumString;
use superstruct::superstruct;
use types::beacon_block_body::KzgCommitments;
use types::blob_sidecar::BlobsList;
use types::{
EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadCapella, ExecutionPayloadDeneb,
ExecutionPayloadMerge, FixedVector, Transactions, Unsigned, VariableList, Withdrawal,
};
use types::{FixedVector, Unsigned};

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down
1 change: 0 additions & 1 deletion beacon_node/execution_layer/src/test_utils/handle_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::test_utils::DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI;
use serde::{de::DeserializeOwned, Deserialize};
use serde_json::Value as JsonValue;
use std::sync::Arc;
use types::{EthSpec, ForkName};

pub const GENERIC_ERROR_CODE: i64 = -1234;
pub const BAD_PARAMS_ERROR_CODE: i64 = -32602;
Expand Down
9 changes: 0 additions & 9 deletions beacon_node/execution_layer/src/test_utils/mock_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ pub trait BidStuff<E: EthSpec> {
fn set_withdrawals_root(&mut self, withdrawals_root: Hash256);

fn sign_builder_message(&mut self, sk: &SecretKey, spec: &ChainSpec) -> Signature;

fn to_signed_bid(self, signature: Signature) -> SignedBuilderBid<E>;
}

impl<E: EthSpec> BidStuff<E> for BuilderBid<E> {
Expand Down Expand Up @@ -183,13 +181,6 @@ impl<E: EthSpec> BidStuff<E> for BuilderBid<E> {
let message = self.signing_root(domain);
sk.sign(message)
}

fn to_signed_bid(self, signature: Signature) -> SignedBuilderBid<E> {
SignedBuilderBid {
message: self,
signature,
}
}
}

#[derive(Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ use crate::{
test_utils::{
MockServer, DEFAULT_JWT_SECRET, DEFAULT_TERMINAL_BLOCK, DEFAULT_TERMINAL_DIFFICULTY,
},
Config, *,
*,
};
use keccak_hash::H256;
use kzg::Kzg;
use sensitive_url::SensitiveUrl;
use task_executor::TaskExecutor;
use tempfile::NamedTempFile;
use types::{Address, ChainSpec, Epoch, EthSpec, Hash256, MainnetEthSpec};
use types::MainnetEthSpec;

pub struct MockExecutionLayer<T: EthSpec> {
pub server: MockServer<T>,
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/genesis/src/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub fn interop_genesis_state_with_withdrawal_credentials<T: EthSpec>(
#[cfg(test)]
mod test {
use super::*;
use types::{test_utils::generate_deterministic_keypairs, EthSpec, MinimalEthSpec};
use types::{test_utils::generate_deterministic_keypairs, MinimalEthSpec};

type TestEthSpec = MinimalEthSpec;

Expand Down
7 changes: 4 additions & 3 deletions beacon_node/http_api/src/block_packing_efficiency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<T: EthSpec> PackingEfficiencyHandler<T> {
}

// Remove duplicate attestations as these yield no reward.
attestations_in_block.retain(|x, _| self.included_attestations.get(x).is_none());
attestations_in_block.retain(|x, _| !self.included_attestations.contains_key(x));
self.included_attestations
.extend(attestations_in_block.clone());

Expand Down Expand Up @@ -179,8 +179,9 @@ impl<T: EthSpec> PackingEfficiencyHandler<T> {
.collect::<Vec<_>>()
};

self.committee_store.previous_epoch_committees =
self.committee_store.current_epoch_committees.clone();
self.committee_store
.previous_epoch_committees
.clone_from(&self.committee_store.current_epoch_committees);

self.committee_store.current_epoch_committees = new_committees;

Expand Down
4 changes: 2 additions & 2 deletions beacon_node/lighthouse_network/src/gossipsub/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ where
return Err(SubscriptionError::NotAllowed);
}

if self.mesh.get(&topic_hash).is_some() {
if self.mesh.contains_key(&topic_hash) {
tracing::debug!(%topic, "Topic is already in the mesh");
return Ok(false);
}
Expand All @@ -551,7 +551,7 @@ where
tracing::debug!(%topic, "Unsubscribing from topic");
let topic_hash = topic.hash();

if self.mesh.get(&topic_hash).is_none() {
if !self.mesh.contains_key(&topic_hash) {
tracing::debug!(topic=%topic_hash, "Already unsubscribed from topic");
// we are not subscribed
return Ok(false);
Expand Down
27 changes: 11 additions & 16 deletions beacon_node/lighthouse_network/src/gossipsub/behaviour/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@

use super::*;
use crate::gossipsub::subscription_filter::WhitelistSubscriptionFilter;
use crate::gossipsub::transform::{DataTransform, IdentityTransform};
use crate::gossipsub::types::{RpcOut, RpcReceiver};
use crate::gossipsub::ValidationError;
use crate::gossipsub::{
config::Config, config::ConfigBuilder, types::Rpc, IdentTopic as Topic, TopicScoreParams,
};
use crate::gossipsub::types::RpcReceiver;
use crate::gossipsub::{config::ConfigBuilder, types::Rpc, IdentTopic as Topic};
use async_std::net::Ipv4Addr;
use byteorder::{BigEndian, ByteOrder};
use libp2p::core::{ConnectedPoint, Endpoint};
use libp2p::core::ConnectedPoint;
use rand::Rng;
use std::thread::sleep;
use std::time::Duration;

#[derive(Default, Debug)]
struct InjectNodes<D, F>
Expand Down Expand Up @@ -427,7 +422,7 @@ fn test_subscribe() {
.create_network();

assert!(
gs.mesh.get(&topic_hashes[0]).is_some(),
gs.mesh.contains_key(&topic_hashes[0]),
"Subscribe should add a new entry to the mesh[topic] hashmap"
);

Expand Down Expand Up @@ -477,7 +472,7 @@ fn test_unsubscribe() {
"Topic_peers contain a topic entry"
);
assert!(
gs.mesh.get(topic_hash).is_some(),
gs.mesh.contains_key(topic_hash),
"mesh should contain a topic entry"
);
}
Expand Down Expand Up @@ -511,7 +506,7 @@ fn test_unsubscribe() {
// check we clean up internal structures
for topic_hash in &topic_hashes {
assert!(
gs.mesh.get(topic_hash).is_none(),
!gs.mesh.contains_key(topic_hash),
"All topics should have been removed from the mesh"
);
}
Expand Down Expand Up @@ -694,7 +689,7 @@ fn test_publish_without_flood_publishing() {
.create_network();

assert!(
gs.mesh.get(&topic_hashes[0]).is_some(),
gs.mesh.contains_key(&topic_hashes[0]),
"Subscribe should add a new entry to the mesh[topic] hashmap"
);

Expand Down Expand Up @@ -774,7 +769,7 @@ fn test_fanout() {
.create_network();

assert!(
gs.mesh.get(&topic_hashes[0]).is_some(),
gs.mesh.contains_key(&topic_hashes[0]),
"Subscribe should add a new entry to the mesh[topic] hashmap"
);
// Unsubscribe from topic
Expand Down Expand Up @@ -946,7 +941,7 @@ fn test_handle_received_subscriptions() {
);

assert!(
gs.connected_peers.get(&unknown_peer).is_none(),
!gs.connected_peers.contains_key(&unknown_peer),
"Unknown peer should not have been added"
);

Expand Down Expand Up @@ -1347,7 +1342,7 @@ fn test_handle_graft_multiple_topics() {
}

assert!(
gs.mesh.get(&topic_hashes[2]).is_none(),
!gs.mesh.contains_key(&topic_hashes[2]),
"Expected the second topic to not be in the mesh"
);
}
Expand Down Expand Up @@ -5228,7 +5223,7 @@ fn test_graft_without_subscribe() {
.create_network();

assert!(
gs.mesh.get(&topic_hashes[0]).is_some(),
gs.mesh.contains_key(&topic_hashes[0]),
"Subscribe should add a new entry to the mesh[topic] hashmap"
);

Expand Down
2 changes: 0 additions & 2 deletions beacon_node/lighthouse_network/src/gossipsub/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,8 @@ impl std::fmt::Debug for Config {
mod test {
use super::*;
use crate::gossipsub::topic::IdentityHash;
use crate::gossipsub::types::PeerKind;
use crate::gossipsub::Topic;
use libp2p::core::UpgradeInfo;
use libp2p::swarm::StreamProtocol;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};

Expand Down
4 changes: 1 addition & 3 deletions beacon_node/lighthouse_network/src/gossipsub/mcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,7 @@ impl MessageCache {
#[cfg(test)]
mod tests {
use super::*;
use crate::gossipsub::types::RawMessage;
use crate::{IdentTopic as Topic, TopicHash};
use libp2p::identity::PeerId;
use crate::IdentTopic as Topic;

fn gen_testm(x: u64, topic: TopicHash) -> (MessageId, RawMessage) {
let default_id = |message: &RawMessage| {
Expand Down
Loading

0 comments on commit 01ec42e

Please sign in to comment.