nautechsystems/nautilus_trader · error

Contract address should be set in logs

Error message

Contract address should be set in logs

What it means

In `parse_mint_event_hypersync`, the decoded HyperSync log's `address` field is `Option<Address>`; the parser calls `.expect("Contract address should be set in logs")` while converting it to the Uniswap V3 pool address. Every real EVM log carries the emitting contract's address, so a `None` here means the caller constructed a log without an address — a violation of the parser's input contract, hence a panic rather than a graceful error. It indicates malformed/incomplete log data passed to the hypersync parsing path, not a chain or decoding problem.

Source

Thrown at crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/mint.rs:96

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

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

        // Decode the data using the MintEventData struct
        let decoded = match <MintEventData as SolType>::abi_decode(data_bytes) {
            Ok(decoded) => decoded,
            Err(e) => anyhow::bail!("Failed to decode mint 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(MintEvent::new(
            dex,
            pool_identifier,
            extract_block_number(log)?,
            extract_transaction_hash(log)?,
            extract_transaction_index(log)?,
            extract_log_index(log)?,
            decoded.sender,
            owner,
            tick_lower,
            tick_upper,
            decoded.amount,
            decoded.amount0,
            decoded.amount1,
        ))

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Populate `log.address` with the emitting pool contract address in the log you pass to `parse_mint_event_hypersync`.
  2. If the log comes from deserialized hypersync data, verify the client/schema maps the log's `address` field correctly and is not dropping it.
  3. In code you control, match on the Option and return a descriptive error instead of relying on the panic.
  4. Check for hypersync-client version changes that altered the log struct's address field optionality.

Example fix

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

Strategy: validation

Validate before calling

fn ensure_log_address(log: &HyperSyncLog) -> Result<Address, String> {
    log.address
        .as_ref()
        .map(|a| Address::from_slice(a.as_ref()))
        .ok_or_else(|| "hypersync log missing contract address".to_string())
}

Type guard

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

Try / catch

// Rust: use Result instead of panic at the call site
let pool_address = ensure_log_address(&log)?;

Prevention

When it happens

Trigger: Calling `parse_mint_event_hypersync` with a `HyperSyncLog` whose `address` field is `None` (or the serde/default constructor left it unset), typically a hand-built log in tests or a deserialization path that did not populate `log.address`.

Common situations: Test fixtures for mint events built with `HyperSyncLog::default()` or struct-update syntax omitting `address`; a schema/version change in the hypersync client that makes `address` optional; gluing logs from another data source into the hypersync parser.

Related errors


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