-
Notifications
You must be signed in to change notification settings - Fork 50
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Added overflow handling for TWAB timestamp #204
[WIP] Added overflow handling for TWAB timestamp #204
Conversation
POOL-1408 Ticket contract should handle overflow cleanly
Two items can overflow:
The key is to let them overflow, but ensure you can detect when they overflow. A branch with partial implementation is here, although it will be out of date: https://github.com/pooltogether/pooltogether-contract-tsunami/tree/pool-1408-ticket-contract-should-handle-overflow I believe the branch solved the timestamp overflow, but not the amount. |
contracts/DrawCalculator.sol
Outdated
_timestampsWithStartCutoffTimes[i] = ( | ||
_draws[i].timestamp - _prizeDistributions[i].startTimestampOffset | ||
); | ||
_timestampsWithEndCutoffTimes[i] = uint32( | ||
_timestampsWithEndCutoffTimes[i] = ( | ||
_draws[i].timestamp - _prizeDistributions[i].endTimestampOffset | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we don't need these parentheses anymore right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't
@@ -261,8 +261,8 @@ contract Ticket is ControlledToken, ITicket { | |||
averageBalances[i] = TwabLib.getAverageBalanceBetween( | |||
_account.twabs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be stored in a variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which? The _account.twabs
? it's a pointer- wouldn't make a difference
@@ -2,6 +2,8 @@ | |||
|
|||
pragma solidity 0.8.6; | |||
|
|||
import "hardhat/console.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run yarn remove-logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yessir
@@ -41,14 +41,6 @@ describe('TwabLib', () => { | |||
.withArgs([200, 1, 1], [0, timestamp], false); | |||
}); | |||
|
|||
it('should require the timestamp to always increase', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why has this test been removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because if the passed timestamp is less than the previous timestamp it assumes that the timestamp has overflowed. That means this test is no longer relevant (I think)
2fe1bc4
to
2a9d203
Compare
contracts/DrawBeacon.sol
Outdated
@@ -191,7 +191,7 @@ contract DrawBeacon is IDrawBeacon, Ownable { | |||
} | |||
|
|||
/// @inheritdoc IDrawBeacon | |||
function calculateNextBeaconPeriodStartTime(uint256 _currentTime) | |||
function calculateNextBeaconPeriodStartTime(uint256 __currentTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to avoid shadowing? I've renamed to _time
:
v4-core/contracts/DrawBeacon.sol
Line 194 in b039133
function calculateNextBeaconPeriodStartTime(uint256 _time) |
So you probably need to rebase master.
ff7e8b8
to
0832802
Compare
0832802
to
688d7ad
Compare
No description provided.