Skip to content

fix(spammer): reject --mix weights whose total overflows u32 - #355

Open
kutluhaneth46 wants to merge 1 commit into
circlefin:mainfrom
kutluhaneth46:fix/spammer-mix-weight-overflow
Open

fix(spammer): reject --mix weights whose total overflows u32#355
kutluhaneth46 wants to merge 1 commit into
circlefin:mainfrom
kutluhaneth46:fix/spammer-mix-weight-overflow

Conversation

@kutluhaneth46

Copy link
Copy Markdown

Summary

Fixes #352: --mix accepted individually valid u32 weights whose sum overflows u32::MAX (e.g. transfer=4294967295,legacy=1), then panicked in TxTypeMix::total_weight() during Config::validate().

Changes

  • Add TxTypeMix::checked_total_weight() using checked addition
  • Reject overflowing totals in FromStr with a clear --mix error
  • Make Config::validate() return an error instead of panicking
  • Keep total_weight() for post-validation callers (expects a safe total)
  • Tests: parser reject/accept boundaries, validate no-panic, CLI try_parse_from

Test plan

  • cargo test -p spammer overflowing
  • cargo test -p spammer tx_type_mix
  • Confirm ordinary mixes (transfer=70,legacy=30) still parse

Individually valid u32 weights could still sum past u32::MAX, panicking in
total_weight during Config::validate. Validate the aggregate with checked
addition at parse and validate time instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Spammer should reject transaction mix weights whose total overflows

1 participant