{"record":{"id":"274c93c81134be56","repo":"nautechsystems/nautilus_trader","slug":"unexpected-event-signature-in-bootstrap-latest-poo","errorCode":null,"errorMessage":"unexpected event signature in bootstrap_latest_pool_profiler: {event_signature} for log {log:?}","messagePattern":"unexpected event signature in bootstrap_latest_pool_profiler: (.+?) for log (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/data/core.rs","lineNumber":1874,"sourceCode":"                .is_some_and(|sig| sig.as_slice() == event_sig_bytes)\n            {\n                let fee_protocol_collect_event =\n                    dex_extended.parse_fee_protocol_collect_event_hypersync(&log)?;\n                let collect = self\n                    .process_pool_fee_protocol_collect_event(\n                        &fee_protocol_collect_event,\n                        &profiler.pool,\n                    )\n                    .with_context(|| {\n                        format!(\n                            \"failed to process CollectProtocol event at block {}\",\n                            fee_protocol_collect_event.block_number\n                        )\n                    })?;\n                profiler.process(&DexPoolData::FeeProtocolCollect(collect))?;\n            } else {\n                let event_signature = hex::encode(event_sig_bytes);\n                anyhow::bail!(\n                    \"unexpected event signature in bootstrap_latest_pool_profiler: {event_signature} for log {log:?}\"\n                );\n            }\n        }\n\n        self.flush_pool_event_blocks(&mut block_batch).await?;\n        profiler.finalize_reporting();\n\n        let snapshot_block_position = self.block_scoped_snapshot_position(to_block).await?;\n        let on_chain_snapshot = self\n            .get_on_chain_snapshot_at_position(&profiler, snapshot_block_position)\n            .await\n            .with_context(|| {\n                format!(\n                    \"failed to restore pool {} from RPC snapshot at target block {} with {} ticks and {} positions\",\n                    profiler.pool.address,\n                    to_block.separate_with_commas(),\n                    profiler.get_active_tick_values().len().separate_with_commas(),","sourceCodeStart":1856,"sourceCodeEnd":1892,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/data/core.rs#L1856-L1892","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["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.","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()`).","Re-run bootstrap pinned to a known-good DEX registry/config version so streamed signatures match the configured ones.","If the event is irrelevant, narrow the HyperSync subscription (event_signatures list) so the log is never streamed."],"exampleFix":"// before\nlet protocol_collect_sig_bytes = protocol_collect_event_signature\n    .map(|s| hex::decode(s.strip_prefix(\"0x\").unwrap_or(s)).unwrap_or_default());\n// after\nlet protocol_collect_sig_bytes = match protocol_collect_event_signature {\n    Some(s) => Some(hex::decode(s.strip_prefix(\"0x\").unwrap_or(s))?),\n    None => None,\n};","handlingStrategy":"try-catch","validationCode":"// Validate configured event signatures are valid hex topic0 values before bootstrap\nfor sig in [dex.fee_protocol_update_event.as_deref(), dex.fee_protocol_collect_event.as_deref()].into_iter().flatten() {\n    hex::decode(sig.strip_prefix(\"0x\").unwrap_or(sig))\n        .map_err(|e| anyhow::anyhow!(\"invalid event signature {sig}: {e}\"))?;\n}","typeGuard":null,"tryCatchPattern":"match bootstrap_result {\n    Err(e) if e.to_string().contains(\"unexpected event signature\") => {\n        log::warn!(\"unknown log signature during bootstrap: {e:#}; skipping pool or refreshing DEX config\");\n        // re-fetch DEX config or fall back to DB-based bootstrap\n    }\n    other => other?,\n}","preventionTips":["Never use unwrap_or_default() when decoding configured event signatures; propagate hex errors.","Keep HyperSync subscriptions scoped to exactly the configured event signatures.","Log and triage new event signatures emitted by pools before enabling them for RPC bootstrap."],"tags":["rpc","hypersync","event-parsing","unexpected-input"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}