-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC-0005: Protocol Upgrade to Enable Automatic Distribution of Delegation Rewards #9
base: main
Are you sure you want to change the base?
Conversation
… Delegation Rewards
… Delegation Rewards to RFC-0005: Protocol Upgrade to Enable Automatic Distribution of Delegation Rewards.md
Thanks for making this PR @lampardlamps! 🙏 |
RFCs/RFC-0005: Protocol Upgrade to Enable Automatic Distribution of Delegation Rewards.md
Outdated
Show resolved
Hide resolved
RFCs/RFC-0005: Protocol Upgrade to Enable Automatic Distribution of Delegation Rewards.md
Outdated
Show resolved
Hide resolved
RFCs/RFC-0005: Protocol Upgrade to Enable Automatic Distribution of Delegation Rewards.md
Show resolved
Hide resolved
Just wanted to surface here, I think there was a previous plan, to (1) add binding coinbase receiver to zkApps, and then (2) have a zkApp that can manage payouts (probably yeah based on the work Gareth had done). Do we think that would be sufficient, or is more necessary? Building a complete version of that zkApp could probably be a good grant to come out of this (and something that could go into production after hard fork launch, though a fully constrained version would have to wait until coinbase receiver is added in) |
… Delegation Rewards.md updated RFC based on Teddy's comments
Hi Evan, thanks for your comments. I was not involved in the details of the discussion. Was it determined that implementing a zkApp for this purpose would be the better choice than one on the protocol level? If so, the zkApp should be okay as long as it satisfies the requirements outlined here, namely: 1. the block producer do not have direct access to the block rewards; 2. the delegation charges are configurable onchain; 3. the rewards for each user is directly distributed/ available for claim according to the charge configurations. |
@teddyjfpender thanks for your comments Teddy, I've made some changes accordingly, I hope they are acceptable. |
Yep I think it would match those requirements - and yep the thought is if it can meet requirements it would be better this way than at the protocol level, since this way features can be added / removed as needed by BPs / staking pools, and without requiring HFs. |
Thanks Evan, makes perfect sense! |
I think Gareth should get involved in this conversation. I was a follower of that project and the last update I got "because of reliance on oracles. It's not worth it because of risks" I might be recalling details wrong. |
The big blocker was the lack of coinbase receiver binding - as anyone could just switch the coinbase receiver and not use the zkApp, which makes the solution kind of moot. As I understand at this time, there won't be an option to make the contract immutable, i.e., |
While the theory of payout creativity was an exciting idea, the reality is that it's been pretty limited. This is not some application-layer capability - it's directly related to the security of the blockchain and should be treated as such. I don't think there is much upside to a bunch of creativity in this area. A zkapp/oracle-dependent solution is a workaround, and while better than our current work-arounds, this should be implemented by the protocol. |
Intro@lampardlamps Thank you for the proposal and writing up the RFC! It is clear that this addition is a necessary component of the protocol and the ecosystem. That said, I find it quite high level. I think we should list various options with more specific details at a lower level. I propose we continue this comment thread to explore and refine potential solutions. I know that @garethtdavies was quite active in this area (thank you!), this is his zkApp description: https://hackmd.io/@garethtdavies/BJH3xMpFs Myself -- I am quite familiar with classic dPoS protocol solutions, which center around on-chain, in-protocol, in-daemon implementations. I list it below as the first one, but frankly, I think we should look for alternatives to leverage the power of ZK stack. Each of the solutions listed below may require breaking changes, but the extent of them is very different and depends on specific details. High level list of potential solutions1. Daemon extension for on-chain protocol rewards distributionThis is quite straight forward:
UNKNOWN:
PROS:
CONS:
2. zkApp DISTRIBUTING the rewardsI believe this case captures Gareths implementaiton. This is zkApp which:
PROS:
CONS:
3. zkApp ACCUMULATING the rewardsAs an alternative lets consider an app:
PROS
CONS
4.
|
@michal0mina From what I outlined above I could only support the first option while I didn't get the daemon part of that solution. I assume because no node actually hold data we are configurating the daemon to hold data for last 2 epochs but if you can elaborate more that would be very helpful. |
@EmrePiconbello Thanks for the comment and legal insights. I incorporated them in the big comment Re: the daemon solution -- this is it, but I mentioned those low level details as it's serious sub-system and long term maintenance, both for developers and node operators (as it is heavy system). |
Regarding the cons of a daemon solution: The daemon already has the entire delegation structure for the current and next epoch. The only thing to add (data-wise) would be the block producer fee. Separately, having the rewards be claimable, vs. auto-incrementing, would be very useful from a tax perspective to give delegators the ability to control timing of receipt of rewards. While this isn't anticipated in the daemon solution @michal0mina has written above, it is something to consider. This feature would add significantly more complication due to a) wanting to consider the rewards in pos lottery, and b) providing an accumulator to keep unpaid rewards. I don't have a strong opinion re: adding this to the specification, but it should be considered given its prevalence in other protocols. |
@jrwashburn Thanks Re the daemon -- I will investigate what we have now. Yes, we have the delegation ledger, but I thought it is only on BP level. About the logic that you describe:
|
The only place to get the staking ledgers (at least that I am aware of) is to export them from the daemon using |
For the daemon solution, I think we need to consider: New transactions:
We could also consider an Update Fee transaction; however, I think it is best to unregister and re-register with the new fee, so that delegates have a clear choice to accept the new fee amount. A further complication to consider would be supporting update fee - but it only taking effect for delegates after a certain date. This all seems like more trouble than it is worth and I suggest the simpler register/unregister approach. I'm certain the community will come up with monitoring solutions to alert delegates of the unregistrations, and expect wallets would notify on unregister as well. Another advantage of this approach would be that it could create an official registry of pools / those BP's offering to accept delegations. (Today, you can delegate to anyone, and we have seen instances of people setting up a pool fee of 100% to make it more clear that the are not a pool. This registry could be used to prevent delegating to people that do not want delegations.) |
@jrwashburn re the delayed update fee, it would be reasonable to apply at least the same delay as for delegations (epoch+1). If there is need for signalling, it may be increased. Also, it's worth considering adding constrains (e.g. max 2x increase, or max 50% increase) Lack of update mechanism would be painful for managing ecosystem of your users. Some sort of inheritance of the old delegators is surly helpful. |
I'm no expert in legal issues, but from purely technical point of view the simplest solution is to bake it into the protocol. Very simply, whenever the node constructing a block pays themselves a coinbase reward, it also scans the staking ledger in search of accounts delegating to them and immediately distributes the rewards among them. It may or may not add explicit transaction for each thus paid reward. While this is not necessary from the protocol's perspective (validators can compute those rewareds for themselves from the information already included in the block), it'll make it much easier for external software like indexers or Rosetta to figure out what's going on in the ledger (without those transactions they'd basically need to replicate the logic). Putting this into a zkApp, while probably could be done without changing the protocol, will require someone to run the zkApp, so it's still up to a BP whether or not they run the zkApp before or after having produced a block. It does not eliminate the trust issue. However, delaying the payment of these rewards on the protocol level complicates the system immensely. The unclaimed rewards must be kept somewhere so that total currency amount is predictable. Moreover, it forces us to implement an additional transaction type (claim rewards), which will have to be included in some future blocks. Also the information about who is entitled to claim how much must be stored somewhere. It cannot be computed from history unless we set a time limit after which unclaimed rewards are considered forefeit. On the other hand, implementing it in a zkApp seems relatively straightforward (all the information above will be stored in zkapp's state, probably even off-chain). So if we deem this feature really valuable, it's a strong argument for a zkapp solution. |
@michal0mina I agree these provisions mitigate the concern - and since monitoring by the delegator is necessary in every solution, as long as they would have a reasonable amount of time to re-delegate before the change, this overcomes my objections. I think Epoch +2 is necessary since the Epoch+1 staking ledger would already be baked. Edited to add: In case it is not clear - I still think we want a registry with register/unregister transactions. |
This thread seems very comprehensive. Interestingly, this decision has some downstream effects. At Kintsu we see a major overlap between this thread and the liquid staking RFC In terms of making a scalable and secure liquid staking protocol, delegation rewards should be permissionless and trustless, and ideally, there is a simple way to claim rewards on-chain. Alternatively, there can be some runtime call made arbitrarily that allows rewards to be claimed. |
Update:
We also discussed deeper zkApp designed that would worked based on epoch's staking ledger. cc: @es92 |
In our discussion in March, we thought that we can use the From the ledger hash, we should be able to prove both our account balance and our However, to prove how much we are allowed to withdraw depends on the total amount staked to the delegate. This is where we ended up getting blocked: The total stake per delegate is not something contained in the ledger or succinctly provable against it. To explore this direction further, I would consider a sort of "zk coprocessor" to Mina which provides this missing information: A map from delegates -> total stake. This coprocessor should probably be a shared piece of infrastructure because it is expensive to operate (needs to constantly churn out proofs). Another option could be to update the delegate -> total stake map as part of the existing protocol, in the transaction snark. That would be a HF-requiring change, but otherwise I think a fairly non-intrusive protocol change. It also might be the case that "historical preconditions" (which are on the protocol roadmap) are needed to get the relevant ledger snapshot (I don't know enough about staking/consensus to tell whether the existing |
@mitschabaude can zk cooprocessor be replaced with an oracle that serves appropriate ledger? Then the contract would be able to compute total delegated stake per delegate? I am assuming here once per epoch computation and once per epoch claim. Probably with the zk cooprocessor it would be possible to jump in and out on demand and do not wait full epoch for accounting. |
The problem is that a computation based on the current ledger would have to process every single account in the ledger and fully re-derive its hash. Otherwise, there is no way to prove that your calculation includes all accounts that are delegating to a particular delegate. I think processing the entire ledger in a zk circuit, every epoch, might be prohibitively expensive. Starting from a known correct delegate->total_stake map and updating it by using all new transactions applied to the ledger in between might be cheaper. |
@mitschabaude is there any middle ground? Can we use the ledger and hash as arguments and have outside tool to show these are complete and match each other? |
that's kinda where my zk coprocessor idea was going at alternatively you could have a trusted source that signs the data that the zkapp needs. (that source would have to be very trusted though because it determines who gets paid staking rewards) |
No description provided.