. Graphene Consensus Testnet Setup | Smart Contract Development
  • Graphene Consensus

Graphene Consensus & Testnet Setup

We have been hearing a lot about EOS lately. With a four-billion-dollar ICO and numerous blockchain personnel raving about it, EOS has taken the blockchain sphere by storm. It is the brainchild of Dan Larimer, the mastermind behind various other mainstream blockchain projects such as Bitshares and Steemit. However, due to the success of these well-marketed ones, one of Dan’s project has always been shunned: Graphene.

The Blockchain community is privy to the fact that EOS, Bitshares, and Steemit would have never seen the light of day if Dan hadn’t come up with Graphene, the then most scalable blockchain. But because of a lack of documentation, the potential of this underrated gem could never be fully realized.

So, here’s a handy guide for those who wish to dive into Graphene.

For ease of understanding, the article has been split into two parts: Consensus and Testnet setup.

Consensus in Graphene

As we are aware, Bitcoin and Ethereum are based upon POW consensus mechanism where all the nodes can participate in the competition of adding blocks to the blockchain. The POW mechanism seems completely decentralized on paper, but in reality, with increasing load on the system, grows the computational power needed to mine these blocks. After a certain point, it becomes nearly impossible for a person with a desktop computer to add any value to the system. In such scenarios, only huge mining rigs and pools are able to mine and add blocks.

screencapture-etherscan-io-stat-miner-2018-07-11-14_28_18

Follow this link for latest data

From the above figure, it can be gathered that Ethereum in its current form is not completely decentralized as the three major rigs/pools contribute to more than 50% of blocks produced.

Along with centralization POW based blockchains are also facing a major backlash given the amount of power being used in the mining process. As reported by CBS, the Bitcoin network alone consumes more electricity than 159 individual countries including Ireland.

With these drawbacks, there was a growing need for a less power hungry and more decentralized consensus mechanism.

 

ENTER — The Delegated Proof of Stake Consensus (DPOS)

Graphene is based on the DPOS consensus mechanism where ‘N’ number of witnesses are selected via continuous voting by stakeholders to produce blocks, where ‘N’ is an odd number. Only these witnesses produce the blocks in their respective time slots until the next maintenance interval. After the maintenance interval, the algorithm chooses the next set of witnesses based on the voting results. It is important to understand here that only stakeholders can participate in the voting process and one stakeholder can only vote one witness.

Apart from witnesses, the stakeholders also elect delegates who have the privilege of proposing changes to the network parameters, ranging from something as simple as transaction fees to the number of elected witnesses. After a proposed change is approved by a majority of delegates, the stakeholders are given a two-week period during which they may vote out the delegates and veto the proposed changes. However, these changes to the network are not very likely to be proposed.

Thus, under DPOS it is safe to assume that the administrative authority rests in the hands of the users, just like a democracy. Although, unlike witnesses, the delegates are not compensated for retaining their positions.

 

Testnet Setup

  1. To run testnet on your local, first you have to install boost libraries in your system. You can install it using https://github.com/cryptonomex/graphene/wiki/build-ubuntu
  2. Clone the repo https://github.com/cryptonomex/graphene.git. Also, clone the sub-modules by this command
    git submodule update –init –recursive 
  3. Make the build by the following steps:
    cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=”-fpermissive” .
    Make
  4. Once the build is successful, create the genesis file:
    mkdir -p genesis
    programs/witness_node/witness_node –create-genesis-JSON genesis/my-genesis.json

Edit the genesis.json accordingly, for example, initially how much accounts should be there, maintenance interval time, ’N’ the number of witnesses, initial balances in accounts etc.

  1. Then start the witness-node with the following command depending on the number of witnesses you have initialized in my-genesis.json:-
    ./witness_node –RPC-endpoint “127.0.0.1:8090″ –enable-stale-production –genesis-JSON genesis/my-genesis.json -w \””1.6.0″\” \””1.6.1″\” \””1.6.2″\” \””1.6.3″\” \””1.6.4″\”

graphene_node_start

Congratulations on understanding the basics, now you should be having some basic knowledge of Graphene’s DPOS consensus and a running graphene tested node in your local environment.

In our next blog, we will cover further concepts like- Multinode Setup and Smart Contracts.

The following two tabs change content below.
Techracers

Techracers

Leaders in providing end-to-end blockchain solutions and services. We help businesses build revolutionary products and practices for the new era of digital economy in order to create transformational value for their customers.
July 11th, 2018|Blockchain Tutorials|