diff --git a/packages/fuels-accounts/src/account.rs b/packages/fuels-accounts/src/account.rs index e858e9a38..2090364e2 100644 --- a/packages/fuels-accounts/src/account.rs +++ b/packages/fuels-accounts/src/account.rs @@ -371,12 +371,12 @@ mod tests { Ok(0) } - async fn maybe_estimate_predicates( + async fn estimate_predicates( &self, _: &FuelTransaction, _: Option, - ) -> Result> { - Ok(None) + ) -> Result { + unimplemented!() } } diff --git a/packages/fuels-accounts/src/provider.rs b/packages/fuels-accounts/src/provider.rs index 707a0f795..0e92238ff 100644 --- a/packages/fuels-accounts/src/provider.rs +++ b/packages/fuels-accounts/src/provider.rs @@ -869,14 +869,12 @@ impl DryRunner for Provider { Ok(self.estimate_gas_price(block_horizon).await?.gas_price) } - async fn maybe_estimate_predicates( + async fn estimate_predicates( &self, tx: &FuelTransaction, _latest_chain_executor_version: Option, - ) -> Result> { - // We always delegate the estimation to the client because estimating locally is no longer - // possible due to the need of blob storage - Ok(Some(self.uncached_client().estimate_predicates(tx).await?)) + ) -> Result { + Ok(self.uncached_client().estimate_predicates(tx).await?) } async fn consensus_parameters(&self) -> Result { diff --git a/packages/fuels-core/src/types/dry_runner.rs b/packages/fuels-core/src/types/dry_runner.rs index d3ea5dab8..7f0cbb06e 100644 --- a/packages/fuels-core/src/types/dry_runner.rs +++ b/packages/fuels-core/src/types/dry_runner.rs @@ -26,11 +26,11 @@ pub trait DryRunner: Send + Sync { async fn dry_run(&self, tx: FuelTransaction) -> Result; async fn estimate_gas_price(&self, block_horizon: u32) -> Result; async fn consensus_parameters(&self) -> Result; - async fn maybe_estimate_predicates( + async fn estimate_predicates( &self, tx: &FuelTransaction, latest_chain_executor_version: Option, - ) -> Result>; + ) -> Result; } #[cfg_attr(target_arch = "wasm32", async_trait(?Send))] @@ -48,13 +48,13 @@ impl DryRunner for &T { (*self).consensus_parameters().await } - async fn maybe_estimate_predicates( + async fn estimate_predicates( &self, tx: &FuelTransaction, latest_chain_executor_version: Option, - ) -> Result> { + ) -> Result { (*self) - .maybe_estimate_predicates(tx, latest_chain_executor_version) + .estimate_predicates(tx, latest_chain_executor_version) .await } } diff --git a/packages/fuels-core/src/types/transaction_builders.rs b/packages/fuels-core/src/types/transaction_builders.rs index 49ceb9d12..0f8ab9658 100644 --- a/packages/fuels-core/src/types/transaction_builders.rs +++ b/packages/fuels-core/src/types/transaction_builders.rs @@ -1661,12 +1661,12 @@ mod tests { Ok(0) } - async fn maybe_estimate_predicates( + async fn estimate_predicates( &self, tx: &FuelTransaction, _: Option, - ) -> Result> { - Ok(Some(tx.clone())) + ) -> Result { + Ok(tx.clone()) } } diff --git a/packages/fuels-core/src/types/wrappers/transaction.rs b/packages/fuels-core/src/types/wrappers/transaction.rs index a4590982f..bc414d41f 100644 --- a/packages/fuels-core/src/types/wrappers/transaction.rs +++ b/packages/fuels-core/src/types/wrappers/transaction.rs @@ -548,19 +548,11 @@ impl EstimablePredicates for UploadTransaction { provider: impl DryRunner, latest_chain_executor_version: Option, ) -> Result<()> { - if let Some(tx) = provider - .maybe_estimate_predicates(&self.tx.clone().into(), latest_chain_executor_version) - .await? - { - tx.as_upload().expect("is upload").clone_into(&mut self.tx); - } else { - // We no longer estimate locally since we don't have the blob storage. - // maybe_estimate_predicates should always return an estimation - return Err(error!( - Other, - "Should have been given an estimation from the node. This is a bug." - )); - } + let tx = provider + .estimate_predicates(&self.tx.clone().into(), latest_chain_executor_version) + .await?; + + tx.as_upload().expect("is upload").clone_into(&mut self.tx); Ok(()) } @@ -574,21 +566,13 @@ impl EstimablePredicates for UpgradeTransaction { provider: impl DryRunner, latest_chain_executor_version: Option, ) -> Result<()> { - if let Some(tx) = provider - .maybe_estimate_predicates(&self.tx.clone().into(), latest_chain_executor_version) - .await? - { - tx.as_upgrade() - .expect("is upgrade") - .clone_into(&mut self.tx); - } else { - // We no longer estimate locally since we don't have the blob storage. - // maybe_estimate_predicates should always return an estimation - return Err(error!( - Other, - "Should have been given an estimation from the node. This is a bug." - )); - } + let tx = provider + .estimate_predicates(&self.tx.clone().into(), latest_chain_executor_version) + .await?; + + tx.as_upgrade() + .expect("is upgrade") + .clone_into(&mut self.tx); Ok(()) } @@ -602,19 +586,11 @@ impl EstimablePredicates for CreateTransaction { provider: impl DryRunner, latest_chain_executor_version: Option, ) -> Result<()> { - if let Some(tx) = provider - .maybe_estimate_predicates(&self.tx.clone().into(), latest_chain_executor_version) - .await? - { - tx.as_create().expect("is create").clone_into(&mut self.tx); - } else { - // We no longer estimate locally since we don't have the blob storage. - // maybe_estimate_predicates should always return an estimation - return Err(error!( - Other, - "Should have been given an estimation from the node. This is a bug." - )); - } + let tx = provider + .estimate_predicates(&self.tx.clone().into(), latest_chain_executor_version) + .await?; + + tx.as_create().expect("is create").clone_into(&mut self.tx); Ok(()) } @@ -642,19 +618,11 @@ impl EstimablePredicates for ScriptTransaction { provider: impl DryRunner, latest_chain_executor_version: Option, ) -> Result<()> { - if let Some(tx) = provider - .maybe_estimate_predicates(&self.tx.clone().into(), latest_chain_executor_version) - .await? - { - tx.as_script().expect("is script").clone_into(&mut self.tx); - } else { - // We no longer estimate locally since we don't have the blob storage. - // maybe_estimate_predicates should always return an estimation - return Err(error!( - Other, - "Should have been given an estimation from the node. This is a bug." - )); - } + let tx = provider + .estimate_predicates(&self.tx.clone().into(), latest_chain_executor_version) + .await?; + + tx.as_script().expect("is script").clone_into(&mut self.tx); Ok(()) } @@ -668,19 +636,11 @@ impl EstimablePredicates for BlobTransaction { provider: impl DryRunner, latest_chain_executor_version: Option, ) -> Result<()> { - if let Some(tx) = provider - .maybe_estimate_predicates(&self.tx.clone().into(), latest_chain_executor_version) - .await? - { - tx.as_blob().expect("is blob").clone_into(&mut self.tx); - } else { - // We no longer estimate locally since we don't have the blob storage. - // maybe_estimate_predicates should always return an estimation - return Err(error!( - Other, - "Should have been given an estimation from the node. This is a bug." - )); - } + let tx = provider + .estimate_predicates(&self.tx.clone().into(), latest_chain_executor_version) + .await?; + + tx.as_blob().expect("is blob").clone_into(&mut self.tx); Ok(()) }