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>
@huklaa

huklaa commented Sep 4, 2026

Copy link
Copy Markdown

I claimed #352 at 13:09 PDT with the exact implementation scope stated publicly. This PR was then opened about 13 minutes later and covers that same scope. Opening a duplicate implementation after a visible claim, without first coordinating on the issue, is not consistent with fair and collaborative open-source contribution etiquette. Please withdraw/close #355 and allow me to complete the work I claimed first. If you had independently started before my claim, please provide that chronology so maintainers can assess it transparently.

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

2 participants