Skip to content

fix!(rpc): disallow non-prefixed hex strings in RPC input#3328

Open
sistemd wants to merge 2 commits intomainfrom
sistemd/enforce-hex-prefix
Open

fix!(rpc): disallow non-prefixed hex strings in RPC input#3328
sistemd wants to merge 2 commits intomainfrom
sistemd/enforce-hex-prefix

Conversation

@sistemd
Copy link
Copy Markdown
Contributor

@sistemd sistemd commented Apr 11, 2026

Changes the JSON-RPC deserialization logic to reject hex strings without the 0x prefix. This brings us closer in line with the Starknet API spec.

Closes: #3309


It goes without saying that this change could break many existing clients, so it might be worth considering a more gradual deprecation strategy.

Also, while we're on the topic, I noticed another inconsistency between our deserialization logic and the spec. Patterns like ^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$ do not allow empty strings after the 0x prefix, but our deserialization logic currently allows them and treats them as zero.

Changes the JSON-RPC deserialization logic to reject hex strings without
the `0x` prefix. This brings us closer in line with the Starknet API
spec.
@sistemd sistemd requested a review from a team as a code owner April 11, 2026 22:12
Copy link
Copy Markdown
Contributor

@zvolin zvolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't say optional now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

@CHr15F0x CHr15F0x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Require "0x" prefix when deserializing hex numbers

3 participants