Creating a private Quorum network on Raspberry Pi

Ahmad Saeed
5 min readJan 15, 2021

--

Working with cutting-edge tech is exciting but sometimes it can become a cumbersome task when getting started with it. Recently, I got my hands on a bunch of Raspberry pi’s for a research project of my own and I was trying to setup a network using a lightweight consensus blockchain. (PS: I had my eyes on Quorum for soo long and really wanted to put it to work)

Talking a bit more about microprocessors and blockchain, we have to acknowledge that we have been through a decade of blockchain development and innovation. Every day we find new solutions that are more secure, robust, and efficient. We need to add more to it, exploring more blockchain applications out there so that people can get inspiration to innovate. We have now less computationally expensive distributed algorithms and many powerful microprocessors. Now is the best time to put out some applications of it.

For this project, I used 3 raspberry pi’s (Raspberry pi 3 Model B) and a laptop running Ubuntu 16.04 (for some reason I had to use a laptop which I’ll explain later). Let’s get started!

Quorum on Laptop:

Before installing it on our raspberry pi’s we need to get one node working on our laptop (Don’t worry this will help us later in the process). For installing a node on your laptop, you can use the official Quorum docs from here.

Quorum on Raspberry Pi:

First clone the Quorum directory from github and make its build. The building process can take a very long time on Raspberry Pi (In some cases you might not be able to make a build on a raspberry pi, due to a limited amount of memory and CPU power), I recommend using a laptop to perform the following tasks and zip the folder and paste it on your raspberry pi.

$ git clone https://github.com/jpmorganchase/quorum.git
$ cd quorum
$ make geth-linux-arm-7

NOTE: Previously, there was no way to directly use Geth binaries on ARM-based chips like Raspberry Pi (You had to cross-compile it) but luckily now all the instructions have been added in the makefile and now you can cross-build via make geth-<os>-<platform> without needing to know any of these details.

Type the following in your terminal in order to let the Operating system know where is your quorum installed. This will let the shell terminal be aware of geth-linux-arm-7 path.

$ export PATH=$(pwd)/quorum/build/bin:$PATH

To proceed further make some separate folders for some organization.

$ mkdir fromscratch$ cd fromscratch$ mkdir new-node

Now, make a new account:

$ geth-linux-arm-7 --datadir new-node account new

Every node in the Quorum network has an enode id. It is a way to describe a node in the form of a URL, so that other nodes can recognize it and connect with it. We already have a running node on our Laptop, so we can have its enode id to connect our Raspberry Pi with it (You must be wondering why can’t we just have another Raspberry Pi and get its enode and connect them together. You are right, but node key generation method doesn’t simply work on a raspberry pi as it is a different architecture chip and some commands don’t work directly on it. But we can still generate it with other methods but it is much easier to get a laptop in the network and find the enode of the raspberry pi node)

We had created a static-nodes.json file while deploying a node on our laptop. Copy that file and paste it in the fromscratch and new-node folder on your Raspberry Pi. Here is how my static-nodes.json file looks like:

[
"enode://1e64506cbbccaf5504f6626bec5e93495eabae8069782b077b72014b826f31264c8c9ef25400884c7a7c36f25af1d1e09a7af0dd1f05c67b8d22161054c4993b@192.168.1.135:21000?discport=0&raftport=50000"
]

192.168.1.135 is the IP address (HostName) of my laptop, 50000 is my raft port and 21000 is my p2pPort and “1e64506cbbccaf5504f6626bec5e93495eabae8069782b077b72014b826f31264c8c9ef25400884c7a7c36f25af1d1e09a7af0dd1f05c67b8d22161054c4993b” is my node id.

Now let’s Initialize geth on our Raspberry pi.

Important: In order to initialize geth, use the same genesis.json used for running the node on your laptop and then use the following command.

$ geth-linux-arm-7 --datadir new-node init genesis.json

Generate a start node script, similar to the node on your laptop but with the following command. Make a startnode.sh file and paste the following command in it.

#!/bin/bashPRIVATE_CONFIG=ignore nohup geth-linux-arm-7 --datadir new-node --nodiscover --verbosity 5 --networkid 31337 --raft --raftport 50000 --raftjoinexisting 2 --rpc --rpcaddr 0.0.0.0 --rpcport 22000 --rpccorsdomain "*" --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,raft --emitcheckpoints --port 21000 2>>node2.log &

Run the script.

$ chmod +x startnode.sh
$ ./startnode.sh

Attach to the geth node

$ geth-linux-arm-7 attach new-node/geth.ipc

In the geth console, get the enode id for this node by running:

> admin.nodeInfo.enode[
"enode://1b338092d5f454838f2b44f80a48c1cce53201c9898476e6bd9e1c2b93688a77106650c761b9bd1fa261e4966da85c63c890662a2103e407a580c774b6f6a1df7@192.168.1.146:21000?discport=0&raftport=50000"
]

In some cases, you might not get the “&raftport=50000” at the end so you can add it by yourself. Now we have our enode id of our first Raspberry pi we can use our geth terminal on our laptop and add it to the network.

> raft.addPeer("enode://b338092d5f454838f2b44f80a48c1cce53201c9898476e6bd9e1c2b93688a77106650c761b9bd1fa261e4966da85c63c890662a2103e407a580c774b6f6a1df7@192.168.1.146:21001?discport=0&raftport=50001")2

2 is the result returned and it represents the raftId number of the node in the network. In order to find the complete network cluster do the following:

> raft.cluster[{
hostname: "192.168.1.146",
nodeId: "b338092d5f454838f2b44f80a48c1cce53201c9898476e6bd9e1c2b93688a77106650c761b9bd1fa261e4966da85c63c890662a2103e407a580c774b6f6a1df7",
p2pPort: 21001,
raftId: 2,
raftPort: 50001,
role: "verifier"
}, {
hostname: "192.168.1.135",
nodeId: "1e64506cbbccaf5504f6626bec5e93495eabae8069782b077b72014b826f31264c8c9ef25400884c7a7c36f25af1d1e09a7af0dd1f05c67b8d22161054c4993b",
p2pPort: 21000,
raftId: 1,
raftPort: 50000,
role: "minter"
}]

You can find both your nodes connected here with each other.

CONGRATULATIONS!

Now you can add as many raspberry pi’s you want to your network using the same procedure.

Execute a Transaction:

You need to find your wallet address to which you have assigned some initial balance in the genesis file. You can find your attached wallet address in geth from the following command:

> eth.accounts

The basic way of sending a simple transaction of ether with the geth console is as follows:

> eth.sendTransaction({from:sender, to:receiver, value: amount})

Example:

eth.sendTransaction({from:eth.accounts[0], to:”0x1ce34b5b3e00f57e3a4c6c2e8083cae71cd1306d”, value: 200000000});

To check your balance you can do the following:

web3.fromWei(eth.getBalance(eth.coinbase), "ether")

Future Announcements:

In this article, we followed instructions to setup a simple Quorum network on 2 Raspberry Pi’s. Next, I will be adding some smart contracts to build some meaningful applications. Also, there will an article on Quorum bugs/issues and troubleshooting the network problems.

Stay Tuned! Do give your feedback.

--

--

Ahmad Saeed
Ahmad Saeed

Written by Ahmad Saeed

Blockchain Lead @AWSt | Web3 architect | Tech Advocate | Algorithms | Music & Art

No responses yet