From bbd0ddb417fef3b6d6496c2e960d0b03fdd4b460 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Thu, 13 Jun 2024 16:57:41 +1000 Subject: [PATCH] Remove extern crate --- beacon_node/client/src/lib.rs | 2 -- beacon_node/eth1/src/lib.rs | 3 --- beacon_node/eth1/src/metrics.rs | 2 ++ beacon_node/execution_layer/src/versioned_hashes.rs | 2 -- beacon_node/lighthouse_network/src/lib.rs | 3 --- beacon_node/lighthouse_network/src/metrics.rs | 2 ++ .../lighthouse_network/src/peer_manager/peerdb/score.rs | 1 + beacon_node/lighthouse_network/src/rpc/protocol.rs | 1 + beacon_node/network/src/lib.rs | 3 --- beacon_node/network/src/metrics.rs | 1 + beacon_node/src/lib.rs | 2 -- beacon_node/store/src/lib.rs | 3 --- beacon_node/store/src/metrics.rs | 1 + common/compare_fields_derive/src/lib.rs | 2 -- common/eth2_interop_keypairs/src/lib.rs | 4 +--- common/lighthouse_metrics/src/lib.rs | 3 +-- common/logging/src/lib.rs | 4 +--- common/logging/src/tracing_metrics_layer.rs | 1 + common/slot_clock/src/lib.rs | 3 --- common/slot_clock/src/metrics.rs | 1 + common/test_random_derive/src/lib.rs | 4 +--- consensus/types/src/beacon_state/committee_cache/tests.rs | 1 + consensus/types/src/beacon_state/tests.rs | 1 + consensus/types/src/lib.rs | 2 -- consensus/types/src/subnet_id.rs | 1 + consensus/types/src/sync_subnet_id.rs | 1 + lcli/src/block_root.rs | 1 + lcli/src/main.rs | 2 -- lcli/src/parse_ssz.rs | 1 + lcli/src/skip_slots.rs | 1 + lcli/src/state_root.rs | 1 + lcli/src/transition_blocks.rs | 1 + testing/simulator/src/main.rs | 3 --- 33 files changed, 23 insertions(+), 41 deletions(-) diff --git a/beacon_node/client/src/lib.rs b/beacon_node/client/src/lib.rs index fd92c282554..e6042103e16 100644 --- a/beacon_node/client/src/lib.rs +++ b/beacon_node/client/src/lib.rs @@ -1,5 +1,3 @@ -extern crate slog; - mod compute_light_client_updates; pub mod config; mod metrics; diff --git a/beacon_node/eth1/src/lib.rs b/beacon_node/eth1/src/lib.rs index 3b288de4901..9d6cb7c8478 100644 --- a/beacon_node/eth1/src/lib.rs +++ b/beacon_node/eth1/src/lib.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate lazy_static; - mod block_cache; mod deposit_cache; mod inner; diff --git a/beacon_node/eth1/src/metrics.rs b/beacon_node/eth1/src/metrics.rs index 5441b40d7e9..ad94d42ecb9 100644 --- a/beacon_node/eth1/src/metrics.rs +++ b/beacon_node/eth1/src/metrics.rs @@ -1,5 +1,7 @@ pub use lighthouse_metrics::*; +use lazy_static::lazy_static; + lazy_static! { /* * Eth1 blocks diff --git a/beacon_node/execution_layer/src/versioned_hashes.rs b/beacon_node/execution_layer/src/versioned_hashes.rs index 37bd35646d9..9bf87596b41 100644 --- a/beacon_node/execution_layer/src/versioned_hashes.rs +++ b/beacon_node/execution_layer/src/versioned_hashes.rs @@ -1,5 +1,3 @@ -extern crate alloy_consensus; -extern crate alloy_rlp; use alloy_consensus::TxEnvelope; use alloy_rlp::Decodable; use types::{EthSpec, ExecutionPayloadRef, Hash256, Unsigned, VersionedHash}; diff --git a/beacon_node/lighthouse_network/src/lib.rs b/beacon_node/lighthouse_network/src/lib.rs index 264795844a0..0b827164fc4 100644 --- a/beacon_node/lighthouse_network/src/lib.rs +++ b/beacon_node/lighthouse_network/src/lib.rs @@ -2,9 +2,6 @@ /// all required libp2p functionality. /// /// This crate builds and manages the libp2p services required by the beacon node. -#[macro_use] -extern crate lazy_static; - mod config; pub mod service; diff --git a/beacon_node/lighthouse_network/src/metrics.rs b/beacon_node/lighthouse_network/src/metrics.rs index fc441f25339..8efed44eb4f 100644 --- a/beacon_node/lighthouse_network/src/metrics.rs +++ b/beacon_node/lighthouse_network/src/metrics.rs @@ -1,5 +1,7 @@ pub use lighthouse_metrics::*; +use lazy_static::lazy_static; + lazy_static! { pub static ref NAT_OPEN: Result = try_create_int_gauge_vec( "nat_open", diff --git a/beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs index ba9bd314722..8187dc4ba4e 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs @@ -6,6 +6,7 @@ //! //! The scoring algorithms are currently experimental. use crate::service::gossipsub_scoring_parameters::GREYLIST_THRESHOLD as GOSSIPSUB_GREYLIST_THRESHOLD; +use lazy_static::lazy_static; use serde::Serialize; use std::time::Instant; use strum::AsRefStr; diff --git a/beacon_node/lighthouse_network/src/rpc/protocol.rs b/beacon_node/lighthouse_network/src/rpc/protocol.rs index 12a7f09338e..bfaaef9b3bd 100644 --- a/beacon_node/lighthouse_network/src/rpc/protocol.rs +++ b/beacon_node/lighthouse_network/src/rpc/protocol.rs @@ -3,6 +3,7 @@ use crate::rpc::codec::{base::BaseInboundCodec, ssz_snappy::SSZSnappyInboundCode use futures::future::BoxFuture; use futures::prelude::{AsyncRead, AsyncWrite}; use futures::{FutureExt, StreamExt}; +use lazy_static::lazy_static; use libp2p::core::{InboundUpgrade, UpgradeInfo}; use ssz::Encode; use ssz_types::VariableList; diff --git a/beacon_node/network/src/lib.rs b/beacon_node/network/src/lib.rs index da64368b16d..1149e6e6e38 100644 --- a/beacon_node/network/src/lib.rs +++ b/beacon_node/network/src/lib.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate lazy_static; - /// This crate provides the network server for Lighthouse. pub mod error; #[allow(clippy::mutable_key_type)] // PeerId in hashmaps are no longer permitted by clippy diff --git a/beacon_node/network/src/metrics.rs b/beacon_node/network/src/metrics.rs index bf4cbd09ab5..32e57da8ae0 100644 --- a/beacon_node/network/src/metrics.rs +++ b/beacon_node/network/src/metrics.rs @@ -5,6 +5,7 @@ use beacon_chain::{ sync_committee_verification::Error as SyncCommitteeError, }; use fnv::FnvHashMap; +use lazy_static::lazy_static; pub use lighthouse_metrics::*; use lighthouse_network::{ peer_manager::peerdb::client::ClientKind, types::GossipKind, GossipTopic, Gossipsub, diff --git a/beacon_node/src/lib.rs b/beacon_node/src/lib.rs index 4ca084c3165..ab400d2e730 100644 --- a/beacon_node/src/lib.rs +++ b/beacon_node/src/lib.rs @@ -1,5 +1,3 @@ -extern crate clap; - mod cli; mod config; diff --git a/beacon_node/store/src/lib.rs b/beacon_node/store/src/lib.rs index 66032d89c52..0247bea5541 100644 --- a/beacon_node/store/src/lib.rs +++ b/beacon_node/store/src/lib.rs @@ -7,9 +7,6 @@ //! //! Provides a simple API for storing/retrieving all types that sometimes needs type-hints. See //! tests for implementation examples. -#[macro_use] -extern crate lazy_static; - mod chunk_writer; pub mod chunked_iter; pub mod chunked_vector; diff --git a/beacon_node/store/src/metrics.rs b/beacon_node/store/src/metrics.rs index 2d901fdd932..1e614036ea6 100644 --- a/beacon_node/store/src/metrics.rs +++ b/beacon_node/store/src/metrics.rs @@ -1,6 +1,7 @@ pub use lighthouse_metrics::{set_gauge, try_create_int_gauge, *}; use directory::size_of_dir; +use lazy_static::lazy_static; use std::path::Path; lazy_static! { diff --git a/common/compare_fields_derive/src/lib.rs b/common/compare_fields_derive/src/lib.rs index 01c5a8f6ef8..1a89ccf4fdf 100644 --- a/common/compare_fields_derive/src/lib.rs +++ b/common/compare_fields_derive/src/lib.rs @@ -1,5 +1,3 @@ -extern crate proc_macro; - use proc_macro::TokenStream; use quote::quote; use syn::{parse_macro_input, DeriveInput}; diff --git a/common/eth2_interop_keypairs/src/lib.rs b/common/eth2_interop_keypairs/src/lib.rs index 3031e1c4dc1..34c3d6f87c9 100644 --- a/common/eth2_interop_keypairs/src/lib.rs +++ b/common/eth2_interop_keypairs/src/lib.rs @@ -16,11 +16,9 @@ //! //! This implementation passes the [reference implementation //! tests](https://github.com/ethereum/eth2.0-pm/blob/6e41fcf383ebeb5125938850d8e9b4e9888389b4/interop/mocked_start/keygen_test_vector.yaml). -#[macro_use] -extern crate lazy_static; - use bls::{Keypair, PublicKey, SecretKey}; use ethereum_hashing::hash; +use lazy_static::lazy_static; use num_bigint::BigUint; use serde::{Deserialize, Serialize}; use std::fs::File; diff --git a/common/lighthouse_metrics/src/lib.rs b/common/lighthouse_metrics/src/lib.rs index 5d25bb313f6..4a76184b8a8 100644 --- a/common/lighthouse_metrics/src/lib.rs +++ b/common/lighthouse_metrics/src/lib.rs @@ -20,8 +20,7 @@ //! ## Example //! //! ```rust -//! #[macro_use] -//! extern crate lazy_static; +//! use lazy_static::lazy_static; //! use lighthouse_metrics::*; //! //! // These metrics are "magically" linked to the global registry defined in `lighthouse_metrics`. diff --git a/common/logging/src/lib.rs b/common/logging/src/lib.rs index b0e1da00e97..50d04fc088f 100644 --- a/common/logging/src/lib.rs +++ b/common/logging/src/lib.rs @@ -1,6 +1,4 @@ -#[macro_use] -extern crate lazy_static; - +use lazy_static::lazy_static; use lighthouse_metrics::{ inc_counter, try_create_int_counter, IntCounter, Result as MetricsResult, }; diff --git a/common/logging/src/tracing_metrics_layer.rs b/common/logging/src/tracing_metrics_layer.rs index 08c323ee890..b9dde584b4c 100644 --- a/common/logging/src/tracing_metrics_layer.rs +++ b/common/logging/src/tracing_metrics_layer.rs @@ -1,5 +1,6 @@ //! Exposes [`MetricsLayer`]: A tracing layer that registers metrics of logging events. +use lazy_static::lazy_static; use lighthouse_metrics as metrics; use tracing_log::NormalizeEvent; diff --git a/common/slot_clock/src/lib.rs b/common/slot_clock/src/lib.rs index 4f54b2ee76b..a742e29457d 100644 --- a/common/slot_clock/src/lib.rs +++ b/common/slot_clock/src/lib.rs @@ -1,6 +1,3 @@ -#[macro_use] -extern crate lazy_static; - mod manual_slot_clock; mod metrics; mod system_time_slot_clock; diff --git a/common/slot_clock/src/metrics.rs b/common/slot_clock/src/metrics.rs index 23a793b2034..ae3a9b599ff 100644 --- a/common/slot_clock/src/metrics.rs +++ b/common/slot_clock/src/metrics.rs @@ -1,4 +1,5 @@ use crate::SlotClock; +use lazy_static::lazy_static; pub use lighthouse_metrics::*; use types::{EthSpec, Slot}; diff --git a/common/test_random_derive/src/lib.rs b/common/test_random_derive/src/lib.rs index 648c20121af..8c4b1ef7c35 100644 --- a/common/test_random_derive/src/lib.rs +++ b/common/test_random_derive/src/lib.rs @@ -1,6 +1,4 @@ -extern crate proc_macro; - -use crate::proc_macro::TokenStream; +use proc_macro::TokenStream; use quote::quote; use syn::{parse_macro_input, DeriveInput}; diff --git a/consensus/types/src/beacon_state/committee_cache/tests.rs b/consensus/types/src/beacon_state/committee_cache/tests.rs index a2274765691..4dc06feab38 100644 --- a/consensus/types/src/beacon_state/committee_cache/tests.rs +++ b/consensus/types/src/beacon_state/committee_cache/tests.rs @@ -2,6 +2,7 @@ use crate::test_utils::*; use beacon_chain::test_utils::{BeaconChainHarness, EphemeralHarnessType}; use beacon_chain::types::*; +use lazy_static::lazy_static; use swap_or_not_shuffle::shuffle_list; pub const VALIDATOR_COUNT: usize = 16; diff --git a/consensus/types/src/beacon_state/tests.rs b/consensus/types/src/beacon_state/tests.rs index 38a76e44c50..16c7ff152fe 100644 --- a/consensus/types/src/beacon_state/tests.rs +++ b/consensus/types/src/beacon_state/tests.rs @@ -6,6 +6,7 @@ use beacon_chain::types::{ ChainSpec, Domain, Epoch, EthSpec, Hash256, Keypair, MainnetEthSpec, MinimalEthSpec, RelativeEpoch, Slot, Vector, }; +use lazy_static::lazy_static; use ssz::Encode; use std::ops::Mul; use swap_or_not_shuffle::compute_shuffled_index; diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index c170b6b70d5..db429095d89 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -9,8 +9,6 @@ ) )] -#[macro_use] -extern crate lazy_static; #[macro_use] pub mod test_utils; diff --git a/consensus/types/src/subnet_id.rs b/consensus/types/src/subnet_id.rs index 9b6a2e6a192..7f6ed45ad88 100644 --- a/consensus/types/src/subnet_id.rs +++ b/consensus/types/src/subnet_id.rs @@ -1,5 +1,6 @@ //! Identifies each shard by an integer identifier. use crate::{AttestationData, ChainSpec, CommitteeIndex, Epoch, EthSpec, Slot}; +use lazy_static::lazy_static; use safe_arith::{ArithError, SafeArith}; use serde::{Deserialize, Serialize}; use std::ops::{Deref, DerefMut}; diff --git a/consensus/types/src/sync_subnet_id.rs b/consensus/types/src/sync_subnet_id.rs index dd0807f21ce..00fb910bdad 100644 --- a/consensus/types/src/sync_subnet_id.rs +++ b/consensus/types/src/sync_subnet_id.rs @@ -1,6 +1,7 @@ //! Identifies each sync committee subnet by an integer identifier. use crate::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT; use crate::EthSpec; +use lazy_static::lazy_static; use safe_arith::{ArithError, SafeArith}; use serde::{Deserialize, Serialize}; use ssz_types::typenum::Unsigned; diff --git a/lcli/src/block_root.rs b/lcli/src/block_root.rs index 0ee304c8a58..a90a4843d8a 100644 --- a/lcli/src/block_root.rs +++ b/lcli/src/block_root.rs @@ -32,6 +32,7 @@ use clap_utils::{parse_optional, parse_required}; use environment::Environment; use eth2::{types::BlockId, BeaconNodeHttpClient, SensitiveUrl, Timeouts}; use eth2_network_config::Eth2NetworkConfig; +use log::info; use std::path::PathBuf; use std::time::{Duration, Instant}; use types::{EthSpec, FullPayload, SignedBeaconBlock}; diff --git a/lcli/src/main.rs b/lcli/src/main.rs index 911e9bdcac5..85898b60ee4 100644 --- a/lcli/src/main.rs +++ b/lcli/src/main.rs @@ -1,5 +1,3 @@ -#[macro_use] -extern crate log; mod block_root; mod check_deposit_data; mod generate_bootnode_enr; diff --git a/lcli/src/parse_ssz.rs b/lcli/src/parse_ssz.rs index 3aa77e57003..dd13f6847b4 100644 --- a/lcli/src/parse_ssz.rs +++ b/lcli/src/parse_ssz.rs @@ -1,6 +1,7 @@ use clap::ArgMatches; use clap_utils::parse_required; use eth2_network_config::Eth2NetworkConfig; +use log::info; use serde::Serialize; use snap::raw::Decoder; use ssz::Decode; diff --git a/lcli/src/skip_slots.rs b/lcli/src/skip_slots.rs index a2173f10df0..2ad79051ea4 100644 --- a/lcli/src/skip_slots.rs +++ b/lcli/src/skip_slots.rs @@ -50,6 +50,7 @@ use clap_utils::{parse_optional, parse_required}; use environment::Environment; use eth2::{types::StateId, BeaconNodeHttpClient, SensitiveUrl, Timeouts}; use eth2_network_config::Eth2NetworkConfig; +use log::info; use ssz::Encode; use state_processing::state_advance::{complete_state_advance, partial_state_advance}; use state_processing::AllCaches; diff --git a/lcli/src/state_root.rs b/lcli/src/state_root.rs index 06293b79b3d..17a947b2f00 100644 --- a/lcli/src/state_root.rs +++ b/lcli/src/state_root.rs @@ -4,6 +4,7 @@ use clap_utils::{parse_optional, parse_required}; use environment::Environment; use eth2::{types::StateId, BeaconNodeHttpClient, SensitiveUrl, Timeouts}; use eth2_network_config::Eth2NetworkConfig; +use log::info; use std::path::PathBuf; use std::time::{Duration, Instant}; use types::{BeaconState, EthSpec}; diff --git a/lcli/src/transition_blocks.rs b/lcli/src/transition_blocks.rs index ba0c2efa512..5a450fed774 100644 --- a/lcli/src/transition_blocks.rs +++ b/lcli/src/transition_blocks.rs @@ -72,6 +72,7 @@ use eth2::{ BeaconNodeHttpClient, SensitiveUrl, Timeouts, }; use eth2_network_config::Eth2NetworkConfig; +use log::{debug, info}; use ssz::Encode; use state_processing::state_advance::complete_state_advance; use state_processing::{ diff --git a/testing/simulator/src/main.rs b/testing/simulator/src/main.rs index 03ee902c770..a259ac11339 100644 --- a/testing/simulator/src/main.rs +++ b/testing/simulator/src/main.rs @@ -10,9 +10,6 @@ //! simulation uses `println` to communicate some info. It might be nice if the nodes logged to //! easy-to-find files and stdout only contained info from the simulation. //! - -extern crate clap; - mod basic_sim; mod checks; mod cli;