Skip to content

refactor(juno): restrict felt.Felt to accept only 0x prefixed hex values#3488

Merged
rodrodros merged 9 commits intomainfrom
maksym/starknet_call_hex
Mar 26, 2026
Merged

refactor(juno): restrict felt.Felt to accept only 0x prefixed hex values#3488
rodrodros merged 9 commits intomainfrom
maksym/starknet_call_hex

Conversation

@MaksymMalicki
Copy link
Copy Markdown
Contributor

@MaksymMalicki MaksymMalicki commented Mar 18, 2026

Previously, Felt accepted decimal numbers, binary strings, and bare hex. Now it only accepts 0x-prefixed hexadecimal strings. This tightens input validation for all JSON-deserialized felt values.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.41%. Comparing base (afe8c38) to head (1c63412).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
core/felt/felt.go 50.00% 0 Missing and 2 partials ⚠️
starknet/class.go 81.81% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3488      +/-   ##
==========================================
- Coverage   75.52%   75.41%   -0.11%     
==========================================
  Files         384      384              
  Lines       34937    34968      +31     
==========================================
- Hits        26386    26372      -14     
- Misses       6693     6696       +3     
- Partials     1858     1900      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread rpc/rpccore/limit_slice.go Outdated
@rodrodros rodrodros changed the title refactor: starknet_call data parameters to allow hex decimal numbes only refactor(rpc): starknet_call data parameters to allow hex decimal numbes only Mar 18, 2026
@MaksymMalicki MaksymMalicki marked this pull request as draft March 18, 2026 16:39
@MaksymMalicki MaksymMalicki marked this pull request as draft March 18, 2026 16:39
@MaksymMalicki MaksymMalicki changed the title refactor(rpc): starknet_call data parameters to allow hex decimal numbes only refactor(juno): restrict felt.Felt to accept only 0x prefixed hex values Mar 25, 2026
@MaksymMalicki MaksymMalicki force-pushed the maksym/starknet_call_hex branch from 467626f to e462337 Compare March 25, 2026 14:22
@MaksymMalicki MaksymMalicki marked this pull request as ready for review March 25, 2026 15:10
Comment thread adapters/core2sn/class_test.go Outdated
Copy link
Copy Markdown
Contributor

@thiagodeev thiagodeev left a comment

Choose a reason for hiding this comment

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

I have one question: if our concern is only about not allowing users to set decimals on felt fields values that should only allow hex values in RPC requests, why then not make this change specific to the RPC?
I mean, we are applying a general change in our entire code base (since felt is used everywhere (consensus, p2p, cryptography...)), where a felt from a decimal is not a problem at all (in some cases, it's even a required behavior (like the EntryPointOffset situation). IMO, this is not good. We should have a patch specifically for RPC-related code.

One idea is to create a new felt type, specifically to be used in all RPC requests, and implement the filter logic on it. Then, we update all RPC methods to use this type instead of felt.Felt.

E.g:

type FeltInput struct {
  *felt.Felt // with it as an embedded field, we can access all felt methods out of the box from the FeltInput type
}

func (z *FeltInput) UnmarshalJSON(data []byte) error {
  // filter logic here....
}

It's just one idea. How it should be done is something that we need to discuss, but I really believe this is the right choice.


Edit: after internal discussion with the team, we decided to move forward with the proposed approach in the PR.

Comment thread starknet/class.go Outdated
@rodrodros rodrodros enabled auto-merge (squash) March 26, 2026 10:32
@MaksymMalicki MaksymMalicki force-pushed the maksym/starknet_call_hex branch from 8848187 to aac696e Compare March 26, 2026 10:51
@MaksymMalicki MaksymMalicki force-pushed the maksym/starknet_call_hex branch from aac696e to 1c63412 Compare March 26, 2026 10:53
@rodrodros rodrodros merged commit d804434 into main Mar 26, 2026
14 checks passed
@rodrodros rodrodros deleted the maksym/starknet_call_hex branch March 26, 2026 11:05
brbrr pushed a commit that referenced this pull request Mar 26, 2026
… values (#3488)

* refactor: `starknet_call` data parameters to allow hex decimal numbers only

* chore: renames, increase codecov

* refactor: allow only 0x-prefixed hex strings for felt

* chore: linter issues

* chore: self review

* chore: remove deprecated felt constructors

* chore: minor cleanups

* chore: fix linter issues
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.

3 participants