Summary (ELI5):
This EIP introduces four new opcodes: SAFEADD, SAFESUB, SAFEMUL, and SAFEDIV that perform unsigned 256-bit arithmetic with built-in overflow, underflow, and division-by-zero checking. This makes smart contracts easier to read and write and cheaper to execute.
Champion: Hubert Ritzdorf, ritzdorf (Hubert Ritzdorf) · GitHub
Detailed Justification:
- Currently, compilers add checked arithmetic, which creates significant overhead
- Introducing checked arithmetic opcodes would reduce the actual gas cost of a checked addition by 88% and 93% for vyper and solidity respectively
- This reduces execution cost and code size
- Previous approaches didn’t offer such great gas cost reductions
Stakeholder Impact:
Positive:
- Easier to implement EVM compilers
- More readable smart contracts
- Cheaper smart contract execution
- Smaller smart contract size
Negative:
- Four additional opcodes taken
Technical Readiness:
This proposal is ready. See Full EIP linked below. The required modifications in execution clients are relatively minor.
Security & Open Questions:
We welcome a discussion about the gas costs for the new opcodes.
Full EIP: