Closes #156 - fix: enforce MAX_BATCH_SIZE in all batch functions (#156) test: add b…#229
Merged
dDevAhmed merged 2 commits intoMay 30, 2026
Merged
Conversation
…st: add batch size limit tests; update batchSlash mismatch assertion
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.
Description
Closes #156
Changes proposed
What were you told to do?
Audit fix: enforce
MAX_BATCH_SIZEin all batch functions.What did I do?
Enforced a batch-size cap in every batch entry point:
VerifierSlashing.batchSlash— replaced the inline magic number50with a namedMAX_BATCH_SIZE = 50constant. Cap kept low because each slash performs an external staking call plus storage writes (heavier per item than a token transfer). Mismatch/oversize/empty cases now revert with custom errors (BatchLengthMismatch,BatchSizeExceeded,EmptyBatch) to match the contract's existing error style.TruthBountyClaims.settleClaimsBatch— already enforcedMAX_BATCH_SIZE = 200; annotated with the audit reference, no functional change.MockReputationOracle.batchSetReputationScores(test mock) — addedMAX_BATCH_SIZE = 200and a size guard for consistency and to prevent confusing out-of-gas failures. This is a robustness change, not a production security fix.Tests
test/BatchSizeLimit_test.tscovering, per function: empty batch reverts, mismatched array lengths revert, exactlyMAX_BATCH_SIZEsucceeds,MAX_BATCH_SIZE + 1reverts.VerifierSlashing_test.tsto expect the newBatchLengthMismatchcustom error.Behavior changes
batchSlashreverts are now custom errors instead of strings.MockReputationOracle.batchSetReputationScoresnow reverts on empty input (previously a silent no-op); no callers affected.Check List (Check all the applicable boxes)