Monday, March 13, 2017

Ethereum BlockChain : Setting up the Ethereum blockchain private multi node/miner network locally on windows

I assume readers have basic understanding of Ethereum blockchain, below setup is done using Geth implementation on windows with multi transaction nodes and multi miner nodes. I'm not covering how to do the transactions , setup accounts, web3 communication, Dapp etc.

Prerequisite:

  • Download & install the Geth command line tool from Ethereum website, depending on your OS download x64 or x86 version, mismatch in OS and installed version will fail the ethereum private setup.
  • Create below folder structure for two miner and two transaction nodes 
    • /Miner1/data
    • /Miner2/data
    • /TxNode1/data
    • /TxNode2/data
  • Copy the geth.exe from installed location "C:\Program Files (x86)\Geth" and place it under all the root folder  Miner1, Miner2, TxNode1, TxNode2.
  • Create file name genesis.json ( file name can be anything) , this file will contain information for genesis block. Genesis block is the first block in the blockchain, It is a special case in that it does not reference a previous block.  Copy below content to the genesis.json file and save this file under each Root folders
{
"nonce": "0xdeadbeefdeadbeef",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x686f727365",
"gasLimit": "0x8000000",
"difficulty": "0x0400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc": {
}
}
}

Setup:
  • Open four command prompt and navigate to individual root folder path .. Miner1Miner2TxNode1TxNode2.
Note: Miner generates the DAG file under Ethash folder which is shared per user on windows account, so running two miners crashes setup. To resolve this issue create one user account on windows locally and run the Miner2 command prompt using newly created account.
  • Run below command to initialize the genesis block on each node
                  geth --datadir="./data" init genesis.json

  • Now, run below command to start the transaction nodes on TxNode1 TxNode2 command prompt
          TxNode1:
         geth --identity TxNode1 --datadir ./data --networkid 12345 --maxpeers 2 --nodiscover --ipcdisable  --rpc --rpccorsdomain "*" --rpcapi "eth,web3,personal,net,miner,admin,debug" --rpcaddr 127.0.0.1 --rpcport 30002 --port 8082 --verbosity 3 console


          TxNode2:
         geth --identity TxNode2 --datadir ./data --networkid 12345 --maxpeers 2 --nodiscover --ipcdisable  --rpc --rpccorsdomain "*" --rpcapi "eth,web3,personal,net,miner,admin,debug" --rpcaddr 127.0.0.1 --rpcport 30003 --port 8083 --verbosity 3 console

         ..More information on command line option can be found here.

  • Now, run the below command to start the miner node on Miner1 & Miner2 command prompt

          Miner1:
          geth --mine --minerthreads 1 --etherbase "0xbfdd59a05f94139e719b52e4e2d2db4b6fa689ad" --gasprice 1000000 --gpomin 1000000 --gpomax 1000000 --identity "Miner1" --datadir ./data --networkid 12345 --maxpeers 4 --nodiscover --ipcdisable --rpc --rpcaddr 127.0.0.1 --rpcport 30001 --port 8081 --verbosity 4 console

          Miner2:
          geth --mine --minerthreads 1 --etherbase "0xbfdd59a05f94139e719b52e4e2d2db4b6fa689ad" --gasprice 1000000 --gpomin 1000000 --gpomax 1000000 --identity "Miner2" --datadir ./data --networkid 12345 --maxpeers 4 --nodiscover --ipcdisable --rpc --rpcaddr 127.0.0.1 --rpcport 30004 --port 8084 --verbosity 4 console

At this point you have setup two transaction nodes and two miner nodes successfully. Now, we have to make them talk & sync data to each other.

Sync setup:

Above setup of nodes is done using --nodiscovery , this will disable discovery of your nodes to other nodes in network, this is to ensure we don't attract network traffic. Hence the reason we need to add the node manually using admin.addPeer() API.

TxNode1<=> TxNode2   (Node to Node communication)
  • Run command below on TxNode2 command prompt 
          admin.nodeInfo.enode

        copy the output node URL like  "enode://a6af24d2ee2d524c1d6e73....." and form below API               command and run on TxNode1 command prompt.

Ex.
        admin.addPeer("enode://a6af24d2ee2d524c1d...")

        To test if nodes are connected, run "net" command which should have peers property equals to 1.


Miner1 <=> Miner2   (Miner to Miner communication)

  • Run command below on Miner2 command prompt 
          admin.nodeInfo.enode

         copy the output node URL like  "enode://a6af24d2ee2d524c1d6e73....." and form below API              command and run on Miner1 command prompt.

Ex.
        admin.addPeer("enode://a6af24d2ee2d524c1d...")

        To test if nodes are connected, run "net" command which should have peers property equals to 1.
       
Now make aware nodes about miner nodes...

  • Run command below on Miner1 command prompt 
          admin.nodeInfo.enode


  • Run command below on Miner2 command prompt 
          admin.nodeInfo.enode


copy the output node URL's from above and form below API  command and run on TxNode1 & TxNode2 command prompt.

Ex.
        admin.addPeer("enode://a6af24d2ee2d524c1d...")
        admin.addPeer("enode://e8c0935450f44910f1...")

Testing peer connection:

Run  "net.peerCount" command in each respective command prompt and see the peer count , should be equal to 3, this ensures all the setup is up and running.

29 comments:

  1. Mahesh, Thanks for the article. I am still not able to figure out why 2 miners are needed? Why not one miner? Actually even before that, why miners are needed here?

    ReplyDelete
  2. In Blockchain miners are the one who approves your transaction by solving proof of work and attaches the block to the chain. Concept of approval of transactions is key for Blockchain technology emerging from traditional approach. Please have a understanding of Blockchain before you start with Ethereum, else it's difficult to catch ethereum concepts.

    ReplyDelete
  3. Hi Mahesh, I have setup a private network with 4 nodes on single network. Started two nodes as miners. Now I want to initiatw a transaction between two non miner nodes. Please share the procedure to accomplish it.

    ReplyDelete
  4. As cryptocurrencies are quite expensive, it is not a good idea to take risks and fall into fraud. After all,https://www.jetwin.com/en-us/bitcoin-casino you do not want to lose your hard earned money in a second.

    ReplyDelete
  5. This is the very first step when buying bitcoins since you will require a place to store, receive https://bitcoinvest.cc

    ReplyDelete
  6. Remember that you are not here to be part of the sport of spectators, you are winning.bitcoin games online And a community of people who want to invest in their motto is the best way to do it!

    ReplyDelete
  7. Thanks for the blog filled with so many information. Stopping by your blog helped me to get what I was looking for. Now my task has become as easy as ABC. blockchain jobs

    ReplyDelete
  8. The truth however, is that it might be past the point of no return in the diversion to profit from Bitcoin mining.https://www.jetwin.com/en-us/bitcoin-casino

    ReplyDelete
  9. Is there anybody who can refer me a guide to make transactions between transaction nodes via Miner node, say a message/text to transmit.

    ReplyDelete
  10. i liked your post very much and i will share it my friends also Blockchain Online course Bangalore

    ReplyDelete
  11. Developer groups are unstable and often not very reliable. Their expertise is difficult to verify since the quality varies from one individual developer to the next.Database Diagram Tool

    ReplyDelete
  12. You will likewise have the capacity to make the same number of addresses as you like, so in the event that you need to follow where the cash is coming from,Cashout CVV tutorial you could have an independently marked location from every single one of your payees.

    ReplyDelete
  13. Regardless of your bitcoin encryption key factor is printed out, you'll be encouraged to go into it. coin mixers

    ReplyDelete
  14. I went over this site and I trust you have a ton of awesome data, spared to my bookmarks artists contracts

    ReplyDelete
  15. I really like your take on the issue. I now have a clear idea on what this matter is all about.. smart contracts

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. Along these lines, GPUs of giant power combined with top of the line RAMs and solid hard circle drives need to do all the assignment. iqmining review

    ReplyDelete
  18. On the off chance that deny the relational word "communist" in the meaning of finances, we may state, that despite everything it keeps reality. 300 euros to dollars

    ReplyDelete
  19. Not at all like a customary business where exchanges require support and confirmation, blockchain does not require any focal verification or friend proposal.read this article

    ReplyDelete
  20. As individuals around the globe get more tired of incredible bank benefits and bank overextend into their lives, there is trust that customers will be respected with deference and not be perpetually saddled with staggering expenses and ridiculous limitations. get free bitcoin

    ReplyDelete
  21. Conversion services often ask for a fee. Usually there is a flat fee if how highly you exchange, and often the conversion service charges a segment of the sum you exchange.https://cryptalker.com/trading-bot/

    ReplyDelete
  22. Bitcoin is a distributed installment framework, also called electronic cash or virtual money. It offers a twenty-first century option in contrast to physical banking. bitcoin code

    ReplyDelete
  23. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. mcb car financing - meezan bank car installment

    ReplyDelete
  24. A large portion of these converters are anything but difficult to utilize and list all the world's monetary forms. convert money online

    ReplyDelete
  25. Learning the systems and venture strategies from the diagrams and graphs given by the online dealer locales help immensely in making the potential financial specialists experienced in the field of Forex exchanging.
    Australian brokers forex

    ReplyDelete
  26. Hire Flutter Developer is one of the most popular in the cross platforms industry. We build excellent flutter mobile app and also learn how to overcome performance issues. is the best choice for all startups to discuss and get their project quotation. We also enable many startups to do Proof of concept and help them to learn about business decisions.

    ReplyDelete
  27. Crossplatform app development is challenging nowadays. many tools like a flutter and react-native are doing work really awesome. App development in Austin in cross-platform also have challenges like performance and network issue.

    ReplyDelete
  28. Once encoded, the exchange is changed over to something many refer to as a square, which is essentially the term utilized for a scrambled gathering of new exchanges. How A Blockchain Works

    ReplyDelete