The Definitive Guide to Harmony Open Staking

Rongjian Lan
Apr 8 · 9 min read
Image for post
Image for post

Harmony is one of the first production mainnets to feature a fully sharded PoS architecture. Across the 4 shards in Harmony mainnet, blocks are produced every 8 seconds and cross-shard transactions are finalized in 2 block times.

Harmony’s Effective Proof-of-Stake (EPoS) is the first staking mechanism in a sharded blockchain that achieves both security and decentralization. EPoS allows staking from hundreds of validators and the unique effective stake mechanism reduces the tendency of stake centralization. Meanwhile, stake delegation, reward compounding, double-sign slashing, and unavailability checking are also supported.

Our token economics model incentivizes early stakers with higher rewards to bootstrap the network successfully. For those validators or delegators who would like to join Harmony Open Staking, this guide will help you get started and learn about how everything works.

Validator Setup and Configuration

A validator in Harmony blockchain is a single person or entity who stakes tokens and runs nodes (validator client software) to validate blocks. A validator can specify one or multiple validating keys (a.k.a. BLS keys) which will be used to sign on validated blocks.

To become a validator in Harmony, you will need to do the following:

  1. Setup a validator node(s) and let it fully synchronized with the latest blockchain. Please follow here to run a node.
  2. Create an on-chain validator record by sending a CreateValidator transaction. Please follow here to create your validator.
  3. Start validating using the node(s) with the BLS key(s) you added in your validator record

There are many fields to configure for your validator. It’s worth clarifying some of the important fields in more detail:

  1. amount: The amount of ONE tokens the validator will stake initially.
  2. rate: The commission fee (%) the validator charges from the block reward. (see section: block reward)
  3. bls-pubkeys: One or multiple BLS public keys the validator will sign with. Each BLS key will be used separately to bid for a slot and if successful, the key is obligated to validate blocks. (see section “Slots Bidding and Election”)

For a detailed guide on how to configure your validator, please follow here.

Slots Bidding and Election

In Open Staking of mainnet, there will be 320 slots available for bidding (200 slots in Stake Heist). A slot represents membership in the network which gives the validator the right to use a specific BLS key to sign on blocks and the signature will be acknowledged by other validators.

After you create the validator record, the tokens you stake, along with any delegated tokens to your validator, will be automatically used to bid for the slots.

Each of the added BLS keys will create a unique bid for a slot in the network. The bid price equals the total stake on your validator divided by the total number of BLS keys attached to your validator.

Simply put, all tokens staked to the validator will be equally divided into each BLS key and each key bids separately. For example, a validator with a total stake of 300 ONE and 3 associated BLS keys will have 3 bids each with a bid price of 100 ONE.

The election for the slots works as follows.

  1. Before the start of an epoch, all validator bids are ranked by bid price in descending order.
  2. The highest 320 bids will be awarded the slots in the upcoming epoch.

The BLS key that successfully bids for a slot is deemed elected. Elected BLS keys will eventually form the committees of the shards. A validator in possession of at least one elected BLS key is also deemed elected.

Example Election Process with 5 Validators for 10 Slots

Above is a simple example of bidding and election process with 10 slots and 5 validators. For more detailed examples, please read here.

Epoch Transition

In Harmony mainnet and in Stake Heist, there are 4 shards each producing new blocks separately and in parallel. The block heights between shards are not synchronized so you will see different shards have different block heights.

An epoch is a period of time when the beacon shard (i.e. shard 0, the coordinator for other shards) produces a fixed number of blocks. In Harmony mainnet, an epoch is 2¹⁴ = 16384 blocks (~1.5 days) in the beacon shard. Once an epoch is completed in the beacon shard, that change is also passed onto the other shards, thus all shards are synchronized by epoch.

At the end of each epoch, the committee election process will take place to elect the committees for the next epoch. The election process takes into account all the staking transactions confirmed before the election happens. The election result will take effect immediately, so we encourage all candidate validators to spin up their nodes even before the election happens.

Shard Assignment

After a validator is elected, each of its elected BLS keys will be semi-randomly assigned to a shard in the network (fully random shard assignment will come in the final phase of mainnet). In the current stage of mainnet, the rule of assignment is simply based on the modulus of the BLS public key’s underlying bytes. For example, with 4 shards, a BLS public key like “xxxxxx8ad5” will be assigned to shard 1 because 5 % 4 = 1. Note that, for each of the elected BLS keys, the validator is obligated to spin up a validator node and validate blocks in the assigned shard.

Effective Stake

Effective stake is a new measure introduced in EPoS in order to prevent stake centralization and still provide capitalistic fairness. For exactly how it achieves that, here is the design rationale behind it.

Let’s call the bid price of the elected BLS keys the raw stake. The effective stake of an elected BLS key is a bounded value on its raw stake with a threshold around the median bidder’s raw stake (denoted as median_stake in the picture below). The upper threshold is 115% of the median_stake and the lower threshold is 85% of the median_stake. For a key with raw stake that’s out of bound of the threshold, its effective stake will be bounded by the corresponding threshold, otherwise, the effective stake is the same as the raw stake.

The effective stake of each BLS key is determined at the last block of an epoch during the election process and will stay the same throughout the next epoch.

Image for post
Image for post
Effective Stake is Bounded around Median Stake

Shard Committee and Voting Power

After the election and shard assignment, the BLS keys assigned in a shard become the committee of that shard. The voting power of an elected BLS key in a committee is the metrics used to measure the key’s weight in the consensus voting process. The total voting power of a shard committee is always 1.0 (or 100%). The consensus of a committee is only reached if more than 2/3 of the voting power is collected in the votes.

Each BLS key in the committee has a certain voting power proportional to the share of its effective stake among the whole committee. For example, if the sum of the effective stake of all the keys in the committee is 10k ONE, a BLS key with effective stake of 1000 ONE will have voting power 0.1 (or 10%).

Block Reward

For each of the blocks produced and confirmed within a shard, it should contain signatures from the keys with more than 2/3 of the total voting power of the shard committee. Each confirmed block will produce 28 ONE as block reward for the validators behind the committee. The 28 ONE is initially allocated to all the validators whose BLS key(s) signed on the block, proportionally to the voting power of the key(s) that signed.

The allocated block reward for a validator will be further distributed to delegators proportionally to their stake after the commission fee is charged. For example, a validator with a commission rate of 25% got allocated 4 ONE for a block it signed. The validator staked 1000 ONE itself and it has 2 delegations each with 1000 ONE. The block reward distribution for this validator works as follows:

  1. The commission fee of 1 ONE (4 ONE * 25%) is cut from the original reward and credited to the validator.
  2. The rest of the reward of 3 ONE is then distributed to all the stakers (including both the validator and its delegators) proportionally based on their stake. Since the stakers (the validator and the two delegators) each staked/delegated 1000 ONE, they each receive 1 ONE in the reward distribution.

For more information about block reward, please read our token economics model.

Double Sign Slashing

If any BLS key(s) are detected signing conflicting blocks (i.e. blocks with the same height and view ID but with different block hashes), the validator will be slashed and forever banned from the network. When a validator is slashed, a certain percentage (i.e. slashing rate) of staked tokens from the validator and its delegators will be forfeited, of which half will be burnt and another half will be credited to the reporter of the double sign event.

The slashing rate is calculated by simply summing all the voting power of the double signing keys with a minimum of 2%. For example, if 3 BLS keys with voting power of 3%, 3% and 4% double signed at the same time, 10% of all staked tokens will be slashed on the validators who hold the 3 BLS keys.

Uptime and Unavailability Penalty

The elected validators are obligated to validate blocks with their elected BLS keys. In every epoch, an elected validator should sign more than 2/3 of the signatures that its BLS keys are asked to sign.

The signing performance is represented by a percentage value called uptime. A validator’s uptime is the ratio of the number of signatures its elected BLS keys signed over the total number of signatures the keys should sign. For example, a validator has 2 elected BLS keys and each of the keys is presented 100 blocks to sign. In the final tally, the first key signed 70 blocks and the second key signed 80 blocks. Overall, the validator’s uptime is (70+80) / (100*2) = 75%.

At the end of each epoch, the validators with uptime of no more than 2/3 (66.66%) will have their status set to “Inactive” and be ruled out from the new election. For these inactive validators, they are required to manually set their status to “Active” by sending an EditValidator transaction in order to participate in future elections. We encourage validators to be proactive in maintaining a high uptime to ensure they remain elected and earn the most block reward possible.

Delegation and Reward Collection

For those wishing to participate in staking without running a validator, delegation is the best approach to still get involved and earn block rewards. Harmony ONE holders can delegate their tokens to existing validators using our staking explorer: https://staking.harmony.one/. If the tokens are delegated to an elected validator, a portion of the block reward earned by the validator will be credited to the delegator (according to section Block Reward).

The earned block rewards are stored in a separate reward balance of the delegator, which can be immediately withdrawn to the delegator’s account balance. The block rewards can also be staked again to achieve the compounding effect of staking.

Undelegation

If a delegator decides to stop delegating to a validator, he or she can choose to undelegate their tokens from the validator. After undelegation transaction is submitted, the undelegated tokens will be locked until the end of the current epoch. Note that the unlocked tokens can be used for a new delegation transaction only starting from next epoch. This means the same token can only possibly generate rewards for you starting from the epoch after next epoch.

In Conclusion

A diverse group of validators and stakers with a sufficient amount of staking is crucial for the security and decentralization of any PoS blockchains. We welcome all Harmony token holders and community members to participate in staking to support our infrastructure for a decentralized economy.


Harmony

To scale trust for billions of people and create a…

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store