{"record":{"id":"681ddaf107184035","repo":"nautechsystems/nautilus_trader","slug":"maximum-transaction-cost-overflow","errorCode":null,"errorMessage":"Maximum transaction cost overflow","messagePattern":"Maximum transaction cost overflow","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":2377,"sourceCode":"            self.verification\n                .verify_gas_estimate(\n                    &self.wallet_address,\n                    &to,\n                    value,\n                    &input,\n                    decision_header.number,\n                )\n                .await,\n            \"pre-sign gas estimate\",\n        )?;\n        let gas_estimate = gas_estimate_verification.value;\n        let gas_limit = derive_gas_limit(gas_estimate, self.gas_buffer_bps, self.gas_limit)?;\n        let max_gas_cost = U256::from(gas_limit)\n            .checked_mul(U256::from(max_fee_per_gas))\n            .ok_or_else(|| anyhow::anyhow!(\"Maximum gas cost overflow\"))?;\n        let max_transaction_cost = value\n            .checked_add(max_gas_cost)\n            .ok_or_else(|| anyhow::anyhow!(\"Maximum transaction cost overflow\"))?;\n        let native_balance_verification = required_verification(\n            self.verification\n                .verify_balance(&self.wallet_address, decision_header.number)\n                .await,\n            \"pre-sign native balance\",\n        )?;\n        let native_balance = native_balance_verification.value;\n\n        if native_balance < max_transaction_cost {\n            anyhow::bail!(\n                \"Native currency balance {native_balance} wei is below maximum transaction cost {max_transaction_cost} wei\"\n            );\n        }\n        let decision_height = Some(decision_header.number);\n        let mut decisions = vec![\n            verification_decision(&chain_id_verification, None, None),\n            verification_decision(\n                &decision_header_verification,","sourceCodeStart":2359,"sourceCodeEnd":2395,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L2359-L2395","documentation":"Immediately after computing max gas cost, the client adds the transaction `value` to it with checked U256 arithmetic to obtain the maximum total cost used for the native-balance check. If `value + max_gas_cost` overflows U256, the addition returns None and this error aborts the pre-sign flow.","triggerScenarios":"Calling the sign path with a `value` (msg.value in wei) so large that adding the maximum gas cost exceeds U256::MAX — e.g. a value near 2^256 from a unit conversion bug or corrupted intent payload.","commonSituations":"Wei/ether unit conversion mistakes when constructing the transaction value; corrupted or malicious intent data; combining a near-U256-max value with any non-zero gas cost.","solutions":["Validate that the transaction `value` is within the wallet/chain's realistic bounds before calling the sign path.","Fix unit conversion so the value is expressed in wei correctly (ether -> wei with 10^18 factor).","Reject or sanitize upstream intent payloads carrying implausible values.","Sanity-check max_fee_per_gas / gas_limit as in the sibling overflow error so max_gas_cost is not inflated."],"exampleFix":"// before\nlet value = U256::from_dec_str(\"115792089237316195423570985008687907853269984665640564039457584007913129639935\")?; // U256::MAX\n// after\nlet value = U256::from(1_000_000_000_000_000_000u64); // 1 ETH in wei, sanity-checked upstream","handlingStrategy":"validation","validationCode":"pub fn transaction_cost_fits(value: U256, max_gas_cost: U256) -> bool {\n    value.checked_add(max_gas_cost).is_some()\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Maximum transaction cost overflow\") => {\n        reject_intent(intent_id, \"implausible transaction value\");\n    }\n    other => other?,\n}","preventionTips":["Validate transaction value against per-intent maxima upstream.","Use type-safe unit conversion (ether -> wei) helpers, not hand-rolled exponent math.","Treat near-U256-max values as malformed input and reject early."],"tags":["blockchain","arithmetic-overflow","u256","transaction-value"],"backgroundTag":"value-out-of-range","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}