• Articles
  • Tutorials
  • Interview Questions

Building Quorum Blockchain using Docker in Google Cloud Shell

Building Quorum Blockchain using Docker in Google Cloud Shell

In this blog, we’ll guide you through setting up a Quorum blockchain network using Docker in Google Cloud Shell. Docker simplifies node deployment and management, while Google Cloud Shell provides a convenient cloud-based development environment. Let’s explore the step-by-step process of building a Quorum blockchain with Docker in Google Cloud Shell.

Table of Contents

Watch this Blockchain video to learn the concepts of blockchain:

Video Thumbnail

Understanding Quorum Blockchain

Quorum Blockchain is a version of Ethereum that has gained popularity for its enhanced privacy and scalability features. It retains the key characteristics of Ethereum while introducing modifications to cater to enterprise requirements. To build a Quorum network successfully, it’s important to have a solid understanding of its basics.

Quorum Key Features:

  • Permissioned Network: Quorum Blockchain allows participants to join the network only with permission, ensuring controlled access.
  • Enhanced Privacy: Quorum offers essential privacy features like private transactions and private contracts that play a crucial role in handling sensitive data.
  • Improved Scalability: Quorum utilizes various techniques, such as parallel transaction processing and increased block size, to enhance scalability compared to the public Ethereum network.
  • Consensus Mechanisms: Quorum supports multiple consensus mechanisms, including QuorumChain and Istanbul BFT, to achieve consensus among network participants.

Differences from Ethereum:

Although Quorum is based on Ethereum, it introduces several modifications to meet enterprise requirements:

  • Privacy: Quorum offers advanced privacy features, such as private transactions and private contracts, which Ethereum lacks.
  • Consensus Mechanisms: Quorum incorporates consensus mechanisms like Istanbul BFT that are not present in Ethereum.
  • Permissioned Network: Quorum is designed as a permissioned network while Ethereum operates as a permissionless network.

Understanding these fundamental aspects of Quorum Blockchain will pave the way for successful network configuration and deployment.

Need for Quorum Blockchain

Quorum Blockchain addresses specific requirements and use cases that make it an ideal choice for various applications across industries. Let’s explore the need for Quorum and its benefits in different sectors:

  • Finance: In the financial industry, confidentiality is crucial. Quorum’s privacy features enable financial institutions to conduct secure transactions while adhering to regulatory compliance. Additionally, Quorum’s scalability supports high transaction volumes and faster settlement times.
  • Supply Chain: Supply chain management often involves multiple stakeholders who need to securely exchange data. Quorum’s privacy and permissioned network provide a suitable platform for secure data sharing, ensuring transparency among authorized participants.
  • Healthcare: Protecting patient data privacy is vital in healthcare. Quorum’s privacy features enable secure storage and sharing of sensitive medical records, ensuring confidentiality while allowing authorized access by healthcare providers.
  • Voting Systems: Transparent and tamper-proof voting systems are critical for fair elections. Quorum’s consensus mechanisms and privacy features provide a secure platform for building trustworthy voting systems, ensuring accurate and confidential voting processes.

Understanding the specific needs of each industry will help organizations leverage the benefits of Quorum Blockchain in their respective domains. Now that we have a better understanding of the topic, we can proceed to set up Google Cloud Shell and install Docker to build a Quorum network effectively.

Setting Up Google Cloud Shell

Google Cloud Shell is an influential utility that offers an interactive shell environment to effectively manage cloud assets. To commence the process of constructing a Quorum Blockchain network, adhere to the subsequent instructions for configuring Google Cloud Shell.

Step 1: Open the Google Cloud Console: Visit the Google Cloud Console (console.cloud.google.com) and log in to your Google account.
Step 2: Enable Google Cloud Shell: In the Cloud Console, click on the Google Cloud Shell icon located at the top right corner of the interface. This will launch the Cloud Shell environment.
Step 3: Wait for initialization: The first time you launch Cloud Shell, it may take a few moments for initialization. Once it’s ready, you will see a command-line interface within the Cloud Shell window.
Step 4: Verify access and resources: In Cloud Shell, you have access to a virtual machine instance with pre-installed tools and resources. To verify your access and available resources, you can execute simple commands like ls (list files) or gcloud version (to check the Google Cloud SDK version).

With Google Cloud Shell set up, you now have an interactive environment ready to proceed with the next steps.

Installing Docker in Google Cloud Shell

Docker is a popular containerization platform that simplifies the process of managing and deploying applications. By installing Docker in Google Cloud Shell, we can leverage its containerization capabilities to build and manage our Quorum Blockchain network efficiently. Follow these steps to install Docker:

Step 1: Update the package manager: Run the following command in the Cloud Shell to update the package manager:

sudo apt-get update

Step 2: Install Docker dependencies: Execute the following command to install the necessary dependencies for Docker:

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

Step 3: Add Docker’s official GPG key: Run the command below to add Docker’s official GPG key to the system:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Step 4: Establishing the Docker repository: Utilize the subsequent command to initialize the Docker repository.

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 5: Update the package manager (again): Run the command below to update the package manager with the newly added Docker repository:

sudo apt-get update

Step 6: Docker Installation: Ultimately, execute the subsequent command to carry out the installation process of Docker.

sudo apt-get install docker-ce docker-ce-cli containerd.io

After the installation process completes, you can verify the Docker installation by running `docker version`. If everything is set up correctly, you will see the version information.

Configuring a Quorum Network

Configuring a Quorum Network

Having installed Google Cloud Shell and Docker, we may now commence with the configuration of a Quorum network. To initialize the Quorum network utilizing Docker containers, kindly adhere to the subsequent steps provided below.

Step 1: Create a Docker network:

Execute the following command to create a Docker network that will be used for communication between Quorum nodes:

docker network create quorum_network

Step 2: Prepare the Quorum Network Directory:

Establish a directory to accommodate the configuration files for your Quorum network. Utilize the subsequent command to initiate the creation of a directory entitled “quorum_network.”

mkdir quorum_network
cd quorum_network

Step 3: Generate the Quorum Genesis file:

The Genesis file contains the initial configuration and parameters for the Quorum network. Use a text editor to create a new file named `genesis.json` inside the `quorum_network` directory. Populate it with the necessary configuration parameters. Here is an example of a simple Genesis file:

{
  "alloc": {},
  "config": {
    "chainId": 10,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 1,
    "clique": {
      "period": 5,
      "epoch": 30000
    }
  },
  "extraData":
"0x0000000000000000000000000000000000000000000000000000000000000000",
  "gasLimit": "0x47b760",
  "difficulty": "0x1",
  "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "nonce": "0x0",
  "timestamp": "0x5b0670c5"
}

Customize the parameters according to your network requirements.

Step 4: Create the Quorum Node Configuration Files:

For each node in your Quorum network, create a configuration file that specifies its network address, consensus mechanism, and other relevant settings. You can use a text editor to create separate JSON files for each node. Here’s an example of a node configuration file named `node1.json`:

{
  "name": "node1",
  "listenAddress": "0.0.0.0:21000",
  "rpcAddress": "0.0.0.0:22000",
  "whisperAddress": "0.0.0.0:23000",
  "raft": true,
  "privateKey": "<private_key>",
  "publicKey": "<public_key>",
  "enclaveKey": "<enclave_key>",
  "url": "http://localhost:22000"
}

Repeat this step for each node, modifying the configuration parameters accordingly.

Step 5: Run the Quorum Nodes using Docker Containers:

For each node in the Quorum network, create a Docker container using the corresponding configuration file. Execute the following command to create a container for `node1`:

docker run -d –name=node1 –network=quorum_network -p 21000:21000 -p 22000:22000 -p 23000:23000 -v <path_to_quorum_network_directory>:/qdata <image_name> /qdata/node1.json

Explanation of each parameter:

  • `-d`: Run the Docker container in detached mode (in the background).
  • `–name=node1`: Assign the name “node1” to the running container for easy reference.
  • `–network=quorum_network`: Connect the container to the Docker network named “quorum_network”.
  • `-p 21000:21000 -p 22000:22000 -p 23000:23000`: Publish container ports 21000, 22000, and 23000 to the corresponding ports on the host machine. This allows external communication with the Quorum node running inside the container.
  • `-v <path_to_quorum_network_directory>:/qdata`: Mount a volume from the host machine to the container, allowing the Quorum node to store data in the specified directory on the host.
  • `<image_name>`: Replace this with the name of the Docker image that contains the Quorum node software.
  • `/qdata/node1.json`: Pass the path to the Quorum configuration file named “node1.json” inside the container. This configuration file will be used to set up the Quorum node.

Replace `<path_to_quorum_network_directory>` with the actual path to the `quorum_network` directory and `<image_name>` with the Quorum Docker image name.

Repeat this command for each node, updating the container name, ports, and configuration file accordingly.

Conclusion

With the help of this blog, you will be equipped with the necessary knowledge and skills to build a Quorum Blockchain network using Docker in Google Cloud Shell. Let’s embark on this journey and unlock the potential of Quorum Blockchain in your projects and applications!

Course Schedule

Name Date Details
Blockchain Course 14 Dec 2024(Sat-Sun) Weekend Batch View Details
21 Dec 2024(Sat-Sun) Weekend Batch
28 Dec 2024(Sat-Sun) Weekend Batch

About the Author

Technical Lead - Blockchain and Cyber Security Professional

Arpit is a Technical Lead in blockchain and cyber security. He has 5+ years of experience helping companies secure their applications via ethical hacking practices and has helped many fintech companies set up their blockchain implementations. In his free time, he provides training on cybersecurity and related domains.