Use string in extensions Block Height to be consistent#3187
Use string in extensions Block Height to be consistent#3187MitchTurner wants to merge 9 commits intomasterfrom
Conversation
PR SummaryMedium Risk Overview The Rust client is updated to deserialize Written by Cursor Bugbot for commit 228516c. This will update automatically on new commits. Configure here. |
|
|
||
| block_height_str.drain(..cut); | ||
| block_height_str | ||
| } |
There was a problem hiding this comment.
Unnecessary leading zero trimming is dead code
Low Severity
The block_to_trimmed_string function contains logic to trim leading zeros from a string (lines 144-152), but this code path can never execute meaningfully. In Rust, u32::to_string() never produces leading zeros - it always outputs the minimal decimal representation. The entire trimming logic is dead code that adds unnecessary complexity. The function could be simplified to just u32::from(block_height).to_string().
There was a problem hiding this comment.
... that's not what I was getting. I was getting leading zeros and that's why I added it.
| } | ||
|
|
||
| fn block_to_trimmed_string(block_height: BlockHeight) -> String { | ||
| let mut block_height_str = u32::from(block_height).to_string(); |
There was a problem hiding this comment.
Why we don't want to use to_string implementation of the BlockHeight?
crates/client/src/reqwest_ext.rs
Outdated
| match value { | ||
| None => Ok(None), | ||
| Some(value) => { | ||
| let parsed = value.parse::<u32>().map_err(|_| { |
There was a problem hiding this comment.
Why can't we parse directly into BlockHeight? It implemented FromStr trait
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
|
|
||
| block_height_str.drain(..cut); | ||
| block_height_str | ||
| } |
There was a problem hiding this comment.
Trimmed hex string breaks BlockHeight deserialization roundtrip
High Severity
block_to_trimmed_string strips leading zeros from BlockHeight::to_string()'s hex output (e.g., "00000064" → "64"), but the client-side deserialize_block_height_option calls BlockHeight::from_str on this trimmed value. Since BlockHeight is a fixed-width 4-byte hex type, from_str expects exactly 8 hex characters matching the Display format. Trimmed strings like "64" (wrong byte count) or "0" (odd-length hex) will fail to parse, breaking the response deserialization for current_fuel_block_height.


Linked Issues/PRs
#3177
Description
Checklist
Before requesting review
After merging, notify other teams
[Add or remove entries as needed]