Skip to content

Commit

Permalink
fmt: add group_imports = StdExternalCrate
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger committed Jun 27, 2024
1 parent 793aa85 commit a15fd40
Show file tree
Hide file tree
Showing 686 changed files with 4,044 additions and 3,007 deletions.
6 changes: 4 additions & 2 deletions bin/reth-bench/src/authenticated_transport.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! This contains an authenticated rpc transport that can be used to send engine API newPayload
//! requests.
use std::sync::Arc;
use std::{
sync::Arc,
task::{Context, Poll},
};

use alloy_json_rpc::{RequestPacket, ResponsePacket};
use alloy_pubsub::{PubSubConnect, PubSubFrontend};
Expand All @@ -15,7 +18,6 @@ use alloy_transport_ipc::IpcConnect;
use alloy_transport_ws::WsConnect;
use futures::FutureExt;
use reqwest::header::HeaderValue;
use std::task::{Context, Poll};
use tokio::sync::RwLock;
use tower::Service;

Expand Down
3 changes: 2 additions & 1 deletion bin/reth-bench/src/bench/context.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! This contains the [`BenchContext`], which is information that all replay-based benchmarks need.
//! The initialization code is also the same, so this can be shared across benchmark commands.
use crate::{authenticated_transport::AuthenticatedTransportConnect, bench_mode::BenchMode};
use alloy_eips::BlockNumberOrTag;
use alloy_provider::{
network::{AnyNetwork, Ethereum},
Expand All @@ -15,6 +14,8 @@ use reqwest::{Client, Url};
use reth_node_core::args::BenchmarkArgs;
use tracing::info;

use crate::{authenticated_transport::AuthenticatedTransportConnect, bench_mode::BenchMode};

/// This is intended to be used by benchmarks that replay blocks from an RPC.
///
/// It contains an authenticated provider for engine API queries, a block provider for block
Expand Down
22 changes: 12 additions & 10 deletions bin/reth-bench/src/bench/new_payload_fcu.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
//! Runs the `reth bench` command, calling first newPayload for each block, then calling
//! forkchoiceUpdated.
use std::time::Instant;

use alloy_provider::Provider;
use alloy_rpc_types_engine::ForkchoiceState;
use clap::Parser;
use csv::Writer;
use reth_cli_runner::CliContext;
use reth_node_core::args::BenchmarkArgs;
use reth_primitives::{Block, B256};
use reth_rpc_types_compat::engine::payload::block_to_payload;
use tracing::{debug, info};

use crate::{
bench::{
context::BenchContext,
Expand All @@ -11,16 +23,6 @@ use crate::{
},
valid_payload::{call_forkchoice_updated, call_new_payload},
};
use alloy_provider::Provider;
use alloy_rpc_types_engine::ForkchoiceState;
use clap::Parser;
use csv::Writer;
use reth_cli_runner::CliContext;
use reth_node_core::args::BenchmarkArgs;
use reth_primitives::{Block, B256};
use reth_rpc_types_compat::engine::payload::block_to_payload;
use std::time::Instant;
use tracing::{debug, info};

/// `reth benchmark new-payload-fcu` command
#[derive(Debug, Parser)]
Expand Down
20 changes: 11 additions & 9 deletions bin/reth-bench/src/bench/new_payload_only.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
//! Runs the `reth bench` command, sending only newPayload, without a forkchoiceUpdated call.
use std::time::Instant;

use alloy_provider::Provider;
use clap::Parser;
use csv::Writer;
use reth_cli_runner::CliContext;
use reth_node_core::args::BenchmarkArgs;
use reth_primitives::{Block, B256};
use reth_rpc_types_compat::engine::payload::block_to_payload;
use tracing::{debug, info};

use crate::{
bench::{
context::BenchContext,
Expand All @@ -10,15 +21,6 @@ use crate::{
},
valid_payload::call_new_payload,
};
use alloy_provider::Provider;
use clap::Parser;
use csv::Writer;
use reth_cli_runner::CliContext;
use reth_node_core::args::BenchmarkArgs;
use reth_primitives::{Block, B256};
use reth_rpc_types_compat::engine::payload::block_to_payload;
use std::time::Instant;
use tracing::{debug, info};

/// `reth benchmark new-payload-only` command
#[derive(Debug, Parser)]
Expand Down
9 changes: 6 additions & 3 deletions bin/reth-bench/src/bench/output.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//! Contains various benchmark output formats, either for logging or for
//! serialization to / from files.
use std::time::Duration;

use reth_primitives::constants::gas_units::GIGAGAS;
use serde::{ser::SerializeStruct, Serialize};
use std::time::Duration;

/// This is the suffix for gas output csv files.
pub(crate) const GAS_OUTPUT_SUFFIX: &str = "total_gas.csv";
Expand Down Expand Up @@ -179,10 +180,12 @@ impl Serialize for TotalGasRow {

#[cfg(test)]
mod tests {
use super::*;
use csv::Writer;
use std::io::BufRead;

use csv::Writer;

use super::*;

#[test]
fn test_write_total_gas_row_csv() {
let row = TotalGasRow { block_number: 1, gas_used: 1_000, time: Duration::from_secs(1) };
Expand Down
30 changes: 16 additions & 14 deletions bin/reth/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
//! CLI definition and entrypoint to executable
use crate::{
args::{
utils::{chain_help, chain_value_parser, SUPPORTED_CHAINS},
LogArgs,
},
commands::{
config_cmd, db, debug_cmd, dump_genesis, import, init_cmd, init_state,
node::{self, NoArgs},
p2p, prune, recover, stage, test_vectors,
},
version::{LONG_VERSION, SHORT_VERSION},
};
use std::{ffi::OsString, fmt, future::Future, sync::Arc};

use clap::{value_parser, Parser, Subcommand};
use reth_chainspec::ChainSpec;
use reth_cli_runner::CliRunner;
use reth_db::DatabaseEnv;
use reth_node_builder::{NodeBuilder, WithLaunchContext};
use reth_tracing::FileWorkerGuard;
use std::{ffi::OsString, fmt, future::Future, sync::Arc};
use tracing::info;

/// Re-export of the `reth_node_core` types specifically in the `cli` module.
Expand All @@ -27,6 +16,18 @@ use tracing::info;
/// `reth::cli` but were moved to the `reth_node_core` crate. This re-export avoids a breaking
/// change.
pub use crate::core::cli::*;
use crate::{
args::{
utils::{chain_help, chain_value_parser, SUPPORTED_CHAINS},
LogArgs,
},
commands::{
config_cmd, db, debug_cmd, dump_genesis, import, init_cmd, init_state,
node::{self, NoArgs},
p2p, prune, recover, stage, test_vectors,
},
version::{LONG_VERSION, SHORT_VERSION},
};

/// The main reth cli interface.
///
Expand Down Expand Up @@ -231,9 +232,10 @@ pub enum Commands<Ext: clap::Args + fmt::Debug = NoArgs> {

#[cfg(test)]
mod tests {
use clap::CommandFactory;

use super::*;
use crate::args::ColorMode;
use clap::CommandFactory;

#[test]
fn parse_color_mode() {
Expand Down
3 changes: 2 additions & 1 deletion bin/reth/src/commands/common.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Contains common `reth` arguments
use std::{path::PathBuf, sync::Arc};

use clap::Parser;
use reth_beacon_consensus::EthBeaconConsensus;
use reth_chainspec::ChainSpec;
Expand All @@ -19,7 +21,6 @@ use reth_primitives::B256;
use reth_provider::{providers::StaticFileProvider, ProviderFactory, StaticFileProviderFactory};
use reth_stages::{sets::DefaultStages, Pipeline, PipelineTarget};
use reth_static_file::StaticFileProducer;
use std::{path::PathBuf, sync::Arc};
use tokio::sync::watch;
use tracing::{debug, info, warn};

Expand Down
14 changes: 8 additions & 6 deletions bin/reth/src/commands/db/checksum.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
use crate::commands::db::get::{maybe_json_value_parser, table_key};
use ahash::RandomState;
use clap::Parser;
use reth_db::{DatabaseEnv, RawKey, RawTable, RawValue, TableViewer, Tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx};
use reth_db_common::DbTool;
use std::{
hash::{BuildHasher, Hasher},
sync::Arc,
time::{Duration, Instant},
};

use ahash::RandomState;
use clap::Parser;
use reth_db::{DatabaseEnv, RawKey, RawTable, RawValue, TableViewer, Tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx};
use reth_db_common::DbTool;
use tracing::{info, warn};

use crate::commands::db::get::{maybe_json_value_parser, table_key};

#[derive(Parser, Debug)]
/// The arguments for the `reth db checksum` command
pub struct Command {
Expand Down
18 changes: 10 additions & 8 deletions bin/reth/src/commands/db/diff.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
use crate::{
args::DatabaseArgs,
dirs::{DataDirPath, PlatformPath},
};
use clap::Parser;
use reth_db::{open_db_read_only, tables_to_generic, DatabaseEnv, Tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx};
use reth_db_common::DbTool;
use std::{
collections::HashMap,
fmt::Debug,
Expand All @@ -15,8 +7,18 @@ use std::{
path::{Path, PathBuf},
sync::Arc,
};

use clap::Parser;
use reth_db::{open_db_read_only, tables_to_generic, DatabaseEnv, Tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx};
use reth_db_common::DbTool;
use tracing::{info, warn};

use crate::{
args::DatabaseArgs,
dirs::{DataDirPath, PlatformPath},
};

#[derive(Parser, Debug)]
/// The arguments for the `reth db diff` command
pub struct Command {
Expand Down
6 changes: 4 additions & 2 deletions bin/reth/src/commands/db/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,14 @@ pub(crate) fn maybe_json_value_parser(value: &str) -> Result<String, eyre::Error

#[cfg(test)]
mod tests {
use super::*;
use std::str::FromStr;

use clap::{Args, Parser};
use reth_db::{AccountsHistory, HashedAccounts, Headers, StageCheckpoints, StoragesHistory};
use reth_db_api::models::{storage_sharded_key::StorageShardedKey, ShardedKey};
use reth_primitives::{Address, B256};
use std::str::FromStr;

use super::*;

/// A helper type to parse Args more easily
#[derive(Parser)]
Expand Down
6 changes: 4 additions & 2 deletions bin/reth/src/commands/db/list.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use super::tui::DbListTUI;
use std::{cell::RefCell, sync::Arc};

use clap::Parser;
use eyre::WrapErr;
use reth_db::{DatabaseEnv, RawValue, TableViewer, Tables};
use reth_db_api::{database::Database, table::Table};
use reth_db_common::{DbTool, ListFilter};
use reth_primitives::hex;
use std::{cell::RefCell, sync::Arc};
use tracing::error;

use super::tui::DbListTUI;

#[derive(Parser, Debug)]
/// The arguments for the `reth db list` command
pub struct Command {
Expand Down
12 changes: 8 additions & 4 deletions bin/reth/src/commands/db/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//! Database debugging tool
use crate::commands::common::{AccessRights, Environment, EnvironmentArgs};
use std::io::{self, Write};

use clap::{Parser, Subcommand};
use reth_db::version::{get_db_version, DatabaseVersionError, DB_VERSION};
use reth_db_common::DbTool;
use std::io::{self, Write};

use crate::commands::common::{AccessRights, Environment, EnvironmentArgs};

mod checksum;
mod clear;
Expand Down Expand Up @@ -146,10 +148,12 @@ impl Command {

#[cfg(test)]
mod tests {
use super::*;
use reth_node_core::args::utils::SUPPORTED_CHAINS;
use std::path::Path;

use reth_node_core::args::utils::SUPPORTED_CHAINS;

use super::*;

#[test]
fn parse_stats_globals() {
let path = format!("../{}", SUPPORTED_CHAINS[0]);
Expand Down
6 changes: 4 additions & 2 deletions bin/reth/src/commands/db/stats.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::commands::db::checksum::ChecksumViewer;
use std::{sync::Arc, time::Duration};

use clap::Parser;
use comfy_table::{Cell, Row, Table as ComfyTable};
use eyre::WrapErr;
Expand All @@ -11,7 +12,8 @@ use reth_fs_util as fs;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_provider::providers::StaticFileProvider;
use reth_static_file_types::{find_fixed_range, SegmentRangeInclusive};
use std::{sync::Arc, time::Duration};

use crate::commands::db::checksum::ChecksumViewer;

#[derive(Parser, Debug)]
/// The arguments for the `reth db stats` command
Expand Down
9 changes: 5 additions & 4 deletions bin/reth/src/commands/db/tui.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
use std::{
io,
time::{Duration, Instant},
};

use crossterm::{
event::{self, Event, KeyCode, MouseEventKind},
execute,
Expand All @@ -12,10 +17,6 @@ use ratatui::{
};
use reth_db::RawValue;
use reth_db_api::table::{Table, TableRow};
use std::{
io,
time::{Duration, Instant},
};
use tracing::error;

/// Available keybindings for the [`DbListTUI`]
Expand Down
12 changes: 7 additions & 5 deletions bin/reth/src/commands/debug_cmd/build_block.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! Command for debugging block building.
use crate::{
commands::common::{AccessRights, Environment, EnvironmentArgs},
macros::block_executor,
};
use std::{path::PathBuf, str::FromStr, sync::Arc};

use alloy_rlp::Decodable;
use clap::Parser;
use eyre::Context;
Expand Down Expand Up @@ -39,9 +37,13 @@ use reth_transaction_pool::{
blobstore::InMemoryBlobStore, BlobStore, EthPooledTransaction, PoolConfig, TransactionOrigin,
TransactionPool, TransactionValidationTaskExecutor,
};
use std::{path::PathBuf, str::FromStr, sync::Arc};
use tracing::*;

use crate::{
commands::common::{AccessRights, Environment, EnvironmentArgs},
macros::block_executor,
};

/// `reth debug build-block` command
/// This debug routine requires that the node is positioned at the block before the target.
/// The script will then parse the block and attempt to build a similar one.
Expand Down
Loading

0 comments on commit a15fd40

Please sign in to comment.