diff --git a/CHANGELOG.md b/CHANGELOG.md index 939c4189..4bbad810 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Unreleased +- Stop defaulting to the `"latest"` block in `eth_estimateGas` params [#1657](https://github.com/gakonst/ethers-rs/pull/1657) - Fix geth trace types for debug_traceTransaction rpc - Fix RLP decoding of legacy `Transaction` - Fix RLP encoding of `TransactionReceipt` [#1661](https://github.com/gakonst/ethers-rs/pull/1661) diff --git a/ethers-providers/src/provider.rs b/ethers-providers/src/provider.rs index 0aec2f7b..0b26489e 100644 --- a/ethers-providers/src/provider.rs +++ b/ethers-providers/src/provider.rs @@ -574,8 +574,14 @@ impl Middleware for Provider

{ block: Option, ) -> Result { let tx = utils::serialize(tx); - let block = utils::serialize(&block.unwrap_or_else(|| BlockNumber::Latest.into())); - self.request("eth_estimateGas", [tx, block]).await + // Some nodes (e.g. old Optimism clients) don't support a block ID being passed as a param, + // so refrain from defaulting to BlockNumber::Latest. + let params = if let Some(block_id) = block { + vec![tx, utils::serialize(&block_id)] + } else { + vec![tx] + }; + self.request("eth_estimateGas", params).await } async fn create_access_list(