{"record":{"id":"521c678d28e239dc","repo":"nautechsystems/nautilus_trader","slug":"missing-gas-limit","errorCode":null,"errorMessage":"Missing gas limit","messagePattern":"Missing gas limit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/hypersync/transform.rs","lineNumber":37,"sourceCode":"use nautilus_model::defi::{Block, Blockchain, hex::from_str_hex_to_u64};\nuse ustr::Ustr;\n\n/// Converts a HyperSync block format to our internal [`Block`] type.\n///\n/// # Errors\n///\n/// Returns an error if required block fields are missing or if hex parsing fails.\npub fn transform_hypersync_block(\n    chain: Blockchain,\n    received_block: hypersync_client::simple_types::Block,\n) -> Result<Block, anyhow::Error> {\n    let number = received_block\n        .number\n        .ok_or_else(|| anyhow::anyhow!(\"Missing block number\"))?;\n    let gas_limit = from_str_hex_to_u64(\n        received_block\n            .gas_limit\n            .ok_or_else(|| anyhow::anyhow!(\"Missing gas limit\"))?\n            .encode_hex()\n            .as_str(),\n    )?;\n    let gas_used = from_str_hex_to_u64(\n        received_block\n            .gas_used\n            .ok_or_else(|| anyhow::anyhow!(\"Missing gas used\"))?\n            .encode_hex()\n            .as_str(),\n    )?;\n    let timestamp = from_str_hex_to_u64(\n        received_block\n            .timestamp\n            .ok_or_else(|| anyhow::anyhow!(\"Missing timestamp\"))?\n            .encode_hex()\n            .as_str(),\n    )?;\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/hypersync/transform.rs#L19-L55","documentation":"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.","triggerScenarios":"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.","commonSituations":"HyperSync responses omitting gas_limit (partial blocks, API field selection gaps); upstream schema changes; blocks synthesized by tests or tooling without gas_limit set.","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"],"exampleFix":"// before\nlet gas_limit = from_str_hex_to_u64(received_block.gas_limit.ok_or_else(|| anyhow::anyhow!(\"Missing gas limit\"))?.encode_hex().as_str())?;\n// after\nlet Some(gas_limit_raw) = received_block.gas_limit else {\n    tracing::warn!(\"hypersync block missing gas_limit; skipping block\");\n    return Ok(None);\n};\nlet gas_limit = from_str_hex_to_u64(gas_limit_raw.encode_hex().as_str())?;","handlingStrategy":"validation","validationCode":"if received_block.gas_limit.is_none() {\n    tracing::warn!(\"skipping hypersync block without gas_limit\");\n    return Ok(None);\n}","typeGuard":"fn block_has_gas_limit(b: &hypersync_client::simple_types::Block) -> bool {\n    b.gas_limit.is_some()\n}","tryCatchPattern":"match transform_hypersync_block(chain, block) {\n    Ok(b) => /* use b */,\n    Err(e) => { tracing::warn!(\"block transform failed: {e}\"); continue; }\n}","preventionTips":["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"],"tags":["hypersync","blockchain","blocks","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}