{"record":{"id":"7bd403f83e1986d6","repo":"nautechsystems/nautilus_trader","slug":"included-wrap-transaction-tx-hash-has-invalid-bl","errorCode":null,"errorMessage":"Included wrap transaction {tx_hash} has invalid block number 0","messagePattern":"Included wrap transaction (.+?) has invalid block number 0","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":680,"sourceCode":"        let code = self.http_rpc_client.get_code(address).await?;\n        if code.is_empty() {\n            anyhow::bail!(\"No deployed bytecode at configured {description} address {address}\");\n        }\n        Ok(())\n    }\n\n    /// Ensures the wrapped native token balance increased by exactly `amount_wei` across the\n    /// block that included transaction `tx_hash`, reading both balances at their historical\n    /// blocks. Shared by the live wrap path and restart reconciliation.\n    async fn ensure_wrap_balance_increase(\n        &self,\n        weth_address: &Address,\n        amount_wei: U256,\n        tx_hash: B256,\n        block_number: u64,\n    ) -> anyhow::Result<()> {\n        let previous_block = block_number.checked_sub(1).ok_or_else(|| {\n            anyhow::anyhow!(\"Included wrap transaction {tx_hash} has invalid block number 0\")\n        })?;\n        let balance_before = self\n            .erc20_contract\n            .balance_of_at(weth_address, &self.wallet_address, previous_block)\n            .await\n            .with_context(|| {\n                format!(\n                    \"failed to read WETH balance before included transaction {tx_hash} at block {previous_block}\"\n                )\n            })?;\n        let balance_after = self\n            .erc20_contract\n            .balance_of_at(weth_address, &self.wallet_address, block_number)\n            .await\n            .with_context(|| {\n                format!(\n                    \"failed to read WETH balance after included transaction {tx_hash} at block {block_number}\"\n                )","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/d1527c24afdf475115785557f89a55c3e336c51f/crates/adapters/blockchain/src/execution/client.rs#L662-L698","documentation":"ensure_wrap_balance_increase (crates/adapters/blockchain/src/execution/client.rs:680) verifies a wrapped-native deposit by reading the WETH balance at block-1 and at the inclusion block; block_number.checked_sub(1) fails only when the receipt reported the wrap transaction as included in block 0. On production chains block 0 is genesis and contains no ordinary transactions, so a zero block number indicates a malformed or fabricated receipt from the RPC node, not a real inclusion. The check runs both in the live wrap path and in restart reconciliation.","triggerScenarios":"The RPC node returns a receipt with block_number 0 for the wrap transaction (misbehaving, forked, or pruned node; mock/dev RPC returning placeholder receipts); reconciling a persisted wrap intent whose recorded inclusion block is 0; a local test chain that numbers the first block 0 and reports receipts accordingly.","commonSituations":"Using a cheap or overloaded public RPC endpoint that serves garbage historical data; running against an in-process anvil/hardhat-style node with non-standard genesis handling; a node still syncing serving incomplete receipts.","solutions":["Point the client at a healthy, fully synced RPC endpoint (established provider or own synced node) and retry the wrap.","Look the transaction hash up in a block explorer and confirm which block actually included it.","If it recurs on a private chain, upgrade or reconfigure the node software so receipts carry correct block numbers.","If stuck at connect-time reconciliation, resolve the persisted intent in Postgres (verify on-chain state first) so the poisoned receipt does not block every restart."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn is_invalid_block_number(e: &anyhow::Error) -> bool {\n    e.to_string().contains(\"invalid block number 0\")\n}","tryCatchPattern":"if let Err(e) = client.wrap(amount_wei).await {\n    if is_invalid_block_number(&e) {\n        // RPC served a malformed receipt; do not retry against the same node blindly\n        log::error!(\"RPC returned an inclusion block of 0; switching endpoint required: {e}\");\n        return Err(e);\n    }\n    return Err(e);\n}","preventionTips":["Use a reputable, fully synced RPC provider for execution paths.","Monitor node health and syncing status; avoid nodes mid-sync for transaction workflows.","On private chains, verify receipt block numbering before enabling wrap operations.","Keep a fallback RPC endpoint configured so a bad node can be swapped quickly."],"tags":["rpc","ethereum","receipt","data-integrity","rust"],"backgroundTag":"invalid-block-number","analyzedSha":"d1527c24afdf475115785557f89a55c3e336c51f","analyzedAt":"2026-08-21T11:28:30.864Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}