diff --git a/CHANGELOG.md b/CHANGELOG.md
index e54ce4cc901..7548587bdca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- [2630](https://github.com/FuelLabs/fuel-core/pull/2630): Removed some noisy `tracing::info!` logs
+### Fixed
+- [2632](https://github.com/FuelLabs/fuel-core/pull/2632): Improved performance of certain async trait impls in the gas price service.
+
## [Version 0.41.4]
### Fixed
diff --git a/crates/fuel-core/src/service/adapters/fuel_gas_price_provider.rs b/crates/fuel-core/src/service/adapters/fuel_gas_price_provider.rs
index 3401e100d4e..8b13f058615 100644
--- a/crates/fuel-core/src/service/adapters/fuel_gas_price_provider.rs
+++ b/crates/fuel-core/src/service/adapters/fuel_gas_price_provider.rs
@@ -53,16 +53,15 @@ impl FuelGasPriceProvider {
}
}
-#[async_trait::async_trait]
impl ProducerGasPriceProvider for FuelGasPriceProvider
where
A: GasPriceAlgorithm + Send + Sync,
{
- async fn production_gas_price(&self) -> anyhow::Result {
+ fn production_gas_price(&self) -> anyhow::Result {
Ok(self.algorithm.next_gas_price())
}
- async fn dry_run_gas_price(&self) -> anyhow::Result {
+ fn dry_run_gas_price(&self) -> anyhow::Result {
let price = self.latest_gas_price.inner_next_gas_price();
Ok(price)
}
diff --git a/crates/fuel-core/src/service/adapters/fuel_gas_price_provider/tests/producer_gas_price_tests.rs b/crates/fuel-core/src/service/adapters/fuel_gas_price_provider/tests/producer_gas_price_tests.rs
index 6d9bc797002..f84fea71416 100644
--- a/crates/fuel-core/src/service/adapters/fuel_gas_price_provider/tests/producer_gas_price_tests.rs
+++ b/crates/fuel-core/src/service/adapters/fuel_gas_price_provider/tests/producer_gas_price_tests.rs
@@ -5,8 +5,8 @@ use fuel_core_gas_price_service::{
};
use fuel_core_producer::block_producer::gas_price::GasPriceProvider;
-#[tokio::test]
-async fn production_gas_price__if_requested_block_height_is_latest_return_gas_price() {
+#[test]
+fn production_gas_price__if_requested_block_height_is_latest_return_gas_price() {
// given
let price = 33;
let algo = StaticAlgorithm::new(price);
@@ -14,14 +14,14 @@ async fn production_gas_price__if_requested_block_height_is_latest_return_gas_pr
// when
let expected_price = algo.next_gas_price();
- let actual_price = gas_price_provider.production_gas_price().await.unwrap();
+ let actual_price = gas_price_provider.production_gas_price().unwrap();
// then
assert_eq!(expected_price, actual_price);
}
-#[tokio::test]
-async fn _dry_run_gas_price__calculates_correctly_based_on_percentage() {
+#[test]
+fn dry_run_gas_price__calculates_correctly_based_on_percentage() {
// given
let height = 123;
let price = 33;
@@ -30,7 +30,7 @@ async fn _dry_run_gas_price__calculates_correctly_based_on_percentage() {
let gas_price_provider = build_provider(algo.clone(), height, price, percentage);
// when
- let actual = gas_price_provider.dry_run_gas_price().await.unwrap();
+ let actual = gas_price_provider.dry_run_gas_price().unwrap();
// then
let change_amount = price.saturating_mul(percentage as u64).saturating_div(100);
diff --git a/crates/fuel-core/src/service/adapters/producer.rs b/crates/fuel-core/src/service/adapters/producer.rs
index a16b0d74227..759e7e38263 100644
--- a/crates/fuel-core/src/service/adapters/producer.rs
+++ b/crates/fuel-core/src/service/adapters/producer.rs
@@ -248,13 +248,12 @@ impl fuel_core_producer::ports::BlockProducerDatabase for OnChainIterableKeyValu
}
}
-#[async_trait::async_trait]
impl GasPriceProvider for StaticGasPrice {
- async fn production_gas_price(&self) -> anyhow::Result {
+ fn production_gas_price(&self) -> anyhow::Result {
Ok(self.gas_price)
}
- async fn dry_run_gas_price(&self) -> anyhow::Result {
+ fn dry_run_gas_price(&self) -> anyhow::Result {
Ok(self.gas_price)
}
}
diff --git a/crates/services/gas_price_service/src/common/l2_block_source.rs b/crates/services/gas_price_service/src/common/l2_block_source.rs
index 5896ed183f7..d53a489bcbc 100644
--- a/crates/services/gas_price_service/src/common/l2_block_source.rs
+++ b/crates/services/gas_price_service/src/common/l2_block_source.rs
@@ -19,11 +19,11 @@ use fuel_core_types::{
fuel_types::BlockHeight,
services::block_importer::SharedImportResult,
};
+use std::future::Future;
use tokio_stream::StreamExt;
-#[async_trait::async_trait]
pub trait L2BlockSource: Send + Sync {
- async fn get_l2_block(&mut self) -> GasPriceResult;
+ fn get_l2_block(&mut self) -> impl Future