mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-30 09:38:24 -05:00
docs: update call fees docs on fallback (#3471)
Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
This commit is contained in:
@@ -374,8 +374,8 @@ pub(crate) struct CallFees {
|
||||
impl CallFees {
|
||||
/// Ensures the fields of a [CallRequest] are not conflicting.
|
||||
///
|
||||
/// If no `gasPrice` or `maxFeePerGas` is set, then the `gas_price` in the response will
|
||||
/// fallback to the given `basefee`.
|
||||
/// If no `gasPrice` or `maxFeePerGas` is set, then the `gas_price` in the returned `gas_price`
|
||||
/// will be `0`. See: <https://github.com/ethereum/go-ethereum/blob/2754b197c935ee63101cbbca2752338246384fec/internal/ethapi/transaction_args.go#L242-L255>
|
||||
fn ensure_fees(
|
||||
call_gas_price: Option<U256>,
|
||||
call_max_fee: Option<U256>,
|
||||
@@ -383,14 +383,10 @@ impl CallFees {
|
||||
base_fee: U256,
|
||||
) -> EthResult<CallFees> {
|
||||
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) => {
|
||||
// request for a legacy transaction
|
||||
// set everything to zero
|
||||
let gas_price = gas_price.unwrap_or(base_fee);
|
||||
// either legacy transaction or no fee fields are specified
|
||||
// when no fields are specified, set gas price to zero
|
||||
let gas_price = gas_price.unwrap_or(U256::ZERO);
|
||||
Ok(CallFees { gas_price, max_priority_fee_per_gas: None })
|
||||
}
|
||||
(None, max_fee_per_gas, max_priority_fee_per_gas) => {
|
||||
@@ -525,3 +521,15 @@ where
|
||||
db: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_ensure_0_fallback() {
|
||||
let CallFees { gas_price, .. } =
|
||||
CallFees::ensure_fees(None, None, None, U256::from(99)).unwrap();
|
||||
assert_eq!(gas_price, U256::ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user