You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Appendix D of Super-optimization of Smart Contracts, rule 10 says: DIV(x, x) = 1 -- this is actually sadly not true in EVM as far as I understand. When x is zero, that value is actually 0, not 1. It can be checked here. Maybe this rule has a check that x must never be zero, so it may still be correct when applied in the code, but as it is stated in the paper I believe it may be incorrect. Unfortunately I couldn't find where this rule is applied in the code of gasol-opimizer so I couldn't verify how it's actually applied :S Sorry.
I hope the above helps,
Mate
The text was updated successfully, but these errors were encountered:
Hi Mate! Thank you for the interest :-)
Yes, it's checked because first it tries to apply DIV(0,X) = 0 or DIV(X,0) = 0 and, after that, it checks DIV(X,X) so in case X =0 it applies always DIV(X,0) rule instead of DIV(X,X).
Ah, cool! And what if they are both symbolic? So let's say it's some:
DIV((SLOAD a) (SLOAD a))
Then the DIV(0, x) would not apply. Would it apply the DIV(x,x) rule in this case? Because the SLOAD a could be zero here I think? Or maybe it can never encounter this kind of symbolic expression?
Thanks once again for flagging the rule issue! You're right—we missed considering cases where symbolic expressions could represent zero values. In those cases, we shouldn't apply the rewrite rule. We'll fix it.
Appendix D of
Super-optimization of Smart Contracts
, rule 10 says:DIV(x, x) = 1
-- this is actually sadly not true in EVM as far as I understand. When x is zero, that value is actually 0, not 1. It can be checked here. Maybe this rule has a check thatx
must never be zero, so it may still be correct when applied in the code, but as it is stated in the paper I believe it may be incorrect. Unfortunately I couldn't find where this rule is applied in the code ofgasol-opimizer
so I couldn't verify how it's actually applied :S Sorry.I hope the above helps,
Mate
The text was updated successfully, but these errors were encountered: