Git Product home page Git Product logo

Comments (6)

malikankit avatar malikankit commented on June 29, 2024

Delegation on Stake Pool is a two step process. We need to account for that in our DelegateDeposit function and the bot.

Link to conversation on Slack about this : https://chorusone.slack.com/archives/C01TPS807D2/p1619433904001700

image

from solido.

malikankit avatar malikankit commented on June 29, 2024

Given that the Stake Pool program only accepts activated stake accounts, this needs to be broken into two functions.

A rough sketch below. Feel free to add notes @naomijub @enriquefynn @joncinque

DelegateDeposits attempts to create an activating stake account that will delegate x amount to validator v.
It will fail if there exists an activating or activated-but-not-merged stake account for this validator v.

Note : For each validator in the Stake Pool Program, we will only maintain atmost one (Activating or Activated-But-Not-Merged) Stake Account in the Lido Program.

1. DelegateDeposits(x: amount, v: validator) 
      1.1 Compute Stake Account Address = f(Program ID, Validator)
              - If it already exists, then it was created earlier by another DelegateDeposits call
              - And so it is either in `Activating Stake` or `Activated But Not Merged State`
              - A possibility is that at this point : we fail this transaction
              - So we are effectively pausing delegating to this validator until the last delegation
                we did for this validator has been activated and merged with the Stake Pool 
               - This also discourages repeated delegations to the same validator.  
               
              
      1.2 If you reached here, that means the stake account doesn't exist
      1.3 Create Stake Account with x SOL in it 
      - (taking the x SOL from the Lido Deposit Pool, of course x < amount in Deposit Pool) 
      1.4 Delegate it to the validator v
      1.5 <Check : What should we set the withdraw and stake authorities to - at this point 
             - so it's not stolen>
      1.6 Stake Account is now activating : nothing to do in this function

As mentioned above, for each validator in the Stake Pool Program, the Lido Program maintains atmost one stake account in the Lido Program.

SubmitStakeAccount(v) - checks if the Lido Program has a stake account that corresponds to this validator. If it exists and is activated and is the credits observed match (i.e. the stake account is mergeable) - it will submit this stake account to the Stake Pool program (in lieu of Stake Pool tokens)



2. SubmitStakeAccount(v: validator) 
    2.1 Compute Stake Account Address = f(Program ID, Validator)
    2.2 If this stake account doesn't exist - fail 
    2.3 If this stake account is still activating - fail
    2.4 If this stake account is activated 
    a) check - do credits_observed of your stake pool stake account and the deposited stake account match
    - If no, fail. 
    - If yes, proceed to next step
    b)  set authorities to Stake Pool Deposit Authority 
    c) call Stake Pool deposit for the above stake account (in the same transaction)
    2.5 Note : If 2.4 succeeds, then this Stake Account Address would be destroyed. 

from solido.

joncinque avatar joncinque commented on June 29, 2024

Regarding

1.5 <Check : What should we set the withdraw and stake authorities to - at this point - so it's not stolen>

You can do something very simple, and set the stake / withdraw authority directly to the deposit authority of the stake pool program, and that way you won't ever need to do 2.4.b

from solido.

malikankit avatar malikankit commented on June 29, 2024

Nice. I thought that at first, but something you wrote on Slack got me confused. I will clarify it in our call! :) Cheers.

from solido.

enriquefynn avatar enriquefynn commented on June 29, 2024

I think 2.2, 2.3 are covered when we call deposit to the stake pool, as it will try to merge the two stake accounts.
If both are activating is also fine (good for the tests) as @joncinque pointed out

from solido.

malikankit avatar malikankit commented on June 29, 2024

So the transaction will fail in these cases - when stake_merge is called in the Stake Pool program. Got it.

from solido.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.