-
Notifications
You must be signed in to change notification settings - Fork 68
Description
Summary:
When the first delegation occurs to a delegatee, and no subsequent operations are performed (like undelegating or redelegating), the preShare value remains 0. This causes issues with the reward calculation, as the reward logic relies on the correct preShare value.
Root Cause:
After the first delegation, the preShare is set to the current share value of the delegator. However, if no further operations are performed (such as redelegate or undelegate), the preShare value is not updated again, causing incorrect calculations for future rewards. The preShare should be updated properly in all cases where the delegation and reward calculations occur.
Reproduce Steps:
1. Delegate a certain amount to a delegatee for the first time (ensure no further delegate or undelegate happen afterward).
2. Verify that the preShare value of the delegator remains 0.
3. After some epochs, attempt to calculate rewards for the delegator.
4. Observe that the reward calculation is incorrect due to preShare being 0.
code in L2Staking.sol with PR693
// first delegate stake at this epoch, update checkpoint & preShare
if (delegatorDelegations[delegatee][_msgSender()].checkpoint < effectiveEpoch) {
delegatorDelegations[delegatee][_msgSender()].checkpoint = effectiveEpoch;
delegatorDelegations[delegatee][_msgSender()].preShare = delegatorDelegations[delegatee][_msgSender()]
.share;
}