{"record":{"id":"17483509a31056f1","repo":"nautechsystems/nautilus_trader","slug":"initialize-event-data-too-short-expected-at-least","errorCode":null,"errorMessage":"Initialize event data too short: expected at least 160 bytes, was {data_bytes_len}","messagePattern":"Initialize event data too short: expected at least 160 bytes, was (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/exchanges/parsing/uniswap_v4/initialize.rs","lineNumber":128,"sourceCode":"            .get(12..32)\n            .ok_or_else(|| anyhow::anyhow!(\"Invalid currency0 topic length\"))?,\n    );\n\n    let currency1 = Address::from_slice(\n        topics[3]\n            .as_ref()\n            .ok_or_else(|| anyhow::anyhow!(\"Missing currency1 topic\"))?\n            .as_ref()\n            .get(12..32)\n            .ok_or_else(|| anyhow::anyhow!(\"Invalid currency1 topic length\"))?,\n    );\n\n    if let Some(data) = log.data {\n        let data_bytes = data.as_ref();\n\n        // Validate minimum data length (5 fields × 32 bytes = 160 bytes)\n        if data_bytes.len() < 160 {\n            anyhow::bail!(\n                \"Initialize event data too short: expected at least 160 bytes, was {}\",\n                data_bytes.len()\n            );\n        }\n\n        let decoded = <InitializeEventData as SolType>::abi_decode(data_bytes)\n            .map_err(|e| anyhow::anyhow!(\"Failed to decode initialize event data: {e}\"))?;\n\n        let mut event = PoolCreatedEvent::new(\n            block_number,\n            currency0,\n            currency1,\n            pool_manager_address, // V4 pools are managed by PoolManager\n            PoolIdentifier::PoolId(pool_identifier), // Pool ID (bytes32 as hex string)\n            Some(decoded.fee.to::<u32>()),\n            Some(i32::try_from(decoded.tick_spacing)? as u32),\n        );\n","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/exchanges/parsing/uniswap_v4/initialize.rs#L110-L146","documentation":"parse_initialize_event_hypersync validates that the Initialize event data carries at least 5 words (160 bytes): sqrtPriceX96, tick, protocolFee, lpFee, and the reserved/extra word layout. Shorter data cannot be decoded as InitializeEventData, so the parser bails with the actual length in the message.","triggerScenarios":"Calling parse_initialize_event_hypersync with a V4 Initialize-like log whose data is under 160 bytes — an older V4 contract revision with fewer fields (e.g. before lpFee/protocolFee were added), a non-V4 event sharing the topic0, or truncated hypersync data.","commonSituations":"Indexing chains deployed with an earlier Uniswap V4 revision whose Initialize data layout omits newer fee fields; broad topic filters catching foreign events; provider truncation on old blocks.","solutions":["Check the V4 contract revision on the target chain and use InitializeEventData bindings matching that deployed version","Verify data length >= 160 in the caller before invoking the parser and skip shorter logs","Filter by exact V4 Initialize topic0 to exclude foreign events","Compare the failing log's data hex against the expected 5-word layout"],"exampleFix":"// before\nif data_bytes.len() < 160 {\n    anyhow::bail!(\"Initialize event data too short: expected at least 160 bytes, was {}\", data_bytes.len());\n}\n// after\nif data_bytes.len() < 160 {\n    tracing::debug!(len = data_bytes.len(), \"skipping short v4 initialize log\");\n    return Ok(None); // or continue\n}","handlingStrategy":"validation","validationCode":"fn has_v4_initialize_data(log: &HypersyncLog) -> bool {\n    log.data.as_ref().map(|d| d.as_ref().len() >= 160).unwrap_or(false)\n}\nif !has_v4_initialize_topics(&log) || !has_v4_initialize_data(&log) { skip_or_log(); }","typeGuard":null,"tryCatchPattern":"match parse_initialize_event_hypersync(&log, &dex) {\n    Ok(ev) => handle(ev),\n    Err(e) => { tracing::warn!(%e, \"short v4 initialize log skipped\"); Ok(None) }\n}","preventionTips":["Match InitializeEventData bindings to the deployed V4 contract revision per chain","Pre-check data length >= 160 bytes","Pin the exact topic0 filter","Compare failing payloads against the expected 5-word layout"],"tags":["blockchain","uniswap-v4","abi-decode","event-parsing"],"backgroundTag":"payload-too-large","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"}