Conversation
ba0b3a8 to
8a30ed4
Compare
Member
Author
|
Latest update (
Local validation passed:
|
# Conflicts: # docs/ARITHMETIC_PROFILE.md
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
Partially addresses #1752.
Stdlib.Math.safeMulandStdlib.Math.safeDivalready exist and the executable path can userequireSomeUint (...), butverity_contractonly acceptedsafeAddandsafeSubin its compiledrequireSomeUinttranslator. This PR closes that inconsistency for checked multiplication and division:safeMulandsafeDivinrequireSomeUintbind type inferencerequireSomeUint (safeMul a b) "..."to an explicit overflow guard before binding the productb == 0 || (a * b) / b == arequireSomeUint (safeDiv a b) "..."to an explicitb != 0guard before binding the quotientsafeAdd/safeSub/safeMul/safeDivare all supported throughrequireSomeUintThis does not change bare
add/sub/mul/div; those remain wrapping/EVM arithmetic, so #1752 remains open for the broader Solidity-0.8 default-semantics question.Validation
lake build Contracts.Smoke Compiler.CompilationModelFeatureTest Contracts.MacroTranslateInvariantTest Contracts.MacroTranslateRoundTripFuzzpython3 scripts/check_macro_health.pymake checkgit diff --checkNote
Medium Risk
Extends
verity_contractmacro translation to new arithmetic forms, affecting generatedrequireguards and thus compiled runtime behavior for contracts using checked mul/div. Risk is moderate due to potential edge cases in overflow/zero-check lowering, but changes are localized and covered by new smoke/invariant tests and docs updates.Overview
Adds
verity_contractsupport for bindingrequireSomeUint (safeMul ...)andrequireSomeUint (safeDiv ...), extending the existing checkedsafeAdd/safeSublowering.The macro translator now typechecks these bind sources and lowers them to explicit compiled
requireguards: mul uses the standardb == 0 || (a*b)/b == aoverflow check, and div requiresb != 0before computing the quotient.Introduces a new
SafeMulRequireSmokecontract plus compilation-model and macro invariant/round-trip coverage, adds a generated Solidity property-test stub artifact, and updates docs to document the expanded checked-arithmetic lowering behavior.Reviewed by Cursor Bugbot for commit c7b164f. Bugbot is set up for automated code reviews on this repo. Configure here.