Fix finalization RPC methods to use hex serialization for U64 values#2543
Closed
Fix finalization RPC methods to use hex serialization for U64 values#2543
Conversation
Copilot
AI
changed the title
[WIP] finalization rpc's uses U64
Fix finalization RPC methods to use hex serialization for U64 values
Jul 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR fixes finalization RPC methods to serialize U64 values as hex strings instead of decimal numbers, making them consistent with other RPC methods in the codebase.
Problem
Finalization RPC methods were returning U64 values as decimal numbers:
{ "proof": { ... }, "l1Height": 12345, "lastL2Height": 7899324 }This was inconsistent with other RPC methods that use hex strings for numeric values, and made the API less developer-friendly for blockchain applications where hex representation is standard.
Solution
1. Custom U64 Hex Serialization Module
Added
utils::u64_hexmodule that:"0x3039")"0x3039"and"3039"formats for deserialization2. Updated Finalization RPC Response Types
Applied hex serialization to key finalization fields:
LastVerifiedBatchProofResponse.l1_heightSequencerCommitmentResponse.l2_end_block_numberBatchProofOutputRpcResponse.last_l2_heightLightClientProofOutputRpcResponse.last_l2_height3. HexU64 Wrapper Type
Created strongly-typed
HexU64wrapper for RPC methods that return U64 directly:getLastScannedL1Height→ returnsHexU64getHeadL2BlockHeight→ returnsHexU64getVerifiedBatchProofsBySlotHeight→ acceptsHexU64parameter4. Updated Components
After
Finalization RPCs now return consistent hex format:
{ "proof": { ... }, "l1Height": "0x3039", "lastL2Height": "0x789abc" }Backward Compatibility
Testing
12345→"0x3039")"0x3039"and"3039"formatsFixes #2535.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.