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

Fix im.31338 - Incorrect initialization of memory of struct in `checkpoint() #54

Merged
merged 4 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/ve/VeTetu.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contract VeTetu is ControllableV3, ReentrancyGuard, IVeTetu {
// *************************************************************

/// @dev Version of this contract. Adjust manually on each code modification.
string public constant VE_VERSION = "1.3.3";
string public constant VE_VERSION = "1.3.4";
uint internal constant WEEK = 1 weeks;
uint internal constant MAX_TIME = 16 weeks;
uint public constant MAX_ATTACHMENTS = 1;
Expand Down
10 changes: 8 additions & 2 deletions contracts/ve/VeTetuLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ library VeTetuLib {
mapping(uint => IVeTetu.Point[1000000000]) storage _userPointHistory,
mapping(uint => IVeTetu.Point) storage _pointHistory
) internal returns (uint newEpoch) {

if (info.tokenId != 0) {
// Calculate slopes and biases
// Kept at zero when they have to
Expand Down Expand Up @@ -301,7 +300,13 @@ library VeTetuLib {
// initialLastPoint is used for extrapolation to calculate block number
// (approximately, for *At methods) and save them
// as we cannot figure that out exactly from inside the contract
IVeTetu.Point memory initialLastPoint = lastPoint;
IVeTetu.Point memory initialLastPoint = IVeTetu.Point({
ts: lastPoint.ts,
slope: lastPoint.slope,
blk: lastPoint.blk,
bias: lastPoint.bias
});

uint blockSlope = 0;
// dblock/dt
if (block.timestamp > lastPoint.ts) {
Expand All @@ -328,6 +333,7 @@ library VeTetuLib {
lastCheckpoint = ti;
lastPoint.ts = ti;
lastPoint.blk = initialLastPoint.blk + (blockSlope * (ti - initialLastPoint.ts)) / MULTIPLIER;

info.epoch += 1;
if (ti == block.timestamp) {
lastPoint.blk = block.number;
Expand Down
Loading