Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Introduction to Hyperledger Sawtooth

DZone's Guide to

Introduction to Hyperledger Sawtooth

In this post, a developer takes a look at the advantages of this open source blockchain platform and how to get it up and running on your machine.

· Security Zone ·
Free Resource

Mobile is increasingly becoming a part of every consumers’ identity, but the increasing use of this digital channel is escalating the security risks faced by consumers and institutions.

Hyperledger Sawtooth is Hyperledger's open source blockchain platform, following closely on Hyperledger Fabric. It is an enterprise distributed ledger proposed by Intel and was one of the first projects to join Linux Foundation's Hyperledger umbrella. This platform is modular, scalable, with an innovative consensus model, has unique support for permissioned and permissionless infrastructure and the potential for incredibly large network sizes.

An application can be native business logic or a smart contract virtual machine. Sawtooth allows both of these applications to coexist, thus allowing multiple types of applications to be in the same instance of the blockchain network. It also simplifies blockchain application development by separating the core system from the application domain.

Hyperledger Sawtooth is extremely scalable and is able to withstand high throughput of data, which makes it a great option for production supply chain scenarios and comes with a lot of features like:

  1. Distributed: There is no centralized data storage and thus the data is distributed among all the participants. All the nodes in the network have identical information with them.
  2. Immutable: The data, once stored in the blockchain, cannot be altered. There exist block hashes to detect any attempt to chain the history.
  3. Secure: Since the transactions are made between untrusted parties, they are verified and signed by known identities that are part of the blockchain itself.
  4. Permissioned as well as permissionless infrastructure: It allows you to build both permissioned as well as permissionless blockchains depending upon the use case. In the case of permissionless blockchains, anybody can participate in the network whereas in the case of permissioned blockchains, prospective participants must identify themselves to the network and the network can decide whether to let them participate. Once in the network, participants share a view of the blockchain ledger.
  5. Parallel transaction execution: Along with a serial scheduler, it also has an advanced parallel scheduler that allows parallel execution of transactions. Thus, increasing performance.
  6. Modular: It provides a modular platform for transaction-based updates to shared state (data) between untrusted parties.
  7. Hardware integration: In addition to certain public blockchain features, Hyperledger Sawtooth has become known for the ease with which it can be integrated with hardware security solutions.

Consensus Implementation:

Consensuses are the backbone of every blockchain platform and Hyperledger Sawtooth provides three consensus implementations: Dev_mode, PoEt, PoEt Simulator, with a forth under active development, called RAFT. Here, we will be talking about one of its main consensus algorithms, Proof of Elapsed Time (PoET).

Proof Of Elapsed Time (PoET):

In Hyperledger Sawtooth, a consensus is the way of selecting the leader of the new block that is to be added in the blockchain. PoEt is the default consensus for Sawtooth. There are two simple rules in this consensus:

  • Each participant in the blockchain network waits a random amount of time.
  • The first participant to finish waiting gets to be the leader for the new block.

In order to ensure that the consensus is fair, it relies on the special CPU instruction set provided by Intel, known as 'Intel Software Guard Extensions (SGX).' SGX allows applications to run trusted code in a protected environment. For PoET, the trusted code is what ensures that these two requirements are satisfied.

Note: In SGX, a special hardware component ensures that some particularly trusted code was set up correctly in a protected environment. This particular code runs in private from rest of the application.

Installation of Hyperledger Sawtooth Using Docker:

Step 1: Install curl:

sudo apt-get install curl

Step 2: Install Node.js:

sudo apt-get update
sudo apt-get install nodejs

Step 3: Install npm:

sudo apt-get install npm

Step 4: Install Docker:

sudo apt-get install docker-ce
sudo apt-get install docker-ce=<VERSION>

Step 5: Install docker-compose from the below mentioned link:

https://github.com/docker/compose/releases

Starting Hyperledger Sawtooth

Step 1: Download the following Docker Compose file as a sawtooth-default.yaml file from here

Or you can use any other docker-compose file depending upon your use case.

Step 2: Change your working directory to the same directory where the sawtooth-default.yaml Docker Compose file is saved. Make sure you do not have anything else running on port 8080 and port 4004.

Step 3: Run the following command:

docker-compose -f sawtooth-default.yaml up

This command will download the Docker images that comprise the Hyperledger Sawtooth demo environment.

Step 4: Open a new terminal window and navigate to the same directory. In order to connect to the client container, run the following command:

docker exec -it sawtooth-client-default bash

In your terminal, we will see something similar to the following:

root@75b380886502:/#

Here, the container name was sawtooth-client-default. Similarly, other containers can also be run by changing the container name.

Step 5: To confirm that the validator is up and running and reachable from the client container, run the following command:

curl http://rest-api:8080/blocks

After running this command, we should see a JSON object response with a “data” array of batches, headers, etc.

Step 6: To check the connectivity from the host computer, run the following command in a new terminal window:

curl http://localhost:8080/blocks

After running this command, we should see a JSON object response with a “data, array of batches, headers, etc.

Stopping Hyperledger Sawtooth:

Step 1: Press Ctrl+C from the window where you originally ran docker-compose. You will see containers stopping.

Step 2: Finally, run the following command:

docker-compose -f sawtooth-default.yaml down

I hope this was helpful. In my next blog, we will be exploring the architecture of Hyperledger Sawtooth.

References:

https://sawtooth.hyperledger.org/docs/core/releases/1.0/

Explore the authentication advancements that are designed to secure accounts and payments—without overburdening consumers with a friction-laden experience.

Topics:
blockchain ,hyperledger sawtooth ,security

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}