Skip to content

Commit

Permalink
fix relock, add SealedEpoch event
Browse files Browse the repository at this point in the history
  • Loading branch information
thang14 committed Aug 24, 2024
1 parent c4e1d61 commit b7ea882
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contracts/sfc/SFC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ contract SFC is SFCBase, Version {

event UpdatedBaseRewardPerSec(uint256 value);
event UpdatedOfflinePenaltyThreshold(uint256 blocksNum, uint256 period);
event SealedEpoch(uint256 epoch);

/*
Constructor
Expand Down Expand Up @@ -212,6 +213,8 @@ contract SFC is SFCBase, Version {
snapshot.endTime = _now();
snapshot.baseRewardPerSecond = c.baseRewardPerSecond();
snapshot.totalSupply = totalSupply;

emit SealedEpoch(currentSealedEpoch);
}

function sealEpochValidators(uint256[] calldata nextValidatorIDs) external onlyDriver {
Expand Down
6 changes: 6 additions & 0 deletions contracts/sfc/SFCLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1251,12 +1251,18 @@ contract SFCLib is SFCBase {
getLockupInfoV2[delAddr][validatorId][lId].lockedStake > 0,
"not locked up"
);
require(
duration >= getLockupInfoV2[delAddr][validatorId][lId].duration,
"lockup duration cannot decrease"
);

uint256 endTime = _now().add(duration);
_relockWhenDelegatorLock(validatorId, endTime);
_stashRewards(delAddr, validatorId, lId);

getLockupInfoV2[delAddr][validatorId][lId].lockedStake += amount;
getLockupInfoV2[delAddr][validatorId][lId].duration = duration;
getLockupInfoV2[delAddr][validatorId][lId].endTime = endTime;
totalLockupBalance[delAddr][validatorId] += amount;

emit LockedUpStake(delAddr, validatorId, lId, duration, amount);
Expand Down

0 comments on commit b7ea882

Please sign in to comment.