nautechsystems/nautilus_trader · error
Missing gas limit
Error message
Missing gas limit
What it means
transform_hypersync_block reads the source block's gas_limit (a hex Quantity) and converts it to u64. The error fires when the gas_limit field is None, preventing construction of a complete domain Block.
Source
Thrown at crates/adapters/blockchain/src/hypersync/transform.rs:37
use nautilus_model::defi::{Block, Blockchain, hex::from_str_hex_to_u64};
use ustr::Ustr;
/// Converts a HyperSync block format to our internal [`Block`] type.
///
/// # Errors
///
/// Returns an error if required block fields are missing or if hex parsing fails.
pub fn transform_hypersync_block(
chain: Blockchain,
received_block: hypersync_client::simple_types::Block,
) -> Result<Block, anyhow::Error> {
let number = received_block
.number
.ok_or_else(|| anyhow::anyhow!("Missing block number"))?;
let gas_limit = from_str_hex_to_u64(
received_block
.gas_limit
.ok_or_else(|| anyhow::anyhow!("Missing gas limit"))?
.encode_hex()
.as_str(),
)?;
let gas_used = from_str_hex_to_u64(
received_block
.gas_used
.ok_or_else(|| anyhow::anyhow!("Missing gas used"))?
.encode_hex()
.as_str(),
)?;
let timestamp = from_str_hex_to_u64(
received_block
.timestamp
.ok_or_else(|| anyhow::anyhow!("Missing timestamp"))?
.encode_hex()
.as_str(),
)?;
View on GitHub (pinned to 18893faf8b)
Solutions
- Include gas_limit in the HyperSync block field selection
- Skip or re-fetch blocks missing gas_limit
- Update/verify the hypersync-client version populates gas_limit
- Inspect the raw response payload to confirm whether the upstream API omits the field
Example fix
// before
let gas_limit = from_str_hex_to_u64(received_block.gas_limit.ok_or_else(|| anyhow::anyhow!("Missing gas limit"))?.encode_hex().as_str())?;
// after
let Some(gas_limit_raw) = received_block.gas_limit else {
tracing::warn!("hypersync block missing gas_limit; skipping block");
return Ok(None);
};
let gas_limit = from_str_hex_to_u64(gas_limit_raw.encode_hex().as_str())?; Defensive patterns
Strategy: validation
Validate before calling
if received_block.gas_limit.is_none() {
tracing::warn!("skipping hypersync block without gas_limit");
return Ok(None);
} Type guard
fn block_has_gas_limit(b: &hypersync_client::simple_types::Block) -> bool {
b.gas_limit.is_some()
} Try / catch
match transform_hypersync_block(chain, block) {
Ok(b) => /* use b */,
Err(e) => { tracing::warn!("block transform failed: {e}"); continue; }
} Prevention
- Select gas_limit (and gas_used) fields in HyperSync block queries
- Validate all required block fields before transformation
- Handle partial blocks gracefully: skip, re-fetch, and alert on repeated gaps
When it happens
Trigger: transform_hypersync_block receives a hypersync_client::simple_types::Block whose gas_limit is None, called from pool_events_from_response while transforming a HyperSync response.
Common situations: HyperSync responses omitting gas_limit (partial blocks, API field selection gaps); upstream schema changes; blocks synthesized by tests or tooling without gas_limit set.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Missing block number
- Missing transaction hash in log
- Missing transaction index in the log
- Missing log index in the log
- Missing block number in the log
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/521c678d28e239dc.
Report an issue: GitHub.