nautechsystems/nautilus_trader · error

unexpected event signature in bootstrap_latest_pool_profiler

Error message

unexpected event signature in bootstrap_latest_pool_profiler: {event_signature} for log {log:?}

What it means

While replaying logs streamed from HyperSync, each log's topic0 signature is compared against the DEX's known event signatures (Initialize, Mint, Burn, and optionally fee-protocol Update/Collect). A log that matches none of them is unrecoverable for the profiler, so bootstrap aborts with the hex signature and raw log to aid diagnosis.

Solutions

  1. Decode the hex signature in the message and identify which event it belongs to; add it to the DEX's event config or handle it explicitly in the match chain.
  2. Check the DEX's `fee_protocol_update_event`/`fee_protocol_collect_event` hex strings for malformed values (invalid hex silently decodes to empty via `unwrap_or_default()`).
  3. Re-run bootstrap pinned to a known-good DEX registry/config version so streamed signatures match the configured ones.
  4. If the event is irrelevant, narrow the HyperSync subscription (event_signatures list) so the log is never streamed.

Example fix

// before
let protocol_collect_sig_bytes = protocol_collect_event_signature
    .map(|s| hex::decode(s.strip_prefix("0x").unwrap_or(s)).unwrap_or_default());
// after
let protocol_collect_sig_bytes = match protocol_collect_event_signature {
    Some(s) => Some(hex::decode(s.strip_prefix("0x").unwrap_or(s))?),
    None => None,
};
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate configured event signatures are valid hex topic0 values before bootstrap
for sig in [dex.fee_protocol_update_event.as_deref(), dex.fee_protocol_collect_event.as_deref()].into_iter().flatten() {
    hex::decode(sig.strip_prefix("0x").unwrap_or(sig))
        .map_err(|e| anyhow::anyhow!("invalid event signature {sig}: {e}"))?;
}

Try / catch

match bootstrap_result {
    Err(e) if e.to_string().contains("unexpected event signature") => {
        log::warn!("unknown log signature during bootstrap: {e:#}; skipping pool or refreshing DEX config");
        // re-fetch DEX config or fall back to DB-based bootstrap
    }
    other => other?,
}

Prevention

When it happens

Trigger: The HyperSync event stream (requested with the DEX's configured signatures) returns a log whose topic0 differs from initialize/mint/burn/fee-protocol signatures — typically because the stream was resumed with a broader filter, a signature was mis-decoded (e.g. empty default from `unwrap_or_default()` on an invalid hex fee-protocol event config), or the stream includes extra events for the pool address.

Common situations: A DEX config whose `fee_protocol_update_event`/`fee_protocol_collect_event` hex is malformed (decodes to empty and then every log matches spuriously or filters mismatch); HyperSync returning logs outside the requested topic set; pool address shared by a contract emitting additional events (e.g. factory-deployed pools with extra events).

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at crates/adapters/blockchain/src/data/core.rs:1874

                .is_some_and(|sig| sig.as_slice() == event_sig_bytes)
            {
                let fee_protocol_collect_event =
                    dex_extended.parse_fee_protocol_collect_event_hypersync(&log)?;
                let collect = self
                    .process_pool_fee_protocol_collect_event(
                        &fee_protocol_collect_event,
                        &profiler.pool,
                    )
                    .with_context(|| {
                        format!(
                            "failed to process CollectProtocol event at block {}",
                            fee_protocol_collect_event.block_number
                        )
                    })?;
                profiler.process(&DexPoolData::FeeProtocolCollect(collect))?;
            } else {
                let event_signature = hex::encode(event_sig_bytes);
                anyhow::bail!(
                    "unexpected event signature in bootstrap_latest_pool_profiler: {event_signature} for log {log:?}"
                );
            }
        }

        self.flush_pool_event_blocks(&mut block_batch).await?;
        profiler.finalize_reporting();

        let snapshot_block_position = self.block_scoped_snapshot_position(to_block).await?;
        let on_chain_snapshot = self
            .get_on_chain_snapshot_at_position(&profiler, snapshot_block_position)
            .await
            .with_context(|| {
                format!(
                    "failed to restore pool {} from RPC snapshot at target block {} with {} ticks and {} positions",
                    profiler.pool.address,
                    to_block.separate_with_commas(),
                    profiler.get_active_tick_values().len().separate_with_commas(),

View on GitHub (pinned to 18893faf8b)