nautechsystems/nautilus_trader · error · BlockchainRpcClientError

NewBlock event type cannot parse pool logs

Error message

NewBlock event type cannot parse pool logs

What it means

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.

Source

Thrown at crates/adapters/blockchain/src/rpc/core.rs:586

            RpcEventType::PoolMint(_) => dex_extended
                .parse_mint_event_rpc(log)
                .map(BlockchainMessage::MintEvent),
            RpcEventType::PoolBurn(_) => dex_extended
                .parse_burn_event_rpc(log)
                .map(BlockchainMessage::BurnEvent),
            RpcEventType::PoolCollect(_) => dex_extended
                .parse_collect_event_rpc(log)
                .map(BlockchainMessage::CollectEvent),
            RpcEventType::PoolFlash(_) => dex_extended
                .parse_flash_event_rpc(log)
                .map(BlockchainMessage::FlashEvent),
            RpcEventType::PoolFeeProtocolUpdate(_) => dex_extended
                .parse_fee_protocol_update_event_rpc(log)
                .map(BlockchainMessage::FeeProtocolUpdateEvent),
            RpcEventType::PoolFeeProtocolCollect(_) => dex_extended
                .parse_fee_protocol_collect_event_rpc(log)
                .map(BlockchainMessage::FeeProtocolCollectEvent),
            RpcEventType::NewBlock => Err(anyhow::anyhow!(
                "NewBlock event type cannot parse pool logs"
            )),
        }
        .map(Some)
        .map_err(|e| BlockchainRpcClientError::MessageParsingError(e.to_string()))
    }

    #[cfg(not(feature = "hypersync"))]
    fn blockchain_message_from_pool_log(
        &self,
        event_type: RpcEventType,
        log: &RpcLog,
    ) -> Result<Option<BlockchainMessage>, BlockchainRpcClientError> {
        if log.removed {
            log::debug!(
                "Skipping removed pool log on chain '{}' for event {:?}",
                self.chain.name,
                event_type

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Filter out NewBlock events before passing them to blockchain_message_from_pool_log (handle them in a separate newHeads path).
  2. Check the subscription setup so pool-log parsing only receives RpcEventType log variants (Swap/Mint/Burn/etc.).
  3. If NewBlock should produce a message, add a dedicated match arm returning the appropriate BlockchainMessage instead of an error.
  4. Inspect the RPC provider's notification payloads — some nodes inject NewBlock messages when debug/newHeads is enabled.

Example fix

// before
let msg = blockchain_message_from_pool_log(dex_extended, event, log)?;
// after
let msg = match event {
    RpcEventType::NewBlock => None, // handled elsewhere via newHeads
    _ => Some(blockchain_message_from_pool_log(dex_extended, event, log)?),
};
Defensive patterns

Strategy: type-guard

Validate before calling

// route events before parsing pool logs
match event {
    RpcEventType::NewBlock => handle_new_block(), // separate path
    _ => { /* safe to call blockchain_message_from_pool_log */ }
}

Type guard

fn is_pool_log_event(event: &RpcEventType) -> bool {
    !matches!(event, RpcEventType::NewBlock)
}

Try / catch

match blockchain_message_from_pool_log(dex, event, log) {
    Ok(Some(msg)) => handle(msg),
    Ok(None) => { /* no message for this log */ }
    Err(BlockchainRpcClientError::MessageParsingError(m))
        if m.contains("NewBlock") => { /* route to newHeads handler */ }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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