diff --git a/CHANGELOG.md b/CHANGELOG.md index a1d1e2bf5d..63a5cb9a42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,7 @@ * [FIX][rust] A transaction's own TX_FEE note is no longer tracked as an input note the paying account could consume. It is a bearer note, so the note screener reported it as consumable, and tracking it registered its note tag: every TX_FEE note on a chain shares one tag, so from a client's first fee-paying transaction onwards every sync pulled in every fee note the chain had produced ([#2446](https://github.com/0xMiden/rust-sdk/issues/2446)). * [FIX][rust] The RPC retry policy is now endpoint-aware: `SubmitProvenTransaction` and `SubmitProvenBatch` retry only `ResourceExhausted` and let `Unavailable` propagate, while read endpoints keep retrying both. `Unavailable` does not say whether the node processed the request, so resubmitting could hit the nullifier consumed by an accepted copy and report a conflict indistinguishable from a genuine double spend, hiding the original success ([#2441](https://github.com/0xMiden/rust-sdk/issues/2441)). * [FIX][cli] `-V`/`--version` now work when the binary is invoked under a different name, such as through the `miden client` shim installed by midenup ([#2486] https://github.com/0xMiden/rust-sdk/pull/2486)). +* [FIX][rust] `get_block_header_by_number` now reports a `chain_length` that does not fit in `usize` as `RpcError::InvalidResponse` instead of panicking. On a 32-bit target such as `wasm32`, a node returning a chain length above `u32::MAX` would abort the client; the conversion now mirrors the `map_err` already used on the adjacent forest-size check ([#2504](https://github.com/0xMiden/rust-sdk/pull/2504)). * [FIX][rust] `ChainAnchor` deserialization no longer panics on crafted input: a partial blockchain whose tracked leaf is missing an ancestor sibling, or whose block-map key disagrees with its header, is rejected as an invalid value, and anchors tracking more blocks than a transaction can reference are rejected early with the new `ChainAnchorError::TooManyTrackedBlocks` ([#2421](https://github.com/0xMiden/rust-sdk/pull/2421)). * [FIX][rust] `Client::execute_transaction_at` now fails with the new `ChainAnchorError::AnchoredTransactionExpired` when the executed transaction's expiration block has already been reached, instead of handing back a transaction the network would reject after proving ([#2421](https://github.com/0xMiden/rust-sdk/pull/2421)). * [FIX][rust] A request that sets `ignore_invalid_input_notes` but carries no input notes, or whose notes are all screened out, no longer fails with an out-of-range note-count error from the consumption checker ([#2421](https://github.com/0xMiden/rust-sdk/pull/2421)). diff --git a/crates/rust-client/src/rpc/tonic_client/mod.rs b/crates/rust-client/src/rpc/tonic_client/mod.rs index 1db3f60608..b3763f79a6 100644 --- a/crates/rust-client/src/rpc/tonic_client/mod.rs +++ b/crates/rust-client/src/rpc/tonic_client/mod.rs @@ -520,7 +520,9 @@ impl NodeRpcClient for GrpcClient { .ok_or(RpcError::ExpectedDataMissing("MmrPath".into()))? .try_into()?; - let forest_size = usize::try_from(forest).expect("u64 should fit in usize"); + let forest_size = usize::try_from(forest).map_err(|_| { + RpcError::InvalidResponse(format!("chain length {forest} does not fit in usize")) + })?; let forest = Forest::new(forest_size).map_err(|_| { RpcError::InvalidResponse(format!("invalid forest size: {forest_size}")) })?;