{"record":{"id":"f8009e7a59b79ec1","repo":"nautechsystems/nautilus_trader","slug":"eth-gettransactionbyhash-returned-a-mismatched-tra","errorCode":null,"errorMessage":"eth_getTransactionByHash returned a mismatched transaction hash","messagePattern":"eth_getTransactionByHash returned a mismatched transaction hash","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/rpc/http.rs","lineNumber":763,"sourceCode":"    /// does not match `tx_hash`.\n    #[cfg(feature = \"hypersync\")]\n    #[allow(\n        dead_code,\n        reason = \"Used by the independent verification read inventory\"\n    )]\n    pub(crate) async fn get_transaction_by_hash(\n        &self,\n        tx_hash: &B256,\n    ) -> anyhow::Result<Option<RpcTransaction>> {\n        let transaction: Option<RpcTransaction> = self\n            .execute_execution_rpc_call(\"eth_getTransactionByHash\", serde_json::json!([tx_hash]))\n            .await?;\n\n        if transaction\n            .as_ref()\n            .is_some_and(|transaction| transaction.hash != *tx_hash)\n        {\n            anyhow::bail!(\"eth_getTransactionByHash returned a mismatched transaction hash\");\n        }\n        Ok(transaction)\n    }\n\n    /// Returns the Geth `callTracer` tree for a transaction.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the trace method is unavailable or the result is missing or malformed.\n    #[cfg(feature = \"hypersync\")]\n    #[allow(\n        dead_code,\n        reason = \"Used by the independent verification read inventory\"\n    )]\n    pub(crate) async fn trace_transaction_call(\n        &self,\n        tx_hash: &B256,\n    ) -> anyhow::Result<RpcCallTrace> {","sourceCodeStart":745,"sourceCodeEnd":781,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/rpc/http.rs#L745-L781","documentation":"Safety check in `get_transaction_by_hash`: the transaction returned by `eth_getTransactionByHash` must carry the same `hash` that was requested; otherwise the library bails. It protects callers from RPC nodes returning mismatched transaction objects.","triggerScenarios":"Calling `get_transaction_by_hash(tx_hash)` and the node returns a transaction object whose `hash` field differs from the requested hash.","commonSituations":"Faulty RPC provider or proxy returning cached/mutated payloads; custom node software with hash-encoding bugs; race with an indexing middleware rewriting responses.","solutions":["Retry against a different, trusted RPC endpoint.","Remove or audit any middleware/proxy that rewrites JSON-RPC responses.","Ensure the requested hash is a well-formed 32-byte hex string so the node isn't forced into fuzzy matching.","Update the node software/provider client if self-hosting."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"fn valid_tx_hash(h: &str) -> bool { h.len() == 66 && h.starts_with(\"0x\") && h[2..].chars().all(|c| c.is_ascii_hexdigit()) }","typeGuard":"fn tx_matches(tx: &Transaction, tx_hash: &Hash) -> bool {\n    tx.hash == *tx_hash\n}","tryCatchPattern":"let tx = match rpc.get_transaction_by_hash(tx_hash).await {\n    Ok(t) => t,\n    Err(e) if e.to_string().contains(\"mismatched transaction hash\") => {\n        warn!(\"integrity check failed; retrying on fallback endpoint\");\n        fallback_rpc.get_transaction_by_hash(tx_hash).await?\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["Audit any proxy/middleware that rewrites JSON-RPC responses","Prefer direct provider connections for transaction-level integrity checks","Update self-hosted node software if hash-encoding bugs appear","Always send canonical 0x-prefixed lowercase hashes"],"tags":["evm","rpc","integrity-check","unexpected-response"],"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"}