From 82fe9ec46ad80c0ea09c3633a07bf87396f36bf6 Mon Sep 17 00:00:00 2001 From: KaoImin Date: Thu, 7 Dec 2023 12:01:46 +0800 Subject: [PATCH] fix: gas limit too low error --- core/api/src/jsonrpc/error.rs | 4 ---- core/api/src/jsonrpc/impl/web3.rs | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/core/api/src/jsonrpc/error.rs b/core/api/src/jsonrpc/error.rs index 6738d7463..ba0701cef 100644 --- a/core/api/src/jsonrpc/error.rs +++ b/core/api/src/jsonrpc/error.rs @@ -27,8 +27,6 @@ pub enum RpcError { GasLimitIsTooLow, #[display(fmt = "Gas limit is too large")] GasLimitIsTooLarge, - #[display(fmt = "Gas limit is zero")] - GasLimitIsZero, #[display(fmt = "Transaction is not signed")] TransactionIsNotSigned, #[display(fmt = "Cannot get latest block")] @@ -78,7 +76,6 @@ impl RpcError { RpcError::GasPriceIsTooLarge => -40007, RpcError::GasLimitIsTooLow => -40008, RpcError::GasLimitIsTooLarge => -40009, - RpcError::GasLimitIsZero => -40010, RpcError::TransactionIsNotSigned => -40011, RpcError::CannotGetLatestBlock => -40013, RpcError::InvalidBlockHash => -40014, @@ -116,7 +113,6 @@ impl From for ErrorObjectOwned { RpcError::GasPriceIsTooLarge => ErrorObject::owned(err_code, err, none_data), RpcError::GasLimitIsTooLow => ErrorObject::owned(err_code, err, none_data), RpcError::GasLimitIsTooLarge => ErrorObject::owned(err_code, err, none_data), - RpcError::GasLimitIsZero => ErrorObject::owned(err_code, err, none_data), RpcError::TransactionIsNotSigned => ErrorObject::owned(err_code, err, none_data), RpcError::CannotGetLatestBlock => ErrorObject::owned(err_code, err, none_data), RpcError::InvalidBlockHash => ErrorObject::owned(err_code, err, none_data), diff --git a/core/api/src/jsonrpc/impl/web3.rs b/core/api/src/jsonrpc/impl/web3.rs index 078e1fed7..79361f87b 100644 --- a/core/api/src/jsonrpc/impl/web3.rs +++ b/core/api/src/jsonrpc/impl/web3.rs @@ -453,8 +453,8 @@ impl Web3RpcServer for Web3RpcImpl { #[metrics_rpc("eth_estimateGas")] async fn estimate_gas(&self, req: Web3CallRequest, number: Option) -> RpcResult { if let Some(gas_limit) = req.gas.as_ref() { - if gas_limit == &U64::zero() { - return Err(RpcError::GasPriceIsZero.into()); + if gas_limit < &(MIN_TRANSACTION_GAS_LIMIT.into()) { + return Err(RpcError::GasLimitIsTooLow.into()); } }