code-423n4 / 2021-12-vader-findings

0 stars 0 forks source link

Avoid use of state variables in event emissions to save gas #79

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

Jujic

Vulnerability details

Impact

Where possible, use equivalent function parameters or local variables in event emits instead of state variables to prevent expensive SLOADs. Post-Berlin, SLOADs on state variables accessed first-time in a transaction increased from 800 gas to 2100, which is a 2.5x increase.

Proof of Concept

https://github.com/code-423n4/2021-12-vader/blob/00ed84015d4116da2f9db0c68db6742c89e73f65/contracts/tokens/Vader.sol#L178

Tools Used

Remix

Recommended Mitigation Steps

0xstormtrooper commented 2 years ago

Vader is live

jack-the-pug commented 2 years ago

Dup #15