fix(spammer): reject --mix weights whose total overflows u32 - #355
Open
kutluhaneth46 wants to merge 1 commit into
Open
fix(spammer): reject --mix weights whose total overflows u32#355kutluhaneth46 wants to merge 1 commit into
kutluhaneth46 wants to merge 1 commit into
Conversation
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>
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.
Summary
Fixes #352:
--mixaccepted individually validu32weights whose sum overflowsu32::MAX(e.g.transfer=4294967295,legacy=1), then panicked inTxTypeMix::total_weight()duringConfig::validate().Changes
TxTypeMix::checked_total_weight()using checked additionFromStrwith a clear--mixerrorConfig::validate()return an error instead of panickingtotal_weight()for post-validation callers (expects a safe total)try_parse_fromTest plan
cargo test -p spammer overflowingcargo test -p spammer tx_type_mixtransfer=70,legacy=30) still parse