fix[venom]: make truthy or rule wrap-aware#5082
Conversation
charles-cooper
left a comment
There was a problem hiding this comment.
are there other bugs of this class in algebraic opts?
|
Audited the rest of Found one adjacent issue in The remaining raw Checked with: |
|
I did a quick sweep of the rest of The remaining direct literal reads are in the power-of-two strength-reduction probe for |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5082 +/- ##
==========================================
- Coverage 92.93% 92.84% -0.10%
==========================================
Files 188 191 +3
Lines 27840 29385 +1545
Branches 4831 5151 +320
==========================================
+ Hits 25874 27282 +1408
- Misses 1315 1411 +96
- Partials 651 692 +41 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Gas ChangesNo changes detected. Summary
|
📊 Bytecode Size Changes (venom)No changes detected. Full bytecode sizes
|
What I did
Fixes #5072.
The algebraic optimizer's truthy-position
orrule treated an unwrapped literal equal to2**256— which is zero as an EVM word — as nonzero, foldingor 2**256, %xin anassertposition to constant1instead of depending on%x.How I did it
One-line fix in
_rule_or: the raw checkops[0].value != 0becomes wrap-awarenot lit_eq(ops[0], 0), consistent with thex | 0 -> xrule directly below it which already useslit_eq. Audited the rest of the file for the same raw-.valuetruthiness pattern; this was the only instance.How to verify it
test_or_truthy_unwrapped_zero_literalparses the issue reproducer, runsAlgebraicOptimizationPass, and asserts theorreduces to%xrather than constant1. Fails on master.Commit message
Description for the changelog
Fix: Venom algebraic optimizer no longer folds
orwith an unwrapped zero literal (e.g.2**256) to constant true in truthy positions.Cute Animal Picture