From d7377d479479d3a4728dd80a476b5390b8b1c294 Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Mon, 13 Dec 2021 08:48:39 -0700 Subject: [PATCH] Revert "Reformat imports to a consistent style for imports" This reverts commit 139d15cd846b73f3e956e7a26269a586cefde71b. --- account-decoder/src/lib.rs | 12 +- account-decoder/src/parse_account_data.rs | 40 ++- account-decoder/src/parse_bpf_loader.rs | 16 +- account-decoder/src/parse_config.rs | 29 +- account-decoder/src/parse_nonce.rs | 26 +- account-decoder/src/parse_stake.rs | 19 +- account-decoder/src/parse_sysvar.rs | 42 ++- account-decoder/src/parse_token.rs | 24 +- account-decoder/src/parse_vote.rs | 15 +- accounts-bench/src/main.rs | 22 +- accounts-cluster-bench/src/main.rs | 78 +++-- .../src/accountsdb_plugin_postgres.rs | 1 + banking-bench/src/main.rs | 65 ++-- banks-client/src/lib.rs | 79 +++-- banks-interface/src/lib.rs | 28 +- banks-server/src/banks_server.rs | 80 +++-- banks-server/src/rpc_banks_service.rs | 33 +- banks-server/src/send_transaction_service.rs | 38 ++- bench-exchange/src/bench.rs | 74 +++-- bench-exchange/src/cli.rs | 14 +- bench-exchange/src/main.rs | 12 +- bench-exchange/src/order_book.rs | 18 +- bench-exchange/tests/bench_exchange.rs | 38 ++- bench-streamer/src/main.rs | 30 +- bench-tps/src/bench.rs | 76 +++-- bench-tps/src/cli.rs | 16 +- bench-tps/src/main.rs | 26 +- bench-tps/tests/bench_tps.rs | 38 ++- clap-utils/src/input_parsers.rs | 10 +- clap-utils/src/input_validators.rs | 3 +- clap-utils/src/keypair.rs | 16 +- cli-config/src/config.rs | 8 +- cli-config/src/lib.rs | 1 + cli-output/src/cli_output.rs | 18 +- cli-output/src/display.rs | 6 +- cli/src/checks.rs | 34 +-- cli/src/clap_app.rs | 14 +- cli/src/cli.rs | 104 +++---- cli/src/cluster_query.rs | 158 +++++----- cli/src/feature.rs | 52 ++-- cli/src/inflation.rs | 28 +- cli/src/main.rs | 32 +- cli/src/memo.rs | 7 +- cli/src/nonce.rs | 100 +++--- cli/src/program.rs | 119 ++++---- cli/src/spend_utils.rs | 22 +- cli/src/stake.rs | 116 ++++--- cli/src/test_utils.rs | 8 +- cli/src/validator_info.rs | 66 ++-- cli/src/vote.rs | 68 ++--- cli/src/wallet.rs | 82 +++-- cli/tests/nonce.rs | 42 ++- cli/tests/program.rs | 38 ++- cli/tests/request_airdrop.rs | 18 +- cli/tests/stake.rs | 54 ++-- cli/tests/transfer.rs | 42 ++- cli/tests/vote.rs | 36 ++- client/src/blockhash_query.rs | 22 +- client/src/client_error.rs | 5 +- client/src/rpc_client.rs | 29 +- client/src/rpc_custom_error.rs | 2 +- client/src/rpc_request.rs | 8 +- client/src/thin_client.rs | 3 +- client/src/tpu_client.rs | 62 ++-- core/benches/banking_stage.rs | 69 +++-- core/benches/blockstore.rs | 18 +- core/benches/consensus.rs | 19 +- core/benches/gen_keys.rs | 3 +- core/benches/shredder.rs | 27 +- core/benches/sigverify_stage.rs | 32 +- core/src/accounts_hash_verifier.rs | 60 ++-- core/src/banking_stage.rs | 191 ++++++------ core/src/broadcast_stage.rs | 43 ++- .../broadcast_fake_shreds_run.rs | 20 +- core/src/broadcast_stage/broadcast_utils.rs | 35 +-- .../broadcast_stage/standard_broadcast_run.rs | 28 +- core/src/cluster_info_vote_listener.rs | 131 ++++---- core/src/cluster_slot_state_verifier.rs | 28 +- core/src/cluster_slots.rs | 3 +- core/src/cluster_slots_service.rs | 28 +- core/src/commitment_service.rs | 66 ++-- core/src/completed_data_sets_service.rs | 38 +-- core/src/consensus.rs | 154 +++++----- core/src/cost_update_service.rs | 31 +- core/src/drop_bank_service.rs | 12 +- core/src/fetch_stage.rs | 33 +- core/src/fork_choice.rs | 22 +- core/src/gen_keys.rs | 14 +- core/src/heaviest_subtree_fork_choice.rs | 54 ++-- ...latest_validator_votes_for_frozen_banks.rs | 8 +- core/src/ledger_cleanup_service.rs | 40 +-- core/src/optimistic_confirmation_verifier.rs | 24 +- core/src/outstanding_requests.rs | 18 +- core/src/progress_map.rs | 26 +- core/src/repair_response.rs | 34 +-- core/src/repair_service.rs | 101 +++--- core/src/repair_weight.rs | 40 ++- core/src/repair_weighted_traversal.rs | 28 +- core/src/replay_stage.rs | 239 +++++++-------- core/src/result.rs | 23 +- core/src/retransmit_stage.rs | 3 +- core/src/rewards_recorder_service.rs | 24 +- core/src/sample_performance_service.rs | 18 +- core/src/serve_repair.rs | 106 +++---- core/src/serve_repair_service.rs | 20 +- core/src/shred_fetch_stage.rs | 42 ++- core/src/sigverify.rs | 9 +- core/src/sigverify_shreds.rs | 38 +-- core/src/sigverify_stage.rs | 29 +- core/src/snapshot_packager_service.rs | 54 ++-- core/src/system_monitor_service.rs | 1 + core/src/tpu.rs | 62 ++-- core/src/tvu.rs | 140 +++++---- .../unfrozen_gossip_verified_vote_hashes.rs | 8 +- core/src/validator.rs | 16 +- core/src/verified_vote_packets.rs | 26 +- core/src/vote_stake_tracker.rs | 6 +- core/src/voting_service.rs | 16 +- core/src/window_service.rs | 9 +- core/tests/client.rs | 82 +++-- core/tests/fork-selection.rs | 6 +- core/tests/ledger_cleanup.rs | 36 +-- core/tests/rpc.rs | 77 +++-- core/tests/snapshots.rs | 75 +++-- dos/src/main.rs | 31 +- download-utils/src/lib.rs | 25 +- faucet/src/faucet.rs | 4 +- faucet/tests/local-faucet.rs | 16 +- frozen-abi/src/abi_digester.rs | 25 +- frozen-abi/src/abi_example.rs | 12 +- frozen-abi/src/hash.rs | 6 +- genesis-utils/src/lib.rs | 14 +- genesis/src/genesis_accounts.rs | 10 +- genesis/src/main.rs | 89 +++--- genesis/src/stakes.rs | 3 +- genesis/src/unlocks.rs | 6 +- gossip/src/cluster_info.rs | 12 +- gossip/src/crds_value.rs | 4 +- gossip/src/duplicate_shred.rs | 16 +- gossip/src/gossip_service.rs | 5 +- gossip/src/weighted_shuffle.rs | 6 +- gossip/tests/gossip.rs | 12 +- install/src/command.rs | 33 +- install/src/config.rs | 8 +- install/src/stop_process.rs | 23 +- keygen/src/keygen.rs | 64 ++-- ledger-tool/src/main.rs | 5 +- ledger-tool/tests/basic.rs | 10 +- ledger/benches/protobuf.rs | 22 +- ledger/benches/sigverify_shreds.rs | 21 +- ledger/src/ancestor_iterator.rs | 10 +- ledger/src/bank_forks_utils.rs | 32 +- ledger/src/bigtable_upload.rs | 24 +- ledger/src/blockstore.rs | 48 ++- ledger/src/blockstore/blockstore_purge.rs | 23 +- ledger/src/blockstore_db.rs | 69 ++--- ledger/src/blockstore_meta.rs | 18 +- ledger/src/blockstore_processor.rs | 173 +++++------ ledger/src/builtins.rs | 10 +- ledger/src/entry.rs | 86 +++--- ledger/src/erasure.rs | 11 +- ledger/src/leader_schedule.rs | 19 +- ledger/src/leader_schedule_cache.rs | 73 ++--- ledger/src/leader_schedule_utils.rs | 23 +- ledger/src/next_slots_iterator.rs | 14 +- ledger/src/poh.rs | 18 +- ledger/src/rooted_slot_iterator.rs | 16 +- ledger/src/shred.rs | 21 +- ledger/src/sigverify_shreds.rs | 55 ++-- ledger/src/staking_utils.rs | 62 ++-- ledger/tests/blockstore.rs | 14 +- ledger/tests/shred.rs | 34 +-- local-cluster/src/cluster.rs | 17 +- local-cluster/src/cluster_tests.rs | 67 ++-- local-cluster/src/local_cluster.rs | 100 +++--- local-cluster/src/validator_configs.rs | 8 +- local-cluster/tests/local_cluster.rs | 147 +++++---- log-analyzer/src/main.rs | 14 +- logger/src/lib.rs | 6 +- measure/src/measure.rs | 13 +- merkle-root-bench/src/main.rs | 10 +- metrics/src/counter.rs | 16 +- metrics/src/lib.rs | 1 + net-shaper/src/main.rs | 16 +- net-utils/src/bin/ip_address_server.rs | 6 +- net-utils/src/lib.rs | 13 +- notifier/src/lib.rs | 8 +- perf/benches/recycler.rs | 7 +- perf/benches/sigverify.rs | 9 +- perf/src/cuda_runtime.rs | 27 +- perf/src/packet.rs | 22 +- perf/src/perf_libs.rs | 26 +- perf/src/recycler.rs | 15 +- perf/src/recycler_cache.rs | 4 +- perf/src/sigverify.rs | 75 ++--- perf/src/test_tx.rs | 20 +- poh-bench/src/main.rs | 10 +- poh/src/poh_recorder.rs | 2 +- program-test/src/lib.rs | 13 +- program-test/tests/builtins.rs | 13 +- program-test/tests/fuzz.rs | 11 +- programs/bpf_loader/benches/serialization.rs | 21 +- programs/bpf_loader/src/allocator_bump.rs | 11 +- programs/bpf_loader/src/bpf_verifier.rs | 4 +- programs/bpf_loader/src/lib.rs | 136 ++++----- programs/bpf_loader/src/serialization.rs | 47 ++- programs/bpf_loader/src/syscalls.rs | 128 ++++---- programs/config/src/config_instruction.rs | 13 +- programs/config/src/config_processor.rs | 48 ++- programs/config/src/date_instruction.rs | 14 +- programs/config/src/lib.rs | 19 +- programs/ed25519/src/lib.rs | 18 +- programs/exchange/src/exchange_instruction.rs | 13 +- programs/exchange/src/exchange_processor.rs | 57 ++-- programs/exchange/src/exchange_state.rs | 8 +- programs/secp256k1/src/lib.rs | 20 +- programs/stake/src/config.rs | 25 +- programs/stake/src/lib.rs | 1 + programs/stake/src/stake_instruction.rs | 43 ++- programs/stake/src/stake_state.rs | 35 ++- programs/vote/src/authorized_voters.rs | 10 +- programs/vote/src/vote_instruction.rs | 61 ++-- programs/vote/src/vote_state/mod.rs | 61 ++-- .../src/vote_state/vote_state_versions.rs | 3 +- programs/vote/src/vote_transaction.rs | 28 +- rpc/src/rpc.rs | 6 +- rpc/src/rpc_health.rs | 6 +- rpc/src/rpc_pubsub_service.rs | 10 +- rpc/src/rpc_service.rs | 12 +- rpc/src/rpc_subscription_tracker.rs | 12 +- rpc/src/rpc_subscriptions.rs | 3 +- runtime/benches/accounts.rs | 48 ++- runtime/benches/accounts_index.rs | 14 +- runtime/benches/append_vec.rs | 25 +- runtime/benches/bank.rs | 31 +- runtime/benches/bloom.rs | 21 +- runtime/benches/message_processor.rs | 10 +- runtime/benches/status_cache.rs | 14 +- runtime/src/accounts.rs | 123 ++++---- runtime/src/accounts_background_service.rs | 56 ++-- runtime/src/accounts_cache.rs | 30 +- runtime/src/accounts_db.rs | 152 +++++---- runtime/src/accounts_hash.rs | 19 +- runtime/src/accounts_index.rs | 66 ++-- runtime/src/ancestors.rs | 13 +- runtime/src/append_vec.rs | 65 ++-- runtime/src/bank.rs | 288 +++++++++--------- runtime/src/bank_client.rs | 56 ++-- runtime/src/bank_forks.rs | 59 ++-- runtime/src/bank_utils.rs | 16 +- runtime/src/block_cost_limits.rs | 10 +- runtime/src/blockhash_queue.rs | 20 +- runtime/src/bloom.rs | 29 +- runtime/src/builtins.rs | 22 +- runtime/src/commitment.rs | 8 +- runtime/src/cost_model.rs | 48 ++- runtime/src/cost_tracker.rs | 33 +- runtime/src/epoch_stakes.rs | 18 +- runtime/src/execute_cost_table.rs | 3 +- runtime/src/genesis_utils.rs | 31 +- runtime/src/hardened_unpack.rs | 11 +- runtime/src/hashed_transaction.rs | 6 +- runtime/src/instruction_recorder.rs | 11 +- runtime/src/loader_utils.rs | 22 +- runtime/src/message_processor.rs | 86 +++--- runtime/src/native_loader.rs | 40 ++- runtime/src/non_circulating_supply.rs | 17 +- runtime/src/read_only_accounts_cache.rs | 23 +- runtime/src/rent_collector.rs | 3 +- runtime/src/secondary_index.rs | 18 +- runtime/src/serde_snapshot.rs | 21 +- runtime/src/serde_snapshot/common.rs | 3 +- runtime/src/serde_snapshot/future.rs | 10 +- runtime/src/snapshot_package.rs | 21 +- runtime/src/snapshot_utils.rs | 13 +- runtime/src/sorted_storages.rs | 9 +- runtime/src/stake_weighted_timestamp.rs | 6 +- runtime/src/stakes.rs | 48 ++- runtime/src/status_cache.rs | 31 +- runtime/src/system_instruction_processor.rs | 75 +++-- runtime/src/transaction_batch.rs | 17 +- runtime/src/vote_account.rs | 44 ++- runtime/src/vote_sender_types.rs | 8 +- runtime/store-tool/src/main.rs | 8 +- runtime/tests/accounts.rs | 38 +-- runtime/tests/bank.rs | 8 +- runtime/tests/stake.rs | 48 ++- scripts/src/csv_to_validator_infos.rs | 8 +- sdk/benches/serialize_instructions.rs | 16 +- sdk/benches/short_vec.rs | 4 +- sdk/benches/slot_hashes.rs | 12 +- sdk/benches/slot_history.rs | 10 +- sdk/cargo-build-bpf/src/main.rs | 3 +- sdk/cargo-test-bpf/src/main.rs | 19 +- sdk/macro/src/lib.rs | 24 +- sdk/program/src/account_info.rs | 12 +- sdk/program/src/bpf_loader_upgradeable.rs | 14 +- sdk/program/src/decode_error.rs | 3 +- sdk/program/src/entrypoint.rs | 26 +- sdk/program/src/entrypoint_deprecated.rs | 19 +- sdk/program/src/feature.rs | 3 +- sdk/program/src/fee_calculator.rs | 15 +- sdk/program/src/hash.rs | 12 +- sdk/program/src/instruction.rs | 13 +- sdk/program/src/keccak.rs | 12 +- sdk/program/src/lamports.rs | 3 +- sdk/program/src/message.rs | 36 +-- sdk/program/src/nonce/state/current.rs | 8 +- sdk/program/src/nonce/state/mod.rs | 1 + sdk/program/src/program_error.rs | 12 +- sdk/program/src/program_stubs.rs | 12 +- sdk/program/src/pubkey.rs | 3 +- sdk/program/src/secp256k1_recover.rs | 8 +- sdk/program/src/serialize_utils.rs | 3 +- sdk/program/src/short_vec.rs | 20 +- sdk/program/src/slot_hashes.rs | 9 +- sdk/program/src/slot_history.rs | 6 +- sdk/program/src/stake/instruction.rs | 13 +- sdk/program/src/stake_history.rs | 1 + sdk/program/src/system_instruction.rs | 28 +- sdk/program/src/sysvar/clock.rs | 1 + sdk/program/src/sysvar/epoch_schedule.rs | 1 + sdk/program/src/sysvar/instructions.rs | 6 +- sdk/program/src/sysvar/mod.rs | 8 +- sdk/program/src/sysvar/recent_blockhashes.rs | 17 +- sdk/program/src/sysvar/rent.rs | 1 + sdk/program/src/sysvar/slot_hashes.rs | 7 +- sdk/program/src/sysvar/slot_history.rs | 3 +- sdk/program/src/sysvar/stake_history.rs | 4 +- sdk/src/account.rs | 19 +- sdk/src/account_utils.rs | 17 +- sdk/src/commitment_config.rs | 3 +- sdk/src/compute_budget.rs | 30 +- sdk/src/derivation_path.rs | 3 +- sdk/src/deserialize_utils.rs | 3 +- sdk/src/ed25519_instruction.rs | 10 +- sdk/src/feature_set.rs | 14 +- sdk/src/genesis_config.rs | 65 ++-- sdk/src/hard_forks.rs | 6 +- sdk/src/keyed_account.rs | 32 +- sdk/src/native_loader.rs | 8 +- sdk/src/nonce_account.rs | 19 +- sdk/src/nonce_keyed_account.rs | 56 ++-- sdk/src/packet.rs | 14 +- sdk/src/poh_config.rs | 6 +- sdk/src/process_instruction.rs | 18 +- sdk/src/program_utils.rs | 3 +- sdk/src/pubkey.rs | 3 +- sdk/src/recent_blockhashes_account.rs | 36 +-- sdk/src/secp256k1_instruction.rs | 8 +- sdk/src/signature.rs | 21 +- sdk/src/signer/mod.rs | 3 +- sdk/src/signer/presigner.rs | 3 +- sdk/src/timing.rs | 10 +- sdk/src/transaction.rs | 57 ++-- sdk/src/transport.rs | 4 +- stake-accounts/src/arg_parser.rs | 25 +- stake-accounts/src/args.rs | 19 +- stake-accounts/src/main.rs | 38 ++- stake-accounts/src/stake_accounts.rs | 20 +- storage-bigtable/src/access_token.rs | 3 +- storage-bigtable/src/bigtable.rs | 18 +- storage-proto/src/convert.rs | 6 +- streamer/src/packet.rs | 35 +-- streamer/src/recvmmsg.rs | 11 +- streamer/src/sendmmsg.rs | 18 +- streamer/src/streamer.rs | 60 ++-- streamer/tests/recvmmsg.rs | 12 +- sys-tuner/src/main.rs | 6 +- tokens/src/arg_parser.rs | 32 +- tokens/src/commands.rs | 122 ++++---- tokens/src/db.rs | 26 +- tokens/src/main.rs | 24 +- tokens/src/spl_token.rs | 32 +- tokens/src/token_display.rs | 12 +- tokens/tests/commands.rs | 12 +- upload-perf/src/upload-perf.rs | 16 +- validator/src/lib.rs | 5 +- validator/src/main.rs | 5 +- version/src/lib.rs | 8 +- 380 files changed, 5320 insertions(+), 6094 deletions(-) diff --git a/account-decoder/src/lib.rs b/account-decoder/src/lib.rs index 00f0b47543..c2e2b3d466 100644 --- a/account-decoder/src/lib.rs +++ b/account-decoder/src/lib.rs @@ -17,10 +17,8 @@ pub mod validator_info; use { crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount}, solana_sdk::{ - account::{ReadableAccount, WritableAccount}, - clock::Epoch, - fee_calculator::FeeCalculator, - pubkey::Pubkey, + account::ReadableAccount, account::WritableAccount, clock::Epoch, + fee_calculator::FeeCalculator, pubkey::Pubkey, }, std::{ io::{Read, Write}, @@ -204,10 +202,8 @@ fn slice_data(data: &[u8], data_slice_config: Option) -> &[u8 #[cfg(test)] mod test { - use { - super::*, - solana_sdk::account::{Account, AccountSharedData}, - }; + use super::*; + use solana_sdk::account::{Account, AccountSharedData}; #[test] fn test_slice_data() { diff --git a/account-decoder/src/parse_account_data.rs b/account-decoder/src/parse_account_data.rs index 35fff127e0..40993ee59d 100644 --- a/account-decoder/src/parse_account_data.rs +++ b/account-decoder/src/parse_account_data.rs @@ -1,19 +1,17 @@ -use { - crate::{ - parse_bpf_loader::parse_bpf_upgradeable_loader, - parse_config::parse_config, - parse_nonce::parse_nonce, - parse_stake::parse_stake, - parse_sysvar::parse_sysvar, - parse_token::{parse_token, spl_token_id}, - parse_vote::parse_vote, - }, - inflector::Inflector, - serde_json::Value, - solana_sdk::{instruction::InstructionError, pubkey::Pubkey, stake, system_program, sysvar}, - std::collections::HashMap, - thiserror::Error, +use crate::{ + parse_bpf_loader::parse_bpf_upgradeable_loader, + parse_config::parse_config, + parse_nonce::parse_nonce, + parse_stake::parse_stake, + parse_sysvar::parse_sysvar, + parse_token::{parse_token, spl_token_id}, + parse_vote::parse_vote, }; +use inflector::Inflector; +use serde_json::Value; +use solana_sdk::{instruction::InstructionError, pubkey::Pubkey, stake, system_program, sysvar}; +use std::collections::HashMap; +use thiserror::Error; lazy_static! { static ref BPF_UPGRADEABLE_LOADER_PROGRAM_ID: Pubkey = solana_sdk::bpf_loader_upgradeable::id(); @@ -114,14 +112,12 @@ pub fn parse_account_data( #[cfg(test)] mod test { - use { - super::*, - solana_sdk::nonce::{ - state::{Data, Versions}, - State, - }, - solana_vote_program::vote_state::{VoteState, VoteStateVersions}, + use super::*; + use solana_sdk::nonce::{ + state::{Data, Versions}, + State, }; + use solana_vote_program::vote_state::{VoteState, VoteStateVersions}; #[test] fn test_parse_account_data() { diff --git a/account-decoder/src/parse_bpf_loader.rs b/account-decoder/src/parse_bpf_loader.rs index 8eb9ac698c..d12753dcf7 100644 --- a/account-decoder/src/parse_bpf_loader.rs +++ b/account-decoder/src/parse_bpf_loader.rs @@ -1,11 +1,9 @@ -use { - crate::{ - parse_account_data::{ParsableAccount, ParseAccountError}, - UiAccountData, UiAccountEncoding, - }, - bincode::{deserialize, serialized_size}, - solana_sdk::{bpf_loader_upgradeable::UpgradeableLoaderState, pubkey::Pubkey}, +use crate::{ + parse_account_data::{ParsableAccount, ParseAccountError}, + UiAccountData, UiAccountEncoding, }; +use bincode::{deserialize, serialized_size}; +use solana_sdk::{bpf_loader_upgradeable::UpgradeableLoaderState, pubkey::Pubkey}; pub fn parse_bpf_upgradeable_loader( data: &[u8], @@ -92,7 +90,9 @@ pub struct UiProgramData { #[cfg(test)] mod test { - use {super::*, bincode::serialize, solana_sdk::pubkey::Pubkey}; + use super::*; + use bincode::serialize; + use solana_sdk::pubkey::Pubkey; #[test] fn test_parse_bpf_upgradeable_loader_accounts() { diff --git a/account-decoder/src/parse_config.rs b/account-decoder/src/parse_config.rs index ecdcdbf1e4..e4cdf2457e 100644 --- a/account-decoder/src/parse_config.rs +++ b/account-decoder/src/parse_config.rs @@ -1,16 +1,12 @@ -use { - crate::{ - parse_account_data::{ParsableAccount, ParseAccountError}, - validator_info, - }, - bincode::deserialize, - serde_json::Value, - solana_config_program::{get_config_data, ConfigKeys}, - solana_sdk::{ - pubkey::Pubkey, - stake::config::{self as stake_config, Config as StakeConfig}, - }, +use crate::{ + parse_account_data::{ParsableAccount, ParseAccountError}, + validator_info, }; +use bincode::deserialize; +use serde_json::Value; +use solana_config_program::{get_config_data, ConfigKeys}; +use solana_sdk::pubkey::Pubkey; +use solana_sdk::stake::config::{self as stake_config, Config as StakeConfig}; pub fn parse_config(data: &[u8], pubkey: &Pubkey) -> Result { let parsed_account = if pubkey == &stake_config::id() { @@ -91,10 +87,11 @@ pub struct UiConfig { #[cfg(test)] mod test { - use { - super::*, crate::validator_info::ValidatorInfo, serde_json::json, - solana_config_program::create_config_account, solana_sdk::account::ReadableAccount, - }; + use super::*; + use crate::validator_info::ValidatorInfo; + use serde_json::json; + use solana_config_program::create_config_account; + use solana_sdk::account::ReadableAccount; #[test] fn test_parse_config() { diff --git a/account-decoder/src/parse_nonce.rs b/account-decoder/src/parse_nonce.rs index d013a84f98..aaa305f658 100644 --- a/account-decoder/src/parse_nonce.rs +++ b/account-decoder/src/parse_nonce.rs @@ -1,9 +1,7 @@ -use { - crate::{parse_account_data::ParseAccountError, UiFeeCalculator}, - solana_sdk::{ - instruction::InstructionError, - nonce::{state::Versions, State}, - }, +use crate::{parse_account_data::ParseAccountError, UiFeeCalculator}; +use solana_sdk::{ + instruction::InstructionError, + nonce::{state::Versions, State}, }; pub fn parse_nonce(data: &[u8]) -> Result { @@ -44,16 +42,14 @@ pub struct UiNonceData { #[cfg(test)] mod test { - use { - super::*, - solana_sdk::{ - hash::Hash, - nonce::{ - state::{Data, Versions}, - State, - }, - pubkey::Pubkey, + use super::*; + use solana_sdk::{ + hash::Hash, + nonce::{ + state::{Data, Versions}, + State, }, + pubkey::Pubkey, }; #[test] diff --git a/account-decoder/src/parse_stake.rs b/account-decoder/src/parse_stake.rs index daafdc44f4..fa3d3def6a 100644 --- a/account-decoder/src/parse_stake.rs +++ b/account-decoder/src/parse_stake.rs @@ -1,14 +1,10 @@ -use { - crate::{ - parse_account_data::{ParsableAccount, ParseAccountError}, - StringAmount, - }, - bincode::deserialize, - solana_sdk::{ - clock::{Epoch, UnixTimestamp}, - stake::state::{Authorized, Delegation, Lockup, Meta, Stake, StakeState}, - }, +use crate::{ + parse_account_data::{ParsableAccount, ParseAccountError}, + StringAmount, }; +use bincode::deserialize; +use solana_sdk::clock::{Epoch, UnixTimestamp}; +use solana_sdk::stake::state::{Authorized, Delegation, Lockup, Meta, Stake, StakeState}; pub fn parse_stake(data: &[u8]) -> Result { let stake_state: StakeState = deserialize(data) @@ -136,7 +132,8 @@ impl From for UiDelegation { #[cfg(test)] mod test { - use {super::*, bincode::serialize}; + use super::*; + use bincode::serialize; #[test] fn test_parse_stake() { diff --git a/account-decoder/src/parse_sysvar.rs b/account-decoder/src/parse_sysvar.rs index 1a695d6398..b5bef681f7 100644 --- a/account-decoder/src/parse_sysvar.rs +++ b/account-decoder/src/parse_sysvar.rs @@ -1,20 +1,18 @@ -use { - crate::{ - parse_account_data::{ParsableAccount, ParseAccountError}, - StringAmount, UiFeeCalculator, - }, - bincode::deserialize, - bv::BitVec, - solana_sdk::{ - clock::{Clock, Epoch, Slot, UnixTimestamp}, - epoch_schedule::EpochSchedule, - pubkey::Pubkey, - rent::Rent, - slot_hashes::SlotHashes, - slot_history::{self, SlotHistory}, - stake_history::{StakeHistory, StakeHistoryEntry}, - sysvar::{self, fees::Fees, recent_blockhashes::RecentBlockhashes, rewards::Rewards}, - }, +use crate::{ + parse_account_data::{ParsableAccount, ParseAccountError}, + StringAmount, UiFeeCalculator, +}; +use bincode::deserialize; +use bv::BitVec; +use solana_sdk::{ + clock::{Clock, Epoch, Slot, UnixTimestamp}, + epoch_schedule::EpochSchedule, + pubkey::Pubkey, + rent::Rent, + slot_hashes::SlotHashes, + slot_history::{self, SlotHistory}, + stake_history::{StakeHistory, StakeHistoryEntry}, + sysvar::{self, fees::Fees, recent_blockhashes::RecentBlockhashes, rewards::Rewards}, }; pub fn parse_sysvar(data: &[u8], pubkey: &Pubkey) -> Result { @@ -214,12 +212,10 @@ pub struct UiStakeHistoryEntry { #[cfg(test)] mod test { - use { - super::*, - solana_sdk::{ - account::create_account_for_test, fee_calculator::FeeCalculator, hash::Hash, - sysvar::recent_blockhashes::IterItem, - }, + use super::*; + use solana_sdk::{ + account::create_account_for_test, fee_calculator::FeeCalculator, hash::Hash, + sysvar::recent_blockhashes::IterItem, }; #[test] diff --git a/account-decoder/src/parse_token.rs b/account-decoder/src/parse_token.rs index 80913ddf3d..2b31f07e8a 100644 --- a/account-decoder/src/parse_token.rs +++ b/account-decoder/src/parse_token.rs @@ -1,17 +1,15 @@ -use { - crate::{ - parse_account_data::{ParsableAccount, ParseAccountError}, - StringAmount, StringDecimals, - }, - solana_sdk::pubkey::Pubkey, - spl_token::{ - solana_program::{ - program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey, - }, - state::{Account, AccountState, Mint, Multisig}, - }, - std::str::FromStr, +use crate::{ + parse_account_data::{ParsableAccount, ParseAccountError}, + StringAmount, StringDecimals, }; +use solana_sdk::pubkey::Pubkey; +use spl_token::{ + solana_program::{ + program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey, + }, + state::{Account, AccountState, Mint, Multisig}, +}; +use std::str::FromStr; // A helper function to convert spl_token::id() as spl_sdk::pubkey::Pubkey to // solana_sdk::pubkey::Pubkey diff --git a/account-decoder/src/parse_vote.rs b/account-decoder/src/parse_vote.rs index b383b28390..a1aca278ee 100644 --- a/account-decoder/src/parse_vote.rs +++ b/account-decoder/src/parse_vote.rs @@ -1,11 +1,9 @@ -use { - crate::{parse_account_data::ParseAccountError, StringAmount}, - solana_sdk::{ - clock::{Epoch, Slot}, - pubkey::Pubkey, - }, - solana_vote_program::vote_state::{BlockTimestamp, Lockout, VoteState}, +use crate::{parse_account_data::ParseAccountError, StringAmount}; +use solana_sdk::{ + clock::{Epoch, Slot}, + pubkey::Pubkey, }; +use solana_vote_program::vote_state::{BlockTimestamp, Lockout, VoteState}; pub fn parse_vote(data: &[u8]) -> Result { let mut vote_state = VoteState::deserialize(data).map_err(ParseAccountError::from)?; @@ -123,7 +121,8 @@ struct UiEpochCredits { #[cfg(test)] mod test { - use {super::*, solana_vote_program::vote_state::VoteStateVersions}; + use super::*; + use solana_vote_program::vote_state::VoteStateVersions; #[test] fn test_parse_vote() { diff --git a/accounts-bench/src/main.rs b/accounts-bench/src/main.rs index 17f32f59d4..aa2dbcf571 100644 --- a/accounts-bench/src/main.rs +++ b/accounts-bench/src/main.rs @@ -1,19 +1,17 @@ #![allow(clippy::integer_arithmetic)] #[macro_use] extern crate log; -use { - clap::{crate_description, crate_name, value_t, App, Arg}, - rayon::prelude::*, - solana_measure::measure::Measure, - solana_runtime::{ - accounts::{create_test_accounts, update_accounts_bench, Accounts}, - accounts_db::AccountShrinkThreshold, - accounts_index::AccountSecondaryIndexes, - ancestors::Ancestors, - }, - solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey}, - std::{env, fs, path::PathBuf}, +use clap::{crate_description, crate_name, value_t, App, Arg}; +use rayon::prelude::*; +use solana_measure::measure::Measure; +use solana_runtime::{ + accounts::{create_test_accounts, update_accounts_bench, Accounts}, + accounts_db::AccountShrinkThreshold, + accounts_index::AccountSecondaryIndexes, + ancestors::Ancestors, }; +use solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey}; +use std::{env, fs, path::PathBuf}; fn main() { solana_logger::setup(); diff --git a/accounts-cluster-bench/src/main.rs b/accounts-cluster-bench/src/main.rs index 3e4694678e..dd34f2cb9f 100644 --- a/accounts-cluster-bench/src/main.rs +++ b/accounts-cluster-bench/src/main.rs @@ -1,38 +1,36 @@ #![allow(clippy::integer_arithmetic)] -use { - clap::{crate_description, crate_name, value_t, values_t_or_exit, App, Arg}, - log::*, - rand::{thread_rng, Rng}, - rayon::prelude::*, - solana_account_decoder::parse_token::spl_token_pubkey, - solana_clap_utils::input_parsers::pubkey_of, - solana_client::rpc_client::RpcClient, - solana_faucet::faucet::{request_airdrop_transaction, FAUCET_PORT}, - solana_gossip::gossip_service::discover, - solana_measure::measure::Measure, - solana_runtime::inline_spl_token, - solana_sdk::{ - commitment_config::CommitmentConfig, - message::Message, - pubkey::Pubkey, - rpc_port::DEFAULT_RPC_PORT, - signature::{read_keypair_file, Keypair, Signature, Signer}, - system_instruction, system_program, - timing::timestamp, - transaction::Transaction, - }, - solana_streamer::socket::SocketAddrSpace, - solana_transaction_status::parse_token::spl_token_instruction, - std::{ - net::SocketAddr, - process::exit, - sync::{ - atomic::{AtomicBool, AtomicU64, Ordering}, - Arc, RwLock, - }, - thread::{sleep, Builder, JoinHandle}, - time::{Duration, Instant}, +use clap::{crate_description, crate_name, value_t, values_t_or_exit, App, Arg}; +use log::*; +use rand::{thread_rng, Rng}; +use rayon::prelude::*; +use solana_account_decoder::parse_token::spl_token_pubkey; +use solana_clap_utils::input_parsers::pubkey_of; +use solana_client::rpc_client::RpcClient; +use solana_faucet::faucet::{request_airdrop_transaction, FAUCET_PORT}; +use solana_gossip::gossip_service::discover; +use solana_measure::measure::Measure; +use solana_runtime::inline_spl_token; +use solana_sdk::{ + commitment_config::CommitmentConfig, + message::Message, + pubkey::Pubkey, + rpc_port::DEFAULT_RPC_PORT, + signature::{read_keypair_file, Keypair, Signature, Signer}, + system_instruction, system_program, + timing::timestamp, + transaction::Transaction, +}; +use solana_streamer::socket::SocketAddrSpace; +use solana_transaction_status::parse_token::spl_token_instruction; +use std::{ + net::SocketAddr, + process::exit, + sync::{ + atomic::{AtomicBool, AtomicU64, Ordering}, + Arc, RwLock, }, + thread::{sleep, Builder, JoinHandle}, + time::{Duration, Instant}, }; // Create and close messages both require 2 signatures; if transaction construction changes, update @@ -703,15 +701,13 @@ fn main() { #[cfg(test)] pub mod test { - use { - super::*, - solana_core::validator::ValidatorConfig, - solana_local_cluster::{ - local_cluster::{ClusterConfig, LocalCluster}, - validator_configs::make_identical_validator_configs, - }, - solana_sdk::poh_config::PohConfig, + use super::*; + use solana_core::validator::ValidatorConfig; + use solana_local_cluster::{ + local_cluster::{ClusterConfig, LocalCluster}, + validator_configs::make_identical_validator_configs, }; + use solana_sdk::poh_config::PohConfig; #[test] fn test_accounts_cluster_bench() { diff --git a/accountsdb-plugin-postgres/src/accountsdb_plugin_postgres.rs b/accountsdb-plugin-postgres/src/accountsdb_plugin_postgres.rs index 908a1ebce5..6d9a4248cc 100644 --- a/accountsdb-plugin-postgres/src/accountsdb_plugin_postgres.rs +++ b/accountsdb-plugin-postgres/src/accountsdb_plugin_postgres.rs @@ -1,4 +1,5 @@ use solana_measure::measure::Measure; + /// Main entry for the PostgreSQL plugin use { crate::{ diff --git a/banking-bench/src/main.rs b/banking-bench/src/main.rs index 0f4e4e4503..b81f2c5ec0 100644 --- a/banking-bench/src/main.rs +++ b/banking-bench/src/main.rs @@ -1,37 +1,36 @@ #![allow(clippy::integer_arithmetic)] -use { - clap::{crate_description, crate_name, value_t, App, Arg}, - crossbeam_channel::unbounded, - log::*, - rand::{thread_rng, Rng}, - rayon::prelude::*, - solana_core::banking_stage::BankingStage, - solana_gossip::cluster_info::{ClusterInfo, Node}, - solana_ledger::{ - blockstore::Blockstore, - genesis_utils::{create_genesis_config, GenesisConfigInfo}, - get_tmp_ledger_path, - }, - solana_measure::measure::Measure, - solana_perf::packet::to_packets_chunked, - solana_poh::poh_recorder::{create_test_recorder, PohRecorder, WorkingBankEntry}, - solana_runtime::{ - accounts_background_service::AbsRequestSender, bank::Bank, bank_forks::BankForks, - cost_model::CostModel, - }, - solana_sdk::{ - hash::Hash, - signature::{Keypair, Signature}, - system_transaction, - timing::{duration_as_us, timestamp}, - transaction::Transaction, - }, - solana_streamer::socket::SocketAddrSpace, - std::{ - sync::{atomic::Ordering, mpsc::Receiver, Arc, Mutex, RwLock}, - thread::sleep, - time::{Duration, Instant}, - }, +use clap::{crate_description, crate_name, value_t, App, Arg}; +use crossbeam_channel::unbounded; +use log::*; +use rand::{thread_rng, Rng}; +use rayon::prelude::*; +use solana_core::banking_stage::BankingStage; +use solana_gossip::{cluster_info::ClusterInfo, cluster_info::Node}; +use solana_ledger::{ + blockstore::Blockstore, + genesis_utils::{create_genesis_config, GenesisConfigInfo}, + get_tmp_ledger_path, +}; +use solana_measure::measure::Measure; +use solana_perf::packet::to_packets_chunked; +use solana_poh::poh_recorder::{create_test_recorder, PohRecorder, WorkingBankEntry}; +use solana_runtime::{ + accounts_background_service::AbsRequestSender, bank::Bank, bank_forks::BankForks, + cost_model::CostModel, +}; +use solana_sdk::{ + hash::Hash, + signature::Keypair, + signature::Signature, + system_transaction, + timing::{duration_as_us, timestamp}, + transaction::Transaction, +}; +use solana_streamer::socket::SocketAddrSpace; +use std::{ + sync::{atomic::Ordering, mpsc::Receiver, Arc, Mutex, RwLock}, + thread::sleep, + time::{Duration, Instant}, }; fn check_txs( diff --git a/banks-client/src/lib.rs b/banks-client/src/lib.rs index 414ee8ba85..d6162a0157 100644 --- a/banks-client/src/lib.rs +++ b/banks-client/src/lib.rs @@ -5,38 +5,37 @@ //! but they are undocumented, may change over time, and are generally more //! cumbersome to use. +use borsh::BorshDeserialize; +use futures::{future::join_all, Future, FutureExt}; pub use solana_banks_interface::{BanksClient as TarpcClient, TransactionStatus}; -use { - borsh::BorshDeserialize, - futures::{future::join_all, Future, FutureExt}, - solana_banks_interface::{BanksRequest, BanksResponse}, - solana_program::{ - clock::{Clock, Slot}, - fee_calculator::FeeCalculator, - hash::Hash, - program_pack::Pack, - pubkey::Pubkey, - rent::Rent, - sysvar::{self, Sysvar}, - }, - solana_sdk::{ - account::{from_account, Account}, - commitment_config::CommitmentLevel, - signature::Signature, - transaction::{self, Transaction}, - transport, - }, - std::io::{self, Error, ErrorKind}, - tarpc::{ - client::{self, channel::RequestDispatch, NewClient}, - context::{self, Context}, - rpc::{ClientMessage, Response}, - serde_transport::tcp, - Transport, - }, - tokio::{net::ToSocketAddrs, time::Duration}, - tokio_serde::formats::Bincode, +use solana_banks_interface::{BanksRequest, BanksResponse}; +use solana_program::{ + clock::Clock, + clock::Slot, + fee_calculator::FeeCalculator, + hash::Hash, + program_pack::Pack, + pubkey::Pubkey, + rent::Rent, + sysvar::{self, Sysvar}, }; +use solana_sdk::{ + account::{from_account, Account}, + commitment_config::CommitmentLevel, + signature::Signature, + transaction::{self, Transaction}, + transport, +}; +use std::io::{self, Error, ErrorKind}; +use tarpc::{ + client::{self, channel::RequestDispatch, NewClient}, + context::{self, Context}, + rpc::{ClientMessage, Response}, + serde_transport::tcp, + Transport, +}; +use tokio::{net::ToSocketAddrs, time::Duration}; +use tokio_serde::formats::Bincode; // This exists only for backward compatibility pub trait BanksClientExt {} @@ -349,18 +348,16 @@ pub async fn start_tcp_client(addr: T) -> io::Result, @@ -103,7 +101,8 @@ impl RpcBanksService { #[cfg(test)] mod tests { - use {super::*, solana_runtime::bank::Bank}; + use super::*; + use solana_runtime::bank::Bank; #[test] fn test_rpc_banks_server_exit() { diff --git a/banks-server/src/send_transaction_service.rs b/banks-server/src/send_transaction_service.rs index a9a165d10f..0371474dbc 100644 --- a/banks-server/src/send_transaction_service.rs +++ b/banks-server/src/send_transaction_service.rs @@ -1,19 +1,17 @@ // TODO: Merge this implementation with the one at `core/src/send_transaction_service.rs` -use { - log::*, - solana_metrics::{datapoint_warn, inc_new_counter_info}, - solana_runtime::{bank::Bank, bank_forks::BankForks}, - solana_sdk::signature::Signature, - std::{ - collections::HashMap, - net::{SocketAddr, UdpSocket}, - sync::{ - mpsc::{Receiver, RecvTimeoutError}, - Arc, RwLock, - }, - thread::{self, Builder, JoinHandle}, - time::{Duration, Instant}, +use log::*; +use solana_metrics::{datapoint_warn, inc_new_counter_info}; +use solana_runtime::{bank::Bank, bank_forks::BankForks}; +use solana_sdk::signature::Signature; +use std::{ + collections::HashMap, + net::{SocketAddr, UdpSocket}, + sync::{ + mpsc::{Receiver, RecvTimeoutError}, + Arc, RwLock, }, + thread::{self, Builder, JoinHandle}, + time::{Duration, Instant}, }; /// Maximum size of the transaction queue @@ -185,14 +183,12 @@ impl SendTransactionService { #[cfg(test)] mod test { - use { - super::*, - solana_sdk::{ - genesis_config::create_genesis_config, pubkey::Pubkey, signature::Signer, - system_transaction, - }, - std::sync::mpsc::channel, + use super::*; + use solana_sdk::{ + genesis_config::create_genesis_config, pubkey::Pubkey, signature::Signer, + system_transaction, }; + use std::sync::mpsc::channel; #[test] fn service_exit() { diff --git a/bench-exchange/src/bench.rs b/bench-exchange/src/bench.rs index cef3aabe1b..cffb7605be 100644 --- a/bench-exchange/src/bench.rs +++ b/bench-exchange/src/bench.rs @@ -1,45 +1,43 @@ #![allow(clippy::useless_attribute)] #![allow(clippy::integer_arithmetic)] -use { - crate::order_book::*, - itertools::izip, - log::*, - rand::{thread_rng, Rng}, - rayon::prelude::*, - solana_client::perf_utils::{sample_txs, SampleStats}, - solana_core::gen_keys::GenKeys, - solana_exchange_program::{exchange_instruction, exchange_state::*, id}, - solana_faucet::faucet::request_airdrop_transaction, - solana_genesis::Base64Account, - solana_metrics::datapoint_info, - solana_sdk::{ - client::{Client, SyncClient}, - commitment_config::CommitmentConfig, - message::Message, - pubkey::Pubkey, - signature::{Keypair, Signer}, - system_instruction, system_program, - timing::{duration_as_ms, duration_as_s}, - transaction::Transaction, - }, - std::{ - cmp, - collections::{HashMap, VecDeque}, - fs::File, - io::prelude::*, - mem, - net::SocketAddr, - path::Path, - process::exit, - sync::{ - atomic::{AtomicBool, AtomicUsize, Ordering}, - mpsc::{channel, Receiver, Sender}, - Arc, RwLock, - }, - thread::{sleep, Builder}, - time::{Duration, Instant}, +use crate::order_book::*; +use itertools::izip; +use log::*; +use rand::{thread_rng, Rng}; +use rayon::prelude::*; +use solana_client::perf_utils::{sample_txs, SampleStats}; +use solana_core::gen_keys::GenKeys; +use solana_exchange_program::{exchange_instruction, exchange_state::*, id}; +use solana_faucet::faucet::request_airdrop_transaction; +use solana_genesis::Base64Account; +use solana_metrics::datapoint_info; +use solana_sdk::{ + client::{Client, SyncClient}, + commitment_config::CommitmentConfig, + message::Message, + pubkey::Pubkey, + signature::{Keypair, Signer}, + timing::{duration_as_ms, duration_as_s}, + transaction::Transaction, + {system_instruction, system_program}, +}; +use std::{ + cmp, + collections::{HashMap, VecDeque}, + fs::File, + io::prelude::*, + mem, + net::SocketAddr, + path::Path, + process::exit, + sync::{ + atomic::{AtomicBool, AtomicUsize, Ordering}, + mpsc::{channel, Receiver, Sender}, + Arc, RwLock, }, + thread::{sleep, Builder}, + time::{Duration, Instant}, }; // TODO Chunk length as specified results in a bunch of failures, divide by 10 helps... diff --git a/bench-exchange/src/cli.rs b/bench-exchange/src/cli.rs index 9a24ebce7e..21e8f39dbd 100644 --- a/bench-exchange/src/cli.rs +++ b/bench-exchange/src/cli.rs @@ -1,10 +1,10 @@ -use { - clap::{crate_description, crate_name, value_t, App, Arg, ArgMatches}, - solana_core::gen_keys::GenKeys, - solana_faucet::faucet::FAUCET_PORT, - solana_sdk::signature::{read_keypair_file, Keypair}, - std::{net::SocketAddr, process::exit, time::Duration}, -}; +use clap::{crate_description, crate_name, value_t, App, Arg, ArgMatches}; +use solana_core::gen_keys::GenKeys; +use solana_faucet::faucet::FAUCET_PORT; +use solana_sdk::signature::{read_keypair_file, Keypair}; +use std::net::SocketAddr; +use std::process::exit; +use std::time::Duration; pub struct Config { pub entrypoint_addr: SocketAddr, diff --git a/bench-exchange/src/main.rs b/bench-exchange/src/main.rs index 30b0569a42..4e52f4027a 100644 --- a/bench-exchange/src/main.rs +++ b/bench-exchange/src/main.rs @@ -3,13 +3,11 @@ pub mod bench; mod cli; pub mod order_book; -use { - crate::bench::{airdrop_lamports, create_client_accounts_file, do_bench_exchange, Config}, - log::*, - solana_gossip::gossip_service::{discover_cluster, get_multi_client}, - solana_sdk::signature::Signer, - solana_streamer::socket::SocketAddrSpace, -}; +use crate::bench::{airdrop_lamports, create_client_accounts_file, do_bench_exchange, Config}; +use log::*; +use solana_gossip::gossip_service::{discover_cluster, get_multi_client}; +use solana_sdk::signature::Signer; +use solana_streamer::socket::SocketAddrSpace; fn main() { solana_logger::setup(); diff --git a/bench-exchange/src/order_book.rs b/bench-exchange/src/order_book.rs index 06a7ca317a..d4c06743c4 100644 --- a/bench-exchange/src/order_book.rs +++ b/bench-exchange/src/order_book.rs @@ -1,13 +1,11 @@ -use { - itertools::{ - EitherOrBoth::{Both, Left, Right}, - Itertools, - }, - log::*, - solana_exchange_program::exchange_state::*, - solana_sdk::pubkey::Pubkey, - std::{cmp::Ordering, collections::BinaryHeap, error, fmt}, -}; +use itertools::EitherOrBoth::{Both, Left, Right}; +use itertools::Itertools; +use log::*; +use solana_exchange_program::exchange_state::*; +use solana_sdk::pubkey::Pubkey; +use std::cmp::Ordering; +use std::collections::BinaryHeap; +use std::{error, fmt}; #[derive(Clone, Debug, Eq, PartialEq)] pub struct ToOrder { diff --git a/bench-exchange/tests/bench_exchange.rs b/bench-exchange/tests/bench_exchange.rs index 537038449a..081791e439 100644 --- a/bench-exchange/tests/bench_exchange.rs +++ b/bench-exchange/tests/bench_exchange.rs @@ -1,24 +1,22 @@ -use { - log::*, - solana_bench_exchange::bench::{airdrop_lamports, do_bench_exchange, Config}, - solana_core::validator::ValidatorConfig, - solana_exchange_program::{ - exchange_processor::process_instruction, id, solana_exchange_program, - }, - solana_faucet::faucet::run_local_faucet_with_port, - solana_gossip::gossip_service::{discover_cluster, get_multi_client}, - solana_local_cluster::{ - local_cluster::{ClusterConfig, LocalCluster}, - validator_configs::make_identical_validator_configs, - }, - solana_runtime::{bank::Bank, bank_client::BankClient}, - solana_sdk::{ - genesis_config::create_genesis_config, - signature::{Keypair, Signer}, - }, - solana_streamer::socket::SocketAddrSpace, - std::{process::exit, sync::mpsc::channel, time::Duration}, +use log::*; +use solana_bench_exchange::bench::{airdrop_lamports, do_bench_exchange, Config}; +use solana_core::validator::ValidatorConfig; +use solana_exchange_program::{ + exchange_processor::process_instruction, id, solana_exchange_program, }; +use solana_faucet::faucet::run_local_faucet_with_port; +use solana_gossip::gossip_service::{discover_cluster, get_multi_client}; +use solana_local_cluster::{ + local_cluster::{ClusterConfig, LocalCluster}, + validator_configs::make_identical_validator_configs, +}; +use solana_runtime::{bank::Bank, bank_client::BankClient}; +use solana_sdk::{ + genesis_config::create_genesis_config, + signature::{Keypair, Signer}, +}; +use solana_streamer::socket::SocketAddrSpace; +use std::{process::exit, sync::mpsc::channel, time::Duration}; #[test] #[ignore] diff --git a/bench-streamer/src/main.rs b/bench-streamer/src/main.rs index bade7a9430..4e1f070eb0 100644 --- a/bench-streamer/src/main.rs +++ b/bench-streamer/src/main.rs @@ -1,22 +1,16 @@ #![allow(clippy::integer_arithmetic)] -use { - clap::{crate_description, crate_name, App, Arg}, - solana_streamer::{ - packet::{Packet, Packets, PacketsRecycler, PACKET_DATA_SIZE}, - streamer::{receiver, PacketReceiver}, - }, - std::{ - cmp::max, - net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket}, - sync::{ - atomic::{AtomicBool, AtomicUsize, Ordering}, - mpsc::channel, - Arc, - }, - thread::{sleep, spawn, JoinHandle, Result}, - time::{Duration, SystemTime}, - }, -}; +use clap::{crate_description, crate_name, App, Arg}; +use solana_streamer::packet::{Packet, Packets, PacketsRecycler, PACKET_DATA_SIZE}; +use solana_streamer::streamer::{receiver, PacketReceiver}; +use std::cmp::max; +use std::net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket}; +use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use std::sync::mpsc::channel; +use std::sync::Arc; +use std::thread::sleep; +use std::thread::{spawn, JoinHandle, Result}; +use std::time::Duration; +use std::time::SystemTime; fn producer(addr: &SocketAddr, exit: Arc) -> JoinHandle<()> { let send = UdpSocket::bind("0.0.0.0:0").unwrap(); diff --git a/bench-tps/src/bench.rs b/bench-tps/src/bench.rs index f890d44996..a2c21ce7ef 100644 --- a/bench-tps/src/bench.rs +++ b/bench-tps/src/bench.rs @@ -1,36 +1,34 @@ -use { - crate::cli::Config, - log::*, - rayon::prelude::*, - solana_client::perf_utils::{sample_txs, SampleStats}, - solana_core::gen_keys::GenKeys, - solana_faucet::faucet::request_airdrop_transaction, - solana_measure::measure::Measure, - solana_metrics::{self, datapoint_info}, - solana_sdk::{ - client::Client, - clock::{DEFAULT_S_PER_SLOT, MAX_PROCESSING_AGE}, - commitment_config::CommitmentConfig, - fee_calculator::FeeCalculator, - hash::Hash, - message::Message, - pubkey::Pubkey, - signature::{Keypair, Signer}, - system_instruction, system_transaction, - timing::{duration_as_ms, duration_as_s, duration_as_us, timestamp}, - transaction::Transaction, - }, - std::{ - collections::{HashSet, VecDeque}, - net::SocketAddr, - process::exit, - sync::{ - atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering}, - Arc, Mutex, RwLock, - }, - thread::{sleep, Builder, JoinHandle}, - time::{Duration, Instant}, +use crate::cli::Config; +use log::*; +use rayon::prelude::*; +use solana_client::perf_utils::{sample_txs, SampleStats}; +use solana_core::gen_keys::GenKeys; +use solana_faucet::faucet::request_airdrop_transaction; +use solana_measure::measure::Measure; +use solana_metrics::{self, datapoint_info}; +use solana_sdk::{ + client::Client, + clock::{DEFAULT_S_PER_SLOT, MAX_PROCESSING_AGE}, + commitment_config::CommitmentConfig, + fee_calculator::FeeCalculator, + hash::Hash, + message::Message, + pubkey::Pubkey, + signature::{Keypair, Signer}, + system_instruction, system_transaction, + timing::{duration_as_ms, duration_as_s, duration_as_us, timestamp}, + transaction::Transaction, +}; +use std::{ + collections::{HashSet, VecDeque}, + net::SocketAddr, + process::exit, + sync::{ + atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering}, + Arc, Mutex, RwLock, }, + thread::{sleep, Builder, JoinHandle}, + time::{Duration, Instant}, }; // The point at which transactions become "too old", in seconds. @@ -926,14 +924,12 @@ pub fn generate_and_fund_keypairs( #[cfg(test)] mod tests { - use { - super::*, - solana_runtime::{bank::Bank, bank_client::BankClient}, - solana_sdk::{ - client::SyncClient, fee_calculator::FeeRateGovernor, - genesis_config::create_genesis_config, - }, - }; + use super::*; + use solana_runtime::bank::Bank; + use solana_runtime::bank_client::BankClient; + use solana_sdk::client::SyncClient; + use solana_sdk::fee_calculator::FeeRateGovernor; + use solana_sdk::genesis_config::create_genesis_config; #[test] fn test_bench_tps_bank_client() { diff --git a/bench-tps/src/cli.rs b/bench-tps/src/cli.rs index c711406a74..875490d1e0 100644 --- a/bench-tps/src/cli.rs +++ b/bench-tps/src/cli.rs @@ -1,13 +1,11 @@ -use { - clap::{crate_description, crate_name, App, Arg, ArgMatches}, - solana_faucet::faucet::FAUCET_PORT, - solana_sdk::{ - fee_calculator::FeeRateGovernor, - pubkey::Pubkey, - signature::{read_keypair_file, Keypair}, - }, - std::{net::SocketAddr, process::exit, time::Duration}, +use clap::{crate_description, crate_name, App, Arg, ArgMatches}; +use solana_faucet::faucet::FAUCET_PORT; +use solana_sdk::fee_calculator::FeeRateGovernor; +use solana_sdk::{ + pubkey::Pubkey, + signature::{read_keypair_file, Keypair}, }; +use std::{net::SocketAddr, process::exit, time::Duration}; const NUM_LAMPORTS_PER_ACCOUNT_DEFAULT: u64 = solana_sdk::native_token::LAMPORTS_PER_SOL; diff --git a/bench-tps/src/main.rs b/bench-tps/src/main.rs index d1a2e379d2..03ae9f7463 100644 --- a/bench-tps/src/main.rs +++ b/bench-tps/src/main.rs @@ -1,20 +1,14 @@ #![allow(clippy::integer_arithmetic)] -use { - log::*, - solana_bench_tps::{ - bench::{do_bench_tps, generate_and_fund_keypairs, generate_keypairs}, - cli, - }, - solana_genesis::Base64Account, - solana_gossip::gossip_service::{discover_cluster, get_client, get_multi_client}, - solana_sdk::{ - fee_calculator::FeeRateGovernor, - signature::{Keypair, Signer}, - system_program, - }, - solana_streamer::socket::SocketAddrSpace, - std::{collections::HashMap, fs::File, io::prelude::*, path::Path, process::exit, sync::Arc}, -}; +use log::*; +use solana_bench_tps::bench::{do_bench_tps, generate_and_fund_keypairs, generate_keypairs}; +use solana_bench_tps::cli; +use solana_genesis::Base64Account; +use solana_gossip::gossip_service::{discover_cluster, get_client, get_multi_client}; +use solana_sdk::fee_calculator::FeeRateGovernor; +use solana_sdk::signature::{Keypair, Signer}; +use solana_sdk::system_program; +use solana_streamer::socket::SocketAddrSpace; +use std::{collections::HashMap, fs::File, io::prelude::*, path::Path, process::exit, sync::Arc}; /// Number of signatures for all transactions in ~1 week at ~100K TPS pub const NUM_SIGNATURES_FOR_TXS: u64 = 100_000 * 60 * 60 * 24 * 7; diff --git a/bench-tps/tests/bench_tps.rs b/bench-tps/tests/bench_tps.rs index 8b40aab0a8..26e6a1f895 100644 --- a/bench-tps/tests/bench_tps.rs +++ b/bench-tps/tests/bench_tps.rs @@ -1,24 +1,22 @@ #![allow(clippy::integer_arithmetic)] -use { - serial_test::serial, - solana_bench_tps::{ - bench::{do_bench_tps, generate_and_fund_keypairs}, - cli::Config, - }, - solana_client::thin_client::create_client, - solana_core::validator::ValidatorConfig, - solana_faucet::faucet::run_local_faucet_with_port, - solana_gossip::cluster_info::VALIDATOR_PORT_RANGE, - solana_local_cluster::{ - local_cluster::{ClusterConfig, LocalCluster}, - validator_configs::make_identical_validator_configs, - }, - solana_sdk::signature::{Keypair, Signer}, - solana_streamer::socket::SocketAddrSpace, - std::{ - sync::{mpsc::channel, Arc}, - time::Duration, - }, +use serial_test::serial; +use solana_bench_tps::{ + bench::{do_bench_tps, generate_and_fund_keypairs}, + cli::Config, +}; +use solana_client::thin_client::create_client; +use solana_core::validator::ValidatorConfig; +use solana_faucet::faucet::run_local_faucet_with_port; +use solana_gossip::cluster_info::VALIDATOR_PORT_RANGE; +use solana_local_cluster::{ + local_cluster::{ClusterConfig, LocalCluster}, + validator_configs::make_identical_validator_configs, +}; +use solana_sdk::signature::{Keypair, Signer}; +use solana_streamer::socket::SocketAddrSpace; +use std::{ + sync::{mpsc::channel, Arc}, + time::Duration, }; fn test_bench_tps_local_cluster(config: Config) { diff --git a/clap-utils/src/input_parsers.rs b/clap-utils/src/input_parsers.rs index 304f6116f2..5e1f2d44f0 100644 --- a/clap-utils/src/input_parsers.rs +++ b/clap-utils/src/input_parsers.rs @@ -196,12 +196,10 @@ pub fn commitment_of(matches: &ArgMatches<'_>, name: &str) -> Option() -> App<'ab, 'v> { App::new("test") diff --git a/clap-utils/src/input_validators.rs b/clap-utils/src/input_validators.rs index ad5d2b1ac5..43ca7a2564 100644 --- a/clap-utils/src/input_validators.rs +++ b/clap-utils/src/input_validators.rs @@ -7,7 +7,8 @@ use { pubkey::{Pubkey, MAX_SEED_LEN}, signature::{read_keypair_file, Signature}, }, - std::{fmt::Display, str::FromStr}, + std::fmt::Display, + std::str::FromStr, }; fn is_parsable_generic(string: T) -> Result<(), String> diff --git a/clap-utils/src/keypair.rs b/clap-utils/src/keypair.rs index 927e455a83..c217cd046e 100644 --- a/clap-utils/src/keypair.rs +++ b/clap-utils/src/keypair.rs @@ -1123,14 +1123,14 @@ fn sanitize_seed_phrase(seed_phrase: &str) -> String { #[cfg(test)] mod tests { - use { - super::*, - crate::offline::OfflineArgs, - clap::{value_t_or_exit, App, Arg}, - solana_remote_wallet::{locator::Manufacturer, remote_wallet::initialize_wallet_manager}, - solana_sdk::{signer::keypair::write_keypair_file, system_instruction}, - tempfile::{NamedTempFile, TempDir}, - }; + use super::*; + use crate::offline::OfflineArgs; + use clap::{value_t_or_exit, App, Arg}; + use solana_remote_wallet::locator::Manufacturer; + use solana_remote_wallet::remote_wallet::initialize_wallet_manager; + use solana_sdk::signer::keypair::write_keypair_file; + use solana_sdk::system_instruction; + use tempfile::{NamedTempFile, TempDir}; #[test] fn test_sanitize_seed_phrase() { diff --git a/cli-config/src/config.rs b/cli-config/src/config.rs index 901b8a6cd5..d9706ef929 100644 --- a/cli-config/src/config.rs +++ b/cli-config/src/config.rs @@ -1,9 +1,7 @@ // Wallet settings that can be configured for long-term use -use { - serde_derive::{Deserialize, Serialize}, - std::{collections::HashMap, io, path::Path}, - url::Url, -}; +use serde_derive::{Deserialize, Serialize}; +use std::{collections::HashMap, io, path::Path}; +use url::Url; lazy_static! { pub static ref CONFIG_FILE: Option = { diff --git a/cli-config/src/lib.rs b/cli-config/src/lib.rs index f1b16c4391..435e9762c3 100644 --- a/cli-config/src/lib.rs +++ b/cli-config/src/lib.rs @@ -3,6 +3,7 @@ extern crate lazy_static; mod config; pub use config::{Config, CONFIG_FILE}; + use std::{ fs::{create_dir_all, File}, io::{self, Write}, diff --git a/cli-output/src/cli_output.rs b/cli-output/src/cli_output.rs index 6a8b232cae..51eab27ac6 100644 --- a/cli-output/src/cli_output.rs +++ b/cli-output/src/cli_output.rs @@ -2525,16 +2525,14 @@ impl VerboseDisplay for CliGossipNodes {} #[cfg(test)] mod tests { - use { - super::*, - clap::{App, Arg}, - solana_sdk::{ - message::Message, - pubkey::Pubkey, - signature::{keypair_from_seed, NullSigner, Signature, Signer, SignerError}, - system_instruction, - transaction::Transaction, - }, + use super::*; + use clap::{App, Arg}; + use solana_sdk::{ + message::Message, + pubkey::Pubkey, + signature::{keypair_from_seed, NullSigner, Signature, Signer, SignerError}, + system_instruction, + transaction::Transaction, }; #[test] diff --git a/cli-output/src/display.rs b/cli-output/src/display.rs index 6021cbf12c..b44af327c0 100644 --- a/cli-output/src/display.rs +++ b/cli-output/src/display.rs @@ -8,7 +8,8 @@ use { program_utils::limited_deserialize, pubkey::Pubkey, stake, transaction::Transaction, }, solana_transaction_status::UiTransactionStatusMeta, - spl_memo::{id as spl_memo_id, v1::id as spl_memo_v1_id}, + spl_memo::id as spl_memo_id, + spl_memo::v1::id as spl_memo_v1_id, std::{collections::HashMap, fmt, io}, }; @@ -430,7 +431,8 @@ pub fn unix_timestamp_to_string(unix_timestamp: UnixTimestamp) -> String { #[cfg(test)] mod test { - use {super::*, solana_sdk::pubkey::Pubkey}; + use super::*; + use solana_sdk::pubkey::Pubkey; #[test] fn test_format_labeled_address() { diff --git a/cli/src/checks.rs b/cli/src/checks.rs index 6a6494003e..92a365c76d 100644 --- a/cli/src/checks.rs +++ b/cli/src/checks.rs @@ -1,13 +1,11 @@ -use { - crate::cli::CliError, - solana_client::{ - client_error::{ClientError, Result as ClientResult}, - rpc_client::RpcClient, - }, - solana_sdk::{ - commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, message::Message, - native_token::lamports_to_sol, pubkey::Pubkey, - }, +use crate::cli::CliError; +use solana_client::{ + client_error::{ClientError, Result as ClientResult}, + rpc_client::RpcClient, +}; +use solana_sdk::{ + commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, message::Message, + native_token::lamports_to_sol, pubkey::Pubkey, }; pub fn check_account_for_fee( @@ -151,16 +149,14 @@ pub fn check_unique_pubkeys( #[cfg(test)] mod tests { - use { - super::*, - serde_json::json, - solana_client::{ - rpc_request::RpcRequest, - rpc_response::{Response, RpcResponseContext}, - }, - solana_sdk::system_instruction, - std::collections::HashMap, + use super::*; + use serde_json::json; + use solana_client::{ + rpc_request::RpcRequest, + rpc_response::{Response, RpcResponseContext}, }; + use solana_sdk::system_instruction; + use std::collections::HashMap; #[test] fn test_check_account_for_fees() { diff --git a/cli/src/clap_app.rs b/cli/src/clap_app.rs index 3d48ed3716..cf15285c3d 100644 --- a/cli/src/clap_app.rs +++ b/cli/src/clap_app.rs @@ -1,12 +1,10 @@ -use { - crate::{ - cli::*, cluster_query::*, feature::*, inflation::*, nonce::*, program::*, stake::*, - validator_info::*, vote::*, wallet::*, - }, - clap::{App, AppSettings, Arg, ArgGroup, SubCommand}, - solana_clap_utils::{self, input_validators::*, keypair::*}, - solana_cli_config::CONFIG_FILE, +use crate::{ + cli::*, cluster_query::*, feature::*, inflation::*, nonce::*, program::*, stake::*, + validator_info::*, vote::*, wallet::*, }; +use clap::{App, AppSettings, Arg, ArgGroup, SubCommand}; +use solana_clap_utils::{self, input_validators::*, keypair::*}; +use solana_cli_config::CONFIG_FILE; pub fn get_clap_app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, 'v> { App::new(name) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 201f6331a3..9cfde30a16 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -1,41 +1,37 @@ -use { - crate::{ - clap_app::*, cluster_query::*, feature::*, inflation::*, nonce::*, program::*, - spend_utils::*, stake::*, validator_info::*, vote::*, wallet::*, - }, - clap::{crate_description, crate_name, value_t_or_exit, ArgMatches, Shell}, - log::*, - num_traits::FromPrimitive, - serde_json::{self, Value}, - solana_clap_utils::{self, input_parsers::*, input_validators::*, keypair::*}, - solana_cli_output::{ - display::println_name_value, CliSignature, CliValidatorsSortOrder, OutputFormat, - }, - solana_client::{ - blockhash_query::BlockhashQuery, - client_error::{ClientError, Result as ClientResult}, - nonce_utils, - rpc_client::RpcClient, - rpc_config::{ - RpcLargestAccountsFilter, RpcSendTransactionConfig, RpcTransactionLogsFilter, - }, - }, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{ - clock::{Epoch, Slot}, - commitment_config::CommitmentConfig, - decode_error::DecodeError, - hash::Hash, - instruction::InstructionError, - pubkey::Pubkey, - signature::{Signature, Signer, SignerError}, - stake::{instruction::LockupArgs, state::Lockup}, - transaction::{Transaction, TransactionError}, - }, - solana_vote_program::vote_state::VoteAuthorize, - std::{collections::HashMap, error, io::stdout, str::FromStr, sync::Arc, time::Duration}, - thiserror::Error, +use crate::{ + clap_app::*, cluster_query::*, feature::*, inflation::*, nonce::*, program::*, spend_utils::*, + stake::*, validator_info::*, vote::*, wallet::*, }; +use clap::{crate_description, crate_name, value_t_or_exit, ArgMatches, Shell}; +use log::*; +use num_traits::FromPrimitive; +use serde_json::{self, Value}; +use solana_clap_utils::{self, input_parsers::*, input_validators::*, keypair::*}; +use solana_cli_output::{ + display::println_name_value, CliSignature, CliValidatorsSortOrder, OutputFormat, +}; +use solana_client::{ + blockhash_query::BlockhashQuery, + client_error::{ClientError, Result as ClientResult}, + nonce_utils, + rpc_client::RpcClient, + rpc_config::{RpcLargestAccountsFilter, RpcSendTransactionConfig, RpcTransactionLogsFilter}, +}; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{ + clock::{Epoch, Slot}, + commitment_config::CommitmentConfig, + decode_error::DecodeError, + hash::Hash, + instruction::InstructionError, + pubkey::Pubkey, + signature::{Signature, Signer, SignerError}, + stake::{instruction::LockupArgs, state::Lockup}, + transaction::{Transaction, TransactionError}, +}; +use solana_vote_program::vote_state::VoteAuthorize; +use std::{collections::HashMap, error, io::stdout, str::FromStr, sync::Arc, time::Duration}; +use thiserror::Error; pub const DEFAULT_RPC_TIMEOUT_SECONDS: &str = "30"; pub const DEFAULT_CONFIRM_TX_TIMEOUT_SECONDS: &str = "5"; @@ -1589,26 +1585,22 @@ where #[cfg(test)] mod tests { - use { - super::*, - serde_json::{json, Value}, - solana_client::{ - blockhash_query, - mock_sender::SIGNATURE, - rpc_request::RpcRequest, - rpc_response::{Response, RpcResponseContext}, - }, - solana_sdk::{ - pubkey::Pubkey, - signature::{ - keypair_from_seed, read_keypair_file, write_keypair_file, Keypair, Presigner, - }, - stake, system_program, - transaction::TransactionError, - }, - solana_transaction_status::TransactionConfirmationStatus, - std::path::PathBuf, + use super::*; + use serde_json::{json, Value}; + use solana_client::{ + blockhash_query, + mock_sender::SIGNATURE, + rpc_request::RpcRequest, + rpc_response::{Response, RpcResponseContext}, }; + use solana_sdk::{ + pubkey::Pubkey, + signature::{keypair_from_seed, read_keypair_file, write_keypair_file, Keypair, Presigner}, + stake, system_program, + transaction::TransactionError, + }; + use solana_transaction_status::TransactionConfirmationStatus; + use std::path::PathBuf; fn make_tmp_path(name: &str) -> String { let out_dir = std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()); diff --git a/cli/src/cluster_query.rs b/cli/src/cluster_query.rs index 6064b52028..4918cb5bf8 100644 --- a/cli/src/cluster_query.rs +++ b/cli/src/cluster_query.rs @@ -1,78 +1,76 @@ -use { - crate::{ - cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, - spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, - }, - clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand}, - console::{style, Emoji}, - serde::{Deserialize, Serialize}, - solana_clap_utils::{ - input_parsers::*, - input_validators::*, - keypair::DefaultSigner, - offline::{blockhash_arg, BLOCKHASH_ARG}, - }, - solana_cli_output::{ - display::{ - build_balance_message, format_labeled_address, new_spinner_progress_bar, - println_name_value, println_transaction, unix_timestamp_to_string, writeln_name_value, - }, - *, - }, - solana_client::{ - client_error::ClientErrorKind, - pubsub_client::PubsubClient, - rpc_client::{GetConfirmedSignaturesForAddress2Config, RpcClient}, - rpc_config::{ - RpcAccountInfoConfig, RpcBlockConfig, RpcGetVoteAccountsConfig, - RpcLargestAccountsConfig, RpcLargestAccountsFilter, RpcProgramAccountsConfig, - RpcTransactionConfig, RpcTransactionLogsConfig, RpcTransactionLogsFilter, - }, - rpc_filter, - rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE, - rpc_response::SlotInfo, - }, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{ - account::from_account, - account_utils::StateMut, - clock::{self, Clock, Slot}, - commitment_config::CommitmentConfig, - epoch_schedule::Epoch, - hash::Hash, - message::Message, - native_token::lamports_to_sol, - nonce::State as NonceState, - pubkey::{self, Pubkey}, - rent::Rent, - rpc_port::DEFAULT_RPC_PORT_STR, - signature::Signature, - slot_history, - stake::{self, state::StakeState}, - system_instruction, system_program, - sysvar::{ - self, - slot_history::SlotHistory, - stake_history::{self}, - }, - timing, - transaction::Transaction, - }, - solana_transaction_status::UiTransactionEncoding, - solana_vote_program::vote_state::VoteState, - std::{ - collections::{BTreeMap, HashMap, VecDeque}, - fmt, - str::FromStr, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - thread::sleep, - time::{Duration, Instant, SystemTime, UNIX_EPOCH}, - }, - thiserror::Error, +use crate::{ + cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, + spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, }; +use clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand}; +use console::{style, Emoji}; +use serde::{Deserialize, Serialize}; +use solana_clap_utils::{ + input_parsers::*, + input_validators::*, + keypair::DefaultSigner, + offline::{blockhash_arg, BLOCKHASH_ARG}, +}; +use solana_cli_output::{ + display::{ + build_balance_message, format_labeled_address, new_spinner_progress_bar, + println_name_value, println_transaction, unix_timestamp_to_string, writeln_name_value, + }, + *, +}; +use solana_client::{ + client_error::ClientErrorKind, + pubsub_client::PubsubClient, + rpc_client::{GetConfirmedSignaturesForAddress2Config, RpcClient}, + rpc_config::{ + RpcAccountInfoConfig, RpcBlockConfig, RpcGetVoteAccountsConfig, RpcLargestAccountsConfig, + RpcLargestAccountsFilter, RpcProgramAccountsConfig, RpcTransactionConfig, + RpcTransactionLogsConfig, RpcTransactionLogsFilter, + }, + rpc_filter, + rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE, + rpc_response::SlotInfo, +}; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{ + account::from_account, + account_utils::StateMut, + clock::{self, Clock, Slot}, + commitment_config::CommitmentConfig, + epoch_schedule::Epoch, + hash::Hash, + message::Message, + native_token::lamports_to_sol, + nonce::State as NonceState, + pubkey::{self, Pubkey}, + rent::Rent, + rpc_port::DEFAULT_RPC_PORT_STR, + signature::Signature, + slot_history, + stake::{self, state::StakeState}, + system_instruction, system_program, + sysvar::{ + self, + slot_history::SlotHistory, + stake_history::{self}, + }, + timing, + transaction::Transaction, +}; +use solana_transaction_status::UiTransactionEncoding; +use solana_vote_program::vote_state::VoteState; +use std::{ + collections::{BTreeMap, HashMap, VecDeque}, + fmt, + str::FromStr, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, + thread::sleep, + time::{Duration, Instant, SystemTime, UNIX_EPOCH}, +}; +use thiserror::Error; static CHECK_MARK: Emoji = Emoji("✅ ", ""); static CROSS_MARK: Emoji = Emoji("❌ ", ""); @@ -2142,13 +2140,11 @@ pub fn process_calculate_rent( #[cfg(test)] mod tests { - use { - super::*, - crate::{clap_app::get_clap_app, cli::parse_command}, - solana_sdk::signature::{write_keypair, Keypair}, - std::str::FromStr, - tempfile::NamedTempFile, - }; + use super::*; + use crate::{clap_app::get_clap_app, cli::parse_command}; + use solana_sdk::signature::{write_keypair, Keypair}; + use std::str::FromStr; + use tempfile::NamedTempFile; fn make_tmp_file() -> (String, NamedTempFile) { let tmp_file = NamedTempFile::new().unwrap(); diff --git a/cli/src/feature.rs b/cli/src/feature.rs index ee6b965f8b..29346fe43e 100644 --- a/cli/src/feature.rs +++ b/cli/src/feature.rs @@ -1,30 +1,28 @@ -use { - crate::{ - cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, - spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, - }, - clap::{App, AppSettings, Arg, ArgMatches, SubCommand}, - console::style, - serde::{Deserialize, Serialize}, - solana_clap_utils::{input_parsers::*, input_validators::*, keypair::*}, - solana_cli_output::{QuietDisplay, VerboseDisplay}, - solana_client::{client_error::ClientError, rpc_client::RpcClient}, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{ - account::Account, - clock::Slot, - feature::{self, Feature}, - feature_set::FEATURE_NAMES, - message::Message, - pubkey::Pubkey, - transaction::Transaction, - }, - std::{ - cmp::Ordering, - collections::{HashMap, HashSet}, - fmt, - sync::Arc, - }, +use crate::{ + cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, + spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, +}; +use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; +use console::style; +use serde::{Deserialize, Serialize}; +use solana_clap_utils::{input_parsers::*, input_validators::*, keypair::*}; +use solana_cli_output::{QuietDisplay, VerboseDisplay}; +use solana_client::{client_error::ClientError, rpc_client::RpcClient}; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{ + account::Account, + clock::Slot, + feature::{self, Feature}, + feature_set::FEATURE_NAMES, + message::Message, + pubkey::Pubkey, + transaction::Transaction, +}; +use std::{ + cmp::Ordering, + collections::{HashMap, HashSet}, + fmt, + sync::Arc, }; #[derive(Copy, Clone, Debug, PartialEq)] diff --git a/cli/src/inflation.rs b/cli/src/inflation.rs index 6466899f55..8ec8233db0 100644 --- a/cli/src/inflation.rs +++ b/cli/src/inflation.rs @@ -1,19 +1,17 @@ -use { - crate::cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, - clap::{App, Arg, ArgMatches, SubCommand}, - solana_clap_utils::{ - input_parsers::{pubkeys_of, value_of}, - input_validators::is_valid_pubkey, - keypair::*, - }, - solana_cli_output::{ - CliEpochRewardshMetadata, CliInflation, CliKeyedEpochReward, CliKeyedEpochRewards, - }, - solana_client::rpc_client::RpcClient, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{clock::Epoch, pubkey::Pubkey}, - std::sync::Arc, +use crate::cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}; +use clap::{App, Arg, ArgMatches, SubCommand}; +use solana_clap_utils::{ + input_parsers::{pubkeys_of, value_of}, + input_validators::is_valid_pubkey, + keypair::*, }; +use solana_cli_output::{ + CliEpochRewardshMetadata, CliInflation, CliKeyedEpochReward, CliKeyedEpochRewards, +}; +use solana_client::rpc_client::RpcClient; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{clock::Epoch, pubkey::Pubkey}; +use std::sync::Arc; #[derive(Debug, PartialEq)] pub enum InflationCliCommand { diff --git a/cli/src/main.rs b/cli/src/main.rs index 6aa20d2a26..4b1d03ce7a 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,21 +1,19 @@ -use { - clap::{crate_description, crate_name, value_t_or_exit, ArgMatches}, - console::style, - solana_clap_utils::{ - input_validators::normalize_to_url_if_moniker, - keypair::{CliSigners, DefaultSigner}, - DisplayError, - }, - solana_cli::{ - clap_app::get_clap_app, - cli::{parse_command, process_command, CliCommandInfo, CliConfig, SettingType}, - }, - solana_cli_config::Config, - solana_cli_output::{display::println_name_value, OutputFormat}, - solana_client::rpc_config::RpcSendTransactionConfig, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - std::{collections::HashMap, error, path::PathBuf, sync::Arc, time::Duration}, +use clap::{crate_description, crate_name, value_t_or_exit, ArgMatches}; +use console::style; +use solana_clap_utils::{ + input_validators::normalize_to_url_if_moniker, + keypair::{CliSigners, DefaultSigner}, + DisplayError, }; +use solana_cli::{ + clap_app::get_clap_app, + cli::{parse_command, process_command, CliCommandInfo, CliConfig, SettingType}, +}; +use solana_cli_config::Config; +use solana_cli_output::{display::println_name_value, OutputFormat}; +use solana_client::rpc_config::RpcSendTransactionConfig; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use std::{collections::HashMap, error, path::PathBuf, sync::Arc, time::Duration}; pub fn println_name_value_or(name: &str, value: &str, setting_type: SettingType) { let description = match setting_type { diff --git a/cli/src/memo.rs b/cli/src/memo.rs index 1043415357..ccb02c3d9b 100644 --- a/cli/src/memo.rs +++ b/cli/src/memo.rs @@ -1,7 +1,6 @@ -use { - solana_sdk::{instruction::Instruction, pubkey::Pubkey}, - spl_memo::id, -}; +use solana_sdk::instruction::Instruction; +use solana_sdk::pubkey::Pubkey; +use spl_memo::id; pub trait WithMemo { fn with_memo>(self, memo: Option) -> Self; diff --git a/cli/src/nonce.rs b/cli/src/nonce.rs index 30a7a5a2cc..90e53be793 100644 --- a/cli/src/nonce.rs +++ b/cli/src/nonce.rs @@ -1,43 +1,41 @@ -use { - crate::{ - checks::{check_account_for_fee_with_commitment, check_unique_pubkeys}, - cli::{ - log_instruction_custom_error, log_instruction_custom_error_ex, CliCommand, - CliCommandInfo, CliConfig, CliError, ProcessResult, - }, - feature::get_feature_is_active, - memo::WithMemo, - spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, +use crate::{ + checks::{check_account_for_fee_with_commitment, check_unique_pubkeys}, + cli::{ + log_instruction_custom_error, log_instruction_custom_error_ex, CliCommand, CliCommandInfo, + CliConfig, CliError, ProcessResult, }, - clap::{App, Arg, ArgMatches, SubCommand}, - solana_clap_utils::{ - input_parsers::*, - input_validators::*, - keypair::{DefaultSigner, SignerIndex}, - memo::{memo_arg, MEMO_ARG}, - nonce::*, - }, - solana_cli_output::CliNonceAccount, - solana_client::{nonce_utils::*, rpc_client::RpcClient}, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{ - account::Account, - feature_set::merge_nonce_error_into_system_error, - hash::Hash, - instruction::InstructionError, - message::Message, - nonce::{self, State}, - pubkey::Pubkey, - system_instruction::{ - advance_nonce_account, authorize_nonce_account, create_nonce_account, - create_nonce_account_with_seed, instruction_to_nonce_error, withdraw_nonce_account, - NonceError, SystemError, - }, - system_program, - transaction::{Transaction, TransactionError}, - }, - std::sync::Arc, + feature::get_feature_is_active, + memo::WithMemo, + spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, }; +use clap::{App, Arg, ArgMatches, SubCommand}; +use solana_clap_utils::{ + input_parsers::*, + input_validators::*, + keypair::{DefaultSigner, SignerIndex}, + memo::{memo_arg, MEMO_ARG}, + nonce::*, +}; +use solana_cli_output::CliNonceAccount; +use solana_client::{nonce_utils::*, rpc_client::RpcClient}; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{ + account::Account, + feature_set::merge_nonce_error_into_system_error, + hash::Hash, + instruction::InstructionError, + message::Message, + nonce::{self, State}, + pubkey::Pubkey, + system_instruction::{ + advance_nonce_account, authorize_nonce_account, create_nonce_account, + create_nonce_account_with_seed, instruction_to_nonce_error, withdraw_nonce_account, + NonceError, SystemError, + }, + system_program, + transaction::{Transaction, TransactionError}, +}; +use std::sync::Arc; pub trait NonceSubCommands { fn nonce_subcommands(self) -> Self; @@ -652,21 +650,19 @@ pub fn process_withdraw_from_nonce_account( #[cfg(test)] mod tests { - use { - super::*, - crate::{clap_app::get_clap_app, cli::parse_command}, - solana_sdk::{ - account::Account, - account_utils::StateMut, - fee_calculator::FeeCalculator, - hash::hash, - nonce::{self, state::Versions, State}, - nonce_account, - signature::{read_keypair_file, write_keypair, Keypair, Signer}, - system_program, - }, - tempfile::NamedTempFile, + use super::*; + use crate::{clap_app::get_clap_app, cli::parse_command}; + use solana_sdk::{ + account::Account, + account_utils::StateMut, + fee_calculator::FeeCalculator, + hash::hash, + nonce::{self, state::Versions, State}, + nonce_account, + signature::{read_keypair_file, write_keypair, Keypair, Signer}, + system_program, }; + use tempfile::NamedTempFile; fn make_tmp_file() -> (String, NamedTempFile) { let tmp_file = NamedTempFile::new().unwrap(); diff --git a/cli/src/program.rs b/cli/src/program.rs index 1a8f1c0a87..2ff65641fa 100644 --- a/cli/src/program.rs +++ b/cli/src/program.rs @@ -1,56 +1,57 @@ -use { - crate::{ - checks::*, - cli::{ - log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, - ProcessResult, - }, - }, - bip39::{Language, Mnemonic, MnemonicType, Seed}, - clap::{App, AppSettings, Arg, ArgMatches, SubCommand}, - log::*, - solana_account_decoder::{UiAccountEncoding, UiDataSliceConfig}, - solana_bpf_loader_program::{bpf_verifier, BpfError, ThisInstructionMeter}, - solana_clap_utils::{self, input_parsers::*, input_validators::*, keypair::*}, - solana_cli_output::{ - CliProgram, CliProgramAccountType, CliProgramAuthority, CliProgramBuffer, CliProgramId, - CliUpgradeableBuffer, CliUpgradeableBuffers, CliUpgradeableProgram, - CliUpgradeableProgramClosed, CliUpgradeablePrograms, - }, - solana_client::{ - client_error::ClientErrorKind, - rpc_client::RpcClient, - rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig, RpcSendTransactionConfig}, - rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType}, - tpu_client::{TpuClient, TpuClientConfig}, - }, - solana_rbpf::vm::{Config, Executable}, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{ - account::Account, - account_utils::StateMut, - bpf_loader, bpf_loader_deprecated, - bpf_loader_upgradeable::{self, UpgradeableLoaderState}, - instruction::{Instruction, InstructionError}, - loader_instruction, - message::Message, - native_token::Sol, - packet::PACKET_DATA_SIZE, - pubkey::Pubkey, - signature::{keypair_from_seed, read_keypair_file, Keypair, Signature, Signer}, - system_instruction::{self, SystemError}, - system_program, - transaction::{Transaction, TransactionError}, - }, - std::{ - fs::File, - io::{Read, Write}, - mem::size_of, - path::PathBuf, - str::FromStr, - sync::Arc, +use crate::{ + checks::*, + cli::{ + log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, + ProcessResult, }, }; +use bip39::{Language, Mnemonic, MnemonicType, Seed}; +use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; +use log::*; +use solana_account_decoder::{UiAccountEncoding, UiDataSliceConfig}; +use solana_bpf_loader_program::{bpf_verifier, BpfError, ThisInstructionMeter}; +use solana_clap_utils::{self, input_parsers::*, input_validators::*, keypair::*}; +use solana_cli_output::{ + CliProgram, CliProgramAccountType, CliProgramAuthority, CliProgramBuffer, CliProgramId, + CliUpgradeableBuffer, CliUpgradeableBuffers, CliUpgradeableProgram, + CliUpgradeableProgramClosed, CliUpgradeablePrograms, +}; +use solana_client::{ + client_error::ClientErrorKind, + rpc_client::RpcClient, + rpc_config::RpcSendTransactionConfig, + rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, + rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType}, + tpu_client::{TpuClient, TpuClientConfig}, +}; +use solana_rbpf::vm::{Config, Executable}; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{ + account::Account, + account_utils::StateMut, + bpf_loader, bpf_loader_deprecated, + bpf_loader_upgradeable::{self, UpgradeableLoaderState}, + instruction::Instruction, + instruction::InstructionError, + loader_instruction, + message::Message, + native_token::Sol, + packet::PACKET_DATA_SIZE, + pubkey::Pubkey, + signature::{keypair_from_seed, read_keypair_file, Keypair, Signature, Signer}, + system_instruction::{self, SystemError}, + system_program, + transaction::Transaction, + transaction::TransactionError, +}; +use std::{ + fs::File, + io::{Read, Write}, + mem::size_of, + path::PathBuf, + str::FromStr, + sync::Arc, +}; #[derive(Debug, PartialEq)] pub enum ProgramCliCommand { @@ -2191,16 +2192,14 @@ fn report_ephemeral_mnemonic(words: usize, mnemonic: bip39::Mnemonic) { #[cfg(test)] mod tests { - use { - super::*, - crate::{ - clap_app::get_clap_app, - cli::{parse_command, process_command}, - }, - serde_json::Value, - solana_cli_output::OutputFormat, - solana_sdk::signature::write_keypair_file, + use super::*; + use crate::{ + clap_app::get_clap_app, + cli::{parse_command, process_command}, }; + use serde_json::Value; + use solana_cli_output::OutputFormat; + use solana_sdk::signature::write_keypair_file; fn make_tmp_path(name: &str) -> String { let out_dir = std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()); diff --git a/cli/src/spend_utils.rs b/cli/src/spend_utils.rs index f466fb9f1b..df785e457b 100644 --- a/cli/src/spend_utils.rs +++ b/cli/src/spend_utils.rs @@ -1,15 +1,13 @@ -use { - crate::{ - checks::{calculate_fee, check_account_for_balance_with_commitment}, - cli::CliError, - }, - clap::ArgMatches, - solana_clap_utils::{input_parsers::lamports_of_sol, offline::SIGN_ONLY_ARG}, - solana_client::rpc_client::RpcClient, - solana_sdk::{ - commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, message::Message, - native_token::lamports_to_sol, pubkey::Pubkey, - }, +use crate::{ + checks::{calculate_fee, check_account_for_balance_with_commitment}, + cli::CliError, +}; +use clap::ArgMatches; +use solana_clap_utils::{input_parsers::lamports_of_sol, offline::SIGN_ONLY_ARG}; +use solana_client::rpc_client::RpcClient; +use solana_sdk::{ + commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, message::Message, + native_token::lamports_to_sol, pubkey::Pubkey, }; #[derive(Debug, PartialEq, Clone, Copy)] diff --git a/cli/src/stake.rs b/cli/src/stake.rs index 40ab514b39..6badf1eb17 100644 --- a/cli/src/stake.rs +++ b/cli/src/stake.rs @@ -1,55 +1,53 @@ -use { - crate::{ - checks::{check_account_for_fee_with_commitment, check_unique_pubkeys}, - cli::{ - log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, - ProcessResult, - }, - memo::WithMemo, - nonce::check_nonce_account, - spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount}, +use crate::{ + checks::{check_account_for_fee_with_commitment, check_unique_pubkeys}, + cli::{ + log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, + ProcessResult, }, - clap::{value_t, App, Arg, ArgGroup, ArgMatches, SubCommand}, - solana_clap_utils::{ - fee_payer::{fee_payer_arg, FEE_PAYER_ARG}, - input_parsers::*, - input_validators::*, - keypair::{DefaultSigner, SignerIndex}, - memo::{memo_arg, MEMO_ARG}, - nonce::*, - offline::*, - ArgConstant, - }, - solana_cli_output::{ - return_signers_with_config, CliEpochReward, CliStakeHistory, CliStakeHistoryEntry, - CliStakeState, CliStakeType, OutputFormat, ReturnSignersConfig, - }, - solana_client::{ - blockhash_query::BlockhashQuery, nonce_utils, rpc_client::RpcClient, - rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE, rpc_response::RpcInflationReward, - }, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{ - account::from_account, - account_utils::StateMut, - clock::{Clock, UnixTimestamp, SECONDS_PER_DAY}, - commitment_config::CommitmentConfig, - epoch_schedule::EpochSchedule, - message::Message, - pubkey::Pubkey, - stake::{ - self, - instruction::{self as stake_instruction, LockupArgs, StakeError}, - state::{Authorized, Lockup, Meta, StakeActivationStatus, StakeAuthorize, StakeState}, - }, - stake_history::StakeHistory, - system_instruction::SystemError, - sysvar::{clock, stake_history}, - transaction::Transaction, - }, - solana_vote_program::vote_state::VoteState, - std::{ops::Deref, sync::Arc}, + memo::WithMemo, + nonce::check_nonce_account, + spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount}, }; +use clap::{value_t, App, Arg, ArgGroup, ArgMatches, SubCommand}; +use solana_clap_utils::{ + fee_payer::{fee_payer_arg, FEE_PAYER_ARG}, + input_parsers::*, + input_validators::*, + keypair::{DefaultSigner, SignerIndex}, + memo::{memo_arg, MEMO_ARG}, + nonce::*, + offline::*, + ArgConstant, +}; +use solana_cli_output::{ + return_signers_with_config, CliEpochReward, CliStakeHistory, CliStakeHistoryEntry, + CliStakeState, CliStakeType, OutputFormat, ReturnSignersConfig, +}; +use solana_client::{ + blockhash_query::BlockhashQuery, nonce_utils, rpc_client::RpcClient, + rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE, rpc_response::RpcInflationReward, +}; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{ + account::from_account, + account_utils::StateMut, + clock::{Clock, UnixTimestamp, SECONDS_PER_DAY}, + commitment_config::CommitmentConfig, + epoch_schedule::EpochSchedule, + message::Message, + pubkey::Pubkey, + stake::{ + self, + instruction::{self as stake_instruction, LockupArgs, StakeError}, + state::{Authorized, Lockup, Meta, StakeActivationStatus, StakeAuthorize, StakeState}, + }, + stake_history::StakeHistory, + system_instruction::SystemError, + sysvar::{clock, stake_history}, + transaction::Transaction, +}; +use solana_vote_program::vote_state::VoteState; +use std::{ops::Deref, sync::Arc}; pub const STAKE_AUTHORITY_ARG: ArgConstant<'static> = ArgConstant { name: "stake_authority", @@ -2440,18 +2438,16 @@ pub fn process_delegate_stake( #[cfg(test)] mod tests { - use { - super::*, - crate::{clap_app::get_clap_app, cli::parse_command}, - solana_client::blockhash_query, - solana_sdk::{ - hash::Hash, - signature::{ - keypair_from_seed, read_keypair_file, write_keypair, Keypair, Presigner, Signer, - }, + use super::*; + use crate::{clap_app::get_clap_app, cli::parse_command}; + use solana_client::blockhash_query; + use solana_sdk::{ + hash::Hash, + signature::{ + keypair_from_seed, read_keypair_file, write_keypair, Keypair, Presigner, Signer, }, - tempfile::NamedTempFile, }; + use tempfile::NamedTempFile; fn make_tmp_file() -> (String, NamedTempFile) { let tmp_file = NamedTempFile::new().unwrap(); diff --git a/cli/src/test_utils.rs b/cli/src/test_utils.rs index b3903ad090..4e526d7f63 100644 --- a/cli/src/test_utils.rs +++ b/cli/src/test_utils.rs @@ -1,8 +1,6 @@ -use { - solana_client::rpc_client::RpcClient, - solana_sdk::{clock::DEFAULT_MS_PER_SLOT, commitment_config::CommitmentConfig, pubkey::Pubkey}, - std::{thread::sleep, time::Duration}, -}; +use solana_client::rpc_client::RpcClient; +use solana_sdk::{clock::DEFAULT_MS_PER_SLOT, commitment_config::CommitmentConfig, pubkey::Pubkey}; +use std::{thread::sleep, time::Duration}; pub fn check_recent_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) { (0..5).for_each(|tries| { diff --git a/cli/src/validator_info.rs b/cli/src/validator_info.rs index f1150a0d65..61054a3e98 100644 --- a/cli/src/validator_info.rs +++ b/cli/src/validator_info.rs @@ -1,33 +1,31 @@ -use { - crate::{ - cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, - spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, - }, - bincode::deserialize, - clap::{App, AppSettings, Arg, ArgMatches, SubCommand}, - reqwest::blocking::Client, - serde_json::{Map, Value}, - solana_account_decoder::validator_info::{ - self, ValidatorInfo, MAX_LONG_FIELD_LENGTH, MAX_SHORT_FIELD_LENGTH, - }, - solana_clap_utils::{ - input_parsers::pubkey_of, - input_validators::{is_pubkey, is_url}, - keypair::DefaultSigner, - }, - solana_cli_output::{CliValidatorInfo, CliValidatorInfoVec}, - solana_client::rpc_client::RpcClient, - solana_config_program::{config_instruction, get_config_data, ConfigKeys, ConfigState}, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{ - account::Account, - message::Message, - pubkey::Pubkey, - signature::{Keypair, Signer}, - transaction::Transaction, - }, - std::{error, sync::Arc}, +use crate::{ + cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, + spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, }; +use bincode::deserialize; +use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; +use reqwest::blocking::Client; +use serde_json::{Map, Value}; +use solana_account_decoder::validator_info::{ + self, ValidatorInfo, MAX_LONG_FIELD_LENGTH, MAX_SHORT_FIELD_LENGTH, +}; +use solana_clap_utils::{ + input_parsers::pubkey_of, + input_validators::{is_pubkey, is_url}, + keypair::DefaultSigner, +}; +use solana_cli_output::{CliValidatorInfo, CliValidatorInfoVec}; +use solana_client::rpc_client::RpcClient; +use solana_config_program::{config_instruction, get_config_data, ConfigKeys, ConfigState}; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{ + account::Account, + message::Message, + pubkey::Pubkey, + signature::{Keypair, Signer}, + transaction::Transaction, +}; +use std::{error, sync::Arc}; // Return an error if a validator details are longer than the max length. pub fn check_details_length(string: String) -> Result<(), String> { @@ -409,12 +407,10 @@ pub fn process_get_validator_info( #[cfg(test)] mod tests { - use { - super::*, - crate::clap_app::get_clap_app, - bincode::{serialize, serialized_size}, - serde_json::json, - }; + use super::*; + use crate::clap_app::get_clap_app; + use bincode::{serialize, serialized_size}; + use serde_json::json; #[test] fn test_check_url() { diff --git a/cli/src/vote.rs b/cli/src/vote.rs index 6f7c25ebab..3c4ba497bf 100644 --- a/cli/src/vote.rs +++ b/cli/src/vote.rs @@ -1,35 +1,33 @@ -use { - crate::{ - checks::{check_account_for_fee_with_commitment, check_unique_pubkeys}, - cli::{ - log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, - ProcessResult, - }, - memo::WithMemo, - spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, - stake::check_current_authority, +use crate::{ + checks::{check_account_for_fee_with_commitment, check_unique_pubkeys}, + cli::{ + log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, + ProcessResult, }, - clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand}, - solana_clap_utils::{ - input_parsers::*, - input_validators::*, - keypair::{DefaultSigner, SignerIndex}, - memo::{memo_arg, MEMO_ARG}, - }, - solana_cli_output::{CliEpochVotingHistory, CliLockout, CliVoteAccount}, - solana_client::rpc_client::RpcClient, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{ - account::Account, commitment_config::CommitmentConfig, message::Message, - native_token::lamports_to_sol, pubkey::Pubkey, system_instruction::SystemError, - transaction::Transaction, - }, - solana_vote_program::{ - vote_instruction::{self, withdraw, VoteError}, - vote_state::{VoteAuthorize, VoteInit, VoteState}, - }, - std::sync::Arc, + memo::WithMemo, + spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, + stake::check_current_authority, }; +use clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand}; +use solana_clap_utils::{ + input_parsers::*, + input_validators::*, + keypair::{DefaultSigner, SignerIndex}, + memo::{memo_arg, MEMO_ARG}, +}; +use solana_cli_output::{CliEpochVotingHistory, CliLockout, CliVoteAccount}; +use solana_client::rpc_client::RpcClient; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{ + account::Account, commitment_config::CommitmentConfig, message::Message, + native_token::lamports_to_sol, pubkey::Pubkey, system_instruction::SystemError, + transaction::Transaction, +}; +use solana_vote_program::{ + vote_instruction::{self, withdraw, VoteError}, + vote_state::{VoteAuthorize, VoteInit, VoteState}, +}; +use std::sync::Arc; pub trait VoteSubCommands { fn vote_subcommands(self) -> Self; @@ -939,12 +937,10 @@ pub fn process_withdraw_from_vote_account( #[cfg(test)] mod tests { - use { - super::*, - crate::{clap_app::get_clap_app, cli::parse_command}, - solana_sdk::signature::{read_keypair_file, write_keypair, Keypair, Signer}, - tempfile::NamedTempFile, - }; + use super::*; + use crate::{clap_app::get_clap_app, cli::parse_command}; + use solana_sdk::signature::{read_keypair_file, write_keypair, Keypair, Signer}; + use tempfile::NamedTempFile; fn make_tmp_file() -> (String, NamedTempFile) { let tmp_file = NamedTempFile::new().unwrap(); diff --git a/cli/src/wallet.rs b/cli/src/wallet.rs index bf2dab9b31..f375562588 100644 --- a/cli/src/wallet.rs +++ b/cli/src/wallet.rs @@ -1,47 +1,45 @@ -use { - crate::{ - cli::{ - log_instruction_custom_error, request_and_confirm_airdrop, CliCommand, CliCommandInfo, - CliConfig, CliError, ProcessResult, - }, - memo::WithMemo, - nonce::check_nonce_account, - spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount}, +use crate::{ + cli::{ + log_instruction_custom_error, request_and_confirm_airdrop, CliCommand, CliCommandInfo, + CliConfig, CliError, ProcessResult, }, - clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand}, - solana_account_decoder::{UiAccount, UiAccountEncoding}, - solana_clap_utils::{ - fee_payer::*, - input_parsers::*, - input_validators::*, - keypair::{DefaultSigner, SignerIndex}, - memo::*, - nonce::*, - offline::*, - }, - solana_cli_output::{ - display::build_balance_message, return_signers_with_config, CliAccount, - CliSignatureVerificationStatus, CliTransaction, CliTransactionConfirmation, OutputFormat, - ReturnSignersConfig, - }, - solana_client::{ - blockhash_query::BlockhashQuery, nonce_utils, rpc_client::RpcClient, - rpc_config::RpcTransactionConfig, rpc_response::RpcKeyedAccount, - }, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{ - commitment_config::CommitmentConfig, - message::Message, - pubkey::Pubkey, - signature::Signature, - stake, - system_instruction::{self, SystemError}, - system_program, - transaction::Transaction, - }, - solana_transaction_status::{EncodedTransaction, UiTransactionEncoding}, - std::{fmt::Write as FmtWrite, fs::File, io::Write, sync::Arc}, + memo::WithMemo, + nonce::check_nonce_account, + spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount}, }; +use clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand}; +use solana_account_decoder::{UiAccount, UiAccountEncoding}; +use solana_clap_utils::{ + fee_payer::*, + input_parsers::*, + input_validators::*, + keypair::{DefaultSigner, SignerIndex}, + memo::*, + nonce::*, + offline::*, +}; +use solana_cli_output::{ + display::build_balance_message, return_signers_with_config, CliAccount, + CliSignatureVerificationStatus, CliTransaction, CliTransactionConfirmation, OutputFormat, + ReturnSignersConfig, +}; +use solana_client::{ + blockhash_query::BlockhashQuery, nonce_utils, rpc_client::RpcClient, + rpc_config::RpcTransactionConfig, rpc_response::RpcKeyedAccount, +}; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{ + commitment_config::CommitmentConfig, + message::Message, + pubkey::Pubkey, + signature::Signature, + stake, + system_instruction::{self, SystemError}, + system_program, + transaction::Transaction, +}; +use solana_transaction_status::{EncodedTransaction, UiTransactionEncoding}; +use std::{fmt::Write as FmtWrite, fs::File, io::Write, sync::Arc}; pub trait WalletSubCommands { fn wallet_subcommands(self) -> Self; diff --git a/cli/tests/nonce.rs b/cli/tests/nonce.rs index a6574fe856..fe17bb811e 100644 --- a/cli/tests/nonce.rs +++ b/cli/tests/nonce.rs @@ -1,26 +1,24 @@ -use { - solana_cli::{ - cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, - spend_utils::SpendAmount, - test_utils::{check_ready, check_recent_balance}, - }, - solana_cli_output::{parse_sign_only_reply_string, OutputFormat}, - solana_client::{ - blockhash_query::{self, BlockhashQuery}, - nonce_utils, - rpc_client::RpcClient, - }, - solana_core::test_validator::TestValidator, - solana_faucet::faucet::run_local_faucet, - solana_sdk::{ - commitment_config::CommitmentConfig, - hash::Hash, - pubkey::Pubkey, - signature::{keypair_from_seed, Keypair, Signer}, - system_program, - }, - solana_streamer::socket::SocketAddrSpace, +use solana_cli::{ + cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, + spend_utils::SpendAmount, + test_utils::{check_ready, check_recent_balance}, }; +use solana_cli_output::{parse_sign_only_reply_string, OutputFormat}; +use solana_client::{ + blockhash_query::{self, BlockhashQuery}, + nonce_utils, + rpc_client::RpcClient, +}; +use solana_core::test_validator::TestValidator; +use solana_faucet::faucet::run_local_faucet; +use solana_sdk::{ + commitment_config::CommitmentConfig, + hash::Hash, + pubkey::Pubkey, + signature::{keypair_from_seed, Keypair, Signer}, + system_program, +}; +use solana_streamer::socket::SocketAddrSpace; #[test] fn test_nonce() { diff --git a/cli/tests/program.rs b/cli/tests/program.rs index c215bf763a..2a0d3dc916 100644 --- a/cli/tests/program.rs +++ b/cli/tests/program.rs @@ -1,24 +1,22 @@ -use { - serde_json::Value, - solana_cli::{ - cli::{process_command, CliCommand, CliConfig}, - program::ProgramCliCommand, - }, - solana_cli_output::OutputFormat, - solana_client::rpc_client::RpcClient, - solana_core::test_validator::TestValidator, - solana_faucet::faucet::run_local_faucet, - solana_sdk::{ - account_utils::StateMut, - bpf_loader, - bpf_loader_upgradeable::{self, UpgradeableLoaderState}, - commitment_config::CommitmentConfig, - pubkey::Pubkey, - signature::{Keypair, Signer}, - }, - solana_streamer::socket::SocketAddrSpace, - std::{env, fs::File, io::Read, path::PathBuf, str::FromStr}, +use serde_json::Value; +use solana_cli::{ + cli::{process_command, CliCommand, CliConfig}, + program::ProgramCliCommand, }; +use solana_cli_output::OutputFormat; +use solana_client::rpc_client::RpcClient; +use solana_core::test_validator::TestValidator; +use solana_faucet::faucet::run_local_faucet; +use solana_sdk::{ + account_utils::StateMut, + bpf_loader, + bpf_loader_upgradeable::{self, UpgradeableLoaderState}, + commitment_config::CommitmentConfig, + pubkey::Pubkey, + signature::{Keypair, Signer}, +}; +use solana_streamer::socket::SocketAddrSpace; +use std::{env, fs::File, io::Read, path::PathBuf, str::FromStr}; #[test] fn test_cli_program_deploy_non_upgradeable() { diff --git a/cli/tests/request_airdrop.rs b/cli/tests/request_airdrop.rs index 56c5becc1a..56444472bf 100644 --- a/cli/tests/request_airdrop.rs +++ b/cli/tests/request_airdrop.rs @@ -1,14 +1,12 @@ -use { - solana_cli::cli::{process_command, CliCommand, CliConfig}, - solana_client::rpc_client::RpcClient, - solana_core::test_validator::TestValidator, - solana_faucet::faucet::run_local_faucet, - solana_sdk::{ - commitment_config::CommitmentConfig, - signature::{Keypair, Signer}, - }, - solana_streamer::socket::SocketAddrSpace, +use solana_cli::cli::{process_command, CliCommand, CliConfig}; +use solana_client::rpc_client::RpcClient; +use solana_core::test_validator::TestValidator; +use solana_faucet::faucet::run_local_faucet; +use solana_sdk::{ + commitment_config::CommitmentConfig, + signature::{Keypair, Signer}, }; +use solana_streamer::socket::SocketAddrSpace; #[test] fn test_cli_request_airdrop() { diff --git a/cli/tests/stake.rs b/cli/tests/stake.rs index e9d039ad40..57d96dae37 100644 --- a/cli/tests/stake.rs +++ b/cli/tests/stake.rs @@ -1,32 +1,30 @@ -use { - solana_cli::{ - cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, - spend_utils::SpendAmount, - stake::StakeAuthorizationIndexed, - test_utils::{check_ready, check_recent_balance}, - }, - solana_cli_output::{parse_sign_only_reply_string, OutputFormat}, - solana_client::{ - blockhash_query::{self, BlockhashQuery}, - nonce_utils, - rpc_client::RpcClient, - }, - solana_core::test_validator::TestValidator, - solana_faucet::faucet::run_local_faucet, - solana_sdk::{ - account_utils::StateMut, - commitment_config::CommitmentConfig, - nonce::State as NonceState, - pubkey::Pubkey, - signature::{keypair_from_seed, Keypair, Signer}, - stake::{ - self, - instruction::LockupArgs, - state::{Lockup, StakeAuthorize, StakeState}, - }, - }, - solana_streamer::socket::SocketAddrSpace, +use solana_cli::{ + cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, + spend_utils::SpendAmount, + stake::StakeAuthorizationIndexed, + test_utils::{check_ready, check_recent_balance}, }; +use solana_cli_output::{parse_sign_only_reply_string, OutputFormat}; +use solana_client::{ + blockhash_query::{self, BlockhashQuery}, + nonce_utils, + rpc_client::RpcClient, +}; +use solana_core::test_validator::TestValidator; +use solana_faucet::faucet::run_local_faucet; +use solana_sdk::{ + account_utils::StateMut, + commitment_config::CommitmentConfig, + nonce::State as NonceState, + pubkey::Pubkey, + signature::{keypair_from_seed, Keypair, Signer}, + stake::{ + self, + instruction::LockupArgs, + state::{Lockup, StakeAuthorize, StakeState}, + }, +}; +use solana_streamer::socket::SocketAddrSpace; #[test] fn test_stake_delegation_force() { diff --git a/cli/tests/transfer.rs b/cli/tests/transfer.rs index 938841b720..ad45784614 100644 --- a/cli/tests/transfer.rs +++ b/cli/tests/transfer.rs @@ -1,26 +1,24 @@ -use { - solana_cli::{ - cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, - spend_utils::SpendAmount, - test_utils::{check_ready, check_recent_balance}, - }, - solana_cli_output::{parse_sign_only_reply_string, OutputFormat}, - solana_client::{ - blockhash_query::{self, BlockhashQuery}, - nonce_utils, - rpc_client::RpcClient, - }, - solana_core::test_validator::TestValidator, - solana_faucet::faucet::run_local_faucet, - solana_sdk::{ - commitment_config::CommitmentConfig, - nonce::State as NonceState, - pubkey::Pubkey, - signature::{keypair_from_seed, Keypair, NullSigner, Signer}, - stake, - }, - solana_streamer::socket::SocketAddrSpace, +use solana_cli::{ + cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, + spend_utils::SpendAmount, + test_utils::{check_ready, check_recent_balance}, }; +use solana_cli_output::{parse_sign_only_reply_string, OutputFormat}; +use solana_client::{ + blockhash_query::{self, BlockhashQuery}, + nonce_utils, + rpc_client::RpcClient, +}; +use solana_core::test_validator::TestValidator; +use solana_faucet::faucet::run_local_faucet; +use solana_sdk::{ + commitment_config::CommitmentConfig, + nonce::State as NonceState, + pubkey::Pubkey, + signature::{keypair_from_seed, Keypair, NullSigner, Signer}, + stake, +}; +use solana_streamer::socket::SocketAddrSpace; #[test] fn test_transfer() { diff --git a/cli/tests/vote.rs b/cli/tests/vote.rs index c0e6cb51cd..49336d9cb2 100644 --- a/cli/tests/vote.rs +++ b/cli/tests/vote.rs @@ -1,23 +1,21 @@ -use { - solana_cli::{ - cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, - spend_utils::SpendAmount, - test_utils::check_recent_balance, - }, - solana_client::{ - blockhash_query::{self, BlockhashQuery}, - rpc_client::RpcClient, - }, - solana_core::test_validator::TestValidator, - solana_faucet::faucet::run_local_faucet, - solana_sdk::{ - account_utils::StateMut, - commitment_config::CommitmentConfig, - signature::{Keypair, Signer}, - }, - solana_streamer::socket::SocketAddrSpace, - solana_vote_program::vote_state::{VoteAuthorize, VoteState, VoteStateVersions}, +use solana_cli::{ + cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, + spend_utils::SpendAmount, + test_utils::check_recent_balance, }; +use solana_client::{ + blockhash_query::{self, BlockhashQuery}, + rpc_client::RpcClient, +}; +use solana_core::test_validator::TestValidator; +use solana_faucet::faucet::run_local_faucet; +use solana_sdk::{ + account_utils::StateMut, + commitment_config::CommitmentConfig, + signature::{Keypair, Signer}, +}; +use solana_streamer::socket::SocketAddrSpace; +use solana_vote_program::vote_state::{VoteAuthorize, VoteState, VoteStateVersions}; #[test] fn test_vote_authorize_and_withdraw() { diff --git a/client/src/blockhash_query.rs b/client/src/blockhash_query.rs index 1ced4dfb4f..78dd26e391 100644 --- a/client/src/blockhash_query.rs +++ b/client/src/blockhash_query.rs @@ -118,19 +118,17 @@ impl Default for BlockhashQuery { #[cfg(test)] mod tests { - use { - super::*, - crate::{ - blockhash_query, - rpc_request::RpcRequest, - rpc_response::{Response, RpcFeeCalculator, RpcFees, RpcResponseContext}, - }, - clap::App, - serde_json::{self, json}, - solana_account_decoder::{UiAccount, UiAccountEncoding}, - solana_sdk::{account::Account, hash::hash, nonce, system_program}, - std::collections::HashMap, + use super::*; + use crate::{ + blockhash_query, + rpc_request::RpcRequest, + rpc_response::{Response, RpcFeeCalculator, RpcFees, RpcResponseContext}, }; + use clap::App; + use serde_json::{self, json}; + use solana_account_decoder::{UiAccount, UiAccountEncoding}; + use solana_sdk::{account::Account, hash::hash, nonce, system_program}; + use std::collections::HashMap; #[test] fn test_blockhash_query_new_ok() { diff --git a/client/src/client_error.rs b/client/src/client_error.rs index 64d1d5c2f6..365d70941c 100644 --- a/client/src/client_error.rs +++ b/client/src/client_error.rs @@ -1,4 +1,3 @@ -pub use reqwest; use { crate::{rpc_request, rpc_response}, solana_faucet::faucet::FaucetError, @@ -7,7 +6,9 @@ use { }, std::io, thiserror::Error, -}; // export `reqwest` for clients +}; + +pub use reqwest; // export `reqwest` for clients #[derive(Error, Debug)] pub enum ClientErrorKind { diff --git a/client/src/rpc_client.rs b/client/src/rpc_client.rs index 759b4a3322..99febbab40 100644 --- a/client/src/rpc_client.rs +++ b/client/src/rpc_client.rs @@ -16,7 +16,8 @@ use { client_error::{ClientError, ClientErrorKind, Result as ClientResult}, http_sender::HttpSender, mock_sender::{MockSender, Mocks}, - rpc_config::{RpcAccountInfoConfig, *}, + rpc_config::RpcAccountInfoConfig, + rpc_config::*, rpc_request::{RpcError, RpcRequest, RpcResponseErrorData, TokenAccountsFilter}, rpc_response::*, rpc_sender::*, @@ -4783,21 +4784,19 @@ pub fn create_rpc_client_mocks() -> crate::mock_sender::Mocks { #[cfg(test)] mod tests { - use { - super::*, - crate::{client_error::ClientErrorKind, mock_sender::PUBKEY}, - assert_matches::assert_matches, - jsonrpc_core::{futures::prelude::*, Error, IoHandler, Params}, - jsonrpc_http_server::{AccessControlAllowOrigin, DomainsValidation, ServerBuilder}, - serde_json::Number, - solana_sdk::{ - instruction::InstructionError, - signature::{Keypair, Signer}, - system_transaction, - transaction::TransactionError, - }, - std::{io, sync::mpsc::channel, thread}, + use super::*; + use crate::{client_error::ClientErrorKind, mock_sender::PUBKEY}; + use assert_matches::assert_matches; + use jsonrpc_core::{futures::prelude::*, Error, IoHandler, Params}; + use jsonrpc_http_server::{AccessControlAllowOrigin, DomainsValidation, ServerBuilder}; + use serde_json::Number; + use solana_sdk::{ + instruction::InstructionError, + signature::{Keypair, Signer}, + system_transaction, + transaction::TransactionError, }; + use std::{io, sync::mpsc::channel, thread}; #[test] fn test_send() { diff --git a/client/src/rpc_custom_error.rs b/client/src/rpc_custom_error.rs index 6b0aa2f959..fb195c4b49 100644 --- a/client/src/rpc_custom_error.rs +++ b/client/src/rpc_custom_error.rs @@ -1,9 +1,9 @@ //! Implementation defined RPC server errors +use thiserror::Error; use { crate::rpc_response::RpcSimulateTransactionResult, jsonrpc_core::{Error, ErrorCode}, solana_sdk::clock::Slot, - thiserror::Error, }; pub const JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: i64 = -32001; diff --git a/client/src/rpc_request.rs b/client/src/rpc_request.rs index 707adec984..52bae09c16 100644 --- a/client/src/rpc_request.rs +++ b/client/src/rpc_request.rs @@ -241,11 +241,9 @@ pub enum TokenAccountsFilter { #[cfg(test)] mod tests { - use { - super::*, - crate::rpc_config::RpcTokenAccountsFilter, - solana_sdk::commitment_config::{CommitmentConfig, CommitmentLevel}, - }; + use super::*; + use crate::rpc_config::RpcTokenAccountsFilter; + use solana_sdk::commitment_config::{CommitmentConfig, CommitmentLevel}; #[test] fn test_build_request_json() { diff --git a/client/src/thin_client.rs b/client/src/thin_client.rs index eb34d27781..3988e8e5d0 100644 --- a/client/src/thin_client.rs +++ b/client/src/thin_client.rs @@ -622,7 +622,8 @@ pub fn create_client_with_timeout( #[cfg(test)] mod tests { - use {super::*, rayon::prelude::*}; + use super::*; + use rayon::prelude::*; #[test] fn test_client_optimizer() { diff --git a/client/src/tpu_client.rs b/client/src/tpu_client.rs index ddc202ec12..4699f665fe 100644 --- a/client/src/tpu_client.rs +++ b/client/src/tpu_client.rs @@ -1,36 +1,34 @@ -use { - crate::{ - client_error::ClientError, - pubsub_client::{PubsubClient, PubsubClientError, PubsubClientSubscription}, - rpc_client::RpcClient, - rpc_request::MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, - rpc_response::{Fees, SlotUpdate}, - spinner, - }, - bincode::serialize, - log::*, - solana_sdk::{ - clock::Slot, - commitment_config::CommitmentConfig, - message::Message, - pubkey::Pubkey, - signature::SignerError, - signers::Signers, - transaction::{Transaction, TransactionError}, - }, - std::{ - collections::{HashMap, HashSet, VecDeque}, - net::{SocketAddr, UdpSocket}, - str::FromStr, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, RwLock, - }, - thread::{sleep, JoinHandle}, - time::{Duration, Instant}, - }, - thiserror::Error, +use crate::{ + client_error::ClientError, + pubsub_client::{PubsubClient, PubsubClientError, PubsubClientSubscription}, + rpc_client::RpcClient, + rpc_request::MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, + rpc_response::{Fees, SlotUpdate}, + spinner, }; +use bincode::serialize; +use log::*; +use solana_sdk::{ + clock::Slot, + commitment_config::CommitmentConfig, + message::Message, + pubkey::Pubkey, + signature::SignerError, + signers::Signers, + transaction::{Transaction, TransactionError}, +}; +use std::{ + collections::{HashMap, HashSet, VecDeque}, + net::{SocketAddr, UdpSocket}, + str::FromStr, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, RwLock, + }, + thread::{sleep, JoinHandle}, + time::{Duration, Instant}, +}; +use thiserror::Error; #[derive(Error, Debug)] pub enum TpuSenderError { diff --git a/core/benches/banking_stage.rs b/core/benches/banking_stage.rs index 5057a78dd2..22e493cd6a 100644 --- a/core/benches/banking_stage.rs +++ b/core/benches/banking_stage.rs @@ -3,41 +3,40 @@ extern crate test; -use { - crossbeam_channel::unbounded, - log::*, - rand::{thread_rng, Rng}, - rayon::prelude::*, - solana_core::banking_stage::{BankingStage, BankingStageStats}, - solana_gossip::cluster_info::{ClusterInfo, Node}, - solana_ledger::{ - blockstore::Blockstore, - blockstore_processor::process_entries, - entry::{next_hash, Entry}, - genesis_utils::{create_genesis_config, GenesisConfigInfo}, - get_tmp_ledger_path, - }, - solana_perf::{packet::to_packets_chunked, test_tx::test_tx}, - solana_poh::poh_recorder::{create_test_recorder, WorkingBankEntry}, - solana_runtime::{bank::Bank, cost_model::CostModel}, - solana_sdk::{ - genesis_config::GenesisConfig, - hash::Hash, - message::Message, - pubkey, - signature::{Keypair, Signature, Signer}, - system_instruction, system_transaction, - timing::{duration_as_us, timestamp}, - transaction::Transaction, - }, - solana_streamer::socket::SocketAddrSpace, - std::{ - collections::VecDeque, - sync::{atomic::Ordering, mpsc::Receiver, Arc, RwLock}, - time::{Duration, Instant}, - }, - test::Bencher, -}; +use crossbeam_channel::unbounded; +use log::*; +use rand::{thread_rng, Rng}; +use rayon::prelude::*; +use solana_core::banking_stage::{BankingStage, BankingStageStats}; +use solana_gossip::cluster_info::ClusterInfo; +use solana_gossip::cluster_info::Node; +use solana_ledger::blockstore_processor::process_entries; +use solana_ledger::entry::{next_hash, Entry}; +use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}; +use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path}; +use solana_perf::packet::to_packets_chunked; +use solana_perf::test_tx::test_tx; +use solana_poh::poh_recorder::{create_test_recorder, WorkingBankEntry}; +use solana_runtime::bank::Bank; +use solana_runtime::cost_model::CostModel; +use solana_sdk::genesis_config::GenesisConfig; +use solana_sdk::hash::Hash; +use solana_sdk::message::Message; +use solana_sdk::pubkey; +use solana_sdk::signature::Keypair; +use solana_sdk::signature::Signature; +use solana_sdk::signature::Signer; +use solana_sdk::system_instruction; +use solana_sdk::system_transaction; +use solana_sdk::timing::{duration_as_us, timestamp}; +use solana_sdk::transaction::Transaction; +use solana_streamer::socket::SocketAddrSpace; +use std::collections::VecDeque; +use std::sync::atomic::Ordering; +use std::sync::mpsc::Receiver; +use std::sync::{Arc, RwLock}; +use std::time::{Duration, Instant}; +use test::Bencher; fn check_txs(receiver: &Arc>, ref_tx_count: usize) { let mut total = 0; diff --git a/core/benches/blockstore.rs b/core/benches/blockstore.rs index 1d0a1ce79e..48480f28a0 100644 --- a/core/benches/blockstore.rs +++ b/core/benches/blockstore.rs @@ -3,17 +3,15 @@ extern crate solana_ledger; extern crate test; -use { - rand::Rng, - solana_ledger::{ - blockstore::{entries_to_test_shreds, Blockstore}, - entry::{create_ticks, Entry}, - get_tmp_ledger_path, - }, - solana_sdk::{clock::Slot, hash::Hash}, - std::path::Path, - test::Bencher, +use rand::Rng; +use solana_ledger::{ + blockstore::{entries_to_test_shreds, Blockstore}, + entry::{create_ticks, Entry}, + get_tmp_ledger_path, }; +use solana_sdk::{clock::Slot, hash::Hash}; +use std::path::Path; +use test::Bencher; // Given some shreds and a ledger at ledger_path, benchmark writing the shreds to the ledger fn bench_write_shreds(bench: &mut Bencher, entries: Vec, ledger_path: &Path) { diff --git a/core/benches/consensus.rs b/core/benches/consensus.rs index e942bd794b..280ee08c13 100644 --- a/core/benches/consensus.rs +++ b/core/benches/consensus.rs @@ -3,17 +3,16 @@ extern crate solana_core; extern crate test; -use { - solana_core::consensus::Tower, - solana_runtime::{bank::Bank, bank_forks::BankForks}, - solana_sdk::{ - pubkey::Pubkey, - signature::{Keypair, Signer}, - }, - std::sync::Arc, - tempfile::TempDir, - test::Bencher, +use solana_core::consensus::Tower; +use solana_runtime::bank::Bank; +use solana_runtime::bank_forks::BankForks; +use solana_sdk::{ + pubkey::Pubkey, + signature::{Keypair, Signer}, }; +use std::sync::Arc; +use tempfile::TempDir; +use test::Bencher; #[bench] fn bench_save_tower(bench: &mut Bencher) { diff --git a/core/benches/gen_keys.rs b/core/benches/gen_keys.rs index 410ec2b733..c584e83ed2 100644 --- a/core/benches/gen_keys.rs +++ b/core/benches/gen_keys.rs @@ -2,7 +2,8 @@ extern crate test; -use {solana_core::gen_keys::GenKeys, test::Bencher}; +use solana_core::gen_keys::GenKeys; +use test::Bencher; #[bench] fn bench_gen_keys(b: &mut Bencher) { diff --git a/core/benches/shredder.rs b/core/benches/shredder.rs index 6991d63927..5a99f15dcc 100644 --- a/core/benches/shredder.rs +++ b/core/benches/shredder.rs @@ -3,22 +3,19 @@ extern crate test; -use { - rand::seq::SliceRandom, - raptorq::{Decoder, Encoder}, - solana_ledger::{ - entry::{create_ticks, Entry}, - shred::{ - max_entries_per_n_shred, max_ticks_per_n_shreds, ProcessShredsStats, Shred, Shredder, - MAX_DATA_SHREDS_PER_FEC_BLOCK, SHRED_PAYLOAD_SIZE, SIZE_OF_CODING_SHRED_HEADERS, - SIZE_OF_DATA_SHRED_PAYLOAD, - }, - }, - solana_perf::test_tx, - solana_sdk::{hash::Hash, signature::Keypair}, - std::sync::Arc, - test::Bencher, +use rand::seq::SliceRandom; +use raptorq::{Decoder, Encoder}; +use solana_ledger::entry::{create_ticks, Entry}; +use solana_ledger::shred::{ + max_entries_per_n_shred, max_ticks_per_n_shreds, ProcessShredsStats, Shred, Shredder, + MAX_DATA_SHREDS_PER_FEC_BLOCK, SHRED_PAYLOAD_SIZE, SIZE_OF_CODING_SHRED_HEADERS, + SIZE_OF_DATA_SHRED_PAYLOAD, }; +use solana_perf::test_tx; +use solana_sdk::hash::Hash; +use solana_sdk::signature::Keypair; +use std::sync::Arc; +use test::Bencher; fn make_test_entry(txs_per_entry: u64) -> Entry { Entry { diff --git a/core/benches/sigverify_stage.rs b/core/benches/sigverify_stage.rs index e48ab9301c..1a14c80835 100644 --- a/core/benches/sigverify_stage.rs +++ b/core/benches/sigverify_stage.rs @@ -3,24 +3,20 @@ extern crate solana_core; extern crate test; -use { - crossbeam_channel::unbounded, - log::*, - rand::{thread_rng, Rng}, - solana_core::{sigverify::TransactionSigVerifier, sigverify_stage::SigVerifyStage}, - solana_perf::{packet::to_packets_chunked, test_tx::test_tx}, - solana_sdk::{ - hash::Hash, - signature::{Keypair, Signer}, - system_transaction, - timing::duration_as_ms, - }, - std::{ - sync::mpsc::channel, - time::{Duration, Instant}, - }, - test::Bencher, -}; +use crossbeam_channel::unbounded; +use log::*; +use rand::{thread_rng, Rng}; +use solana_core::sigverify::TransactionSigVerifier; +use solana_core::sigverify_stage::SigVerifyStage; +use solana_perf::packet::to_packets_chunked; +use solana_perf::test_tx::test_tx; +use solana_sdk::hash::Hash; +use solana_sdk::signature::{Keypair, Signer}; +use solana_sdk::system_transaction; +use solana_sdk::timing::duration_as_ms; +use std::sync::mpsc::channel; +use std::time::{Duration, Instant}; +use test::Bencher; #[bench] fn bench_packet_discard(bencher: &mut Bencher) { diff --git a/core/src/accounts_hash_verifier.rs b/core/src/accounts_hash_verifier.rs index 4fc3d95f17..3222d5edf7 100644 --- a/core/src/accounts_hash_verifier.rs +++ b/core/src/accounts_hash_verifier.rs @@ -4,25 +4,23 @@ // hash on gossip. Monitor gossip for messages from validators in the `--known-validator`s // set and halt the node if a mismatch is detected. -use { - crate::snapshot_packager_service::PendingSnapshotPackage, - rayon::ThreadPool, - solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES}, - solana_runtime::{ - accounts_db, - snapshot_package::{AccountsPackage, AccountsPackagePre, AccountsPackageReceiver}, - }, - solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey}, - std::{ - collections::{HashMap, HashSet}, - sync::{ - atomic::{AtomicBool, Ordering}, - mpsc::RecvTimeoutError, - Arc, - }, - thread::{self, Builder, JoinHandle}, - time::Duration, +use crate::snapshot_packager_service::PendingSnapshotPackage; +use rayon::ThreadPool; +use solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES}; +use solana_runtime::{ + accounts_db, + snapshot_package::{AccountsPackage, AccountsPackagePre, AccountsPackageReceiver}, +}; +use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey}; +use std::collections::{HashMap, HashSet}; +use std::{ + sync::{ + atomic::{AtomicBool, Ordering}, + mpsc::RecvTimeoutError, + Arc, }, + thread::{self, Builder, JoinHandle}, + time::Duration, }; pub struct AccountsHashVerifier { @@ -131,10 +129,8 @@ impl AccountsHashVerifier { && accounts_package.slot % fault_injection_rate_slots == 0 { // For testing, publish an invalid hash to gossip. - use { - rand::{thread_rng, Rng}, - solana_sdk::hash::extend_and_hash, - }; + use rand::{thread_rng, Rng}; + use solana_sdk::hash::extend_and_hash; warn!("inserting fault at slot: {}", accounts_package.slot); let rand = thread_rng().gen_range(0, 10); let hash = extend_and_hash(&hash, &[rand]); @@ -219,16 +215,15 @@ impl AccountsHashVerifier { #[cfg(test)] mod tests { - use { - super::*, - solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo}, - solana_runtime::{bank_forks::ArchiveFormat, snapshot_utils::SnapshotVersion}, - solana_sdk::{ - hash::hash, - signature::{Keypair, Signer}, - }, - solana_streamer::socket::SocketAddrSpace, + use super::*; + use solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo}; + use solana_runtime::bank_forks::ArchiveFormat; + use solana_runtime::snapshot_utils::SnapshotVersion; + use solana_sdk::{ + hash::hash, + signature::{Keypair, Signer}, }; + use solana_streamer::socket::SocketAddrSpace; fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo { ClusterInfo::new( @@ -274,7 +269,8 @@ mod tests { #[test] fn test_max_hashes() { solana_logger::setup(); - use {std::path::PathBuf, tempfile::TempDir}; + use std::path::PathBuf; + use tempfile::TempDir; let keypair = Keypair::new(); let contact_info = ContactInfo::new_localhost(&keypair.pubkey(), 0); diff --git a/core/src/banking_stage.rs b/core/src/banking_stage.rs index 90717ac8c4..2cf147b96a 100644 --- a/core/src/banking_stage.rs +++ b/core/src/banking_stage.rs @@ -1,67 +1,64 @@ //! The `banking_stage` processes Transaction messages. It is intended to be used //! to contruct a software pipeline. The stage uses all available CPU cores and //! can do its processing in parallel with signature verification on the GPU. -use { - crate::packet_hasher::PacketHasher, - crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError}, - itertools::Itertools, - lru::LruCache, - retain_mut::RetainMut, - solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo}, - solana_ledger::{blockstore_processor::TransactionStatusSender, entry::hash_transactions}, - solana_measure::measure::Measure, - solana_metrics::{inc_new_counter_debug, inc_new_counter_info}, - solana_perf::{ - cuda_runtime::PinnedVec, - data_budget::DataBudget, - packet::{limited_deserialize, Packet, Packets, PACKETS_PER_BATCH}, - perf_libs, +use crate::packet_hasher::PacketHasher; +use crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError}; +use itertools::Itertools; +use lru::LruCache; +use retain_mut::RetainMut; +use solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo}; +use solana_ledger::{blockstore_processor::TransactionStatusSender, entry::hash_transactions}; +use solana_measure::measure::Measure; +use solana_metrics::{inc_new_counter_debug, inc_new_counter_info}; +use solana_perf::{ + cuda_runtime::PinnedVec, + data_budget::DataBudget, + packet::{limited_deserialize, Packet, Packets, PACKETS_PER_BATCH}, + perf_libs, +}; +use solana_poh::poh_recorder::{PohRecorder, PohRecorderError, TransactionRecorder}; +use solana_runtime::{ + accounts_db::ErrorCounters, + bank::{ + Bank, ExecuteTimings, TransactionBalancesSet, TransactionCheckResult, + TransactionExecutionResult, }, - solana_poh::poh_recorder::{PohRecorder, PohRecorderError, TransactionRecorder}, - solana_runtime::{ - accounts_db::ErrorCounters, - bank::{ - Bank, ExecuteTimings, TransactionBalancesSet, TransactionCheckResult, - TransactionExecutionResult, - }, - bank_utils, - cost_model::CostModel, - cost_tracker::CostTracker, - hashed_transaction::HashedTransaction, - transaction_batch::TransactionBatch, - vote_sender_types::ReplayVoteSender, - }, - solana_sdk::{ - clock::{ - Slot, DEFAULT_TICKS_PER_SLOT, MAX_PROCESSING_AGE, MAX_TRANSACTION_FORWARDING_DELAY, - MAX_TRANSACTION_FORWARDING_DELAY_GPU, - }, - feature_set, - message::Message, - pubkey::Pubkey, - short_vec::decode_shortu16_len, - signature::Signature, - timing::{duration_as_ms, timestamp, AtomicInterval}, - transaction::{self, Transaction, TransactionError}, - }, - solana_transaction_status::token_balances::{ - collect_token_balances, TransactionTokenBalancesSet, - }, - std::{ - borrow::Cow, - cmp, - collections::{HashMap, VecDeque}, - env, - mem::size_of, - net::{SocketAddr, UdpSocket}, - ops::DerefMut, - sync::{ - atomic::{AtomicU64, AtomicUsize, Ordering}, - Arc, Mutex, RwLock, RwLockReadGuard, - }, - thread::{self, Builder, JoinHandle}, - time::{Duration, Instant}, + bank_utils, + cost_model::CostModel, + cost_tracker::CostTracker, + hashed_transaction::HashedTransaction, + transaction_batch::TransactionBatch, + vote_sender_types::ReplayVoteSender, +}; +use solana_sdk::{ + clock::{ + Slot, DEFAULT_TICKS_PER_SLOT, MAX_PROCESSING_AGE, MAX_TRANSACTION_FORWARDING_DELAY, + MAX_TRANSACTION_FORWARDING_DELAY_GPU, }, + feature_set, + message::Message, + pubkey::Pubkey, + short_vec::decode_shortu16_len, + signature::Signature, + timing::{duration_as_ms, timestamp, AtomicInterval}, + transaction::{self, Transaction, TransactionError}, +}; +use solana_transaction_status::token_balances::{ + collect_token_balances, TransactionTokenBalancesSet, +}; +use std::{ + borrow::Cow, + cmp, + collections::{HashMap, VecDeque}, + env, + mem::size_of, + net::{SocketAddr, UdpSocket}, + ops::DerefMut, + sync::atomic::{AtomicU64, AtomicUsize, Ordering}, + sync::{Arc, Mutex, RwLock, RwLockReadGuard}, + thread::{self, Builder, JoinHandle}, + time::Duration, + time::Instant, }; /// (packets, valid_indexes, forwarded) @@ -1663,46 +1660,44 @@ where #[cfg(test)] mod tests { - use { - super::*, - crossbeam_channel::unbounded, - itertools::Itertools, - solana_gossip::{cluster_info::Node, contact_info::ContactInfo}, - solana_ledger::{ - blockstore::{entries_to_test_shreds, Blockstore}, - entry::{next_entry, Entry, EntrySlice}, - genesis_utils::{create_genesis_config, GenesisConfigInfo}, - get_tmp_ledger_path, - leader_schedule_cache::LeaderScheduleCache, - }, - solana_perf::packet::to_packets_chunked, - solana_poh::{ - poh_recorder::{create_test_recorder, Record, WorkingBank, WorkingBankEntry}, - poh_service::PohService, - }, - solana_rpc::transaction_status_service::TransactionStatusService, - solana_runtime::cost_model::CostModel, - solana_sdk::{ - hash::Hash, - instruction::InstructionError, - poh_config::PohConfig, - signature::{Keypair, Signer}, - system_instruction::SystemError, - system_transaction, - transaction::TransactionError, - }, - solana_streamer::socket::SocketAddrSpace, - solana_transaction_status::TransactionWithStatusMeta, - solana_vote_program::vote_transaction, - std::{ - net::SocketAddr, - path::Path, - sync::{ - atomic::{AtomicBool, Ordering}, - mpsc::Receiver, - }, - thread::sleep, + use super::*; + use crossbeam_channel::unbounded; + use itertools::Itertools; + use solana_gossip::{cluster_info::Node, contact_info::ContactInfo}; + use solana_ledger::{ + blockstore::{entries_to_test_shreds, Blockstore}, + entry::{next_entry, Entry, EntrySlice}, + genesis_utils::{create_genesis_config, GenesisConfigInfo}, + get_tmp_ledger_path, + leader_schedule_cache::LeaderScheduleCache, + }; + use solana_perf::packet::to_packets_chunked; + use solana_poh::{ + poh_recorder::{create_test_recorder, Record, WorkingBank, WorkingBankEntry}, + poh_service::PohService, + }; + use solana_rpc::transaction_status_service::TransactionStatusService; + use solana_runtime::cost_model::CostModel; + use solana_sdk::{ + hash::Hash, + instruction::InstructionError, + poh_config::PohConfig, + signature::{Keypair, Signer}, + system_instruction::SystemError, + system_transaction, + transaction::TransactionError, + }; + use solana_streamer::socket::SocketAddrSpace; + use solana_transaction_status::TransactionWithStatusMeta; + use solana_vote_program::vote_transaction; + use std::{ + net::SocketAddr, + path::Path, + sync::{ + atomic::{AtomicBool, Ordering}, + mpsc::Receiver, }, + thread::sleep, }; fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo { diff --git a/core/src/broadcast_stage.rs b/core/src/broadcast_stage.rs index 2cd66d8bcc..286c1f4c51 100644 --- a/core/src/broadcast_stage.rs +++ b/core/src/broadcast_stage.rs @@ -23,9 +23,8 @@ use { solana_poh::poh_recorder::WorkingBankEntry, solana_runtime::{bank::Bank, bank_forks::BankForks}, solana_sdk::{ - clock::Slot, - pubkey::Pubkey, timing::{timestamp, AtomicInterval}, + {clock::Slot, pubkey::Pubkey}, }, solana_streamer::{ sendmmsg::{batch_send, SendPktsError}, @@ -450,28 +449,24 @@ pub fn broadcast_shreds( #[cfg(test)] pub mod test { - use { - super::*, - crossbeam_channel::unbounded, - solana_gossip::cluster_info::{ClusterInfo, Node}, - solana_ledger::{ - blockstore::{make_slot_entries, Blockstore}, - entry::create_ticks, - genesis_utils::{create_genesis_config, GenesisConfigInfo}, - get_tmp_ledger_path, - shred::{max_ticks_per_n_shreds, ProcessShredsStats, Shredder}, - }, - solana_runtime::bank::Bank, - solana_sdk::{ - hash::Hash, - pubkey::Pubkey, - signature::{Keypair, Signer}, - }, - std::{ - path::Path, - sync::{atomic::AtomicBool, mpsc::channel, Arc}, - thread::sleep, - }, + use super::*; + use crossbeam_channel::unbounded; + use solana_gossip::cluster_info::{ClusterInfo, Node}; + use solana_ledger::{ + blockstore::{make_slot_entries, Blockstore}, + entry::create_ticks, + genesis_utils::{create_genesis_config, GenesisConfigInfo}, + get_tmp_ledger_path, + shred::{max_ticks_per_n_shreds, ProcessShredsStats, Shredder}, + }; + use solana_runtime::bank::Bank; + use solana_sdk::{ + hash::Hash, + pubkey::Pubkey, + signature::{Keypair, Signer}, + }; + use std::{ + path::Path, sync::atomic::AtomicBool, sync::mpsc::channel, sync::Arc, thread::sleep, }; #[allow(clippy::implicit_hasher)] diff --git a/core/src/broadcast_stage/broadcast_fake_shreds_run.rs b/core/src/broadcast_stage/broadcast_fake_shreds_run.rs index 9b80131f17..1aa2f9e578 100644 --- a/core/src/broadcast_stage/broadcast_fake_shreds_run.rs +++ b/core/src/broadcast_stage/broadcast_fake_shreds_run.rs @@ -1,8 +1,8 @@ -use { - super::*, - solana_ledger::{entry::Entry, shred::Shredder}, - solana_sdk::{hash::Hash, signature::Keypair}, -}; +use super::*; +use solana_ledger::entry::Entry; +use solana_ledger::shred::Shredder; +use solana_sdk::hash::Hash; +use solana_sdk::signature::Keypair; #[derive(Clone)] pub(super) struct BroadcastFakeShredsRun { @@ -139,12 +139,10 @@ impl BroadcastRun for BroadcastFakeShredsRun { #[cfg(test)] mod tests { - use { - super::*, - solana_gossip::contact_info::ContactInfo, - solana_streamer::socket::SocketAddrSpace, - std::net::{IpAddr, Ipv4Addr, SocketAddr}, - }; + use super::*; + use solana_gossip::contact_info::ContactInfo; + use solana_streamer::socket::SocketAddrSpace; + use std::net::{IpAddr, Ipv4Addr, SocketAddr}; #[test] fn test_tvu_peers_ordering() { diff --git a/core/src/broadcast_stage/broadcast_utils.rs b/core/src/broadcast_stage/broadcast_utils.rs index 2e3d832412..08a9d40738 100644 --- a/core/src/broadcast_stage/broadcast_utils.rs +++ b/core/src/broadcast_stage/broadcast_utils.rs @@ -1,13 +1,12 @@ -use { - crate::result::Result, - solana_ledger::{entry::Entry, shred::Shred}, - solana_poh::poh_recorder::WorkingBankEntry, - solana_runtime::bank::Bank, - solana_sdk::clock::Slot, - std::{ - sync::{mpsc::Receiver, Arc}, - time::{Duration, Instant}, - }, +use crate::result::Result; +use solana_ledger::{entry::Entry, shred::Shred}; +use solana_poh::poh_recorder::WorkingBankEntry; +use solana_runtime::bank::Bank; +use solana_sdk::clock::Slot; +use std::{ + sync::mpsc::Receiver, + sync::Arc, + time::{Duration, Instant}, }; pub(super) struct ReceiveResults { @@ -80,15 +79,13 @@ pub(super) fn recv_slot_entries(receiver: &Receiver) -> Result #[cfg(test)] mod tests { - use { - super::*, - solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}, - solana_sdk::{ - genesis_config::GenesisConfig, pubkey::Pubkey, system_transaction, - transaction::Transaction, - }, - std::sync::mpsc::channel, - }; + use super::*; + use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}; + use solana_sdk::genesis_config::GenesisConfig; + use solana_sdk::pubkey::Pubkey; + use solana_sdk::system_transaction; + use solana_sdk::transaction::Transaction; + use std::sync::mpsc::channel; fn setup_test() -> (GenesisConfig, Arc, Transaction) { let GenesisConfigInfo { diff --git a/core/src/broadcast_stage/standard_broadcast_run.rs b/core/src/broadcast_stage/standard_broadcast_run.rs index 7118a64054..e0d2f6740d 100644 --- a/core/src/broadcast_stage/standard_broadcast_run.rs +++ b/core/src/broadcast_stage/standard_broadcast_run.rs @@ -511,21 +511,21 @@ impl BroadcastRun for StandardBroadcastRun { #[cfg(test)] mod test { - use { - super::*, - solana_gossip::cluster_info::{ClusterInfo, Node}, - solana_ledger::{ - blockstore::Blockstore, entry::create_ticks, genesis_utils::create_genesis_config, - get_tmp_ledger_path, shred::max_ticks_per_n_shreds, - }, - solana_runtime::bank::Bank, - solana_sdk::{ - genesis_config::GenesisConfig, - signature::{Keypair, Signer}, - }, - solana_streamer::socket::SocketAddrSpace, - std::{sync::Arc, time::Duration}, + use super::*; + use solana_gossip::cluster_info::{ClusterInfo, Node}; + use solana_ledger::genesis_utils::create_genesis_config; + use solana_ledger::{ + blockstore::Blockstore, entry::create_ticks, get_tmp_ledger_path, + shred::max_ticks_per_n_shreds, }; + use solana_runtime::bank::Bank; + use solana_sdk::{ + genesis_config::GenesisConfig, + signature::{Keypair, Signer}, + }; + use solana_streamer::socket::SocketAddrSpace; + use std::sync::Arc; + use std::time::Duration; #[allow(clippy::type_complexity)] fn setup( diff --git a/core/src/cluster_info_vote_listener.rs b/core/src/cluster_info_vote_listener.rs index 3a6c6b5544..fc9f7a3db6 100644 --- a/core/src/cluster_info_vote_listener.rs +++ b/core/src/cluster_info_vote_listener.rs @@ -1,56 +1,53 @@ -use { - crate::{ - optimistic_confirmation_verifier::OptimisticConfirmationVerifier, - replay_stage::DUPLICATE_THRESHOLD, - result::{Error, Result}, - sigverify, - verified_vote_packets::VerifiedVotePackets, - vote_stake_tracker::VoteStakeTracker, - }, - crossbeam_channel::{ - unbounded, Receiver as CrossbeamReceiver, RecvTimeoutError, Select, - Sender as CrossbeamSender, - }, - itertools::izip, - log::*, - solana_gossip::{ - cluster_info::{ClusterInfo, GOSSIP_SLEEP_MILLIS}, - crds::Cursor, - crds_value::CrdsValueLabel, - }, - solana_ledger::blockstore::Blockstore, - solana_metrics::inc_new_counter_debug, - solana_perf::packet::{self, Packets}, - solana_poh::poh_recorder::PohRecorder, - solana_rpc::{ - optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender}, - rpc_subscriptions::RpcSubscriptions, - }, - solana_runtime::{ - bank::Bank, - bank_forks::BankForks, - commitment::VOTE_THRESHOLD_SIZE, - epoch_stakes::{EpochAuthorizedVoters, EpochStakes}, - stakes::Stakes, - vote_sender_types::{ReplayVoteReceiver, ReplayedVote}, - }, - solana_sdk::{ - clock::{Epoch, Slot, DEFAULT_MS_PER_SLOT, DEFAULT_TICKS_PER_SLOT}, - epoch_schedule::EpochSchedule, - hash::Hash, - pubkey::Pubkey, - transaction::Transaction, - }, - solana_vote_program::{self, vote_state::Vote, vote_transaction}, - std::{ - collections::HashMap, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, Mutex, RwLock, - }, - thread::{self, sleep, Builder, JoinHandle}, - time::{Duration, Instant}, +use crate::{ + optimistic_confirmation_verifier::OptimisticConfirmationVerifier, + replay_stage::DUPLICATE_THRESHOLD, + result::{Error, Result}, + sigverify, + verified_vote_packets::VerifiedVotePackets, + vote_stake_tracker::VoteStakeTracker, +}; +use crossbeam_channel::{ + unbounded, Receiver as CrossbeamReceiver, RecvTimeoutError, Select, Sender as CrossbeamSender, +}; +use itertools::izip; +use log::*; +use solana_gossip::{ + cluster_info::{ClusterInfo, GOSSIP_SLEEP_MILLIS}, + crds::Cursor, + crds_value::CrdsValueLabel, +}; +use solana_ledger::blockstore::Blockstore; +use solana_metrics::inc_new_counter_debug; +use solana_perf::packet::{self, Packets}; +use solana_poh::poh_recorder::PohRecorder; +use solana_rpc::{ + optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender}, + rpc_subscriptions::RpcSubscriptions, +}; +use solana_runtime::{ + bank::Bank, + bank_forks::BankForks, + commitment::VOTE_THRESHOLD_SIZE, + epoch_stakes::{EpochAuthorizedVoters, EpochStakes}, + stakes::Stakes, + vote_sender_types::{ReplayVoteReceiver, ReplayedVote}, +}; +use solana_sdk::{ + clock::{Epoch, Slot, DEFAULT_MS_PER_SLOT, DEFAULT_TICKS_PER_SLOT}, + epoch_schedule::EpochSchedule, + hash::Hash, + pubkey::Pubkey, + transaction::Transaction, +}; +use solana_vote_program::{self, vote_state::Vote, vote_transaction}; +use std::{ + collections::HashMap, + sync::{ + atomic::{AtomicBool, Ordering}, + {Arc, Mutex, RwLock}, }, + thread::{self, sleep, Builder, JoinHandle}, + time::{Duration, Instant}, }; // Map from a vote account to the authorized voter for an epoch @@ -838,23 +835,21 @@ impl ClusterInfoVoteListener { #[cfg(test)] mod tests { - use { - super::*, - solana_perf::packet, - solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, - solana_runtime::{ - bank::Bank, - commitment::BlockCommitmentCache, - genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs}, - vote_sender_types::ReplayVoteSender, - }, - solana_sdk::{ - hash::Hash, - signature::{Keypair, Signature, Signer}, - }, - solana_vote_program::vote_state::Vote, - std::collections::BTreeSet, + use super::*; + use solana_perf::packet; + use solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank; + use solana_runtime::{ + bank::Bank, + commitment::BlockCommitmentCache, + genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs}, + vote_sender_types::ReplayVoteSender, }; + use solana_sdk::{ + hash::Hash, + signature::{Keypair, Signature, Signer}, + }; + use solana_vote_program::vote_state::Vote; + use std::collections::BTreeSet; #[test] fn test_max_vote_tx_fits() { diff --git a/core/src/cluster_slot_state_verifier.rs b/core/src/cluster_slot_state_verifier.rs index a63d9378bb..2ad5090ce5 100644 --- a/core/src/cluster_slot_state_verifier.rs +++ b/core/src/cluster_slot_state_verifier.rs @@ -1,11 +1,9 @@ -use { - crate::{ - fork_choice::ForkChoice, heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, - progress_map::ProgressMap, - }, - solana_sdk::{clock::Slot, hash::Hash}, - std::collections::{BTreeMap, BTreeSet}, +use crate::{ + fork_choice::ForkChoice, heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, + progress_map::ProgressMap, }; +use solana_sdk::{clock::Slot, hash::Hash}; +use std::collections::{BTreeMap, BTreeSet}; pub(crate) type DuplicateSlotsTracker = BTreeSet; pub(crate) type GossipDuplicateConfirmedSlots = BTreeMap; @@ -307,16 +305,14 @@ pub(crate) fn check_slot_agrees_with_cluster( #[cfg(test)] mod test { - use { - super::*, - crate::consensus::test::VoteSimulator, - solana_runtime::bank_forks::BankForks, - std::{ - collections::{HashMap, HashSet}, - sync::RwLock, - }, - trees::tr, + use super::*; + use crate::consensus::test::VoteSimulator; + use solana_runtime::bank_forks::BankForks; + use std::{ + collections::{HashMap, HashSet}, + sync::RwLock, }; + use trees::tr; struct InitialState { heaviest_subtree_fork_choice: HeaviestSubtreeForkChoice, diff --git a/core/src/cluster_slots.rs b/core/src/cluster_slots.rs index 0619062678..1eee4ff29e 100644 --- a/core/src/cluster_slots.rs +++ b/core/src/cluster_slots.rs @@ -186,7 +186,8 @@ impl ClusterSlots { #[cfg(test)] mod tests { - use {super::*, solana_runtime::epoch_stakes::NodeVoteAccounts}; + use super::*; + use solana_runtime::epoch_stakes::NodeVoteAccounts; #[test] fn test_default() { diff --git a/core/src/cluster_slots_service.rs b/core/src/cluster_slots_service.rs index 35179ee28e..d2f7e7a295 100644 --- a/core/src/cluster_slots_service.rs +++ b/core/src/cluster_slots_service.rs @@ -1,19 +1,17 @@ -use { - crate::cluster_slots::ClusterSlots, - crossbeam_channel::{Receiver, RecvTimeoutError, Sender}, - solana_gossip::cluster_info::ClusterInfo, - solana_ledger::blockstore::Blockstore, - solana_measure::measure::Measure, - solana_runtime::bank_forks::BankForks, - solana_sdk::clock::Slot, - std::{ - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, RwLock, - }, - thread::{self, Builder, JoinHandle}, - time::{Duration, Instant}, +use crate::cluster_slots::ClusterSlots; +use crossbeam_channel::{Receiver, RecvTimeoutError, Sender}; +use solana_gossip::cluster_info::ClusterInfo; +use solana_ledger::blockstore::Blockstore; +use solana_measure::measure::Measure; +use solana_runtime::bank_forks::BankForks; +use solana_sdk::clock::Slot; +use std::{ + sync::{ + atomic::{AtomicBool, Ordering}, + {Arc, RwLock}, }, + thread::{self, Builder, JoinHandle}, + time::{Duration, Instant}, }; pub type ClusterSlotsUpdateReceiver = Receiver>; diff --git a/core/src/commitment_service.rs b/core/src/commitment_service.rs index c30d38d311..fe10848b75 100644 --- a/core/src/commitment_service.rs +++ b/core/src/commitment_service.rs @@ -1,25 +1,21 @@ -use { - crate::consensus::Stake, - solana_measure::measure::Measure, - solana_metrics::datapoint_info, - solana_rpc::rpc_subscriptions::RpcSubscriptions, - solana_runtime::{ - bank::Bank, - commitment::{BlockCommitment, BlockCommitmentCache, CommitmentSlots, VOTE_THRESHOLD_SIZE}, - }, - solana_sdk::clock::Slot, - solana_vote_program::vote_state::VoteState, - std::{ - cmp::max, - collections::HashMap, - sync::{ - atomic::{AtomicBool, Ordering}, - mpsc::{channel, Receiver, RecvTimeoutError, Sender}, - Arc, RwLock, - }, - thread::{self, Builder, JoinHandle}, - time::Duration, - }, +use crate::consensus::Stake; +use solana_measure::measure::Measure; +use solana_metrics::datapoint_info; +use solana_rpc::rpc_subscriptions::RpcSubscriptions; +use solana_runtime::{ + bank::Bank, + commitment::{BlockCommitment, BlockCommitmentCache, CommitmentSlots, VOTE_THRESHOLD_SIZE}, +}; +use solana_sdk::clock::Slot; +use solana_vote_program::vote_state::VoteState; +use std::{ + cmp::max, + collections::HashMap, + sync::atomic::{AtomicBool, Ordering}, + sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender}, + sync::{Arc, RwLock}, + thread::{self, Builder, JoinHandle}, + time::Duration, }; pub struct CommitmentAggregationData { @@ -251,20 +247,18 @@ impl AggregateCommitmentService { #[cfg(test)] mod tests { - use { - super::*, - solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}, - solana_runtime::{ - accounts_background_service::AbsRequestSender, - bank_forks::BankForks, - genesis_utils::{create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs}, - }, - solana_sdk::{account::Account, pubkey::Pubkey, signature::Signer}, - solana_stake_program::stake_state, - solana_vote_program::{ - vote_state::{self, VoteStateVersions}, - vote_transaction, - }, + use super::*; + use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}; + use solana_runtime::{ + accounts_background_service::AbsRequestSender, + bank_forks::BankForks, + genesis_utils::{create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs}, + }; + use solana_sdk::{account::Account, pubkey::Pubkey, signature::Signer}; + use solana_stake_program::stake_state; + use solana_vote_program::{ + vote_state::{self, VoteStateVersions}, + vote_transaction, }; #[test] diff --git a/core/src/completed_data_sets_service.rs b/core/src/completed_data_sets_service.rs index 5c9536c11d..9bc5186943 100644 --- a/core/src/completed_data_sets_service.rs +++ b/core/src/completed_data_sets_service.rs @@ -1,19 +1,15 @@ -use { - crossbeam_channel::{Receiver, RecvTimeoutError, Sender}, - solana_ledger::{ - blockstore::{Blockstore, CompletedDataSetInfo}, - entry::Entry, - }, - solana_rpc::{max_slots::MaxSlots, rpc_subscriptions::RpcSubscriptions}, - solana_sdk::signature::Signature, - std::{ - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - thread::{self, Builder, JoinHandle}, - time::Duration, +use crossbeam_channel::{Receiver, RecvTimeoutError, Sender}; +use solana_ledger::blockstore::{Blockstore, CompletedDataSetInfo}; +use solana_ledger::entry::Entry; +use solana_rpc::{max_slots::MaxSlots, rpc_subscriptions::RpcSubscriptions}; +use solana_sdk::signature::Signature; +use std::{ + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, }, + thread::{self, Builder, JoinHandle}, + time::Duration, }; pub type CompletedDataSetsReceiver = Receiver>; @@ -104,14 +100,10 @@ impl CompletedDataSetsService { #[cfg(test)] pub mod test { - use { - super::*, - solana_sdk::{ - hash::Hash, - signature::{Keypair, Signer}, - transaction::Transaction, - }, - }; + use super::*; + use solana_sdk::hash::Hash; + use solana_sdk::signature::{Keypair, Signer}; + use solana_sdk::transaction::Transaction; #[test] fn test_zero_signatures() { diff --git a/core/src/consensus.rs b/core/src/consensus.rs index 88fb0a0d30..32bc419bbd 100644 --- a/core/src/consensus.rs +++ b/core/src/consensus.rs @@ -1,42 +1,40 @@ -use { - crate::{ - heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, - latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, - progress_map::{LockoutIntervals, ProgressMap}, - }, - chrono::prelude::*, - solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore, blockstore_db}, - solana_measure::measure::Measure, - solana_runtime::{ - bank::Bank, bank_forks::BankForks, commitment::VOTE_THRESHOLD_SIZE, - vote_account::ArcVoteAccount, - }, - solana_sdk::{ - clock::{Slot, UnixTimestamp}, - hash::Hash, - instruction::Instruction, - pubkey::Pubkey, - signature::{Keypair, Signature, Signer}, - slot_history::{Check, SlotHistory}, - }, - solana_vote_program::{ - vote_instruction, - vote_state::{BlockTimestamp, Lockout, Vote, VoteState, MAX_LOCKOUT_HISTORY}, - }, - std::{ - cmp::Ordering, - collections::{HashMap, HashSet}, - fs::{self, File}, - io::BufReader, - ops::{ - Bound::{Included, Unbounded}, - Deref, - }, - path::{Path, PathBuf}, - sync::Arc, - }, - thiserror::Error, +use crate::{ + heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, + latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, + progress_map::{LockoutIntervals, ProgressMap}, }; +use chrono::prelude::*; +use solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore, blockstore_db}; +use solana_measure::measure::Measure; +use solana_runtime::{ + bank::Bank, bank_forks::BankForks, commitment::VOTE_THRESHOLD_SIZE, + vote_account::ArcVoteAccount, +}; +use solana_sdk::{ + clock::{Slot, UnixTimestamp}, + hash::Hash, + instruction::Instruction, + pubkey::Pubkey, + signature::{Keypair, Signature, Signer}, + slot_history::{Check, SlotHistory}, +}; +use solana_vote_program::{ + vote_instruction, + vote_state::{BlockTimestamp, Lockout, Vote, VoteState, MAX_LOCKOUT_HISTORY}, +}; +use std::{ + cmp::Ordering, + collections::{HashMap, HashSet}, + fs::{self, File}, + io::BufReader, + ops::{ + Bound::{Included, Unbounded}, + Deref, + }, + path::{Path, PathBuf}, + sync::Arc, +}; +use thiserror::Error; #[derive(PartialEq, Clone, Debug, AbiExample)] pub enum SwitchForkDecision { @@ -1357,48 +1355,46 @@ pub fn reconcile_blockstore_roots_with_tower( #[cfg(test)] pub mod test { - use { - super::*, - crate::{ - cluster_info_vote_listener::VoteTracker, - cluster_slot_state_verifier::{DuplicateSlotsTracker, GossipDuplicateConfirmedSlots}, - cluster_slots::ClusterSlots, - fork_choice::{ForkChoice, SelectVoteAndResetForkResult}, - heaviest_subtree_fork_choice::SlotHashKey, - progress_map::ForkProgress, - replay_stage::{HeaviestForkFailures, ReplayStage}, - unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes, - }, - solana_ledger::{blockstore::make_slot_entries, get_tmp_ledger_path}, - solana_runtime::{ - accounts_background_service::AbsRequestSender, - bank::Bank, - bank_forks::BankForks, - genesis_utils::{ - create_genesis_config_with_vote_accounts, GenesisConfigInfo, ValidatorVoteKeypairs, - }, - }, - solana_sdk::{ - account::{Account, AccountSharedData, ReadableAccount, WritableAccount}, - clock::Slot, - hash::Hash, - pubkey::Pubkey, - signature::Signer, - slot_history::SlotHistory, - }, - solana_vote_program::{ - vote_state::{Vote, VoteStateVersions, MAX_LOCKOUT_HISTORY}, - vote_transaction, - }, - std::{ - collections::HashMap, - fs::{remove_file, OpenOptions}, - io::{Read, Seek, SeekFrom, Write}, - sync::RwLock, - }, - tempfile::TempDir, - trees::{tr, Tree, TreeWalk}, + use super::*; + use crate::{ + cluster_info_vote_listener::VoteTracker, + cluster_slot_state_verifier::{DuplicateSlotsTracker, GossipDuplicateConfirmedSlots}, + cluster_slots::ClusterSlots, + fork_choice::{ForkChoice, SelectVoteAndResetForkResult}, + heaviest_subtree_fork_choice::SlotHashKey, + progress_map::ForkProgress, + replay_stage::{HeaviestForkFailures, ReplayStage}, + unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes, }; + use solana_ledger::{blockstore::make_slot_entries, get_tmp_ledger_path}; + use solana_runtime::{ + accounts_background_service::AbsRequestSender, + bank::Bank, + bank_forks::BankForks, + genesis_utils::{ + create_genesis_config_with_vote_accounts, GenesisConfigInfo, ValidatorVoteKeypairs, + }, + }; + use solana_sdk::{ + account::{Account, AccountSharedData, ReadableAccount, WritableAccount}, + clock::Slot, + hash::Hash, + pubkey::Pubkey, + signature::Signer, + slot_history::SlotHistory, + }; + use solana_vote_program::{ + vote_state::{Vote, VoteStateVersions, MAX_LOCKOUT_HISTORY}, + vote_transaction, + }; + use std::{ + collections::HashMap, + fs::{remove_file, OpenOptions}, + io::{Read, Seek, SeekFrom, Write}, + sync::RwLock, + }; + use tempfile::TempDir; + use trees::{tr, Tree, TreeWalk}; pub(crate) struct VoteSimulator { pub validator_keypairs: HashMap, diff --git a/core/src/cost_update_service.rs b/core/src/cost_update_service.rs index b79641733e..1e239d8aae 100644 --- a/core/src/cost_update_service.rs +++ b/core/src/cost_update_service.rs @@ -3,23 +3,18 @@ //! packing transactions into block; it also triggers persisting cost //! table to blockstore. -use { - solana_ledger::blockstore::Blockstore, - solana_measure::measure::Measure, - solana_runtime::{ - bank::{Bank, ExecuteTimings}, - cost_model::CostModel, - }, - solana_sdk::timing::timestamp, - std::{ - sync::{ - atomic::{AtomicBool, Ordering}, - mpsc::Receiver, - Arc, RwLock, - }, - thread::{self, Builder, JoinHandle}, - time::Duration, +use solana_ledger::blockstore::Blockstore; +use solana_measure::measure::Measure; +use solana_runtime::{bank::Bank, bank::ExecuteTimings, cost_model::CostModel}; +use solana_sdk::timing::timestamp; +use std::{ + sync::{ + atomic::{AtomicBool, Ordering}, + mpsc::Receiver, + Arc, RwLock, }, + thread::{self, Builder, JoinHandle}, + time::Duration, }; #[derive(Default)] @@ -208,7 +203,9 @@ impl CostUpdateService { #[cfg(test)] mod tests { - use {super::*, solana_runtime::message_processor::ProgramTiming, solana_sdk::pubkey::Pubkey}; + use super::*; + use solana_runtime::message_processor::ProgramTiming; + use solana_sdk::pubkey::Pubkey; #[test] fn test_update_cost_model_with_empty_execute_timings() { diff --git a/core/src/drop_bank_service.rs b/core/src/drop_bank_service.rs index 8359bf1e63..a53f6f1520 100644 --- a/core/src/drop_bank_service.rs +++ b/core/src/drop_bank_service.rs @@ -1,10 +1,8 @@ -use { - solana_measure::measure::Measure, - solana_runtime::bank::Bank, - std::{ - sync::{mpsc::Receiver, Arc}, - thread::{self, Builder, JoinHandle}, - }, +use solana_measure::measure::Measure; +use solana_runtime::bank::Bank; +use std::{ + sync::{mpsc::Receiver, Arc}, + thread::{self, Builder, JoinHandle}, }; pub struct DropBankService { diff --git a/core/src/fetch_stage.rs b/core/src/fetch_stage.rs index 17a5cdafe5..019ea4b0e5 100644 --- a/core/src/fetch_stage.rs +++ b/core/src/fetch_stage.rs @@ -1,25 +1,18 @@ //! The `fetch_stage` batches input from a UDP socket and sends it to a channel. -use { - crate::{ - banking_stage::HOLD_TRANSACTIONS_SLOT_OFFSET, - result::{Error, Result}, - }, - solana_metrics::{inc_new_counter_debug, inc_new_counter_info}, - solana_perf::{packet::PacketsRecycler, recycler::Recycler}, - solana_poh::poh_recorder::PohRecorder, - solana_sdk::clock::DEFAULT_TICKS_PER_SLOT, - solana_streamer::streamer::{self, PacketReceiver, PacketSender}, - std::{ - net::UdpSocket, - sync::{ - atomic::AtomicBool, - mpsc::{channel, RecvTimeoutError}, - Arc, Mutex, - }, - thread::{self, Builder, JoinHandle}, - }, -}; +use crate::banking_stage::HOLD_TRANSACTIONS_SLOT_OFFSET; +use crate::result::{Error, Result}; +use solana_metrics::{inc_new_counter_debug, inc_new_counter_info}; +use solana_perf::packet::PacketsRecycler; +use solana_perf::recycler::Recycler; +use solana_poh::poh_recorder::PohRecorder; +use solana_sdk::clock::DEFAULT_TICKS_PER_SLOT; +use solana_streamer::streamer::{self, PacketReceiver, PacketSender}; +use std::net::UdpSocket; +use std::sync::atomic::AtomicBool; +use std::sync::mpsc::{channel, RecvTimeoutError}; +use std::sync::{Arc, Mutex}; +use std::thread::{self, Builder, JoinHandle}; pub struct FetchStage { thread_hdls: Vec>, diff --git a/core/src/fork_choice.rs b/core/src/fork_choice.rs index 2c15cd9313..b5e6524359 100644 --- a/core/src/fork_choice.rs +++ b/core/src/fork_choice.rs @@ -1,15 +1,13 @@ -use { - crate::{ - consensus::{SwitchForkDecision, Tower}, - latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, - progress_map::ProgressMap, - replay_stage::HeaviestForkFailures, - }, - solana_runtime::{bank::Bank, bank_forks::BankForks}, - std::{ - collections::{HashMap, HashSet}, - sync::{Arc, RwLock}, - }, +use crate::{ + consensus::{SwitchForkDecision, Tower}, + latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, + progress_map::ProgressMap, + replay_stage::HeaviestForkFailures, +}; +use solana_runtime::{bank::Bank, bank_forks::BankForks}; +use std::{ + collections::{HashMap, HashSet}, + sync::{Arc, RwLock}, }; pub(crate) struct SelectVoteAndResetForkResult { diff --git a/core/src/gen_keys.rs b/core/src/gen_keys.rs index b037b26596..4f8f4d86d9 100644 --- a/core/src/gen_keys.rs +++ b/core/src/gen_keys.rs @@ -1,11 +1,9 @@ //! The `gen_keys` module makes lots of keypairs -use { - rand::{Rng, SeedableRng}, - rand_chacha::ChaChaRng, - rayon::prelude::*, - solana_sdk::signature::Keypair, -}; +use rand::{Rng, SeedableRng}; +use rand_chacha::ChaChaRng; +use rayon::prelude::*; +use solana_sdk::signature::Keypair; pub struct GenKeys { generator: ChaChaRng, @@ -41,8 +39,10 @@ impl GenKeys { #[cfg(test)] mod tests { + use super::*; pub use solana_sdk::pubkey::Pubkey; - use {super::*, solana_sdk::signature::Signer, std::collections::HashSet}; + use solana_sdk::signature::Signer; + use std::collections::HashSet; #[test] fn test_new_key_is_deterministic() { diff --git a/core/src/heaviest_subtree_fork_choice.rs b/core/src/heaviest_subtree_fork_choice.rs index e9410fcea0..df75eaae72 100644 --- a/core/src/heaviest_subtree_fork_choice.rs +++ b/core/src/heaviest_subtree_fork_choice.rs @@ -1,26 +1,24 @@ +use crate::{ + consensus::Tower, fork_choice::ForkChoice, + latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, + progress_map::ProgressMap, tree_diff::TreeDiff, +}; +use solana_measure::measure::Measure; +use solana_runtime::{bank::Bank, bank_forks::BankForks, epoch_stakes::EpochStakes}; +use solana_sdk::{ + clock::{Epoch, Slot}, + epoch_schedule::EpochSchedule, + hash::Hash, + pubkey::Pubkey, +}; +use std::{ + borrow::Borrow, + collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque}, + sync::{Arc, RwLock}, + time::Instant, +}; #[cfg(test)] use trees::{Tree, TreeWalk}; -use { - crate::{ - consensus::Tower, fork_choice::ForkChoice, - latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, - progress_map::ProgressMap, tree_diff::TreeDiff, - }, - solana_measure::measure::Measure, - solana_runtime::{bank::Bank, bank_forks::BankForks, epoch_stakes::EpochStakes}, - solana_sdk::{ - clock::{Epoch, Slot}, - epoch_schedule::EpochSchedule, - hash::Hash, - pubkey::Pubkey, - }, - std::{ - borrow::Borrow, - collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque}, - sync::{Arc, RwLock}, - time::Instant, - }, -}; pub type ForkWeight = u64; pub type SlotHashKey = (Slot, Hash); @@ -1046,14 +1044,12 @@ impl<'a> Iterator for AncestorIterator<'a> { #[cfg(test)] mod test { - use { - super::*, - crate::consensus::test::VoteSimulator, - solana_runtime::{bank::Bank, bank_utils}, - solana_sdk::{hash::Hash, slot_history::SlotHistory}, - std::{collections::HashSet, ops::Range}, - trees::tr, - }; + use super::*; + use crate::consensus::test::VoteSimulator; + use solana_runtime::{bank::Bank, bank_utils}; + use solana_sdk::{hash::Hash, slot_history::SlotHistory}; + use std::{collections::HashSet, ops::Range}; + use trees::tr; #[test] fn test_max_by_weight() { diff --git a/core/src/latest_validator_votes_for_frozen_banks.rs b/core/src/latest_validator_votes_for_frozen_banks.rs index b0327b1d06..10b01d60ab 100644 --- a/core/src/latest_validator_votes_for_frozen_banks.rs +++ b/core/src/latest_validator_votes_for_frozen_banks.rs @@ -1,8 +1,6 @@ -use { - crate::heaviest_subtree_fork_choice::SlotHashKey, - solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey}, - std::collections::{hash_map::Entry, HashMap}, -}; +use crate::heaviest_subtree_fork_choice::SlotHashKey; +use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey}; +use std::collections::{hash_map::Entry, HashMap}; #[derive(Default)] pub(crate) struct LatestValidatorVotesForFrozenBanks { diff --git a/core/src/ledger_cleanup_service.rs b/core/src/ledger_cleanup_service.rs index 3486a24ad2..574e1dc7a2 100644 --- a/core/src/ledger_cleanup_service.rs +++ b/core/src/ledger_cleanup_service.rs @@ -1,24 +1,17 @@ //! The `ledger_cleanup_service` drops older ledger data to limit disk space usage -use { - rand::{thread_rng, Rng}, - solana_ledger::{ - blockstore::{Blockstore, PurgeType}, - blockstore_db::Result as BlockstoreResult, - }, - solana_measure::measure::Measure, - solana_sdk::clock::{Slot, DEFAULT_TICKS_PER_SLOT, TICKS_PER_DAY}, - std::{ - string::ToString, - sync::{ - atomic::{AtomicBool, AtomicU64, Ordering}, - mpsc::{Receiver, RecvTimeoutError}, - Arc, - }, - thread::{self, sleep, Builder, JoinHandle}, - time::Duration, - }, -}; +use rand::{thread_rng, Rng}; +use solana_ledger::blockstore::{Blockstore, PurgeType}; +use solana_ledger::blockstore_db::Result as BlockstoreResult; +use solana_measure::measure::Measure; +use solana_sdk::clock::{Slot, DEFAULT_TICKS_PER_SLOT, TICKS_PER_DAY}; +use std::string::ToString; +use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::mpsc::{Receiver, RecvTimeoutError}; +use std::sync::Arc; +use std::thread; +use std::thread::{sleep, Builder, JoinHandle}; +use std::time::Duration; // - To try and keep the RocksDB size under 400GB: // Seeing about 1600b/shred, using 2000b/shred for margin, so 200m shreds can be stored in 400gb. @@ -313,11 +306,10 @@ impl LedgerCleanupService { } #[cfg(test)] mod tests { - use { - super::*, - solana_ledger::{blockstore::make_many_slot_entries, get_tmp_ledger_path}, - std::sync::mpsc::channel, - }; + use super::*; + use solana_ledger::blockstore::make_many_slot_entries; + use solana_ledger::get_tmp_ledger_path; + use std::sync::mpsc::channel; #[test] fn test_cleanup1() { diff --git a/core/src/optimistic_confirmation_verifier.rs b/core/src/optimistic_confirmation_verifier.rs index 2e5b4fbd7f..5e53abb342 100644 --- a/core/src/optimistic_confirmation_verifier.rs +++ b/core/src/optimistic_confirmation_verifier.rs @@ -1,10 +1,8 @@ -use { - crate::cluster_info_vote_listener::VoteTracker, - solana_ledger::blockstore::Blockstore, - solana_runtime::bank::Bank, - solana_sdk::{clock::Slot, hash::Hash}, - std::{collections::BTreeSet, time::Instant}, -}; +use crate::cluster_info_vote_listener::VoteTracker; +use solana_ledger::blockstore::Blockstore; +use solana_runtime::bank::Bank; +use solana_sdk::{clock::Slot, hash::Hash}; +use std::{collections::BTreeSet, time::Instant}; pub struct OptimisticConfirmationVerifier { snapshot_start_slot: Slot, @@ -141,11 +139,13 @@ impl OptimisticConfirmationVerifier { #[cfg(test)] mod test { - use { - super::*, crate::consensus::test::VoteSimulator, solana_ledger::get_tmp_ledger_path, - solana_runtime::bank::Bank, solana_sdk::pubkey::Pubkey, std::collections::HashMap, - trees::tr, - }; + use super::*; + use crate::consensus::test::VoteSimulator; + use solana_ledger::get_tmp_ledger_path; + use solana_runtime::bank::Bank; + use solana_sdk::pubkey::Pubkey; + use std::collections::HashMap; + use trees::tr; #[test] fn test_add_new_optimistic_confirmed_slots() { diff --git a/core/src/outstanding_requests.rs b/core/src/outstanding_requests.rs index 811a6ccd0b..fe542e92b1 100644 --- a/core/src/outstanding_requests.rs +++ b/core/src/outstanding_requests.rs @@ -1,9 +1,7 @@ -use { - crate::request_response::RequestResponse, - lru::LruCache, - rand::{thread_rng, Rng}, - solana_ledger::shred::Nonce, -}; +use crate::request_response::RequestResponse; +use lru::LruCache; +use rand::{thread_rng, Rng}; +use solana_ledger::shred::Nonce; pub const DEFAULT_REQUEST_EXPIRATION_MS: u64 = 60_000; @@ -74,10 +72,10 @@ pub struct RequestStatus { #[cfg(test)] pub(crate) mod tests { - use { - super::*, crate::serve_repair::RepairType, solana_ledger::shred::Shred, - solana_sdk::timing::timestamp, - }; + use super::*; + use crate::serve_repair::RepairType; + use solana_ledger::shred::Shred; + use solana_sdk::timing::timestamp; #[test] fn test_add_request() { diff --git a/core/src/progress_map.rs b/core/src/progress_map.rs index 8bc2e6b4fb..fb8e94eca6 100644 --- a/core/src/progress_map.rs +++ b/core/src/progress_map.rs @@ -1,17 +1,15 @@ -use { - crate::{ - cluster_info_vote_listener::SlotVoteTracker, - cluster_slots::SlotPubkeys, - consensus::{Stake, VotedStakes}, - replay_stage::SUPERMINORITY_THRESHOLD, - }, - solana_ledger::blockstore_processor::{ConfirmationProgress, ConfirmationTiming}, - solana_runtime::{bank::Bank, bank_forks::BankForks, vote_account::ArcVoteAccount}, - solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey}, - std::{ - collections::{BTreeMap, HashMap, HashSet}, - sync::{Arc, RwLock}, - }, +use crate::{ + cluster_info_vote_listener::SlotVoteTracker, + cluster_slots::SlotPubkeys, + replay_stage::SUPERMINORITY_THRESHOLD, + {consensus::Stake, consensus::VotedStakes}, +}; +use solana_ledger::blockstore_processor::{ConfirmationProgress, ConfirmationTiming}; +use solana_runtime::{bank::Bank, bank_forks::BankForks, vote_account::ArcVoteAccount}; +use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey}; +use std::{ + collections::{BTreeMap, HashMap, HashSet}, + sync::{Arc, RwLock}, }; type VotedSlot = Slot; diff --git a/core/src/repair_response.rs b/core/src/repair_response.rs index 31d7941d31..fef52628c7 100644 --- a/core/src/repair_response.rs +++ b/core/src/repair_response.rs @@ -1,12 +1,10 @@ -use { - solana_ledger::{ - blockstore::Blockstore, - shred::{Nonce, SIZE_OF_NONCE}, - }, - solana_perf::packet::limited_deserialize, - solana_sdk::{clock::Slot, packet::Packet}, - std::{io, net::SocketAddr}, +use solana_ledger::{ + blockstore::Blockstore, + shred::{Nonce, SIZE_OF_NONCE}, }; +use solana_perf::packet::limited_deserialize; +use solana_sdk::{clock::Slot, packet::Packet}; +use std::{io, net::SocketAddr}; pub fn repair_response_packet( blockstore: &Blockstore, @@ -50,17 +48,15 @@ pub fn nonce(buf: &[u8]) -> Option { #[cfg(test)] mod test { - use { - super::*, - solana_ledger::{ - shred::{Shred, Shredder}, - sigverify_shreds::verify_shred_cpu, - }, - solana_sdk::signature::{Keypair, Signer}, - std::{ - collections::HashMap, - net::{IpAddr, Ipv4Addr}, - }, + use super::*; + use solana_ledger::{ + shred::{Shred, Shredder}, + sigverify_shreds::verify_shred_cpu, + }; + use solana_sdk::signature::{Keypair, Signer}; + use std::{ + collections::HashMap, + net::{IpAddr, Ipv4Addr}, }; fn run_test_sigverify_shred_cpu_repair(slot: Slot) { diff --git a/core/src/repair_service.rs b/core/src/repair_service.rs index e9920f3265..7aa70da19e 100644 --- a/core/src/repair_service.rs +++ b/core/src/repair_service.rs @@ -1,42 +1,40 @@ //! The `repair_service` module implements the tools necessary to generate a thread which //! regularly finds missing shreds in the ledger and sends repair requests for those shreds -use { - crate::{ - cluster_info_vote_listener::VerifiedVoteReceiver, - cluster_slots::ClusterSlots, - outstanding_requests::OutstandingRequests, - repair_weight::RepairWeight, - replay_stage::DUPLICATE_THRESHOLD, - result::Result, - serve_repair::{RepairType, ServeRepair, REPAIR_PEERS_CACHE_CAPACITY}, - }, - crossbeam_channel::{Receiver as CrossbeamReceiver, Sender as CrossbeamSender}, - lru::LruCache, - solana_gossip::cluster_info::ClusterInfo, - solana_ledger::{ - blockstore::{Blockstore, SlotMeta}, - shred::Nonce, - }, - solana_measure::measure::Measure, - solana_runtime::{bank::Bank, bank_forks::BankForks, contains::Contains}, - solana_sdk::{ - clock::{BankId, Slot}, - epoch_schedule::EpochSchedule, - pubkey::Pubkey, - timing::timestamp, - }, - solana_streamer::sendmmsg::{batch_send, SendPktsError}, - std::{ - collections::{HashMap, HashSet}, - iter::Iterator, - net::{SocketAddr, UdpSocket}, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, RwLock, - }, - thread::{self, sleep, Builder, JoinHandle}, - time::{Duration, Instant}, - }, +use crate::{ + cluster_info_vote_listener::VerifiedVoteReceiver, + cluster_slots::ClusterSlots, + outstanding_requests::OutstandingRequests, + repair_weight::RepairWeight, + replay_stage::DUPLICATE_THRESHOLD, + result::Result, + serve_repair::{RepairType, ServeRepair, REPAIR_PEERS_CACHE_CAPACITY}, +}; +use crossbeam_channel::{Receiver as CrossbeamReceiver, Sender as CrossbeamSender}; +use lru::LruCache; +use solana_gossip::cluster_info::ClusterInfo; +use solana_ledger::{ + blockstore::{Blockstore, SlotMeta}, + shred::Nonce, +}; +use solana_measure::measure::Measure; +use solana_runtime::{bank::Bank, bank_forks::BankForks, contains::Contains}; +use solana_sdk::{ + clock::{BankId, Slot}, + epoch_schedule::EpochSchedule, + pubkey::Pubkey, + timing::timestamp, +}; +use solana_streamer::sendmmsg::{batch_send, SendPktsError}; +use std::{ + collections::{HashMap, HashSet}, + iter::Iterator, + net::SocketAddr, + net::UdpSocket, + sync::atomic::{AtomicBool, Ordering}, + sync::{Arc, RwLock}, + thread::sleep, + thread::{self, Builder, JoinHandle}, + time::{Duration, Instant}, }; pub type DuplicateSlotsResetSender = CrossbeamSender; @@ -713,23 +711,20 @@ impl RepairService { #[cfg(test)] mod test { - use { - super::*, - crossbeam_channel::unbounded, - solana_gossip::{cluster_info::Node, contact_info::ContactInfo}, - solana_ledger::{ - blockstore::{ - make_chaining_slot_entries, make_many_slot_entries, make_slot_entries, Blockstore, - }, - get_tmp_ledger_path, - shred::max_ticks_per_n_shreds, - }, - solana_runtime::genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs}, - solana_sdk::signature::{Keypair, Signer}, - solana_streamer::socket::SocketAddrSpace, - solana_vote_program::vote_transaction, - std::collections::HashSet, + use super::*; + use crossbeam_channel::unbounded; + use solana_gossip::{cluster_info::Node, contact_info::ContactInfo}; + use solana_ledger::blockstore::{ + make_chaining_slot_entries, make_many_slot_entries, make_slot_entries, }; + use solana_ledger::shred::max_ticks_per_n_shreds; + use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path}; + use solana_runtime::genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs}; + use solana_sdk::signature::Keypair; + use solana_sdk::signature::Signer; + use solana_streamer::socket::SocketAddrSpace; + use solana_vote_program::vote_transaction; + use std::collections::HashSet; fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo { ClusterInfo::new( diff --git a/core/src/repair_weight.rs b/core/src/repair_weight.rs index 111c394fd8..8a62b210ea 100644 --- a/core/src/repair_weight.rs +++ b/core/src/repair_weight.rs @@ -1,19 +1,17 @@ -use { - crate::{ - heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairTiming, - repair_weighted_traversal, serve_repair::RepairType, tree_diff::TreeDiff, - }, - solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore}, - solana_measure::measure::Measure, - solana_runtime::{contains::Contains, epoch_stakes::EpochStakes}, - solana_sdk::{ - clock::Slot, - epoch_schedule::{Epoch, EpochSchedule}, - hash::Hash, - pubkey::Pubkey, - }, - std::collections::{BTreeSet, HashMap, HashSet, VecDeque}, +use crate::{ + heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairTiming, + repair_weighted_traversal, serve_repair::RepairType, tree_diff::TreeDiff, }; +use solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore}; +use solana_measure::measure::Measure; +use solana_runtime::{contains::Contains, epoch_stakes::EpochStakes}; +use solana_sdk::{ + clock::Slot, + epoch_schedule::{Epoch, EpochSchedule}, + hash::Hash, + pubkey::Pubkey, +}; +use std::collections::{BTreeSet, HashMap, HashSet, VecDeque}; pub struct RepairWeight { // Map from root -> a subtree rooted at that `root` @@ -533,13 +531,11 @@ impl RepairWeight { #[cfg(test)] mod test { - use { - super::*, - solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path}, - solana_runtime::{bank::Bank, bank_utils}, - solana_sdk::hash::Hash, - trees::tr, - }; + use super::*; + use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path}; + use solana_runtime::{bank::Bank, bank_utils}; + use solana_sdk::hash::Hash; + use trees::tr; #[test] fn test_sort_by_stake_weight_slot() { diff --git a/core/src/repair_weighted_traversal.rs b/core/src/repair_weighted_traversal.rs index 21db8614e0..8b6cd0ceb4 100644 --- a/core/src/repair_weighted_traversal.rs +++ b/core/src/repair_weighted_traversal.rs @@ -1,13 +1,11 @@ -use { - crate::{ - heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairService, - serve_repair::RepairType, tree_diff::TreeDiff, - }, - solana_ledger::blockstore::Blockstore, - solana_runtime::contains::Contains, - solana_sdk::{clock::Slot, hash::Hash}, - std::collections::{HashMap, HashSet}, +use crate::{ + heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairService, + serve_repair::RepairType, tree_diff::TreeDiff, }; +use solana_ledger::blockstore::Blockstore; +use solana_runtime::contains::Contains; +use solana_sdk::{clock::Slot, hash::Hash}; +use std::collections::{HashMap, HashSet}; #[derive(Debug, PartialEq)] enum Visit { @@ -138,13 +136,11 @@ pub fn get_best_repair_shreds<'a>( #[cfg(test)] pub mod test { - use { - super::*, - solana_ledger::{get_tmp_ledger_path, shred::Shred}, - solana_runtime::bank_utils, - solana_sdk::hash::Hash, - trees::tr, - }; + use super::*; + use solana_ledger::{get_tmp_ledger_path, shred::Shred}; + use solana_runtime::bank_utils; + use solana_sdk::hash::Hash; + use trees::tr; #[test] fn test_weighted_repair_traversal_single() { diff --git a/core/src/replay_stage.rs b/core/src/replay_stage.rs index 1fd1f25283..149d702af4 100644 --- a/core/src/replay_stage.rs +++ b/core/src/replay_stage.rs @@ -1,74 +1,73 @@ //! The `replay_stage` replays transactions broadcast by the leader. -use { - crate::{ - broadcast_stage::RetransmitSlotsSender, - cache_block_meta_service::CacheBlockMetaSender, - cluster_info_vote_listener::{ - GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver, VoteTracker, - }, - cluster_slot_state_verifier::*, - cluster_slots::ClusterSlots, - cluster_slots_service::ClusterSlotsUpdateSender, - commitment_service::{AggregateCommitmentService, CommitmentAggregationData}, - consensus::{ - ComputedBankState, Stake, SwitchForkDecision, Tower, VotedStakes, SWITCH_FORK_THRESHOLD, - }, - cost_update_service::CostUpdate, - fork_choice::{ForkChoice, SelectVoteAndResetForkResult}, - heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, - latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, - progress_map::{ForkProgress, ProgressMap, PropagatedStats}, - repair_service::DuplicateSlotsResetReceiver, - rewards_recorder_service::RewardsRecorderSender, - unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes, - voting_service::VoteOp, - window_service::DuplicateSlotReceiver, +use crate::{ + broadcast_stage::RetransmitSlotsSender, + cache_block_meta_service::CacheBlockMetaSender, + cluster_info_vote_listener::{ + GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver, VoteTracker, }, - solana_client::rpc_response::SlotUpdate, - solana_gossip::cluster_info::ClusterInfo, - solana_ledger::{ - block_error::BlockError, - blockstore::Blockstore, - blockstore_processor::{self, BlockstoreProcessorError, TransactionStatusSender}, - entry::VerifyRecyclers, - leader_schedule_cache::LeaderScheduleCache, + cluster_slot_state_verifier::*, + cluster_slots::ClusterSlots, + cluster_slots_service::ClusterSlotsUpdateSender, + commitment_service::{AggregateCommitmentService, CommitmentAggregationData}, + consensus::{ + ComputedBankState, Stake, SwitchForkDecision, Tower, VotedStakes, SWITCH_FORK_THRESHOLD, }, - solana_measure::measure::Measure, - solana_metrics::inc_new_counter_info, - solana_poh::poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS}, - solana_rpc::{ - optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender}, - rpc_subscriptions::RpcSubscriptions, - }, - solana_runtime::{ - accounts_background_service::AbsRequestSender, - bank::{Bank, ExecuteTimings, NewBankOptions}, - bank_forks::BankForks, - commitment::BlockCommitmentCache, - vote_sender_types::ReplayVoteSender, - }, - solana_sdk::{ - clock::{Slot, MAX_PROCESSING_AGE, NUM_CONSECUTIVE_LEADER_SLOTS}, - genesis_config::ClusterType, - hash::Hash, - pubkey::Pubkey, - signature::{Keypair, Signature, Signer}, - timing::timestamp, - transaction::Transaction, - }, - solana_vote_program::vote_state::Vote, - std::{ - collections::{BTreeMap, HashMap, HashSet}, - result, - sync::{ - atomic::{AtomicBool, Ordering}, - mpsc::{Receiver, RecvTimeoutError, Sender}, - Arc, Mutex, RwLock, - }, - thread::{self, Builder, JoinHandle}, - time::{Duration, Instant}, + cost_update_service::CostUpdate, + fork_choice::{ForkChoice, SelectVoteAndResetForkResult}, + heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, + latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, + progress_map::{ForkProgress, ProgressMap, PropagatedStats}, + repair_service::DuplicateSlotsResetReceiver, + rewards_recorder_service::RewardsRecorderSender, + unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes, + voting_service::VoteOp, + window_service::DuplicateSlotReceiver, +}; +use solana_client::rpc_response::SlotUpdate; +use solana_gossip::cluster_info::ClusterInfo; +use solana_ledger::{ + block_error::BlockError, + blockstore::Blockstore, + blockstore_processor::{self, BlockstoreProcessorError, TransactionStatusSender}, + entry::VerifyRecyclers, + leader_schedule_cache::LeaderScheduleCache, +}; +use solana_measure::measure::Measure; +use solana_metrics::inc_new_counter_info; +use solana_poh::poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS}; +use solana_rpc::{ + optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender}, + rpc_subscriptions::RpcSubscriptions, +}; +use solana_runtime::{ + accounts_background_service::AbsRequestSender, + bank::{Bank, ExecuteTimings, NewBankOptions}, + bank_forks::BankForks, + commitment::BlockCommitmentCache, + vote_sender_types::ReplayVoteSender, +}; +use solana_sdk::{ + clock::{Slot, MAX_PROCESSING_AGE, NUM_CONSECUTIVE_LEADER_SLOTS}, + genesis_config::ClusterType, + hash::Hash, + pubkey::Pubkey, + signature::Signature, + signature::{Keypair, Signer}, + timing::timestamp, + transaction::Transaction, +}; +use solana_vote_program::vote_state::Vote; +use std::{ + collections::{BTreeMap, HashMap, HashSet}, + result, + sync::{ + atomic::{AtomicBool, Ordering}, + mpsc::{Receiver, RecvTimeoutError, Sender}, + Arc, Mutex, RwLock, }, + thread::{self, Builder, JoinHandle}, + time::{Duration, Instant}, }; pub const MAX_ENTRY_RECV_PER_ITER: usize = 512; @@ -2562,62 +2561,60 @@ impl ReplayStage { #[cfg(test)] mod tests { - use { - super::*, - crate::{ - consensus::{ - test::{initialize_state, VoteSimulator}, - Tower, - }, - progress_map::ValidatorStakeInfo, - replay_stage::ReplayStage, - }, - crossbeam_channel::unbounded, - solana_gossip::{cluster_info::Node, crds::Cursor}, - solana_ledger::{ - blockstore::{entries_to_test_shreds, make_slot_entries, BlockstoreError}, - create_new_tmp_ledger, - entry::{self, Entry}, - genesis_utils::{create_genesis_config, create_genesis_config_with_leader}, - get_tmp_ledger_path, - shred::{ - CodingShredHeader, DataShredHeader, Shred, ShredCommonHeader, DATA_COMPLETE_SHRED, - SIZE_OF_COMMON_SHRED_HEADER, SIZE_OF_DATA_SHRED_HEADER, SIZE_OF_DATA_SHRED_PAYLOAD, - }, - }, - solana_rpc::{ - optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, - rpc::create_test_transactions_and_populate_blockstore, - }, - solana_runtime::{ - accounts_background_service::AbsRequestSender, - commitment::BlockCommitment, - genesis_utils::{GenesisConfigInfo, ValidatorVoteKeypairs}, - }, - solana_sdk::{ - clock::NUM_CONSECUTIVE_LEADER_SLOTS, - genesis_config, - hash::{hash, Hash}, - instruction::InstructionError, - packet::PACKET_DATA_SIZE, - poh_config::PohConfig, - signature::{Keypair, Signer}, - system_transaction, - transaction::TransactionError, - }, - solana_streamer::socket::SocketAddrSpace, - solana_transaction_status::TransactionWithStatusMeta, - solana_vote_program::{ - vote_state::{VoteState, VoteStateVersions}, - vote_transaction, - }, - std::{ - fs::remove_dir_all, - iter, - sync::{atomic::AtomicU64, mpsc::channel, Arc, RwLock}, - }, - trees::{tr, Tree}, + use super::*; + use crate::{ + consensus::test::{initialize_state, VoteSimulator}, + consensus::Tower, + progress_map::ValidatorStakeInfo, + replay_stage::ReplayStage, }; + use crossbeam_channel::unbounded; + use solana_gossip::{cluster_info::Node, crds::Cursor}; + use solana_ledger::{ + blockstore::make_slot_entries, + blockstore::{entries_to_test_shreds, BlockstoreError}, + create_new_tmp_ledger, + entry::{self, Entry}, + genesis_utils::{create_genesis_config, create_genesis_config_with_leader}, + get_tmp_ledger_path, + shred::{ + CodingShredHeader, DataShredHeader, Shred, ShredCommonHeader, DATA_COMPLETE_SHRED, + SIZE_OF_COMMON_SHRED_HEADER, SIZE_OF_DATA_SHRED_HEADER, SIZE_OF_DATA_SHRED_PAYLOAD, + }, + }; + use solana_rpc::{ + optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, + rpc::create_test_transactions_and_populate_blockstore, + }; + use solana_runtime::{ + accounts_background_service::AbsRequestSender, + commitment::BlockCommitment, + genesis_utils::{GenesisConfigInfo, ValidatorVoteKeypairs}, + }; + use solana_sdk::{ + clock::NUM_CONSECUTIVE_LEADER_SLOTS, + genesis_config, + hash::{hash, Hash}, + instruction::InstructionError, + packet::PACKET_DATA_SIZE, + poh_config::PohConfig, + signature::{Keypair, Signer}, + system_transaction, + transaction::TransactionError, + }; + use solana_streamer::socket::SocketAddrSpace; + use solana_transaction_status::TransactionWithStatusMeta; + use solana_vote_program::{ + vote_state::{VoteState, VoteStateVersions}, + vote_transaction, + }; + use std::sync::mpsc::channel; + use std::{ + fs::remove_dir_all, + iter, + sync::{atomic::AtomicU64, Arc, RwLock}, + }; + use trees::{tr, Tree}; #[test] fn test_is_partition_detected() { diff --git a/core/src/result.rs b/core/src/result.rs index dbe32850c9..5fafca2ee1 100644 --- a/core/src/result.rs +++ b/core/src/result.rs @@ -1,9 +1,7 @@ //! The `result` module exposes a Result type that propagates one of many different Error types. -use { - solana_gossip::{cluster_info, gossip_error::GossipError}, - solana_ledger::blockstore, -}; +use solana_gossip::{cluster_info, gossip_error::GossipError}; +use solana_ledger::blockstore; #[derive(Debug)] pub enum Error { @@ -100,15 +98,14 @@ impl std::convert::From for Error { #[cfg(test)] mod tests { - use { - crate::result::{Error, Result}, - std::{ - io, - io::Write, - panic, - sync::mpsc::{channel, RecvError, RecvTimeoutError}, - }, - }; + use crate::result::Error; + use crate::result::Result; + use std::io; + use std::io::Write; + use std::panic; + use std::sync::mpsc::channel; + use std::sync::mpsc::RecvError; + use std::sync::mpsc::RecvTimeoutError; fn send_error() -> Result<()> { let (s, r) = channel(); diff --git a/core/src/retransmit_stage.rs b/core/src/retransmit_stage.rs index a602c9362d..a07ebe2399 100644 --- a/core/src/retransmit_stage.rs +++ b/core/src/retransmit_stage.rs @@ -18,7 +18,8 @@ use { solana_client::rpc_response::SlotUpdate, solana_gossip::cluster_info::{ClusterInfo, DATA_PLANE_FANOUT}, solana_ledger::{ - blockstore::Blockstore, leader_schedule_cache::LeaderScheduleCache, shred::Shred, + shred::Shred, + {blockstore::Blockstore, leader_schedule_cache::LeaderScheduleCache}, }, solana_measure::measure::Measure, solana_perf::packet::Packets, diff --git a/core/src/rewards_recorder_service.rs b/core/src/rewards_recorder_service.rs index 8988441d22..65c66fe49a 100644 --- a/core/src/rewards_recorder_service.rs +++ b/core/src/rewards_recorder_service.rs @@ -1,17 +1,15 @@ -use { - crossbeam_channel::{Receiver, RecvTimeoutError, Sender}, - solana_ledger::blockstore::Blockstore, - solana_runtime::bank::RewardInfo, - solana_sdk::{clock::Slot, pubkey::Pubkey}, - solana_transaction_status::Reward, - std::{ - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - thread::{self, Builder, JoinHandle}, - time::Duration, +use crossbeam_channel::{Receiver, RecvTimeoutError, Sender}; +use solana_ledger::blockstore::Blockstore; +use solana_runtime::bank::RewardInfo; +use solana_sdk::{clock::Slot, pubkey::Pubkey}; +use solana_transaction_status::Reward; +use std::{ + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, }, + thread::{self, Builder, JoinHandle}, + time::Duration, }; pub type RewardsRecorderReceiver = Receiver<(Slot, Vec<(Pubkey, RewardInfo)>)>; diff --git a/core/src/sample_performance_service.rs b/core/src/sample_performance_service.rs index fe6820c91d..c02be57746 100644 --- a/core/src/sample_performance_service.rs +++ b/core/src/sample_performance_service.rs @@ -1,14 +1,12 @@ -use { - solana_ledger::{blockstore::Blockstore, blockstore_meta::PerfSample}, - solana_runtime::bank_forks::BankForks, - std::{ - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, RwLock, - }, - thread::{self, sleep, Builder, JoinHandle}, - time::{Duration, Instant}, +use solana_ledger::{blockstore::Blockstore, blockstore_meta::PerfSample}; +use solana_runtime::bank_forks::BankForks; +use std::{ + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, RwLock, }, + thread::{self, sleep, Builder, JoinHandle}, + time::{Duration, Instant}, }; const SAMPLE_INTERVAL: u64 = 60; diff --git a/core/src/serve_repair.rs b/core/src/serve_repair.rs index 63a45fc84b..9eb7467727 100644 --- a/core/src/serve_repair.rs +++ b/core/src/serve_repair.rs @@ -1,46 +1,42 @@ -use { - crate::{ - cluster_slots::ClusterSlots, - repair_response, - repair_service::{OutstandingRepairs, RepairStats}, - request_response::RequestResponse, - result::{Error, Result}, - }, - bincode::serialize, - lru::LruCache, - rand::{ - distributions::{Distribution, WeightedError, WeightedIndex}, - Rng, - }, - solana_gossip::{ - cluster_info::{ClusterInfo, ClusterInfoError}, - contact_info::ContactInfo, - weighted_shuffle::weighted_best, - }, - solana_ledger::{ - blockstore::Blockstore, - shred::{Nonce, Shred}, - }, - solana_measure::measure::Measure, - solana_metrics::inc_new_counter_debug, - solana_perf::packet::{limited_deserialize, Packets, PacketsRecycler}, - solana_sdk::{ - clock::Slot, - pubkey::Pubkey, - signature::{Keypair, Signer}, - timing::duration_as_ms, - }, - solana_streamer::streamer::{PacketReceiver, PacketSender}, - std::{ - collections::HashSet, - net::SocketAddr, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, RwLock, - }, - thread::{Builder, JoinHandle}, - time::{Duration, Instant}, - }, +use crate::{ + cluster_slots::ClusterSlots, + repair_response, + repair_service::{OutstandingRepairs, RepairStats}, + request_response::RequestResponse, + result::{Error, Result}, +}; +use bincode::serialize; +use lru::LruCache; +use rand::{ + distributions::{Distribution, WeightedError, WeightedIndex}, + Rng, +}; +use solana_gossip::{ + cluster_info::{ClusterInfo, ClusterInfoError}, + contact_info::ContactInfo, + weighted_shuffle::weighted_best, +}; +use solana_ledger::{ + blockstore::Blockstore, + shred::{Nonce, Shred}, +}; +use solana_measure::measure::Measure; +use solana_metrics::inc_new_counter_debug; +use solana_perf::packet::{limited_deserialize, Packets, PacketsRecycler}; +use solana_sdk::{ + clock::Slot, + pubkey::Pubkey, + signature::{Keypair, Signer}, + timing::duration_as_ms, +}; +use solana_streamer::streamer::{PacketReceiver, PacketSender}; +use std::{ + collections::HashSet, + net::SocketAddr, + sync::atomic::{AtomicBool, Ordering}, + sync::{Arc, RwLock}, + thread::{Builder, JoinHandle}, + time::{Duration, Instant}, }; /// the number of slots to respond with when responding to `Orphan` requests @@ -639,20 +635,18 @@ impl ServeRepair { #[cfg(test)] mod tests { - use { - super::*, - crate::{repair_response, result::Error}, - solana_gossip::{socketaddr, socketaddr_any}, - solana_ledger::{ - blockstore::make_many_slot_entries, - blockstore_processor::fill_blockstore_slot_with_ticks, - get_tmp_ledger_path, - shred::{max_ticks_per_n_shreds, Shred}, - }, - solana_perf::packet::Packet, - solana_sdk::{hash::Hash, pubkey::Pubkey, signature::Keypair, timing::timestamp}, - solana_streamer::socket::SocketAddrSpace, + use super::*; + use crate::{repair_response, result::Error}; + use solana_gossip::{socketaddr, socketaddr_any}; + use solana_ledger::get_tmp_ledger_path; + use solana_ledger::{ + blockstore::make_many_slot_entries, + blockstore_processor::fill_blockstore_slot_with_ticks, + shred::{max_ticks_per_n_shreds, Shred}, }; + use solana_perf::packet::Packet; + use solana_sdk::{hash::Hash, pubkey::Pubkey, signature::Keypair, timing::timestamp}; + use solana_streamer::socket::SocketAddrSpace; #[test] fn test_run_highest_window_request() { diff --git a/core/src/serve_repair_service.rs b/core/src/serve_repair_service.rs index 8eae0c623b..70ce3f2e67 100644 --- a/core/src/serve_repair_service.rs +++ b/core/src/serve_repair_service.rs @@ -1,14 +1,12 @@ -use { - crate::serve_repair::ServeRepair, - solana_ledger::blockstore::Blockstore, - solana_perf::recycler::Recycler, - solana_streamer::{socket::SocketAddrSpace, streamer}, - std::{ - net::UdpSocket, - sync::{atomic::AtomicBool, mpsc::channel, Arc, RwLock}, - thread::{self, JoinHandle}, - }, -}; +use crate::serve_repair::ServeRepair; +use solana_ledger::blockstore::Blockstore; +use solana_perf::recycler::Recycler; +use solana_streamer::{socket::SocketAddrSpace, streamer}; +use std::net::UdpSocket; +use std::sync::atomic::AtomicBool; +use std::sync::mpsc::channel; +use std::sync::{Arc, RwLock}; +use std::thread::{self, JoinHandle}; pub struct ServeRepairService { thread_hdls: Vec>, diff --git a/core/src/shred_fetch_stage.rs b/core/src/shred_fetch_stage.rs index 9ac40d2991..50a5316074 100644 --- a/core/src/shred_fetch_stage.rs +++ b/core/src/shred_fetch_stage.rs @@ -1,24 +1,21 @@ //! The `shred_fetch_stage` pulls shreds from UDP sockets and sends it to a channel. -use { - crate::packet_hasher::PacketHasher, - lru::LruCache, - solana_ledger::shred::{get_shred_slot_index_type, ShredFetchStats}, - solana_perf::{ - cuda_runtime::PinnedVec, - packet::{Packet, PacketsRecycler}, - recycler::Recycler, - }, - solana_runtime::bank_forks::BankForks, - solana_sdk::clock::{Slot, DEFAULT_MS_PER_SLOT}, - solana_streamer::streamer::{self, PacketReceiver, PacketSender}, - std::{ - net::UdpSocket, - sync::{atomic::AtomicBool, mpsc::channel, Arc, RwLock}, - thread::{self, Builder, JoinHandle}, - time::Instant, - }, -}; +use crate::packet_hasher::PacketHasher; +use lru::LruCache; +use solana_ledger::shred::{get_shred_slot_index_type, ShredFetchStats}; +use solana_perf::cuda_runtime::PinnedVec; +use solana_perf::packet::{Packet, PacketsRecycler}; +use solana_perf::recycler::Recycler; +use solana_runtime::bank_forks::BankForks; +use solana_sdk::clock::{Slot, DEFAULT_MS_PER_SLOT}; +use solana_streamer::streamer::{self, PacketReceiver, PacketSender}; +use std::net::UdpSocket; +use std::sync::atomic::AtomicBool; +use std::sync::mpsc::channel; +use std::sync::Arc; +use std::sync::RwLock; +use std::thread::{self, Builder, JoinHandle}; +use std::time::Instant; const DEFAULT_LRU_SIZE: usize = 10_000; pub type ShredsReceived = LruCache; @@ -226,10 +223,9 @@ impl ShredFetchStage { #[cfg(test)] mod tests { - use { - super::*, - solana_ledger::{blockstore::MAX_DATA_SHREDS_PER_SLOT, shred::Shred}, - }; + use super::*; + use solana_ledger::blockstore::MAX_DATA_SHREDS_PER_SLOT; + use solana_ledger::shred::Shred; #[test] fn test_data_code_same_index() { diff --git a/core/src/sigverify.rs b/core/src/sigverify.rs index 8ffa30bb84..53b1da56ae 100644 --- a/core/src/sigverify.rs +++ b/core/src/sigverify.rs @@ -4,13 +4,14 @@ //! to the GPU. //! +use crate::sigverify_stage::SigVerifier; +use solana_perf::cuda_runtime::PinnedVec; +use solana_perf::packet::Packets; +use solana_perf::recycler::Recycler; +use solana_perf::sigverify; pub use solana_perf::sigverify::{ batch_size, ed25519_verify_cpu, ed25519_verify_disabled, init, TxOffset, }; -use { - crate::sigverify_stage::SigVerifier, - solana_perf::{cuda_runtime::PinnedVec, packet::Packets, recycler::Recycler, sigverify}, -}; #[derive(Clone)] pub struct TransactionSigVerifier { diff --git a/core/src/sigverify_shreds.rs b/core/src/sigverify_shreds.rs index 174811ccee..d3403d6523 100644 --- a/core/src/sigverify_shreds.rs +++ b/core/src/sigverify_shreds.rs @@ -1,17 +1,13 @@ #![allow(clippy::implicit_hasher)] -use { - crate::{sigverify, sigverify_stage::SigVerifier}, - solana_ledger::{ - leader_schedule_cache::LeaderScheduleCache, shred::Shred, - sigverify_shreds::verify_shreds_gpu, - }, - solana_perf::{self, packet::Packets, recycler_cache::RecyclerCache}, - solana_runtime::bank_forks::BankForks, - std::{ - collections::{HashMap, HashSet}, - sync::{Arc, RwLock}, - }, -}; +use crate::sigverify; +use crate::sigverify_stage::SigVerifier; +use solana_ledger::leader_schedule_cache::LeaderScheduleCache; +use solana_ledger::shred::Shred; +use solana_ledger::sigverify_shreds::verify_shreds_gpu; +use solana_perf::{self, packet::Packets, recycler_cache::RecyclerCache}; +use solana_runtime::bank_forks::BankForks; +use std::collections::{HashMap, HashSet}; +use std::sync::{Arc, RwLock}; #[derive(Clone)] pub struct ShredSigVerifier { @@ -63,16 +59,12 @@ impl SigVerifier for ShredSigVerifier { #[cfg(test)] pub mod tests { - use { - super::*, - solana_ledger::{ - genesis_utils::create_genesis_config_with_leader, - shred::{Shred, Shredder}, - }, - solana_perf::packet::Packet, - solana_runtime::bank::Bank, - solana_sdk::signature::{Keypair, Signer}, - }; + use super::*; + use solana_ledger::genesis_utils::create_genesis_config_with_leader; + use solana_ledger::shred::{Shred, Shredder}; + use solana_perf::packet::Packet; + use solana_runtime::bank::Bank; + use solana_sdk::signature::{Keypair, Signer}; #[test] fn test_sigverify_shreds_read_slots() { diff --git a/core/src/sigverify_stage.rs b/core/src/sigverify_stage.rs index 596cdcd211..6fbb790851 100644 --- a/core/src/sigverify_stage.rs +++ b/core/src/sigverify_stage.rs @@ -5,21 +5,17 @@ //! transaction. All processing is done on the CPU by default and on a GPU //! if perf-libs are available -use { - crate::sigverify, - crossbeam_channel::{SendError, Sender as CrossbeamSender}, - solana_measure::measure::Measure, - solana_perf::packet::Packets, - solana_sdk::timing, - solana_streamer::streamer::{self, PacketReceiver, StreamerError}, - std::{ - collections::HashMap, - sync::mpsc::{Receiver, RecvTimeoutError}, - thread::{self, Builder, JoinHandle}, - time::Instant, - }, - thiserror::Error, -}; +use crate::sigverify; +use crossbeam_channel::{SendError, Sender as CrossbeamSender}; +use solana_measure::measure::Measure; +use solana_perf::packet::Packets; +use solana_sdk::timing; +use solana_streamer::streamer::{self, PacketReceiver, StreamerError}; +use std::collections::HashMap; +use std::sync::mpsc::{Receiver, RecvTimeoutError}; +use std::thread::{self, Builder, JoinHandle}; +use std::time::Instant; +use thiserror::Error; const MAX_SIGVERIFY_BATCH: usize = 10_000; @@ -269,7 +265,8 @@ impl SigVerifyStage { #[cfg(test)] mod tests { - use {super::*, solana_perf::packet::Packet}; + use super::*; + use solana_perf::packet::Packet; fn count_non_discard(packets: &[Packets]) -> usize { packets diff --git a/core/src/snapshot_packager_service.rs b/core/src/snapshot_packager_service.rs index 1af71933c6..fbc5a163b6 100644 --- a/core/src/snapshot_packager_service.rs +++ b/core/src/snapshot_packager_service.rs @@ -1,16 +1,14 @@ -use { - solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES}, - solana_perf::thread::renice_this_thread, - solana_runtime::{snapshot_package::AccountsPackage, snapshot_utils}, - solana_sdk::{clock::Slot, hash::Hash}, - std::{ - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, Mutex, - }, - thread::{self, Builder, JoinHandle}, - time::Duration, +use solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES}; +use solana_perf::thread::renice_this_thread; +use solana_runtime::{snapshot_package::AccountsPackage, snapshot_utils}; +use solana_sdk::{clock::Slot, hash::Hash}; +use std::{ + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, Mutex, }, + thread::{self, Builder, JoinHandle}, + time::Duration, }; pub type PendingSnapshotPackage = Arc>>; @@ -78,24 +76,22 @@ impl SnapshotPackagerService { #[cfg(test)] mod tests { - use { - super::*, - bincode::serialize_into, - solana_runtime::{ - accounts_db::AccountStorageEntry, - bank::BankSlotDelta, - bank_forks::ArchiveFormat, - snapshot_package::AccountsPackage, - snapshot_utils::{self, SnapshotVersion, SNAPSHOT_STATUS_CACHE_FILE_NAME}, - }, - solana_sdk::hash::Hash, - std::{ - fs::{self, remove_dir_all, OpenOptions}, - io::Write, - path::{Path, PathBuf}, - }, - tempfile::TempDir, + use super::*; + use bincode::serialize_into; + use solana_runtime::{ + accounts_db::AccountStorageEntry, + bank::BankSlotDelta, + bank_forks::ArchiveFormat, + snapshot_package::AccountsPackage, + snapshot_utils::{self, SnapshotVersion, SNAPSHOT_STATUS_CACHE_FILE_NAME}, }; + use solana_sdk::hash::Hash; + use std::{ + fs::{self, remove_dir_all, OpenOptions}, + io::Write, + path::{Path, PathBuf}, + }; + use tempfile::TempDir; // Create temporary placeholder directory for all test files fn make_tmp_dir_path() -> PathBuf { diff --git a/core/src/system_monitor_service.rs b/core/src/system_monitor_service.rs index d7c9066329..3b6b07c284 100644 --- a/core/src/system_monitor_service.rs +++ b/core/src/system_monitor_service.rs @@ -8,6 +8,7 @@ use std::{ thread::{self, sleep, Builder, JoinHandle}, time::{Duration, Instant}, }; + #[cfg(target_os = "linux")] use std::{fs::File, io::BufReader, path::Path}; diff --git a/core/src/tpu.rs b/core/src/tpu.rs index 4b4eadf92c..fb895bd084 100644 --- a/core/src/tpu.rs +++ b/core/src/tpu.rs @@ -1,40 +1,38 @@ //! The `tpu` module implements the Transaction Processing Unit, a //! multi-stage transaction processing pipeline in software. -use { - crate::{ - banking_stage::BankingStage, - broadcast_stage::{BroadcastStage, BroadcastStageType, RetransmitSlotsReceiver}, - cluster_info_vote_listener::{ - ClusterInfoVoteListener, GossipDuplicateConfirmedSlotsSender, - GossipVerifiedVoteHashSender, VerifiedVoteSender, VoteTracker, - }, - fetch_stage::FetchStage, - sigverify::TransactionSigVerifier, - sigverify_stage::SigVerifyStage, +use crate::{ + banking_stage::BankingStage, + broadcast_stage::{BroadcastStage, BroadcastStageType, RetransmitSlotsReceiver}, + cluster_info_vote_listener::{ + ClusterInfoVoteListener, GossipDuplicateConfirmedSlotsSender, GossipVerifiedVoteHashSender, + VerifiedVoteSender, VoteTracker, }, - crossbeam_channel::unbounded, - solana_gossip::cluster_info::ClusterInfo, - solana_ledger::{blockstore::Blockstore, blockstore_processor::TransactionStatusSender}, - solana_poh::poh_recorder::{PohRecorder, WorkingBankEntry}, - solana_rpc::{ - optimistically_confirmed_bank_tracker::BankNotificationSender, - rpc_subscriptions::RpcSubscriptions, - }, - solana_runtime::{ - bank_forks::BankForks, - cost_model::CostModel, - vote_sender_types::{ReplayVoteReceiver, ReplayVoteSender}, - }, - std::{ - net::UdpSocket, - sync::{ - atomic::AtomicBool, - mpsc::{channel, Receiver}, - Arc, Mutex, RwLock, - }, - thread, + fetch_stage::FetchStage, + sigverify::TransactionSigVerifier, + sigverify_stage::SigVerifyStage, +}; +use crossbeam_channel::unbounded; +use solana_gossip::cluster_info::ClusterInfo; +use solana_ledger::{blockstore::Blockstore, blockstore_processor::TransactionStatusSender}; +use solana_poh::poh_recorder::{PohRecorder, WorkingBankEntry}; +use solana_rpc::{ + optimistically_confirmed_bank_tracker::BankNotificationSender, + rpc_subscriptions::RpcSubscriptions, +}; +use solana_runtime::{ + bank_forks::BankForks, + cost_model::CostModel, + vote_sender_types::{ReplayVoteReceiver, ReplayVoteSender}, +}; +use std::{ + net::UdpSocket, + sync::{ + atomic::AtomicBool, + mpsc::{channel, Receiver}, + Arc, Mutex, RwLock, }, + thread, }; pub const DEFAULT_TPU_COALESCE_MS: u64 = 5; diff --git a/core/src/tvu.rs b/core/src/tvu.rs index 3812547a93..115d5adb55 100644 --- a/core/src/tvu.rs +++ b/core/src/tvu.rs @@ -1,66 +1,64 @@ //! The `tvu` module implements the Transaction Validation Unit, a multi-stage transaction //! validation pipeline in software. -use { - crate::{ - accounts_hash_verifier::AccountsHashVerifier, - broadcast_stage::RetransmitSlotsSender, - cache_block_meta_service::CacheBlockMetaSender, - cluster_info_vote_listener::{ - GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver, - VerifiedVoteReceiver, VoteTracker, - }, - cluster_slots::ClusterSlots, - completed_data_sets_service::CompletedDataSetsSender, - consensus::Tower, - cost_update_service::CostUpdateService, - drop_bank_service::DropBankService, - ledger_cleanup_service::LedgerCleanupService, - replay_stage::{ReplayStage, ReplayStageConfig}, - retransmit_stage::RetransmitStage, - rewards_recorder_service::RewardsRecorderSender, - shred_fetch_stage::ShredFetchStage, - sigverify_shreds::ShredSigVerifier, - sigverify_stage::SigVerifyStage, - snapshot_packager_service::PendingSnapshotPackage, - voting_service::VotingService, +use crate::{ + accounts_hash_verifier::AccountsHashVerifier, + broadcast_stage::RetransmitSlotsSender, + cache_block_meta_service::CacheBlockMetaSender, + cluster_info_vote_listener::{ + GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver, + VerifiedVoteReceiver, VoteTracker, }, - crossbeam_channel::unbounded, - solana_gossip::cluster_info::ClusterInfo, - solana_ledger::{ - blockstore::Blockstore, blockstore_processor::TransactionStatusSender, - leader_schedule_cache::LeaderScheduleCache, + cluster_slots::ClusterSlots, + completed_data_sets_service::CompletedDataSetsSender, + consensus::Tower, + cost_update_service::CostUpdateService, + drop_bank_service::DropBankService, + ledger_cleanup_service::LedgerCleanupService, + replay_stage::{ReplayStage, ReplayStageConfig}, + retransmit_stage::RetransmitStage, + rewards_recorder_service::RewardsRecorderSender, + shred_fetch_stage::ShredFetchStage, + sigverify_shreds::ShredSigVerifier, + sigverify_stage::SigVerifyStage, + snapshot_packager_service::PendingSnapshotPackage, + voting_service::VotingService, +}; +use crossbeam_channel::unbounded; +use solana_gossip::cluster_info::ClusterInfo; +use solana_ledger::{ + blockstore::Blockstore, blockstore_processor::TransactionStatusSender, + leader_schedule_cache::LeaderScheduleCache, +}; +use solana_poh::poh_recorder::PohRecorder; +use solana_rpc::{ + max_slots::MaxSlots, optimistically_confirmed_bank_tracker::BankNotificationSender, + rpc_subscriptions::RpcSubscriptions, +}; +use solana_runtime::{ + accounts_background_service::{ + AbsRequestHandler, AbsRequestSender, AccountsBackgroundService, SnapshotRequestHandler, }, - solana_poh::poh_recorder::PohRecorder, - solana_rpc::{ - max_slots::MaxSlots, optimistically_confirmed_bank_tracker::BankNotificationSender, - rpc_subscriptions::RpcSubscriptions, - }, - solana_runtime::{ - accounts_background_service::{ - AbsRequestHandler, AbsRequestSender, AccountsBackgroundService, SnapshotRequestHandler, - }, - accounts_db::AccountShrinkThreshold, - bank_forks::{BankForks, SnapshotConfig}, - commitment::BlockCommitmentCache, - cost_model::CostModel, - vote_sender_types::ReplayVoteSender, - }, - solana_sdk::{ - pubkey::Pubkey, - signature::{Keypair, Signer}, - }, - std::{ - boxed::Box, - collections::HashSet, - net::UdpSocket, - sync::{ - atomic::AtomicBool, - mpsc::{channel, Receiver}, - Arc, Mutex, RwLock, - }, - thread, + accounts_db::AccountShrinkThreshold, + bank_forks::{BankForks, SnapshotConfig}, + commitment::BlockCommitmentCache, + cost_model::CostModel, + vote_sender_types::ReplayVoteSender, +}; +use solana_sdk::{ + pubkey::Pubkey, + signature::{Keypair, Signer}, +}; +use std::{ + boxed::Box, + collections::HashSet, + net::UdpSocket, + sync::{ + atomic::AtomicBool, + mpsc::{channel, Receiver}, + Arc, Mutex, RwLock, }, + thread, }; pub struct Tvu { @@ -379,22 +377,20 @@ impl Tvu { #[cfg(test)] pub mod tests { - use { - super::*, - serial_test::serial, - solana_gossip::cluster_info::{ClusterInfo, Node}, - solana_ledger::{ - blockstore::BlockstoreSignals, - create_new_tmp_ledger, - genesis_utils::{create_genesis_config, GenesisConfigInfo}, - }, - solana_poh::poh_recorder::create_test_recorder, - solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, - solana_runtime::bank::Bank, - solana_sdk::signature::{Keypair, Signer}, - solana_streamer::socket::SocketAddrSpace, - std::sync::atomic::Ordering, + use super::*; + use serial_test::serial; + use solana_gossip::cluster_info::{ClusterInfo, Node}; + use solana_ledger::{ + blockstore::BlockstoreSignals, + create_new_tmp_ledger, + genesis_utils::{create_genesis_config, GenesisConfigInfo}, }; + use solana_poh::poh_recorder::create_test_recorder; + use solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank; + use solana_runtime::bank::Bank; + use solana_sdk::signature::{Keypair, Signer}; + use solana_streamer::socket::SocketAddrSpace; + use std::sync::atomic::Ordering; #[ignore] #[test] diff --git a/core/src/unfrozen_gossip_verified_vote_hashes.rs b/core/src/unfrozen_gossip_verified_vote_hashes.rs index 29b07ab754..30d944754c 100644 --- a/core/src/unfrozen_gossip_verified_vote_hashes.rs +++ b/core/src/unfrozen_gossip_verified_vote_hashes.rs @@ -1,8 +1,6 @@ -use { - crate::latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, - solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey}, - std::collections::{BTreeMap, HashMap}, -}; +use crate::latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks; +use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey}; +use std::collections::{BTreeMap, HashMap}; #[derive(Default)] pub(crate) struct UnfrozenGossipVerifiedVoteHashes { diff --git a/core/src/validator.rs b/core/src/validator.rs index 98ec7001f9..5238e51df5 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -45,6 +45,7 @@ use { poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS}, poh_service::{self, PohService}, }, + solana_rpc::send_transaction_service, solana_rpc::{ max_slots::MaxSlots, optimistically_confirmed_bank_tracker::{ @@ -55,7 +56,6 @@ use { rpc_pubsub_service::{PubSubConfig, PubSubService}, rpc_service::JsonRpcService, rpc_subscriptions::RpcSubscriptions, - send_transaction_service, transaction_status_service::TransactionStatusService, }, solana_runtime::{ @@ -1640,12 +1640,11 @@ pub fn is_snapshot_config_invalid( #[cfg(test)] mod tests { - use { - super::*, - solana_ledger::{create_new_tmp_ledger, genesis_utils::create_genesis_config_with_leader}, - solana_sdk::{genesis_config::create_genesis_config, poh_config::PohConfig}, - std::fs::remove_dir_all, - }; + use super::*; + use solana_ledger::{create_new_tmp_ledger, genesis_utils::create_genesis_config_with_leader}; + use solana_sdk::genesis_config::create_genesis_config; + use solana_sdk::poh_config::PohConfig; + use std::fs::remove_dir_all; #[test] fn validator_exit() { @@ -1690,7 +1689,8 @@ mod tests { fn test_backup_and_clear_blockstore() { use std::time::Instant; solana_logger::setup(); - use solana_ledger::{blockstore, entry, get_tmp_ledger_path}; + use solana_ledger::get_tmp_ledger_path; + use solana_ledger::{blockstore, entry}; let blockstore_path = get_tmp_ledger_path!(); { let blockstore = Blockstore::open(&blockstore_path).unwrap(); diff --git a/core/src/verified_vote_packets.rs b/core/src/verified_vote_packets.rs index 55c7577c87..772aac1775 100644 --- a/core/src/verified_vote_packets.rs +++ b/core/src/verified_vote_packets.rs @@ -1,12 +1,10 @@ -use { - crate::{cluster_info_vote_listener::VerifiedLabelVotePacketsReceiver, result::Result}, - solana_gossip::crds_value::CrdsValueLabel, - solana_perf::packet::Packets, - solana_sdk::clock::Slot, - std::{ - collections::{hash_map::Entry, HashMap}, - time::Duration, - }, +use crate::{cluster_info_vote_listener::VerifiedLabelVotePacketsReceiver, result::Result}; +use solana_gossip::crds_value::CrdsValueLabel; +use solana_perf::packet::Packets; +use solana_sdk::clock::Slot; +use std::{ + collections::{hash_map::Entry, HashMap}, + time::Duration, }; #[derive(Default)] @@ -76,12 +74,10 @@ impl VerifiedVotePackets { #[cfg(test)] mod tests { - use { - super::*, - crate::result::Error, - crossbeam_channel::{unbounded, RecvTimeoutError}, - solana_perf::packet::{Meta, Packet}, - }; + use super::*; + use crate::result::Error; + use crossbeam_channel::{unbounded, RecvTimeoutError}; + use solana_perf::packet::{Meta, Packet}; #[test] fn test_get_latest_votes() { diff --git a/core/src/vote_stake_tracker.rs b/core/src/vote_stake_tracker.rs index f51c6a0f61..feaede7bdc 100644 --- a/core/src/vote_stake_tracker.rs +++ b/core/src/vote_stake_tracker.rs @@ -1,4 +1,5 @@ -use {solana_sdk::pubkey::Pubkey, std::collections::HashSet}; +use solana_sdk::pubkey::Pubkey; +use std::collections::HashSet; #[derive(Default)] pub struct VoteStakeTracker { @@ -48,7 +49,8 @@ impl VoteStakeTracker { #[cfg(test)] mod test { - use {super::*, solana_runtime::commitment::VOTE_THRESHOLD_SIZE}; + use super::*; + use solana_runtime::commitment::VOTE_THRESHOLD_SIZE; #[test] fn test_add_vote_pubkey() { diff --git a/core/src/voting_service.rs b/core/src/voting_service.rs index e78f7145d1..c7d01c99f2 100644 --- a/core/src/voting_service.rs +++ b/core/src/voting_service.rs @@ -1,12 +1,10 @@ -use { - solana_gossip::cluster_info::ClusterInfo, - solana_poh::poh_recorder::PohRecorder, - solana_runtime::bank_forks::BankForks, - solana_sdk::{clock::Slot, transaction::Transaction}, - std::{ - sync::{mpsc::Receiver, Arc, Mutex, RwLock}, - thread::{self, Builder, JoinHandle}, - }, +use solana_gossip::cluster_info::ClusterInfo; +use solana_poh::poh_recorder::PohRecorder; +use solana_runtime::bank_forks::BankForks; +use solana_sdk::{clock::Slot, transaction::Transaction}; +use std::{ + sync::{mpsc::Receiver, Arc, Mutex, RwLock}, + thread::{self, Builder, JoinHandle}, }; pub enum VoteOp { diff --git a/core/src/window_service.rs b/core/src/window_service.rs index 3438b16178..5cc505dc89 100644 --- a/core/src/window_service.rs +++ b/core/src/window_service.rs @@ -26,9 +26,10 @@ use { solana_rayon_threadlimit::get_thread_count, solana_runtime::{bank::Bank, bank_forks::BankForks}, solana_sdk::{clock::Slot, packet::PACKET_DATA_SIZE, pubkey::Pubkey}, + std::collections::HashSet, std::{ cmp::Reverse, - collections::{HashMap, HashSet}, + collections::HashMap, net::{SocketAddr, UdpSocket}, sync::{ atomic::{AtomicBool, Ordering}, @@ -913,10 +914,8 @@ mod test { #[test] fn test_prune_shreds() { - use { - crate::serve_repair::RepairType, - std::net::{IpAddr, Ipv4Addr}, - }; + use crate::serve_repair::RepairType; + use std::net::{IpAddr, Ipv4Addr}; solana_logger::setup(); let (common, coding) = Shredder::new_coding_shred_header(5, 5, 5, 6, 6, 0); let shred = Shred::new_empty_from_header(common, DataShredHeader::default(), coding); diff --git a/core/tests/client.rs b/core/tests/client.rs index 1dbd858000..325124650f 100644 --- a/core/tests/client.rs +++ b/core/tests/client.rs @@ -1,46 +1,44 @@ -use { - serde_json::{json, Value}, - serial_test::serial, - solana_client::{ - pubsub_client::PubsubClient, - rpc_client::RpcClient, - rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, - rpc_response::SlotInfo, - }, - solana_core::test_validator::TestValidator, - solana_rpc::{ - optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, - rpc_pubsub_service::{PubSubConfig, PubSubService}, - rpc_subscriptions::RpcSubscriptions, - }, - solana_runtime::{ - bank::Bank, - bank_forks::BankForks, - commitment::{BlockCommitmentCache, CommitmentSlots}, - genesis_utils::{create_genesis_config, GenesisConfigInfo}, - }, - solana_sdk::{ - clock::Slot, - commitment_config::CommitmentConfig, - native_token::sol_to_lamports, - pubkey::Pubkey, - rpc_port, - signature::{Keypair, Signer}, - system_program, system_transaction, - }, - solana_streamer::socket::SocketAddrSpace, - std::{ - collections::HashSet, - net::{IpAddr, SocketAddr}, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, RwLock, - }, - thread::sleep, - time::{Duration, Instant}, - }, - systemstat::Ipv4Addr, +use serde_json::{json, Value}; +use serial_test::serial; +use solana_client::{ + pubsub_client::PubsubClient, + rpc_client::RpcClient, + rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, + rpc_response::SlotInfo, }; +use solana_core::test_validator::TestValidator; +use solana_rpc::{ + optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, + rpc_pubsub_service::{PubSubConfig, PubSubService}, + rpc_subscriptions::RpcSubscriptions, +}; +use solana_runtime::{ + bank::Bank, + bank_forks::BankForks, + commitment::{BlockCommitmentCache, CommitmentSlots}, + genesis_utils::{create_genesis_config, GenesisConfigInfo}, +}; +use solana_sdk::{ + clock::Slot, + commitment_config::CommitmentConfig, + native_token::sol_to_lamports, + pubkey::Pubkey, + rpc_port, + signature::{Keypair, Signer}, + system_program, system_transaction, +}; +use solana_streamer::socket::SocketAddrSpace; +use std::{ + collections::HashSet, + net::{IpAddr, SocketAddr}, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, RwLock, + }, + thread::sleep, + time::{Duration, Instant}, +}; +use systemstat::Ipv4Addr; #[test] fn test_rpc_client() { diff --git a/core/tests/fork-selection.rs b/core/tests/fork-selection.rs index 21d4ebd4c3..cfeda12228 100644 --- a/core/tests/fork-selection.rs +++ b/core/tests/fork-selection.rs @@ -74,10 +74,8 @@ #![allow(clippy::integer_arithmetic)] extern crate rand; -use { - rand::{thread_rng, Rng}, - std::collections::{HashMap, VecDeque}, -}; +use rand::{thread_rng, Rng}; +use std::collections::{HashMap, VecDeque}; #[derive(Clone, Default, Debug, Hash, Eq, PartialEq)] pub struct Fork { diff --git a/core/tests/ledger_cleanup.rs b/core/tests/ledger_cleanup.rs index 8901ef5a7f..69778edefa 100644 --- a/core/tests/ledger_cleanup.rs +++ b/core/tests/ledger_cleanup.rs @@ -3,28 +3,20 @@ #[cfg(test)] mod tests { - use { - log::*, - solana_core::ledger_cleanup_service::LedgerCleanupService, - solana_ledger::{ - blockstore::{make_many_slot_entries, Blockstore}, - get_tmp_ledger_path, - shred::Shred, - }, - solana_measure::measure::Measure, - std::{ - collections::VecDeque, - str::FromStr, - sync::{ - atomic::{AtomicBool, AtomicU64, Ordering}, - mpsc::channel, - Arc, Mutex, RwLock, - }, - thread::{self, Builder, JoinHandle}, - time::{Duration, Instant}, - }, - systemstat::{CPULoad, Platform, System}, - }; + use log::*; + use solana_core::ledger_cleanup_service::LedgerCleanupService; + use solana_ledger::blockstore::{make_many_slot_entries, Blockstore}; + use solana_ledger::get_tmp_ledger_path; + use solana_ledger::shred::Shred; + use solana_measure::measure::Measure; + use std::collections::VecDeque; + use std::str::FromStr; + use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; + use std::sync::mpsc::channel; + use std::sync::{Arc, Mutex, RwLock}; + use std::thread::{self, Builder, JoinHandle}; + use std::time::{Duration, Instant}; + use systemstat::{CPULoad, Platform, System}; const DEFAULT_BENCHMARK_SLOTS: u64 = 50; const DEFAULT_BATCH_SIZE: u64 = 1; diff --git a/core/tests/rpc.rs b/core/tests/rpc.rs index 44c27b36ca..b942f32aaf 100644 --- a/core/tests/rpc.rs +++ b/core/tests/rpc.rs @@ -1,40 +1,40 @@ -use { - bincode::serialize, - jsonrpc_core::futures::StreamExt, - jsonrpc_core_client::transports::ws, - log::*, - reqwest::{self, header::CONTENT_TYPE}, - serde_json::{json, Value}, - solana_account_decoder::UiAccount, - solana_client::{ - client_error::{ClientErrorKind, Result as ClientResult}, - rpc_client::RpcClient, - rpc_config::{RpcAccountInfoConfig, RpcSignatureSubscribeConfig}, - rpc_request::RpcError, - rpc_response::{Response as RpcResponse, RpcSignatureResult, SlotUpdate}, - tpu_client::{TpuClient, TpuClientConfig}, - }, - solana_core::test_validator::TestValidator, - solana_rpc::rpc_pubsub::gen_client::Client as PubsubClient, - solana_sdk::{ - commitment_config::CommitmentConfig, - hash::Hash, - pubkey::Pubkey, - signature::{Keypair, Signer}, - system_transaction, - transaction::Transaction, - }, - solana_streamer::socket::SocketAddrSpace, - solana_transaction_status::TransactionStatus, - std::{ - collections::HashSet, - net::UdpSocket, - sync::{mpsc::channel, Arc}, - thread::sleep, - time::{Duration, Instant}, - }, - tokio::runtime::Runtime, +use bincode::serialize; +use jsonrpc_core::futures::StreamExt; +use jsonrpc_core_client::transports::ws; + +use log::*; +use reqwest::{self, header::CONTENT_TYPE}; +use serde_json::{json, Value}; +use solana_account_decoder::UiAccount; +use solana_client::{ + client_error::{ClientErrorKind, Result as ClientResult}, + rpc_client::RpcClient, + rpc_config::{RpcAccountInfoConfig, RpcSignatureSubscribeConfig}, + rpc_request::RpcError, + rpc_response::{Response as RpcResponse, RpcSignatureResult, SlotUpdate}, + tpu_client::{TpuClient, TpuClientConfig}, }; +use solana_core::test_validator::TestValidator; +use solana_rpc::rpc_pubsub::gen_client::Client as PubsubClient; + +use solana_sdk::{ + commitment_config::CommitmentConfig, + hash::Hash, + pubkey::Pubkey, + signature::{Keypair, Signer}, + system_transaction, + transaction::Transaction, +}; +use solana_streamer::socket::SocketAddrSpace; +use solana_transaction_status::TransactionStatus; +use std::{ + collections::HashSet, + net::UdpSocket, + sync::{mpsc::channel, Arc}, + thread::sleep, + time::{Duration, Instant}, +}; +use tokio::runtime::Runtime; macro_rules! json_req { ($method: expr, $params: expr) => {{ @@ -108,9 +108,8 @@ fn test_rpc_send_tx() { assert!(confirmed_tx); - use { - solana_account_decoder::UiAccountEncoding, solana_client::rpc_config::RpcAccountInfoConfig, - }; + use solana_account_decoder::UiAccountEncoding; + use solana_client::rpc_config::RpcAccountInfoConfig; let config = RpcAccountInfoConfig { encoding: Some(UiAccountEncoding::Base64), commitment: None, diff --git a/core/tests/snapshots.rs b/core/tests/snapshots.rs index 360597e0a2..2c87e3b1ed 100644 --- a/core/tests/snapshots.rs +++ b/core/tests/snapshots.rs @@ -35,45 +35,44 @@ macro_rules! DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS { #[cfg(test)] mod tests { - use { - bincode::serialize_into, - crossbeam_channel::unbounded, - fs_extra::dir::CopyOptions, - itertools::Itertools, - solana_core::snapshot_packager_service::{PendingSnapshotPackage, SnapshotPackagerService}, - solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo}, - solana_runtime::{ - accounts_background_service::{AbsRequestSender, SnapshotRequestHandler}, - accounts_db, - accounts_index::AccountSecondaryIndexes, - bank::{Bank, BankSlotDelta}, - bank_forks::{ArchiveFormat, BankForks, SnapshotConfig}, - genesis_utils::{create_genesis_config, GenesisConfigInfo}, - snapshot_utils::{self, SnapshotVersion, DEFAULT_MAX_SNAPSHOTS_TO_RETAIN}, - status_cache::MAX_CACHE_ENTRIES, - }, - solana_sdk::{ - clock::Slot, - genesis_config::{ClusterType, GenesisConfig}, - hash::hashv, - pubkey::Pubkey, - signature::{Keypair, Signer}, - system_transaction, - }, - solana_streamer::socket::SocketAddrSpace, - std::{ - collections::HashSet, - fs, - path::PathBuf, - sync::{ - atomic::{AtomicBool, Ordering}, - mpsc::channel, - Arc, - }, - time::Duration, - }, - tempfile::TempDir, + use bincode::serialize_into; + use crossbeam_channel::unbounded; + use fs_extra::dir::CopyOptions; + use itertools::Itertools; + use solana_core::snapshot_packager_service::{PendingSnapshotPackage, SnapshotPackagerService}; + use solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo}; + use solana_runtime::{ + accounts_background_service::{AbsRequestSender, SnapshotRequestHandler}, + accounts_db, + accounts_index::AccountSecondaryIndexes, + bank::{Bank, BankSlotDelta}, + bank_forks::{ArchiveFormat, BankForks, SnapshotConfig}, + genesis_utils::{create_genesis_config, GenesisConfigInfo}, + snapshot_utils, + snapshot_utils::{SnapshotVersion, DEFAULT_MAX_SNAPSHOTS_TO_RETAIN}, + status_cache::MAX_CACHE_ENTRIES, }; + use solana_sdk::{ + clock::Slot, + genesis_config::{ClusterType, GenesisConfig}, + hash::hashv, + pubkey::Pubkey, + signature::{Keypair, Signer}, + system_transaction, + }; + use solana_streamer::socket::SocketAddrSpace; + use std::{ + collections::HashSet, + fs, + path::PathBuf, + sync::{ + atomic::{AtomicBool, Ordering}, + mpsc::channel, + Arc, + }, + time::Duration, + }; + use tempfile::TempDir; DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Development, V1_2_0_Development); DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Devnet, V1_2_0_Devnet); diff --git a/dos/src/main.rs b/dos/src/main.rs index 7ec6274edb..ab8d5f5b51 100644 --- a/dos/src/main.rs +++ b/dos/src/main.rs @@ -1,20 +1,16 @@ #![allow(clippy::integer_arithmetic)] -use { - clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg}, - log::*, - rand::{thread_rng, Rng}, - solana_client::rpc_client::RpcClient, - solana_core::serve_repair::RepairProtocol, - solana_gossip::{contact_info::ContactInfo, gossip_service::discover}, - solana_sdk::pubkey::Pubkey, - solana_streamer::socket::SocketAddrSpace, - std::{ - net::{SocketAddr, UdpSocket}, - process::exit, - str::FromStr, - time::{Duration, Instant}, - }, -}; +use clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg}; +use log::*; +use rand::{thread_rng, Rng}; +use solana_client::rpc_client::RpcClient; +use solana_core::serve_repair::RepairProtocol; +use solana_gossip::{contact_info::ContactInfo, gossip_service::discover}; +use solana_sdk::pubkey::Pubkey; +use solana_streamer::socket::SocketAddrSpace; +use std::net::{SocketAddr, UdpSocket}; +use std::process::exit; +use std::str::FromStr; +use std::time::{Duration, Instant}; fn get_repair_contact(nodes: &[ContactInfo]) -> ContactInfo { let source = thread_rng().gen_range(0, nodes.len()); @@ -271,7 +267,8 @@ fn main() { #[cfg(test)] pub mod test { - use {super::*, solana_sdk::timing::timestamp}; + use super::*; + use solana_sdk::timing::timestamp; #[test] fn test_dos() { diff --git a/download-utils/src/lib.rs b/download-utils/src/lib.rs index 6721e426e2..3fda667dea 100644 --- a/download-utils/src/lib.rs +++ b/download-utils/src/lib.rs @@ -1,18 +1,15 @@ #![allow(clippy::integer_arithmetic)] -use { - console::Emoji, - indicatif::{ProgressBar, ProgressStyle}, - log::*, - solana_runtime::{bank_forks::ArchiveFormat, snapshot_utils}, - solana_sdk::{clock::Slot, genesis_config::DEFAULT_GENESIS_ARCHIVE, hash::Hash}, - std::{ - fs::{self, File}, - io::{self, Read}, - net::SocketAddr, - path::{Path, PathBuf}, - time::{Duration, Instant}, - }, -}; +use console::Emoji; +use indicatif::{ProgressBar, ProgressStyle}; +use log::*; +use solana_runtime::{bank_forks::ArchiveFormat, snapshot_utils}; +use solana_sdk::{clock::Slot, genesis_config::DEFAULT_GENESIS_ARCHIVE, hash::Hash}; +use std::fs::{self, File}; +use std::io; +use std::io::Read; +use std::net::SocketAddr; +use std::path::{Path, PathBuf}; +use std::time::{Duration, Instant}; static TRUCK: Emoji = Emoji("🚚 ", ""); static SPARKLE: Emoji = Emoji("✨ ", ""); diff --git a/faucet/src/faucet.rs b/faucet/src/faucet.rs index 6d7d84c232..b253a65435 100644 --- a/faucet/src/faucet.rs +++ b/faucet/src/faucet.rs @@ -494,7 +494,9 @@ impl LimitByTime for Pubkey { #[cfg(test)] mod tests { - use {super::*, solana_sdk::system_instruction::SystemInstruction, std::time::Duration}; + use super::*; + use solana_sdk::system_instruction::SystemInstruction; + use std::time::Duration; #[test] fn test_check_time_request_limit() { diff --git a/faucet/tests/local-faucet.rs b/faucet/tests/local-faucet.rs index 7f2bfe5e25..8629c68ac2 100644 --- a/faucet/tests/local-faucet.rs +++ b/faucet/tests/local-faucet.rs @@ -1,12 +1,10 @@ -use { - solana_faucet::faucet::{request_airdrop_transaction, run_local_faucet}, - solana_sdk::{ - hash::Hash, - message::Message, - signature::{Keypair, Signer}, - system_instruction, - transaction::Transaction, - }, +use solana_faucet::faucet::{request_airdrop_transaction, run_local_faucet}; +use solana_sdk::{ + hash::Hash, + message::Message, + signature::{Keypair, Signer}, + system_instruction, + transaction::Transaction, }; #[test] diff --git a/frozen-abi/src/abi_digester.rs b/frozen-abi/src/abi_digester.rs index 10cf14b807..7831a70c94 100644 --- a/frozen-abi/src/abi_digester.rs +++ b/frozen-abi/src/abi_digester.rs @@ -1,16 +1,12 @@ -use { - crate::{ - abi_example::{normalize_type_name, AbiEnumVisitor}, - hash::{Hash, Hasher}, - }, - log::*, - serde::{ - ser::{Error as SerdeError, *}, - Serialize, Serializer, - }, - std::{any::type_name, io::Write}, - thiserror::Error, -}; +use crate::abi_example::{normalize_type_name, AbiEnumVisitor}; +use crate::hash::{Hash, Hasher}; +use log::*; +use serde::ser::Error as SerdeError; +use serde::ser::*; +use serde::{Serialize, Serializer}; +use std::any::type_name; +use std::io::Write; +use thiserror::Error; #[derive(Debug)] pub struct AbiDigester { @@ -532,7 +528,8 @@ impl SerializeStructVariant for AbiDigester { #[cfg(test)] mod tests { - use std::{collections::HashMap, sync::atomic::AtomicIsize}; + use std::collections::HashMap; + use std::sync::atomic::AtomicIsize; #[frozen_abi(digest = "CQiGCzsGquChkwffHjZKFqa3tCYtS3GWYRRYX7iDR38Q")] type TestTypeAlias = i32; diff --git a/frozen-abi/src/abi_example.rs b/frozen-abi/src/abi_example.rs index 0bf16b6106..b9bb57b364 100644 --- a/frozen-abi/src/abi_example.rs +++ b/frozen-abi/src/abi_example.rs @@ -1,9 +1,9 @@ -use { - crate::abi_digester::{AbiDigester, DigestError, DigestResult}, - log::*, - serde::Serialize, - std::any::type_name, -}; +use crate::abi_digester::{AbiDigester, DigestError, DigestResult}; + +use log::*; + +use serde::Serialize; +use std::any::type_name; pub trait AbiExample: Sized { fn example() -> Self; diff --git a/frozen-abi/src/hash.rs b/frozen-abi/src/hash.rs index 5802099462..480131b7d1 100644 --- a/frozen-abi/src/hash.rs +++ b/frozen-abi/src/hash.rs @@ -1,7 +1,5 @@ -use { - sha2::{Digest, Sha256}, - std::{convert::TryFrom, fmt}, -}; +use sha2::{Digest, Sha256}; +use std::{convert::TryFrom, fmt}; const HASH_BYTES: usize = 32; #[derive(AbiExample)] diff --git a/genesis-utils/src/lib.rs b/genesis-utils/src/lib.rs index 6af1981aac..513da409ad 100644 --- a/genesis-utils/src/lib.rs +++ b/genesis-utils/src/lib.rs @@ -1,12 +1,10 @@ -use { - solana_download_utils::download_genesis_if_missing, - solana_runtime::hardened_unpack::unpack_genesis_archive, - solana_sdk::{ - genesis_config::{GenesisConfig, DEFAULT_GENESIS_ARCHIVE}, - hash::Hash, - }, - std::net::SocketAddr, +use solana_download_utils::download_genesis_if_missing; +use solana_runtime::hardened_unpack::unpack_genesis_archive; +use solana_sdk::{ + genesis_config::{GenesisConfig, DEFAULT_GENESIS_ARCHIVE}, + hash::Hash, }; +use std::net::SocketAddr; fn check_genesis_hash( genesis_config: &GenesisConfig, diff --git a/genesis/src/genesis_accounts.rs b/genesis/src/genesis_accounts.rs index 1f540d4c6f..7bf3504402 100644 --- a/genesis/src/genesis_accounts.rs +++ b/genesis/src/genesis_accounts.rs @@ -1,10 +1,8 @@ -use { - crate::{ - stakes::{create_and_add_stakes, StakerInfo}, - unlocks::UnlockInfo, - }, - solana_sdk::{genesis_config::GenesisConfig, native_token::LAMPORTS_PER_SOL}, +use crate::{ + stakes::{create_and_add_stakes, StakerInfo}, + unlocks::UnlockInfo, }; +use solana_sdk::{genesis_config::GenesisConfig, native_token::LAMPORTS_PER_SOL}; // 9 month schedule is 100% after 9 months const UNLOCKS_ALL_AT_9_MONTHS: UnlockInfo = UnlockInfo { diff --git a/genesis/src/main.rs b/genesis/src/main.rs index b7f35f02b0..2fb7498337 100644 --- a/genesis/src/main.rs +++ b/genesis/src/main.rs @@ -4,48 +4,42 @@ #[macro_use] extern crate solana_exchange_program; -use { - clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg, ArgMatches}, - solana_clap_utils::{ - input_parsers::{ - cluster_type_of, pubkey_of, pubkeys_of, unix_timestamp_from_rfc3339_datetime, - }, - input_validators::{ - is_pubkey_or_keypair, is_rfc3339_datetime, is_slot, is_valid_percentage, - }, - }, - solana_genesis::{genesis_accounts::add_genesis_accounts, Base64Account}, - solana_ledger::{ - blockstore::create_new_ledger, blockstore_db::AccessType, poh::compute_hashes_per_tick, - }, - solana_runtime::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE, - solana_sdk::{ - account::{Account, AccountSharedData, ReadableAccount, WritableAccount}, - clock, - epoch_schedule::EpochSchedule, - fee_calculator::FeeRateGovernor, - genesis_config::{ClusterType, GenesisConfig}, - inflation::Inflation, - native_token::sol_to_lamports, - poh_config::PohConfig, - pubkey::Pubkey, - rent::Rent, - signature::{Keypair, Signer}, - stake::state::StakeState, - system_program, timing, - }, - solana_stake_program::stake_state, - solana_vote_program::vote_state::{self, VoteState}, - std::{ - collections::HashMap, - error, - fs::File, - io::{self, Read}, - path::PathBuf, - process, - str::FromStr, - time::Duration, - }, +use clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg, ArgMatches}; +use solana_clap_utils::{ + input_parsers::{cluster_type_of, pubkey_of, pubkeys_of, unix_timestamp_from_rfc3339_datetime}, + input_validators::{is_pubkey_or_keypair, is_rfc3339_datetime, is_slot, is_valid_percentage}, +}; +use solana_genesis::{genesis_accounts::add_genesis_accounts, Base64Account}; +use solana_ledger::{ + blockstore::create_new_ledger, blockstore_db::AccessType, poh::compute_hashes_per_tick, +}; +use solana_runtime::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE; +use solana_sdk::{ + account::{Account, AccountSharedData, ReadableAccount, WritableAccount}, + clock, + epoch_schedule::EpochSchedule, + fee_calculator::FeeRateGovernor, + genesis_config::{ClusterType, GenesisConfig}, + inflation::Inflation, + native_token::sol_to_lamports, + poh_config::PohConfig, + pubkey::Pubkey, + rent::Rent, + signature::{Keypair, Signer}, + stake::state::StakeState, + system_program, timing, +}; +use solana_stake_program::stake_state; +use solana_vote_program::vote_state::{self, VoteState}; +use std::{ + collections::HashMap, + error, + fs::File, + io::{self, Read}, + path::PathBuf, + process, + str::FromStr, + time::Duration, }; pub enum AccountFileFormat { @@ -648,11 +642,12 @@ fn main() -> Result<(), Box> { #[cfg(test)] mod tests { - use { - super::*, - solana_sdk::genesis_config::GenesisConfig, - std::{collections::HashMap, fs::remove_file, io::Write, path::Path}, - }; + use super::*; + use solana_sdk::genesis_config::GenesisConfig; + use std::collections::HashMap; + use std::fs::remove_file; + use std::io::Write; + use std::path::Path; #[test] fn test_append_primordial_accounts_to_genesis() { diff --git a/genesis/src/stakes.rs b/genesis/src/stakes.rs index 9ee08bf69b..ca2b8da4d9 100644 --- a/genesis/src/stakes.rs +++ b/genesis/src/stakes.rs @@ -165,7 +165,8 @@ pub fn create_and_add_stakes( #[cfg(test)] mod tests { - use {super::*, solana_sdk::rent::Rent}; + use super::*; + use solana_sdk::rent::Rent; fn create_and_check_stakes( genesis_config: &mut GenesisConfig, diff --git a/genesis/src/unlocks.rs b/genesis/src/unlocks.rs index 0fb1a69207..c54cf88515 100644 --- a/genesis/src/unlocks.rs +++ b/genesis/src/unlocks.rs @@ -1,8 +1,6 @@ //! lockups generator -use { - solana_sdk::{clock::Epoch, epoch_schedule::EpochSchedule, timing::years_as_slots}, - std::time::Duration, -}; +use solana_sdk::{clock::Epoch, epoch_schedule::EpochSchedule, timing::years_as_slots}; +use std::time::Duration; #[derive(Debug)] pub struct UnlockInfo { diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs index b5fd389add..c434acd96f 100644 --- a/gossip/src/cluster_info.rs +++ b/gossip/src/cluster_info.rs @@ -44,12 +44,10 @@ use { bind_common, bind_common_in_range, bind_in_range, find_available_port_in_range, multi_bind_in_range, PortRange, }, - solana_perf::{ - data_budget::DataBudget, - packet::{ - limited_deserialize, to_packets_with_destination, Packet, Packets, PacketsRecycler, - PACKET_DATA_SIZE, - }, + solana_perf::data_budget::DataBudget, + solana_perf::packet::{ + limited_deserialize, to_packets_with_destination, Packet, Packets, PacketsRecycler, + PACKET_DATA_SIZE, }, solana_rayon_threadlimit::get_thread_count, solana_runtime::bank_forks::BankForks, @@ -86,7 +84,7 @@ use { sync::{ atomic::{AtomicBool, Ordering}, mpsc::{Receiver, RecvTimeoutError, Sender}, - Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard, + {Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard}, }, thread::{sleep, Builder, JoinHandle}, time::{Duration, Instant}, diff --git a/gossip/src/crds_value.rs b/gossip/src/crds_value.rs index 618b07bacf..02a2429b7d 100644 --- a/gossip/src/crds_value.rs +++ b/gossip/src/crds_value.rs @@ -9,13 +9,13 @@ use { bincode::{serialize, serialized_size}, rand::{CryptoRng, Rng}, serde::de::{Deserialize, Deserializer}, + solana_sdk::sanitize::{Sanitize, SanitizeError}, + solana_sdk::timing::timestamp, solana_sdk::{ clock::Slot, hash::Hash, pubkey::{self, Pubkey}, - sanitize::{Sanitize, SanitizeError}, signature::{Keypair, Signable, Signature, Signer}, - timing::timestamp, transaction::Transaction, }, solana_vote_program::vote_transaction::parse_vote_transaction, diff --git a/gossip/src/duplicate_shred.rs b/gossip/src/duplicate_shred.rs index 5aaa3d3e5a..ba7c330a59 100644 --- a/gossip/src/duplicate_shred.rs +++ b/gossip/src/duplicate_shred.rs @@ -285,17 +285,11 @@ impl Sanitize for DuplicateShred { #[cfg(test)] pub(crate) mod tests { - use { - super::*, - rand::Rng, - solana_ledger::{entry::Entry, shred::Shredder}, - solana_sdk::{ - hash, - signature::{Keypair, Signer}, - system_transaction, - }, - std::sync::Arc, - }; + use super::*; + use rand::Rng; + use solana_ledger::{entry::Entry, shred::Shredder}; + use solana_sdk::{hash, signature::Keypair, signature::Signer, system_transaction}; + use std::sync::Arc; #[test] fn test_duplicate_shred_header_size() { diff --git a/gossip/src/gossip_service.rs b/gossip/src/gossip_service.rs index 29c700f54c..90ddf2102e 100644 --- a/gossip/src/gossip_service.rs +++ b/gossip/src/gossip_service.rs @@ -13,14 +13,15 @@ use { pubkey::Pubkey, signature::{Keypair, Signer}, }, - solana_streamer::{socket::SocketAddrSpace, streamer}, + solana_streamer::socket::SocketAddrSpace, + solana_streamer::streamer, std::{ collections::HashSet, net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener, UdpSocket}, sync::{ atomic::{AtomicBool, Ordering}, mpsc::channel, - Arc, RwLock, + {Arc, RwLock}, }, thread::{self, sleep, JoinHandle}, time::{Duration, Instant}, diff --git a/gossip/src/weighted_shuffle.rs b/gossip/src/weighted_shuffle.rs index a1a9990632..63ba440f30 100644 --- a/gossip/src/weighted_shuffle.rs +++ b/gossip/src/weighted_shuffle.rs @@ -192,10 +192,8 @@ pub fn weighted_best(weights_and_indexes: &[(u64, usize)], seed: [u8; 32]) -> us #[cfg(test)] mod tests { - use { - super::*, - std::{convert::TryInto, iter::repeat_with}, - }; + use super::*; + use std::{convert::TryInto, iter::repeat_with}; fn weighted_shuffle_slow(rng: &mut R, mut weights: Vec) -> Vec where diff --git a/gossip/tests/gossip.rs b/gossip/tests/gossip.rs index 8caef7f743..b6fa2ed44d 100644 --- a/gossip/tests/gossip.rs +++ b/gossip/tests/gossip.rs @@ -246,13 +246,11 @@ pub fn cluster_info_retransmit() { #[test] #[ignore] pub fn cluster_info_scale() { - use { - solana_measure::measure::Measure, - solana_perf::test_tx::test_tx, - solana_runtime::{ - bank::Bank, - genesis_utils::{create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs}, - }, + use solana_measure::measure::Measure; + use solana_perf::test_tx::test_tx; + use solana_runtime::bank::Bank; + use solana_runtime::genesis_utils::{ + create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs, }; solana_logger::setup(); let exit = Arc::new(AtomicBool::new(false)); diff --git a/install/src/command.rs b/install/src/command.rs index d12bac22df..e91c0298f7 100644 --- a/install/src/command.rs +++ b/install/src/command.rs @@ -154,7 +154,8 @@ fn extract_release_archive( archive: &Path, extract_dir: &Path, ) -> Result<(), Box> { - use {bzip2::bufread::BzDecoder, tar::Archive}; + use bzip2::bufread::BzDecoder; + use tar::Archive; let progress_bar = new_spinner_progress_bar(); progress_bar.set_message(&format!("{}Extracting...", PACKAGE)); @@ -307,7 +308,8 @@ fn check_env_path_for_bin_dir(config: &Config) { /// Encodes a UTF-8 string as a null-terminated UCS-2 string in bytes #[cfg(windows)] pub fn string_to_winreg_bytes(s: &str) -> Vec { - use std::{ffi::OsString, os::windows::ffi::OsStrExt}; + use std::ffi::OsString; + use std::os::windows::ffi::OsStrExt; let v: Vec<_> = OsString::from(format!("{}\x00", s)).encode_wide().collect(); unsafe { std::slice::from_raw_parts(v.as_ptr() as *const u8, v.len() * 2).to_vec() } } @@ -318,7 +320,8 @@ pub fn string_to_winreg_bytes(s: &str) -> Vec { // conversion. #[cfg(windows)] pub fn string_from_winreg_value(val: &winreg::RegValue) -> Option { - use {std::slice, winreg::enums::RegType}; + use std::slice; + use winreg::enums::RegType; match val.vtype { RegType::REG_SZ | RegType::REG_EXPAND_SZ => { @@ -344,10 +347,8 @@ pub fn string_from_winreg_value(val: &winreg::RegValue) -> Option { // should not mess with it. #[cfg(windows)] fn get_windows_path_var() -> Result, String> { - use winreg::{ - enums::{HKEY_CURRENT_USER, KEY_READ, KEY_WRITE}, - RegKey, - }; + use winreg::enums::{HKEY_CURRENT_USER, KEY_READ, KEY_WRITE}; + use winreg::RegKey; let root = RegKey::predef(HKEY_CURRENT_USER); let environment = root @@ -371,19 +372,13 @@ fn get_windows_path_var() -> Result, String> { #[cfg(windows)] fn add_to_path(new_path: &str) -> bool { - use { - std::ptr, - winapi::{ - shared::minwindef::*, - um::winuser::{ - SendMessageTimeoutA, HWND_BROADCAST, SMTO_ABORTIFHUNG, WM_SETTINGCHANGE, - }, - }, - winreg::{ - enums::{RegType, HKEY_CURRENT_USER, KEY_READ, KEY_WRITE}, - RegKey, RegValue, - }, + use std::ptr; + use winapi::shared::minwindef::*; + use winapi::um::winuser::{ + SendMessageTimeoutA, HWND_BROADCAST, SMTO_ABORTIFHUNG, WM_SETTINGCHANGE, }; + use winreg::enums::{RegType, HKEY_CURRENT_USER, KEY_READ, KEY_WRITE}; + use winreg::{RegKey, RegValue}; let old_path = if let Some(s) = get_windows_path_var().unwrap_or_else(|err| panic!("Unable to get PATH: {}", err)) diff --git a/install/src/config.rs b/install/src/config.rs index 8ced2420df..db676eb74b 100644 --- a/install/src/config.rs +++ b/install/src/config.rs @@ -2,11 +2,9 @@ use { crate::update_manifest::UpdateManifest, serde::{Deserialize, Serialize}, solana_sdk::pubkey::Pubkey, - std::{ - fs::{create_dir_all, File}, - io::{self, Write}, - path::{Path, PathBuf}, - }, + std::fs::{create_dir_all, File}, + std::io::{self, Write}, + std::path::{Path, PathBuf}, }; #[derive(Serialize, Deserialize, Debug, PartialEq)] diff --git a/install/src/stop_process.rs b/install/src/stop_process.rs index cf4cac6782..2a888f99da 100644 --- a/install/src/stop_process.rs +++ b/install/src/stop_process.rs @@ -1,4 +1,5 @@ -use std::{io, process::Child}; +use std::io; +use std::process::Child; fn kill_process(process: &mut Child) -> Result<(), io::Error> { if let Ok(()) = process.kill() { @@ -16,19 +17,13 @@ pub fn stop_process(process: &mut Child) -> Result<(), io::Error> { #[cfg(not(windows))] pub fn stop_process(process: &mut Child) -> Result<(), io::Error> { - use { - nix::{ - errno::Errno::{EINVAL, EPERM, ESRCH}, - sys::signal::{kill, Signal}, - unistd::Pid, - Error::Sys, - }, - std::{ - io::ErrorKind, - thread, - time::{Duration, Instant}, - }, - }; + use nix::errno::Errno::{EINVAL, EPERM, ESRCH}; + use nix::sys::signal::{kill, Signal}; + use nix::unistd::Pid; + use nix::Error::Sys; + use std::io::ErrorKind; + use std::thread; + use std::time::{Duration, Instant}; let nice_wait = Duration::from_secs(5); let pid = Pid::from_raw(process.id() as i32); diff --git a/keygen/src/keygen.rs b/keygen/src/keygen.rs index 951026ce73..c7c962a58a 100644 --- a/keygen/src/keygen.rs +++ b/keygen/src/keygen.rs @@ -1,39 +1,37 @@ #![allow(clippy::integer_arithmetic)] -use { - bip39::{Language, Mnemonic, MnemonicType, Seed}, - clap::{ - crate_description, crate_name, value_t, value_t_or_exit, values_t_or_exit, App, - AppSettings, Arg, ArgMatches, SubCommand, +use bip39::{Language, Mnemonic, MnemonicType, Seed}; +use clap::{ + crate_description, crate_name, value_t, value_t_or_exit, values_t_or_exit, App, AppSettings, + Arg, ArgMatches, SubCommand, +}; +use solana_clap_utils::{ + input_parsers::STDOUT_OUTFILE_TOKEN, + input_validators::{is_parsable, is_prompt_signer_source}, + keypair::{ + keypair_from_path, keypair_from_seed_phrase, prompt_passphrase, signer_from_path, + SKIP_SEED_PHRASE_VALIDATION_ARG, }, - solana_clap_utils::{ - input_parsers::STDOUT_OUTFILE_TOKEN, - input_validators::{is_parsable, is_prompt_signer_source}, - keypair::{ - keypair_from_path, keypair_from_seed_phrase, prompt_passphrase, signer_from_path, - SKIP_SEED_PHRASE_VALIDATION_ARG, - }, - ArgConstant, DisplayError, - }, - solana_cli_config::{Config, CONFIG_FILE}, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{ - instruction::{AccountMeta, Instruction}, - message::Message, - pubkey::{write_pubkey_file, Pubkey}, - signature::{keypair_from_seed, write_keypair, write_keypair_file, Keypair, Signer}, - }, - std::{ - collections::HashSet, - error, - path::Path, - process::exit, - sync::{ - atomic::{AtomicBool, AtomicU64, Ordering}, - Arc, - }, - thread, - time::Instant, + ArgConstant, DisplayError, +}; +use solana_cli_config::{Config, CONFIG_FILE}; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{ + instruction::{AccountMeta, Instruction}, + message::Message, + pubkey::{write_pubkey_file, Pubkey}, + signature::{keypair_from_seed, write_keypair, write_keypair_file, Keypair, Signer}, +}; +use std::{ + collections::HashSet, + error, + path::Path, + process::exit, + sync::{ + atomic::{AtomicBool, AtomicU64, Ordering}, + Arc, }, + thread, + time::Instant, }; const NO_PASSPHRASE: &str = ""; diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index cc77015937..c45044be91 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -16,13 +16,13 @@ use { is_parsable, is_pubkey, is_pubkey_or_keypair, is_slot, is_valid_percentage, }, }, + solana_ledger::entry::Entry, solana_ledger::{ ancestor_iterator::AncestorIterator, bank_forks_utils, blockstore::{create_new_ledger, Blockstore, PurgeType}, blockstore_db::{self, AccessType, BlockstoreRecoveryMode, Column, Database}, blockstore_processor::ProcessOptions, - entry::Entry, shred::Shred, }, solana_runtime::{ @@ -31,7 +31,8 @@ use { cost_model::CostModel, cost_tracker::CostTracker, hardened_unpack::{open_genesis_config, MAX_GENESIS_ARCHIVE_UNPACKED_SIZE}, - snapshot_utils::{self, SnapshotVersion, DEFAULT_MAX_SNAPSHOTS_TO_RETAIN}, + snapshot_utils, + snapshot_utils::{SnapshotVersion, DEFAULT_MAX_SNAPSHOTS_TO_RETAIN}, }, solana_sdk::{ account::{AccountSharedData, ReadableAccount, WritableAccount}, diff --git a/ledger-tool/tests/basic.rs b/ledger-tool/tests/basic.rs index 5224c6a34a..4cda481e6e 100644 --- a/ledger-tool/tests/basic.rs +++ b/ledger-tool/tests/basic.rs @@ -1,8 +1,8 @@ -use { - assert_cmd::prelude::*, - solana_ledger::{create_new_tmp_ledger, genesis_utils::create_genesis_config}, - std::process::{Command, Output}, -}; +use assert_cmd::prelude::*; +use solana_ledger::create_new_tmp_ledger; +use solana_ledger::genesis_utils::create_genesis_config; +use std::process::Command; +use std::process::Output; fn run_ledger_tool(args: &[&str]) -> Output { Command::cargo_bin(env!("CARGO_PKG_NAME")) diff --git a/ledger/benches/protobuf.rs b/ledger/benches/protobuf.rs index 240674ca01..e0244efa07 100644 --- a/ledger/benches/protobuf.rs +++ b/ledger/benches/protobuf.rs @@ -2,19 +2,17 @@ #![feature(test)] extern crate test; -use { - bincode::{deserialize, serialize}, - solana_ledger::{ - blockstore::Blockstore, - blockstore_db::{columns as cf, LedgerColumn}, - get_tmp_ledger_path, - }, - solana_runtime::bank::RewardType, - solana_sdk::{clock::Slot, pubkey}, - solana_transaction_status::{Reward, Rewards}, - std::path::Path, - test::Bencher, +use bincode::{deserialize, serialize}; +use solana_ledger::{ + blockstore::Blockstore, + blockstore_db::{columns as cf, LedgerColumn}, + get_tmp_ledger_path, }; +use solana_runtime::bank::RewardType; +use solana_sdk::{clock::Slot, pubkey}; +use solana_transaction_status::{Reward, Rewards}; +use std::path::Path; +use test::Bencher; fn create_rewards() -> Rewards { (0..100) diff --git a/ledger/benches/sigverify_shreds.rs b/ledger/benches/sigverify_shreds.rs index 4a3de44fff..116e1fd77a 100644 --- a/ledger/benches/sigverify_shreds.rs +++ b/ledger/benches/sigverify_shreds.rs @@ -1,19 +1,16 @@ #![feature(test)] extern crate test; -use { - solana_ledger::{ - shred::{Shred, SIZE_OF_DATA_SHRED_PAYLOAD}, - sigverify_shreds::{sign_shreds_cpu, sign_shreds_gpu, sign_shreds_gpu_pinned_keypair}, - }, - solana_perf::{ - packet::{Packet, Packets}, - recycler_cache::RecyclerCache, - }, - solana_sdk::signature::Keypair, - std::sync::Arc, - test::Bencher, +use solana_ledger::shred::Shred; +use solana_ledger::shred::SIZE_OF_DATA_SHRED_PAYLOAD; +use solana_ledger::sigverify_shreds::{ + sign_shreds_cpu, sign_shreds_gpu, sign_shreds_gpu_pinned_keypair, }; +use solana_perf::packet::{Packet, Packets}; +use solana_perf::recycler_cache::RecyclerCache; +use solana_sdk::signature::Keypair; +use std::sync::Arc; +use test::Bencher; const NUM_PACKETS: usize = 256; const NUM_BATCHES: usize = 1; diff --git a/ledger/src/ancestor_iterator.rs b/ledger/src/ancestor_iterator.rs index 87a32ac15f..333974cc05 100644 --- a/ledger/src/ancestor_iterator.rs +++ b/ledger/src/ancestor_iterator.rs @@ -1,4 +1,5 @@ -use {crate::blockstore::*, solana_sdk::clock::Slot}; +use crate::blockstore::*; +use solana_sdk::clock::Slot; pub struct AncestorIterator<'a> { current: Option, @@ -51,10 +52,9 @@ impl<'a> Iterator for AncestorIterator<'a> { #[cfg(test)] mod tests { - use { - super::*, crate::blockstore_processor::fill_blockstore_slot_with_ticks, - solana_sdk::hash::Hash, - }; + use super::*; + use crate::blockstore_processor::fill_blockstore_slot_with_ticks; + use solana_sdk::hash::Hash; #[test] fn test_ancestor_iterator() { diff --git a/ledger/src/bank_forks_utils.rs b/ledger/src/bank_forks_utils.rs index c6e03afafd..39cd2b0a6d 100644 --- a/ledger/src/bank_forks_utils.rs +++ b/ledger/src/bank_forks_utils.rs @@ -1,22 +1,20 @@ -use { - crate::{ - blockstore::Blockstore, - blockstore_processor::{ - self, BlockstoreProcessorError, BlockstoreProcessorResult, CacheBlockMetaSender, - ProcessOptions, TransactionStatusSender, - }, - entry::VerifyRecyclers, - leader_schedule_cache::LeaderScheduleCache, +use crate::{ + blockstore::Blockstore, + blockstore_processor::{ + self, BlockstoreProcessorError, BlockstoreProcessorResult, CacheBlockMetaSender, + ProcessOptions, TransactionStatusSender, }, - log::*, - solana_runtime::{ - accounts_update_notifier_interface::AccountsUpdateNotifier, - bank_forks::{ArchiveFormat, BankForks, SnapshotConfig}, - snapshot_utils, - }, - solana_sdk::{clock::Slot, genesis_config::GenesisConfig, hash::Hash}, - std::{fs, path::PathBuf, process, result}, + entry::VerifyRecyclers, + leader_schedule_cache::LeaderScheduleCache, }; +use log::*; +use solana_runtime::{ + accounts_update_notifier_interface::AccountsUpdateNotifier, + bank_forks::{ArchiveFormat, BankForks, SnapshotConfig}, + snapshot_utils, +}; +use solana_sdk::{clock::Slot, genesis_config::GenesisConfig, hash::Hash}; +use std::{fs, path::PathBuf, process, result}; pub type LoadResult = result::Result< (BankForks, LeaderScheduleCache, Option<(Slot, Hash)>), diff --git a/ledger/src/bigtable_upload.rs b/ledger/src/bigtable_upload.rs index 860a6348bf..2288c9c282 100644 --- a/ledger/src/bigtable_upload.rs +++ b/ledger/src/bigtable_upload.rs @@ -1,17 +1,15 @@ -use { - crate::blockstore::Blockstore, - log::*, - solana_measure::measure::Measure, - solana_sdk::clock::Slot, - std::{ - collections::HashSet, - result::Result, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - time::Duration, +use crate::blockstore::Blockstore; +use log::*; +use solana_measure::measure::Measure; +use solana_sdk::clock::Slot; +use std::{ + collections::HashSet, + result::Result, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, }, + time::Duration, }; // Attempt to upload this many blocks in parallel diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index f0f0b44db8..9c49ba6af0 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -4004,32 +4004,30 @@ fn adjust_ulimit_nofile(enforce_ulimit_nofile: bool) -> Result<()> { #[cfg(test)] pub mod tests { - use { - super::*, - crate::{ - entry::{next_entry, next_entry_mut}, - genesis_utils::{create_genesis_config, GenesisConfigInfo}, - leader_schedule::{FixedSchedule, LeaderSchedule}, - shred::{max_ticks_per_n_shreds, DataShredHeader}, - }, - assert_matches::assert_matches, - bincode::serialize, - itertools::Itertools, - rand::{seq::SliceRandom, thread_rng}, - solana_account_decoder::parse_token::UiTokenAmount, - solana_runtime::bank::{Bank, RewardType}, - solana_sdk::{ - hash::{self, hash, Hash}, - instruction::CompiledInstruction, - packet::PACKET_DATA_SIZE, - pubkey::Pubkey, - signature::Signature, - transaction::TransactionError, - }, - solana_storage_proto::convert::generated, - solana_transaction_status::{InnerInstructions, Reward, Rewards, TransactionTokenBalance}, - std::{sync::mpsc::channel, thread::Builder, time::Duration}, + use super::*; + use crate::{ + entry::{next_entry, next_entry_mut}, + genesis_utils::{create_genesis_config, GenesisConfigInfo}, + leader_schedule::{FixedSchedule, LeaderSchedule}, + shred::{max_ticks_per_n_shreds, DataShredHeader}, }; + use assert_matches::assert_matches; + use bincode::serialize; + use itertools::Itertools; + use rand::{seq::SliceRandom, thread_rng}; + use solana_account_decoder::parse_token::UiTokenAmount; + use solana_runtime::bank::{Bank, RewardType}; + use solana_sdk::{ + hash::{self, hash, Hash}, + instruction::CompiledInstruction, + packet::PACKET_DATA_SIZE, + pubkey::Pubkey, + signature::Signature, + transaction::TransactionError, + }; + use solana_storage_proto::convert::generated; + use solana_transaction_status::{InnerInstructions, Reward, Rewards, TransactionTokenBalance}; + use std::{sync::mpsc::channel, thread::Builder, time::Duration}; // used for tests only pub(crate) fn make_slot_entries_with_transactions(num_entries: u64) -> Vec { diff --git a/ledger/src/blockstore/blockstore_purge.rs b/ledger/src/blockstore/blockstore_purge.rs index 67fe846f97..e847b24674 100644 --- a/ledger/src/blockstore/blockstore_purge.rs +++ b/ledger/src/blockstore/blockstore_purge.rs @@ -1,4 +1,5 @@ -use {super::*, std::time::Instant}; +use super::*; +use std::time::Instant; #[derive(Default)] pub struct PurgeStats { @@ -390,17 +391,15 @@ impl Blockstore { #[cfg(test)] pub mod tests { - use { - super::*, - crate::{ - blockstore::tests::make_slot_entries_with_transactions, entry::next_entry_mut, - get_tmp_ledger_path, - }, - bincode::serialize, - solana_sdk::{ - hash::{hash, Hash}, - message::Message, - }, + use super::*; + use crate::{ + blockstore::tests::make_slot_entries_with_transactions, entry::next_entry_mut, + get_tmp_ledger_path, + }; + use bincode::serialize; + use solana_sdk::{ + hash::{hash, Hash}, + message::Message, }; // check that all columns are either empty or start at `min_slot` diff --git a/ledger/src/blockstore_db.rs b/ledger/src/blockstore_db.rs index 9cd0abcfee..46b97e121e 100644 --- a/ledger/src/blockstore_db.rs +++ b/ledger/src/blockstore_db.rs @@ -1,39 +1,39 @@ +use crate::blockstore_meta; +use bincode::{deserialize, serialize}; +use byteorder::{BigEndian, ByteOrder}; +use log::*; +use prost::Message; pub use rocksdb::Direction as IteratorDirection; -use { - crate::blockstore_meta, - bincode::{deserialize, serialize}, - byteorder::{BigEndian, ByteOrder}, - log::*, - prost::Message, - rocksdb::{ - self, - compaction_filter::CompactionFilter, - compaction_filter_factory::{CompactionFilterContext, CompactionFilterFactory}, - ColumnFamily, ColumnFamilyDescriptor, CompactionDecision, DBIterator, DBRawIterator, - DBRecoveryMode, IteratorMode as RocksIteratorMode, Options, WriteBatch as RWriteBatch, DB, - }, - serde::{de::DeserializeOwned, Serialize}, - solana_runtime::hardened_unpack::UnpackError, - solana_sdk::{ - clock::{Slot, UnixTimestamp}, - pubkey::Pubkey, - signature::Signature, - }, - solana_storage_proto::convert::generated, - std::{ - collections::{HashMap, HashSet}, - ffi::{CStr, CString}, - fs, - marker::PhantomData, - path::Path, - sync::{ - atomic::{AtomicU64, Ordering}, - Arc, - }, - }, - thiserror::Error, +use rocksdb::{ + self, + compaction_filter::CompactionFilter, + compaction_filter_factory::{CompactionFilterContext, CompactionFilterFactory}, + ColumnFamily, ColumnFamilyDescriptor, CompactionDecision, DBIterator, DBRawIterator, + DBRecoveryMode, IteratorMode as RocksIteratorMode, Options, WriteBatch as RWriteBatch, DB, }; +use serde::de::DeserializeOwned; +use serde::Serialize; +use solana_runtime::hardened_unpack::UnpackError; +use solana_sdk::{ + clock::{Slot, UnixTimestamp}, + pubkey::Pubkey, + signature::Signature, +}; +use solana_storage_proto::convert::generated; +use std::{ + collections::{HashMap, HashSet}, + ffi::{CStr, CString}, + fs, + marker::PhantomData, + path::Path, + sync::{ + atomic::{AtomicU64, Ordering}, + Arc, + }, +}; +use thiserror::Error; + const MAX_WRITE_BUFFER_SIZE: u64 = 256 * 1024 * 1024; // 256MB // Column family for metadata about a leader slot @@ -1430,7 +1430,8 @@ fn excludes_from_compaction(cf_name: &str) -> bool { #[cfg(test)] pub mod tests { - use {super::*, crate::blockstore_db::columns::ShredData}; + use super::*; + use crate::blockstore_db::columns::ShredData; #[test] fn test_compaction_filter() { diff --git a/ledger/src/blockstore_meta.rs b/ledger/src/blockstore_meta.rs index 0d5399fcc4..a0a41fcb59 100644 --- a/ledger/src/blockstore_meta.rs +++ b/ledger/src/blockstore_meta.rs @@ -1,9 +1,7 @@ -use { - crate::erasure::ErasureConfig, - serde::{Deserialize, Serialize}, - solana_sdk::{clock::Slot, hash::Hash}, - std::{collections::BTreeSet, ops::RangeBounds}, -}; +use crate::erasure::ErasureConfig; +use serde::{Deserialize, Serialize}; +use solana_sdk::{clock::Slot, hash::Hash}; +use std::{collections::BTreeSet, ops::RangeBounds}; #[derive(Clone, Debug, Default, Deserialize, Serialize, Eq, PartialEq)] // The Meta column family @@ -289,11 +287,9 @@ pub struct ProgramCost { #[cfg(test)] mod test { - use { - super::*, - rand::{seq::SliceRandom, thread_rng}, - std::iter::repeat, - }; + use super::*; + use rand::{seq::SliceRandom, thread_rng}; + use std::iter::repeat; #[test] fn test_erasure_meta_status() { diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 10c0a07b6e..a50ba8e1aa 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -1,63 +1,60 @@ -use { - crate::{ - block_error::BlockError, - blockstore::Blockstore, - blockstore_db::BlockstoreError, - blockstore_meta::SlotMeta, - entry::{ - create_ticks, Entry, EntrySlice, EntryType, EntryVerificationStatus, VerifyRecyclers, - }, - leader_schedule_cache::LeaderScheduleCache, - }, - chrono_humanize::{Accuracy, HumanTime, Tense}, - crossbeam_channel::Sender, - itertools::Itertools, - log::*, - rand::{seq::SliceRandom, thread_rng}, - rayon::{prelude::*, ThreadPool}, - solana_measure::measure::Measure, - solana_metrics::{datapoint_error, inc_new_counter_debug}, - solana_rayon_threadlimit::get_thread_count, - solana_runtime::{ - accounts_db::AccountShrinkThreshold, - accounts_index::AccountSecondaryIndexes, - accounts_update_notifier_interface::AccountsUpdateNotifier, - bank::{ - Bank, ExecuteTimings, InnerInstructionsList, RentDebits, TransactionBalancesSet, - TransactionExecutionResult, TransactionLogMessages, TransactionResults, - }, - bank_forks::BankForks, - bank_utils, - block_cost_limits::*, - commitment::VOTE_THRESHOLD_SIZE, - snapshot_utils::BankFromArchiveTimings, - transaction_batch::TransactionBatch, - vote_account::ArcVoteAccount, - vote_sender_types::ReplayVoteSender, - }, - solana_sdk::{ - clock::{Slot, MAX_PROCESSING_AGE}, - feature_set, - genesis_config::GenesisConfig, - hash::Hash, - pubkey::Pubkey, - signature::{Keypair, Signature}, - timing, - transaction::{Result, Transaction, TransactionError}, - }, - solana_transaction_status::token_balances::{ - collect_token_balances, TransactionTokenBalancesSet, - }, - std::{ - cell::RefCell, - collections::{HashMap, HashSet}, - path::PathBuf, - result, - sync::{Arc, RwLock}, - time::{Duration, Instant}, - }, - thiserror::Error, +use crate::{ + block_error::BlockError, + blockstore::Blockstore, + blockstore_db::BlockstoreError, + blockstore_meta::SlotMeta, + entry::{create_ticks, Entry, EntrySlice, EntryType, EntryVerificationStatus, VerifyRecyclers}, + leader_schedule_cache::LeaderScheduleCache, }; +use chrono_humanize::{Accuracy, HumanTime, Tense}; +use crossbeam_channel::Sender; +use itertools::Itertools; +use log::*; +use rand::{seq::SliceRandom, thread_rng}; +use rayon::{prelude::*, ThreadPool}; +use solana_measure::measure::Measure; +use solana_metrics::{datapoint_error, inc_new_counter_debug}; +use solana_rayon_threadlimit::get_thread_count; +use solana_runtime::{ + accounts_db::AccountShrinkThreshold, + accounts_index::AccountSecondaryIndexes, + accounts_update_notifier_interface::AccountsUpdateNotifier, + bank::{ + Bank, ExecuteTimings, InnerInstructionsList, RentDebits, TransactionBalancesSet, + TransactionExecutionResult, TransactionLogMessages, TransactionResults, + }, + bank_forks::BankForks, + bank_utils, + block_cost_limits::*, + commitment::VOTE_THRESHOLD_SIZE, + snapshot_utils::BankFromArchiveTimings, + transaction_batch::TransactionBatch, + vote_account::ArcVoteAccount, + vote_sender_types::ReplayVoteSender, +}; +use solana_sdk::{ + clock::{Slot, MAX_PROCESSING_AGE}, + feature_set, + genesis_config::GenesisConfig, + hash::Hash, + pubkey::Pubkey, + signature::{Keypair, Signature}, + timing, + transaction::{Result, Transaction, TransactionError}, +}; +use solana_transaction_status::token_balances::{ + collect_token_balances, TransactionTokenBalancesSet, +}; + +use std::{ + cell::RefCell, + collections::{HashMap, HashSet}, + path::PathBuf, + result, + sync::{Arc, RwLock}, + time::{Duration, Instant}, +}; +use thiserror::Error; // it tracks the block cost available capacity - number of compute-units allowed // by max blockl cost limit @@ -1385,38 +1382,36 @@ pub fn fill_blockstore_slot_with_ticks( #[cfg(test)] pub mod tests { - use { - super::*, - crate::{ - entry::{create_ticks, next_entry, next_entry_mut}, - genesis_utils::{ - create_genesis_config, create_genesis_config_with_leader, GenesisConfigInfo, - }, + use super::*; + use crate::{ + entry::{create_ticks, next_entry, next_entry_mut}, + genesis_utils::{ + create_genesis_config, create_genesis_config_with_leader, GenesisConfigInfo, }, - crossbeam_channel::unbounded, - matches::assert_matches, - rand::{thread_rng, Rng}, - solana_runtime::genesis_utils::{ - self, create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs, - }, - solana_sdk::{ - account::{AccountSharedData, WritableAccount}, - epoch_schedule::EpochSchedule, - hash::Hash, - pubkey::Pubkey, - signature::{Keypair, Signer}, - system_instruction::SystemError, - system_transaction, - transaction::{Transaction, TransactionError}, - }, - solana_vote_program::{ - self, - vote_state::{VoteState, VoteStateVersions, MAX_LOCKOUT_HISTORY}, - vote_transaction, - }, - std::{collections::BTreeSet, sync::RwLock}, - trees::tr, }; + use crossbeam_channel::unbounded; + use matches::assert_matches; + use rand::{thread_rng, Rng}; + use solana_runtime::genesis_utils::{ + self, create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs, + }; + use solana_sdk::{ + account::{AccountSharedData, WritableAccount}, + epoch_schedule::EpochSchedule, + hash::Hash, + pubkey::Pubkey, + signature::{Keypair, Signer}, + system_instruction::SystemError, + system_transaction, + transaction::{Transaction, TransactionError}, + }; + use solana_vote_program::{ + self, + vote_state::{VoteState, VoteStateVersions, MAX_LOCKOUT_HISTORY}, + vote_transaction, + }; + use std::{collections::BTreeSet, sync::RwLock}; + use trees::tr; #[test] fn test_process_blockstore_with_missing_hashes() { diff --git a/ledger/src/builtins.rs b/ledger/src/builtins.rs index da4f6d4974..6896ccfa39 100644 --- a/ledger/src/builtins.rs +++ b/ledger/src/builtins.rs @@ -1,10 +1,8 @@ -use { - solana_runtime::{ - bank::{Builtin, Builtins}, - builtins::ActivationType, - }, - solana_sdk::{feature_set, pubkey::Pubkey}, +use solana_runtime::{ + bank::{Builtin, Builtins}, + builtins::ActivationType, }; +use solana_sdk::{feature_set, pubkey::Pubkey}; macro_rules! to_builtin { ($b:expr) => { diff --git a/ledger/src/entry.rs b/ledger/src/entry.rs index 272262f571..8330ea73f2 100644 --- a/ledger/src/entry.rs +++ b/ledger/src/entry.rs @@ -2,40 +2,36 @@ //! unique ID that is the hash of the Entry before it, plus the hash of the //! transactions within it. Entries cannot be reordered, and its field `num_hashes` //! represents an approximate amount of time since the last Entry was created. -use { - crate::poh::Poh, - dlopen::symbor::{Container, SymBorApi, Symbol}, - dlopen_derive::SymBorApi, - log::*, - rand::{thread_rng, Rng}, - rayon::{prelude::*, ThreadPool}, - serde::{Deserialize, Serialize}, - solana_measure::measure::Measure, - solana_merkle_tree::MerkleTree, - solana_metrics::*, - solana_perf::{cuda_runtime::PinnedVec, perf_libs, recycler::Recycler}, - solana_rayon_threadlimit::get_thread_count, - solana_runtime::hashed_transaction::HashedTransaction, - solana_sdk::{ - feature_set::{self, FeatureSet}, - hash::Hash, - packet::PACKET_DATA_SIZE, - timing, - transaction::Transaction, - }, - std::{ - borrow::Cow, - cell::RefCell, - cmp, - ffi::OsStr, - sync::{ - mpsc::{Receiver, Sender}, - Arc, Mutex, Once, - }, - thread::{self, JoinHandle}, - time::Instant, - }, -}; +use crate::poh::Poh; +use dlopen::symbor::{Container, SymBorApi, Symbol}; +use dlopen_derive::SymBorApi; +use log::*; +use rand::{thread_rng, Rng}; +use rayon::prelude::*; +use rayon::ThreadPool; +use serde::{Deserialize, Serialize}; +use solana_measure::measure::Measure; +use solana_merkle_tree::MerkleTree; +use solana_metrics::*; +use solana_perf::cuda_runtime::PinnedVec; +use solana_perf::perf_libs; +use solana_perf::recycler::Recycler; +use solana_rayon_threadlimit::get_thread_count; +use solana_runtime::hashed_transaction::HashedTransaction; +use solana_sdk::hash::Hash; +use solana_sdk::packet::PACKET_DATA_SIZE; +use solana_sdk::timing; +use solana_sdk::transaction::Transaction; +use solana_sdk::{feature_set, feature_set::FeatureSet}; +use std::borrow::Cow; +use std::cell::RefCell; +use std::ffi::OsStr; +use std::sync::mpsc::{Receiver, Sender}; +use std::sync::Once; +use std::sync::{Arc, Mutex}; +use std::thread::JoinHandle; +use std::time::Instant; +use std::{cmp, thread}; thread_local!(static PAR_THREAD_POOL: RefCell = RefCell::new(rayon::ThreadPoolBuilder::new() .num_threads(get_thread_count()) @@ -733,18 +729,16 @@ pub fn next_entry(prev_hash: &Hash, num_hashes: u64, transactions: Vec for LeaderSchedule { #[cfg(test)] mod tests { - use {super::*, rand::Rng, std::iter::repeat_with}; + use super::*; + use rand::Rng; + use std::iter::repeat_with; #[test] fn test_leader_schedule_index() { diff --git a/ledger/src/leader_schedule_cache.rs b/ledger/src/leader_schedule_cache.rs index 5b94978e47..3f44c84324 100644 --- a/ledger/src/leader_schedule_cache.rs +++ b/ledger/src/leader_schedule_cache.rs @@ -1,21 +1,19 @@ -use { - crate::{ - blockstore::Blockstore, - leader_schedule::{FixedSchedule, LeaderSchedule}, - leader_schedule_utils, - }, - itertools::Itertools, - log::*, - solana_runtime::bank::Bank, - solana_sdk::{ - clock::{Epoch, Slot}, - epoch_schedule::EpochSchedule, - pubkey::Pubkey, - }, - std::{ - collections::{hash_map::Entry, HashMap, VecDeque}, - sync::{Arc, RwLock}, - }, +use crate::{ + blockstore::Blockstore, + leader_schedule::{FixedSchedule, LeaderSchedule}, + leader_schedule_utils, +}; +use itertools::Itertools; +use log::*; +use solana_runtime::bank::Bank; +use solana_sdk::{ + clock::{Epoch, Slot}, + epoch_schedule::EpochSchedule, + pubkey::Pubkey, +}; +use std::{ + collections::{hash_map::Entry, HashMap, VecDeque}, + sync::{Arc, RwLock}, }; type CachedSchedules = (HashMap>, VecDeque); @@ -250,31 +248,24 @@ impl LeaderScheduleCache { #[cfg(test)] mod tests { - use { - super::*, - crate::{ - blockstore::make_slot_entries, - genesis_utils::{ - bootstrap_validator_stake_lamports, create_genesis_config, - create_genesis_config_with_leader, GenesisConfigInfo, - }, - get_tmp_ledger_path, - staking_utils::tests::setup_vote_and_stake_accounts, - }, - solana_runtime::bank::Bank, - solana_sdk::{ - clock::NUM_CONSECUTIVE_LEADER_SLOTS, - epoch_schedule::{ - EpochSchedule, DEFAULT_LEADER_SCHEDULE_SLOT_OFFSET, DEFAULT_SLOTS_PER_EPOCH, - MINIMUM_SLOTS_PER_EPOCH, - }, - signature::{Keypair, Signer}, - }, - std::{ - sync::{mpsc::channel, Arc}, - thread::Builder, + use super::*; + use crate::{ + blockstore::make_slot_entries, + genesis_utils::{ + bootstrap_validator_stake_lamports, create_genesis_config, + create_genesis_config_with_leader, GenesisConfigInfo, }, + get_tmp_ledger_path, + staking_utils::tests::setup_vote_and_stake_accounts, }; + use solana_runtime::bank::Bank; + use solana_sdk::clock::NUM_CONSECUTIVE_LEADER_SLOTS; + use solana_sdk::epoch_schedule::{ + EpochSchedule, DEFAULT_LEADER_SCHEDULE_SLOT_OFFSET, DEFAULT_SLOTS_PER_EPOCH, + MINIMUM_SLOTS_PER_EPOCH, + }; + use solana_sdk::signature::{Keypair, Signer}; + use std::{sync::mpsc::channel, sync::Arc, thread::Builder}; #[test] fn test_new_cache() { diff --git a/ledger/src/leader_schedule_utils.rs b/ledger/src/leader_schedule_utils.rs index 0217b11cd3..ea21a79b73 100644 --- a/ledger/src/leader_schedule_utils.rs +++ b/ledger/src/leader_schedule_utils.rs @@ -1,11 +1,10 @@ -use { - crate::leader_schedule::LeaderSchedule, - solana_runtime::bank::Bank, - solana_sdk::{ - clock::{Epoch, Slot, NUM_CONSECUTIVE_LEADER_SLOTS}, - pubkey::Pubkey, - }, - std::collections::HashMap, +use std::collections::HashMap; + +use crate::leader_schedule::LeaderSchedule; +use solana_runtime::bank::Bank; +use solana_sdk::{ + clock::{Epoch, Slot, NUM_CONSECUTIVE_LEADER_SLOTS}, + pubkey::Pubkey, }; /// Return the leader schedule for the given epoch. @@ -76,11 +75,9 @@ fn sort_stakes(stakes: &mut Vec<(Pubkey, u64)>) { #[cfg(test)] mod tests { - use { - super::*, - solana_runtime::genesis_utils::{ - bootstrap_validator_stake_lamports, create_genesis_config_with_leader, - }, + use super::*; + use solana_runtime::genesis_utils::{ + bootstrap_validator_stake_lamports, create_genesis_config_with_leader, }; #[test] diff --git a/ledger/src/next_slots_iterator.rs b/ledger/src/next_slots_iterator.rs index ff2e8d6716..f3c67a6cf0 100644 --- a/ledger/src/next_slots_iterator.rs +++ b/ledger/src/next_slots_iterator.rs @@ -1,7 +1,5 @@ -use { - crate::{blockstore::*, blockstore_meta::SlotMeta}, - solana_sdk::clock::Slot, -}; +use crate::{blockstore::*, blockstore_meta::SlotMeta}; +use solana_sdk::clock::Slot; pub struct NextSlotsIterator<'a> { pending_slots: Vec, @@ -36,10 +34,10 @@ impl<'a> Iterator for NextSlotsIterator<'a> { #[cfg(test)] mod tests { - use { - super::*, crate::blockstore_processor::fill_blockstore_slot_with_ticks, - solana_sdk::hash::Hash, std::collections::HashSet, - }; + use super::*; + use crate::blockstore_processor::fill_blockstore_slot_with_ticks; + use solana_sdk::hash::Hash; + use std::collections::HashSet; #[test] fn test_next_slots_iterator() { diff --git a/ledger/src/poh.rs b/ledger/src/poh.rs index 28126276f3..23521c9759 100644 --- a/ledger/src/poh.rs +++ b/ledger/src/poh.rs @@ -1,9 +1,7 @@ //! The `Poh` module provides an object for generating a Proof of History. -use { - log::*, - solana_sdk::hash::{hash, hashv, Hash}, - std::time::{Duration, Instant}, -}; +use log::*; +use solana_sdk::hash::{hash, hashv, Hash}; +use std::time::{Duration, Instant}; pub struct Poh { pub hash: Hash, @@ -129,12 +127,10 @@ pub fn compute_hashes_per_tick(duration: Duration, hashes_sample_size: u64) -> u #[cfg(test)] mod tests { - use { - crate::poh::{Poh, PohEntry}, - matches::assert_matches, - solana_sdk::hash::{hash, hashv, Hash}, - std::time::Duration, - }; + use crate::poh::{Poh, PohEntry}; + use matches::assert_matches; + use solana_sdk::hash::{hash, hashv, Hash}; + use std::time::Duration; fn verify(initial_hash: Hash, entries: &[(PohEntry, Option)]) -> bool { let mut current_hash = initial_hash; diff --git a/ledger/src/rooted_slot_iterator.rs b/ledger/src/rooted_slot_iterator.rs index 16894660c9..cdc6f1c46e 100644 --- a/ledger/src/rooted_slot_iterator.rs +++ b/ledger/src/rooted_slot_iterator.rs @@ -1,8 +1,7 @@ -use { - crate::{blockstore::*, blockstore_db::Result, blockstore_meta::SlotMeta}, - log::*, - solana_sdk::clock::Slot, -}; +use crate::blockstore_db::Result; +use crate::{blockstore::*, blockstore_meta::SlotMeta}; +use log::*; +use solana_sdk::clock::Slot; pub struct RootedSlotIterator<'a> { next_slots: Vec, @@ -77,10 +76,9 @@ impl<'a> Iterator for RootedSlotIterator<'a> { #[cfg(test)] mod tests { - use { - super::*, crate::blockstore_processor::fill_blockstore_slot_with_ticks, - solana_sdk::hash::Hash, - }; + use super::*; + use crate::blockstore_processor::fill_blockstore_slot_with_ticks; + use solana_sdk::hash::Hash; #[test] fn test_rooted_slot_iterator() { diff --git a/ledger/src/shred.rs b/ledger/src/shred.rs index f922a18631..b0520e2440 100644 --- a/ledger/src/shred.rs +++ b/ledger/src/shred.rs @@ -70,7 +70,8 @@ use { solana_sdk::{ clock::Slot, feature_set, - hash::{hashv, Hash}, + hash::hashv, + hash::Hash, packet::PACKET_DATA_SIZE, pubkey::Pubkey, signature::{Keypair, Signature, Signer}, @@ -1126,17 +1127,15 @@ pub fn verify_test_data_shred( #[cfg(test)] pub mod tests { - use { - super::*, - bincode::serialized_size, - matches::assert_matches, - rand::{seq::SliceRandom, Rng}, - solana_sdk::{ - hash::{self, hash}, - shred_version, system_transaction, - }, - std::{collections::HashSet, convert::TryInto, iter::repeat_with}, + use super::*; + use bincode::serialized_size; + use matches::assert_matches; + use rand::{seq::SliceRandom, Rng}; + use solana_sdk::{ + hash::{self, hash}, + shred_version, system_transaction, }; + use std::{collections::HashSet, convert::TryInto, iter::repeat_with}; #[test] fn test_shred_constants() { diff --git a/ledger/src/sigverify_shreds.rs b/ledger/src/sigverify_shreds.rs index 279d54e903..42ae66d83d 100644 --- a/ledger/src/sigverify_shreds.rs +++ b/ledger/src/sigverify_shreds.rs @@ -1,30 +1,29 @@ #![allow(clippy::implicit_hasher)] -use { - crate::shred::{ShredType, SIZE_OF_NONCE}, - rayon::{ - iter::{ - IndexedParallelIterator, IntoParallelIterator, IntoParallelRefMutIterator, - ParallelIterator, - }, - ThreadPool, +use crate::shred::{ShredType, SIZE_OF_NONCE}; +use rayon::{ + iter::{ + IndexedParallelIterator, IntoParallelIterator, IntoParallelRefMutIterator, ParallelIterator, }, - sha2::{Digest, Sha512}, - solana_metrics::inc_new_counter_debug, - solana_perf::{ - cuda_runtime::PinnedVec, - packet::{limited_deserialize, Packet, Packets}, - perf_libs, - recycler_cache::RecyclerCache, - sigverify::{self, batch_size, TxOffset}, - }, - solana_rayon_threadlimit::get_thread_count, - solana_sdk::{ - clock::Slot, - pubkey::Pubkey, - signature::{Keypair, Signature, Signer}, - }, - std::{collections::HashMap, mem::size_of, sync::Arc}, + ThreadPool, }; +use sha2::{Digest, Sha512}; +use solana_metrics::inc_new_counter_debug; +use solana_perf::{ + cuda_runtime::PinnedVec, + packet::{limited_deserialize, Packet, Packets}, + perf_libs, + recycler_cache::RecyclerCache, + sigverify::{self, batch_size, TxOffset}, +}; +use solana_rayon_threadlimit::get_thread_count; +use solana_sdk::{ + clock::Slot, + pubkey::Pubkey, + signature::Signature, + signature::{Keypair, Signer}, +}; +use std::sync::Arc; +use std::{collections::HashMap, mem::size_of}; pub const SIGN_SHRED_GPU_MIN: usize = 256; @@ -452,11 +451,9 @@ pub fn sign_shreds_gpu( #[cfg(test)] pub mod tests { - use { - super::*, - crate::shred::{Shred, Shredder, SIZE_OF_DATA_SHRED_PAYLOAD}, - solana_sdk::signature::{Keypair, Signer}, - }; + use super::*; + use crate::shred::{Shred, Shredder, SIZE_OF_DATA_SHRED_PAYLOAD}; + use solana_sdk::signature::{Keypair, Signer}; fn run_test_sigverify_shred_cpu(slot: Slot) { solana_logger::setup(); diff --git a/ledger/src/staking_utils.rs b/ledger/src/staking_utils.rs index 9785fbfa56..3c8df05475 100644 --- a/ledger/src/staking_utils.rs +++ b/ledger/src/staking_utils.rs @@ -1,11 +1,9 @@ -use { - solana_runtime::bank::Bank, - solana_sdk::{ - clock::{Epoch, Slot}, - pubkey::Pubkey, - }, - std::collections::HashMap, +use solana_runtime::bank::Bank; +use solana_sdk::{ + clock::{Epoch, Slot}, + pubkey::Pubkey, }; +use std::collections::HashMap; /// Looks through vote accounts, and finds the latest slot that has achieved /// supermajority lockout @@ -63,33 +61,31 @@ where #[cfg(test)] pub(crate) mod tests { - use { - super::*, - crate::genesis_utils::{ - bootstrap_validator_stake_lamports, create_genesis_config, GenesisConfigInfo, - }, - rand::Rng, - solana_runtime::vote_account::{ArcVoteAccount, VoteAccounts}, - solana_sdk::{ - account::{from_account, AccountSharedData}, - clock::Clock, - instruction::Instruction, - pubkey::Pubkey, - signature::{Keypair, Signer}, - signers::Signers, - stake::{ - instruction as stake_instruction, - state::{Authorized, Delegation, Lockup, Stake}, - }, - sysvar::stake_history::{self, StakeHistory}, - transaction::Transaction, - }, - solana_vote_program::{ - vote_instruction, - vote_state::{VoteInit, VoteState, VoteStateVersions}, - }, - std::sync::Arc, + use super::*; + use crate::genesis_utils::{ + bootstrap_validator_stake_lamports, create_genesis_config, GenesisConfigInfo, }; + use rand::Rng; + use solana_runtime::vote_account::{ArcVoteAccount, VoteAccounts}; + use solana_sdk::{ + account::{from_account, AccountSharedData}, + clock::Clock, + instruction::Instruction, + pubkey::Pubkey, + signature::{Keypair, Signer}, + signers::Signers, + stake::{ + instruction as stake_instruction, + state::{Authorized, Delegation, Lockup, Stake}, + }, + sysvar::stake_history::{self, StakeHistory}, + transaction::Transaction, + }; + use solana_vote_program::{ + vote_instruction, + vote_state::{VoteInit, VoteState, VoteStateVersions}, + }; + use std::sync::Arc; fn new_from_parent(parent: &Arc, slot: Slot) -> Bank { Bank::new_from_parent(parent, &Pubkey::default(), slot) diff --git a/ledger/tests/blockstore.rs b/ledger/tests/blockstore.rs index 2659485dbd..4840b57a16 100644 --- a/ledger/tests/blockstore.rs +++ b/ledger/tests/blockstore.rs @@ -1,11 +1,11 @@ -use { - solana_ledger::{ - blockstore::{self, Blockstore}, - entry, get_tmp_ledger_path, - }, - solana_sdk::hash::Hash, - std::{sync::Arc, thread::Builder}, +use solana_ledger::entry; +use solana_ledger::{ + blockstore::{self, Blockstore}, + get_tmp_ledger_path, }; +use solana_sdk::hash::Hash; +use std::sync::Arc; +use std::thread::Builder; #[test] fn test_multiple_threads_insert_shred() { diff --git a/ledger/tests/shred.rs b/ledger/tests/shred.rs index 905f52e48f..8dc241de38 100644 --- a/ledger/tests/shred.rs +++ b/ledger/tests/shred.rs @@ -1,23 +1,19 @@ #![allow(clippy::integer_arithmetic)] -use { - solana_ledger::{ - entry::Entry, - shred::{ - max_entries_per_n_shred, verify_test_data_shred, Shred, Shredder, - MAX_DATA_SHREDS_PER_FEC_BLOCK, SIZE_OF_DATA_SHRED_PAYLOAD, - }, - }, - solana_sdk::{ - clock::Slot, - hash::Hash, - signature::{Keypair, Signer}, - system_transaction, - }, - std::{ - collections::{BTreeMap, HashSet}, - convert::TryInto, - sync::Arc, - }, +use solana_ledger::entry::Entry; +use solana_ledger::shred::{ + max_entries_per_n_shred, verify_test_data_shred, Shred, Shredder, + MAX_DATA_SHREDS_PER_FEC_BLOCK, SIZE_OF_DATA_SHRED_PAYLOAD, +}; +use solana_sdk::{ + clock::Slot, + hash::Hash, + signature::{Keypair, Signer}, + system_transaction, +}; +use std::{ + collections::{BTreeMap, HashSet}, + convert::TryInto, + sync::Arc, }; type IndexShredsMap = BTreeMap>; diff --git a/local-cluster/src/cluster.rs b/local-cluster/src/cluster.rs index b5bcf658fb..8211041970 100644 --- a/local-cluster/src/cluster.rs +++ b/local-cluster/src/cluster.rs @@ -1,11 +1,12 @@ -use { - solana_client::thin_client::ThinClient, - solana_core::validator::{Validator, ValidatorConfig}, - solana_gossip::{cluster_info::Node, contact_info::ContactInfo}, - solana_sdk::{pubkey::Pubkey, signature::Keypair}, - solana_streamer::socket::SocketAddrSpace, - std::{path::PathBuf, sync::Arc}, -}; +use solana_client::thin_client::ThinClient; +use solana_core::validator::Validator; +use solana_core::validator::ValidatorConfig; +use solana_gossip::{cluster_info::Node, contact_info::ContactInfo}; +use solana_sdk::pubkey::Pubkey; +use solana_sdk::signature::Keypair; +use solana_streamer::socket::SocketAddrSpace; +use std::path::PathBuf; +use std::sync::Arc; pub struct ValidatorInfo { pub keypair: Arc, diff --git a/local-cluster/src/cluster_tests.rs b/local-cluster/src/cluster_tests.rs index 346431fb4a..3e053dd551 100644 --- a/local-cluster/src/cluster_tests.rs +++ b/local-cluster/src/cluster_tests.rs @@ -3,41 +3,38 @@ /// All tests must start from an entry point and a funding keypair and /// discover the rest of the network. use log::*; -use { - rand::{thread_rng, Rng}, - rayon::prelude::*, - solana_client::thin_client::create_client, - solana_core::consensus::VOTE_THRESHOLD_DEPTH, - solana_gossip::{ - cluster_info::VALIDATOR_PORT_RANGE, contact_info::ContactInfo, - gossip_service::discover_cluster, - }, - solana_ledger::{ - blockstore::Blockstore, - entry::{Entry, EntrySlice}, - }, - solana_sdk::{ - client::SyncClient, - clock::{self, Slot, NUM_CONSECUTIVE_LEADER_SLOTS}, - commitment_config::CommitmentConfig, - epoch_schedule::MINIMUM_SLOTS_PER_EPOCH, - exit::Exit, - hash::Hash, - poh_config::PohConfig, - pubkey::Pubkey, - signature::{Keypair, Signature, Signer}, - system_transaction, - timing::duration_as_ms, - transport::TransportError, - }, - solana_streamer::socket::SocketAddrSpace, - std::{ - collections::{HashMap, HashSet}, - path::Path, - sync::{Arc, RwLock}, - thread::sleep, - time::{Duration, Instant}, - }, +use rand::{thread_rng, Rng}; +use rayon::prelude::*; +use solana_client::thin_client::create_client; +use solana_core::consensus::VOTE_THRESHOLD_DEPTH; +use solana_gossip::{ + cluster_info::VALIDATOR_PORT_RANGE, contact_info::ContactInfo, gossip_service::discover_cluster, +}; +use solana_ledger::{ + blockstore::Blockstore, + entry::{Entry, EntrySlice}, +}; +use solana_sdk::{ + client::SyncClient, + clock::{self, Slot, NUM_CONSECUTIVE_LEADER_SLOTS}, + commitment_config::CommitmentConfig, + epoch_schedule::MINIMUM_SLOTS_PER_EPOCH, + exit::Exit, + hash::Hash, + poh_config::PohConfig, + pubkey::Pubkey, + signature::{Keypair, Signature, Signer}, + system_transaction, + timing::duration_as_ms, + transport::TransportError, +}; +use solana_streamer::socket::SocketAddrSpace; +use std::{ + collections::{HashMap, HashSet}, + path::Path, + sync::{Arc, RwLock}, + thread::sleep, + time::{Duration, Instant}, }; /// Spend and verify from every node in the network diff --git a/local-cluster/src/local_cluster.rs b/local-cluster/src/local_cluster.rs index e2cbf273b2..af80e7e510 100644 --- a/local-cluster/src/local_cluster.rs +++ b/local-cluster/src/local_cluster.rs @@ -1,53 +1,52 @@ -use { - crate::{ - cluster::{Cluster, ClusterValidatorInfo, ValidatorInfo}, - cluster_tests, - validator_configs::*, - }, - itertools::izip, - log::*, - solana_client::thin_client::{create_client, ThinClient}, - solana_core::validator::{Validator, ValidatorConfig, ValidatorStartProgress}, - solana_gossip::{ - cluster_info::{Node, VALIDATOR_PORT_RANGE}, - contact_info::ContactInfo, - gossip_service::discover_cluster, - }, - solana_ledger::create_new_tmp_ledger, - solana_runtime::genesis_utils::{ - create_genesis_config_with_vote_accounts_and_cluster_type, GenesisConfigInfo, - ValidatorVoteKeypairs, - }, - solana_sdk::{ - account::{Account, AccountSharedData}, - client::SyncClient, - clock::{DEFAULT_DEV_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT}, - commitment_config::CommitmentConfig, - epoch_schedule::EpochSchedule, - genesis_config::{ClusterType, GenesisConfig}, - message::Message, - poh_config::PohConfig, - pubkey::Pubkey, - signature::{Keypair, Signer}, - stake::{ - config as stake_config, instruction as stake_instruction, - state::{Authorized, Lockup}, - }, - system_transaction, - transaction::Transaction, - }, - solana_stake_program::{config::create_account as create_stake_config_account, stake_state}, - solana_streamer::socket::SocketAddrSpace, - solana_vote_program::{ - vote_instruction, - vote_state::{VoteInit, VoteState}, - }, - std::{ - collections::HashMap, - io::{Error, ErrorKind, Result}, - iter, - sync::{Arc, RwLock}, +use crate::{ + cluster::{Cluster, ClusterValidatorInfo, ValidatorInfo}, + cluster_tests, + validator_configs::*, +}; +use itertools::izip; +use log::*; +use solana_client::thin_client::{create_client, ThinClient}; +use solana_core::validator::{Validator, ValidatorConfig, ValidatorStartProgress}; +use solana_gossip::{ + cluster_info::{Node, VALIDATOR_PORT_RANGE}, + contact_info::ContactInfo, + gossip_service::discover_cluster, +}; +use solana_ledger::create_new_tmp_ledger; +use solana_runtime::genesis_utils::{ + create_genesis_config_with_vote_accounts_and_cluster_type, GenesisConfigInfo, + ValidatorVoteKeypairs, +}; +use solana_sdk::{ + account::Account, + account::AccountSharedData, + client::SyncClient, + clock::{DEFAULT_DEV_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT}, + commitment_config::CommitmentConfig, + epoch_schedule::EpochSchedule, + genesis_config::{ClusterType, GenesisConfig}, + message::Message, + poh_config::PohConfig, + pubkey::Pubkey, + signature::{Keypair, Signer}, + stake::{ + config as stake_config, instruction as stake_instruction, + state::{Authorized, Lockup}, }, + system_transaction, + transaction::Transaction, +}; +use solana_stake_program::{config::create_account as create_stake_config_account, stake_state}; +use solana_streamer::socket::SocketAddrSpace; +use solana_vote_program::{ + vote_instruction, + vote_state::{VoteInit, VoteState}, +}; +use std::{ + collections::HashMap, + io::{Error, ErrorKind, Result}, + iter, + sync::{Arc, RwLock}, }; #[derive(Debug)] @@ -747,7 +746,8 @@ impl Drop for LocalCluster { #[cfg(test)] mod test { - use {super::*, solana_sdk::epoch_schedule::MINIMUM_SLOTS_PER_EPOCH}; + use super::*; + use solana_sdk::epoch_schedule::MINIMUM_SLOTS_PER_EPOCH; #[test] fn test_local_cluster_start_and_exit() { diff --git a/local-cluster/src/validator_configs.rs b/local-cluster/src/validator_configs.rs index 1eecd8c5a8..df943536d6 100644 --- a/local-cluster/src/validator_configs.rs +++ b/local-cluster/src/validator_configs.rs @@ -1,8 +1,6 @@ -use { - solana_core::validator::ValidatorConfig, - solana_sdk::exit::Exit, - std::sync::{Arc, RwLock}, -}; +use solana_core::validator::ValidatorConfig; +use solana_sdk::exit::Exit; +use std::sync::{Arc, RwLock}; pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig { ValidatorConfig { diff --git a/local-cluster/tests/local_cluster.rs b/local-cluster/tests/local_cluster.rs index 2edfb24335..7d34374a72 100644 --- a/local-cluster/tests/local_cluster.rs +++ b/local-cluster/tests/local_cluster.rs @@ -1,80 +1,77 @@ #![allow(clippy::integer_arithmetic)] -use { - assert_matches::assert_matches, - crossbeam_channel::{unbounded, Receiver}, - gag::BufferRedirect, - log::*, - serial_test::serial, - solana_client::{ - pubsub_client::PubsubClient, - rpc_client::RpcClient, - rpc_config::{RpcProgramAccountsConfig, RpcSignatureSubscribeConfig}, - rpc_response::RpcSignatureResult, - thin_client::{create_client, ThinClient}, - }, - solana_core::{ - broadcast_stage::{BroadcastDuplicatesConfig, BroadcastStageType}, - consensus::{Tower, SWITCH_FORK_THRESHOLD, VOTE_THRESHOLD_DEPTH}, - optimistic_confirmation_verifier::OptimisticConfirmationVerifier, - validator::ValidatorConfig, - }, - solana_download_utils::download_snapshot, - solana_gossip::{ - cluster_info::{self, VALIDATOR_PORT_RANGE}, - crds_value::{self, CrdsData, CrdsValue}, - gossip_service::discover_cluster, - }, - solana_ledger::{ - ancestor_iterator::AncestorIterator, - blockstore::{Blockstore, PurgeType}, - blockstore_db::AccessType, - leader_schedule::{FixedSchedule, LeaderSchedule}, - }, - solana_local_cluster::{ - cluster::{Cluster, ClusterValidatorInfo}, - cluster_tests, - local_cluster::{ClusterConfig, LocalCluster}, - validator_configs::*, - }, - solana_runtime::{ - bank_forks::{ArchiveFormat, SnapshotConfig}, - snapshot_utils, - }, - solana_sdk::{ - account::AccountSharedData, - client::{AsyncClient, SyncClient}, - clock::{self, Slot, DEFAULT_MS_PER_SLOT, DEFAULT_TICKS_PER_SLOT, MAX_RECENT_BLOCKHASHES}, - commitment_config::CommitmentConfig, - epoch_schedule::MINIMUM_SLOTS_PER_EPOCH, - genesis_config::ClusterType, - hash::Hash, - poh_config::PohConfig, - pubkey::Pubkey, - signature::{Keypair, Signer}, - system_program, system_transaction, - timing::timestamp, - transaction::Transaction, - }, - solana_streamer::socket::SocketAddrSpace, - solana_vote_program::{ - vote_instruction, - vote_state::{Vote, MAX_LOCKOUT_HISTORY}, - }, - std::{ - collections::{BTreeSet, HashMap, HashSet}, - fs, - io::Read, - iter, - path::{Path, PathBuf}, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - thread::{sleep, Builder, JoinHandle}, - time::{Duration, Instant}, - }, - tempfile::TempDir, +use assert_matches::assert_matches; +use crossbeam_channel::{unbounded, Receiver}; +use gag::BufferRedirect; +use log::*; +use serial_test::serial; +use solana_client::{ + pubsub_client::PubsubClient, + rpc_client::RpcClient, + rpc_config::{RpcProgramAccountsConfig, RpcSignatureSubscribeConfig}, + rpc_response::RpcSignatureResult, + thin_client::{create_client, ThinClient}, }; +use solana_core::{ + broadcast_stage::{BroadcastDuplicatesConfig, BroadcastStageType}, + consensus::{Tower, SWITCH_FORK_THRESHOLD, VOTE_THRESHOLD_DEPTH}, + optimistic_confirmation_verifier::OptimisticConfirmationVerifier, + validator::ValidatorConfig, +}; +use solana_download_utils::download_snapshot; +use solana_gossip::{ + cluster_info::{self, VALIDATOR_PORT_RANGE}, + crds_value::{self, CrdsData, CrdsValue}, + gossip_service::discover_cluster, +}; +use solana_ledger::{ + ancestor_iterator::AncestorIterator, + blockstore::{Blockstore, PurgeType}, + blockstore_db::AccessType, + leader_schedule::FixedSchedule, + leader_schedule::LeaderSchedule, +}; +use solana_local_cluster::{ + cluster::{Cluster, ClusterValidatorInfo}, + cluster_tests, + local_cluster::{ClusterConfig, LocalCluster}, + validator_configs::*, +}; +use solana_runtime::{ + bank_forks::{ArchiveFormat, SnapshotConfig}, + snapshot_utils, +}; +use solana_sdk::{ + account::AccountSharedData, + client::{AsyncClient, SyncClient}, + clock::{self, Slot, DEFAULT_MS_PER_SLOT, DEFAULT_TICKS_PER_SLOT, MAX_RECENT_BLOCKHASHES}, + commitment_config::CommitmentConfig, + epoch_schedule::MINIMUM_SLOTS_PER_EPOCH, + genesis_config::ClusterType, + hash::Hash, + poh_config::PohConfig, + pubkey::Pubkey, + signature::{Keypair, Signer}, + system_program, system_transaction, + timing::timestamp, + transaction::Transaction, +}; +use solana_streamer::socket::SocketAddrSpace; +use solana_vote_program::{ + vote_instruction, + vote_state::{Vote, MAX_LOCKOUT_HISTORY}, +}; +use std::{ + collections::{BTreeSet, HashMap, HashSet}, + fs, + io::Read, + iter, + path::{Path, PathBuf}, + sync::atomic::{AtomicBool, Ordering}, + sync::Arc, + thread::{sleep, Builder, JoinHandle}, + time::{Duration, Instant}, +}; +use tempfile::TempDir; const RUST_LOG_FILTER: &str = "error,solana_core::replay_stage=warn,solana_local_cluster=info,local_cluster=info"; diff --git a/log-analyzer/src/main.rs b/log-analyzer/src/main.rs index 7f5812def7..a8eaf41bc5 100644 --- a/log-analyzer/src/main.rs +++ b/log-analyzer/src/main.rs @@ -1,12 +1,14 @@ #![allow(clippy::integer_arithmetic)] extern crate byte_unit; -use { - byte_unit::Byte, - clap::{crate_description, crate_name, value_t_or_exit, App, Arg, ArgMatches, SubCommand}, - serde::{Deserialize, Serialize}, - std::{collections::HashMap, fs, ops::Sub, path::PathBuf}, -}; +use byte_unit::Byte; +use clap::{crate_description, crate_name, value_t_or_exit, App, Arg, ArgMatches, SubCommand}; + +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use std::fs; +use std::ops::Sub; +use std::path::PathBuf; #[derive(Deserialize, Serialize, Debug)] struct IpAddrMapping { diff --git a/logger/src/lib.rs b/logger/src/lib.rs index cf032bb869..2e044a01ce 100644 --- a/logger/src/lib.rs +++ b/logger/src/lib.rs @@ -1,9 +1,7 @@ //! The `logger` module configures `env_logger` -use { - lazy_static::lazy_static, - std::sync::{Arc, RwLock}, -}; +use lazy_static::lazy_static; +use std::sync::{Arc, RwLock}; lazy_static! { static ref LOGGER: Arc> = diff --git a/measure/src/measure.rs b/measure/src/measure.rs index 92090dc73e..26f32b097c 100644 --- a/measure/src/measure.rs +++ b/measure/src/measure.rs @@ -1,7 +1,5 @@ -use { - solana_sdk::timing::duration_as_ns, - std::{fmt, time::Instant}, -}; +use solana_sdk::timing::duration_as_ns; +use std::{fmt, time::Instant}; pub struct Measure { name: &'static str, @@ -92,10 +90,9 @@ impl fmt::Display for Measure { #[cfg(test)] mod tests { - use { - super::*, - std::{thread::sleep, time::Duration}, - }; + use super::*; + use std::thread::sleep; + use std::time::Duration; #[test] fn test_measure() { diff --git a/merkle-root-bench/src/main.rs b/merkle-root-bench/src/main.rs index 26b4d8ffc3..76ec3388dc 100644 --- a/merkle-root-bench/src/main.rs +++ b/merkle-root-bench/src/main.rs @@ -1,10 +1,8 @@ extern crate log; -use { - clap::{crate_description, crate_name, value_t, App, Arg}, - solana_measure::measure::Measure, - solana_runtime::accounts_hash::AccountsHash, - solana_sdk::{hash::Hash, pubkey::Pubkey}, -}; +use clap::{crate_description, crate_name, value_t, App, Arg}; +use solana_measure::measure::Measure; +use solana_runtime::accounts_hash::AccountsHash; +use solana_sdk::{hash::Hash, pubkey::Pubkey}; fn main() { solana_logger::setup(); diff --git a/metrics/src/counter.rs b/metrics/src/counter.rs index eb33c25a29..265cb636f9 100644 --- a/metrics/src/counter.rs +++ b/metrics/src/counter.rs @@ -211,15 +211,13 @@ impl Counter { } #[cfg(test)] mod tests { - use { - crate::counter::{Counter, DEFAULT_LOG_RATE, DEFAULT_METRICS_RATE}, - log::{Level, *}, - serial_test::serial, - std::{ - env, - sync::{atomic::Ordering, Once, RwLock}, - }, - }; + use crate::counter::{Counter, DEFAULT_LOG_RATE, DEFAULT_METRICS_RATE}; + use log::Level; + use log::*; + use serial_test::serial; + use std::env; + use std::sync::atomic::Ordering; + use std::sync::{Once, RwLock}; fn get_env_lock() -> &'static RwLock<()> { static mut ENV_LOCK: Option> = None; diff --git a/metrics/src/lib.rs b/metrics/src/lib.rs index 7f5121317a..01c03a4269 100644 --- a/metrics/src/lib.rs +++ b/metrics/src/lib.rs @@ -3,6 +3,7 @@ pub mod counter; pub mod datapoint; mod metrics; pub use crate::metrics::{flush, query, set_host_id, set_panic_hook, submit}; + use std::sync::Arc; /// A helper that sends the count of created tokens as a datapoint. diff --git a/net-shaper/src/main.rs b/net-shaper/src/main.rs index a8c84a3f57..ba45148f01 100644 --- a/net-shaper/src/main.rs +++ b/net-shaper/src/main.rs @@ -1,14 +1,14 @@ #![allow(clippy::integer_arithmetic)] -use { - clap::{ - crate_description, crate_name, crate_version, value_t, value_t_or_exit, App, Arg, - ArgMatches, SubCommand, - }, - rand::{thread_rng, Rng}, - serde::{Deserialize, Serialize}, - std::{fs, io, path::PathBuf}, +use clap::{ + crate_description, crate_name, crate_version, value_t, value_t_or_exit, App, Arg, ArgMatches, + SubCommand, }; +use rand::{thread_rng, Rng}; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; +use std::{fs, io}; + #[derive(Deserialize, Serialize, Debug)] struct NetworkInterconnect { pub a: u8, diff --git a/net-utils/src/bin/ip_address_server.rs b/net-utils/src/bin/ip_address_server.rs index 4598d248bd..dbf55f8edb 100644 --- a/net-utils/src/bin/ip_address_server.rs +++ b/net-utils/src/bin/ip_address_server.rs @@ -1,7 +1,5 @@ -use { - clap::{App, Arg}, - std::net::{SocketAddr, TcpListener}, -}; +use clap::{App, Arg}; +use std::net::{SocketAddr, TcpListener}; fn main() { solana_logger::setup(); diff --git a/net-utils/src/lib.rs b/net-utils/src/lib.rs index 6cf7439562..55d702baeb 100644 --- a/net-utils/src/lib.rs +++ b/net-utils/src/lib.rs @@ -380,13 +380,9 @@ fn udp_socket(_reuseaddr: bool) -> io::Result { #[cfg(not(windows))] fn udp_socket(reuseaddr: bool) -> io::Result { - use { - nix::sys::socket::{ - setsockopt, - sockopt::{ReuseAddr, ReusePort}, - }, - std::os::unix::io::AsRawFd, - }; + use nix::sys::socket::setsockopt; + use nix::sys::socket::sockopt::{ReuseAddr, ReusePort}; + use std::os::unix::io::AsRawFd; let sock = Socket::new(Domain::ipv4(), Type::dgram(), None)?; let sock_fd = sock.as_raw_fd(); @@ -529,7 +525,8 @@ pub fn find_available_port_in_range(ip_addr: IpAddr, range: PortRange) -> io::Re #[cfg(test)] mod tests { - use {super::*, std::net::Ipv4Addr}; + use super::*; + use std::net::Ipv4Addr; #[test] fn test_response_length() { diff --git a/notifier/src/lib.rs b/notifier/src/lib.rs index 274befa89b..0bb3b0798c 100644 --- a/notifier/src/lib.rs +++ b/notifier/src/lib.rs @@ -18,11 +18,9 @@ /// export TWILIO_CONFIG='ACCOUNT=,TOKEN=,TO=,FROM=' /// ``` use log::*; -use { - reqwest::{blocking::Client, StatusCode}, - serde_json::json, - std::{env, str::FromStr, thread::sleep, time::Duration}, -}; +use reqwest::{blocking::Client, StatusCode}; +use serde_json::json; +use std::{env, str::FromStr, thread::sleep, time::Duration}; struct TelegramWebHook { bot_token: String, diff --git a/perf/benches/recycler.rs b/perf/benches/recycler.rs index 63410ffc85..ed7b36534f 100644 --- a/perf/benches/recycler.rs +++ b/perf/benches/recycler.rs @@ -2,10 +2,9 @@ extern crate test; -use { - solana_perf::{packet::PacketsRecycler, recycler::Recycler}, - test::Bencher, -}; +use solana_perf::{packet::PacketsRecycler, recycler::Recycler}; + +use test::Bencher; #[bench] fn bench_recycler(bencher: &mut Bencher) { diff --git a/perf/benches/sigverify.rs b/perf/benches/sigverify.rs index a3211cade6..bcc487d12d 100644 --- a/perf/benches/sigverify.rs +++ b/perf/benches/sigverify.rs @@ -2,10 +2,11 @@ extern crate test; -use { - solana_perf::{packet::to_packets_chunked, recycler::Recycler, sigverify, test_tx::test_tx}, - test::Bencher, -}; +use solana_perf::packet::to_packets_chunked; +use solana_perf::recycler::Recycler; +use solana_perf::sigverify; +use solana_perf::test_tx::test_tx; +use test::Bencher; #[bench] fn bench_sigverify(bencher: &mut Bencher) { diff --git a/perf/src/cuda_runtime.rs b/perf/src/cuda_runtime.rs index 741b009367..eb0bf6a79f 100644 --- a/perf/src/cuda_runtime.rs +++ b/perf/src/cuda_runtime.rs @@ -5,26 +5,23 @@ // copies from host memory to GPU memory unless the memory is page-pinned and // cannot be paged to disk. The cuda driver provides these interfaces to pin and unpin memory. -use { - crate::{ - perf_libs, - recycler::{RecyclerX, Reset}, - }, - rand::{seq::SliceRandom, Rng}, - rayon::prelude::*, - std::{ - ops::{Index, IndexMut}, - os::raw::c_int, - slice::{Iter, IterMut, SliceIndex}, - sync::Weak, - }, -}; +use crate::perf_libs; +use crate::recycler::{RecyclerX, Reset}; +use rand::seq::SliceRandom; +use rand::Rng; +use rayon::prelude::*; +use std::ops::{Index, IndexMut}; +use std::slice::{Iter, IterMut, SliceIndex}; +use std::sync::Weak; + +use std::os::raw::c_int; const CUDA_SUCCESS: c_int = 0; fn pin(_mem: &mut Vec) { if let Some(api) = perf_libs::api() { - use std::{ffi::c_void, mem::size_of}; + use std::ffi::c_void; + use std::mem::size_of; let ptr = _mem.as_mut_ptr(); let size = _mem.capacity().saturating_mul(size_of::()); diff --git a/perf/src/packet.rs b/perf/src/packet.rs index 59f9d8f7df..e73a5ad6b7 100644 --- a/perf/src/packet.rs +++ b/perf/src/packet.rs @@ -1,11 +1,9 @@ //! The `packet` module defines data structures and methods to pull data from the network. +use crate::{cuda_runtime::PinnedVec, recycler::Recycler}; +use bincode::config::Options; +use serde::Serialize; pub use solana_sdk::packet::{Meta, Packet, PACKET_DATA_SIZE}; -use { - crate::{cuda_runtime::PinnedVec, recycler::Recycler}, - bincode::config::Options, - serde::Serialize, - std::net::SocketAddr, -}; +use std::net::SocketAddr; pub const NUM_PACKETS: usize = 1024 * 8; @@ -133,14 +131,10 @@ where #[cfg(test)] mod tests { - use { - super::*, - solana_sdk::{ - hash::Hash, - signature::{Keypair, Signer}, - system_transaction, - }, - }; + use super::*; + use solana_sdk::hash::Hash; + use solana_sdk::signature::{Keypair, Signer}; + use solana_sdk::system_transaction; #[test] fn test_to_packets() { diff --git a/perf/src/perf_libs.rs b/perf/src/perf_libs.rs index 1f0505b4a4..facb2edd59 100644 --- a/perf/src/perf_libs.rs +++ b/perf/src/perf_libs.rs @@ -1,18 +1,14 @@ -use { - core::ffi::c_void, - dlopen::symbor::{Container, SymBorApi, Symbol}, - dlopen_derive::SymBorApi, - log::*, - solana_sdk::packet::Packet, - std::{ - env, - ffi::OsStr, - fs, - os::raw::{c_int, c_uint}, - path::{Path, PathBuf}, - sync::Once, - }, -}; +use core::ffi::c_void; +use dlopen::symbor::{Container, SymBorApi, Symbol}; +use dlopen_derive::SymBorApi; +use log::*; +use solana_sdk::packet::Packet; +use std::env; +use std::ffi::OsStr; +use std::fs; +use std::os::raw::{c_int, c_uint}; +use std::path::{Path, PathBuf}; +use std::sync::Once; #[repr(C)] pub struct Elems { diff --git a/perf/src/recycler.rs b/perf/src/recycler.rs index 381bf76cf1..1dce8e74c2 100644 --- a/perf/src/recycler.rs +++ b/perf/src/recycler.rs @@ -1,10 +1,7 @@ -use { - rand::{thread_rng, Rng}, - std::sync::{ - atomic::{AtomicBool, AtomicUsize, Ordering}, - Arc, Mutex, Weak, - }, -}; +use rand::{thread_rng, Rng}; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::{Arc, Mutex, Weak}; // A temporary burst in the workload can cause a large number of allocations, // after which they will be recycled and still reside in memory. If the number @@ -183,7 +180,9 @@ impl RecyclerX { #[cfg(test)] mod tests { - use {super::*, crate::packet::PacketsRecycler, std::iter::repeat_with}; + use super::*; + use crate::packet::PacketsRecycler; + use std::iter::repeat_with; impl Reset for u64 { fn reset(&mut self) { diff --git a/perf/src/recycler_cache.rs b/perf/src/recycler_cache.rs index cbd723120b..5dcf777230 100644 --- a/perf/src/recycler_cache.rs +++ b/perf/src/recycler_cache.rs @@ -1,4 +1,6 @@ -use crate::{cuda_runtime::PinnedVec, recycler::Recycler, sigverify::TxOffset}; +use crate::cuda_runtime::PinnedVec; +use crate::recycler::Recycler; +use crate::sigverify::TxOffset; #[derive(Default, Clone)] pub struct RecyclerCache { diff --git a/perf/src/sigverify.rs b/perf/src/sigverify.rs index 1b60511219..84ee833372 100644 --- a/perf/src/sigverify.rs +++ b/perf/src/sigverify.rs @@ -4,24 +4,22 @@ //! to the GPU. //! +use crate::cuda_runtime::PinnedVec; +use crate::packet::{Packet, Packets}; +use crate::perf_libs; +use crate::recycler::Recycler; +use rayon::ThreadPool; +use solana_metrics::inc_new_counter_debug; +use solana_rayon_threadlimit::get_thread_count; +use solana_sdk::hash::Hash; +use solana_sdk::message::MESSAGE_HEADER_LENGTH; +use solana_sdk::pubkey::Pubkey; +use solana_sdk::short_vec::decode_shortu16_len; +use solana_sdk::signature::Signature; #[cfg(test)] use solana_sdk::transaction::Transaction; -use { - crate::{ - cuda_runtime::PinnedVec, - packet::{Packet, Packets}, - perf_libs, - recycler::Recycler, - }, - rayon::ThreadPool, - solana_metrics::inc_new_counter_debug, - solana_rayon_threadlimit::get_thread_count, - solana_sdk::{ - hash::Hash, message::MESSAGE_HEADER_LENGTH, pubkey::Pubkey, short_vec::decode_shortu16_len, - signature::Signature, - }, - std::{convert::TryFrom, mem::size_of}, -}; +use std::convert::TryFrom; +use std::mem::size_of; // Representing key tKeYE4wtowRb8yRroZShTipE18YVnqwXjsSAoNsFU6g const TRACER_KEY_BYTES: [u8; 32] = [ @@ -562,21 +560,16 @@ pub fn make_packet_from_transaction(tx: Transaction) -> Packet { #[cfg(test)] #[allow(clippy::integer_arithmetic)] mod tests { - use { - super::*, - crate::{ - packet::{Packet, Packets}, - sigverify::{self, PacketOffsets}, - test_tx::{test_multisig_tx, test_tx, vote_tx}, - }, - bincode::{deserialize, serialize}, - solana_sdk::{ - instruction::CompiledInstruction, - message::{Message, MessageHeader}, - signature::{Keypair, Signature}, - transaction::Transaction, - }, - }; + use super::*; + use crate::packet::{Packet, Packets}; + use crate::sigverify; + use crate::sigverify::PacketOffsets; + use crate::test_tx::{test_multisig_tx, test_tx, vote_tx}; + use bincode::{deserialize, serialize}; + use solana_sdk::instruction::CompiledInstruction; + use solana_sdk::message::{Message, MessageHeader}; + use solana_sdk::signature::{Keypair, Signature}; + use solana_sdk::transaction::Transaction; const SIG_OFFSET: usize = 1; @@ -1043,12 +1036,10 @@ mod tests { #[test] fn test_get_checked_scalar() { solana_logger::setup(); - use { - curve25519_dalek::scalar::Scalar, - rand::{thread_rng, Rng}, - rayon::prelude::*, - std::sync::atomic::{AtomicU64, Ordering}, - }; + use curve25519_dalek::scalar::Scalar; + use rand::{thread_rng, Rng}; + use rayon::prelude::*; + use std::sync::atomic::{AtomicU64, Ordering}; if perf_libs::api().is_none() { return; @@ -1085,12 +1076,10 @@ mod tests { #[test] fn test_ge_small_order() { solana_logger::setup(); - use { - curve25519_dalek::edwards::CompressedEdwardsY, - rand::{thread_rng, Rng}, - rayon::prelude::*, - std::sync::atomic::{AtomicU64, Ordering}, - }; + use curve25519_dalek::edwards::CompressedEdwardsY; + use rand::{thread_rng, Rng}; + use rayon::prelude::*; + use std::sync::atomic::{AtomicU64, Ordering}; if perf_libs::api().is_none() { return; diff --git a/perf/src/test_tx.rs b/perf/src/test_tx.rs index 20da0e7c2b..7939e0732f 100644 --- a/perf/src/test_tx.rs +++ b/perf/src/test_tx.rs @@ -1,15 +1,13 @@ -use { - solana_sdk::{ - hash::Hash, - instruction::CompiledInstruction, - signature::{Keypair, Signer}, - stake, - system_instruction::SystemInstruction, - system_program, system_transaction, - transaction::Transaction, - }, - solana_vote_program::vote_transaction, +use solana_sdk::{ + hash::Hash, + instruction::CompiledInstruction, + signature::{Keypair, Signer}, + stake, + system_instruction::SystemInstruction, + system_program, system_transaction, + transaction::Transaction, }; +use solana_vote_program::vote_transaction; pub fn test_tx() -> Transaction { let keypair1 = Keypair::new(); diff --git a/poh-bench/src/main.rs b/poh-bench/src/main.rs index 9c759e066e..d742d816e2 100644 --- a/poh-bench/src/main.rs +++ b/poh-bench/src/main.rs @@ -1,14 +1,12 @@ #![allow(clippy::integer_arithmetic)] +use clap::{crate_description, crate_name, value_t, App, Arg}; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] use solana_ledger::entry::{self, create_ticks, init_poh, EntrySlice, VerifyRecyclers}; #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] use solana_ledger::entry::{create_ticks, init_poh, EntrySlice, VerifyRecyclers}; -use { - clap::{crate_description, crate_name, value_t, App, Arg}, - solana_measure::measure::Measure, - solana_perf::perf_libs, - solana_sdk::hash::hash, -}; +use solana_measure::measure::Measure; +use solana_perf::perf_libs; +use solana_sdk::hash::hash; fn main() { solana_logger::setup(); diff --git a/poh/src/poh_recorder.rs b/poh/src/poh_recorder.rs index b6f725e514..2a17c68d41 100644 --- a/poh/src/poh_recorder.rs +++ b/poh/src/poh_recorder.rs @@ -30,7 +30,7 @@ use { sync::{ atomic::{AtomicBool, Ordering}, mpsc::{channel, Receiver, SendError, Sender, SyncSender}, - Arc, Mutex, + {Arc, Mutex}, }, time::{Duration, Instant}, }, diff --git a/program-test/src/lib.rs b/program-test/src/lib.rs index 92cb627f9e..4cb85a6237 100644 --- a/program-test/src/lib.rs +++ b/program-test/src/lib.rs @@ -1,10 +1,6 @@ //! The solana-program-test provides a BanksClient-based test framework BPF programs #![allow(clippy::integer_arithmetic)] -// Export types so test clients can limit their solana crate dependencies -pub use solana_banks_client::BanksClient; -// Export tokio for test clients -pub use tokio; use { async_trait::async_trait, chrono_humanize::{Accuracy, HumanTime, Tense}, @@ -27,7 +23,8 @@ use { fee_calculator::{FeeCalculator, FeeRateGovernor}, genesis_config::{ClusterType, GenesisConfig}, hash::Hash, - instruction::{Instruction, InstructionError}, + instruction::Instruction, + instruction::InstructionError, message::Message, native_token::sol_to_lamports, poh_config::PohConfig, @@ -64,6 +61,12 @@ use { tokio::task::JoinHandle, }; +// Export types so test clients can limit their solana crate dependencies +pub use solana_banks_client::BanksClient; + +// Export tokio for test clients +pub use tokio; + pub mod programs; #[macro_use] diff --git a/program-test/tests/builtins.rs b/program-test/tests/builtins.rs index 1da1b1a3f4..a350506430 100644 --- a/program-test/tests/builtins.rs +++ b/program-test/tests/builtins.rs @@ -1,12 +1,11 @@ -use { - solana_program_test::ProgramTest, - solana_sdk::{ - bpf_loader_upgradeable::{self, UpgradeableLoaderState}, - signature::{Keypair, Signer}, - transaction::Transaction, - }, +use solana_sdk::{ + bpf_loader_upgradeable::{self, UpgradeableLoaderState}, + signature::{Keypair, Signer}, + transaction::Transaction, }; +use solana_program_test::ProgramTest; + #[tokio::test] async fn test_bpf_loader_upgradable_present() { // Arrange diff --git a/program-test/tests/fuzz.rs b/program-test/tests/fuzz.rs index 83bb603cc9..20b0f018b5 100644 --- a/program-test/tests/fuzz.rs +++ b/program-test/tests/fuzz.rs @@ -2,15 +2,8 @@ use { solana_banks_client::BanksClient, solana_program_test::{processor, ProgramTest}, solana_sdk::{ - account_info::AccountInfo, - entrypoint::ProgramResult, - hash::Hash, - instruction::Instruction, - msg, - pubkey::Pubkey, - rent::Rent, - signature::{Keypair, Signer}, - system_instruction, + account_info::AccountInfo, entrypoint::ProgramResult, hash::Hash, instruction::Instruction, + msg, pubkey::Pubkey, rent::Rent, signature::Keypair, signature::Signer, system_instruction, transaction::Transaction, }, }; diff --git a/programs/bpf_loader/benches/serialization.rs b/programs/bpf_loader/benches/serialization.rs index 1287f518ee..472c795305 100644 --- a/programs/bpf_loader/benches/serialization.rs +++ b/programs/bpf_loader/benches/serialization.rs @@ -2,19 +2,16 @@ extern crate test; -use { - solana_bpf_loader_program::serialization::{ - serialize_parameters_aligned, serialize_parameters_unaligned, - }, - solana_sdk::{ - account::{Account, AccountSharedData}, - bpf_loader, - keyed_account::KeyedAccount, - pubkey::Pubkey, - }, - std::cell::RefCell, - test::Bencher, +use solana_bpf_loader_program::serialization::{ + serialize_parameters_aligned, serialize_parameters_unaligned, }; +use solana_sdk::{ + account::{Account, AccountSharedData}, + bpf_loader, +}; +use solana_sdk::{keyed_account::KeyedAccount, pubkey::Pubkey}; +use std::cell::RefCell; +use test::Bencher; fn create_inputs() -> ( Pubkey, diff --git a/programs/bpf_loader/src/allocator_bump.rs b/programs/bpf_loader/src/allocator_bump.rs index d38ce4b07f..ea3fee8fd1 100644 --- a/programs/bpf_loader/src/allocator_bump.rs +++ b/programs/bpf_loader/src/allocator_bump.rs @@ -1,9 +1,8 @@ -use { - crate::alloc, - alloc::{Alloc, AllocErr}, - solana_rbpf::aligned_memory::AlignedMemory, - std::alloc::Layout, -}; +use crate::alloc; + +use alloc::{Alloc, AllocErr}; +use solana_rbpf::aligned_memory::AlignedMemory; +use std::alloc::Layout; #[derive(Debug)] pub struct BpfAllocator { diff --git a/programs/bpf_loader/src/bpf_verifier.rs b/programs/bpf_loader/src/bpf_verifier.rs index 230b974749..57372262f5 100644 --- a/programs/bpf_loader/src/bpf_verifier.rs +++ b/programs/bpf_loader/src/bpf_verifier.rs @@ -1,6 +1,8 @@ #![allow(clippy::upper_case_acronyms)] -use {crate::BpfError, solana_rbpf::ebpf, thiserror::Error}; +use crate::BpfError; +use solana_rbpf::ebpf; +use thiserror::Error; /// Error definitions #[derive(Debug, Error, PartialEq)] diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index ea9f444907..3352c9d0f9 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -9,50 +9,47 @@ pub mod upgradeable; pub mod upgradeable_with_jit; pub mod with_jit; -use { - crate::{ - bpf_verifier::VerifierError, - serialization::{deserialize_parameters, serialize_parameters}, - syscalls::SyscallError, - }, - log::{log_enabled, trace, Level::Trace}, - solana_measure::measure::Measure, - solana_rbpf::{ - aligned_memory::AlignedMemory, - ebpf::{HOST_ALIGN, MM_HEAP_START}, - error::{EbpfError, UserDefinedError}, - memory_region::MemoryRegion, - static_analysis::Analysis, - vm::{Config, EbpfVm, Executable, InstructionMeter}, - }, - solana_runtime::message_processor::MessageProcessor, - solana_sdk::{ - account::{ReadableAccount, WritableAccount}, - account_utils::State, - bpf_loader, bpf_loader_deprecated, - bpf_loader_upgradeable::{self, UpgradeableLoaderState}, - clock::Clock, - entrypoint::{HEAP_LENGTH, SUCCESS}, - feature_set::{ - add_missing_program_error_mappings, close_upgradeable_program_accounts, - fix_write_privs, reduce_required_deploy_balance, requestable_heap_size, - upgradeable_close_instruction, - }, - ic_logger_msg, ic_msg, - instruction::{AccountMeta, InstructionError}, - keyed_account::{from_keyed_account, keyed_account_at_index, KeyedAccount}, - loader_instruction::LoaderInstruction, - loader_upgradeable_instruction::UpgradeableLoaderInstruction, - process_instruction::{stable_log, ComputeMeter, Executor, InvokeContext, Logger}, - program_error::{ACCOUNT_NOT_RENT_EXEMPT, BORSH_IO_ERROR}, - program_utils::limited_deserialize, - pubkey::Pubkey, - rent::Rent, - system_instruction::{self, MAX_PERMITTED_DATA_LENGTH}, - }, - std::{cell::RefCell, fmt::Debug, rc::Rc, sync::Arc}, - thiserror::Error, +use crate::{ + bpf_verifier::VerifierError, + serialization::{deserialize_parameters, serialize_parameters}, + syscalls::SyscallError, }; +use log::{log_enabled, trace, Level::Trace}; +use solana_measure::measure::Measure; +use solana_rbpf::{ + aligned_memory::AlignedMemory, + ebpf::{HOST_ALIGN, MM_HEAP_START}, + error::{EbpfError, UserDefinedError}, + memory_region::MemoryRegion, + static_analysis::Analysis, + vm::{Config, EbpfVm, Executable, InstructionMeter}, +}; +use solana_runtime::message_processor::MessageProcessor; +use solana_sdk::{ + account::{ReadableAccount, WritableAccount}, + account_utils::State, + bpf_loader, bpf_loader_deprecated, + bpf_loader_upgradeable::{self, UpgradeableLoaderState}, + clock::Clock, + entrypoint::{HEAP_LENGTH, SUCCESS}, + feature_set::{ + add_missing_program_error_mappings, close_upgradeable_program_accounts, fix_write_privs, + reduce_required_deploy_balance, requestable_heap_size, upgradeable_close_instruction, + }, + ic_logger_msg, ic_msg, + instruction::{AccountMeta, InstructionError}, + keyed_account::{from_keyed_account, keyed_account_at_index, KeyedAccount}, + loader_instruction::LoaderInstruction, + loader_upgradeable_instruction::UpgradeableLoaderInstruction, + process_instruction::{stable_log, ComputeMeter, Executor, InvokeContext, Logger}, + program_error::{ACCOUNT_NOT_RENT_EXEMPT, BORSH_IO_ERROR}, + program_utils::limited_deserialize, + pubkey::Pubkey, + rent::Rent, + system_instruction::{self, MAX_PERMITTED_DATA_LENGTH}, +}; +use std::{cell::RefCell, fmt::Debug, rc::Rc, sync::Arc}; +use thiserror::Error; solana_sdk::declare_builtin!( solana_sdk::bpf_loader::ID, @@ -1002,35 +999,34 @@ impl Executor for BpfExecutor { #[cfg(test)] mod tests { - use { - super::*, - rand::Rng, - solana_runtime::{bank::Bank, bank_client::BankClient}, - solana_sdk::{ - account::{ - create_account_shared_data_for_test as create_account_for_test, AccountSharedData, - }, - account_utils::StateMut, - client::SyncClient, - clock::Clock, - feature_set::FeatureSet, - genesis_config::create_genesis_config, - instruction::{AccountMeta, Instruction, InstructionError}, - keyed_account::KeyedAccount, - message::Message, - native_token::LAMPORTS_PER_SOL, - process_instruction::{ - BpfComputeBudget, InvokeContextStackFrame, MockComputeMeter, MockInvokeContext, - MockLogger, - }, - pubkey::Pubkey, - rent::Rent, - signature::{Keypair, Signer}, - system_program, sysvar, - transaction::TransactionError, + use super::*; + use rand::Rng; + use solana_runtime::{bank::Bank, bank_client::BankClient}; + use solana_sdk::{ + account::{ + create_account_shared_data_for_test as create_account_for_test, AccountSharedData, }, - std::{cell::RefCell, fs::File, io::Read, ops::Range, rc::Rc, sync::Arc}, + account_utils::StateMut, + client::SyncClient, + clock::Clock, + feature_set::FeatureSet, + genesis_config::create_genesis_config, + instruction::Instruction, + instruction::{AccountMeta, InstructionError}, + keyed_account::KeyedAccount, + message::Message, + native_token::LAMPORTS_PER_SOL, + process_instruction::{ + BpfComputeBudget, InvokeContextStackFrame, MockComputeMeter, MockInvokeContext, + MockLogger, + }, + pubkey::Pubkey, + rent::Rent, + signature::{Keypair, Signer}, + system_program, sysvar, + transaction::TransactionError, }; + use std::{cell::RefCell, fs::File, io::Read, ops::Range, rc::Rc, sync::Arc}; struct TestInstructionMeter { remaining: u64, diff --git a/programs/bpf_loader/src/serialization.rs b/programs/bpf_loader/src/serialization.rs index 609177e8d7..3fae5ba12e 100644 --- a/programs/bpf_loader/src/serialization.rs +++ b/programs/bpf_loader/src/serialization.rs @@ -1,16 +1,14 @@ -use { - byteorder::{ByteOrder, LittleEndian, WriteBytesExt}, - solana_rbpf::{aligned_memory::AlignedMemory, ebpf::HOST_ALIGN}, - solana_sdk::{ - account::{ReadableAccount, WritableAccount}, - bpf_loader_deprecated, - entrypoint::{BPF_ALIGN_OF_U128, MAX_PERMITTED_DATA_INCREASE}, - instruction::InstructionError, - keyed_account::KeyedAccount, - pubkey::Pubkey, - }, - std::{io::prelude::*, mem::size_of}, +use byteorder::{ByteOrder, LittleEndian, WriteBytesExt}; +use solana_rbpf::{aligned_memory::AlignedMemory, ebpf::HOST_ALIGN}; +use solana_sdk::{ + account::{ReadableAccount, WritableAccount}, + bpf_loader_deprecated, + entrypoint::{BPF_ALIGN_OF_U128, MAX_PERMITTED_DATA_INCREASE}, + instruction::InstructionError, + keyed_account::KeyedAccount, + pubkey::Pubkey, }; +use std::{io::prelude::*, mem::size_of}; /// Look for a duplicate account and return its position if found pub fn is_dup(accounts: &[KeyedAccount], keyed_account: &KeyedAccount) -> (bool, usize) { @@ -285,19 +283,18 @@ pub fn deserialize_parameters_aligned( #[cfg(test)] mod tests { - use { - super::*, - solana_sdk::{ - account::{Account, AccountSharedData}, - account_info::AccountInfo, - bpf_loader, - entrypoint::deserialize, - }, - std::{ - cell::RefCell, - rc::Rc, - slice::{from_raw_parts, from_raw_parts_mut}, - }, + use super::*; + use solana_sdk::{ + account::{Account, AccountSharedData}, + account_info::AccountInfo, + bpf_loader, + entrypoint::deserialize, + }; + use std::{ + cell::RefCell, + rc::Rc, + // Hide Result from bindgen gets confused about generics in non-generic type declarations + slice::{from_raw_parts, from_raw_parts_mut}, }; #[test] diff --git a/programs/bpf_loader/src/syscalls.rs b/programs/bpf_loader/src/syscalls.rs index f0efb5f2f6..312befd3bf 100644 --- a/programs/bpf_loader/src/syscalls.rs +++ b/programs/bpf_loader/src/syscalls.rs @@ -1,58 +1,56 @@ -use { - crate::{alloc, BpfError}, - alloc::Alloc, - solana_rbpf::{ - aligned_memory::AlignedMemory, - ebpf::MM_HEAP_START, - error::EbpfError, - memory_region::{AccessType, MemoryMapping}, - question_mark, - vm::{EbpfVm, SyscallObject, SyscallRegistry}, - }, - solana_runtime::message_processor::MessageProcessor, - solana_sdk::{ - account::{Account, AccountSharedData, ReadableAccount}, - account_info::AccountInfo, - account_utils::StateMut, - bpf_loader, bpf_loader_deprecated, - bpf_loader_upgradeable::{self, UpgradeableLoaderState}, - clock::Clock, - entrypoint::{BPF_ALIGN_OF_U128, MAX_PERMITTED_DATA_INCREASE, SUCCESS}, - epoch_schedule::EpochSchedule, - feature_set::{ - allow_native_ids, check_seed_length, close_upgradeable_program_accounts, cpi_data_cost, - demote_program_write_locks, enforce_aligned_host_addrs, keccak256_syscall_enabled, - libsecp256k1_0_5_upgrade_enabled, mem_overlap_fix, memory_ops_syscalls, - return_data_syscall_enabled, secp256k1_recover_syscall_enabled, - set_upgrade_authority_via_cpi_enabled, sol_log_data_syscall_enabled, - sysvar_via_syscall, update_data_on_realloc, - }, - hash::{Hasher, HASH_BYTES}, - ic_msg, - instruction::{AccountMeta, Instruction, InstructionError}, - keccak, - keyed_account::KeyedAccount, - native_loader, - process_instruction::{self, stable_log, ComputeMeter, InvokeContext, Logger}, - program::MAX_RETURN_DATA, - pubkey::{Pubkey, PubkeyError, MAX_SEEDS, MAX_SEED_LEN}, - rent::Rent, - secp256k1_recover::{ - Secp256k1RecoverError, SECP256K1_PUBLIC_KEY_LENGTH, SECP256K1_SIGNATURE_LENGTH, - }, - sysvar::{self, fees::Fees, Sysvar, SysvarId}, - }, - std::{ - alloc::Layout, - cell::{Ref, RefCell, RefMut}, - cmp::min, - mem::{align_of, size_of}, - rc::Rc, - slice::from_raw_parts_mut, - str::{from_utf8, Utf8Error}, - }, - thiserror::Error as ThisError, +use crate::{alloc, BpfError}; +use alloc::Alloc; +use solana_rbpf::{ + aligned_memory::AlignedMemory, + ebpf::MM_HEAP_START, + error::EbpfError, + memory_region::{AccessType, MemoryMapping}, + question_mark, + vm::{EbpfVm, SyscallObject, SyscallRegistry}, }; +use solana_runtime::message_processor::MessageProcessor; +use solana_sdk::{ + account::{Account, AccountSharedData, ReadableAccount}, + account_info::AccountInfo, + account_utils::StateMut, + bpf_loader, bpf_loader_deprecated, + bpf_loader_upgradeable::{self, UpgradeableLoaderState}, + clock::Clock, + entrypoint::{BPF_ALIGN_OF_U128, MAX_PERMITTED_DATA_INCREASE, SUCCESS}, + epoch_schedule::EpochSchedule, + feature_set::{ + allow_native_ids, check_seed_length, close_upgradeable_program_accounts, cpi_data_cost, + demote_program_write_locks, enforce_aligned_host_addrs, keccak256_syscall_enabled, + libsecp256k1_0_5_upgrade_enabled, mem_overlap_fix, memory_ops_syscalls, + return_data_syscall_enabled, secp256k1_recover_syscall_enabled, + set_upgrade_authority_via_cpi_enabled, sol_log_data_syscall_enabled, sysvar_via_syscall, + update_data_on_realloc, + }, + hash::{Hasher, HASH_BYTES}, + ic_msg, + instruction::{AccountMeta, Instruction, InstructionError}, + keccak, + keyed_account::KeyedAccount, + native_loader, + process_instruction::{self, stable_log, ComputeMeter, InvokeContext, Logger}, + program::MAX_RETURN_DATA, + pubkey::{Pubkey, PubkeyError, MAX_SEEDS, MAX_SEED_LEN}, + rent::Rent, + secp256k1_recover::{ + Secp256k1RecoverError, SECP256K1_PUBLIC_KEY_LENGTH, SECP256K1_SIGNATURE_LENGTH, + }, + sysvar::{self, fees::Fees, Sysvar, SysvarId}, +}; +use std::{ + alloc::Layout, + cell::{Ref, RefCell, RefMut}, + cmp::min, + mem::{align_of, size_of}, + rc::Rc, + slice::from_raw_parts_mut, + str::{from_utf8, Utf8Error}, +}; +use thiserror::Error as ThisError; /// Maximum signers pub const MAX_SIGNERS: usize = 16; @@ -2764,19 +2762,17 @@ impl<'a> SyscallObject for SyscallLogData<'a> { #[cfg(test)] mod tests { - use { - super::*, - solana_rbpf::{ - ebpf::HOST_ALIGN, memory_region::MemoryRegion, user_error::UserError, vm::Config, - }, - solana_sdk::{ - bpf_loader, - fee_calculator::FeeCalculator, - hash::hashv, - process_instruction::{MockComputeMeter, MockInvokeContext, MockLogger}, - }, - std::str::FromStr, + use super::*; + use solana_rbpf::{ + ebpf::HOST_ALIGN, memory_region::MemoryRegion, user_error::UserError, vm::Config, }; + use solana_sdk::{ + bpf_loader, + fee_calculator::FeeCalculator, + hash::hashv, + process_instruction::{MockComputeMeter, MockInvokeContext, MockLogger}, + }; + use std::str::FromStr; const DEFAULT_CONFIG: Config = Config { max_call_depth: 20, diff --git a/programs/config/src/config_instruction.rs b/programs/config/src/config_instruction.rs index 773f360973..b1869b5d4f 100644 --- a/programs/config/src/config_instruction.rs +++ b/programs/config/src/config_instruction.rs @@ -1,10 +1,9 @@ -use { - crate::{id, ConfigKeys, ConfigState}, - solana_sdk::{ - instruction::{AccountMeta, Instruction}, - pubkey::Pubkey, - system_instruction, - }, +use crate::id; +use crate::{ConfigKeys, ConfigState}; +use solana_sdk::{ + instruction::{AccountMeta, Instruction}, + pubkey::Pubkey, + system_instruction, }; fn initialize_account(config_pubkey: &Pubkey) -> Instruction { diff --git a/programs/config/src/config_processor.rs b/programs/config/src/config_processor.rs index 6b2d5124c7..a7ac27313a 100644 --- a/programs/config/src/config_processor.rs +++ b/programs/config/src/config_processor.rs @@ -1,19 +1,17 @@ //! Config program -use { - crate::ConfigKeys, - bincode::deserialize, - solana_sdk::{ - account::{ReadableAccount, WritableAccount}, - feature_set, ic_msg, - instruction::InstructionError, - keyed_account::keyed_account_at_index, - process_instruction::InvokeContext, - program_utils::limited_deserialize, - pubkey::Pubkey, - }, - std::collections::BTreeSet, +use crate::ConfigKeys; +use bincode::deserialize; +use solana_sdk::{ + account::{ReadableAccount, WritableAccount}, + feature_set, ic_msg, + instruction::InstructionError, + keyed_account::keyed_account_at_index, + process_instruction::InvokeContext, + program_utils::limited_deserialize, + pubkey::Pubkey, }; +use std::collections::BTreeSet; pub fn process_instruction( _program_id: &Pubkey, @@ -138,20 +136,18 @@ pub fn process_instruction( #[cfg(test)] mod tests { - use { - super::*, - crate::{config_instruction, get_config_data, id, ConfigKeys, ConfigState}, - bincode::serialized_size, - serde_derive::{Deserialize, Serialize}, - solana_sdk::{ - account::{Account, AccountSharedData}, - keyed_account::create_keyed_accounts_unified, - process_instruction::MockInvokeContext, - signature::{Keypair, Signer}, - system_instruction::SystemInstruction, - }, - std::cell::RefCell, + use super::*; + use crate::{config_instruction, get_config_data, id, ConfigKeys, ConfigState}; + use bincode::serialized_size; + use serde_derive::{Deserialize, Serialize}; + use solana_sdk::{ + account::{Account, AccountSharedData}, + keyed_account::create_keyed_accounts_unified, + process_instruction::MockInvokeContext, + signature::{Keypair, Signer}, + system_instruction::SystemInstruction, }; + use std::cell::RefCell; #[derive(Serialize, Deserialize, Debug, PartialEq)] struct MyConfig { diff --git a/programs/config/src/date_instruction.rs b/programs/config/src/date_instruction.rs index 4151ed4806..7bc4ae4145 100644 --- a/programs/config/src/date_instruction.rs +++ b/programs/config/src/date_instruction.rs @@ -1,16 +1,14 @@ +use crate::{config_instruction, ConfigState}; /// /// A library for creating a trusted date oracle. /// use bincode::{deserialize, serialized_size}; -use { - crate::{config_instruction, ConfigState}, - chrono::{ - prelude::{Date, DateTime, TimeZone, Utc}, - serde::ts_seconds, - }, - serde_derive::{Deserialize, Serialize}, - solana_sdk::{instruction::Instruction, pubkey::Pubkey}, +use chrono::{ + prelude::{Date, DateTime, TimeZone, Utc}, + serde::ts_seconds, }; +use serde_derive::{Deserialize, Serialize}; +use solana_sdk::{instruction::Instruction, pubkey::Pubkey}; #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] pub struct DateConfig { diff --git a/programs/config/src/lib.rs b/programs/config/src/lib.rs index 912c69ab23..5658232c36 100644 --- a/programs/config/src/lib.rs +++ b/programs/config/src/lib.rs @@ -3,18 +3,17 @@ pub mod config_instruction; pub mod config_processor; pub mod date_instruction; -pub use solana_sdk::config::program::id; -use { - bincode::{deserialize, serialize, serialized_size}, - serde_derive::{Deserialize, Serialize}, - solana_sdk::{ - account::{Account, AccountSharedData}, - pubkey::Pubkey, - short_vec, - stake::config::Config as StakeConfig, - }, +use bincode::{deserialize, serialize, serialized_size}; +use serde_derive::{Deserialize, Serialize}; +use solana_sdk::{ + account::{Account, AccountSharedData}, + pubkey::Pubkey, + short_vec, + stake::config::Config as StakeConfig, }; +pub use solana_sdk::config::program::id; + pub trait ConfigState: serde::Serialize + Default { /// Maximum space that the serialized representation will require fn max_space() -> u64; diff --git a/programs/ed25519/src/lib.rs b/programs/ed25519/src/lib.rs index b0496f02cf..da579fb1d1 100644 --- a/programs/ed25519/src/lib.rs +++ b/programs/ed25519/src/lib.rs @@ -13,17 +13,15 @@ pub fn process_instruction( #[cfg(test)] pub mod test { - use { - rand::{thread_rng, Rng}, - solana_sdk::{ - ed25519_instruction::new_ed25519_instruction, - feature_set::FeatureSet, - hash::Hash, - signature::{Keypair, Signer}, - transaction::Transaction, - }, - std::sync::Arc, + use rand::{thread_rng, Rng}; + use solana_sdk::{ + ed25519_instruction::new_ed25519_instruction, + feature_set::FeatureSet, + hash::Hash, + signature::{Keypair, Signer}, + transaction::Transaction, }; + use std::sync::Arc; #[test] fn test_ed25519() { diff --git a/programs/exchange/src/exchange_instruction.rs b/programs/exchange/src/exchange_instruction.rs index 66d8610729..806c112f6a 100644 --- a/programs/exchange/src/exchange_instruction.rs +++ b/programs/exchange/src/exchange_instruction.rs @@ -1,13 +1,10 @@ //! Exchange program -use { - crate::{exchange_state::*, id}, - serde_derive::{Deserialize, Serialize}, - solana_sdk::{ - instruction::{AccountMeta, Instruction}, - pubkey::Pubkey, - }, -}; +use crate::exchange_state::*; +use crate::id; +use serde_derive::{Deserialize, Serialize}; +use solana_sdk::instruction::{AccountMeta, Instruction}; +use solana_sdk::pubkey::Pubkey; #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] pub struct OrderRequestInfo { diff --git a/programs/exchange/src/exchange_processor.rs b/programs/exchange/src/exchange_processor.rs index a0ac3bc60d..ab63cf7ec6 100644 --- a/programs/exchange/src/exchange_processor.rs +++ b/programs/exchange/src/exchange_processor.rs @@ -1,23 +1,23 @@ //! Config processor -use { - crate::{exchange_instruction::*, exchange_state::*, faucet}, - log::*, - num_derive::{FromPrimitive, ToPrimitive}, - serde_derive::Serialize, - solana_metrics::inc_new_counter_info, - solana_sdk::{ - account::{ReadableAccount, WritableAccount}, - decode_error::DecodeError, - instruction::InstructionError, - keyed_account::KeyedAccount, - process_instruction::InvokeContext, - program_utils::limited_deserialize, - pubkey::Pubkey, - }, - std::cmp, - thiserror::Error, +use crate::exchange_instruction::*; +use crate::exchange_state::*; +use crate::faucet; +use log::*; +use num_derive::{FromPrimitive, ToPrimitive}; +use serde_derive::Serialize; +use solana_metrics::inc_new_counter_info; +use solana_sdk::{ + account::{ReadableAccount, WritableAccount}, + decode_error::DecodeError, + instruction::InstructionError, + keyed_account::KeyedAccount, + process_instruction::InvokeContext, + program_utils::limited_deserialize, + pubkey::Pubkey, }; +use std::cmp; +use thiserror::Error; #[derive(Error, Debug, Serialize, Clone, PartialEq, FromPrimitive, ToPrimitive)] pub enum ExchangeError { @@ -510,19 +510,16 @@ pub fn process_instruction( #[cfg(test)] mod test { - use { - super::*, - crate::{exchange_instruction, id}, - solana_runtime::{bank::Bank, bank_client::BankClient}, - solana_sdk::{ - client::SyncClient, - genesis_config::create_genesis_config, - message::Message, - signature::{Keypair, Signer}, - system_instruction, - }, - std::mem, - }; + use super::*; + use crate::{exchange_instruction, id}; + use solana_runtime::bank::Bank; + use solana_runtime::bank_client::BankClient; + use solana_sdk::client::SyncClient; + use solana_sdk::genesis_config::create_genesis_config; + use solana_sdk::message::Message; + use solana_sdk::signature::{Keypair, Signer}; + use solana_sdk::system_instruction; + use std::mem; #[allow(clippy::too_many_arguments)] fn try_calc( diff --git a/programs/exchange/src/exchange_state.rs b/programs/exchange/src/exchange_state.rs index 46572ee586..cd3101cf18 100644 --- a/programs/exchange/src/exchange_state.rs +++ b/programs/exchange/src/exchange_state.rs @@ -1,8 +1,6 @@ -use { - serde_derive::{Deserialize, Serialize}, - solana_sdk::pubkey::Pubkey, - std::{error, fmt}, -}; +use serde_derive::{Deserialize, Serialize}; +use solana_sdk::pubkey::Pubkey; +use std::{error, fmt}; /// Fixed-point scaler, 10 = one base 10 digit to the right of the decimal, 100 = 2, ... /// Used by both price and amount in their fixed point representation diff --git a/programs/secp256k1/src/lib.rs b/programs/secp256k1/src/lib.rs index d2058e3feb..de879e0924 100644 --- a/programs/secp256k1/src/lib.rs +++ b/programs/secp256k1/src/lib.rs @@ -13,19 +13,17 @@ pub fn process_instruction( #[cfg(test)] pub mod test { - use { - rand::{thread_rng, Rng}, - solana_sdk::{ - feature_set, - hash::Hash, - secp256k1_instruction::{ - new_secp256k1_instruction, SecpSignatureOffsets, SIGNATURE_OFFSETS_SERIALIZED_SIZE, - }, - signature::{Keypair, Signer}, - transaction::Transaction, + use rand::{thread_rng, Rng}; + use solana_sdk::{ + feature_set, + hash::Hash, + secp256k1_instruction::{ + new_secp256k1_instruction, SecpSignatureOffsets, SIGNATURE_OFFSETS_SERIALIZED_SIZE, }, - std::sync::Arc, + signature::{Keypair, Signer}, + transaction::Transaction, }; + use std::sync::Arc; #[test] fn test_secp256k1() { diff --git a/programs/stake/src/config.rs b/programs/stake/src/config.rs index b5d4274a0c..98d5b9df44 100644 --- a/programs/stake/src/config.rs +++ b/programs/stake/src/config.rs @@ -1,21 +1,20 @@ //! config for staking //! carries variables that the stake program cares about +use bincode::deserialize; +use solana_config_program::{create_config_account, get_config_data}; +use solana_sdk::{ + account::{AccountSharedData, ReadableAccount, WritableAccount}, + genesis_config::GenesisConfig, + instruction::InstructionError, + keyed_account::KeyedAccount, + stake::config::{self, Config}, +}; + #[deprecated( since = "1.7.2", note = "Please use `solana_sdk::stake::config` or `solana_program::stake::config` instead" )] pub use solana_sdk::stake::config::*; -use { - bincode::deserialize, - solana_config_program::{create_config_account, get_config_data}, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount, WritableAccount}, - genesis_config::GenesisConfig, - instruction::InstructionError, - keyed_account::KeyedAccount, - stake::config::{self, Config}, - }, -}; pub fn from(account: &T) -> Option { get_config_data(account.data()) @@ -47,7 +46,9 @@ pub fn add_genesis_account(genesis_config: &mut GenesisConfig) -> u64 { #[cfg(test)] mod tests { - use {super::*, solana_sdk::pubkey::Pubkey, std::cell::RefCell}; + use super::*; + use solana_sdk::pubkey::Pubkey; + use std::cell::RefCell; #[test] fn test() { diff --git a/programs/stake/src/lib.rs b/programs/stake/src/lib.rs index 737387e7fb..26d9c31df5 100644 --- a/programs/stake/src/lib.rs +++ b/programs/stake/src/lib.rs @@ -1,6 +1,7 @@ #![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))] #![allow(clippy::integer_arithmetic)] use solana_sdk::genesis_config::GenesisConfig; + #[deprecated( since = "1.7.2", note = "Please use `solana_sdk::stake::program::id` or `solana_program::stake::program::id` instead" diff --git a/programs/stake/src/stake_instruction.rs b/programs/stake/src/stake_instruction.rs index ae37c58059..f8258a82df 100644 --- a/programs/stake/src/stake_instruction.rs +++ b/programs/stake/src/stake_instruction.rs @@ -1,8 +1,3 @@ -#[deprecated( - since = "1.7.2", - note = "Please use `solana_sdk::stake::instruction` or `solana_program::stake::instruction` instead" -)] -pub use solana_sdk::stake::instruction::*; use { crate::{config, stake_state::StakeAccount}, log::*, @@ -22,6 +17,12 @@ use { }, }; +#[deprecated( + since = "1.7.2", + note = "Please use `solana_sdk::stake::instruction` or `solana_program::stake::instruction` instead" +)] +pub use solana_sdk::stake::instruction::*; + pub fn process_instruction( _program_id: &Pubkey, data: &[u8], @@ -273,25 +274,23 @@ pub fn process_instruction( #[cfg(test)] mod tests { - use { - super::*, - crate::stake_state::{Meta, StakeState}, - bincode::serialize, - solana_sdk::{ - account::{self, Account, AccountSharedData, WritableAccount}, - instruction::{AccountMeta, Instruction}, - keyed_account::KeyedAccount, - process_instruction::{mock_set_sysvar, MockInvokeContext}, - rent::Rent, - stake::{ - config as stake_config, - instruction::{self, LockupArgs}, - state::{Authorized, Lockup, StakeAuthorize}, - }, - sysvar::stake_history::StakeHistory, + use super::*; + use crate::stake_state::{Meta, StakeState}; + use bincode::serialize; + use solana_sdk::{ + account::{self, Account, AccountSharedData, WritableAccount}, + instruction::{AccountMeta, Instruction}, + keyed_account::KeyedAccount, + process_instruction::{mock_set_sysvar, MockInvokeContext}, + rent::Rent, + stake::{ + config as stake_config, + instruction::{self, LockupArgs}, + state::{Authorized, Lockup, StakeAuthorize}, }, - std::{cell::RefCell, rc::Rc, str::FromStr}, + sysvar::stake_history::StakeHistory, }; + use std::{cell::RefCell, rc::Rc, str::FromStr}; fn create_default_account() -> RefCell { RefCell::new(AccountSharedData::default()) diff --git a/programs/stake/src/stake_state.rs b/programs/stake/src/stake_state.rs index 2e2f334b01..7a146d199f 100644 --- a/programs/stake/src/stake_state.rs +++ b/programs/stake/src/stake_state.rs @@ -3,11 +3,6 @@ //! * keep track of rewards //! * own mining pools -#[deprecated( - since = "1.7.2", - note = "Please use `solana_sdk::stake::state` or `solana_program::stake::state` instead" -)] -pub use solana_sdk::stake::state::*; use { solana_sdk::{ account::{AccountSharedData, ReadableAccount, WritableAccount}, @@ -31,6 +26,12 @@ use { std::{collections::HashSet, convert::TryFrom}, }; +#[deprecated( + since = "1.7.2", + note = "Please use `solana_sdk::stake::state` or `solana_program::stake::state` instead" +)] +pub use solana_sdk::stake::state::*; + #[derive(Debug)] pub enum SkippedReason { ZeroPoints, @@ -1370,20 +1371,18 @@ fn do_create_account( #[cfg(test)] mod tests { - use { - super::*, - proptest::prelude::*, - solana_sdk::{ - account::{AccountSharedData, WritableAccount}, - clock::UnixTimestamp, - native_token, - process_instruction::MockInvokeContext, - pubkey::Pubkey, - system_program, - }, - solana_vote_program::vote_state, - std::{cell::RefCell, iter::FromIterator}, + use super::*; + use proptest::prelude::*; + use solana_sdk::{ + account::{AccountSharedData, WritableAccount}, + clock::UnixTimestamp, + native_token, + process_instruction::MockInvokeContext, + pubkey::Pubkey, + system_program, }; + use solana_vote_program::vote_state; + use std::{cell::RefCell, iter::FromIterator}; #[test] fn test_authorized_authorize() { diff --git a/programs/vote/src/authorized_voters.rs b/programs/vote/src/authorized_voters.rs index 1951e35450..134d06b6b4 100644 --- a/programs/vote/src/authorized_voters.rs +++ b/programs/vote/src/authorized_voters.rs @@ -1,9 +1,7 @@ -use { - log::*, - serde_derive::{Deserialize, Serialize}, - solana_sdk::{clock::Epoch, pubkey::Pubkey}, - std::collections::BTreeMap, -}; +use log::*; +use serde_derive::{Deserialize, Serialize}; +use solana_sdk::{clock::Epoch, pubkey::Pubkey}; +use std::collections::BTreeMap; #[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone, AbiExample)] pub struct AuthorizedVoters { diff --git a/programs/vote/src/vote_instruction.rs b/programs/vote/src/vote_instruction.rs index 012797ff77..37ce4e3950 100644 --- a/programs/vote/src/vote_instruction.rs +++ b/programs/vote/src/vote_instruction.rs @@ -1,30 +1,28 @@ //! Vote program //! Receive and processes votes from validators -use { - crate::{ - id, - vote_state::{self, Vote, VoteAuthorize, VoteInit, VoteState}, - }, - log::*, - num_derive::{FromPrimitive, ToPrimitive}, - serde_derive::{Deserialize, Serialize}, - solana_metrics::inc_new_counter_info, - solana_sdk::{ - decode_error::DecodeError, - feature_set, - hash::Hash, - instruction::{AccountMeta, Instruction, InstructionError}, - keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount}, - process_instruction::InvokeContext, - program_utils::limited_deserialize, - pubkey::Pubkey, - system_instruction, - sysvar::{self, clock::Clock, slot_hashes::SlotHashes}, - }, - std::collections::HashSet, - thiserror::Error, +use crate::{ + id, + vote_state::{self, Vote, VoteAuthorize, VoteInit, VoteState}, }; +use log::*; +use num_derive::{FromPrimitive, ToPrimitive}; +use serde_derive::{Deserialize, Serialize}; +use solana_metrics::inc_new_counter_info; +use solana_sdk::{ + decode_error::DecodeError, + feature_set, + hash::Hash, + instruction::{AccountMeta, Instruction, InstructionError}, + keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount}, + process_instruction::InvokeContext, + program_utils::limited_deserialize, + pubkey::Pubkey, + system_instruction, + sysvar::{self, clock::Clock, slot_hashes::SlotHashes}, +}; +use std::collections::HashSet; +use thiserror::Error; /// Reasons the stake might have had an error #[derive(Error, Debug, Clone, PartialEq, FromPrimitive, ToPrimitive)] @@ -390,16 +388,15 @@ pub fn process_instruction( #[cfg(test)] mod tests { - use { - super::*, - bincode::serialize, - solana_sdk::{ - account::{self, Account, AccountSharedData}, - process_instruction::MockInvokeContext, - rent::Rent, - }, - std::{cell::RefCell, str::FromStr}, + use super::*; + use bincode::serialize; + use solana_sdk::{ + account::{self, Account, AccountSharedData}, + process_instruction::MockInvokeContext, + rent::Rent, }; + use std::cell::RefCell; + use std::str::FromStr; fn create_default_account() -> RefCell { RefCell::new(AccountSharedData::default()) diff --git a/programs/vote/src/vote_state/mod.rs b/programs/vote/src/vote_state/mod.rs index dd49f1a220..05f3a94050 100644 --- a/programs/vote/src/vote_state/mod.rs +++ b/programs/vote/src/vote_state/mod.rs @@ -1,29 +1,26 @@ //! Vote state, vote program //! Receive and processes votes from validators -use { - crate::{authorized_voters::AuthorizedVoters, id, vote_instruction::VoteError}, - bincode::{deserialize, serialize_into, serialized_size, ErrorKind}, - log::*, - serde_derive::{Deserialize, Serialize}, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount, WritableAccount}, - account_utils::State, - clock::{Epoch, Slot, UnixTimestamp}, - epoch_schedule::MAX_LEADER_SCHEDULE_EPOCH_OFFSET, - hash::Hash, - instruction::InstructionError, - keyed_account::KeyedAccount, - pubkey::Pubkey, - rent::Rent, - slot_hashes::SlotHash, - sysvar::clock::Clock, - }, - std::{ - boxed::Box, - cmp::Ordering, - collections::{HashSet, VecDeque}, - }, +use crate::authorized_voters::AuthorizedVoters; +use crate::{id, vote_instruction::VoteError}; +use bincode::{deserialize, serialize_into, serialized_size, ErrorKind}; +use log::*; +use serde_derive::{Deserialize, Serialize}; +use solana_sdk::{ + account::{AccountSharedData, ReadableAccount, WritableAccount}, + account_utils::State, + clock::{Epoch, Slot, UnixTimestamp}, + epoch_schedule::MAX_LEADER_SCHEDULE_EPOCH_OFFSET, + hash::Hash, + instruction::InstructionError, + keyed_account::KeyedAccount, + pubkey::Pubkey, + rent::Rent, + slot_hashes::SlotHash, + sysvar::clock::Clock, }; +use std::boxed::Box; +use std::cmp::Ordering; +use std::collections::{HashSet, VecDeque}; mod vote_state_0_23_5; pub mod vote_state_versions; @@ -796,17 +793,15 @@ pub fn create_account( #[cfg(test)] mod tests { - use { - super::*, - crate::vote_state, - solana_sdk::{ - account::AccountSharedData, - account_utils::StateMut, - hash::hash, - keyed_account::{get_signers, keyed_account_at_index}, - }, - std::cell::RefCell, + use super::*; + use crate::vote_state; + use solana_sdk::{ + account::AccountSharedData, + account_utils::StateMut, + hash::hash, + keyed_account::{get_signers, keyed_account_at_index}, }; + use std::cell::RefCell; const MAX_RECENT_VOTES: usize = 16; diff --git a/programs/vote/src/vote_state/vote_state_versions.rs b/programs/vote/src/vote_state/vote_state_versions.rs index 3f6b9ec14d..f00cc65354 100644 --- a/programs/vote/src/vote_state/vote_state_versions.rs +++ b/programs/vote/src/vote_state/vote_state_versions.rs @@ -1,4 +1,5 @@ -use {super::*, crate::vote_state::vote_state_0_23_5::VoteState0_23_5}; +use super::*; +use crate::vote_state::vote_state_0_23_5::VoteState0_23_5; #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)] pub enum VoteStateVersions { diff --git a/programs/vote/src/vote_transaction.rs b/programs/vote/src/vote_transaction.rs index afb0bdcb84..f5446564c5 100644 --- a/programs/vote/src/vote_transaction.rs +++ b/programs/vote/src/vote_transaction.rs @@ -1,16 +1,15 @@ -use { - crate::{ - vote_instruction::{self, VoteInstruction}, - vote_state::Vote, - }, - solana_sdk::{ - clock::Slot, - hash::Hash, - program_utils::limited_deserialize, - pubkey::Pubkey, - signature::{Keypair, Signer}, - transaction::Transaction, - }, +use solana_sdk::{ + clock::Slot, + hash::Hash, + program_utils::limited_deserialize, + pubkey::Pubkey, + signature::{Keypair, Signer}, + transaction::Transaction, +}; + +use crate::{ + vote_instruction::{self, VoteInstruction}, + vote_state::Vote, }; pub fn parse_vote_transaction(tx: &Transaction) -> Option<(Pubkey, Vote, Option)> { @@ -83,7 +82,8 @@ pub fn new_vote_transaction( #[cfg(test)] mod test { - use {super::*, solana_sdk::hash::hash}; + use super::*; + use solana_sdk::hash::hash; fn run_test_parse_vote_transaction(input_hash: Option) { let node_keypair = Keypair::new(); diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 9826e5e3bd..d7f03397ed 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -29,7 +29,8 @@ use { MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, MAX_GET_SLOT_LEADERS, MAX_MULTIPLE_ACCOUNTS, NUM_LARGEST_ACCOUNTS, }, - rpc_response::{Response as RpcResponse, *}, + rpc_response::Response as RpcResponse, + rpc_response::*, }, solana_faucet::faucet::request_airdrop_transaction, solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo}, @@ -4101,7 +4102,8 @@ pub mod tests { }, spl_token::{ solana_program::{program_option::COption, pubkey::Pubkey as SplTokenPubkey}, - state::{AccountState as TokenAccountState, Mint}, + state::AccountState as TokenAccountState, + state::Mint, }, std::collections::HashMap, }; diff --git a/rpc/src/rpc_health.rs b/rpc/src/rpc_health.rs index 8f4b4dfc4c..94dff94fcc 100644 --- a/rpc/src/rpc_health.rs +++ b/rpc/src/rpc_health.rs @@ -3,10 +3,8 @@ use { solana_sdk::{clock::Slot, pubkey::Pubkey}, std::{ collections::HashSet, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, + sync::atomic::{AtomicBool, Ordering}, + sync::Arc, }, }; diff --git a/rpc/src/rpc_pubsub_service.rs b/rpc/src/rpc_pubsub_service.rs index 19a0b8f2cd..1f12e7843a 100644 --- a/rpc/src/rpc_pubsub_service.rs +++ b/rpc/src/rpc_pubsub_service.rs @@ -187,13 +187,9 @@ pub struct TestBroadcastReceiver { #[cfg(test)] impl TestBroadcastReceiver { pub fn recv(&mut self) -> String { - use { - std::{ - thread::sleep, - time::{Duration, Instant}, - }, - tokio::sync::broadcast::error::TryRecvError, - }; + use std::thread::sleep; + use std::time::{Duration, Instant}; + use tokio::sync::broadcast::error::TryRecvError; let timeout = Duration::from_secs(5); let started = Instant::now(); diff --git a/rpc/src/rpc_service.rs b/rpc/src/rpc_service.rs index d928addf18..8b5e9b9d5d 100644 --- a/rpc/src/rpc_service.rs +++ b/rpc/src/rpc_service.rs @@ -36,11 +36,8 @@ use { collections::HashSet, net::SocketAddr, path::{Path, PathBuf}, - sync::{ - atomic::{AtomicBool, AtomicU64, Ordering}, - mpsc::channel, - Arc, Mutex, RwLock, - }, + sync::atomic::{AtomicBool, AtomicU64, Ordering}, + sync::{mpsc::channel, Arc, Mutex, RwLock}, thread::{self, Builder, JoinHandle}, }, tokio_util::codec::{BytesCodec, FramedRead}, @@ -491,9 +488,8 @@ mod tests { get_tmp_ledger_path, }, solana_runtime::{ - bank::Bank, - bank_forks::ArchiveFormat, - snapshot_utils::{SnapshotVersion, DEFAULT_MAX_SNAPSHOTS_TO_RETAIN}, + bank::Bank, bank_forks::ArchiveFormat, snapshot_utils::SnapshotVersion, + snapshot_utils::DEFAULT_MAX_SNAPSHOTS_TO_RETAIN, }, solana_sdk::{ genesis_config::{ClusterType, DEFAULT_GENESIS_ARCHIVE}, diff --git a/rpc/src/rpc_subscription_tracker.rs b/rpc/src/rpc_subscription_tracker.rs index c2bd05284e..2cca19a5fb 100644 --- a/rpc/src/rpc_subscription_tracker.rs +++ b/rpc/src/rpc_subscription_tracker.rs @@ -535,13 +535,11 @@ impl SubscriptionToken { #[cfg(test)] mod tests { - use { - super::*, - crate::rpc_pubsub_service::PubSubConfig, - solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}, - solana_runtime::bank::Bank, - std::str::FromStr, - }; + use super::*; + use crate::rpc_pubsub_service::PubSubConfig; + use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}; + use solana_runtime::bank::Bank; + use std::str::FromStr; struct ControlWrapper { control: SubscriptionControl, diff --git a/rpc/src/rpc_subscriptions.rs b/rpc/src/rpc_subscriptions.rs index b5c5e877c3..d2b7137322 100644 --- a/rpc/src/rpc_subscriptions.rs +++ b/rpc/src/rpc_subscriptions.rs @@ -48,7 +48,8 @@ use { Arc, Mutex, RwLock, Weak, }, thread::{Builder, JoinHandle}, - time::{Duration, Instant}, + time::Duration, + time::Instant, }, tokio::sync::broadcast, }; diff --git a/runtime/benches/accounts.rs b/runtime/benches/accounts.rs index a1c61ff93c..e94b595a5d 100644 --- a/runtime/benches/accounts.rs +++ b/runtime/benches/accounts.rs @@ -3,32 +3,30 @@ extern crate test; -use { - dashmap::DashMap, - rand::Rng, - rayon::iter::{IntoParallelRefIterator, ParallelIterator}, - solana_runtime::{ - accounts::{create_test_accounts, AccountAddressFilter, Accounts}, - accounts_db::AccountShrinkThreshold, - accounts_index::AccountSecondaryIndexes, - ancestors::Ancestors, - bank::*, - }, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, - genesis_config::{create_genesis_config, ClusterType}, - hash::Hash, - lamports::LamportsError, - pubkey::Pubkey, - }, - std::{ - collections::{HashMap, HashSet}, - path::PathBuf, - sync::{Arc, RwLock}, - thread::Builder, - }, - test::Bencher, +use dashmap::DashMap; +use rand::Rng; +use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; +use solana_runtime::{ + accounts::{create_test_accounts, AccountAddressFilter, Accounts}, + accounts_db::AccountShrinkThreshold, + accounts_index::AccountSecondaryIndexes, + ancestors::Ancestors, + bank::*, }; +use solana_sdk::{ + account::{AccountSharedData, ReadableAccount}, + genesis_config::{create_genesis_config, ClusterType}, + hash::Hash, + lamports::LamportsError, + pubkey::Pubkey, +}; +use std::{ + collections::{HashMap, HashSet}, + path::PathBuf, + sync::{Arc, RwLock}, + thread::Builder, +}; +use test::Bencher; fn deposit_many(bank: &Bank, pubkeys: &mut Vec, num: usize) -> Result<(), LamportsError> { for t in 0..num { diff --git a/runtime/benches/accounts_index.rs b/runtime/benches/accounts_index.rs index 384ade5e6c..98eb982140 100644 --- a/runtime/benches/accounts_index.rs +++ b/runtime/benches/accounts_index.rs @@ -2,15 +2,13 @@ extern crate test; -use { - rand::{thread_rng, Rng}, - solana_runtime::{ - accounts_db::AccountInfo, - accounts_index::{AccountSecondaryIndexes, AccountsIndex}, - }, - solana_sdk::pubkey::{self, Pubkey}, - test::Bencher, +use rand::{thread_rng, Rng}; +use solana_runtime::{ + accounts_db::AccountInfo, + accounts_index::{AccountSecondaryIndexes, AccountsIndex}, }; +use solana_sdk::pubkey::{self, Pubkey}; +use test::Bencher; #[bench] fn bench_accounts_index(bencher: &mut Bencher) { diff --git a/runtime/benches/append_vec.rs b/runtime/benches/append_vec.rs index a7bf8896d3..17e7eaf63d 100644 --- a/runtime/benches/append_vec.rs +++ b/runtime/benches/append_vec.rs @@ -1,20 +1,19 @@ #![feature(test)] extern crate test; -use { - rand::{thread_rng, Rng}, - solana_runtime::append_vec::{ - test_utils::{create_test_account, get_append_vec_path}, - AppendVec, - }, - solana_sdk::{account::ReadableAccount, hash::Hash}, - std::{ - sync::{Arc, Mutex}, - thread::{sleep, spawn}, - time::Duration, - }, - test::Bencher, +use rand::{thread_rng, Rng}; +use solana_runtime::append_vec::{ + test_utils::{create_test_account, get_append_vec_path}, + AppendVec, }; +use solana_sdk::{account::ReadableAccount, hash::Hash}; +use std::{ + sync::{Arc, Mutex}, + thread::sleep, + thread::spawn, + time::Duration, +}; +use test::Bencher; #[bench] fn append_vec_append(bencher: &mut Bencher) { diff --git a/runtime/benches/bank.rs b/runtime/benches/bank.rs index ffc58e99ef..22f7b48c06 100644 --- a/runtime/benches/bank.rs +++ b/runtime/benches/bank.rs @@ -3,23 +3,22 @@ extern crate test; -use { - log::*, - solana_runtime::{bank::*, bank_client::BankClient, loader_utils::create_invoke_instruction}, - solana_sdk::{ - client::{AsyncClient, SyncClient}, - clock::MAX_RECENT_BLOCKHASHES, - genesis_config::create_genesis_config, - instruction::InstructionError, - message::Message, - process_instruction::InvokeContext, - pubkey::Pubkey, - signature::{Keypair, Signer}, - transaction::Transaction, - }, - std::{sync::Arc, thread::sleep, time::Duration}, - test::Bencher, +use log::*; +use solana_runtime::{bank::*, bank_client::BankClient, loader_utils::create_invoke_instruction}; +use solana_sdk::{ + client::AsyncClient, + client::SyncClient, + clock::MAX_RECENT_BLOCKHASHES, + genesis_config::create_genesis_config, + instruction::InstructionError, + message::Message, + process_instruction::InvokeContext, + pubkey::Pubkey, + signature::{Keypair, Signer}, + transaction::Transaction, }; +use std::{sync::Arc, thread::sleep, time::Duration}; +use test::Bencher; const BUILTIN_PROGRAM_ID: [u8; 32] = [ 98, 117, 105, 108, 116, 105, 110, 95, 112, 114, 111, 103, 114, 97, 109, 95, 105, 100, 0, 0, 0, diff --git a/runtime/benches/bloom.rs b/runtime/benches/bloom.rs index ca2ed9de77..2a964e55cf 100644 --- a/runtime/benches/bloom.rs +++ b/runtime/benches/bloom.rs @@ -1,18 +1,17 @@ #![feature(test)] extern crate test; -use { - bv::BitVec, - fnv::FnvHasher, - rand::Rng, - solana_runtime::bloom::{AtomicBloom, Bloom, BloomHashIndex}, - solana_sdk::{ - hash::{hash, Hash}, - signature::Signature, - }, - std::{collections::HashSet, hash::Hasher}, - test::Bencher, +use bv::BitVec; +use fnv::FnvHasher; +use rand::Rng; +use solana_runtime::bloom::{AtomicBloom, Bloom, BloomHashIndex}; +use solana_sdk::{ + hash::{hash, Hash}, + signature::Signature, }; +use std::collections::HashSet; +use std::hash::Hasher; +use test::Bencher; #[bench] #[ignore] diff --git a/runtime/benches/message_processor.rs b/runtime/benches/message_processor.rs index 75e60a1c45..1a3665607f 100644 --- a/runtime/benches/message_processor.rs +++ b/runtime/benches/message_processor.rs @@ -2,12 +2,10 @@ extern crate test; -use { - log::*, - solana_runtime::message_processor::{ExecuteDetailsTimings, PreAccount}, - solana_sdk::{account::AccountSharedData, pubkey, rent::Rent}, - test::Bencher, -}; +use log::*; +use solana_runtime::message_processor::{ExecuteDetailsTimings, PreAccount}; +use solana_sdk::{account::AccountSharedData, pubkey, rent::Rent}; +use test::Bencher; #[bench] fn bench_verify_account_changes_data(bencher: &mut Bencher) { diff --git a/runtime/benches/status_cache.rs b/runtime/benches/status_cache.rs index bced5d55b7..66c4ec7883 100644 --- a/runtime/benches/status_cache.rs +++ b/runtime/benches/status_cache.rs @@ -2,15 +2,13 @@ extern crate test; -use { - bincode::serialize, - solana_runtime::status_cache::*, - solana_sdk::{ - hash::{hash, Hash}, - signature::Signature, - }, - test::Bencher, +use bincode::serialize; +use solana_runtime::status_cache::*; +use solana_sdk::{ + hash::{hash, Hash}, + signature::Signature, }; +use test::Bencher; type BankStatusCache = StatusCache<()>; diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 76e0d43deb..1f61e33303 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -1,48 +1,47 @@ -use { - crate::{ - accounts_db::{ - AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, BankHashInfo, ErrorCounters, - LoadHint, LoadedAccount, ScanStorageResult, - }, - accounts_index::{AccountSecondaryIndexes, IndexKey, ScanResult}, - accounts_update_notifier_interface::AccountsUpdateNotifier, - ancestors::Ancestors, - bank::{ - NonceRollbackFull, NonceRollbackInfo, RentDebits, TransactionCheckResult, - TransactionExecutionResult, - }, - blockhash_queue::BlockhashQueue, - rent_collector::RentCollector, - system_instruction_processor::{get_system_account_kind, SystemAccountKind}, +use crate::{ + accounts_db::{ + AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, BankHashInfo, ErrorCounters, + LoadHint, LoadedAccount, ScanStorageResult, }, - dashmap::{ - mapref::entry::Entry::{Occupied, Vacant}, - DashMap, - }, - log::*, - rand::{thread_rng, Rng}, - solana_sdk::{ - account::{Account, AccountSharedData, ReadableAccount, WritableAccount}, - account_utils::StateMut, - bpf_loader_upgradeable::{self, UpgradeableLoaderState}, - clock::{BankId, Slot, INITIAL_RENT_EPOCH}, - feature_set::{self, FeatureSet}, - fee_calculator::FeeCalculator, - genesis_config::ClusterType, - hash::Hash, - message::{Message, MessageProgramIdsCache}, - native_loader, - nonce::{self, NONCED_TX_MARKER_IX_INDEX}, - pubkey::Pubkey, - transaction::{Result, Transaction, TransactionError}, - }, - std::{ - cmp::Reverse, - collections::{hash_map, BinaryHeap, HashMap, HashSet}, - ops::RangeBounds, - path::PathBuf, - sync::{Arc, Mutex}, + accounts_index::{AccountSecondaryIndexes, IndexKey, ScanResult}, + accounts_update_notifier_interface::AccountsUpdateNotifier, + ancestors::Ancestors, + bank::{ + NonceRollbackFull, NonceRollbackInfo, RentDebits, TransactionCheckResult, + TransactionExecutionResult, }, + blockhash_queue::BlockhashQueue, + rent_collector::RentCollector, + system_instruction_processor::{get_system_account_kind, SystemAccountKind}, +}; +use dashmap::{ + mapref::entry::Entry::{Occupied, Vacant}, + DashMap, +}; +use log::*; +use rand::{thread_rng, Rng}; +use solana_sdk::{ + account::{Account, AccountSharedData, ReadableAccount, WritableAccount}, + account_utils::StateMut, + bpf_loader_upgradeable::{self, UpgradeableLoaderState}, + clock::{BankId, Slot, INITIAL_RENT_EPOCH}, + feature_set::{self, FeatureSet}, + fee_calculator::FeeCalculator, + genesis_config::ClusterType, + hash::Hash, + message::{Message, MessageProgramIdsCache}, + native_loader, nonce, + nonce::NONCED_TX_MARKER_IX_INDEX, + pubkey::Pubkey, + transaction::Result, + transaction::{Transaction, TransactionError}, +}; +use std::{ + cmp::Reverse, + collections::{hash_map, BinaryHeap, HashMap, HashSet}, + ops::RangeBounds, + path::PathBuf, + sync::{Arc, Mutex}, }; #[derive(Debug, Default, AbiExample)] @@ -1156,26 +1155,24 @@ pub fn update_accounts_bench(accounts: &Accounts, pubkeys: &[Pubkey], slot: u64) #[cfg(test)] mod tests { - use { - super::*, - crate::rent_collector::RentCollector, - solana_sdk::{ - account::{AccountSharedData, WritableAccount}, - epoch_schedule::EpochSchedule, - fee_calculator::FeeCalculator, - genesis_config::ClusterType, - hash::Hash, - instruction::{CompiledInstruction, InstructionError}, - message::Message, - nonce, nonce_account, - rent::Rent, - signature::{keypair_from_seed, Keypair, Signer}, - system_instruction, system_program, - }, - std::{ - sync::atomic::{AtomicBool, AtomicU64, Ordering}, - thread, time, - }, + use super::*; + use crate::rent_collector::RentCollector; + use solana_sdk::{ + account::{AccountSharedData, WritableAccount}, + epoch_schedule::EpochSchedule, + fee_calculator::FeeCalculator, + genesis_config::ClusterType, + hash::Hash, + instruction::{CompiledInstruction, InstructionError}, + message::Message, + nonce, nonce_account, + rent::Rent, + signature::{keypair_from_seed, Keypair, Signer}, + system_instruction, system_program, + }; + use std::{ + sync::atomic::{AtomicBool, AtomicU64, Ordering}, + {thread, time}, }; fn load_accounts_with_fee_and_rent( diff --git a/runtime/src/accounts_background_service.rs b/runtime/src/accounts_background_service.rs index 62272c5199..7b51615f67 100644 --- a/runtime/src/accounts_background_service.rs +++ b/runtime/src/accounts_background_service.rs @@ -2,31 +2,29 @@ // // This can be expensive since we have to walk the append vecs being cleaned up. -use { - crate::{ - bank::{Bank, BankSlotDelta, DropCallback}, - bank_forks::{BankForks, SnapshotConfig}, - snapshot_package::AccountsPackageSender, - snapshot_utils, - }, - crossbeam_channel::{Receiver, SendError, Sender}, - log::*, - rand::{thread_rng, Rng}, - solana_measure::measure::Measure, - solana_sdk::{ - clock::{BankId, Slot}, - hash::Hash, - }, - std::{ - boxed::Box, - fmt::{Debug, Formatter}, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, RwLock, - }, - thread::{self, sleep, Builder, JoinHandle}, - time::{Duration, Instant}, +use crate::{ + bank::{Bank, BankSlotDelta, DropCallback}, + bank_forks::{BankForks, SnapshotConfig}, + snapshot_package::AccountsPackageSender, + snapshot_utils, +}; +use crossbeam_channel::{Receiver, SendError, Sender}; +use log::*; +use rand::{thread_rng, Rng}; +use solana_measure::measure::Measure; +use solana_sdk::{ + clock::{BankId, Slot}, + hash::Hash, +}; +use std::{ + boxed::Box, + fmt::{Debug, Formatter}, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, RwLock, }, + thread::{self, sleep, Builder, JoinHandle}, + time::{Duration, Instant}, }; const INTERVAL_MS: u64 = 100; @@ -457,12 +455,10 @@ impl AccountsBackgroundService { #[cfg(test)] mod test { - use { - super::*, - crate::genesis_utils::create_genesis_config, - crossbeam_channel::unbounded, - solana_sdk::{account::AccountSharedData, pubkey::Pubkey}, - }; + use super::*; + use crate::genesis_utils::create_genesis_config; + use crossbeam_channel::unbounded; + use solana_sdk::{account::AccountSharedData, pubkey::Pubkey}; #[test] fn test_accounts_background_service_remove_dead_slots() { diff --git a/runtime/src/accounts_cache.rs b/runtime/src/accounts_cache.rs index 40acb1d7e5..cf0772a33e 100644 --- a/runtime/src/accounts_cache.rs +++ b/runtime/src/accounts_cache.rs @@ -1,19 +1,17 @@ -use { - dashmap::DashMap, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, - clock::Slot, - hash::Hash, - pubkey::Pubkey, - }, - std::{ - borrow::Borrow, - collections::BTreeSet, - ops::Deref, - sync::{ - atomic::{AtomicBool, AtomicU64, Ordering}, - Arc, RwLock, - }, +use dashmap::DashMap; +use solana_sdk::{ + account::{AccountSharedData, ReadableAccount}, + clock::Slot, + hash::Hash, + pubkey::Pubkey, +}; +use std::{ + borrow::Borrow, + collections::BTreeSet, + ops::Deref, + sync::{ + atomic::{AtomicBool, AtomicU64, Ordering}, + Arc, RwLock, }, }; diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index d6c337266e..871986fd70 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -18,64 +18,61 @@ //! tracks the number of commits to the entire data store. So the latest //! commit for each slot entry would be indexed. +use crate::{ + accounts_background_service::{DroppedSlotsSender, SendDroppedBankCallback}, + accounts_cache::{AccountsCache, CachedAccount, SlotCache}, + accounts_hash::{AccountsHash, CalculateHashIntermediate, HashStats, PreviousPass}, + accounts_index::{ + AccountIndexGetResult, AccountSecondaryIndexes, AccountsIndex, AccountsIndexRootsStats, + IndexKey, IsCached, ScanResult, SlotList, SlotSlice, ZeroLamport, + }, + accounts_update_notifier_interface::AccountsUpdateNotifier, + ancestors::Ancestors, + append_vec::{AppendVec, StoredAccountMeta, StoredMeta, StoredMetaWriteVersion}, + contains::Contains, + pubkey_bins::PubkeyBinCalculator16, + read_only_accounts_cache::ReadOnlyAccountsCache, + sorted_storages::SortedStorages, +}; +use blake3::traits::digest::Digest; +use crossbeam_channel::{unbounded, Receiver, Sender}; +use dashmap::{ + mapref::entry::Entry::{Occupied, Vacant}, + DashMap, DashSet, +}; +use lazy_static::lazy_static; +use log::*; +use rand::{prelude::SliceRandom, thread_rng, Rng}; +use rayon::{prelude::*, ThreadPool}; +use serde::{Deserialize, Serialize}; +use solana_measure::measure::Measure; +use solana_rayon_threadlimit::get_thread_count; +use solana_sdk::{ + account::{AccountSharedData, ReadableAccount}, + clock::{BankId, Epoch, Slot}, + genesis_config::ClusterType, + hash::{Hash, Hasher}, + pubkey::Pubkey, + timing::AtomicInterval, +}; +use solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY; +use std::{ + borrow::{Borrow, Cow}, + boxed::Box, + collections::{hash_map::Entry, BTreeSet, HashMap, HashSet}, + convert::TryFrom, + io::{Error as IoError, Result as IoResult}, + ops::{Range, RangeBounds}, + path::{Path, PathBuf}, + sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}, + sync::{Arc, Condvar, Mutex, MutexGuard, RwLock}, + thread::Builder, + time::Instant, +}; +use tempfile::TempDir; + #[cfg(test)] use std::{thread::sleep, time::Duration}; -use { - crate::{ - accounts_background_service::{DroppedSlotsSender, SendDroppedBankCallback}, - accounts_cache::{AccountsCache, CachedAccount, SlotCache}, - accounts_hash::{AccountsHash, CalculateHashIntermediate, HashStats, PreviousPass}, - accounts_index::{ - AccountIndexGetResult, AccountSecondaryIndexes, AccountsIndex, AccountsIndexRootsStats, - IndexKey, IsCached, ScanResult, SlotList, SlotSlice, ZeroLamport, - }, - accounts_update_notifier_interface::AccountsUpdateNotifier, - ancestors::Ancestors, - append_vec::{AppendVec, StoredAccountMeta, StoredMeta, StoredMetaWriteVersion}, - contains::Contains, - pubkey_bins::PubkeyBinCalculator16, - read_only_accounts_cache::ReadOnlyAccountsCache, - sorted_storages::SortedStorages, - }, - blake3::traits::digest::Digest, - crossbeam_channel::{unbounded, Receiver, Sender}, - dashmap::{ - mapref::entry::Entry::{Occupied, Vacant}, - DashMap, DashSet, - }, - lazy_static::lazy_static, - log::*, - rand::{prelude::SliceRandom, thread_rng, Rng}, - rayon::{prelude::*, ThreadPool}, - serde::{Deserialize, Serialize}, - solana_measure::measure::Measure, - solana_rayon_threadlimit::get_thread_count, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, - clock::{BankId, Epoch, Slot}, - genesis_config::ClusterType, - hash::{Hash, Hasher}, - pubkey::Pubkey, - timing::AtomicInterval, - }, - solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY, - std::{ - borrow::{Borrow, Cow}, - boxed::Box, - collections::{hash_map::Entry, BTreeSet, HashMap, HashSet}, - convert::TryFrom, - io::{Error as IoError, Result as IoResult}, - ops::{Range, RangeBounds}, - path::{Path, PathBuf}, - sync::{ - atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}, - Arc, Condvar, Mutex, MutexGuard, RwLock, - }, - thread::Builder, - time::Instant, - }, - tempfile::TempDir, -}; const PAGE_SIZE: u64 = 4 * 1024; const MAX_RECYCLE_STORES: usize = 1000; @@ -6331,29 +6328,26 @@ impl AccountsDb { #[cfg(test)] pub mod tests { - use { - super::*, - crate::{ - accounts_hash::MERKLE_FANOUT, - accounts_index::{tests::*, AccountSecondaryIndexesIncludeExclude, RefCount}, - append_vec::{test_utils::TempFile, AccountMeta}, - inline_spl_token, - }, - assert_matches::assert_matches, - rand::{thread_rng, Rng}, - solana_sdk::{ - account::{ - accounts_equal, Account, AccountSharedData, ReadableAccount, WritableAccount, - }, - hash::HASH_BYTES, - pubkey::PUBKEY_BYTES, - }, - std::{ - iter::FromIterator, - str::FromStr, - thread::{self, sleep, Builder, JoinHandle}, - time::Duration, - }, + use super::*; + use crate::{ + accounts_hash::MERKLE_FANOUT, + accounts_index::RefCount, + accounts_index::{tests::*, AccountSecondaryIndexesIncludeExclude}, + append_vec::{test_utils::TempFile, AccountMeta}, + inline_spl_token, + }; + use assert_matches::assert_matches; + use rand::{thread_rng, Rng}; + use solana_sdk::{ + account::{accounts_equal, Account, AccountSharedData, ReadableAccount, WritableAccount}, + hash::HASH_BYTES, + pubkey::PUBKEY_BYTES, + }; + use std::{ + iter::FromIterator, + str::FromStr, + thread::{self, sleep, Builder, JoinHandle}, + time::Duration, }; fn linear_ancestors(end_slot: u64) -> Ancestors { diff --git a/runtime/src/accounts_hash.rs b/runtime/src/accounts_hash.rs index 8122628eec..a5827dd21b 100644 --- a/runtime/src/accounts_hash.rs +++ b/runtime/src/accounts_hash.rs @@ -1,13 +1,11 @@ -use { - log::*, - rayon::prelude::*, - solana_measure::measure::Measure, - solana_sdk::{ - hash::{Hash, Hasher}, - pubkey::Pubkey, - }, - std::{convert::TryInto, sync::Mutex}, +use log::*; +use rayon::prelude::*; +use solana_measure::measure::Measure; +use solana_sdk::{ + hash::{Hash, Hasher}, + pubkey::Pubkey, }; +use std::{convert::TryInto, sync::Mutex}; pub const ZERO_RAW_LAMPORTS_SENTINEL: u64 = std::u64::MAX; pub const MERKLE_FANOUT: usize = 16; @@ -784,7 +782,8 @@ impl AccountsHash { #[cfg(test)] pub mod tests { - use {super::*, std::str::FromStr}; + use super::*; + use std::str::FromStr; #[test] fn test_accountsdb_div_ceil() { diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index b0a68b9a1c..b36316707e 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -1,35 +1,33 @@ -use { - crate::{ - ancestors::Ancestors, - contains::Contains, - inline_spl_token::{self, SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET}, - secondary_index::*, - }, - bv::BitVec, - log::*, - ouroboros::self_referencing, - solana_measure::measure::Measure, - solana_sdk::{ - clock::{BankId, Slot}, - pubkey::{Pubkey, PUBKEY_BYTES}, - }, - std::{ - collections::{ - btree_map::{self, BTreeMap, Entry}, - HashSet, - }, - ops::{ - Bound, - Bound::{Excluded, Included, Unbounded}, - Range, RangeBounds, - }, - sync::{ - atomic::{AtomicU64, Ordering}, - Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard, - }, - }, - thiserror::Error, +use crate::{ + ancestors::Ancestors, + contains::Contains, + inline_spl_token::{self, SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET}, + secondary_index::*, }; +use bv::BitVec; +use log::*; +use ouroboros::self_referencing; +use solana_measure::measure::Measure; +use solana_sdk::{ + clock::{BankId, Slot}, + pubkey::{Pubkey, PUBKEY_BYTES}, +}; +use std::{ + collections::{ + btree_map::{self, BTreeMap, Entry}, + HashSet, + }, + ops::{ + Bound, + Bound::{Excluded, Included, Unbounded}, + Range, RangeBounds, + }, + sync::{ + atomic::{AtomicU64, Ordering}, + Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard, + }, +}; +use thiserror::Error; pub const ITER_BATCH_SIZE: usize = 1000; const BINS: usize = 16; @@ -1735,10 +1733,8 @@ impl { RwLock(&'a SecondaryIndex), diff --git a/runtime/src/ancestors.rs b/runtime/src/ancestors.rs index 7960018cdf..5c5e16bcea 100644 --- a/runtime/src/ancestors.rs +++ b/runtime/src/ancestors.rs @@ -1,4 +1,6 @@ -use {crate::accounts_index::RollingBitField, solana_sdk::clock::Slot, std::collections::HashMap}; +use crate::accounts_index::RollingBitField; +use solana_sdk::clock::Slot; +use std::collections::HashMap; pub type AncestorsForSerialization = HashMap; @@ -80,10 +82,11 @@ impl Ancestors { } #[cfg(test)] pub mod tests { - use { - super::*, crate::contains::Contains, log::*, solana_measure::measure::Measure, - std::collections::HashSet, - }; + use super::*; + use crate::contains::Contains; + use log::*; + use solana_measure::measure::Measure; + use std::collections::HashSet; impl std::iter::FromIterator<(Slot, usize)> for Ancestors { fn from_iter(iter: I) -> Self diff --git a/runtime/src/append_vec.rs b/runtime/src/append_vec.rs index d091eb729c..1f8f9744ea 100644 --- a/runtime/src/append_vec.rs +++ b/runtime/src/append_vec.rs @@ -1,27 +1,24 @@ //! Persistent storage for accounts. For more information, see: //! https://docs.solana.com/implemented-proposals/persistent-account-storage -use { - log::*, - memmap2::MmapMut, - serde::{Deserialize, Serialize}, - solana_sdk::{ - account::{Account, AccountSharedData, ReadableAccount}, - clock::{Epoch, Slot}, - hash::Hash, - pubkey::Pubkey, - }, - std::{ - borrow::Borrow, - fs::{remove_file, OpenOptions}, - io::{self, Seek, SeekFrom, Write}, - mem, - path::{Path, PathBuf}, - sync::{ - atomic::{AtomicUsize, Ordering}, - Mutex, - }, - }, +use log::*; +use memmap2::MmapMut; +use serde::{Deserialize, Serialize}; +use solana_sdk::{ + account::{Account, AccountSharedData, ReadableAccount}, + clock::{Epoch, Slot}, + hash::Hash, + pubkey::Pubkey, +}; +use std::{ + borrow::Borrow, + fs::{remove_file, OpenOptions}, + io, + io::{Seek, SeekFrom, Write}, + mem, + path::{Path, PathBuf}, + sync::atomic::{AtomicUsize, Ordering}, + sync::Mutex, }; // Data placement should be aligned at the next boundary. Without alignment accessing the memory may @@ -529,12 +526,13 @@ impl AppendVec { } pub mod test_utils { - use { - super::StoredMeta, - rand::{distributions::Alphanumeric, thread_rng, Rng}, - solana_sdk::{account::AccountSharedData, pubkey::Pubkey}, - std::{fs::create_dir_all, path::PathBuf}, - }; + use super::StoredMeta; + use rand::distributions::Alphanumeric; + use rand::{thread_rng, Rng}; + use solana_sdk::account::AccountSharedData; + use solana_sdk::pubkey::Pubkey; + use std::fs::create_dir_all; + use std::path::PathBuf; pub struct TempFile { pub path: PathBuf, @@ -577,13 +575,12 @@ pub mod test_utils { #[cfg(test)] pub mod tests { - use { - super::{test_utils::*, *}, - assert_matches::assert_matches, - rand::{thread_rng, Rng}, - solana_sdk::{account::WritableAccount, timing::duration_as_ms}, - std::time::Instant, - }; + use super::test_utils::*; + use super::*; + use assert_matches::assert_matches; + use rand::{thread_rng, Rng}; + use solana_sdk::{account::WritableAccount, timing::duration_as_ms}; + use std::time::Instant; impl AppendVec { fn append_account_test(&self, data: &(StoredMeta, AccountSharedData)) -> Option { diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 7345ec78b7..5e10cc2320 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -33,112 +33,111 @@ //! It offers a high-level API that signs transactions //! on behalf of the caller, and a low-level API for when they have //! already been signed and verified. -use { - crate::{ - accounts::{ - AccountAddressFilter, Accounts, TransactionAccounts, TransactionLoadResult, - TransactionLoaders, - }, - accounts_db::{AccountShrinkThreshold, ErrorCounters, SnapshotStorages}, - accounts_index::{AccountSecondaryIndexes, IndexKey, ScanResult}, - accounts_update_notifier_interface::AccountsUpdateNotifier, - ancestors::{Ancestors, AncestorsForSerialization}, - blockhash_queue::BlockhashQueue, - builtins::{self, ActivationType}, - cost_tracker::CostTracker, - epoch_stakes::{EpochStakes, NodeVoteAccounts}, - hashed_transaction::{HashedTransaction, HashedTransactionSlice}, - inline_spl_token, - instruction_recorder::InstructionRecorder, - log_collector::LogCollector, - message_processor::{ExecuteDetailsTimings, Executors, MessageProcessor}, - rent_collector::RentCollector, - stake_weighted_timestamp::{ - calculate_stake_weighted_timestamp, MaxAllowableDrift, MAX_ALLOWABLE_DRIFT_PERCENTAGE, - MAX_ALLOWABLE_DRIFT_PERCENTAGE_FAST, MAX_ALLOWABLE_DRIFT_PERCENTAGE_SLOW, - }, - stakes::Stakes, - status_cache::{SlotDelta, StatusCache}, - system_instruction_processor::{get_system_account_kind, SystemAccountKind}, - transaction_batch::TransactionBatch, - vote_account::ArcVoteAccount, +use crate::{ + accounts::{ + AccountAddressFilter, Accounts, TransactionAccounts, TransactionLoadResult, + TransactionLoaders, }, - byteorder::{ByteOrder, LittleEndian}, - dashmap::DashMap, - itertools::Itertools, - log::*, - rayon::{ - iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator}, - ThreadPool, ThreadPoolBuilder, + accounts_db::{AccountShrinkThreshold, ErrorCounters, SnapshotStorages}, + accounts_index::{AccountSecondaryIndexes, IndexKey, ScanResult}, + accounts_update_notifier_interface::AccountsUpdateNotifier, + ancestors::{Ancestors, AncestorsForSerialization}, + blockhash_queue::BlockhashQueue, + builtins::{self, ActivationType}, + cost_tracker::CostTracker, + epoch_stakes::{EpochStakes, NodeVoteAccounts}, + hashed_transaction::{HashedTransaction, HashedTransactionSlice}, + inline_spl_token, + instruction_recorder::InstructionRecorder, + log_collector::LogCollector, + message_processor::{ExecuteDetailsTimings, Executors, MessageProcessor}, + rent_collector::RentCollector, + stake_weighted_timestamp::{ + calculate_stake_weighted_timestamp, MaxAllowableDrift, MAX_ALLOWABLE_DRIFT_PERCENTAGE, + MAX_ALLOWABLE_DRIFT_PERCENTAGE_FAST, MAX_ALLOWABLE_DRIFT_PERCENTAGE_SLOW, }, - solana_measure::measure::Measure, - solana_metrics::{inc_new_counter_debug, inc_new_counter_info}, - solana_sdk::{ - account::{ - create_account_shared_data_with_fields as create_account, from_account, Account, - AccountSharedData, InheritableAccountFields, ReadableAccount, WritableAccount, - }, - account_utils::StateMut, - clock::{ - BankId, Epoch, Slot, SlotCount, SlotIndex, UnixTimestamp, DEFAULT_TICKS_PER_SECOND, - INITIAL_RENT_EPOCH, MAX_PROCESSING_AGE, MAX_RECENT_BLOCKHASHES, - MAX_TRANSACTION_FORWARDING_DELAY, SECONDS_PER_DAY, - }, - compute_budget, - epoch_info::EpochInfo, - epoch_schedule::EpochSchedule, - feature, - feature_set::{self, tx_wide_compute_cap, FeatureSet}, - fee_calculator::{FeeCalculator, FeeRateGovernor}, - genesis_config::{ClusterType, GenesisConfig}, - hard_forks::HardForks, - hash::{extend_and_hash, hashv, Hash}, - incinerator, - inflation::Inflation, - instruction::{CompiledInstruction, InstructionError}, - lamports::LamportsError, - message::Message, - native_loader, - native_token::sol_to_lamports, - nonce, nonce_account, - process_instruction::{ - BpfComputeBudget, ComputeMeter, Executor, ProcessInstructionWithContext, - }, - program_utils::limited_deserialize, - pubkey::Pubkey, - recent_blockhashes_account, - sanitize::Sanitize, - signature::{Keypair, Signature}, - slot_hashes::SlotHashes, - slot_history::SlotHistory, - system_transaction, - sysvar::{self}, - timing::years_as_slots, - transaction::{self, Result, Transaction, TransactionError}, + stakes::Stakes, + status_cache::{SlotDelta, StatusCache}, + system_instruction_processor::{get_system_account_kind, SystemAccountKind}, + transaction_batch::TransactionBatch, + vote_account::ArcVoteAccount, +}; +use byteorder::{ByteOrder, LittleEndian}; +use dashmap::DashMap; +use itertools::Itertools; +use log::*; +use rayon::{ + iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator}, + ThreadPool, ThreadPoolBuilder, +}; +use solana_measure::measure::Measure; +use solana_metrics::{inc_new_counter_debug, inc_new_counter_info}; +use solana_sdk::{ + account::{ + create_account_shared_data_with_fields as create_account, from_account, Account, + AccountSharedData, InheritableAccountFields, ReadableAccount, WritableAccount, }, - solana_stake_program::stake_state::{ - self, Delegation, InflationPointCalculationEvent, PointValue, StakeState, + account_utils::StateMut, + clock::{ + BankId, Epoch, Slot, SlotCount, SlotIndex, UnixTimestamp, DEFAULT_TICKS_PER_SECOND, + INITIAL_RENT_EPOCH, MAX_PROCESSING_AGE, MAX_RECENT_BLOCKHASHES, + MAX_TRANSACTION_FORWARDING_DELAY, SECONDS_PER_DAY, }, - solana_vote_program::{ - vote_instruction::VoteInstruction, - vote_state::{VoteState, VoteStateVersions}, + compute_budget, + epoch_info::EpochInfo, + epoch_schedule::EpochSchedule, + feature, + feature_set::{self, tx_wide_compute_cap, FeatureSet}, + fee_calculator::{FeeCalculator, FeeRateGovernor}, + genesis_config::{ClusterType, GenesisConfig}, + hard_forks::HardForks, + hash::{extend_and_hash, hashv, Hash}, + incinerator, + inflation::Inflation, + instruction::{CompiledInstruction, InstructionError}, + lamports::LamportsError, + message::Message, + native_loader, + native_token::sol_to_lamports, + nonce, nonce_account, + process_instruction::{ + BpfComputeBudget, ComputeMeter, Executor, ProcessInstructionWithContext, }, - std::{ - borrow::Cow, - cell::RefCell, - collections::{HashMap, HashSet}, - convert::{TryFrom, TryInto}, - fmt, mem, - ops::RangeInclusive, - path::PathBuf, - ptr, - rc::Rc, - sync::{ - atomic::{AtomicBool, AtomicU64, Ordering::Relaxed}, - Arc, LockResult, RwLock, RwLockReadGuard, RwLockWriteGuard, - }, - time::{Duration, Instant}, + program_utils::limited_deserialize, + pubkey::Pubkey, + recent_blockhashes_account, + sanitize::Sanitize, + signature::{Keypair, Signature}, + slot_hashes::SlotHashes, + slot_history::SlotHistory, + system_transaction, + sysvar::{self}, + timing::years_as_slots, + transaction::{self, Result, Transaction, TransactionError}, +}; +use solana_stake_program::stake_state::{ + self, Delegation, InflationPointCalculationEvent, PointValue, StakeState, +}; +use solana_vote_program::{ + vote_instruction::VoteInstruction, + vote_state::{VoteState, VoteStateVersions}, +}; +use std::{ + borrow::Cow, + cell::RefCell, + collections::{HashMap, HashSet}, + convert::{TryFrom, TryInto}, + fmt, mem, + ops::RangeInclusive, + path::PathBuf, + ptr, + rc::Rc, + sync::{ + atomic::{AtomicBool, AtomicU64, Ordering::Relaxed}, + LockResult, RwLockWriteGuard, {Arc, RwLock, RwLockReadGuard}, }, + time::Duration, + time::Instant, }; pub const SECONDS_PER_YEAR: f64 = 365.25 * 24.0 * 60.0 * 60.0; @@ -6054,55 +6053,52 @@ fn is_simple_vote_transaction(transaction: &Transaction) -> bool { #[cfg(test)] pub(crate) mod tests { - use { - super::*, - crate::{ - accounts_background_service::{AbsRequestHandler, SendDroppedBankCallback}, - accounts_db::DEFAULT_ACCOUNTS_SHRINK_RATIO, - accounts_index::{ - AccountIndex, AccountMap, AccountSecondaryIndexes, ScanError, ITER_BATCH_SIZE, - }, - ancestors::Ancestors, - genesis_utils::{ - activate_all_features, bootstrap_validator_stake_lamports, - create_genesis_config_with_leader, create_genesis_config_with_vote_accounts, - GenesisConfigInfo, ValidatorVoteKeypairs, - }, - status_cache::MAX_CACHE_ENTRIES, + use super::*; + use crate::{ + accounts_background_service::{AbsRequestHandler, SendDroppedBankCallback}, + accounts_db::DEFAULT_ACCOUNTS_SHRINK_RATIO, + accounts_index::{ + AccountIndex, AccountMap, AccountSecondaryIndexes, ScanError, ITER_BATCH_SIZE, }, - crossbeam_channel::{bounded, unbounded}, - solana_sdk::{ - account::Account, - clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT}, - compute_budget, - epoch_schedule::MINIMUM_SLOTS_PER_EPOCH, - feature::Feature, - genesis_config::create_genesis_config, - instruction::{AccountMeta, CompiledInstruction, Instruction, InstructionError}, - message::{Message, MessageHeader}, - nonce, - poh_config::PohConfig, - process_instruction::InvokeContext, - rent::Rent, - signature::{keypair_from_seed, Keypair, Signer}, - stake::{ - instruction as stake_instruction, - state::{Authorized, Delegation, Lockup, Stake}, - }, - system_instruction::{self, SystemError}, - system_program, - sysvar::{fees::Fees, rewards::Rewards}, - timing::duration_as_s, + ancestors::Ancestors, + genesis_utils::{ + activate_all_features, bootstrap_validator_stake_lamports, + create_genesis_config_with_leader, create_genesis_config_with_vote_accounts, + GenesisConfigInfo, ValidatorVoteKeypairs, }, - solana_vote_program::{ - vote_instruction, - vote_state::{ - self, BlockTimestamp, Vote, VoteInit, VoteState, VoteStateVersions, - MAX_LOCKOUT_HISTORY, - }, - }, - std::{result, thread::Builder, time::Duration}, + status_cache::MAX_CACHE_ENTRIES, }; + use crossbeam_channel::{bounded, unbounded}; + use solana_sdk::{ + account::Account, + clock::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT}, + compute_budget, + epoch_schedule::MINIMUM_SLOTS_PER_EPOCH, + feature::Feature, + genesis_config::create_genesis_config, + instruction::{AccountMeta, CompiledInstruction, Instruction, InstructionError}, + message::{Message, MessageHeader}, + nonce, + poh_config::PohConfig, + process_instruction::InvokeContext, + rent::Rent, + signature::{keypair_from_seed, Keypair, Signer}, + stake::{ + instruction as stake_instruction, + state::{Authorized, Delegation, Lockup, Stake}, + }, + system_instruction::{self, SystemError}, + system_program, + sysvar::{fees::Fees, rewards::Rewards}, + timing::duration_as_s, + }; + use solana_vote_program::{ + vote_instruction, + vote_state::{ + self, BlockTimestamp, Vote, VoteInit, VoteState, VoteStateVersions, MAX_LOCKOUT_HISTORY, + }, + }; + use std::{result, thread::Builder, time::Duration}; #[test] fn test_nonce_rollback_info() { diff --git a/runtime/src/bank_client.rs b/runtime/src/bank_client.rs index 573f037110..0033614ff1 100644 --- a/runtime/src/bank_client.rs +++ b/runtime/src/bank_client.rs @@ -1,30 +1,28 @@ -use { - crate::bank::Bank, - solana_sdk::{ - account::Account, - client::{AsyncClient, Client, SyncClient}, - commitment_config::CommitmentConfig, - epoch_info::EpochInfo, - fee_calculator::{FeeCalculator, FeeRateGovernor}, - hash::Hash, - instruction::Instruction, - message::Message, - pubkey::Pubkey, - signature::{Keypair, Signature, Signer}, - signers::Signers, - system_instruction, - transaction::{self, Transaction}, - transport::{Result, TransportError}, - }, - std::{ - io, - sync::{ - mpsc::{channel, Receiver, Sender}, - Arc, Mutex, - }, - thread::{sleep, Builder}, - time::{Duration, Instant}, +use crate::bank::Bank; +use solana_sdk::{ + account::Account, + client::{AsyncClient, Client, SyncClient}, + commitment_config::CommitmentConfig, + epoch_info::EpochInfo, + fee_calculator::{FeeCalculator, FeeRateGovernor}, + hash::Hash, + instruction::Instruction, + message::Message, + pubkey::Pubkey, + signature::{Keypair, Signature, Signer}, + signers::Signers, + system_instruction, + transaction::{self, Transaction}, + transport::{Result, TransportError}, +}; +use std::{ + io, + sync::{ + mpsc::{channel, Receiver, Sender}, + Arc, Mutex, }, + thread::{sleep, Builder}, + time::{Duration, Instant}, }; pub struct BankClient { @@ -309,10 +307,8 @@ impl BankClient { #[cfg(test)] mod tests { - use { - super::*, - solana_sdk::{genesis_config::create_genesis_config, instruction::AccountMeta}, - }; + use super::*; + use solana_sdk::{genesis_config::create_genesis_config, instruction::AccountMeta}; #[test] fn test_bank_client_new_with_keypairs() { diff --git a/runtime/src/bank_forks.rs b/runtime/src/bank_forks.rs index a283c0fd29..d6d50c6a29 100644 --- a/runtime/src/bank_forks.rs +++ b/runtime/src/bank_forks.rs @@ -1,22 +1,21 @@ //! The `bank_forks` module implements BankForks a DAG of checkpointed Banks -pub use crate::snapshot_utils::SnapshotVersion; -use { - crate::{ - accounts_background_service::{AbsRequestSender, SnapshotRequest}, - bank::Bank, - }, - log::*, - solana_measure::measure::Measure, - solana_sdk::{clock::Slot, hash::Hash, timing}, - std::{ - collections::{hash_map::Entry, HashMap, HashSet}, - ops::Index, - path::PathBuf, - sync::Arc, - time::Instant, - }, +use crate::{ + accounts_background_service::{AbsRequestSender, SnapshotRequest}, + bank::Bank, }; +use log::*; +use solana_measure::measure::Measure; +use solana_sdk::{clock::Slot, hash::Hash, timing}; +use std::{ + collections::{hash_map::Entry, HashMap, HashSet}, + ops::Index, + path::PathBuf, + sync::Arc, + time::Instant, +}; + +pub use crate::snapshot_utils::SnapshotVersion; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum ArchiveFormat { @@ -522,23 +521,21 @@ impl BankForks { #[cfg(test)] mod tests { - use { - super::*, - crate::{ - bank::tests::update_vote_account_timestamp, - genesis_utils::{ - create_genesis_config, create_genesis_config_with_leader, GenesisConfigInfo, - }, + use super::*; + use crate::{ + bank::tests::update_vote_account_timestamp, + genesis_utils::{ + create_genesis_config, create_genesis_config_with_leader, GenesisConfigInfo, }, - solana_sdk::{ - clock::UnixTimestamp, - hash::Hash, - pubkey::Pubkey, - signature::{Keypair, Signer}, - sysvar::epoch_schedule::EpochSchedule, - }, - solana_vote_program::vote_state::BlockTimestamp, }; + use solana_sdk::hash::Hash; + use solana_sdk::{ + clock::UnixTimestamp, + pubkey::Pubkey, + signature::{Keypair, Signer}, + sysvar::epoch_schedule::EpochSchedule, + }; + use solana_vote_program::vote_state::BlockTimestamp; #[test] fn test_bank_forks_new() { diff --git a/runtime/src/bank_utils.rs b/runtime/src/bank_utils.rs index b862f40dde..84d19a9093 100644 --- a/runtime/src/bank_utils.rs +++ b/runtime/src/bank_utils.rs @@ -1,13 +1,11 @@ -use { - crate::{ - bank::{Bank, TransactionResults}, - genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs}, - hashed_transaction::HashedTransaction, - vote_sender_types::ReplayVoteSender, - }, - solana_sdk::{pubkey::Pubkey, signature::Signer}, - solana_vote_program::vote_transaction, +use crate::{ + bank::{Bank, TransactionResults}, + genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs}, + hashed_transaction::HashedTransaction, + vote_sender_types::ReplayVoteSender, }; +use solana_sdk::{pubkey::Pubkey, signature::Signer}; +use solana_vote_program::vote_transaction; pub fn setup_bank_and_vote_pubkeys(num_vote_accounts: usize, stake: u64) -> (Bank, Vec) { // Create some voters at genesis diff --git a/runtime/src/block_cost_limits.rs b/runtime/src/block_cost_limits.rs index 97be8a062d..11243fc3fd 100644 --- a/runtime/src/block_cost_limits.rs +++ b/runtime/src/block_cost_limits.rs @@ -1,12 +1,10 @@ //! defines block cost related limits //! -use { - lazy_static::lazy_static, - solana_sdk::{ - feature, incinerator, native_loader, pubkey::Pubkey, secp256k1_program, system_program, - }, - std::collections::HashMap, +use lazy_static::lazy_static; +use solana_sdk::{ + feature, incinerator, native_loader, pubkey::Pubkey, secp256k1_program, system_program, }; +use std::collections::HashMap; /// Static configurations: /// diff --git a/runtime/src/blockhash_queue.rs b/runtime/src/blockhash_queue.rs index e7ca527384..5e2b76f3b5 100644 --- a/runtime/src/blockhash_queue.rs +++ b/runtime/src/blockhash_queue.rs @@ -1,10 +1,8 @@ -use { - serde::{Deserialize, Serialize}, - solana_sdk::{ - fee_calculator::FeeCalculator, hash::Hash, sysvar::recent_blockhashes, timing::timestamp, - }, - std::collections::HashMap, +use serde::{Deserialize, Serialize}; +use solana_sdk::{ + fee_calculator::FeeCalculator, hash::Hash, sysvar::recent_blockhashes, timing::timestamp, }; +use std::collections::HashMap; #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, AbiExample)] struct HashAge { @@ -135,12 +133,10 @@ impl BlockhashQueue { } #[cfg(test)] mod tests { - use { - super::*, - bincode::serialize, - solana_sdk::{ - clock::MAX_RECENT_BLOCKHASHES, hash::hash, sysvar::recent_blockhashes::IterItem, - }, + use super::*; + use bincode::serialize; + use solana_sdk::{ + clock::MAX_RECENT_BLOCKHASHES, hash::hash, sysvar::recent_blockhashes::IterItem, }; #[test] diff --git a/runtime/src/bloom.rs b/runtime/src/bloom.rs index d6fab3a078..2fde18a038 100644 --- a/runtime/src/bloom.rs +++ b/runtime/src/bloom.rs @@ -1,17 +1,12 @@ //! Simple Bloom Filter -use { - bv::BitVec, - fnv::FnvHasher, - rand::{self, Rng}, - serde::{Deserialize, Serialize}, - solana_sdk::sanitize::{Sanitize, SanitizeError}, - std::{ - cmp, fmt, - hash::Hasher, - marker::PhantomData, - sync::atomic::{AtomicU64, Ordering}, - }, -}; +use bv::BitVec; +use fnv::FnvHasher; +use rand::{self, Rng}; +use serde::{Deserialize, Serialize}; +use solana_sdk::sanitize::{Sanitize, SanitizeError}; +use std::fmt; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::{cmp, hash::Hasher, marker::PhantomData}; /// Generate a stable hash of `self` for each `hash_index` /// Best effort can be made for uniqueness of each hash. @@ -222,11 +217,9 @@ impl From> for Bloom { #[cfg(test)] mod test { - use { - super::*, - rayon::prelude::*, - solana_sdk::hash::{hash, Hash}, - }; + use super::*; + use rayon::prelude::*; + use solana_sdk::hash::{hash, Hash}; #[test] fn test_bloom_filter() { diff --git a/runtime/src/builtins.rs b/runtime/src/builtins.rs index fc1ccb886e..dc9c717bbc 100644 --- a/runtime/src/builtins.rs +++ b/runtime/src/builtins.rs @@ -1,15 +1,13 @@ -use { - crate::{ - bank::{Builtin, Builtins}, - system_instruction_processor, - }, - solana_sdk::{ - feature_set, - instruction::InstructionError, - process_instruction::{stable_log, InvokeContext, ProcessInstructionWithContext}, - pubkey::Pubkey, - stake, system_program, - }, +use crate::{ + bank::{Builtin, Builtins}, + system_instruction_processor, +}; +use solana_sdk::{ + feature_set, + instruction::InstructionError, + process_instruction::{stable_log, InvokeContext, ProcessInstructionWithContext}, + pubkey::Pubkey, + stake, system_program, }; fn process_instruction_with_program_logging( diff --git a/runtime/src/commitment.rs b/runtime/src/commitment.rs index cb420e05bb..603bfc2352 100644 --- a/runtime/src/commitment.rs +++ b/runtime/src/commitment.rs @@ -1,8 +1,6 @@ -use { - solana_sdk::{clock::Slot, commitment_config::CommitmentLevel}, - solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY, - std::collections::HashMap, -}; +use solana_sdk::{clock::Slot, commitment_config::CommitmentLevel}; +use solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY; +use std::collections::HashMap; pub const VOTE_THRESHOLD_SIZE: f64 = 2f64 / 3f64; diff --git a/runtime/src/cost_model.rs b/runtime/src/cost_model.rs index 075497ab76..2c7a27ff23 100644 --- a/runtime/src/cost_model.rs +++ b/runtime/src/cost_model.rs @@ -4,12 +4,10 @@ //! //! The main function is `calculate_cost` which returns &TransactionCost. //! -use { - crate::{block_cost_limits::*, execute_cost_table::ExecuteCostTable}, - log::*, - solana_sdk::{pubkey::Pubkey, transaction::Transaction}, - std::collections::HashMap, -}; +use crate::{block_cost_limits::*, execute_cost_table::ExecuteCostTable}; +use log::*; +use solana_sdk::{pubkey::Pubkey, transaction::Transaction}; +use std::collections::HashMap; const MAX_WRITABLE_ACCOUNTS: usize = 256; @@ -182,26 +180,24 @@ impl CostModel { #[cfg(test)] mod tests { - use { - super::*, - crate::{ - bank::Bank, - genesis_utils::{create_genesis_config, GenesisConfigInfo}, - }, - solana_sdk::{ - bpf_loader, - hash::Hash, - instruction::CompiledInstruction, - message::Message, - signature::{Keypair, Signer}, - system_instruction::{self}, - system_program, system_transaction, - }, - std::{ - str::FromStr, - sync::{Arc, RwLock}, - thread::{self, JoinHandle}, - }, + use super::*; + use crate::{ + bank::Bank, + genesis_utils::{create_genesis_config, GenesisConfigInfo}, + }; + use solana_sdk::{ + bpf_loader, + hash::Hash, + instruction::CompiledInstruction, + message::Message, + signature::{Keypair, Signer}, + system_instruction::{self}, + system_program, system_transaction, + }; + use std::{ + str::FromStr, + sync::{Arc, RwLock}, + thread::{self, JoinHandle}, }; fn test_setup() -> (Keypair, Hash) { diff --git a/runtime/src/cost_tracker.rs b/runtime/src/cost_tracker.rs index d2aa08c709..ae08a70492 100644 --- a/runtime/src/cost_tracker.rs +++ b/runtime/src/cost_tracker.rs @@ -3,11 +3,10 @@ //! - would_transaction_fit(&tx_cost), immutable function to test if tx with tx_cost would fit into current block //! - add_transaction_cost(&tx_cost), mutable function to accumulate tx_cost to tracker. //! -use { - crate::{block_cost_limits::*, cost_model::TransactionCost}, - solana_sdk::{clock::Slot, pubkey::Pubkey, transaction::Transaction}, - std::collections::HashMap, -}; +use crate::block_cost_limits::*; +use crate::cost_model::TransactionCost; +use solana_sdk::{clock::Slot, pubkey::Pubkey, transaction::Transaction}; +use std::collections::HashMap; const WRITABLE_ACCOUNTS_PER_BLOCK: usize = 512; @@ -154,20 +153,18 @@ impl CostTracker { #[cfg(test)] mod tests { - use { - super::*, - crate::{ - bank::Bank, - genesis_utils::{create_genesis_config, GenesisConfigInfo}, - }, - solana_sdk::{ - hash::Hash, - signature::{Keypair, Signer}, - system_transaction, - transaction::Transaction, - }, - std::{cmp, sync::Arc}, + use super::*; + use crate::{ + bank::Bank, + genesis_utils::{create_genesis_config, GenesisConfigInfo}, }; + use solana_sdk::{ + hash::Hash, + signature::{Keypair, Signer}, + system_transaction, + transaction::Transaction, + }; + use std::{cmp, sync::Arc}; fn test_setup() -> (Keypair, Hash) { solana_logger::setup(); diff --git a/runtime/src/epoch_stakes.rs b/runtime/src/epoch_stakes.rs index 1f6e6e4663..2fdc4ba91a 100644 --- a/runtime/src/epoch_stakes.rs +++ b/runtime/src/epoch_stakes.rs @@ -1,9 +1,7 @@ -use { - crate::{stakes::Stakes, vote_account::ArcVoteAccount}, - serde::{Deserialize, Serialize}, - solana_sdk::{clock::Epoch, pubkey::Pubkey}, - std::{collections::HashMap, sync::Arc}, -}; +use crate::{stakes::Stakes, vote_account::ArcVoteAccount}; +use serde::{Deserialize, Serialize}; +use solana_sdk::{clock::Epoch, pubkey::Pubkey}; +use std::{collections::HashMap, sync::Arc}; pub type NodeIdToVoteAccounts = HashMap; pub type EpochAuthorizedVoters = HashMap; @@ -117,10 +115,10 @@ impl EpochStakes { #[cfg(test)] pub(crate) mod tests { - use { - super::*, solana_sdk::account::AccountSharedData, - solana_vote_program::vote_state::create_account_with_authorized, std::iter, - }; + use super::*; + use solana_sdk::account::AccountSharedData; + use solana_vote_program::vote_state::create_account_with_authorized; + use std::iter; struct VoteAccountInfo { vote_account: Pubkey, diff --git a/runtime/src/execute_cost_table.rs b/runtime/src/execute_cost_table.rs index 10dd656afa..4f0b3e9645 100644 --- a/runtime/src/execute_cost_table.rs +++ b/runtime/src/execute_cost_table.rs @@ -4,7 +4,8 @@ /// When its capacity limit is reached, it prunes old and less-used programs /// to make room for new ones. use log::*; -use {solana_sdk::pubkey::Pubkey, std::collections::HashMap}; +use solana_sdk::pubkey::Pubkey; +use std::collections::HashMap; // prune is rather expensive op, free up bulk space in each operation // would be more efficient. PRUNE_RATIO defines the after prune table diff --git a/runtime/src/genesis_utils.rs b/runtime/src/genesis_utils.rs index 71222fdf44..eea539905c 100644 --- a/runtime/src/genesis_utils.rs +++ b/runtime/src/genesis_utils.rs @@ -1,20 +1,19 @@ -use { - solana_sdk::{ - account::{Account, AccountSharedData}, - feature::{self, Feature}, - feature_set::FeatureSet, - fee_calculator::FeeRateGovernor, - genesis_config::{ClusterType, GenesisConfig}, - pubkey::Pubkey, - rent::Rent, - signature::{Keypair, Signer}, - stake::state::StakeState, - system_program, - }, - solana_stake_program::stake_state, - solana_vote_program::vote_state, - std::borrow::Borrow, +use solana_sdk::{ + account::Account, + account::AccountSharedData, + feature::{self, Feature}, + feature_set::FeatureSet, + fee_calculator::FeeRateGovernor, + genesis_config::{ClusterType, GenesisConfig}, + pubkey::Pubkey, + rent::Rent, + signature::{Keypair, Signer}, + stake::state::StakeState, + system_program, }; +use solana_stake_program::stake_state; +use solana_vote_program::vote_state; +use std::borrow::Borrow; // Default amount received by the validator const VALIDATOR_LAMPORTS: u64 = 42; diff --git a/runtime/src/hardened_unpack.rs b/runtime/src/hardened_unpack.rs index a889085970..f56c20808f 100644 --- a/runtime/src/hardened_unpack.rs +++ b/runtime/src/hardened_unpack.rs @@ -1,8 +1,9 @@ +use solana_sdk::genesis_config::{DEFAULT_GENESIS_ARCHIVE, DEFAULT_GENESIS_FILE}; use { bzip2::bufread::BzDecoder, log::*, rand::{thread_rng, Rng}, - solana_sdk::genesis_config::{GenesisConfig, DEFAULT_GENESIS_ARCHIVE, DEFAULT_GENESIS_FILE}, + solana_sdk::genesis_config::GenesisConfig, std::{ collections::HashMap, fs::{self, File}, @@ -473,11 +474,9 @@ fn is_valid_genesis_archive_entry(parts: &[&str], kind: tar::EntryType) -> bool #[cfg(test)] mod tests { - use { - super::*, - assert_matches::assert_matches, - tar::{Builder, Header}, - }; + use super::*; + use assert_matches::assert_matches; + use tar::{Builder, Header}; #[test] fn test_archive_is_valid_entry() { diff --git a/runtime/src/hashed_transaction.rs b/runtime/src/hashed_transaction.rs index 15d8666d36..4caddda76b 100644 --- a/runtime/src/hashed_transaction.rs +++ b/runtime/src/hashed_transaction.rs @@ -1,7 +1,5 @@ -use { - solana_sdk::{hash::Hash, transaction::Transaction, vote}, - std::borrow::Cow, -}; +use solana_sdk::{hash::Hash, transaction::Transaction, vote}; +use std::borrow::Cow; /// Transaction and the hash of its message #[derive(Debug, Clone)] diff --git a/runtime/src/instruction_recorder.rs b/runtime/src/instruction_recorder.rs index fa76861920..f314b7c8bd 100644 --- a/runtime/src/instruction_recorder.rs +++ b/runtime/src/instruction_recorder.rs @@ -1,9 +1,8 @@ -use { - solana_sdk::{ - instruction::{CompiledInstruction, Instruction}, - message::Message, - }, - std::{cell::RefCell, rc::Rc}, +use std::{cell::RefCell, rc::Rc}; + +use solana_sdk::{ + instruction::{CompiledInstruction, Instruction}, + message::Message, }; /// Records and compiles cross-program invoked instructions diff --git a/runtime/src/loader_utils.rs b/runtime/src/loader_utils.rs index 6c5196300c..7580ef873b 100644 --- a/runtime/src/loader_utils.rs +++ b/runtime/src/loader_utils.rs @@ -1,15 +1,13 @@ -use { - serde::Serialize, - solana_sdk::{ - bpf_loader_upgradeable::{self, UpgradeableLoaderState}, - client::Client, - instruction::{AccountMeta, Instruction}, - loader_instruction, - message::Message, - pubkey::Pubkey, - signature::{Keypair, Signer}, - system_instruction, - }, +use serde::Serialize; +use solana_sdk::{ + bpf_loader_upgradeable::{self, UpgradeableLoaderState}, + client::Client, + instruction::{AccountMeta, Instruction}, + loader_instruction, + message::Message, + pubkey::Pubkey, + signature::{Keypair, Signer}, + system_instruction, }; pub fn load_program( diff --git a/runtime/src/message_processor.rs b/runtime/src/message_processor.rs index 867aee9b11..9984e8912f 100644 --- a/runtime/src/message_processor.rs +++ b/runtime/src/message_processor.rs @@ -1,41 +1,39 @@ -use { - crate::{ - accounts::Accounts, ancestors::Ancestors, instruction_recorder::InstructionRecorder, - log_collector::LogCollector, native_loader::NativeLoader, rent_collector::RentCollector, +use crate::{ + accounts::Accounts, ancestors::Ancestors, instruction_recorder::InstructionRecorder, + log_collector::LogCollector, native_loader::NativeLoader, rent_collector::RentCollector, +}; +use log::*; +use serde::{Deserialize, Serialize}; +use solana_measure::measure::Measure; +use solana_sdk::{ + account::{AccountSharedData, ReadableAccount, WritableAccount}, + account_utils::StateMut, + bpf_loader_upgradeable::{self, UpgradeableLoaderState}, + feature_set::{ + demote_program_write_locks, fix_write_privs, instructions_sysvar_enabled, + neon_evm_compute_budget, remove_native_loader, requestable_heap_size, tx_wide_compute_cap, + updated_verify_policy, FeatureSet, }, - log::*, - serde::{Deserialize, Serialize}, - solana_measure::measure::Measure, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount, WritableAccount}, - account_utils::StateMut, - bpf_loader_upgradeable::{self, UpgradeableLoaderState}, - feature_set::{ - demote_program_write_locks, fix_write_privs, instructions_sysvar_enabled, - neon_evm_compute_budget, remove_native_loader, requestable_heap_size, - tx_wide_compute_cap, updated_verify_policy, FeatureSet, - }, - ic_logger_msg, ic_msg, - instruction::{CompiledInstruction, Instruction, InstructionError}, - keyed_account::{create_keyed_accounts_unified, keyed_account_at_index, KeyedAccount}, - message::Message, - native_loader, - process_instruction::{ - BpfComputeBudget, ComputeMeter, Executor, InvokeContext, InvokeContextStackFrame, - Logger, ProcessInstructionWithContext, - }, - pubkey::Pubkey, - rent::Rent, - system_program, - sysvar::instructions, - transaction::TransactionError, - }, - std::{ - cell::{Ref, RefCell}, - collections::HashMap, - rc::Rc, - sync::Arc, + ic_logger_msg, ic_msg, + instruction::{CompiledInstruction, Instruction, InstructionError}, + keyed_account::{create_keyed_accounts_unified, keyed_account_at_index, KeyedAccount}, + message::Message, + native_loader, + process_instruction::{ + BpfComputeBudget, ComputeMeter, Executor, InvokeContext, InvokeContextStackFrame, Logger, + ProcessInstructionWithContext, }, + pubkey::Pubkey, + rent::Rent, + system_program, + sysvar::instructions, + transaction::TransactionError, +}; +use std::{ + cell::{Ref, RefCell}, + collections::HashMap, + rc::Rc, + sync::Arc, }; pub struct Executors { @@ -1342,15 +1340,13 @@ impl MessageProcessor { #[cfg(test)] mod tests { - use { - super::*, - solana_sdk::{ - account::Account, - instruction::{AccountMeta, Instruction, InstructionError}, - message::Message, - native_loader::create_loadable_account_for_test, - process_instruction::MockComputeMeter, - }, + use super::*; + use solana_sdk::{ + account::Account, + instruction::{AccountMeta, Instruction, InstructionError}, + message::Message, + native_loader::create_loadable_account_for_test, + process_instruction::MockComputeMeter, }; #[test] diff --git a/runtime/src/native_loader.rs b/runtime/src/native_loader.rs index 44f8647683..7a313945d0 100644 --- a/runtime/src/native_loader.rs +++ b/runtime/src/native_loader.rs @@ -3,28 +3,26 @@ use libloading::os::unix::*; #[cfg(windows)] use libloading::os::windows::*; -use { - log::*, - num_derive::{FromPrimitive, ToPrimitive}, - solana_sdk::{ - account::ReadableAccount, - decode_error::DecodeError, - entrypoint_native::ProgramEntrypoint, - instruction::InstructionError, - keyed_account::keyed_account_at_index, - native_loader, - process_instruction::{InvokeContext, LoaderEntrypoint}, - pubkey::Pubkey, - }, - std::{ - collections::HashMap, - env, - path::{Path, PathBuf}, - str, - sync::RwLock, - }, - thiserror::Error, +use log::*; +use num_derive::{FromPrimitive, ToPrimitive}; +use solana_sdk::{ + account::ReadableAccount, + decode_error::DecodeError, + entrypoint_native::ProgramEntrypoint, + instruction::InstructionError, + keyed_account::keyed_account_at_index, + native_loader, + process_instruction::{InvokeContext, LoaderEntrypoint}, + pubkey::Pubkey, }; +use std::{ + collections::HashMap, + env, + path::{Path, PathBuf}, + str, + sync::RwLock, +}; +use thiserror::Error; #[derive(Error, Debug, Serialize, Clone, PartialEq, FromPrimitive, ToPrimitive)] pub enum NativeLoaderError { diff --git a/runtime/src/non_circulating_supply.rs b/runtime/src/non_circulating_supply.rs index ee6769bcfc..62e922142c 100644 --- a/runtime/src/non_circulating_supply.rs +++ b/runtime/src/non_circulating_supply.rs @@ -195,16 +195,15 @@ solana_sdk::pubkeys!( #[cfg(test)] mod tests { - use { - super::*, - solana_sdk::{ - account::{Account, AccountSharedData}, - epoch_schedule::EpochSchedule, - genesis_config::{ClusterType, GenesisConfig}, - stake::state::{Authorized, Lockup, Meta}, - }, - std::{collections::BTreeMap, sync::Arc}, + use super::*; + use solana_sdk::{ + account::Account, + account::AccountSharedData, + epoch_schedule::EpochSchedule, + genesis_config::{ClusterType, GenesisConfig}, + stake::state::{Authorized, Lockup, Meta}, }; + use std::{collections::BTreeMap, sync::Arc}; fn new_from_parent(parent: &Arc) -> Bank { Bank::new_from_parent(parent, &Pubkey::default(), parent.slot() + 1) diff --git a/runtime/src/read_only_accounts_cache.rs b/runtime/src/read_only_accounts_cache.rs index f6159db445..a9ba34b348 100644 --- a/runtime/src/read_only_accounts_cache.rs +++ b/runtime/src/read_only_accounts_cache.rs @@ -1,21 +1,20 @@ //! ReadOnlyAccountsCache used to store accounts, such as executable accounts, //! which can be large, loaded many times, and rarely change. +use dashmap::{mapref::entry::Entry, DashMap}; //use mapref::entry::{Entry, OccupiedEntry, VacantEntry}; use solana_sdk::{ account::{AccountSharedData, ReadableAccount}, clock::Slot, pubkey::Pubkey, }; -use { - dashmap::{mapref::entry::Entry, DashMap}, - std::{ - sync::{ - atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}, - Arc, RwLock, - }, - thread::{sleep, Builder, JoinHandle}, - time::{Duration, Instant}, +use std::thread::{sleep, Builder, JoinHandle}; +use std::time::Duration; +use std::{ + sync::{ + atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}, + Arc, RwLock, }, + time::Instant, }; type ReadOnlyCacheKey = (Pubkey, Slot); @@ -241,10 +240,8 @@ impl ReadOnlyAccountsCache { #[cfg(test)] pub mod tests { - use { - super::*, - solana_sdk::account::{accounts_equal, Account, WritableAccount}, - }; + use super::*; + use solana_sdk::account::{accounts_equal, Account, WritableAccount}; #[test] fn test_accountsdb_sizeof() { // size_of(arc(x)) does not return the size of x diff --git a/runtime/src/rent_collector.rs b/runtime/src/rent_collector.rs index b431e93128..744bd7ee0a 100644 --- a/runtime/src/rent_collector.rs +++ b/runtime/src/rent_collector.rs @@ -126,7 +126,8 @@ impl RentCollector { #[cfg(test)] mod tests { - use {super::*, solana_sdk::account::Account}; + use super::*; + use solana_sdk::account::Account; #[test] fn test_collect_from_account_created_and_existing() { diff --git a/runtime/src/secondary_index.rs b/runtime/src/secondary_index.rs index dd499a11c0..6b0e045423 100644 --- a/runtime/src/secondary_index.rs +++ b/runtime/src/secondary_index.rs @@ -1,13 +1,11 @@ -use { - dashmap::{mapref::entry::Entry::Occupied, DashMap}, - solana_sdk::{pubkey::Pubkey, timing::AtomicInterval}, - std::{ - collections::HashSet, - fmt::Debug, - sync::{ - atomic::{AtomicU64, Ordering}, - RwLock, - }, +use dashmap::{mapref::entry::Entry::Occupied, DashMap}; +use solana_sdk::{pubkey::Pubkey, timing::AtomicInterval}; +use std::{ + collections::HashSet, + fmt::Debug, + sync::{ + atomic::{AtomicU64, Ordering}, + RwLock, }, }; diff --git a/runtime/src/serde_snapshot.rs b/runtime/src/serde_snapshot.rs index e7b2bb8f3f..7954bddcdd 100644 --- a/runtime/src/serde_snapshot.rs +++ b/runtime/src/serde_snapshot.rs @@ -1,5 +1,3 @@ -#[cfg(RUSTC_WITH_SPECIALIZATION)] -use solana_frozen_abi::abi_example::IgnoreAsHelper; use { crate::{ accounts::Accounts, @@ -19,7 +17,8 @@ use { serde_snapshot::future::SerializableStorage, stakes::Stakes, }, - bincode::{self, config::Options, Error}, + bincode, + bincode::{config::Options, Error}, log::*, rayon::prelude::*, serde::{de::DeserializeOwned, Deserialize, Serialize}, @@ -28,7 +27,8 @@ use { clock::{Epoch, Slot, UnixTimestamp}, epoch_schedule::EpochSchedule, fee_calculator::{FeeCalculator, FeeRateGovernor}, - genesis_config::{ClusterType, GenesisConfig}, + genesis_config::ClusterType, + genesis_config::GenesisConfig, hard_forks::HardForks, hash::Hash, inflation::Inflation, @@ -43,19 +43,24 @@ use { }, }; +#[cfg(RUSTC_WITH_SPECIALIZATION)] +use solana_frozen_abi::abi_example::IgnoreAsHelper; + mod common; mod future; mod tests; mod utils; -// a number of test cases in accounts_db use this -#[cfg(test)] -pub(crate) use self::tests::reconstruct_accounts_db_via_serialization; -pub(crate) use crate::accounts_db::{SnapshotStorage, SnapshotStorages}; use future::Context as TypeContextFuture; #[allow(unused_imports)] use utils::{serialize_iter_as_map, serialize_iter_as_seq, serialize_iter_as_tuple}; +// a number of test cases in accounts_db use this +#[cfg(test)] +pub(crate) use self::tests::reconstruct_accounts_db_via_serialization; + +pub(crate) use crate::accounts_db::{SnapshotStorage, SnapshotStorages}; + #[derive(Copy, Clone, Eq, PartialEq)] pub(crate) enum SerdeStyle { Newer, diff --git a/runtime/src/serde_snapshot/common.rs b/runtime/src/serde_snapshot/common.rs index e8464ea3de..23cdf45eec 100644 --- a/runtime/src/serde_snapshot/common.rs +++ b/runtime/src/serde_snapshot/common.rs @@ -1,4 +1,5 @@ -use {super::*, std::collections::HashSet}; +use super::*; +use std::collections::HashSet; #[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize, AbiExample)] pub(crate) struct UnusedAccounts { diff --git a/runtime/src/serde_snapshot/future.rs b/runtime/src/serde_snapshot/future.rs index 628a73501d..1002c1cddb 100644 --- a/runtime/src/serde_snapshot/future.rs +++ b/runtime/src/serde_snapshot/future.rs @@ -1,11 +1,9 @@ +use super::common::UnusedAccounts; #[cfg(all(test, RUSTC_WITH_SPECIALIZATION))] use solana_frozen_abi::abi_example::IgnoreAsHelper; -use { - super::{common::UnusedAccounts, *}, - crate::ancestors::AncestorsForSerialization, - solana_measure::measure::Measure, - std::cell::RefCell, -}; +use {super::*, solana_measure::measure::Measure, std::cell::RefCell}; + +use crate::ancestors::AncestorsForSerialization; type AccountsDbFields = super::AccountsDbFields; diff --git a/runtime/src/snapshot_package.rs b/runtime/src/snapshot_package.rs index eb3efeb95e..8d03154fd0 100644 --- a/runtime/src/snapshot_package.rs +++ b/runtime/src/snapshot_package.rs @@ -1,15 +1,14 @@ -use { - crate::{ - accounts_db::SnapshotStorages, bank::BankSlotDelta, bank_forks::ArchiveFormat, - snapshot_utils::SnapshotVersion, - }, - solana_sdk::{clock::Slot, genesis_config::ClusterType, hash::Hash}, - std::{ - path::PathBuf, - sync::mpsc::{Receiver, SendError, Sender}, - }, - tempfile::TempDir, +use crate::bank_forks::ArchiveFormat; +use crate::snapshot_utils::SnapshotVersion; +use crate::{accounts_db::SnapshotStorages, bank::BankSlotDelta}; +use solana_sdk::clock::Slot; +use solana_sdk::genesis_config::ClusterType; +use solana_sdk::hash::Hash; +use std::{ + path::PathBuf, + sync::mpsc::{Receiver, SendError, Sender}, }; +use tempfile::TempDir; pub type AccountsPackageSender = Sender; pub type AccountsPackageReceiver = Receiver; diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index 48852dee1d..c4b6aca0d8 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -23,7 +23,8 @@ use { solana_measure::measure::Measure, solana_sdk::{clock::Slot, genesis_config::GenesisConfig, hash::Hash, pubkey::Pubkey}, std::{ - cmp::{max, Ordering}, + cmp::max, + cmp::Ordering, collections::HashSet, fmt, fs::{self, File}, @@ -1112,12 +1113,10 @@ pub fn process_accounts_package_pre( #[cfg(test)] mod tests { - use { - super::*, - assert_matches::assert_matches, - bincode::{deserialize_from, serialize_into}, - std::mem::size_of, - }; + use super::*; + use assert_matches::assert_matches; + use bincode::{deserialize_from, serialize_into}; + use std::mem::size_of; #[test] fn test_serialize_snapshot_data_file_under_limit() { diff --git a/runtime/src/sorted_storages.rs b/runtime/src/sorted_storages.rs index cabd8c1e04..cb87cad55a 100644 --- a/runtime/src/sorted_storages.rs +++ b/runtime/src/sorted_storages.rs @@ -1,7 +1,8 @@ -use { - crate::accounts_db::SnapshotStorage, log::*, solana_measure::measure::Measure, - solana_sdk::clock::Slot, std::ops::Range, -}; +use crate::accounts_db::SnapshotStorage; +use log::*; +use solana_measure::measure::Measure; +use solana_sdk::clock::Slot; +use std::ops::Range; pub struct SortedStorages<'a> { range: Range, diff --git a/runtime/src/stake_weighted_timestamp.rs b/runtime/src/stake_weighted_timestamp.rs index fbb268f317..6674024686 100644 --- a/runtime/src/stake_weighted_timestamp.rs +++ b/runtime/src/stake_weighted_timestamp.rs @@ -100,10 +100,8 @@ where #[cfg(test)] pub mod tests { - use { - super::*, - solana_sdk::{account::Account, native_token::sol_to_lamports}, - }; + use super::*; + use solana_sdk::{account::Account, native_token::sol_to_lamports}; #[test] fn test_calculate_stake_weighted_timestamp_uses_median() { diff --git a/runtime/src/stakes.rs b/runtime/src/stakes.rs index 4df4eb3da0..f13d65689d 100644 --- a/runtime/src/stakes.rs +++ b/runtime/src/stakes.rs @@ -1,25 +1,23 @@ //! Stakes serve as a cache of stake and vote accounts to derive //! node stakes -use { - crate::vote_account::{ArcVoteAccount, VoteAccounts, VoteAccountsHashMap}, - rayon::{ - iter::{IntoParallelRefIterator, ParallelIterator}, - ThreadPool, - }, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, - clock::Epoch, - pubkey::Pubkey, - stake::{ - self, - state::{Delegation, StakeActivationStatus, StakeState}, - }, - stake_history::StakeHistory, - }, - solana_stake_program::stake_state, - solana_vote_program::vote_state::VoteState, - std::collections::HashMap, +use crate::vote_account::{ArcVoteAccount, VoteAccounts, VoteAccountsHashMap}; +use rayon::{ + iter::{IntoParallelRefIterator, ParallelIterator}, + ThreadPool, }; +use solana_sdk::{ + account::{AccountSharedData, ReadableAccount}, + clock::Epoch, + pubkey::Pubkey, + stake::{ + self, + state::{Delegation, StakeActivationStatus, StakeState}, + }, + stake_history::StakeHistory, +}; +use solana_stake_program::stake_state; +use solana_vote_program::vote_state::VoteState; +use std::collections::HashMap; #[derive(Default, Clone, PartialEq, Debug, Deserialize, Serialize, AbiExample)] pub struct Stakes { @@ -295,13 +293,11 @@ impl Stakes { #[cfg(test)] pub mod tests { - use { - super::*, - rayon::ThreadPoolBuilder, - solana_sdk::{account::WritableAccount, pubkey::Pubkey, rent::Rent}, - solana_stake_program::stake_state, - solana_vote_program::vote_state::{self, VoteState, VoteStateVersions}, - }; + use super::*; + use rayon::ThreadPoolBuilder; + use solana_sdk::{account::WritableAccount, pubkey::Pubkey, rent::Rent}; + use solana_stake_program::stake_state; + use solana_vote_program::vote_state::{self, VoteState, VoteStateVersions}; // set up some dummies for a staked node (( vote ) ( stake )) pub fn create_staked_node_accounts( diff --git a/runtime/src/status_cache.rs b/runtime/src/status_cache.rs index 34f335ad75..d07ee5356e 100644 --- a/runtime/src/status_cache.rs +++ b/runtime/src/status_cache.rs @@ -1,16 +1,15 @@ -use { - crate::ancestors::Ancestors, - log::*, - rand::{thread_rng, Rng}, - serde::Serialize, - solana_sdk::{ - clock::{Slot, MAX_RECENT_BLOCKHASHES}, - hash::Hash, - }, - std::{ - collections::{hash_map::Entry, HashMap, HashSet}, - sync::{Arc, Mutex}, - }, +use crate::ancestors::Ancestors; + +use log::*; +use rand::{thread_rng, Rng}; +use serde::Serialize; +use solana_sdk::{ + clock::{Slot, MAX_RECENT_BLOCKHASHES}, + hash::Hash, +}; +use std::{ + collections::{hash_map::Entry, HashMap, HashSet}, + sync::{Arc, Mutex}, }; pub const MAX_CACHE_ENTRIES: usize = MAX_RECENT_BLOCKHASHES; @@ -295,10 +294,8 @@ impl StatusCache { #[cfg(test)] mod tests { - use { - super::*, - solana_sdk::{hash::hash, signature::Signature}, - }; + use super::*; + use solana_sdk::{hash::hash, signature::Signature}; type BankStatusCache = StatusCache<()>; diff --git a/runtime/src/system_instruction_processor.rs b/runtime/src/system_instruction_processor.rs index 815059844d..2d7ba74613 100644 --- a/runtime/src/system_instruction_processor.rs +++ b/runtime/src/system_instruction_processor.rs @@ -1,22 +1,20 @@ -use { - log::*, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount, WritableAccount}, - account_utils::StateMut, - feature_set, ic_msg, - instruction::InstructionError, - keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount}, - nonce, - nonce_keyed_account::NonceKeyedAccount, - process_instruction::InvokeContext, - program_utils::limited_deserialize, - pubkey::Pubkey, - system_instruction::{SystemError, SystemInstruction, MAX_PERMITTED_DATA_LENGTH}, - system_program, - sysvar::{self, recent_blockhashes::RecentBlockhashes, rent::Rent}, - }, - std::collections::HashSet, +use log::*; +use solana_sdk::{ + account::{AccountSharedData, ReadableAccount, WritableAccount}, + account_utils::StateMut, + feature_set, ic_msg, + instruction::InstructionError, + keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount}, + nonce, + nonce_keyed_account::NonceKeyedAccount, + process_instruction::InvokeContext, + program_utils::limited_deserialize, + pubkey::Pubkey, + system_instruction::{SystemError, SystemInstruction, MAX_PERMITTED_DATA_LENGTH}, + system_program, + sysvar::{self, recent_blockhashes::RecentBlockhashes, rent::Rent}, }; +use std::collections::HashSet; // represents an address that may or may not have been generated // from a seed @@ -461,28 +459,27 @@ pub fn get_system_account_kind(account: &AccountSharedData) -> Option for Address { fn from(address: Pubkey) -> Self { diff --git a/runtime/src/transaction_batch.rs b/runtime/src/transaction_batch.rs index 405040e23b..ba4b963174 100644 --- a/runtime/src/transaction_batch.rs +++ b/runtime/src/transaction_batch.rs @@ -1,8 +1,7 @@ -use { - crate::{bank::Bank, hashed_transaction::HashedTransaction}, - solana_sdk::transaction::{Result, Transaction}, - std::borrow::Cow, -}; +use crate::bank::Bank; +use crate::hashed_transaction::HashedTransaction; +use solana_sdk::transaction::{Result, Transaction}; +use std::borrow::Cow; // Represents the results of trying to lock a set of accounts pub struct TransactionBatch<'a, 'b> { @@ -53,11 +52,9 @@ impl<'a, 'b> Drop for TransactionBatch<'a, 'b> { #[cfg(test)] mod tests { - use { - super::*, - crate::genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo}, - solana_sdk::{signature::Keypair, system_transaction}, - }; + use super::*; + use crate::genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo}; + use solana_sdk::{signature::Keypair, system_transaction}; #[test] fn test_transaction_batch() { diff --git a/runtime/src/vote_account.rs b/runtime/src/vote_account.rs index 72909c9da3..0210649201 100644 --- a/runtime/src/vote_account.rs +++ b/runtime/src/vote_account.rs @@ -1,21 +1,15 @@ -use { - serde::{ - de::{Deserialize, Deserializer}, - ser::{Serialize, Serializer}, - }, - solana_sdk::{ - account::{Account, AccountSharedData}, - instruction::InstructionError, - pubkey::Pubkey, - }, - solana_vote_program::vote_state::VoteState, - std::{ - cmp::Ordering, - collections::{hash_map::Entry, HashMap}, - iter::FromIterator, - ops::Deref, - sync::{Arc, Once, RwLock, RwLockReadGuard}, - }, +use serde::de::{Deserialize, Deserializer}; +use serde::ser::{Serialize, Serializer}; +use solana_sdk::{ + account::Account, account::AccountSharedData, instruction::InstructionError, pubkey::Pubkey, +}; +use solana_vote_program::vote_state::VoteState; +use std::{ + cmp::Ordering, + collections::{hash_map::Entry, HashMap}, + iter::FromIterator, + ops::Deref, + sync::{Arc, Once, RwLock, RwLockReadGuard}, }; // The value here does not matter. It will be overwritten @@ -321,14 +315,12 @@ impl<'de> Deserialize<'de> for VoteAccounts { #[cfg(test)] mod tests { - use { - super::*, - bincode::Options, - rand::Rng, - solana_sdk::{pubkey::Pubkey, sysvar::clock::Clock}, - solana_vote_program::vote_state::{VoteInit, VoteStateVersions}, - std::iter::repeat_with, - }; + use super::*; + use bincode::Options; + use rand::Rng; + use solana_sdk::{pubkey::Pubkey, sysvar::clock::Clock}; + use solana_vote_program::vote_state::{VoteInit, VoteStateVersions}; + use std::iter::repeat_with; fn new_rand_vote_account( rng: &mut R, diff --git a/runtime/src/vote_sender_types.rs b/runtime/src/vote_sender_types.rs index ef7f245cd5..6d81b1916c 100644 --- a/runtime/src/vote_sender_types.rs +++ b/runtime/src/vote_sender_types.rs @@ -1,8 +1,6 @@ -use { - crossbeam_channel::{Receiver, Sender}, - solana_sdk::{hash::Hash, pubkey::Pubkey}, - solana_vote_program::vote_state::Vote, -}; +use crossbeam_channel::{Receiver, Sender}; +use solana_sdk::{hash::Hash, pubkey::Pubkey}; +use solana_vote_program::vote_state::Vote; pub type ReplayedVote = (Pubkey, Vote, Option); pub type ReplayVoteSender = Sender; diff --git a/runtime/store-tool/src/main.rs b/runtime/store-tool/src/main.rs index 7c6c162ce4..68ed042314 100644 --- a/runtime/store-tool/src/main.rs +++ b/runtime/store-tool/src/main.rs @@ -1,8 +1,6 @@ -use { - clap::{crate_description, crate_name, value_t_or_exit, App, Arg}, - log::*, - solana_runtime::append_vec::AppendVec, -}; +use clap::{crate_description, crate_name, value_t_or_exit, App, Arg}; +use log::*; +use solana_runtime::append_vec::AppendVec; fn main() { solana_logger::setup_with_default("solana=info"); diff --git a/runtime/tests/accounts.rs b/runtime/tests/accounts.rs index fbde712b42..7439d0a847 100644 --- a/runtime/tests/accounts.rs +++ b/runtime/tests/accounts.rs @@ -1,26 +1,20 @@ -use { - log::*, - rand::{thread_rng, Rng}, - rayon::prelude::*, - solana_runtime::{ - accounts_db::{AccountsDb, LoadHint}, - ancestors::Ancestors, - }, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount, WritableAccount}, - clock::Slot, - genesis_config::ClusterType, - pubkey::Pubkey, - }, - std::{ - collections::HashSet, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - time::Instant, - }, +use log::*; +use rand::{thread_rng, Rng}; +use rayon::prelude::*; +use solana_runtime::{ + accounts_db::{AccountsDb, LoadHint}, + ancestors::Ancestors, }; +use solana_sdk::genesis_config::ClusterType; +use solana_sdk::{ + account::{AccountSharedData, ReadableAccount, WritableAccount}, + clock::Slot, + pubkey::Pubkey, +}; +use std::collections::HashSet; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; +use std::time::Instant; #[test] fn test_shrink_and_clean() { diff --git a/runtime/tests/bank.rs b/runtime/tests/bank.rs index 41284bb7c8..5e9e118dec 100644 --- a/runtime/tests/bank.rs +++ b/runtime/tests/bank.rs @@ -1,8 +1,6 @@ -use { - solana_runtime::bank::Bank, - solana_sdk::{genesis_config::create_genesis_config, hash::hash}, - std::{sync::Arc, thread::Builder}, -}; +use solana_runtime::bank::Bank; +use solana_sdk::{genesis_config::create_genesis_config, hash::hash}; +use std::{sync::Arc, thread::Builder}; #[test] fn test_race_register_tick_freeze() { diff --git a/runtime/tests/stake.rs b/runtime/tests/stake.rs index 4e10e0e252..f81b6e70b3 100644 --- a/runtime/tests/stake.rs +++ b/runtime/tests/stake.rs @@ -1,30 +1,28 @@ #![allow(clippy::integer_arithmetic)] -use { - solana_runtime::{ - bank::Bank, - bank_client::BankClient, - genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo}, - }, - solana_sdk::{ - account::from_account, - account_utils::StateMut, - client::SyncClient, - message::Message, - pubkey::Pubkey, - signature::{Keypair, Signer}, - stake::{ - self, instruction as stake_instruction, - state::{Authorized, Lockup, StakeState}, - }, - sysvar::{self, stake_history::StakeHistory}, - }, - solana_stake_program::stake_state, - solana_vote_program::{ - vote_instruction, - vote_state::{Vote, VoteInit, VoteState, VoteStateVersions}, - }, - std::sync::Arc, +use solana_runtime::{ + bank::Bank, + bank_client::BankClient, + genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo}, }; +use solana_sdk::{ + account::from_account, + account_utils::StateMut, + client::SyncClient, + message::Message, + pubkey::Pubkey, + signature::{Keypair, Signer}, + stake::{ + self, instruction as stake_instruction, + state::{Authorized, Lockup, StakeState}, + }, + sysvar::{self, stake_history::StakeHistory}, +}; +use solana_stake_program::stake_state; +use solana_vote_program::{ + vote_instruction, + vote_state::{Vote, VoteInit, VoteState, VoteStateVersions}, +}; +use std::sync::Arc; fn next_epoch(bank: &Arc) -> Arc { bank.squash(); diff --git a/scripts/src/csv_to_validator_infos.rs b/scripts/src/csv_to_validator_infos.rs index da3afbf868..de7a62c86e 100644 --- a/scripts/src/csv_to_validator_infos.rs +++ b/scripts/src/csv_to_validator_infos.rs @@ -3,10 +3,10 @@ // Usage: // cargo run --bin solana-csv-to-validator-infos < validators.csv -use { - serde::Deserialize, - std::{error::Error, io, process}, -}; +use serde::Deserialize; +use std::error::Error; +use std::io; +use std::process; #[derive(Debug, Deserialize)] struct ValidatorRecord { diff --git a/sdk/benches/serialize_instructions.rs b/sdk/benches/serialize_instructions.rs index 92b20f158a..4a0a77e65f 100644 --- a/sdk/benches/serialize_instructions.rs +++ b/sdk/benches/serialize_instructions.rs @@ -1,16 +1,12 @@ #![feature(test)] extern crate test; -use { - bincode::{deserialize, serialize}, - solana_sdk::{ - instruction::{AccountMeta, Instruction}, - message::Message, - pubkey, - sysvar::instructions, - }, - test::Bencher, -}; +use bincode::{deserialize, serialize}; +use solana_sdk::instruction::{AccountMeta, Instruction}; +use solana_sdk::message::Message; +use solana_sdk::pubkey; +use solana_sdk::sysvar::instructions; +use test::Bencher; fn make_instructions() -> Vec { let meta = AccountMeta::new(pubkey::new_rand(), false); diff --git a/sdk/benches/short_vec.rs b/sdk/benches/short_vec.rs index 0a73a7e0eb..c1e687edf3 100644 --- a/sdk/benches/short_vec.rs +++ b/sdk/benches/short_vec.rs @@ -1,7 +1,9 @@ #![feature(test)] extern crate test; -use {bincode::deserialize, solana_sdk::short_vec::ShortVec, test::Bencher}; +use bincode::deserialize; +use solana_sdk::short_vec::ShortVec; +use test::Bencher; // Return a ShortVec with 127 bytes fn create_encoded_short_vec() -> Vec { diff --git a/sdk/benches/slot_hashes.rs b/sdk/benches/slot_hashes.rs index 3d13d2de8f..0167d8d777 100644 --- a/sdk/benches/slot_hashes.rs +++ b/sdk/benches/slot_hashes.rs @@ -1,14 +1,12 @@ #![feature(test)] extern crate test; -use { - solana_sdk::{ - account::{create_account_for_test, from_account}, - hash::Hash, - slot_hashes::{Slot, SlotHashes, MAX_ENTRIES}, - }, - test::Bencher, +use solana_sdk::{ + account::{create_account_for_test, from_account}, + hash::Hash, + slot_hashes::{Slot, SlotHashes, MAX_ENTRIES}, }; +use test::Bencher; #[bench] fn bench_to_from_account(b: &mut Bencher) { diff --git a/sdk/benches/slot_history.rs b/sdk/benches/slot_history.rs index 9ae9329139..9da3cf69d0 100644 --- a/sdk/benches/slot_history.rs +++ b/sdk/benches/slot_history.rs @@ -1,13 +1,11 @@ #![feature(test)] extern crate test; -use { - solana_sdk::{ - account::{create_account_for_test, from_account}, - slot_history::SlotHistory, - }, - test::Bencher, +use solana_sdk::{ + account::{create_account_for_test, from_account}, + slot_history::SlotHistory, }; +use test::Bencher; #[bench] fn bench_to_from_account(b: &mut Bencher) { diff --git a/sdk/cargo-build-bpf/src/main.rs b/sdk/cargo-build-bpf/src/main.rs index 5b449d021f..5ac3bb26ec 100644 --- a/sdk/cargo-build-bpf/src/main.rs +++ b/sdk/cargo-build-bpf/src/main.rs @@ -13,7 +13,8 @@ use { fs::{self, File}, io::{prelude::*, BufReader, BufWriter}, path::{Path, PathBuf}, - process::{exit, Command, Stdio}, + process::exit, + process::{Command, Stdio}, str::FromStr, }, tar::Archive, diff --git a/sdk/cargo-test-bpf/src/main.rs b/sdk/cargo-test-bpf/src/main.rs index 37a58e1e90..92392d4f8c 100644 --- a/sdk/cargo-test-bpf/src/main.rs +++ b/sdk/cargo-test-bpf/src/main.rs @@ -1,13 +1,12 @@ -use { - clap::{ - crate_description, crate_name, crate_version, value_t, values_t, App, AppSettings, Arg, - }, - std::{ - env, - ffi::OsStr, - path::{Path, PathBuf}, - process::{exit, Command}, - }, +use clap::{ + crate_description, crate_name, crate_version, value_t, values_t, App, AppSettings, Arg, +}; +use std::{ + env, + ffi::OsStr, + path::{Path, PathBuf}, + process::exit, + process::Command, }; struct Config { diff --git a/sdk/macro/src/lib.rs b/sdk/macro/src/lib.rs index 455e625fc8..14e01a25fe 100644 --- a/sdk/macro/src/lib.rs +++ b/sdk/macro/src/lib.rs @@ -4,19 +4,17 @@ extern crate proc_macro; -use { - proc_macro::TokenStream, - proc_macro2::{Delimiter, Span, TokenTree}, - quote::{quote, ToTokens}, - std::convert::TryFrom, - syn::{ - bracketed, - parse::{Parse, ParseStream, Result}, - parse_macro_input, - punctuated::Punctuated, - token::Bracket, - Expr, Ident, LitByte, LitStr, Path, Token, - }, +use proc_macro::TokenStream; +use proc_macro2::{Delimiter, Span, TokenTree}; +use quote::{quote, ToTokens}; +use std::convert::TryFrom; +use syn::{ + bracketed, + parse::{Parse, ParseStream, Result}, + parse_macro_input, + punctuated::Punctuated, + token::Bracket, + Expr, Ident, LitByte, LitStr, Path, Token, }; fn parse_id( diff --git a/sdk/program/src/account_info.rs b/sdk/program/src/account_info.rs index d837ec1bcf..663b52caea 100644 --- a/sdk/program/src/account_info.rs +++ b/sdk/program/src/account_info.rs @@ -1,10 +1,8 @@ -use { - crate::{clock::Epoch, program_error::ProgramError, pubkey::Pubkey}, - std::{ - cell::{Ref, RefCell, RefMut}, - cmp, fmt, - rc::Rc, - }, +use crate::{clock::Epoch, program_error::ProgramError, pubkey::Pubkey}; +use std::{ + cell::{Ref, RefCell, RefMut}, + cmp, fmt, + rc::Rc, }; /// Account information diff --git a/sdk/program/src/bpf_loader_upgradeable.rs b/sdk/program/src/bpf_loader_upgradeable.rs index 9d56a0dddf..f086b58282 100644 --- a/sdk/program/src/bpf_loader_upgradeable.rs +++ b/sdk/program/src/bpf_loader_upgradeable.rs @@ -8,15 +8,13 @@ //! upgradeable programs which still have a functioning authority. For more //! information refer to `loader_upgradeable_instruction.rs` -use { - crate::{ - instruction::{AccountMeta, Instruction, InstructionError}, - loader_upgradeable_instruction::UpgradeableLoaderInstruction, - pubkey::Pubkey, - system_instruction, sysvar, - }, - bincode::serialized_size, +use crate::{ + instruction::{AccountMeta, Instruction, InstructionError}, + loader_upgradeable_instruction::UpgradeableLoaderInstruction, + pubkey::Pubkey, + system_instruction, sysvar, }; +use bincode::serialized_size; crate::declare_id!("BPFLoaderUpgradeab1e11111111111111111111111"); diff --git a/sdk/program/src/decode_error.rs b/sdk/program/src/decode_error.rs index 4d94e76704..7ca44864d7 100644 --- a/sdk/program/src/decode_error.rs +++ b/sdk/program/src/decode_error.rs @@ -13,7 +13,8 @@ pub trait DecodeError { #[cfg(test)] mod tests { - use {super::*, num_derive::FromPrimitive}; + use super::*; + use num_derive::FromPrimitive; #[test] fn test_decode_custom_error_to_enum() { diff --git a/sdk/program/src/entrypoint.rs b/sdk/program/src/entrypoint.rs index 66e26c16af..3d56ceb09a 100644 --- a/sdk/program/src/entrypoint.rs +++ b/sdk/program/src/entrypoint.rs @@ -2,18 +2,17 @@ //! BPFLoader. For more information see './bpf_loader.rs' extern crate alloc; -use { - crate::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}, - alloc::vec::Vec, - std::{ - alloc::Layout, - cell::RefCell, - mem::size_of, - ptr::null_mut, - rc::Rc, - result::Result as ResultGeneric, - slice::{from_raw_parts, from_raw_parts_mut}, - }, +use crate::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; +use alloc::vec::Vec; +use std::{ + alloc::Layout, + cell::RefCell, + mem::size_of, + ptr::null_mut, + rc::Rc, + // Hide Result from bindgen gets confused about generics in non-generic type declarations + result::Result as ResultGeneric, + slice::{from_raw_parts, from_raw_parts_mut}, }; pub type ProgramResult = ResultGeneric<(), ProgramError>; @@ -355,7 +354,8 @@ pub unsafe fn deserialize<'a>(input: *mut u8) -> (&'a Pubkey, Vec; diff --git a/sdk/program/src/feature.rs b/sdk/program/src/feature.rs index 8a9a23afba..7586157c50 100644 --- a/sdk/program/src/feature.rs +++ b/sdk/program/src/feature.rs @@ -58,7 +58,8 @@ pub fn activate_with_lamports( #[cfg(test)] mod test { - use {super::*, solana_program::clock::Slot}; + use super::*; + use solana_program::clock::Slot; #[test] fn feature_sizeof() { diff --git a/sdk/program/src/fee_calculator.rs b/sdk/program/src/fee_calculator.rs index 0588f09d1a..4bb8cb62e5 100644 --- a/sdk/program/src/fee_calculator.rs +++ b/sdk/program/src/fee_calculator.rs @@ -1,8 +1,9 @@ #![allow(clippy::integer_arithmetic)] -use { - crate::{clock::DEFAULT_MS_PER_SLOT, ed25519_program, message::Message, secp256k1_program}, - log::*, -}; +use crate::clock::DEFAULT_MS_PER_SLOT; +use crate::ed25519_program; +use crate::message::Message; +use crate::secp256k1_program; +use log::*; #[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug, AbiExample)] #[serde(rename_all = "camelCase")] @@ -179,10 +180,8 @@ impl FeeRateGovernor { #[cfg(test)] mod tests { - use { - super::*, - crate::{pubkey::Pubkey, system_instruction}, - }; + use super::*; + use crate::{pubkey::Pubkey, system_instruction}; #[test] fn test_fee_rate_governor_burn() { diff --git a/sdk/program/src/hash.rs b/sdk/program/src/hash.rs index 6b73698d46..e39add147d 100644 --- a/sdk/program/src/hash.rs +++ b/sdk/program/src/hash.rs @@ -1,12 +1,10 @@ //! The `hash` module provides functions for creating SHA-256 hashes. -use { - crate::sanitize::Sanitize, - borsh::{BorshDeserialize, BorshSchema, BorshSerialize}, - sha2::{Digest, Sha256}, - std::{convert::TryFrom, fmt, mem, str::FromStr}, - thiserror::Error, -}; +use crate::sanitize::Sanitize; +use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; +use sha2::{Digest, Sha256}; +use std::{convert::TryFrom, fmt, mem, str::FromStr}; +use thiserror::Error; pub const HASH_BYTES: usize = 32; /// Maximum string length of a base58 encoded hash diff --git a/sdk/program/src/instruction.rs b/sdk/program/src/instruction.rs index 7161489d52..1ad9cfa9d7 100644 --- a/sdk/program/src/instruction.rs +++ b/sdk/program/src/instruction.rs @@ -1,13 +1,12 @@ #![allow(clippy::integer_arithmetic)] //! Defines a composable Instruction type and a memory-efficient CompiledInstruction. -use { - crate::{pubkey::Pubkey, sanitize::Sanitize, short_vec}, - bincode::serialize, - borsh::BorshSerialize, - serde::Serialize, - thiserror::Error, -}; +use crate::sanitize::Sanitize; +use crate::{pubkey::Pubkey, short_vec}; +use bincode::serialize; +use borsh::BorshSerialize; +use serde::Serialize; +use thiserror::Error; /// Reasons the runtime might have rejected an instruction. /// diff --git a/sdk/program/src/keccak.rs b/sdk/program/src/keccak.rs index f02e1ebbe7..b3df920f15 100644 --- a/sdk/program/src/keccak.rs +++ b/sdk/program/src/keccak.rs @@ -1,10 +1,8 @@ -use { - crate::sanitize::Sanitize, - borsh::{BorshDeserialize, BorshSchema, BorshSerialize}, - sha3::{Digest, Keccak256}, - std::{convert::TryFrom, fmt, mem, str::FromStr}, - thiserror::Error, -}; +use crate::sanitize::Sanitize; +use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; +use sha3::{Digest, Keccak256}; +use std::{convert::TryFrom, fmt, mem, str::FromStr}; +use thiserror::Error; pub const HASH_BYTES: usize = 32; /// Maximum string length of a base58 encoded hash diff --git a/sdk/program/src/lamports.rs b/sdk/program/src/lamports.rs index c1f7711893..36ecb0ae0d 100644 --- a/sdk/program/src/lamports.rs +++ b/sdk/program/src/lamports.rs @@ -1,4 +1,5 @@ -use {crate::instruction::InstructionError, thiserror::Error}; +use crate::instruction::InstructionError; +use thiserror::Error; #[derive(Debug, Error)] pub enum LamportsError { diff --git a/sdk/program/src/message.rs b/sdk/program/src/message.rs index 7f6e6a96fa..8a893d590d 100644 --- a/sdk/program/src/message.rs +++ b/sdk/program/src/message.rs @@ -1,22 +1,20 @@ #![allow(clippy::integer_arithmetic)] //! A library for generating a message from a sequence of instructions -use { - crate::{ - bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, - hash::Hash, - instruction::{AccountMeta, CompiledInstruction, Instruction}, - pubkey::Pubkey, - sanitize::{Sanitize, SanitizeError}, - serialize_utils::{ - append_slice, append_u16, append_u8, read_pubkey, read_slice, read_u16, read_u8, - }, - short_vec, system_instruction, system_program, sysvar, - }, - itertools::Itertools, - lazy_static::lazy_static, - std::{convert::TryFrom, str::FromStr}, +use crate::sanitize::{Sanitize, SanitizeError}; +use crate::serialize_utils::{ + append_slice, append_u16, append_u8, read_pubkey, read_slice, read_u16, read_u8, }; +use crate::{ + bpf_loader, bpf_loader_deprecated, bpf_loader_upgradeable, + hash::Hash, + instruction::{AccountMeta, CompiledInstruction, Instruction}, + pubkey::Pubkey, + short_vec, system_instruction, system_program, sysvar, +}; +use itertools::Itertools; +use lazy_static::lazy_static; +use std::{convert::TryFrom, str::FromStr}; lazy_static! { // Copied keys over since direct references create cyclical dependency. @@ -551,11 +549,9 @@ impl Message { #[cfg(test)] mod tests { - use { - super::*, - crate::{hash, instruction::AccountMeta}, - std::collections::HashSet, - }; + use super::*; + use crate::{hash, instruction::AccountMeta}; + use std::collections::HashSet; #[test] fn test_message_unique_program_ids() { diff --git a/sdk/program/src/nonce/state/current.rs b/sdk/program/src/nonce/state/current.rs index c37abe2bde..3b31789095 100644 --- a/sdk/program/src/nonce/state/current.rs +++ b/sdk/program/src/nonce/state/current.rs @@ -1,8 +1,6 @@ -use { - super::Versions, - crate::{fee_calculator::FeeCalculator, hash::Hash, pubkey::Pubkey}, - serde_derive::{Deserialize, Serialize}, -}; +use super::Versions; +use crate::{fee_calculator::FeeCalculator, hash::Hash, pubkey::Pubkey}; +use serde_derive::{Deserialize, Serialize}; #[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone)] pub struct Data { diff --git a/sdk/program/src/nonce/state/mod.rs b/sdk/program/src/nonce/state/mod.rs index 910843d2fd..18b1ffcb94 100644 --- a/sdk/program/src/nonce/state/mod.rs +++ b/sdk/program/src/nonce/state/mod.rs @@ -1,5 +1,6 @@ mod current; pub use current::{Data, State}; + use serde_derive::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] diff --git a/sdk/program/src/program_error.rs b/sdk/program/src/program_error.rs index cc0f18f186..bce1a6a50e 100644 --- a/sdk/program/src/program_error.rs +++ b/sdk/program/src/program_error.rs @@ -1,11 +1,9 @@ #![allow(clippy::integer_arithmetic)] -use { - crate::{decode_error::DecodeError, instruction::InstructionError, msg, pubkey::PubkeyError}, - borsh::maybestd::io::Error as BorshIoError, - num_traits::{FromPrimitive, ToPrimitive}, - std::convert::TryFrom, - thiserror::Error, -}; +use crate::{decode_error::DecodeError, instruction::InstructionError, msg, pubkey::PubkeyError}; +use borsh::maybestd::io::Error as BorshIoError; +use num_traits::{FromPrimitive, ToPrimitive}; +use std::convert::TryFrom; +use thiserror::Error; /// Reasons the program may fail #[derive(Clone, Debug, Deserialize, Eq, Error, PartialEq, Serialize)] diff --git a/sdk/program/src/program_stubs.rs b/sdk/program/src/program_stubs.rs index 71084c1ef9..54b02b5699 100644 --- a/sdk/program/src/program_stubs.rs +++ b/sdk/program/src/program_stubs.rs @@ -2,14 +2,12 @@ #![cfg(not(target_arch = "bpf"))] -use { - crate::{ - account_info::AccountInfo, entrypoint::ProgramResult, instruction::Instruction, - program_error::UNSUPPORTED_SYSVAR, pubkey::Pubkey, - }, - itertools::Itertools, - std::sync::{Arc, RwLock}, +use crate::{ + account_info::AccountInfo, entrypoint::ProgramResult, instruction::Instruction, + program_error::UNSUPPORTED_SYSVAR, pubkey::Pubkey, }; +use itertools::Itertools; +use std::sync::{Arc, RwLock}; lazy_static::lazy_static! { static ref SYSCALL_STUBS: Arc>> = Arc::new(RwLock::new(Box::new(DefaultSyscallStubs {}))); diff --git a/sdk/program/src/pubkey.rs b/sdk/program/src/pubkey.rs index fe83e1a9d6..fc1c90ec84 100644 --- a/sdk/program/src/pubkey.rs +++ b/sdk/program/src/pubkey.rs @@ -393,7 +393,8 @@ impl fmt::Display for Pubkey { #[cfg(test)] mod tests { - use {super::*, std::str::from_utf8}; + use super::*; + use std::str::from_utf8; #[test] fn test_new_unique() { diff --git a/sdk/program/src/secp256k1_recover.rs b/sdk/program/src/secp256k1_recover.rs index 54e65c7488..4a6433d5da 100644 --- a/sdk/program/src/secp256k1_recover.rs +++ b/sdk/program/src/secp256k1_recover.rs @@ -1,8 +1,6 @@ -use { - borsh::{BorshDeserialize, BorshSchema, BorshSerialize}, - core::convert::TryFrom, - thiserror::Error, -}; +use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; +use core::convert::TryFrom; +use thiserror::Error; #[derive(Debug, Clone, PartialEq, Eq, Error)] pub enum Secp256k1RecoverError { diff --git a/sdk/program/src/serialize_utils.rs b/sdk/program/src/serialize_utils.rs index 24e85f648f..e334e3f477 100644 --- a/sdk/program/src/serialize_utils.rs +++ b/sdk/program/src/serialize_utils.rs @@ -1,5 +1,6 @@ #![allow(clippy::integer_arithmetic)] -use crate::{pubkey::Pubkey, sanitize::SanitizeError}; +use crate::pubkey::Pubkey; +use crate::sanitize::SanitizeError; pub fn append_u16(buf: &mut Vec, data: u16) { let start = buf.len(); diff --git a/sdk/program/src/short_vec.rs b/sdk/program/src/short_vec.rs index 15221bd86d..8eac739595 100644 --- a/sdk/program/src/short_vec.rs +++ b/sdk/program/src/short_vec.rs @@ -1,12 +1,10 @@ #![allow(clippy::integer_arithmetic)] -use { - serde::{ - de::{self, Deserializer, SeqAccess, Visitor}, - ser::{self, SerializeTuple, Serializer}, - Deserialize, Serialize, - }, - std::{convert::TryFrom, fmt, marker::PhantomData}, +use serde::{ + de::{self, Deserializer, SeqAccess, Visitor}, + ser::{self, SerializeTuple, Serializer}, + {Deserialize, Serialize}, }; +use std::{convert::TryFrom, fmt, marker::PhantomData}; /// Same as u16, but serialized with 1 to 3 bytes. If the value is above /// 0x7f, the top bit is set and the remaining value is stored in the next @@ -267,11 +265,9 @@ pub fn decode_shortu16_len(bytes: &[u8]) -> Result<(usize, usize), ()> { #[cfg(test)] mod tests { - use { - super::*, - assert_matches::assert_matches, - bincode::{deserialize, serialize}, - }; + use super::*; + use assert_matches::assert_matches; + use bincode::{deserialize, serialize}; /// Return the serialized length. fn encode_len(len: u16) -> Vec { diff --git a/sdk/program/src/slot_hashes.rs b/sdk/program/src/slot_hashes.rs index f8994664f6..8016505a0a 100644 --- a/sdk/program/src/slot_hashes.rs +++ b/sdk/program/src/slot_hashes.rs @@ -2,10 +2,8 @@ //! //! this account carries the Bank's most recent bank hashes for some N parents //! -use { - crate::hash::Hash, - std::{iter::FromIterator, ops::Deref}, -}; +use crate::hash::Hash; +use std::{iter::FromIterator, ops::Deref}; pub const MAX_ENTRIES: usize = 512; // about 2.5 minutes to get your vote in @@ -53,7 +51,8 @@ impl Deref for SlotHashes { #[cfg(test)] mod tests { - use {super::*, crate::hash::hash}; + use super::*; + use crate::hash::hash; #[test] fn test() { diff --git a/sdk/program/src/slot_history.rs b/sdk/program/src/slot_history.rs index dc0d0240a5..930df19bd9 100644 --- a/sdk/program/src/slot_history.rs +++ b/sdk/program/src/slot_history.rs @@ -3,7 +3,8 @@ //! slot history //! pub use crate::clock::Slot; -use bv::{BitVec, BitsMut}; +use bv::BitVec; +use bv::BitsMut; #[repr(C)] #[derive(Clone, Serialize, Deserialize, PartialEq)] @@ -85,7 +86,8 @@ impl SlotHistory { #[cfg(test)] mod tests { - use {super::*, log::*}; + use super::*; + use log::*; #[test] fn slot_history_test1() { diff --git a/sdk/program/src/stake/instruction.rs b/sdk/program/src/stake/instruction.rs index e0509400d6..6fadfd7a04 100644 --- a/sdk/program/src/stake/instruction.rs +++ b/sdk/program/src/stake/instruction.rs @@ -1,14 +1,14 @@ use { + crate::stake::{ + config, + program::id, + state::{Authorized, Lockup, StakeAuthorize, StakeState}, + }, crate::{ clock::{Epoch, UnixTimestamp}, decode_error::DecodeError, instruction::{AccountMeta, Instruction}, pubkey::Pubkey, - stake::{ - config, - program::id, - state::{Authorized, Lockup, StakeAuthorize, StakeState}, - }, system_instruction, sysvar, }, log::*, @@ -680,7 +680,8 @@ pub fn set_lockup_checked( #[cfg(test)] mod tests { - use {super::*, crate::instruction::InstructionError}; + use super::*; + use crate::instruction::InstructionError; #[test] fn test_custom_error_decode() { diff --git a/sdk/program/src/stake_history.rs b/sdk/program/src/stake_history.rs index d75090a2bc..910cb2f18a 100644 --- a/sdk/program/src/stake_history.rs +++ b/sdk/program/src/stake_history.rs @@ -3,6 +3,7 @@ //! this account carries history about stake activations and de-activations //! pub use crate::clock::Epoch; + use std::ops::Deref; pub const MAX_ENTRIES: usize = 512; // it should never take as many as 512 epochs to warm up or cool down diff --git a/sdk/program/src/system_instruction.rs b/sdk/program/src/system_instruction.rs index 77d6a58b23..01e2ce66b5 100644 --- a/sdk/program/src/system_instruction.rs +++ b/sdk/program/src/system_instruction.rs @@ -1,15 +1,13 @@ -use { - crate::{ - decode_error::DecodeError, - instruction::{AccountMeta, Instruction, InstructionError}, - nonce, - pubkey::Pubkey, - system_program, - sysvar::{recent_blockhashes, rent}, - }, - num_derive::{FromPrimitive, ToPrimitive}, - thiserror::Error, +use crate::{ + decode_error::DecodeError, + instruction::{AccountMeta, Instruction, InstructionError}, + nonce, + pubkey::Pubkey, + system_program, + sysvar::{recent_blockhashes, rent}, }; +use num_derive::{FromPrimitive, ToPrimitive}; +use thiserror::Error; #[derive(Error, Debug, Serialize, Clone, PartialEq, FromPrimitive, ToPrimitive)] pub enum SystemError { @@ -569,11 +567,9 @@ pub fn authorize_nonce_account( #[cfg(test)] mod tests { - use { - super::*, - crate::instruction::{Instruction, InstructionError}, - num_traits::ToPrimitive, - }; + use super::*; + use crate::instruction::{Instruction, InstructionError}; + use num_traits::ToPrimitive; fn get_keys(instruction: &Instruction) -> Vec { instruction.accounts.iter().map(|x| x.pubkey).collect() diff --git a/sdk/program/src/sysvar/clock.rs b/sdk/program/src/sysvar/clock.rs index d6a8c73d81..89566a0574 100644 --- a/sdk/program/src/sysvar/clock.rs +++ b/sdk/program/src/sysvar/clock.rs @@ -1,6 +1,7 @@ //! This account contains the clock slot, epoch, and leader_schedule_epoch //! pub use crate::clock::Clock; + use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar}; crate::declare_sysvar_id!("SysvarC1ock11111111111111111111111111111111", Clock); diff --git a/sdk/program/src/sysvar/epoch_schedule.rs b/sdk/program/src/sysvar/epoch_schedule.rs index d5b1a81a10..502d477d9e 100644 --- a/sdk/program/src/sysvar/epoch_schedule.rs +++ b/sdk/program/src/sysvar/epoch_schedule.rs @@ -1,6 +1,7 @@ //! This account contains the current cluster rent //! pub use crate::epoch_schedule::EpochSchedule; + use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar}; crate::declare_sysvar_id!("SysvarEpochSchedu1e111111111111111111111111", EpochSchedule); diff --git a/sdk/program/src/sysvar/instructions.rs b/sdk/program/src/sysvar/instructions.rs index 696cc8897e..30e6716c7f 100644 --- a/sdk/program/src/sysvar/instructions.rs +++ b/sdk/program/src/sysvar/instructions.rs @@ -105,10 +105,8 @@ pub fn get_instruction_relative( #[cfg(test)] mod tests { - use { - super::*, - crate::{instruction::AccountMeta, message::Message, pubkey::Pubkey}, - }; + use super::*; + use crate::{instruction::AccountMeta, message::Message, pubkey::Pubkey}; #[test] fn test_load_store_instruction() { diff --git a/sdk/program/src/sysvar/mod.rs b/sdk/program/src/sysvar/mod.rs index f6a539a373..1cc67068d9 100644 --- a/sdk/program/src/sysvar/mod.rs +++ b/sdk/program/src/sysvar/mod.rs @@ -108,11 +108,9 @@ macro_rules! impl_sysvar_get { #[cfg(test)] mod tests { - use { - super::*, - crate::{clock::Epoch, program_error::ProgramError, pubkey::Pubkey}, - std::{cell::RefCell, rc::Rc}, - }; + use super::*; + use crate::{clock::Epoch, program_error::ProgramError, pubkey::Pubkey}; + use std::{cell::RefCell, rc::Rc}; #[repr(C)] #[derive(Serialize, Deserialize, Debug, Default, PartialEq)] diff --git a/sdk/program/src/sysvar/recent_blockhashes.rs b/sdk/program/src/sysvar/recent_blockhashes.rs index 5d3114d827..00f822c74e 100644 --- a/sdk/program/src/sysvar/recent_blockhashes.rs +++ b/sdk/program/src/sysvar/recent_blockhashes.rs @@ -1,13 +1,11 @@ #![allow(clippy::integer_arithmetic)] -use { - crate::{ - declare_sysvar_id, - fee_calculator::FeeCalculator, - hash::{hash, Hash}, - sysvar::Sysvar, - }, - std::{cmp::Ordering, collections::BinaryHeap, iter::FromIterator, ops::Deref}, +use crate::{ + declare_sysvar_id, + fee_calculator::FeeCalculator, + hash::{hash, Hash}, + sysvar::Sysvar, }; +use std::{cmp::Ordering, collections::BinaryHeap, iter::FromIterator, ops::Deref}; pub const MAX_ENTRIES: usize = 150; @@ -147,7 +145,8 @@ pub fn create_test_recent_blockhashes(start: usize) -> RecentBlockhashes { #[cfg(test)] mod tests { - use {super::*, crate::clock::MAX_PROCESSING_AGE}; + use super::*; + use crate::clock::MAX_PROCESSING_AGE; #[test] #[allow(clippy::assertions_on_constants)] diff --git a/sdk/program/src/sysvar/rent.rs b/sdk/program/src/sysvar/rent.rs index 83f2dfdecb..13e7f32367 100644 --- a/sdk/program/src/sysvar/rent.rs +++ b/sdk/program/src/sysvar/rent.rs @@ -1,6 +1,7 @@ //! This account contains the current cluster rent //! pub use crate::rent::Rent; + use crate::{impl_sysvar_get, program_error::ProgramError, sysvar::Sysvar}; crate::declare_sysvar_id!("SysvarRent111111111111111111111111111111111", Rent); diff --git a/sdk/program/src/sysvar/slot_hashes.rs b/sdk/program/src/sysvar/slot_hashes.rs index e1f9d10a87..d10cb57d8a 100644 --- a/sdk/program/src/sysvar/slot_hashes.rs +++ b/sdk/program/src/sysvar/slot_hashes.rs @@ -3,6 +3,7 @@ //! this account carries the Bank's most recent bank hashes for some N parents //! pub use crate::slot_hashes::SlotHashes; + use crate::{account_info::AccountInfo, program_error::ProgramError, sysvar::Sysvar}; crate::declare_sysvar_id!("SysvarS1otHashes111111111111111111111111111", SlotHashes); @@ -21,10 +22,8 @@ impl Sysvar for SlotHashes { #[cfg(test)] mod tests { - use { - super::*, - crate::{clock::Slot, hash::Hash, slot_hashes::MAX_ENTRIES}, - }; + use super::*; + use crate::{clock::Slot, hash::Hash, slot_hashes::MAX_ENTRIES}; #[test] fn test_size_of() { diff --git a/sdk/program/src/sysvar/slot_history.rs b/sdk/program/src/sysvar/slot_history.rs index a180a2398f..fae51b2f26 100644 --- a/sdk/program/src/sysvar/slot_history.rs +++ b/sdk/program/src/sysvar/slot_history.rs @@ -3,11 +3,12 @@ //! this account carries a bitvector of slots present over the past //! epoch //! -use crate::sysvar::Sysvar; pub use crate::{ account_info::AccountInfo, program_error::ProgramError, slot_history::SlotHistory, }; +use crate::sysvar::Sysvar; + crate::declare_sysvar_id!("SysvarS1otHistory11111111111111111111111111", SlotHistory); impl Sysvar for SlotHistory { diff --git a/sdk/program/src/sysvar/stake_history.rs b/sdk/program/src/sysvar/stake_history.rs index 070b6956d0..8438f3f05d 100644 --- a/sdk/program/src/sysvar/stake_history.rs +++ b/sdk/program/src/sysvar/stake_history.rs @@ -3,6 +3,7 @@ //! this account carries history about stake activations and de-activations //! pub use crate::stake_history::StakeHistory; + use crate::sysvar::Sysvar; crate::declare_sysvar_id!("SysvarStakeHistory1111111111111111111111111", StakeHistory); @@ -17,7 +18,8 @@ impl Sysvar for StakeHistory { #[cfg(test)] mod tests { - use {super::*, crate::stake_history::*}; + use super::*; + use crate::stake_history::*; #[test] fn test_size_of() { diff --git a/sdk/src/account.rs b/sdk/src/account.rs index 0d09db7b8d..a3f467d5a5 100644 --- a/sdk/src/account.rs +++ b/sdk/src/account.rs @@ -1,17 +1,10 @@ -use { - crate::{ - clock::{Epoch, INITIAL_RENT_EPOCH}, - lamports::LamportsError, - pubkey::Pubkey, - }, - solana_program::{account_info::AccountInfo, sysvar::Sysvar}, - std::{ - cell::{Ref, RefCell}, - cmp, fmt, - rc::Rc, - sync::Arc, - }, +use crate::{ + clock::{Epoch, INITIAL_RENT_EPOCH}, + lamports::LamportsError, + pubkey::Pubkey, }; +use solana_program::{account_info::AccountInfo, sysvar::Sysvar}; +use std::{cell::Ref, cell::RefCell, cmp, fmt, rc::Rc, sync::Arc}; /// An Account with data that is stored on chain #[repr(C)] diff --git a/sdk/src/account_utils.rs b/sdk/src/account_utils.rs index 226fcb8323..a7f5f30366 100644 --- a/sdk/src/account_utils.rs +++ b/sdk/src/account_utils.rs @@ -1,12 +1,7 @@ //! useful extras for Account state -use { - crate::{ - account::{Account, AccountSharedData}, - instruction::InstructionError, - }, - bincode::ErrorKind, - std::cell::Ref, -}; +use crate::{account::Account, account::AccountSharedData, instruction::InstructionError}; +use bincode::ErrorKind; +use std::cell::Ref; /// Convenience trait to covert bincode errors to instruction errors. pub trait StateMut { @@ -65,10 +60,8 @@ where #[cfg(test)] mod tests { - use { - super::*, - crate::{account::AccountSharedData, pubkey::Pubkey}, - }; + use super::*; + use crate::{account::AccountSharedData, pubkey::Pubkey}; #[test] fn test_account_state() { diff --git a/sdk/src/commitment_config.rs b/sdk/src/commitment_config.rs index a3f7da1cb6..1e77c65968 100644 --- a/sdk/src/commitment_config.rs +++ b/sdk/src/commitment_config.rs @@ -1,7 +1,8 @@ #![allow(deprecated)] #![cfg(feature = "full")] -use {std::str::FromStr, thiserror::Error}; +use std::str::FromStr; +use thiserror::Error; #[derive(Serialize, Deserialize, Default, Clone, Copy, Debug, PartialEq, Eq, Hash)] #[serde(rename_all = "camelCase")] diff --git a/sdk/src/compute_budget.rs b/sdk/src/compute_budget.rs index e027633262..f1cdd84bc4 100644 --- a/sdk/src/compute_budget.rs +++ b/sdk/src/compute_budget.rs @@ -1,19 +1,17 @@ #![cfg(feature = "full")] -use { - crate::{ - entrypoint::HEAP_LENGTH as MIN_HEAP_FRAME_BYTES, - feature_set::{requestable_heap_size, FeatureSet}, - process_instruction::BpfComputeBudget, - transaction::{Transaction, TransactionError}, - }, - borsh::{BorshDeserialize, BorshSchema, BorshSerialize}, - solana_sdk::{ - borsh::try_from_slice_unchecked, - instruction::{Instruction, InstructionError}, - }, - std::sync::Arc, +use crate::{ + entrypoint::HEAP_LENGTH as MIN_HEAP_FRAME_BYTES, + feature_set::{requestable_heap_size, FeatureSet}, + process_instruction::BpfComputeBudget, + transaction::{Transaction, TransactionError}, }; +use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; +use solana_sdk::{ + borsh::try_from_slice_unchecked, + instruction::{Instruction, InstructionError}, +}; +use std::sync::Arc; crate::declare_id!("ComputeBudget111111111111111111111111111111"); @@ -93,10 +91,8 @@ pub fn process_request( #[cfg(test)] mod tests { - use { - super::*, - crate::{hash::Hash, message::Message, pubkey::Pubkey, signature::Keypair, signer::Signer}, - }; + use super::*; + use crate::{hash::Hash, message::Message, pubkey::Pubkey, signature::Keypair, signer::Signer}; macro_rules! test { ( $instructions: expr, $expected_error: expr, $expected_budget: expr ) => { diff --git a/sdk/src/derivation_path.rs b/sdk/src/derivation_path.rs index a90b715e37..06feb0cfbd 100644 --- a/sdk/src/derivation_path.rs +++ b/sdk/src/derivation_path.rs @@ -260,7 +260,8 @@ impl Bip44 for Solana { #[cfg(test)] mod tests { - use {super::*, uriparse::URIReferenceBuilder}; + use super::*; + use uriparse::URIReferenceBuilder; struct TestCoin; impl Bip44 for TestCoin { diff --git a/sdk/src/deserialize_utils.rs b/sdk/src/deserialize_utils.rs index 9eb37d2e05..e6293e293d 100644 --- a/sdk/src/deserialize_utils.rs +++ b/sdk/src/deserialize_utils.rs @@ -18,7 +18,8 @@ where #[cfg(test)] pub mod tests { - use {super::*, bincode::deserialize}; + use super::*; + use bincode::deserialize; #[test] fn test_default_on_eof() { diff --git a/sdk/src/ed25519_instruction.rs b/sdk/src/ed25519_instruction.rs index 911b31e80b..33232239ae 100644 --- a/sdk/src/ed25519_instruction.rs +++ b/sdk/src/ed25519_instruction.rs @@ -1,11 +1,9 @@ #![cfg(feature = "full")] -use { - crate::{decode_error::DecodeError, instruction::Instruction}, - bytemuck::{bytes_of, Pod, Zeroable}, - ed25519_dalek::{ed25519::signature::Signature, Signer, Verifier}, - thiserror::Error, -}; +use crate::{decode_error::DecodeError, instruction::Instruction}; +use bytemuck::{bytes_of, Pod, Zeroable}; +use ed25519_dalek::{ed25519::signature::Signature, Signer, Verifier}; +use thiserror::Error; #[derive(Error, Debug, Clone, PartialEq)] pub enum Ed25519Error { diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index c3dc05879a..3d346d7bff 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -1,12 +1,10 @@ -use { - lazy_static::lazy_static, - solana_sdk::{ - clock::Slot, - hash::{Hash, Hasher}, - pubkey::Pubkey, - }, - std::collections::{HashMap, HashSet}, +use lazy_static::lazy_static; +use solana_sdk::{ + clock::Slot, + hash::{Hash, Hasher}, + pubkey::Pubkey, }; +use std::collections::{HashMap, HashSet}; pub mod instructions_sysvar_enabled { solana_sdk::declare_id!("EnvhHCLvg55P7PDtbvR1NwuTuAeodqpusV3MR5QEK8gs"); diff --git a/sdk/src/genesis_config.rs b/sdk/src/genesis_config.rs index 4b3568d472..3c7c363f1c 100644 --- a/sdk/src/genesis_config.rs +++ b/sdk/src/genesis_config.rs @@ -2,35 +2,34 @@ #![cfg(feature = "full")] -use { - crate::{ - account::{Account, AccountSharedData}, - clock::{UnixTimestamp, DEFAULT_TICKS_PER_SLOT}, - epoch_schedule::EpochSchedule, - fee_calculator::FeeRateGovernor, - hash::{hash, Hash}, - inflation::Inflation, - native_token::lamports_to_sol, - poh_config::PohConfig, - pubkey::Pubkey, - rent::Rent, - shred_version::compute_shred_version, - signature::{Keypair, Signer}, - system_program, - timing::years_as_slots, - }, - bincode::{deserialize, serialize}, - chrono::{TimeZone, Utc}, - memmap2::Mmap, - std::{ - collections::BTreeMap, - fmt, - fs::{File, OpenOptions}, - io::Write, - path::{Path, PathBuf}, - str::FromStr, - time::{SystemTime, UNIX_EPOCH}, - }, +use crate::{ + account::Account, + account::AccountSharedData, + clock::{UnixTimestamp, DEFAULT_TICKS_PER_SLOT}, + epoch_schedule::EpochSchedule, + fee_calculator::FeeRateGovernor, + hash::{hash, Hash}, + inflation::Inflation, + native_token::lamports_to_sol, + poh_config::PohConfig, + pubkey::Pubkey, + rent::Rent, + shred_version::compute_shred_version, + signature::{Keypair, Signer}, + system_program, + timing::years_as_slots, +}; +use bincode::{deserialize, serialize}; +use chrono::{TimeZone, Utc}; +use memmap2::Mmap; +use std::{ + collections::BTreeMap, + fmt, + fs::{File, OpenOptions}, + io::Write, + path::{Path, PathBuf}, + str::FromStr, + time::{SystemTime, UNIX_EPOCH}, }; pub const DEFAULT_GENESIS_FILE: &str = "genesis.bin"; @@ -294,11 +293,9 @@ impl fmt::Display for GenesisConfig { #[cfg(test)] mod tests { - use { - super::*, - crate::signature::{Keypair, Signer}, - std::path::PathBuf, - }; + use super::*; + use crate::signature::{Keypair, Signer}; + use std::path::PathBuf; fn make_tmp_path(name: &str) -> PathBuf { let out_dir = std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()); diff --git a/sdk/src/hard_forks.rs b/sdk/src/hard_forks.rs index a83168ce37..1714fef458 100644 --- a/sdk/src/hard_forks.rs +++ b/sdk/src/hard_forks.rs @@ -3,10 +3,8 @@ #![cfg(feature = "full")] -use { - byteorder::{ByteOrder, LittleEndian}, - solana_sdk::clock::Slot, -}; +use byteorder::{ByteOrder, LittleEndian}; +use solana_sdk::clock::Slot; #[derive(Default, Clone, Debug, Deserialize, Serialize, AbiExample, PartialEq, Eq)] pub struct HardForks { diff --git a/sdk/src/keyed_account.rs b/sdk/src/keyed_account.rs index 88ac3acb3c..6188ae8fb4 100644 --- a/sdk/src/keyed_account.rs +++ b/sdk/src/keyed_account.rs @@ -1,14 +1,12 @@ -use { - crate::{ - account::{from_account, AccountSharedData, ReadableAccount}, - account_utils::{State, StateMut}, - }, - solana_program::{clock::Epoch, instruction::InstructionError, pubkey::Pubkey, sysvar::Sysvar}, - std::{ - cell::{Ref, RefCell, RefMut}, - iter::FromIterator, - rc::Rc, - }, +use crate::{ + account::{from_account, AccountSharedData, ReadableAccount}, + account_utils::{State, StateMut}, +}; +use solana_program::{clock::Epoch, instruction::InstructionError, pubkey::Pubkey, sysvar::Sysvar}; +use std::{ + cell::{Ref, RefCell, RefMut}, + iter::FromIterator, + rc::Rc, }; #[repr(C)] @@ -258,14 +256,12 @@ pub fn from_keyed_account( #[cfg(test)] mod tests { - use { - super::*, - crate::{ - account::{create_account_for_test, to_account}, - pubkey::Pubkey, - }, - std::cell::RefCell, + use super::*; + use crate::{ + account::{create_account_for_test, to_account}, + pubkey::Pubkey, }; + use std::cell::RefCell; #[repr(C)] #[derive(Serialize, Deserialize, Debug, Default, PartialEq)] diff --git a/sdk/src/native_loader.rs b/sdk/src/native_loader.rs index 68b835e1bb..eaed82bade 100644 --- a/sdk/src/native_loader.rs +++ b/sdk/src/native_loader.rs @@ -1,9 +1,7 @@ -use crate::{ - account::{ - Account, AccountSharedData, InheritableAccountFields, DUMMY_INHERITABLE_ACCOUNT_FIELDS, - }, - clock::INITIAL_RENT_EPOCH, +use crate::account::{ + Account, AccountSharedData, InheritableAccountFields, DUMMY_INHERITABLE_ACCOUNT_FIELDS, }; +use crate::clock::INITIAL_RENT_EPOCH; crate::declare_id!("NativeLoader1111111111111111111111111111111"); diff --git a/sdk/src/nonce_account.rs b/sdk/src/nonce_account.rs index b9f031af14..dcfff92e52 100644 --- a/sdk/src/nonce_account.rs +++ b/sdk/src/nonce_account.rs @@ -1,13 +1,11 @@ -use { - crate::{ - account::{AccountSharedData, ReadableAccount}, - account_utils::StateMut, - fee_calculator::FeeCalculator, - hash::Hash, - nonce::{state::Versions, State}, - }, - std::cell::RefCell, +use crate::{ + account::{AccountSharedData, ReadableAccount}, + account_utils::StateMut, + fee_calculator::FeeCalculator, + hash::Hash, + nonce::{state::Versions, State}, }; +use std::cell::RefCell; pub fn create_account(lamports: u64) -> RefCell { RefCell::new( @@ -43,7 +41,8 @@ pub fn fee_calculator_of(account: &AccountSharedData) -> Option { #[cfg(test)] mod tests { - use {super::*, crate::pubkey::Pubkey}; + use super::*; + use crate::pubkey::Pubkey; #[test] fn test_verify_bad_account_owner_fails() { diff --git a/sdk/src/nonce_keyed_account.rs b/sdk/src/nonce_keyed_account.rs index 07857eba71..d9e6fc4ae5 100644 --- a/sdk/src/nonce_keyed_account.rs +++ b/sdk/src/nonce_keyed_account.rs @@ -1,21 +1,19 @@ -use { - crate::{ - account::{ReadableAccount, WritableAccount}, - account_utils::State as AccountUtilsState, - feature_set, ic_msg, - keyed_account::KeyedAccount, - nonce_account::create_account, - process_instruction::InvokeContext, - }, - solana_program::{ - instruction::{checked_add, InstructionError}, - nonce::{self, state::Versions, State}, - pubkey::Pubkey, - system_instruction::{nonce_to_instruction_error, NonceError}, - sysvar::{recent_blockhashes::RecentBlockhashes, rent::Rent}, - }, - std::collections::HashSet, +use crate::{ + account::{ReadableAccount, WritableAccount}, + account_utils::State as AccountUtilsState, + feature_set, ic_msg, + keyed_account::KeyedAccount, + nonce_account::create_account, + process_instruction::InvokeContext, }; +use solana_program::{ + instruction::{checked_add, InstructionError}, + nonce::{self, state::Versions, State}, + pubkey::Pubkey, + system_instruction::{nonce_to_instruction_error, NonceError}, + sysvar::{recent_blockhashes::RecentBlockhashes, rent::Rent}, +}; +use std::collections::HashSet; pub trait NonceKeyedAccount { fn advance_nonce_account( @@ -296,20 +294,18 @@ where #[cfg(test)] mod test { - use { - super::*, - crate::{ - account::ReadableAccount, - account_utils::State as AccountUtilsState, - keyed_account::KeyedAccount, - nonce::{self, State}, - nonce_account::verify_nonce_account, - process_instruction::MockInvokeContext, - system_instruction::SystemError, - sysvar::recent_blockhashes::create_test_recent_blockhashes, - }, - solana_program::hash::Hash, + use super::*; + use crate::{ + account::ReadableAccount, + account_utils::State as AccountUtilsState, + keyed_account::KeyedAccount, + nonce::{self, State}, + nonce_account::verify_nonce_account, + process_instruction::MockInvokeContext, + system_instruction::SystemError, + sysvar::recent_blockhashes::create_test_recent_blockhashes, }; + use solana_program::hash::Hash; #[test] fn default_is_uninitialized() { diff --git a/sdk/src/packet.rs b/sdk/src/packet.rs index 27435b3ae6..62b9e0f960 100644 --- a/sdk/src/packet.rs +++ b/sdk/src/packet.rs @@ -1,11 +1,9 @@ -use { - crate::clock::Slot, - bincode::Result, - serde::Serialize, - std::{ - fmt, io, - net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, - }, +use crate::clock::Slot; +use bincode::Result; +use serde::Serialize; +use std::{ + net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, + {fmt, io}, }; /// Maximum over-the-wire size of a Transaction diff --git a/sdk/src/poh_config.rs b/sdk/src/poh_config.rs index 9639ed4530..a393365750 100644 --- a/sdk/src/poh_config.rs +++ b/sdk/src/poh_config.rs @@ -1,7 +1,5 @@ -use { - crate::{clock::DEFAULT_TICKS_PER_SECOND, unchecked_div_by_const}, - std::time::Duration, -}; +use crate::{clock::DEFAULT_TICKS_PER_SECOND, unchecked_div_by_const}; +use std::time::Duration; #[derive(Serialize, Deserialize, Clone, Debug, AbiExample)] pub struct PohConfig { diff --git a/sdk/src/process_instruction.rs b/sdk/src/process_instruction.rs index d2fa2f2fa0..98859439aa 100644 --- a/sdk/src/process_instruction.rs +++ b/sdk/src/process_instruction.rs @@ -1,14 +1,12 @@ -use { - itertools::Itertools, - solana_sdk::{ - account::AccountSharedData, - instruction::{CompiledInstruction, Instruction, InstructionError}, - keyed_account::{create_keyed_accounts_unified, KeyedAccount}, - pubkey::Pubkey, - sysvar::Sysvar, - }, - std::{cell::RefCell, collections::HashSet, fmt::Debug, rc::Rc, sync::Arc}, +use itertools::Itertools; +use solana_sdk::{ + account::AccountSharedData, + instruction::{CompiledInstruction, Instruction, InstructionError}, + keyed_account::{create_keyed_accounts_unified, KeyedAccount}, + pubkey::Pubkey, + sysvar::Sysvar, }; +use std::{cell::RefCell, collections::HashSet, fmt::Debug, rc::Rc, sync::Arc}; /// Prototype of a native loader entry point /// diff --git a/sdk/src/program_utils.rs b/sdk/src/program_utils.rs index 590e81ae39..cfe8033479 100644 --- a/sdk/src/program_utils.rs +++ b/sdk/src/program_utils.rs @@ -1,4 +1,5 @@ -use {crate::instruction::InstructionError, bincode::config::Options}; +use crate::instruction::InstructionError; +use bincode::config::Options; /// Deserialize with a limit based the maximum amount of data a program can expect to get. /// This function should be used in place of direct deserialization to help prevent OOM errors diff --git a/sdk/src/pubkey.rs b/sdk/src/pubkey.rs index 4b343ae629..a5fe36adde 100644 --- a/sdk/src/pubkey.rs +++ b/sdk/src/pubkey.rs @@ -33,7 +33,8 @@ pub fn read_pubkey_file(infile: &str) -> Result Result<(), Box> { diff --git a/sdk/src/recent_blockhashes_account.rs b/sdk/src/recent_blockhashes_account.rs index 053f5ba2ec..58a0694b47 100644 --- a/sdk/src/recent_blockhashes_account.rs +++ b/sdk/src/recent_blockhashes_account.rs @@ -1,16 +1,12 @@ -use { - crate::{ - account::{ - create_account_shared_data_with_fields, to_account, AccountSharedData, - InheritableAccountFields, DUMMY_INHERITABLE_ACCOUNT_FIELDS, - }, - clock::INITIAL_RENT_EPOCH, - }, - solana_program::sysvar::recent_blockhashes::{ - IntoIterSorted, IterItem, RecentBlockhashes, MAX_ENTRIES, - }, - std::{collections::BinaryHeap, iter::FromIterator}, +use crate::account::{ + create_account_shared_data_with_fields, to_account, AccountSharedData, + InheritableAccountFields, DUMMY_INHERITABLE_ACCOUNT_FIELDS, }; +use crate::clock::INITIAL_RENT_EPOCH; +use solana_program::sysvar::recent_blockhashes::{ + IntoIterSorted, IterItem, RecentBlockhashes, MAX_ENTRIES, +}; +use std::{collections::BinaryHeap, iter::FromIterator}; pub fn update_account<'a, I>( account: &mut AccountSharedData, @@ -61,15 +57,13 @@ where #[cfg(test)] mod tests { - use { - super::*, - crate::account::from_account, - rand::{seq::SliceRandom, thread_rng}, - solana_program::{ - fee_calculator::FeeCalculator, - hash::{Hash, HASH_BYTES}, - sysvar::recent_blockhashes::Entry, - }, + use super::*; + use crate::account::from_account; + use rand::{seq::SliceRandom, thread_rng}; + use solana_program::{ + fee_calculator::FeeCalculator, + hash::{Hash, HASH_BYTES}, + sysvar::recent_blockhashes::Entry, }; #[test] diff --git a/sdk/src/secp256k1_instruction.rs b/sdk/src/secp256k1_instruction.rs index a79a0054f7..afe2b88b9e 100644 --- a/sdk/src/secp256k1_instruction.rs +++ b/sdk/src/secp256k1_instruction.rs @@ -1,10 +1,8 @@ #![cfg(feature = "full")] -use { - crate::instruction::Instruction, - digest::Digest, - serde_derive::{Deserialize, Serialize}, -}; +use crate::instruction::Instruction; +use digest::Digest; +use serde_derive::{Deserialize, Serialize}; #[derive(Debug, PartialEq)] pub enum Secp256k1Error { diff --git a/sdk/src/signature.rs b/sdk/src/signature.rs index 353b42444d..bf4f5e4322 100644 --- a/sdk/src/signature.rs +++ b/sdk/src/signature.rs @@ -1,19 +1,18 @@ //! The `signature` module provides functionality for public, and private keys. #![cfg(feature = "full")] +use crate::pubkey::Pubkey; +use generic_array::{typenum::U64, GenericArray}; +use std::{ + borrow::{Borrow, Cow}, + convert::TryInto, + fmt, mem, + str::FromStr, +}; +use thiserror::Error; + // legacy module paths pub use crate::signer::{keypair::*, null_signer::*, presigner::*, *}; -use { - crate::pubkey::Pubkey, - generic_array::{typenum::U64, GenericArray}, - std::{ - borrow::{Borrow, Cow}, - convert::TryInto, - fmt, mem, - str::FromStr, - }, - thiserror::Error, -}; /// Number of bytes in a signature pub const SIGNATURE_BYTES: usize = 64; diff --git a/sdk/src/signer/mod.rs b/sdk/src/signer/mod.rs index 3a4c4cd022..27a4d07066 100644 --- a/sdk/src/signer/mod.rs +++ b/sdk/src/signer/mod.rs @@ -100,7 +100,8 @@ pub fn unique_signers(signers: Vec<&dyn Signer>) -> Vec<&dyn Signer> { #[cfg(test)] mod tests { - use {super::*, crate::signer::keypair::Keypair}; + use super::*; + use crate::signer::keypair::Keypair; fn pubkeys(signers: &[&dyn Signer]) -> Vec { signers.iter().map(|x| x.pubkey()).collect() diff --git a/sdk/src/signer/presigner.rs b/sdk/src/signer/presigner.rs index 47eb3119ef..a5f16fb6e1 100644 --- a/sdk/src/signer/presigner.rs +++ b/sdk/src/signer/presigner.rs @@ -63,7 +63,8 @@ where #[cfg(test)] mod tests { - use {super::*, crate::signer::keypair::keypair_from_seed}; + use super::*; + use crate::signer::keypair::keypair_from_seed; #[test] fn test_presigner() { diff --git a/sdk/src/timing.rs b/sdk/src/timing.rs index 42e3ba48ef..f415848a49 100644 --- a/sdk/src/timing.rs +++ b/sdk/src/timing.rs @@ -1,11 +1,7 @@ //! The `timing` module provides std::time utility functions. -use { - crate::unchecked_div_by_const, - std::{ - sync::atomic::{AtomicU64, Ordering}, - time::{Duration, SystemTime, UNIX_EPOCH}, - }, -}; +use crate::unchecked_div_by_const; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::time::{Duration, SystemTime, UNIX_EPOCH}; pub fn duration_as_ns(d: &Duration) -> u64 { d.as_secs() diff --git a/sdk/src/transaction.rs b/sdk/src/transaction.rs index 96f6cf969b..c6bc85a5a9 100644 --- a/sdk/src/transaction.rs +++ b/sdk/src/transaction.rs @@ -2,27 +2,26 @@ #![cfg(feature = "full")] -use { - crate::{ - ed25519_instruction::verify_signatures, - feature_set, - hash::Hash, - instruction::{CompiledInstruction, Instruction, InstructionError}, - message::Message, - nonce::NONCED_TX_MARKER_IX_INDEX, - program_utils::limited_deserialize, - pubkey::Pubkey, - sanitize::{Sanitize, SanitizeError}, - secp256k1_instruction::verify_eth_addresses, - short_vec, - signature::{Signature, SignerError}, - signers::Signers, - system_instruction::SystemInstruction, - system_program, - }, - std::{result, sync::Arc}, - thiserror::Error, +use crate::sanitize::{Sanitize, SanitizeError}; +use crate::secp256k1_instruction::verify_eth_addresses; +use crate::{ + ed25519_instruction::verify_signatures, + feature_set, + hash::Hash, + instruction::{CompiledInstruction, Instruction, InstructionError}, + message::Message, + nonce::NONCED_TX_MARKER_IX_INDEX, + program_utils::limited_deserialize, + pubkey::Pubkey, + short_vec, + signature::{Signature, SignerError}, + signers::Signers, + system_instruction::SystemInstruction, + system_program, }; +use std::result; +use std::sync::Arc; +use thiserror::Error; /// Reasons a transaction might be rejected. #[derive( @@ -520,17 +519,15 @@ pub fn get_nonce_pubkey_from_instruction<'a>( #[cfg(test)] mod tests { - use { - super::*, - crate::{ - hash::hash, - instruction::AccountMeta, - signature::{Keypair, Presigner, Signer}, - system_instruction, - }, - bincode::{deserialize, serialize, serialized_size}, - std::mem::size_of, + use super::*; + use crate::{ + hash::hash, + instruction::AccountMeta, + signature::{Keypair, Presigner, Signer}, + system_instruction, }; + use bincode::{deserialize, serialize, serialized_size}; + use std::mem::size_of; fn get_program_id(tx: &Transaction, instruction_index: usize) -> &Pubkey { let message = tx.message(); diff --git a/sdk/src/transport.rs b/sdk/src/transport.rs index fe8b178faf..db4cef4bb0 100644 --- a/sdk/src/transport.rs +++ b/sdk/src/transport.rs @@ -1,6 +1,8 @@ #![cfg(feature = "full")] -use {crate::transaction::TransactionError, std::io, thiserror::Error}; +use crate::transaction::TransactionError; +use std::io; +use thiserror::Error; #[derive(Debug, Error)] pub enum TransportError { diff --git a/stake-accounts/src/arg_parser.rs b/stake-accounts/src/arg_parser.rs index a29b880cbe..fefd2ab113 100644 --- a/stake-accounts/src/arg_parser.rs +++ b/stake-accounts/src/arg_parser.rs @@ -1,17 +1,16 @@ -use { - crate::args::{ - Args, AuthorizeArgs, Command, CountArgs, MoveArgs, NewArgs, QueryArgs, RebaseArgs, - SetLockupArgs, - }, - clap::{value_t, value_t_or_exit, App, Arg, ArgMatches, SubCommand}, - solana_clap_utils::{ - input_parsers::unix_timestamp_from_rfc3339_datetime, - input_validators::{is_amount, is_rfc3339_datetime, is_valid_pubkey, is_valid_signer}, - }, - solana_cli_config::CONFIG_FILE, - solana_sdk::native_token::sol_to_lamports, - std::{ffi::OsString, process::exit}, +use crate::args::{ + Args, AuthorizeArgs, Command, CountArgs, MoveArgs, NewArgs, QueryArgs, RebaseArgs, + SetLockupArgs, }; +use clap::{value_t, value_t_or_exit, App, Arg, ArgMatches, SubCommand}; +use solana_clap_utils::{ + input_parsers::unix_timestamp_from_rfc3339_datetime, + input_validators::{is_amount, is_rfc3339_datetime, is_valid_pubkey, is_valid_signer}, +}; +use solana_cli_config::CONFIG_FILE; +use solana_sdk::native_token::sol_to_lamports; +use std::ffi::OsString; +use std::process::exit; fn fee_payer_arg<'a, 'b>() -> Arg<'a, 'b> { solana_clap_utils::fee_payer::fee_payer_arg().required(true) diff --git a/stake-accounts/src/args.rs b/stake-accounts/src/args.rs index de25dca870..56a0a3a6fe 100644 --- a/stake-accounts/src/args.rs +++ b/stake-accounts/src/args.rs @@ -1,14 +1,13 @@ -use { - clap::ArgMatches, - solana_clap_utils::keypair::{pubkey_from_path, signer_from_path}, - solana_remote_wallet::remote_wallet::RemoteWalletManager, - solana_sdk::{ - clock::{Epoch, UnixTimestamp}, - pubkey::Pubkey, - signature::Signer, - }, - std::{error::Error, sync::Arc}, +use clap::ArgMatches; +use solana_clap_utils::keypair::{pubkey_from_path, signer_from_path}; +use solana_remote_wallet::remote_wallet::RemoteWalletManager; +use solana_sdk::{ + clock::{Epoch, UnixTimestamp}, + pubkey::Pubkey, + signature::Signer, }; +use std::error::Error; +use std::sync::Arc; pub(crate) struct NewArgs { pub fee_payer: K, diff --git a/stake-accounts/src/main.rs b/stake-accounts/src/main.rs index ce81bac1d7..94cca8701d 100644 --- a/stake-accounts/src/main.rs +++ b/stake-accounts/src/main.rs @@ -3,27 +3,25 @@ mod arg_parser; mod args; mod stake_accounts; -use { - crate::{ - arg_parser::parse_args, - args::{ - resolve_command, AuthorizeArgs, Command, MoveArgs, NewArgs, RebaseArgs, SetLockupArgs, - }, - }, - solana_cli_config::Config, - solana_client::{client_error::ClientError, rpc_client::RpcClient}, - solana_sdk::{ - message::Message, - native_token::lamports_to_sol, - pubkey::Pubkey, - signature::{unique_signers, Signature, Signer}, - signers::Signers, - stake::{instruction::LockupArgs, state::Lockup}, - transaction::Transaction, - }, - solana_stake_program::stake_state, - std::{env, error::Error}, +use crate::arg_parser::parse_args; +use crate::args::{ + resolve_command, AuthorizeArgs, Command, MoveArgs, NewArgs, RebaseArgs, SetLockupArgs, }; +use solana_cli_config::Config; +use solana_client::client_error::ClientError; +use solana_client::rpc_client::RpcClient; +use solana_sdk::{ + message::Message, + native_token::lamports_to_sol, + pubkey::Pubkey, + signature::{unique_signers, Signature, Signer}, + signers::Signers, + stake::{instruction::LockupArgs, state::Lockup}, + transaction::Transaction, +}; +use solana_stake_program::stake_state; +use std::env; +use std::error::Error; fn get_balance_at(client: &RpcClient, pubkey: &Pubkey, i: usize) -> Result { let address = stake_accounts::derive_stake_account_address(pubkey, i); diff --git a/stake-accounts/src/stake_accounts.rs b/stake-accounts/src/stake_accounts.rs index 39af3fe25a..ef183c338b 100644 --- a/stake-accounts/src/stake_accounts.rs +++ b/stake-accounts/src/stake_accounts.rs @@ -281,18 +281,16 @@ pub(crate) fn move_stake_accounts( #[cfg(test)] mod tests { - use { - super::*, - solana_runtime::{bank::Bank, bank_client::BankClient}, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, - client::SyncClient, - genesis_config::create_genesis_config, - signature::{Keypair, Signer}, - stake::state::StakeState, - }, - solana_stake_program::stake_state, + use super::*; + use solana_runtime::{bank::Bank, bank_client::BankClient}; + use solana_sdk::{ + account::{AccountSharedData, ReadableAccount}, + client::SyncClient, + genesis_config::create_genesis_config, + signature::{Keypair, Signer}, + stake::state::StakeState, }; + use solana_stake_program::stake_state; fn create_bank(lamports: u64) -> (Bank, Keypair, u64) { let (genesis_config, mint_keypair) = create_genesis_config(lamports); diff --git a/storage-bigtable/src/access_token.rs b/storage-bigtable/src/access_token.rs index 9b8cef0153..e73962b2b2 100644 --- a/storage-bigtable/src/access_token.rs +++ b/storage-bigtable/src/access_token.rs @@ -1,4 +1,3 @@ -pub use goauth::scopes::Scope; /// A module for managing a Google API access token use { goauth::{ @@ -16,6 +15,8 @@ use { }, }; +pub use goauth::scopes::Scope; + fn load_credentials() -> Result { // Use standard GOOGLE_APPLICATION_CREDENTIALS environment variable let credentials_file = std::env::var("GOOGLE_APPLICATION_CREDENTIALS") diff --git a/storage-bigtable/src/bigtable.rs b/storage-bigtable/src/bigtable.rs index 460baa4ce9..66f2c9759c 100644 --- a/storage-bigtable/src/bigtable.rs +++ b/storage-bigtable/src/bigtable.rs @@ -782,17 +782,15 @@ where #[cfg(test)] mod tests { - use { - super::*, - crate::StoredConfirmedBlock, - prost::Message, - solana_sdk::{hash::Hash, signature::Keypair, system_transaction}, - solana_storage_proto::convert::generated, - solana_transaction_status::{ - ConfirmedBlock, TransactionStatusMeta, TransactionWithStatusMeta, - }, - std::convert::TryInto, + use super::*; + use crate::StoredConfirmedBlock; + use prost::Message; + use solana_sdk::{hash::Hash, signature::Keypair, system_transaction}; + use solana_storage_proto::convert::generated; + use solana_transaction_status::{ + ConfirmedBlock, TransactionStatusMeta, TransactionWithStatusMeta, }; + use std::convert::TryInto; #[test] fn test_deserialize_protobuf_or_bincode_cell_data() { diff --git a/storage-proto/src/convert.rs b/storage-proto/src/convert.rs index 533993f1da..049d611306 100644 --- a/storage-proto/src/convert.rs +++ b/storage-proto/src/convert.rs @@ -3,11 +3,13 @@ use { solana_account_decoder::parse_token::{real_number_string_trimmed, UiTokenAmount}, solana_sdk::{ hash::Hash, - instruction::{CompiledInstruction, InstructionError}, + instruction::CompiledInstruction, + instruction::InstructionError, message::{Message, MessageHeader}, pubkey::Pubkey, signature::Signature, - transaction::{Transaction, TransactionError}, + transaction::Transaction, + transaction::TransactionError, }, solana_transaction_status::{ ConfirmedBlock, InnerInstructions, Reward, RewardType, TransactionByAddrInfo, diff --git a/streamer/src/packet.rs b/streamer/src/packet.rs index 58688ef80e..3e7f734224 100644 --- a/streamer/src/packet.rs +++ b/streamer/src/packet.rs @@ -1,20 +1,17 @@ //! The `packet` module defines data structures and methods to pull data from the network. -use { - crate::{ - recvmmsg::{recv_mmsg, NUM_RCVMMSGS}, - socket::SocketAddrSpace, - }, - solana_metrics::inc_new_counter_debug, - std::{io::Result, net::UdpSocket, time::Instant}, +use crate::{ + recvmmsg::{recv_mmsg, NUM_RCVMMSGS}, + socket::SocketAddrSpace, }; -pub use { - solana_perf::packet::{ - limited_deserialize, to_packets_chunked, Packets, PacketsRecycler, NUM_PACKETS, - PACKETS_PER_BATCH, - }, - solana_sdk::packet::{Meta, Packet, PACKET_DATA_SIZE}, +pub use solana_perf::packet::{ + limited_deserialize, to_packets_chunked, Packets, PacketsRecycler, NUM_PACKETS, + PACKETS_PER_BATCH, }; +use solana_metrics::inc_new_counter_debug; +pub use solana_sdk::packet::{Meta, Packet, PACKET_DATA_SIZE}; +use std::{io::Result, net::UdpSocket, time::Instant}; + pub fn recv_from(obj: &mut Packets, socket: &UdpSocket, max_wait_ms: u64) -> Result { let mut i = 0; //DOCUMENTED SIDE-EFFECT @@ -76,14 +73,10 @@ pub fn send_to( #[cfg(test)] mod tests { - use { - super::*, - std::{ - io, - io::Write, - net::{SocketAddr, UdpSocket}, - }, - }; + use super::*; + use std::io; + use std::io::Write; + use std::net::{SocketAddr, UdpSocket}; #[test] fn test_packets_set_addr() { diff --git a/streamer/src/recvmmsg.rs b/streamer/src/recvmmsg.rs index 0a9e25d908..64eb3e86b4 100644 --- a/streamer/src/recvmmsg.rs +++ b/streamer/src/recvmmsg.rs @@ -119,13 +119,10 @@ pub fn recv_mmsg(sock: &UdpSocket, packets: &mut [Packet]) -> io::Result<(usize, #[cfg(test)] mod tests { - use { - crate::{packet::PACKET_DATA_SIZE, recvmmsg::*}, - std::{ - net::{SocketAddr, UdpSocket}, - time::{Duration, Instant}, - }, - }; + use crate::packet::PACKET_DATA_SIZE; + use crate::recvmmsg::*; + use std::net::{SocketAddr, UdpSocket}; + use std::time::{Duration, Instant}; type TestConfig = (UdpSocket, SocketAddr, UdpSocket, SocketAddr); diff --git a/streamer/src/sendmmsg.rs b/streamer/src/sendmmsg.rs index 6e434f5ed5..e3ce61713e 100644 --- a/streamer/src/sendmmsg.rs +++ b/streamer/src/sendmmsg.rs @@ -149,17 +149,13 @@ where #[cfg(test)] mod tests { - use { - crate::{ - packet::Packet, - recvmmsg::recv_mmsg, - sendmmsg::{batch_send, multi_target_send, SendPktsError}, - }, - solana_sdk::packet::PACKET_DATA_SIZE, - std::{ - io::ErrorKind, - net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket}, - }, + use crate::packet::Packet; + use crate::recvmmsg::recv_mmsg; + use crate::sendmmsg::{batch_send, multi_target_send, SendPktsError}; + use solana_sdk::packet::PACKET_DATA_SIZE; + use std::{ + io::ErrorKind, + net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket}, }; #[test] diff --git a/streamer/src/streamer.rs b/streamer/src/streamer.rs index a6eebf8ad5..386f3b7fea 100644 --- a/streamer/src/streamer.rs +++ b/streamer/src/streamer.rs @@ -1,25 +1,19 @@ //! The `streamer` module defines a set of services for efficiently pulling data from UDP sockets. //! -use { - crate::{ - packet::{self, send_to, Packets, PacketsRecycler, PACKETS_PER_BATCH}, - recvmmsg::NUM_RCVMMSGS, - socket::SocketAddrSpace, - }, - solana_sdk::timing::timestamp, - std::{ - net::UdpSocket, - sync::{ - atomic::{AtomicBool, Ordering}, - mpsc::{Receiver, RecvTimeoutError, SendError, Sender}, - Arc, - }, - thread::{Builder, JoinHandle}, - time::{Duration, Instant}, - }, - thiserror::Error, +use crate::{ + packet::{self, send_to, Packets, PacketsRecycler, PACKETS_PER_BATCH}, + recvmmsg::NUM_RCVMMSGS, + socket::SocketAddrSpace, }; +use solana_sdk::timing::timestamp; +use std::net::UdpSocket; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::mpsc::{Receiver, RecvTimeoutError, SendError, Sender}; +use std::sync::Arc; +use std::thread::{Builder, JoinHandle}; +use std::time::{Duration, Instant}; +use thiserror::Error; pub type PacketReceiver = Receiver; pub type PacketSender = Sender; @@ -190,25 +184,17 @@ pub fn responder( #[cfg(test)] mod test { - use { - super::*, - crate::{ - packet::{Packet, Packets, PACKET_DATA_SIZE}, - streamer::{receiver, responder}, - }, - solana_perf::recycler::Recycler, - std::{ - io, - io::Write, - net::UdpSocket, - sync::{ - atomic::{AtomicBool, Ordering}, - mpsc::channel, - Arc, - }, - time::Duration, - }, - }; + use super::*; + use crate::packet::{Packet, Packets, PACKET_DATA_SIZE}; + use crate::streamer::{receiver, responder}; + use solana_perf::recycler::Recycler; + use std::io; + use std::io::Write; + use std::net::UdpSocket; + use std::sync::atomic::{AtomicBool, Ordering}; + use std::sync::mpsc::channel; + use std::sync::Arc; + use std::time::Duration; fn get_msgs(r: PacketReceiver, num: &mut usize) { for _ in 0..10 { diff --git a/streamer/tests/recvmmsg.rs b/streamer/tests/recvmmsg.rs index 614dc16ee1..e91a0dc6a2 100644 --- a/streamer/tests/recvmmsg.rs +++ b/streamer/tests/recvmmsg.rs @@ -1,12 +1,10 @@ #![cfg(target_os = "linux")] -use { - solana_streamer::{ - packet::{Packet, PACKET_DATA_SIZE}, - recvmmsg::*, - }, - std::{net::UdpSocket, time::Instant}, -}; +use solana_streamer::packet::Packet; +use solana_streamer::packet::PACKET_DATA_SIZE; +use solana_streamer::recvmmsg::*; +use std::net::UdpSocket; +use std::time::Instant; #[test] pub fn test_recv_mmsg_batch_size() { diff --git a/sys-tuner/src/main.rs b/sys-tuner/src/main.rs index 2b8578b971..36b85539a3 100644 --- a/sys-tuner/src/main.rs +++ b/sys-tuner/src/main.rs @@ -36,7 +36,8 @@ fn tune_poh_service_priority(uid: u32) { None } - use std::{process::Command, str::from_utf8}; + use std::process::Command; + use std::str::from_utf8; if let Some(pid) = find_pid("solana-validato", "/proc", uid, |dir| { let mut path = dir.path(); @@ -67,7 +68,8 @@ fn tune_poh_service_priority(uid: u32) { #[cfg(target_os = "linux")] fn tune_kernel_udp_buffers_and_vmmap() { - use sysctl::{CtlValue::String, Sysctl}; + use sysctl::CtlValue::String; + use sysctl::Sysctl; fn sysctl_write(name: &str, value: &str) { if let Ok(ctl) = sysctl::Ctl::new(name) { info!("Old {} value {:?}", name, ctl.value()); diff --git a/tokens/src/arg_parser.rs b/tokens/src/arg_parser.rs index 010acccf3b..6b8bf2bcff 100644 --- a/tokens/src/arg_parser.rs +++ b/tokens/src/arg_parser.rs @@ -1,21 +1,19 @@ -use { - crate::args::{ - Args, BalancesArgs, Command, DistributeTokensArgs, SenderStakeArgs, SplTokenArgs, - StakeArgs, TransactionLogArgs, - }, - clap::{ - crate_description, crate_name, value_t, value_t_or_exit, App, Arg, ArgMatches, SubCommand, - }, - solana_clap_utils::{ - input_parsers::{pubkey_of_signer, value_of}, - input_validators::{is_amount, is_valid_pubkey, is_valid_signer}, - keypair::{pubkey_from_path, signer_from_path}, - }, - solana_cli_config::CONFIG_FILE, - solana_remote_wallet::remote_wallet::maybe_wallet_manager, - solana_sdk::native_token::sol_to_lamports, - std::{error::Error, ffi::OsString, process::exit}, +use crate::args::{ + Args, BalancesArgs, Command, DistributeTokensArgs, SenderStakeArgs, SplTokenArgs, StakeArgs, + TransactionLogArgs, }; +use clap::{ + crate_description, crate_name, value_t, value_t_or_exit, App, Arg, ArgMatches, SubCommand, +}; +use solana_clap_utils::{ + input_parsers::{pubkey_of_signer, value_of}, + input_validators::{is_amount, is_valid_pubkey, is_valid_signer}, + keypair::{pubkey_from_path, signer_from_path}, +}; +use solana_cli_config::CONFIG_FILE; +use solana_remote_wallet::remote_wallet::maybe_wallet_manager; +use solana_sdk::native_token::sol_to_lamports; +use std::{error::Error, ffi::OsString, process::exit}; fn get_matches<'a, I, T>(args: I) -> ArgMatches<'a> where diff --git a/tokens/src/commands.rs b/tokens/src/commands.rs index 8f48091f97..8fe955811d 100644 --- a/tokens/src/commands.rs +++ b/tokens/src/commands.rs @@ -1,56 +1,52 @@ -use { - crate::{ - args::{ - BalancesArgs, DistributeTokensArgs, SenderStakeArgs, StakeArgs, TransactionLogArgs, - }, - db::{self, TransactionInfo}, - spl_token::*, - token_display::Token, +use crate::{ + args::{BalancesArgs, DistributeTokensArgs, SenderStakeArgs, StakeArgs, TransactionLogArgs}, + db::{self, TransactionInfo}, + spl_token::*, + token_display::Token, +}; +use chrono::prelude::*; +use console::style; +use csv::{ReaderBuilder, Trim}; +use indexmap::IndexMap; +use indicatif::{ProgressBar, ProgressStyle}; +use pickledb::PickleDb; +use serde::{Deserialize, Serialize}; +use solana_account_decoder::parse_token::{ + pubkey_from_spl_token, real_number_string, spl_token_pubkey, +}; +use solana_client::{ + client_error::{ClientError, Result as ClientResult}, + rpc_client::RpcClient, + rpc_config::RpcSendTransactionConfig, + rpc_request::MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, + rpc_response::Fees, +}; +use solana_sdk::{ + clock::Slot, + commitment_config::CommitmentConfig, + instruction::Instruction, + message::Message, + native_token::{lamports_to_sol, sol_to_lamports}, + signature::{unique_signers, Signature, Signer}, + stake::{ + instruction::{self as stake_instruction, LockupArgs}, + state::{Authorized, Lockup, StakeAuthorize}, }, - chrono::prelude::*, - console::style, - csv::{ReaderBuilder, Trim}, - indexmap::IndexMap, - indicatif::{ProgressBar, ProgressStyle}, - pickledb::PickleDb, - serde::{Deserialize, Serialize}, - solana_account_decoder::parse_token::{ - pubkey_from_spl_token, real_number_string, spl_token_pubkey, - }, - solana_client::{ - client_error::{ClientError, Result as ClientResult}, - rpc_client::RpcClient, - rpc_config::RpcSendTransactionConfig, - rpc_request::MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, - rpc_response::Fees, - }, - solana_sdk::{ - clock::Slot, - commitment_config::CommitmentConfig, - instruction::Instruction, - message::Message, - native_token::{lamports_to_sol, sol_to_lamports}, - signature::{unique_signers, Signature, Signer}, - stake::{ - instruction::{self as stake_instruction, LockupArgs}, - state::{Authorized, Lockup, StakeAuthorize}, - }, - system_instruction, - transaction::Transaction, - }, - solana_transaction_status::TransactionStatus, - spl_associated_token_account::get_associated_token_address, - spl_token::solana_program::program_error::ProgramError, - std::{ - cmp::{self}, - io, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - thread::sleep, - time::Duration, + system_instruction, + transaction::Transaction, +}; +use solana_transaction_status::TransactionStatus; +use spl_associated_token_account::get_associated_token_address; +use spl_token::solana_program::program_error::ProgramError; +use std::{ + cmp::{self}, + io, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, }, + thread::sleep, + time::Duration, }; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] @@ -868,11 +864,9 @@ pub fn process_transaction_log(args: &TransactionLogArgs) -> Result<(), Error> { Ok(()) } -use { - crate::db::check_output_file, - solana_sdk::{pubkey::Pubkey, signature::Keypair}, - tempfile::{tempdir, NamedTempFile}, -}; +use crate::db::check_output_file; +use solana_sdk::{pubkey::Pubkey, signature::Keypair}; +use tempfile::{tempdir, NamedTempFile}; pub fn test_process_distribute_tokens_with_client( client: &RpcClient, sender_keypair: Keypair, @@ -1212,16 +1206,14 @@ pub fn test_process_distribute_stake_with_client(client: &RpcClient, sender_keyp #[cfg(test)] mod tests { - use { - super::*, - solana_core::test_validator::TestValidator, - solana_sdk::{ - signature::{read_keypair_file, write_keypair_file, Signer}, - stake::instruction::StakeInstruction, - }, - solana_streamer::socket::SocketAddrSpace, - solana_transaction_status::TransactionConfirmationStatus, + use super::*; + use solana_core::test_validator::TestValidator; + use solana_sdk::{ + signature::{read_keypair_file, write_keypair_file, Signer}, + stake::instruction::StakeInstruction, }; + use solana_streamer::socket::SocketAddrSpace; + use solana_transaction_status::TransactionConfirmationStatus; #[test] fn test_process_token_allocations() { diff --git a/tokens/src/db.rs b/tokens/src/db.rs index 819b463193..bd250597c7 100644 --- a/tokens/src/db.rs +++ b/tokens/src/db.rs @@ -1,11 +1,9 @@ -use { - chrono::prelude::*, - pickledb::{error::Error, PickleDb, PickleDbDumpPolicy}, - serde::{Deserialize, Serialize}, - solana_sdk::{clock::Slot, pubkey::Pubkey, signature::Signature, transaction::Transaction}, - solana_transaction_status::TransactionStatus, - std::{cmp::Ordering, fs, io, path::Path}, -}; +use chrono::prelude::*; +use pickledb::{error::Error, PickleDb, PickleDbDumpPolicy}; +use serde::{Deserialize, Serialize}; +use solana_sdk::{clock::Slot, pubkey::Pubkey, signature::Signature, transaction::Transaction}; +use solana_transaction_status::TransactionStatus; +use std::{cmp::Ordering, fs, io, path::Path}; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct TransactionInfo { @@ -210,13 +208,11 @@ pub(crate) fn check_output_file(path: &str, db: &PickleDb) { #[cfg(test)] mod tests { - use { - super::*, - csv::{ReaderBuilder, Trim}, - solana_sdk::transaction::TransactionError, - solana_transaction_status::TransactionConfirmationStatus, - tempfile::NamedTempFile, - }; + use super::*; + use csv::{ReaderBuilder, Trim}; + use solana_sdk::transaction::TransactionError; + use solana_transaction_status::TransactionConfirmationStatus; + use tempfile::NamedTempFile; #[test] fn test_sort_transaction_infos_finalized_first() { diff --git a/tokens/src/main.rs b/tokens/src/main.rs index bbd8c0e435..447b7a6603 100644 --- a/tokens/src/main.rs +++ b/tokens/src/main.rs @@ -1,16 +1,14 @@ -use { - solana_cli_config::{Config, CONFIG_FILE}, - solana_client::rpc_client::RpcClient, - solana_tokens::{arg_parser::parse_args, args::Command, commands, spl_token}, - std::{ - env, - error::Error, - path::Path, - process, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, +use solana_cli_config::{Config, CONFIG_FILE}; +use solana_client::rpc_client::RpcClient; +use solana_tokens::{arg_parser::parse_args, args::Command, commands, spl_token}; +use std::{ + env, + error::Error, + path::Path, + process, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, }, }; diff --git a/tokens/src/spl_token.rs b/tokens/src/spl_token.rs index fd241c23e0..57b54d84a5 100644 --- a/tokens/src/spl_token.rs +++ b/tokens/src/spl_token.rs @@ -1,20 +1,18 @@ -use { - crate::{ - args::{DistributeTokensArgs, SplTokenArgs}, - commands::{Allocation, Error, FundingSource}, - }, - console::style, - solana_account_decoder::parse_token::{ - pubkey_from_spl_token, real_number_string, real_number_string_trimmed, spl_token_pubkey, - }, - solana_client::rpc_client::RpcClient, - solana_sdk::{instruction::Instruction, native_token::lamports_to_sol}, - solana_transaction_status::parse_token::spl_token_instruction, - spl_associated_token_account::{create_associated_token_account, get_associated_token_address}, - spl_token::{ - solana_program::program_pack::Pack, - state::{Account as SplTokenAccount, Mint}, - }, +use crate::{ + args::{DistributeTokensArgs, SplTokenArgs}, + commands::{Allocation, Error, FundingSource}, +}; +use console::style; +use solana_account_decoder::parse_token::{ + pubkey_from_spl_token, real_number_string, real_number_string_trimmed, spl_token_pubkey, +}; +use solana_client::rpc_client::RpcClient; +use solana_sdk::{instruction::Instruction, native_token::lamports_to_sol}; +use solana_transaction_status::parse_token::spl_token_instruction; +use spl_associated_token_account::{create_associated_token_account, get_associated_token_address}; +use spl_token::{ + solana_program::program_pack::Pack, + state::{Account as SplTokenAccount, Mint}, }; pub fn update_token_args(client: &RpcClient, args: &mut Option) -> Result<(), Error> { diff --git a/tokens/src/token_display.rs b/tokens/src/token_display.rs index fae099f5f3..1a42787c11 100644 --- a/tokens/src/token_display.rs +++ b/tokens/src/token_display.rs @@ -1,10 +1,8 @@ -use { - solana_account_decoder::parse_token::real_number_string_trimmed, - solana_sdk::native_token::lamports_to_sol, - std::{ - fmt::{Debug, Display, Formatter, Result}, - ops::Add, - }, +use solana_account_decoder::parse_token::real_number_string_trimmed; +use solana_sdk::native_token::lamports_to_sol; +use std::{ + fmt::{Debug, Display, Formatter, Result}, + ops::Add, }; const SOL_SYMBOL: &str = "◎"; diff --git a/tokens/tests/commands.rs b/tokens/tests/commands.rs index d1bb653f7c..7e65461681 100644 --- a/tokens/tests/commands.rs +++ b/tokens/tests/commands.rs @@ -1,10 +1,8 @@ -use { - solana_client::rpc_client::RpcClient, - solana_core::test_validator::TestValidator, - solana_sdk::signature::{Keypair, Signer}, - solana_streamer::socket::SocketAddrSpace, - solana_tokens::commands::test_process_distribute_tokens_with_client, -}; +use solana_client::rpc_client::RpcClient; +use solana_core::test_validator::TestValidator; +use solana_sdk::signature::{Keypair, Signer}; +use solana_streamer::socket::SocketAddrSpace; +use solana_tokens::commands::test_process_distribute_tokens_with_client; #[test] fn test_process_distribute_with_rpc_client() { diff --git a/upload-perf/src/upload-perf.rs b/upload-perf/src/upload-perf.rs index 8fa44455cf..8018564827 100644 --- a/upload-perf/src/upload-perf.rs +++ b/upload-perf/src/upload-perf.rs @@ -1,13 +1,9 @@ -use { - serde_json::Value, - std::{ - collections::HashMap, - env, - fs::File, - io::{BufRead, BufReader}, - process::Command, - }, -}; +use serde_json::Value; +use std::collections::HashMap; +use std::env; +use std::fs::File; +use std::io::{BufRead, BufReader}; +use std::process::Command; fn get_last_metrics(metric: &str, db: &str, name: &str, branch: &str) -> Result { let query = format!( diff --git a/validator/src/lib.rs b/validator/src/lib.rs index 14f5be064a..7823566d65 100644 --- a/validator/src/lib.rs +++ b/validator/src/lib.rs @@ -1,4 +1,6 @@ #![allow(clippy::integer_arithmetic)] +pub use solana_core::test_validator; +pub use solana_gossip::cluster_info::MINIMUM_VALIDATOR_PORT_RANGE_WIDTH; use { console::style, fd_lock::{FdLock, FdLockGuard}, @@ -11,9 +13,6 @@ use { thread::JoinHandle, }, }; -pub use { - solana_core::test_validator, solana_gossip::cluster_info::MINIMUM_VALIDATOR_PORT_RANGE_WIDTH, -}; pub mod admin_rpc_service; pub mod dashboard; diff --git a/validator/src/main.rs b/validator/src/main.rs index 30a5bbb24b..ded5ebeab4 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -1,6 +1,4 @@ #![allow(clippy::integer_arithmetic)] -#[cfg(not(target_env = "msvc"))] -use jemallocator::Jemalloc; use { clap::{ crate_description, crate_name, value_t, value_t_or_exit, values_t, values_t_or_exit, App, @@ -80,6 +78,9 @@ use { }, }; +#[cfg(not(target_env = "msvc"))] +use jemallocator::Jemalloc; + #[cfg(not(target_env = "msvc"))] #[global_allocator] static GLOBAL: Jemalloc = Jemalloc; diff --git a/version/src/lib.rs b/version/src/lib.rs index 25d8fb256e..85afcd95c4 100644 --- a/version/src/lib.rs +++ b/version/src/lib.rs @@ -1,11 +1,9 @@ #![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))] extern crate serde_derive; -use { - serde_derive::{Deserialize, Serialize}, - solana_sdk::sanitize::Sanitize, - std::{convert::TryInto, fmt}, -}; +use serde_derive::{Deserialize, Serialize}; +use solana_sdk::sanitize::Sanitize; +use std::{convert::TryInto, fmt}; #[macro_use] extern crate solana_frozen_abi_macro;