Skip to content

Commit

Permalink
chore: remove unused async (#9299)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshieDo authored Jul 4, 2024
1 parent afe8689 commit af280b9
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 53 deletions.
4 changes: 2 additions & 2 deletions bin/reth-bench/src/authenticated_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl InnerTransport {
jwt: JwtSecret,
) -> Result<(Self, Claims), AuthenticatedTransportError> {
match url.scheme() {
"http" | "https" => Self::connect_http(url, jwt).await,
"http" | "https" => Self::connect_http(url, jwt),
"ws" | "wss" => Self::connect_ws(url, jwt).await,
"file" => Ok((Self::connect_ipc(url).await?, Claims::default())),
_ => Err(AuthenticatedTransportError::BadScheme(url.scheme().to_string())),
Expand All @@ -48,7 +48,7 @@ impl InnerTransport {

/// Connects to an HTTP [`alloy_transport_http::Http`] transport. Returns an [`InnerTransport`]
/// and the [Claims] generated from the jwt.
async fn connect_http(
fn connect_http(
url: Url,
jwt: JwtSecret,
) -> Result<(Self, Claims), AuthenticatedTransportError> {
Expand Down
5 changes: 2 additions & 3 deletions bin/reth/src/commands/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ impl ImportCommand {
Arc::new(file_client),
StaticFileProducer::new(provider_factory.clone(), PruneModes::default()),
self.no_state,
)
.await?;
)?;

// override the tip
pipeline.set_tip(tip);
Expand Down Expand Up @@ -153,7 +152,7 @@ impl ImportCommand {
///
/// If configured to execute, all stages will run. Otherwise, only stages that don't require state
/// will run.
pub async fn build_import_pipeline<DB, C>(
pub fn build_import_pipeline<DB, C>(
config: &Config,
provider_factory: ProviderFactory<DB>,
consensus: &Arc<C>,
Expand Down
9 changes: 4 additions & 5 deletions bin/reth/src/commands/stage/dump/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) async fn dump_execution_stage<DB: Database>(

import_tables_with_range(&output_db, db_tool, from, to)?;

unwind_and_copy(db_tool, from, tip_block_number, &output_db).await?;
unwind_and_copy(db_tool, from, tip_block_number, &output_db)?;

if should_run {
dry_run(
Expand All @@ -32,8 +32,7 @@ pub(crate) async fn dump_execution_stage<DB: Database>(
),
to,
from,
)
.await?;
)?;
}

Ok(())
Expand Down Expand Up @@ -120,7 +119,7 @@ fn import_tables_with_range<DB: Database>(
/// Dry-run an unwind to FROM block, so we can get the `PlainStorageState` and
/// `PlainAccountState` safely. There might be some state dependency from an address
/// which hasn't been changed in the given range.
async fn unwind_and_copy<DB: Database>(
fn unwind_and_copy<DB: Database>(
db_tool: &DbTool<DB>,
from: u64,
tip_block_number: u64,
Expand Down Expand Up @@ -151,7 +150,7 @@ async fn unwind_and_copy<DB: Database>(
}

/// Try to re-execute the stage without committing
async fn dry_run<DB: Database>(
fn dry_run<DB: Database>(
output_provider_factory: ProviderFactory<DB>,
to: u64,
from: u64,
Expand Down
5 changes: 2 additions & 3 deletions bin/reth/src/commands/stage/dump/hashing_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ pub(crate) async fn dump_hashing_account_stage<DB: Database>(
),
to,
from,
)
.await?;
)?;
}

Ok(())
Expand Down Expand Up @@ -71,7 +70,7 @@ fn unwind_and_copy<DB: Database>(
}

/// Try to re-execute the stage straight away
async fn dry_run<DB: Database>(
fn dry_run<DB: Database>(
output_provider_factory: ProviderFactory<DB>,
to: u64,
from: u64,
Expand Down
5 changes: 2 additions & 3 deletions bin/reth/src/commands/stage/dump/hashing_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ pub(crate) async fn dump_hashing_storage_stage<DB: Database>(
),
to,
from,
)
.await?;
)?;
}

Ok(())
Expand Down Expand Up @@ -66,7 +65,7 @@ fn unwind_and_copy<DB: Database>(
}

/// Try to re-execute the stage straight away
async fn dry_run<DB: Database>(
fn dry_run<DB: Database>(
output_provider_factory: ProviderFactory<DB>,
to: u64,
from: u64,
Expand Down
9 changes: 4 additions & 5 deletions bin/reth/src/commands/stage/dump/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub(crate) async fn dump_merkle_stage<DB: Database>(
)
})??;

unwind_and_copy(db_tool, (from, to), tip_block_number, &output_db).await?;
unwind_and_copy(db_tool, (from, to), tip_block_number, &output_db)?;

if should_run {
dry_run(
Expand All @@ -55,15 +55,14 @@ pub(crate) async fn dump_merkle_stage<DB: Database>(
),
to,
from,
)
.await?;
)?;
}

Ok(())
}

/// Dry-run an unwind to FROM block and copy the necessary table data to the new database.
async fn unwind_and_copy<DB: Database>(
fn unwind_and_copy<DB: Database>(
db_tool: &DbTool<DB>,
range: (u64, u64),
tip_block_number: u64,
Expand Down Expand Up @@ -143,7 +142,7 @@ async fn unwind_and_copy<DB: Database>(
}

/// Try to re-execute the stage straight away
async fn dry_run<DB: Database>(
fn dry_run<DB: Database>(
output_provider_factory: ProviderFactory<DB>,
to: u64,
from: u64,
Expand Down
4 changes: 2 additions & 2 deletions bin/reth/src/commands/stage/unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Command {
}

// This will build an offline-only pipeline if the `offline` flag is enabled
let mut pipeline = self.build_pipeline(config, provider_factory.clone()).await?;
let mut pipeline = self.build_pipeline(config, provider_factory)?;

// Move all applicable data from database to static files.
pipeline.move_to_static_files()?;
Expand Down Expand Up @@ -108,7 +108,7 @@ impl Command {
Ok(())
}

async fn build_pipeline<DB: Database + 'static>(
fn build_pipeline<DB: Database + 'static>(
self,
config: Config,
provider_factory: ProviderFactory<Arc<DB>>,
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/engine/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ where
/// Sends a transition configuration exchange message to the beacon consensus engine.
///
/// See also <https://github.com/ethereum/execution-apis/blob/3d627c95a4d3510a8187dd02e0250ecb4331d27e/src/engine/paris.md#engine_exchangetransitionconfigurationv1>
pub async fn transition_configuration_exchanged(&self) {
pub fn transition_configuration_exchanged(&self) {
let _ = self.to_engine.send(BeaconEngineMessage::TransitionConfigurationExchanged);
}

Expand Down
8 changes: 4 additions & 4 deletions crates/node/builder/src/launch/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ impl LaunchContext {
/// `config`.
///
/// Attaches both the `NodeConfig` and the loaded `reth.toml` config to the launch context.
pub async fn with_loaded_toml_config(
pub fn with_loaded_toml_config(
self,
config: NodeConfig,
) -> eyre::Result<LaunchContextWith<WithConfigs>> {
let toml_config = self.load_toml_config(&config).await?;
let toml_config = self.load_toml_config(&config)?;
Ok(self.with(WithConfigs { config, toml_config }))
}

/// Loads the reth config with the configured `data_dir` and overrides settings according to the
/// `config`.
///
/// This is async because the trusted peers may have to be resolved.
pub async fn load_toml_config(&self, config: &NodeConfig) -> eyre::Result<reth_config::Config> {
pub fn load_toml_config(&self, config: &NodeConfig) -> eyre::Result<reth_config::Config> {
let config_path = config.config.clone().unwrap_or_else(|| self.data_dir.config());

let mut toml_config = confy::load_path::<reth_config::Config>(&config_path)
Expand Down Expand Up @@ -518,7 +518,7 @@ where
}

/// Creates a `BlockchainProvider` and attaches it to the launch context.
pub async fn with_blockchain_db<T>(
pub fn with_blockchain_db<T>(
self,
) -> eyre::Result<LaunchContextWith<Attached<WithConfigs, WithMeteredProviders<DB, T>>>>
where
Expand Down
10 changes: 4 additions & 6 deletions crates/node/builder/src/launch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ where
let ctx = ctx
.with_configured_globals()
// load the toml config
.with_loaded_toml_config(config).await?
.with_loaded_toml_config(config)?
// add resolved peers
.with_resolved_peers().await?
// attach the database
Expand All @@ -127,7 +127,7 @@ where
.with_metrics()
// passing FullNodeTypes as type parameter here so that we can build
// later the components.
.with_blockchain_db::<T>().await?
.with_blockchain_db::<T>()?
.with_components(components_builder, on_component_initialized).await?;

// spawn exexs
Expand Down Expand Up @@ -201,8 +201,7 @@ where
static_file_producer,
ctx.components().block_executor().clone(),
pipeline_exex_handle,
)
.await?;
)?;

let pipeline_events = pipeline.events();
task.set_pipeline_events(pipeline_events);
Expand All @@ -223,8 +222,7 @@ where
static_file_producer,
ctx.components().block_executor().clone(),
pipeline_exex_handle,
)
.await?;
)?;

(pipeline, Either::Right(network_client.clone()))
};
Expand Down
7 changes: 3 additions & 4 deletions crates/node/builder/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use tokio::sync::watch;

/// Constructs a [Pipeline] that's wired to the network
#[allow(clippy::too_many_arguments)]
pub async fn build_networked_pipeline<DB, Client, Executor>(
pub fn build_networked_pipeline<DB, Client, Executor>(
config: &StageConfig,
client: Client,
consensus: Arc<dyn Consensus>,
Expand Down Expand Up @@ -63,15 +63,14 @@ where
static_file_producer,
executor,
exex_manager_handle,
)
.await?;
)?;

Ok(pipeline)
}

/// Builds the [Pipeline] with the given [`ProviderFactory`] and downloaders.
#[allow(clippy::too_many_arguments)]
pub async fn build_pipeline<DB, H, B, Executor>(
pub fn build_pipeline<DB, H, B, Executor>(
provider_factory: ProviderFactory<DB>,
stage_config: &StageConfig,
header_downloader: H,
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ enum WsHttpServers {

impl WsHttpServers {
/// Starts the servers and returns the handles (http, ws)
async fn start(
fn start(
self,
http_module: Option<RpcModule<()>>,
ws_module: Option<RpcModule<()>>,
Expand Down Expand Up @@ -1796,7 +1796,7 @@ impl RpcServer {
jwt_secret: None,
};

let (http, ws) = ws_http.server.start(http, ws, &config).await?;
let (http, ws) = ws_http.server.start(http, ws, &config)?;
handle.http = http;
handle.ws = ws;

Expand Down
20 changes: 10 additions & 10 deletions crates/rpc/rpc-engine-api/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ where
}

/// Fetches the client version.
async fn get_client_version_v1(
fn get_client_version_v1(
&self,
_client: ClientVersionV1,
) -> EngineApiResult<Vec<ClientVersionV1>> {
Expand Down Expand Up @@ -444,7 +444,7 @@ where

/// Called to verify network configuration parameters and ensure that Consensus and Execution
/// layers are using the latest configuration.
pub async fn exchange_transition_configuration(
pub fn exchange_transition_configuration(
&self,
config: TransitionConfiguration,
) -> EngineApiResult<TransitionConfiguration> {
Expand All @@ -469,7 +469,7 @@ where
})
}

self.inner.beacon_consensus.transition_configuration_exchanged().await;
self.inner.beacon_consensus.transition_configuration_exchanged();

// Short circuit if communicated block hash is zero
if terminal_block_hash.is_zero() {
Expand Down Expand Up @@ -801,7 +801,7 @@ where
) -> RpcResult<TransitionConfiguration> {
trace!(target: "rpc::engine", "Serving engine_exchangeTransitionConfigurationV1");
let start = Instant::now();
let res = Self::exchange_transition_configuration(self, config).await;
let res = Self::exchange_transition_configuration(self, config);
self.inner.metrics.latency.exchange_transition_configuration.record(start.elapsed());
Ok(res?)
}
Expand All @@ -814,7 +814,7 @@ where
client: ClientVersionV1,
) -> RpcResult<Vec<ClientVersionV1>> {
trace!(target: "rpc::engine", "Serving engine_getClientVersionV1");
let res = Self::get_client_version_v1(self, client).await;
let res = Self::get_client_version_v1(self, client);

Ok(res?)
}
Expand Down Expand Up @@ -889,7 +889,7 @@ mod tests {
commit: "defa64b2".to_string(),
};
let (_, api) = setup_engine_api();
let res = api.get_client_version_v1(client.clone()).await;
let res = api.get_client_version_v1(client.clone());
assert_eq!(res.unwrap(), vec![client]);
}

Expand Down Expand Up @@ -1045,7 +1045,7 @@ mod tests {
..Default::default()
};

let res = api.exchange_transition_configuration(transition_config).await;
let res = api.exchange_transition_configuration(transition_config);

assert_matches!(
res,
Expand Down Expand Up @@ -1077,7 +1077,7 @@ mod tests {
};

// Unknown block number
let res = api.exchange_transition_configuration(transition_config).await;
let res = api.exchange_transition_configuration(transition_config);

assert_matches!(
res,
Expand All @@ -1091,7 +1091,7 @@ mod tests {
execution_terminal_block.clone().unseal(),
);

let res = api.exchange_transition_configuration(transition_config).await;
let res = api.exchange_transition_configuration(transition_config);

assert_matches!(
res,
Expand Down Expand Up @@ -1120,7 +1120,7 @@ mod tests {

handle.provider.add_block(terminal_block.hash(), terminal_block.unseal());

let config = api.exchange_transition_configuration(transition_config).await.unwrap();
let config = api.exchange_transition_configuration(transition_config).unwrap();
assert_eq!(config, transition_config);
}
}
Expand Down
Loading

0 comments on commit af280b9

Please sign in to comment.