#Parity #Docker #Ethstats

This part demonstrates the use of parity framework to setup a proof of authority (POA) based Blockchain.

We have basically used https://github.com/Arsalen/poa-parity-ethstats to build the Blockchain.

The project mentioned above consists of a set of parity configuration files to customize the network, bash scripts to automate the process and a keygen script to generate the crypto materials for each node.

It also provides the option to start an ethstats monitoring instance that can be connected through the browser.

Command:

bash parity-deploy.sh — config aura — nodes 7

Steps:

1- The Blockchain administrator introduces the parameters of the network.

2- The program builds the genesis block, parity configurations and docker-compose file based on these parameters.

a- Create nodes and their keys (pub.key, priv.key, password)

b- Create enodes for the genesis block.

c- Create authority.toml for parity configuration.

d- Create docker-compose.yml to launch the containers.

e- Create one member node (client.toml and client.yml)

3- The program finally build the genesis.json file based on the configurations above and a set of default parameters.

Once the command is launched, a docker-compose.yml and a new directory named deployment/ are generated, the later is contains several sub-directories (one per node) containing informations revolving its associated node and a genesis.json for the Blockchain.

Command:

docker-compose up

Instantiates containers each running a parity node indexing the same genesis block.

Each container is triggered out of a parity/parity:beta image, a light EVM and WASM Blockchain client, comprised of the dependencies of the framework, authority.toml, password, enodes, genesis.json and other data revolving the underlying node.

Command:

curl — data ‘{“jsonrpc”:”2.0",”method”:”personal_sendTransaction”,”params”:[{“from”:”0xsource”,”to”:”0xdestination”,”value”:”0x0"}, “password”],”id”:0}’ -H “Content-Type: application/json” -X POST localhost:8545

was used to test the connectivity of the Blockchain over rpc.

Command:

parity — chain /parity/genesis.json — config /parity/authority.toml -d /parity/data

is the entrypoint of each container.

A secp256k1 private and public keys for each node are generated based on openssl toolkit, a general purpose cryptography library.

We are currently working on the ethstats container as it sounds like it doesn’t detect neither all the instances set by the administrator nor the transactions submitted via rpc.

Update: The problem was the fact that app.json to include within eth-net-intelligence-api docker instance in order to connect eth-netstats instance with the blockchain doesn’t update itself depending on the number of nodes. Only 7 instances can be launched due to a problem of synchronization between containers.

We needed to configure authority.toml in order to connect to parity-ui: [ui] force = true disable = false port = 8180 interface = “all”, then we opened another terminal to run:

Command:

parity-ui — chain deployment/chain/spec.json

Parity will automatically connect to host1 which is running on localhost:8545.

We have pre-funded sealers so they can deploy contracts and send transactions.

Using parity-ui we have deployed a simple hello world smart contract

https://raw.githubusercontent.com/web3j/web3j/master/codegen/src/test/resources/solidity/greeter/Greeter.sol

and invoked Greeter.kill() method.

The transaction is confirmed after 6 blocks.

#Geth #Shell #Ethstats

You will find the full project in this repo.

In this part, we will proceed with a step-by-step tutorial of POA project https://github.com/Arsalen/POA which builds a Proof of autority based network using Geth, connects to ethstats and test the network with a flood of transactions.

Before we start, let’s sweep over its content: The project is comprised of 3 subdirectories:

1- Eth-build-network: Mainly contains bash scripts to automate the process of build and synchronize nodes, create accounts, set up the genesis block, also contains default network configurations.

2- Eth-netstats: A front-end implementation for eth-net-intelligence-api, provides a visual interface for tracking ethereum network status. It uses WebSockets to receive stats from running nodes and output them through an angular interface.

3- Eth-net-intelligence-api: This is the backend service which runs along with ethereum and tracks the network status, fetches information through JSON-RPC and connects through WebSockets to eth-netstats to feed information.

After cloning the project in your local repository, run:

Commands:

cd POA/eth-build-network

Bash blockchain 9

The command above will basically set up a private network with 9 nodes:

1- Create a default genesis.json.

2- Create nodes and accounts.

3- Edit genesis.json: Add nodes as sealers and pre-fund accounts

4- Initialize genesis block.

5- Synchronize nodes.

Now as the blockchain is ready, in order to display its state, let’s run eth-netstats, open another terminal and execute:

Command:

bash ethstats 9

This will issue the command npm start from eth-netstats directory and launch a node server to monitor your blockchain, for the moment the server is not connected to the blockchain, however, we need eth-net-intelligence-api as a middleware to connect both layers, through app.json which contains the nodes’ RPC and blockchain interfaces, WS_SECRET token and websocket server url to connect to, and other default parameters, then pm2 start app.json to manage the nodes’ processes in the background.

Finally command:

Bash clean

Will clean the network: Delete genesis.json, nodes’ data, app.json, stop pm2 and shutdown websocket server.

Determined, passionate and hardworking individual with unyielding self motivation, highly driven and well-versed in open source technologies.

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