nautechsystems/nautilus_trader · error
Estimated gas {estimate} with {gas_buffer_bps} bps buffer ({
Error message
Estimated gas {estimate} with {gas_buffer_bps} bps buffer ({buffered}) exceeds gas limit {gas_limit} What it means
derive_gas_limit applies a basis-point buffer to a gas estimate and checks the result against a configured gas_limit ceiling. It bails when the buffered estimate exceeds the ceiling (or when the buffer arithmetic overflows in apply_buffer_bps). This prevents submitting transactions whose declared gas limit is above the allowed maximum.
Source
Thrown at crates/adapters/blockchain/src/execution/transaction.rs:337
);
Ok(())
}
/// Applies `gas_buffer_bps` over the `eth_estimateGas` result.
///
/// A buffered estimate above `gas_limit` rejects the transaction rather than clamping to the
/// ceiling: on Arbitrum the estimate folds the L1 data fee into gas units, and clamping
/// guarantees a paid-for out-of-gas revert.
///
/// # Errors
///
/// Returns an error if the buffered estimate exceeds `gas_limit` or the arithmetic overflows.
pub fn derive_gas_limit(estimate: u64, gas_buffer_bps: u32, gas_limit: u64) -> anyhow::Result<u64> {
let buffered = apply_buffer_bps(u128::from(estimate), gas_buffer_bps)?;
if buffered > u128::from(gas_limit) {
anyhow::bail!(
"Estimated gas {estimate} with {gas_buffer_bps} bps buffer ({buffered}) exceeds gas limit {gas_limit}"
);
}
u64::try_from(buffered).context("buffered gas limit overflow")
}
/// Derives EIP-1559 fees from the latest base fee and the node's suggested priority fee.
///
/// `max_fee_per_gas` is the base fee with `base_fee_buffer_bps` applied plus the priority fee;
/// `max_priority_fee_per_gas` is the priority fee itself. `max_fee_per_gas_wei` is a hard
/// ceiling that rejects the transaction when current conditions exceed it.
///
/// # Errors
///
/// Returns an error if the derived max fee exceeds `max_fee_per_gas_wei` or the arithmetic
/// overflows.
pub fn derive_fees(View on GitHub (pinned to 18893faf8b)
Solutions
- Raise the configured gas_limit to at least the buffered estimate, if the ceiling is safe to raise.
- Reduce gas_buffer_bps so the buffered estimate fits under the ceiling.
- Investigate why the estimate is high: re-simulate the call, check for unexpectedly expensive contract paths or failing simulations.
- If the estimate genuinely exceeds the chain-safe maximum, abort the transaction rather than clamping — do not submit with a gas limit below the estimate.
Example fix
// before let gas = derive_gas_limit(estimate, 5000, 300_000)?; // buffered 750k > 300k ceiling // after let gas = derive_gas_limit(estimate, 1000, 1_000_000)?; // buffer and ceiling sized for the workload
Defensive patterns
Strategy: validation
Validate before calling
fn buffered_gas_ok(estimate: u64, gas_buffer_bps: u32, gas_limit: u64) -> bool {
let buffered = estimate as u128 * (10_000 + gas_buffer_bps as u128) / 10_000;
buffered <= gas_limit as u128
}
// check before calling derive_gas_limit / prepare_and_sign_with_anchors Try / catch
match derive_gas_limit(estimate, bps, limit) {
Err(e) if e.to_string().contains("exceeds gas limit") => /* raise gas_limit, lower bps, or abort the tx */,
Err(e) => return Err(e),
Ok(gas) => gas,
} Prevention
- Size gas_limit ceilings from recent block/contract gas usage, not stale values
- Re-simulate and re-estimate under current network conditions before signing
- Keep gas_buffer_bps modest (e.g. 10-20%) and reconcile against the ceiling in config validation
- Monitor estimate-vs-ceiling headroom and alert before it hits zero
When it happens
Trigger: Calling derive_gas_limit(estimate, gas_buffer_bps, gas_limit) where estimate * (1 + gas_buffer_bps/10000) > gas_limit, e.g. a large simulation estimate, an oversized buffer in bps, or a too-low configured gas_limit. Also raised via prepare_and_sign_with_anchors when building a transaction.
Common situations: Network congestion pushing estimates above a static gas_limit cap; a buffer configured too aggressively (e.g. 5000 bps = 50%); gas_limit configured from an outdated chain or block-gas setting; a pathological contract path consuming far more gas than the ceiling allows.
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
- Finalized transaction gas commission overflow
- Invalid step in bar_type.spec.step: {step} for aggregation={
- WETH balance overflow for included transaction {tx_hash} at
- Unsupported blockchain {blockchain} for RPC connection
- Kraken Spot does not support the demo environment
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/e9c8f1cbeaa762c3.
Report an issue: GitHub.