fix(rust-client): reject out-of-range faucet decimals from the node - #2423
Open
Xowiek wants to merge 1 commit into
Open
fix(rust-client): reject out-of-range faucet decimals from the node#2423Xowiek wants to merge 1 commit into
Xowiek wants to merge 1 commit into
Conversation
Xowiek
force-pushed
the
validate-faucet-decimals
branch
from
August 20, 2026 05:30
407bdaf to
bddc73e
Compare
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.
FungibleFaucet caps a faucet at MAX_DECIMALS and refuses to build a component
past it, and the CLI applies the same cap on the way in, since
tokens_to_base_units rejects an amount carrying more decimal places than that.
fetch_remote_token_metadata reads decimals straight out of the token config slot
of a node-supplied account proof and only checks that the felt fits a u8, so
anything from 13 to 255 is taken.
The value is then written to the settings store under the faucet key and read
back from there on every later lookup, so a single bad response keeps rendering
that faucet's balances until the row is replaced. The slot schema declares the
field as a u8, so the storage layout does not carry the protocol bound either.
The symbol sitting beside it in the same slot already gets its protocol type
check through TokenSymbol, so this closes the other half of that pair.
The decode moved into a small function so it can be driven directly, since the
call around it needs an account proof. Five tests: a config inside the bounds
decodes, MAX_DECIMALS itself is accepted, one above it and 200 are rejected, a
value too wide for a u8 is rejected, and a symbol that is not a TokenSymbol is
rejected. The third fails on next.