desmos-labs / desmos

Improving the well-being of users on social networks through the blockchain technology.
https://desmos.network
Apache License 2.0
104 stars 46 forks source link

Introducing the idea of epoch #316

Open kwunyeung opened 3 years ago

kwunyeung commented 3 years ago
## Feature description

We always want to achieve a more fair mechanism for validators. When there is a limit in the validator set in PoS, it will never be fair. Even if the validators will be supported by the foundation, the validators outside of the set will never be selected to the set under PoS. Our first step is to spread the token as distributed as possible and encourage validators to join as many as possible.

One more step to consider is to select different validators at different time. So that even if we have limited number if validator slots, more validators can join. Increasing the validator set won't be a long term solution as it will just increase the block time under the asynchronous voting queue of Tendermint Core.

By introducing epoch, we can reselect validators and also use this as a period for applying the warm up / cool down of voting power issue raised in #194.

Implementation proposal

  1. Define a number of blocks for each epoch
  2. At the height of end of each epoch, taking the previous block hash of the block as random seed. Randomize a list of validator indexes and select them as validators.
  3. Update the validator set at the end of this block.

One issue comes from the random seed. I have discussed this issue with Band Protocol as they use the same method to select a small group of validators for reporting the oracle. Their approach is that the nodes have to calculated the randomized result 3 times to ensure deterministic. They have also audited the code and auditor considered using the block hash is safe.

We have planned the foundation should hold most of the tokens when launch. Then most of the delegations will be coming from the foundation. We can set up criteria on which validators should be supported, similar to what we are going to do with the 200 validator set. This can be done programmatically or by application. We can even delegate to those validators not in the active set as they will be selected in a long run. The total bonded stake holds high but the stake take part in the consensus may not be that much in each epoch.

If we can implement this, the idea will be similar to Polkadot's Nominated PoS and Celo's validator election. The difference is we can control the distribution to be fair at start which won't lead to Polkadot's problem of a single crypto fund split their stake in multiple nodes.

leobragaz commented 3 years ago

I like this approach and I think it could be achieved by slightly modify the x/staking module, probably with an edited version of a function that is call in EndBlocker.
These are my first impressions after taking a look on how the validator set is updated in such module, but it could even not be enough for what we want to achieve, I need to take a deeper look.

We can set up criteria on which validators should be supported, similar to what we are going to do with the 200 validator set.

About this, as a user with some delegated tokens, in the past I struggled to understand WHY I should delegate token to one validator rather than another one.
The first delegations I made was completely random and moved by gut (and commissions % LOL) and later on I felt like I wasn't acting like a crypto-user supposed to and redelegate everything to new and more uncommon validator, but even then, I struggled to understand WHO they are and WHY I should delegate to them. So I think that, when we set up these criteria, they should widely cover the validator "history", to help where it's possible users to make a good and clever choice for them and the system.

kwunyeung commented 3 years ago

@bragaz yes and the current staking mechanism on Cosmos Hub will just make delegators delegate to the top 10 or 20 validators. If I'm a I know a validator that is good but it has no enough delegation, I will not delegate to it as I will not receive any rewards. As a result, that validator will never be elected as an active validator. Using EndBlock is correct as this is how Tendermint update the validator set.

kwunyeung commented 3 years ago

This actually may be related to x/distribution and x/gov as many operations from these modules rely on the bonding stake.

RiccardoM commented 3 years ago

@kwunyeung Is this the same thing that is being proposed inside cosmos/cosmos-sdk#8569?

kwunyeung commented 3 years ago

@RiccardoM yes it is. I will read more on the ADR and join the discussion.

leobragaz commented 3 years ago

Epoch in staking module here: https://github.com/cosmos/cosmos-sdk/pull/9043