{"record":{"id":"c1413020dfd38652","repo":"nautechsystems/nautilus_trader","slug":"newblock-event-type-cannot-parse-pool-logs","errorCode":null,"errorMessage":"NewBlock event type cannot parse pool logs","messagePattern":"NewBlock event type cannot parse pool logs","errorType":"exception","errorClass":"BlockchainRpcClientError","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/rpc/core.rs","lineNumber":586,"sourceCode":"            RpcEventType::PoolMint(_) => dex_extended\n                .parse_mint_event_rpc(log)\n                .map(BlockchainMessage::MintEvent),\n            RpcEventType::PoolBurn(_) => dex_extended\n                .parse_burn_event_rpc(log)\n                .map(BlockchainMessage::BurnEvent),\n            RpcEventType::PoolCollect(_) => dex_extended\n                .parse_collect_event_rpc(log)\n                .map(BlockchainMessage::CollectEvent),\n            RpcEventType::PoolFlash(_) => dex_extended\n                .parse_flash_event_rpc(log)\n                .map(BlockchainMessage::FlashEvent),\n            RpcEventType::PoolFeeProtocolUpdate(_) => dex_extended\n                .parse_fee_protocol_update_event_rpc(log)\n                .map(BlockchainMessage::FeeProtocolUpdateEvent),\n            RpcEventType::PoolFeeProtocolCollect(_) => dex_extended\n                .parse_fee_protocol_collect_event_rpc(log)\n                .map(BlockchainMessage::FeeProtocolCollectEvent),\n            RpcEventType::NewBlock => Err(anyhow::anyhow!(\n                \"NewBlock event type cannot parse pool logs\"\n            )),\n        }\n        .map(Some)\n        .map_err(|e| BlockchainRpcClientError::MessageParsingError(e.to_string()))\n    }\n\n    #[cfg(not(feature = \"hypersync\"))]\n    fn blockchain_message_from_pool_log(\n        &self,\n        event_type: RpcEventType,\n        log: &RpcLog,\n    ) -> Result<Option<BlockchainMessage>, BlockchainRpcClientError> {\n        if log.removed {\n            log::debug!(\n                \"Skipping removed pool log on chain '{}' for event {:?}\",\n                self.chain.name,\n                event_type","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/rpc/core.rs#L568-L604","documentation":"blockchain_message_from_pool_log maps RPC log events to blockchain messages, but NewBlock is an internal notification event that carries no pool log data. When a NewBlock event is routed through the pool-log parsing path, the code explicitly rejects it with this error, since pool event decoding requires a contract log with topics/data.","triggerScenarios":"next_rpc_message processing a subscription/notification stream that delivers a NewBlock event type into the pool-log dispatch, instead of filtering it out beforehand (e.g. a subscription configured to also receive newHeads events).","commonSituations":"Subscribing to both newHeads and log streams and merging them into one message channel; an RPC node delivering synthetic NewBlock events mixed with logs; misconfigured event routing after adding a new event type to the enum.","solutions":["Filter out NewBlock events before passing them to blockchain_message_from_pool_log (handle them in a separate newHeads path).","Check the subscription setup so pool-log parsing only receives RpcEventType log variants (Swap/Mint/Burn/etc.).","If NewBlock should produce a message, add a dedicated match arm returning the appropriate BlockchainMessage instead of an error.","Inspect the RPC provider's notification payloads — some nodes inject NewBlock messages when debug/newHeads is enabled."],"exampleFix":"// before\nlet msg = blockchain_message_from_pool_log(dex_extended, event, log)?;\n// after\nlet msg = match event {\n    RpcEventType::NewBlock => None, // handled elsewhere via newHeads\n    _ => Some(blockchain_message_from_pool_log(dex_extended, event, log)?),\n};","handlingStrategy":"type-guard","validationCode":"// route events before parsing pool logs\nmatch event {\n    RpcEventType::NewBlock => handle_new_block(), // separate path\n    _ => { /* safe to call blockchain_message_from_pool_log */ }\n}","typeGuard":"fn is_pool_log_event(event: &RpcEventType) -> bool {\n    !matches!(event, RpcEventType::NewBlock)\n}","tryCatchPattern":"match blockchain_message_from_pool_log(dex, event, log) {\n    Ok(Some(msg)) => handle(msg),\n    Ok(None) => { /* no message for this log */ }\n    Err(BlockchainRpcClientError::MessageParsingError(m))\n        if m.contains(\"NewBlock\") => { /* route to newHeads handler */ }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep newHeads/NewBlock events on a dedicated subscription and channel.","Filter the event stream by type before pool-log parsing.","When adding new RpcEventType variants, update the dispatch match exhaustively."],"tags":["blockchain","rpc","event-parsing","unsupported-event"],"backgroundTag":"unsupported-operation","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"}