C 341: Making a Node on the Kovan PoA Testnet (30 pts.)

What You Need

Purpose

To learn how Ethereum works and set up a node on a public testnet.

Installing parity

There are two main software packages used to make Ethereum nodes: Parity and Geth.

In this project, we'll use Parity. Note: Parity is no longer being developed, so people are migrating to geth. We'll use geth in the next project.

On your Linux machine, in a Terminal window, execute these commands, one at a time. Enter your password when you are prompted to, and approve the installation when you are prompted to.

sudo apt update
sudo apt install snapd
sudo snap install core
sudo snap install parity
/snap/bin/parity --version
Now execute this command to start your node on the Kovan testnet:
/snap/bin/parity --chain=kovan
As shown below, it shows you where the blockchain data will be stored locally and shows a long series of "Syncing" messages.

Sending an RPC Command

One easy way to interact with the blockchain is to use the RPC, sending network requests to the loopback address.

Open another Terminal window.

In the new window, execute this command:


curl -H "Content-Type: application/json" -X POST \
--data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' \
http://localhost:8545
This shows you the version of Parity you are using, as shown below.

Watching the Syncing Process

In the new window, execute this command:

curl -H "Content-Type: application/json" -X POST \
--data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":67}' \
http://localhost:8545
This shows you currentBlock and the highestBlock. Repeat the command a second time.

In the image below, I found these values:


"currentBlock":"0x127e087","highestBlock":"0x17a40cd"
"currentBlock":"0x127f1b2","highestBlock":"0x17a40d2"
So in the time between my two commands, the currentBlock increased by more than 0x1000, and the highestBlock increased by 5. My node is rapidly processing the blocks, and the blockchain is also growing slowly.

Viewing a Recent Block

Execute this command, replacing the block number 0x127f1b2 with the largest current block number you found with the previous command:

curl  -H "Content-Type: application/json" -X POST \
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x127f1b2", true],"id":1}' \
http://localhost:8545
The reply shows many details about that block. Note these items, highlighted in the image below:

C 341.1: Viewing Block 0x1270222 (15 pts)

Execute this command:

curl  -H "Content-Type: application/json" -X POST \
--data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1270222", true],"id":1}' \
http://localhost:8545
The flag is covered by a green rectangle in the image below.

If you see this message: "Requested block number is in a range that is not available yet, because the ancient block sync is still in progress." please notify your instructor, who will need to update this flag.

C 341.2: Syncing (15 pts)

To see the syncing status, execute this command:

curl -H "Content-Type: application/json" -X POST \
--data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":67}' \
http://localhost:8545
As shown below, you see "currentBlock" and "highestBlock" values.

Let your node finish syncing, which will take some time.

When I did it on May 11-12, 2021, it took 19 hours. The storage space consumed was about 50 GB.

When your node is done syncing, the reply to the eth_syncing method will be different. The new result is the flag, covered by a green rectangle in the image below.

Other JSON-RPC Commands

The complete list of JSON-RPC commands are here:

JSON RPC API

Sources

Ethereum Testnets: What Are They and Why So Many?


Posted 5-12-2021 by Sam Bowne