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
The line above that caught my eye and I looked into how "nextDrawId" and "_nextDrawId" were being used.
I speculated that it would be more efficient if "_nextDrawId" was eliminated in favor of using the state variable directly. Testing proved that not to be true.
But what I did notice is that the following
nextDrawId = ++_nextDrawId;
is more efficient (less gas) than the current code
nextDrawId = _nextDrawId + 1;
</code.
While there is no need to increment "_nextDrawId" it isn't used again.
And even with future changes if it is used again, if it is supposed to mirror "nextDrawId", then it would probably need to be incremented anyway.
Handle
ye0lde
Vulnerability details
Impact
Gas savings when using ++var instead of var + 1
Proof of Concept
I noticed a typo here (rngReqeust):
https://github.com/pooltogether/v4-core/blob/35b00f710db422a6193131b7dc2de5202dc4677c/contracts/DrawBeacon.sol#L245
The line above that caught my eye and I looked into how "nextDrawId" and "_nextDrawId" were being used.
I speculated that it would be more efficient if "_nextDrawId" was eliminated in favor of using the state variable directly. Testing proved that not to be true.
But what I did notice is that the following
nextDrawId = ++_nextDrawId;
is more efficient (less gas) than the current code
nextDrawId = _nextDrawId + 1;
</code.
While there is no need to increment "_nextDrawId" it isn't used again.
And even with future changes if it is used again, if it is supposed to mirror "nextDrawId", then it would probably need to be incremented anyway.
Tools Used
Visual Studio Code, Remix
Recommended Mitigation Steps
Change this line
https://github.com/pooltogether/v4-core/blob/35b00f710db422a6193131b7dc2de5202dc4677c/contracts/DrawBeacon.sol#L243
to
nextDrawId = ++_nextDrawId;
The text was updated successfully, but these errors were encountered: