nautechsystems/nautilus_trader · error
Derived max fee per gas {max_fee} wei exceeds ceiling {max_f
Error message
Derived max fee per gas {max_fee} wei exceeds ceiling {max_fee_per_gas_wei} wei What it means
derive_fees computes a max fee per gas from a buffered base fee plus a priority fee and enforces a configured ceiling max_fee_per_gas_wei. It bails when the derived max fee exceeds that ceiling, so callers never sign a transaction whose fee cap exceeds policy. The priority fee is returned unchanged alongside.
Source
Thrown at crates/adapters/blockchain/src/execution/transaction.rs:368
///
/// # Errors
///
/// Returns an error if the derived max fee exceeds `max_fee_per_gas_wei` or the arithmetic
/// overflows.
pub fn derive_fees(
base_fee_per_gas_wei: u128,
priority_fee_per_gas_wei: u128,
base_fee_buffer_bps: u32,
max_fee_per_gas_wei: u128,
) -> anyhow::Result<(u128, u128)> {
let max_fee = compute_max_fee(
base_fee_per_gas_wei,
priority_fee_per_gas_wei,
base_fee_buffer_bps,
)?;
if max_fee > max_fee_per_gas_wei {
anyhow::bail!(
"Derived max fee per gas {max_fee} wei exceeds ceiling {max_fee_per_gas_wei} wei"
);
}
Ok((max_fee, priority_fee_per_gas_wei))
}
/// Computes the EIP-1559 max fee per gas: the base fee with `base_fee_buffer_bps` applied
/// plus the priority fee, without applying any ceiling.
///
/// # Errors
///
/// Returns an error if the arithmetic overflows.
pub fn compute_max_fee(
base_fee_per_gas_wei: u128,
priority_fee_per_gas_wei: u128,
base_fee_buffer_bps: u32,
) -> anyhow::Result<u128> {View on GitHub (pinned to 18893faf8b)
Solutions
- Raise the max_fee_per_gas_wei ceiling to accommodate current network base fee plus buffer and priority fee.
- Reduce base_fee_buffer_bps or the priority fee so the derived max fee fits under the ceiling.
- Refresh base fee data from the latest block — a stale/spiked base_fee_per_gas_wei input may be the cause.
- If the ceiling is a hard policy limit, delay or skip the transaction until base fee falls rather than raising the ceiling.
Example fix
// before let (max_fee, tip) = derive_fees(50_000_000_000, 2_000_000_000, 2000, 40_000_000_000)?; // derived > 40 gwei ceiling // after let (max_fee, tip) = derive_fees(50_000_000_000, 2_000_000_000, 2000, 75_000_000_000)?; // ceiling raised
Defensive patterns
Strategy: validation
Validate before calling
fn fees_within_ceiling(base_fee: u128, tip: u128, bps: u32, ceiling: u128) -> bool {
let max_fee = base_fee * (10_000 + bps as u128) / 10_000 + tip;
max_fee <= ceiling
}
// verify config before calling derive_fees Try / catch
match derive_fees(base_fee, tip, bps, ceiling) {
Err(e) if e.to_string().contains("exceeds ceiling") => /* defer tx or raise ceiling per policy */,
Err(e) => return Err(e),
Ok((max_fee, tip)) => (max_fee, tip),
} Prevention
- Derive fee ceilings from live network conditions with headroom, not hardcoded values
- Refresh base fee from the latest block before each signing
- Treat ceiling breaches as a signal to delay, not to clamp fees below estimate
- Alert when sustained base-fee levels approach the configured ceiling
When it happens
Trigger: Calling derive_fees (or prepare_and_sign_with_anchors) when base_fee_per_gas_wei plus its base_fee_buffer_bps buffer plus priority_fee_per_gas_wei exceeds max_fee_per_gas_wei — e.g. a network base-fee spike or a ceiling configured below current chain fees.
Common situations: Volatile base fee during congestion exceeding a static configured ceiling; max_fee_per_gas configured too low for current network conditions; base-fee buffer bps set too aggressively; stale fee data cached from a calmer period.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Unsupported blockchain {blockchain} for RPC connection
- Kraken Spot does not support the demo environment
- Redis config error: username supplied without password. Eith
- {secret_var} is required when {key_var} is provided
- {key_var} is required when {secret_var} is provided
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/24169ddc4e81cbd0.
Report an issue: GitHub.