Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary indirection to access block.timestamp value #34

Open
code423n4 opened this issue Jun 23, 2021 · 1 comment
Open

Unnecessary indirection to access block.timestamp value #34

code423n4 opened this issue Jun 23, 2021 · 1 comment

Comments

@code423n4
Copy link
Contributor

Handle

0xRajeev

Vulnerability details

Impact

_currentTime() returns the block.timestamp value to multiple call sites in PrizePool contract. This internal call only to get value of block.timestamp seems unnecessary because there isn’t any other way of getting current time on the blockchain which justifies moving this to a separate function for modularity.

Impact: Adds an additional jump and other supporting bytecode of making the internal call which increase gas usage unnecessarily.

Proof of Concept

https://github.com/code-423n4/2021-06-pooltogether/blob/85f8d044e7e46b7a3c64465dcd5dffa9d70e4a3e/contracts/PrizePool.sol#L1019-L1023

https://github.com/code-423n4/2021-06-pooltogether/blob/85f8d044e7e46b7a3c64465dcd5dffa9d70e4a3e/contracts/PrizePool.sol#L381

https://github.com/code-423n4/2021-06-pooltogether/blob/85f8d044e7e46b7a3c64465dcd5dffa9d70e4a3e/contracts/PrizePool.sol#L409

https://github.com/code-423n4/2021-06-pooltogether/blob/85f8d044e7e46b7a3c64465dcd5dffa9d70e4a3e/contracts/PrizePool.sol#L654

https://github.com/code-423n4/2021-06-pooltogether/blob/85f8d044e7e46b7a3c64465dcd5dffa9d70e4a3e/contracts/PrizePool.sol#L840

https://github.com/code-423n4/2021-06-pooltogether/blob/85f8d044e7e46b7a3c64465dcd5dffa9d70e4a3e/contracts/PrizePool.sol#L880

Tools Used

Manual Analysis

Recommended Mitigation Steps

Use block.timestamp directly to save a little gas by avoiding this unnecessary indirection.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Jun 23, 2021
code423n4 added a commit that referenced this issue Jun 23, 2021
@asselstine
Copy link
Collaborator

We need to manipulate the time for testing, and changing the EVM time via _increaseTime wasn't working consistently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants