Tenderize / tender-core

Smart contracts for the core Tenderize protocol
MIT License
6 stars 3 forks source link

Node migration #265

Closed reubenr0d closed 1 year ago

reubenr0d commented 1 year ago

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 storage

currentPrincipal

kyriediculous commented 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.

  1. rescueUnlock + processUnstake from node A a. amount equals total amount staked to node A b. Set pendingMigration to amount from (a)
  2. setNodeto node B, we can receive and stake deposits to node B already
  3. processWithdraw+ rescueWithdraw a. Set pendingMigration to 0
  4. claimRewards to restake migrated funds
kyriediculous commented 1 year ago

One thing that could be useful is to wrap the "rescue" functions into a "migrate" function which handles the state updates for uint256 pendingMIgration

reubenr0d commented 1 year ago

Migration workflow