mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-27 16:18:08 -05:00
chore(rpc): include call stipend for optimistic gas limit (#9703)
This commit is contained in:
@@ -21,7 +21,9 @@ use reth_rpc_eth_types::{
|
||||
},
|
||||
EthApiError, EthResult, RevertError, RpcInvalidTransactionError, StateCacheDb,
|
||||
};
|
||||
use reth_rpc_server_types::constants::gas_oracle::{ESTIMATE_GAS_ERROR_RATIO, MIN_TRANSACTION_GAS};
|
||||
use reth_rpc_server_types::constants::gas_oracle::{
|
||||
CALL_STIPEND_GAS, ESTIMATE_GAS_ERROR_RATIO, MIN_TRANSACTION_GAS,
|
||||
};
|
||||
use reth_rpc_types::{
|
||||
state::{EvmOverrides, StateOverride},
|
||||
AccessListWithGasUsed, BlockId, Bundle, EthCallResponse, StateContext, TransactionInfo,
|
||||
@@ -631,7 +633,7 @@ pub trait Call: LoadState + SpawnBlocking {
|
||||
//
|
||||
// Calculate the optimistic gas limit by adding gas used and gas refund,
|
||||
// then applying a 64/63 multiplier to account for gas forwarding rules.
|
||||
let optimistic_gas_limit = (gas_used + gas_refund) * 64 / 63;
|
||||
let optimistic_gas_limit = (gas_used + gas_refund + CALL_STIPEND_GAS) * 64 / 63;
|
||||
if optimistic_gas_limit < highest_gas_limit {
|
||||
// Set the transaction's gas limit to the calculated optimistic gas limit.
|
||||
env.tx.gas_limit = optimistic_gas_limit;
|
||||
|
||||
@@ -87,6 +87,9 @@ pub mod gas_oracle {
|
||||
/// Taken from Geth's implementation in order to pass the hive tests
|
||||
/// <https://github.com/ethereum/go-ethereum/blob/a5a4fa7032bb248f5a7c40f4e8df2b131c4186a4/internal/ethapi/api.go#L56>
|
||||
pub const ESTIMATE_GAS_ERROR_RATIO: f64 = 0.015;
|
||||
|
||||
/// Gas required at the beginning of a call.
|
||||
pub const CALL_STIPEND_GAS: u64 = 2_300;
|
||||
}
|
||||
|
||||
/// Cache specific constants
|
||||
|
||||
Reference in New Issue
Block a user