Closed reubenr0d closed 1 year ago
I personally think adding address node
to the locks might be cleaner, this value would be populated by the global node
state variable at the time of execution.
So a migration process could look like this.
rescueUnlock
+ processUnstake
from node A
a. amount equals total amount staked to node A
b. Set pendingMigration
to amount from (a)setNode
to node B, we can receive and stake deposits to node B alreadyprocessWithdraw
+ rescueWithdraw
a. Set pendingMigration
to 0claimRewards
to restake migrated fundsOne thing that could be useful is to wrap the "rescue" functions into a "migrate" function which handles the state updates for uint256 pendingMIgration
Problem
In the current state of the Tenderizer, if we need to migrate stake to a new node, we need to perform a rescue withdrawal, set the new node and then stake. However in this workflow claimingRewards and stakes need to be paused while the resuce withdrawal is thawing. The goal of this issue is to make the necessary changes such that new deposits/stakes and immediately staked towards the new node, and we can start claiming rewards for the same, while the withdrawal for the previous node is still processing.
Proposed solution
node
storagesetNode()
apart from settingnode
we also storeoldNode
so that can be used to process the rescue withdrawal.rescueUnlock()
,processUnstake()
,processWithdraw()
we use node asoldNode == address(0) ? node : oldNode
processWithdraw()
we setoldNode
back to zero address, indicating that the withdrawal from the older node has been processed, and future unlocks will be processed fromnode
as usualcurrentPrincipal
rescueUnlock()
,cpAtResuce = currentPricnple
Graph._processNewStake()
,rewards = int256(stake) + int256(cpAtRescue) - int256(currentPrincipal_);
_claimRewards()
,However this requires us to also change _stake() to accept the node.
Tenderizer.claimRewards()
,_stake(steak.balanceOf(address(this)) - cpAtRescue);