Skip to content

Commit

Permalink
Merge pull request #252 from Layr-Labs/alex/fix-ext-call-in-loop
Browse files Browse the repository at this point in the history
Remove useless stake updates and fix issue where operator was set inc…
  • Loading branch information
wadealexc authored Oct 16, 2023
2 parents dad75a4 + fb44fef commit db916ae
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/contracts/core/DelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
(IStrategy[] memory strategies, uint256[] memory shares)
= getDelegatableShares(staker);

// push the operator's new stake to the StakeRegistry
_pushOperatorStakeUpdate(operator);

// emit an event if this action was not initiated by the staker themselves
if (msg.sender != staker) {
emit StakerForceUndelegated(staker, operator);
Expand Down Expand Up @@ -607,16 +604,19 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
podOwner: staker,
shares: withdrawal.shares[i]
});
currentOperator = delegatedTo[staker];
address podOwnerOperator = delegatedTo[staker];
// Similar to `isDelegated` logic
if (currentOperator != address(0)) {
if (podOwnerOperator != address(0)) {
_increaseOperatorShares({
operator: currentOperator,
operator: podOwnerOperator,
// the 'staker' here is the address receiving new shares
staker: staker,
strategy: withdrawal.strategies[i],
shares: increaseInDelegateableShares
});

// push the operator's new stake to the StakeRegistry
_pushOperatorStakeUpdate(podOwnerOperator);
}
} else {
strategyManager.addShares(msg.sender, withdrawal.strategies[i], withdrawal.shares[i]);
Expand Down Expand Up @@ -687,9 +687,6 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
strategy: strategies[i],
shares: shares[i]
});

// push the operator's new stake to the StakeRegistry
_pushOperatorStakeUpdate(operator);
}

// Remove active shares from EigenPodManager/StrategyManager
Expand All @@ -709,6 +706,11 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg
unchecked { ++i; }
}

// Push the operator's new stake to the StakeRegistry
if (operator != address(0)) {
_pushOperatorStakeUpdate(operator);
}

// Create queue entry and increment withdrawal nonce
uint256 nonce = cumulativeWithdrawalsQueued[staker];
cumulativeWithdrawalsQueued[staker]++;
Expand Down

0 comments on commit db916ae

Please sign in to comment.