Skip to content

fix(rust-client): reject out-of-range faucet decimals from the node - #2423

Open
Xowiek wants to merge 1 commit into
0xMiden:nextfrom
Xowiek:validate-faucet-decimals
Open

fix(rust-client): reject out-of-range faucet decimals from the node#2423
Xowiek wants to merge 1 commit into
0xMiden:nextfrom
Xowiek:validate-faucet-decimals

Conversation

@Xowiek

@Xowiek Xowiek commented Aug 20, 2026

Copy link
Copy Markdown

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.

@Xowiek
Xowiek force-pushed the validate-faucet-decimals branch from 407bdaf to bddc73e Compare August 20, 2026 05:30
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.

1 participant