Skip to content

Ava33343/Blockchain_Testnet_Nodes_Duet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Two Winks a Charm

Blockchain Customized for Z-Bank

In this homework, an ethereum testnet is created based on the proof-of-authority (PoA) consensus algorithm.

Installments

Geth 1.9.13 with Tools

MyCrypto Wallet

Blockchain Mining

Step 1: Create a folder called twinkle with Geth package

  • One option is to use terminal and type:
    mkdir twinkle
    

Tip: You may call it anything you like.

Step 2: Generate two new nodes using

  • Open terminal or bash window
  • Move to twinkle folder
  • type command line prompts:
    ./geth account new --datadir node1
    ./geth account new --datadir node2
    
    • For simplicity, passwords for all nodes are synchronized to the same password
  • Copy the address and secret keys onto a text file

Step 3: Launch a new blockchain testnet

  • Under twinkle folder, enter the following in the terminal window:

    ./puppeth
    
  • Enter winkweb as the name for the blockchain testnet. Again, you can choose any name you want!

  • Choose 2 for Configure new genesis:

    twinkle_puppeth

  • Create new genesis from scratch by typing 1

  • For consensus structure, type in 2 to choose Clique - proof-of-authority

  • Enter the public addresses of the two nodes starting with 0x one at a time for authorized accounts to seal ethereum blocks

  • For Pre-funded accounts, copy and paste the two addresses again

  • Enter no instead of funding with 1 wei

  • The block time is set at the default time of 15s by hitting enter

  • Type in a 3-digit chain ID for MyCrypto testnet connection. It is is 357 for winkweb

Step 4: Export Network Confuration

  • Go back to the ./puppeth terminal window
  • Select 2. Manage exising genesis option
  • Choose 2 to Export genesis configurations
  • Hit enter to generate files in the same twinkle folder by default:
    • View at the terminal window: Twinkle Configuration Export

    • Folder overview: Twinkle Configuration Export

Step 5: Initialize Nodes

  • Under twinkle folder, in a terminal window:
    ./geth init winkweb.json --datadir node1
    ./geth init winkweb.json --datadir node2
    
    • --datadir flag leads to the data directory for keystore and databases

Step 6: Create a password test file

  • Create a text file called password.txt in twinkle folder

    secret password of your own choice
    

Step 7: Mining

  • Launch Node 1

    ./geth --datadir node1 --rpc --mine --minerthreads 1 --unlock "0xC49ef9067a3D523E313FCB1aAE78340ef887B83e"  --password password.txt --allow-insecure-unlock
    
    • --mine flag allows for mining
    • --minerthreads 1 tells the computer to use 1 CPU
    • --rpc flag allows MyCrypto wallet to talk to our chain
    • --unlock unlocks node 1 address using passwod text file
    • --allow-insecure-unlock resolves the http issue twinkle_node1_launch
  • Copy and paste the enode: address onto notes for node 2 mining

  • Launch Node 2

    ./geth --datadir node2 --port 30304 --mine --unlock "0x7B1051942e452b3288564F0fB594E8978077c676" --password password.txt --bootnodes "enode://d06b72dc40419de3e48ee07a66376f95563d1061f7a7aca9158e6ad73d1d5d2caddb9a5662f24d4dc66c13b35b0c5f17ffc4c4e5d2b978952b2b3a883d9f4fc0@127.0.0.1:30303"
    
    • --port flag tells the computer which port to start mining.
    • --bootnodes flag allows both nodes to be connected by passing on information of P2P discovery bootstrap from comma separated enode URLs
      • The default port is 30303 that is used by node 1
    • Note: --ipcdisable needs to be added on windows to disable IPC-RPC server and allow mining on multiple mining processes to run parallel
Launching

twinkle_node1_node2_launch

Block Seal twinkle_node1_node2_blockseal

Blocksealing continues:

twinkle_node1_node2_blockseal

Connect to MyCrypto Wallet

Step 1: Unlock the account on MyCrypto Wallet by uploading the file under keystore subfolder inside node1 folder with the password.

twinkle_winkweb

Step 2: Change Network on the bottom left-hand-side corner and input as follows:

twinkle_winkweb Note: Chain ID is set to be 357. The default URL is http://127.0.0.1:8545/.

MyCrypto Transactions

Step 1: Click on View & Send on the top left-hand-side corner below MyCrypto Icon, enter node2 address as the recipient, confirm the amount and transaction fee.

twinkle_winkweb

Step 2: Check status by entering the transaction hash.

transaction_checkstatus

High five!

Challenge

To add another bootnode onto twinkle network to connect all three for a new colleague, we use port 30305 and connect node3 to node1 by:

Step 1: Create a new node, node3
./geth account new --datadir node3
Step 2: Initialize node3
./geth init winkweb.json --datadir node3
Step 3: Launch node3 mining
./geth --datadir node3 --port 30305 --mine --unlock "0x1c3a8EcC422ea95aFbe09E8c0e0553f7f163B830" --password password.txt --bootnodes "enode://d06b72dc40419de3e48ee07a66376f95563d1061f7a7aca9158e6ad73d1d5d2caddb9a5662f24d4dc66c13b35b0c5f17ffc4c4e5d2b978952b2b3a883d9f4fc0@127.0.0.1:30303"

However, an error for "unauthorized signer" was preventing the mining:

Details on warning message "Block sealing failed":

node3_althenticity_failed

The following attempt was made to change the blockchain network settings via `puppeth`. However, mining did not occur. See details below:

node3_alters

In order to clear up the preceding processes, the following command line prompt was entered under the same folder:

rm -Rf node1/geth node2/geth node3/geth

A new folder twinkles was created with three nodes as authorized sealers and their addresses to be pre-funded under ./puppeth. The three nodes are running on port 30303, 30304 and 30305 respectively.

The three nodes were initialized as follows:

node3_twinkles_launch

The mining party starts after 11pm on a Saturday!

twinkles_blockseal

Blockseal static image:

twinkles_blockseal

Send 567 ETH from node1 to node3 on winksplus network. Whoo-hoo!

twinkles_transaction

Note: The folder for node3 is based on node3 created under twinkles folder for proof-of-authority blockchain testnet winksplus. For details, please refer to logs in Nodes folder.

Cheers!


Files

Code

Nodes

Images

References:

Releases

No releases published

Packages

No packages published