nautechsystems/nautilus_trader · error

Contract address should be set in logs

Error message

Contract address should be set in logs

What it means

parse_fee_protocol_update_event_hypersync (Uniswap V3 variant) expects log.address to be Some: the address becomes the pool identifier of the FeeProtocolUpdateEvent. Since every Ethereum log carries its emitting contract address, the library asserts this with expect(); a None address indicates malformed input and panics, as documented in # Panics.

Source

Thrown at crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/fee_protocol_update.rs:82

    )?;

    if let Some(data) = &log.data {
        let data_bytes = data.as_ref();

        // Validate the data contains 4 parameters of 32 bytes each
        if data_bytes.len() < 4 * 32 {
            anyhow::bail!("SetFeeProtocol event data is too short");
        }

        let decoded = match <SetFeeProtocolEventData as SolType>::abi_decode(data_bytes) {
            Ok(decoded) => decoded,
            Err(e) => anyhow::bail!("Failed to decode SetFeeProtocol event data: {e}"),
        };

        let pool_address = Address::from_slice(
            log.address
                .clone()
                .expect("Contract address should be set in logs")
                .as_ref(),
        );
        let pool_identifier = PoolIdentifier::Address(Ustr::from(&pool_address.to_string()));

        Ok(FeeProtocolUpdateEvent::new(
            dex,
            pool_identifier,
            extract_block_number(log)?,
            extract_transaction_hash(log)?,
            extract_transaction_index(log)?,
            extract_log_index(log)?,
            u32::from(decoded.fee_protocol0_new),
            u32::from(decoded.fee_protocol1_new),
        ))
    } else {
        anyhow::bail!("Missing data in SetFeeProtocol event log");
    }
}

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Ensure the address field is selected in the Hypersync log query.
  2. Filter out address-less logs before parsing.
  3. Return an anyhow error instead of panicking when address is missing.

Example fix

// before
let pool_address = Address::from_slice(
    log.address.clone().expect("Contract address should be set in logs").as_ref(),
);
// after
let raw_address = log.address.as_ref()
    .ok_or_else(|| anyhow::anyhow!("missing contract address in SetFeeProtocol log"))?;
let pool_address = Address::from_slice(raw_address.as_ref());
Defensive patterns

Strategy: validation

Validate before calling

if log.address.is_none() {
    log::warn!("skipping SetFeeProtocol log without contract address");
    return Ok(());
}
let event = parse_fee_protocol_update_event_hypersync(dex.clone(), &log)?;

Type guard

fn has_address(log: &HypersyncLog) -> bool {
    log.address.is_some()
}

Try / catch

match parse_fee_protocol_update_event_hypersync(dex, &log) {
    Ok(event) => handle(event),
    Err(e) => log::error!("failed to parse SetFeeProtocol log: {e:#}"),
}
// Note: missing address panics via expect(); pre-check log.address before calling.

Prevention

When it happens

Trigger: Calling parse_fee_protocol_update_event_hypersync with a HypersyncLog whose address is None — from Hypersync queries omitting the address column, upstream partial rows, or test fixtures lacking address.

Common situations: Misconfigured Hypersync projections; Hypersync client/schema version changes; synthetic logs built in unit tests.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/f8c1f58c7689ce3b. Report an issue: GitHub.