Cosmos Network is a project that allows anyone with a basic knowledge of programming in Go, to create their own blockchain based on the Proof-of-Stake (PoS) consensus protocol. This protocol, quite simply, bases its operation on the demonstration of the possession of a certain amount of tokens (ATOMs in the case of Cosmos) to allow the validation of the blocks that make up the blockchain itself. To better understand how it works in reality, let’s take a practical example.
Suppose that our blockchain is composed of the minimum number of nodes, namely 4, and we call these nodes Alice, Bob, Charlie and Denver. What will happen during the normal operation of the blockchain will therefore be as follows:
1. Generation of a block.
Every 6 seconds a new block must be generated. This block will contain all the transactions that have taken place since the previous block was generated. If no transaction is executed, the block will still be generated empty.
To generate the block, a node must be chosen as the forger. We will see later how this choice is made, but suppose that it is chosen at random Bob.
2. Validation of the generated block.
All nodes within the blockchain must validate the generated node, ensuring that the transactions contained within it are correct and have been created correctly.
In our case, the block must be validated by Alice, Charlie and Denver.
3.Distribution of the reward.
If the block is validated by all the nodes, then the person who generated the block receives a reward. All nodes, in exchange for their validation effort, receive in any case an amount of tokens.
Bob will therefore receive a slightly more substantial prize (+4%), but Alice, Charlie and Denver will also get their own reward.
As you can imagine, the most important step is therefore to determine fairly who should generate a block. If in fact such a proposer is always the same person (the same node), all the gain will go to him, making the whole system unfair.
To solve this problem, Cosmos has implemented the random choice algorithm. According to this system, the generating node is chosen among all the nodes present, taking into consideration also the quantity of ATOM he owns. To make this system as fair as possible, the amount of tokens he owns only partially affects the result of the extraction, and guarantees to all (even those who have very few tokens) to be extracted eventually. To better understand this, let’s take another practical example.
Let’s assume that our first blockchain has the following distribution of tokens:
- Alice owns 100 tokens
- Bob owns 75 tokens
- Charlie owns 30 tokens
- Denver has 2 tokens
According to what has been said, Alice will have a much higher probability of being extracted as a proposer than Denver, but Denver doesn’t have to worry about that because the system also guarantees him to be extracted sooner or later.
The amount of tokens that a node puts into play to increase the probability of being extracted as a proposer of the next block is called stake.
Validators and Slashing
Through the examples we have seen, we have implicitly introduced one of the two main figures of a blockchain using the Proof of Stake protocol: the validator.
A validator is a node that puts a stake into play in order to be extracted as a proposer node and, in any case, validates the generated blocks.
This task is of fundamental importance for the blockchain itself as without the validators it could not exist. It is also vital to understand how important it is for validators to do their job properly. If in fact a validator were to start validating wrong transactions, or worse it were to team up with others to alter the history of the blockchain, it would be a disaster. For this reason within Cosmos there is a system of slashing the stake.
Slashing is the process by which in case a validator doesn’t behave correctly, part of its stake is burned (slashed).
The delegators and the bonding
As we have seen, validators are extracted based on the number of tokens they have. In order for the whole blockchain to work, it is therefore necessary that there is a sufficient amount of tokens always staked. If this were not the case, in fact, the blockchain would stop because it would not be possible to determine the proposers of the blocks. However, if you had to use only the tokens owned by the validators themselves, no one would want to cover this task. You have to think that a validator often supports an investment in terms of hardware (server, internet connection, etc.) and time needed to install everything. If he were to buy tokens, the validation work would be poorly convenient in economic terms, if not even inconvenient at all.
To solve this problem, Cosmos has introduced the possibility for all those who own some ATOMs to become a delegator.
A delegator is any Atom owner who lends his tokens to increase a validator’s stake, in return for a reward.
The process by which a delegate lends its Atom to a validator is called bonding.
Inside any blockchain created with Cosmos, in case you have tokens of that blockchain, you can lend your tokens to one of the validators to increase his stake and make him be advantaged in the extraction for the role of proposer of a block. This loan is repaid by the validator with the division among all its delegators of the gain that it receives after the generation of the block and the validation of the blocks generated by the other validators.
To encourage Atom owners to stake their tokens, Cosmos has also introduced an inflation system so that if the number of ATOM staked are less than 2/3 of the fully circulating ATOM supply, their value drops by up to 20% per year. By doing so, no ATOM owner has the advantage of keeping them without delegating them, but, on the contrary, by placing them within a stake, they have the possibility of increasing their token amount and therefore also the value of their investment.
In essence, therefore, the Proof-of-Stake on Cosmos works as follows.
- Anyone who owns some ATOMs delegates the value they want to one or more validators.
- One of the validators is extracted as a block proposer, and performs its duty.
- The other validators in the network check that the generated block is valid.
- If everything is correct, the proposer receives a compensation for its work.
Otherwise, it loses part of its stake.
- If each validator does its job correctly, it receives a gain. Otherwise, it is slashed by its own stake.
Obviously, the last two points are shared between the validator and its delegators.
In the event that a validator suffers a slash of its stake, delegators will also lose part of their assets. On the other hand, if the validator does its job correctly, they will receive a reward proportional to their commitment to the validator.
It should be noted that, very often, validators retain a share of the reward (a commission) before distributing the proceeds of the work to their delegators. This fee is decided unilaterally by the validator and is used by it to maintain the service and repay the hardware, software and usage costs of the entire system.
If you are an ATOM owner, I personally recommend that you put them on stake as soon as possible. As we have seen before, in fact, in case you hodl them you could risk that their value drops. If you put them on stake, however, you can have a return of up to 9% per year on your investment (considering a validator with a 10% commission and an inflation of 10% per year).
Lastly, I would like to point out that the first validator in Italy, Commercio.network, currently applies a commission of 9%. You can find more information on its website and on the validator’s page on Lunie.io.
I hope that this little introduction has been useful to you to understand a little better how Cosmos.network works and in general the Proof-of-Stake consensus algorithm. If all this seemed interesting to you, let me know in the comments! Good staking! 🚀