Definitions

PoS Consensus - Proof Of Stake  - A family of blockchain consensus protocols.  https://en.wikipedia.org/wiki/Proof-of-stake

GHOST Protocol - 'Greedy Heaviest Observed SubTree'.  https://github.com/ethereum/wiki/wiki/White-Paper#modified-ghost-implementation

Background

Talk about Proof of work, investment, mining and nonces.  

In order to participate in the protocol as a validator, a bond must be provided.  This bond replaces the financial penalties associated with cheating in the traditional Proof of Work consensus model employed by Bitcoin.  It also replaces the infrastructure investment, in that since work is not needed to propose a block, large amounts of compute are similarly no longer required.


Actors

Bonded Validator: 

A client that has provided a bond in the form of tokens.  Initially (Mercury timeframe) the only staking token that will be supported is the Rev token.  In the future, additional tokens may be supported in specific namespaces/regions or shards.

Unbonded Validator:

A client that was previously a bonded validator that has requested to leave the validator set and is waiting to reclaim their stake.  During this time, the client can no longer propose blocks or be paid fees.  They can, however, be slashed if previous block proposals include slashable offenses, and cryptographic evidence is provided to that effect by another validator or watcher.

Requirements:

The Consensus protocol has to do the following:

The Consensus protocol should also support the following:

The Proof of Stake Contract

Proof-of-stake in RChain will be handled by the PoS "blessed" contract within the RChain state. Since all validators must know about each other, this contract will live in the top level namespace (see Powerset shards - sharding solution is still TBD).  The root namespace will store the validator set and their bonds and derive the individual validator weights from that information. 

This contract will perform the following functions:

Additionally, each shard will have a local version of the PoS blessed contract which performs the following functions:

Bonding Process

A prospective validator will make a bonding request via the bonding API call to a validator in a shard requesting to join the validator group.  The bonding request has to contain the following parameters:

When the bonding request is approved the following happens:

If the bonding request is not approved:

Reasons for rejecting a bonding request:

Unbonding

Unbonding is triggered when the PoS contract is invoked (again in the normal way) with the signature of an existing validator along with a return channel. On the return channel, an unforgeable name is sent, which the now ex-validator can listen on. After the post-unbonding stake holding time has elapsed, a purse containing the ex-validaor's stake is sent on that name, thus allowing the validator to recover their bond. The unbonding is successful so long as it does not exceed the unbonding rate specified for the region.

Unbonding Wait Period

During this time the validator is not active.  The validator cannot propose blocks, nor receive rewards.  The stake is held by the PoS contract, and the validator can be slashed by other validators.  The other validators are not aware that the validator has requested to unbond.  The unbonding request is held by the PoS contract in the shard.   Note that no rewards are distributed at this time, only the exact original stake (minus any slashed amount) is returned. Unpaid rewards can be withdrawn from the shard's local PoS contract after unbonding has occurred (see below). 

The purpose of this wait time is to prevent a variant of the "long range attack" (reference Details of Proof-of-Stake in RChain )


Slashing

Slashing is triggered when the PoS contract is invoked with the following arguments:

Only validators can slash and the slashed bond is distributed equally among all remaining validators. If the evidence is invalid then the block that includes the invalid slashing transaction is considered invalid, eventually leading to the accusers bond to be deducted instead. If a validator's stake drops to 0 then they are automatically unbonded. The following are slashable offences:

Notification of Slash

A validator that has been slashed will be notified that he has been slashed, what the offence was (SLA, equivocation, invalid block).

Slashing amounts

Slashing API

Authored by Former user (Deleted)

This details the slashing API for the proof of stake contract. Each bullet will become an API endpoint where the arguments will be the blocks that are asked of. If the same block can be slashed for multiple reasons, use the ordering of the following list to determine precedence.

Ejection

A basic ejection criteria that addresses the 'lazy' validator or 'underperforming' validator is required, in order to ensure the security of the network.  At some random interval, one of the validators in the set proposes an invalid block.  Which validator needs to also be randomized.  The invalid block is a challenge to one of the other validators in the set.  Which validator is challenged is also randomized.  The validator presenting the challenge also holds an associated 'coupon' that can be redeemed against a slash. The coupon is only good for the slashing event associated with that particular challenge block.  There are one of 3 possible outcomes from the challenge:

The kinds of invalid blocks need to be determined.  The invalidity of the block must be subtle, and should only present itself when the validator attempts to update its state (run the contents of the block).  What is injected into the block has to be something that can be created programmatically, that is more expensive to detect outside of validating the block.

Rewards Distribution

Rewards distribution is handled by a local PoS contract. Fees will accrue within the PoS contract or a purse controlled by the PoS contract.  At a random interval, the PoS contract will divide the fees by the number of validators in the shard and distributes the fees to the validator set. 

Rewards will accrue until the validator withdraws their rewards. 

The validator can withdraw their rewards from the local PoS contract by calling the contract with the following information:

Reference: RChain Validator Economics

Minting

The blessed Rev mint contract can only exist in a single namespace.  If the mint exists at the root namespace, it will exist in the same namespace where all the staking, sharding and validator information for the network is stored.  Can the Rev mint contract mint Rev and distribute the Rev to PoS contracts in shards for distribution as validator rewards?  Rev' Tokens in the shards would be considered as 'backed by Rev' much in the same way as a currency is backed by gold.  

Reference: RChain Validator Economics

The rate at which this Rev is minted by the blessed Rev Contract:Reference: RChain Validator Economics

How PoS contracts in a shard distribute Rev rewards (separate from transaction fees) :Reference: Shards in RChain

GHOST Protocol

There are 2 stages to the protocol: Scoring and Traversal

Scoring:

The validator weight is tied to the validator's bond amount.  The validator weight is assigned by the PoS contract running in the root shard, and is determined by the validators' bond in relation to the total bond staked in the network.  These validator weights will change as validators bond and unbond from the network.

When a validator places a bet on a block, the validator's weight is added to the block' score. 

Justifications:

Justifications are the validator's reasons why a block is included or not included as part of the fork-choice-rule.  In essence a validator says 'I'm betting on this proposed block because it has the most weight' or 'I'm NOT betting on this proposed block because this other block has more weight'.  Justifications are part of the block data, and this is how a block makes its way to finalization.  

Scoring in action:  

To see multiple blocks and the progression of scoring, reference the Consensus presentation here: https://docs.google.com/presentation/d/1znz01SF1ljriPzbMoFV0J127ryPglUYLFyhvsb-ftQk/edit#slide=id.g36e6995ef0_2_28

Transaction confirmation

Current day practice with bitcoin and other PoW coins is to wait for 6 blocks to be added to the chain after the transaction has been proposed within a block.  This means that the transaction confirmation time is actually 6X the block creation time.  This isn't acceptable as a go forward plan for the RChain blockchain.  There needs to be some mechanism that can provide fault tolerance information and finalization information for a given block.  Furthermore,  if blocks are being created at different rates in different shards, it makes it hard for industries to obtain a sense for how long transaction finalization will take.  Exchanges and users will need to know transaction confirmation status, how confident they can be in a transaction's 'finality' and some estimation of transaction confirmation times.

Races:

The system will race to quiescence.  


Tickets