Everscale Depools: Distributed network validation built on smart contracts

Everscale Depools: Distributed network validation built on smart contracts

The Proof-of-Stake (PoS) consensus algorithm used in Everscale allows more people to participate in the transaction validation process than can participate in Proof-of-Work (PoW) systems. In order to participate in the latter, one has to have a top-level computing machine in order to keep pace in the everlasting hashrate arms race.

In PoS algorithms, minimum stake and minimum computational power requirements are much milder, allowing more people to secure the crypto network of their choice. Nevertheless, hoarding thousands of EVER and launching one’s own validator node is strenuous and is not possible for everyone. Hence, the blockchain needs a solution to increase its scale of decentralization and involve as many network participants in the consensus as possible.

Luckily, such a solution does exist in the Everscale blockchain and it is called Depools.

What is a Depool

Depool in Everscale stands for “Decentralized Pool,” which is a smart contract that allows other smart contracts to invest stakes of EVER tokens into a common pool of funds and to receive them back with interest after the validation period ends. The funds locked will be added up to a validator’s stake to increase their chances to be chosen for transaction validation.

Let us cover some crucial terms concerning Depools:

  • Participant — a smart contract that invests funds into Depool.
  • Validator — software running blockchain nodes. Each Depool works with one node only. This node must be a Depool participant.
  • Assurance — the minimum stake of the validator. This is to be forfeited if slashing (charging part of the malfunctioning or malicious validator’s stake as a mulct) occurs.
  • Ordinary Stake — a simple stake that is put every second round (an even or odd round). The division of the rounds by even and odd numbers is required to maintain the continuous validation process.
  • Vesting Stake — this stake is divided into two parts. This is done to ensure that the participant will take part in either an odd or even round, whichever they have been chosen to validate. A vesting stake also requires a set beneficiary address to receive the part of the stake by the end of every vesting period (this is quite similar to incremental option unlocking for an employee).
  • Lock Stake — similar to the Vesting stake in that it involves a division into two parts and gradual unlocking, but the beneficiary address plays another role here. During a lock stake, at the end of every vesting period some portion of the stake is returned to the owner (participant) address, and the remainder is reinvested. The rewards from the constantly diminishing stake are paid to the beneficiary address.
  • APY (Annual Percentage Yield) is the real rate of return earned that is calculated on the basis of compound interest, i.e. when the reward is reinvested at the end of every vesting period.
  • Elector — a system level smart contract, deployed to masterchain from the zero state. Elector contracts run validator elections periodically.
  • Depool Proxy (proxy) — a smart contract that delivers messages between a Depool and Elector. This smart contract is required because all Depool contracts are deployed to a workchain and all Elector contracts refuse to accept messages sent from workchain contracts.
  • Depool Helper — a smart contract that stores the address of the actual Depool and works with the Timer contract.
  • Validation period — period of time for which GVS is elected.
  • Investment round — period of time between a Participant investing a stake in Depool and receiving it back (with or without interest).
  • Timer — a smart contract that can call other smart contracts periodically.

Depositing Funds to a Depool

From a user's perspective, everything is clear and simple if the aggregator service called Ever Pools is used. With their EVER Wallet connected, one can interact with the interface to deposit EVER and send them to the chosen Depool contract in a couple of clicks. The assurance and fee are available in the base info on the Depool settings. 

Choosing a Depool to invest in is quite an easy task. The main thing to consider here is TVL, which is total value locked. You may find Depools deployed for testing purposes that have very low TVLs, which means that such Depools will never win elections and be accepted into the validation process. 

Another thing to bear in mind is the Depool fee, which denotes the percentage of total reward for validation that will be accrued to the validator’s wallet directly. This fee is to cover the costs of maintaining the node. Each participant’s portion is calculated in the following way: 100 - Depool fee. If you choose a Depool with a 10% validator fee, your reward will be calculated on the basis of the 90% of the total validation reward, according to your share in the Depool. 

The higher the assurance value, the better. This is the amount that will be slashed first if there is a validator malfunction during the validation period. Slashing is quite severe in the Everscale blockchain and that is why it is best to choose a Depool with the highest assurance value. 

APY is a dynamic value that depends mostly on network activity. You can check the average APY rate of every Depool on the Ever Pools website, where it is calculated based on previous investment rounds.

From a network smart contracts perspective, the Depool smart contract firstly receives a deposit from a user's account. Then the funds are allocated according to the staking scheme, which is initiated by calling a particular function of the smart contract.

A validator’s wallet must be among the participants of the Depool. They also deposit their own funds to the Depool smart contract. It is also worth mentioning that one validator can deploy several Depools smart contracts.

Investment round and validator election

Every election round goes through several steps that consist of interactions between Depool contracts, validator wallet contracts, and electors:

  1. The “PrePooling” step is an imaginary round, introduced to store half of the vesting/lock stakes from participants.
  2. The “Pooling” step is when the round is ready to accept stakes from Participants. This round receives ordinary, vesting and lock stakes.
  3. The “Waiting for election requests” step is when validator elections begin. Each Depool is waiting for a signed election request from a validator wallet. The validator wallet must also be a Participant and invest a sum that is at equal to the assurance value. If they don't, the round is completed and stakes are reinvested in another round or are returned to the participants.
  4. The “Waiting if stake is accepted by the elector” phase is when the Depool has received an election request signed by the validator. Then the Depool has to send the whole round stake to the elector through one of the Depool proxies. By this stage, the Depool is waiting for the elector’s answer. 
  5. The “Waiting for validation to start” phase comes when a stake is accepted by an elector. The validator then becomes a candidate. The Depool contract is waiting for the start of the validation to find out if the validator is going to win the elections.
  6. The “Waiting for the election result” stage denotes the moment when the Depool tries to recover its stake from an elector to find out if the validator has won the elections. If the validator wins the elections, the stake is not returned to the Depool contract. On the other hand, if the validator loses the elections, the elector contract returns the whole stake to the Depool smart contract.
  7. The “Waiting for the stake to unfreeze” step comes after the election results have been defined. If the elections have been lost, the election completion status gets updated and the stake gets sent back to the Depool. After receiving the stake, the Depool smart contract can reinvest it to participate in the next round. No defined completion reason implies that the Depool has won the election and it is going to be the validator for the next 18 hours, skipping the next election.
  8. “Waiting for a reward” is a step when the Unfreeze period has ended for the elected validator. The Depool sends a request to the elector to recover the stake and waits for an answer from the elector.
  9. The “Completing” step is when the Depool receives a reward and returns or reinvests participants’ stakes. Also during this step, the Depool recalculates vesting and lock stakes and modifies them if necessary. The completion reason here is defined as “Reward is received from the elector.”
  10. “Completed” means that the round has ended after all participants’ stakes have been recalculated in accordance with the rewards. The next tick-tock transaction will switch the round and this completed round will be deleted.

Is staking EVER with Depools secure?

There are many mechanisms in place to ensure that investing Everscale cryptocurrency in a Depool smart contract does not pose excessive risks to Depool participants.

First of all, there is an assurance sum that limits participants’ losses in case of validator slashing. Moreover, all validator wallets must be participants of the same rank as other users, thus sharing the risks and losses.

Second, the architecture of the Depool contract does not allow substantial changes to be made to the Depool code:

  • A Depool owner cannot change their wallet address associated with the Depool smart contract;
  • A Depool owner can only lower the percentage of the validator reward;
  • A Depool owner can terminate the Depool smart contract, but in this case all of the stakes, whether they are actively participating in validation process or simply stored on the Depool balance, will be returned to the participants’ addresses along with all the rewards from the current round;
  • No code changes are allowed for the Depool owner;
  • There are no means of initiating a transfer of an arbitrary amount to an arbitrary address from the Depool balance;
  • Any contract can call the ticktock() function to get a status update on the state of the Depool contract.

What is a tick-tock message and why is it important for a Depool?

A tick-tock message is a message emitted every time the Timer contract deployed to the Everscale workchain is called. Depool contracts cannot interact with the Timer contract directly. Instead, a Depool Helper contract calls the Timer contract and conveys the tick-tock message to the Depool. The interval between calls is chosen in accordance with the interval between elections.

This own “time awareness” of the Depool contract helps it to keep pace with election rounds. Receiving tick-tock messages results in changing to odd rounds from even ones and vice versa, and deleting previous rounds upon their completion. 

Moreover, such messages generated as a result of a participant contract call, carry updates of the Depool state, so the participants are aware of the election process and other parameters of the Depool contract.

Conclusion

Depools resolve the issue of low decentralization, which blockchains requiring highly performant nodes and enormous balances to participate in PoS validation have to grapple with. With Depools, validators only have to have a machine that meets the basic processing requirements. Stake amounts and elections are handled with the help of the ordinary users who want to take part in securing the network. Such circular interdependence enhances the security of the whole network and makes it truly decentralized and trustless.

Read More