fix: set fees to zero if not provided (#1997)

This commit is contained in:
Dan Cline
2023-03-28 08:26:46 -04:00
committed by GitHub
parent 1ecbd55d45
commit 8987f4e8be
2 changed files with 12 additions and 0 deletions

View File

@ -30,6 +30,7 @@ use revm::{
}, },
Database, Database,
}; };
use tracing::trace;
// Gas per transaction not creating a contract. // Gas per transaction not creating a contract.
const MIN_TRANSACTION_GAS: u64 = 21_000u64; const MIN_TRANSACTION_GAS: u64 = 21_000u64;
@ -86,11 +87,18 @@ where
apply_state_overrides(state_overrides, &mut db)?; apply_state_overrides(state_overrides, &mut db)?;
} }
// The basefee should be ignored for eth_call
// See:
// <https://github.com/ethereum/go-ethereum/blob/ee8e83fa5f6cb261dad2ed0a7bbcde4930c41e6c/internal/ethapi/api.go#L985>
env.block.basefee = U256::ZERO;
if request_gas.is_none() && env.tx.gas_price > U256::ZERO { if request_gas.is_none() && env.tx.gas_price > U256::ZERO {
trace!(target: "rpc::eth::call", ?env, "Applying gas limit cap");
// no gas limit was provided in the request, so we need to cap the request's gas limit // no gas limit was provided in the request, so we need to cap the request's gas limit
cap_tx_gas_limit_with_caller_allowance(&mut db, &mut env.tx)?; cap_tx_gas_limit_with_caller_allowance(&mut db, &mut env.tx)?;
} }
trace!(target: "rpc::eth::call", ?env, "Executing call");
transact(&mut db, env) transact(&mut db, env)
} }

View File

@ -168,6 +168,10 @@ impl CallFees {
base_fee: U256, base_fee: U256,
) -> EthResult<CallFees> { ) -> EthResult<CallFees> {
match (call_gas_price, call_max_fee, call_priority_fee) { match (call_gas_price, call_max_fee, call_priority_fee) {
(None, None, None) => {
// when none are specified, they are all set to zero
Ok(CallFees { gas_price: U256::ZERO, max_priority_fee_per_gas: None })
}
(gas_price, None, None) => { (gas_price, None, None) => {
// request for a legacy transaction // request for a legacy transaction
// set everything to zero // set everything to zero