How to deploy (early) production ready Hyperledger Fabric applications using IBM Cloud

Written by sneljo | Published 2018/08/06
Tech Story Tags: ibm | blockchain | hyperledger | hyperledger-fabric | cloud

TLDRvia the TL;DR App

This post will be a quick walkthrough of the new blockchain plans on IBM Cloud and on how to deploy chaincode on them. I created an account and I’m currently running my tests on the starter plan which is FREE while it’s in Beta.

What is IBM Blockchain Platform

For v1.1, IBM has revamped their blockchain plans for IBM Cloud. These currently include a starter plan, an enterprise plan, an enterprise plus plan and a self-managed plan. The fully integrated blockchain platform is designed to accelerate the development, governing, and operation of a multi-institution business network. It allows you to fully manage and easily deploy code to a running network.

Starter plan

The starter plan is mainly meant for testing and educational purposes. It includes one orderer using the SOLO consensus which is not meant for production. Same goes for the CA. There will only be one, so it’s not fault tolerant. If you don’t care and want to use it in production anyways, please read IBM’s “Need to know” for a detailed overview of why not to do this.

Features:

  • One-click-ready networkStarter Plan provisions you a network with an ordering service, CAs, a default channel, and two organizations (with one peer per organization) with a single click. IBM Blockchain Platform handles the creation and configuration of this network (you’ll be able to update it after it goes live).

  • Multi-organization network simulationYou can use Starter Plan to simulate building a network with multiple organizations. You do not need to actually invite other organizations to your network, you can act as other organizations yourself. This mechanism enables you to learn how a new organization can join the network, how multiple organizations work together in the network, and so on. You can switch between your organizations from the Network Monitor to view and manage the network from different organizations’ view.

  • Swagger APIsStarter Plan exposes several REST APIs that you can try out from a Swagger interface. For more information, see Using Swagger APIs.

  • Sample applicationsStarter Plan leverages the Toolchain service in IBM Cloud and enables sample deployment with simple clicks. After you deploy and launch a sample, the chaincodes and applications automatically run on your blockchain network. For more information about sample applications, see Deploying sample applications.

Enterprise plan

The Enterprise plan offers all the features of the starter plan. But adds some extra missing features which made the starter plan not production worthy.

They explicitly mention early production workloads because Hyperledger Fabric still needs to do some work before it can handle real production loads.

  • **Crash Fault Tolerance**The enterprise plan provides a crash fault tolerant (CFT) Kafka ordering service with 3 nodes. It also includes two intermediate CAs per member, which grant membership to the network. This allows for one of the CA’s or orderers to go down without breaking your network.

  • Hardware Security Module (HSM)This plan includes a Hardware Security Module (HSM). This provides on-demand encryption, key management, and key storage as a managed service. HSM is a physical appliance that handles the resource-intensive tasks of cryptography processing and reduce latency to applications. For more information, see Hardware Security Module.

  • **Secure storage**Besides the core blockchain components, the Enterprise Membership option provides an infrastructure with secure data storage and communications (TLS) and high availability. While Fabric networks share these infrastructure resources, isolation is provided for the Fabric component nodes in a network, and each node executes in a secure docker container that protects the execution environment.

Enterprise plus plan

This plan includes all features of the enterprise plan, but this plan also runs on dedicated computing hardware for performance and isolation.

Self Managed plan

This plan is coming soon. You’ll be able to install and run the software stack on your own infrastructure. You’ll also be able to easily connect to another network on the IBM blockchain plans.

Benefits

You can easily setup your network using the first-network scripts without using IBM Cloud. You are in control of your network by editing the docker-compose file. You would need to deploy these containers using Kubernetes or docker and provide the necessary configuration for the network to get up and running. But this is only the start, you also need Governing tools setup to keep your network healthy and upgrade your code when needed.

IBM Cloud Blockchain platform is providing Hyperledger Fabric as a service. Taking away the devops and adding the ability for you to manage and govern the HLF network by using a handy and straightforward GUI. Starting a network is as easy as clicking some buttons and uploading your chaincode.

A nice addition to the platform is the ability to easily govern the network. You can send invitations to other members to participate in governing the network. You can establish policies for membership, channel management, chaincode. The parties included in the policy will have to accept when making changes to the network in a controlled manner.

Let’s deploy some code

If you haven’t already, you should really create an account on Bluemix if you want to do this. We’ll just make some basic adjustment and upload chaincode.

Setup

Go to the blockchain tab in the Bluemix catalog. It’s possible you’ll be greeted with something like this. In this case, go to Cloud Foundry Orgs and create a new space. If you want to use the free trial, create one for the region US South”. If you already have this, just switch to this region and select a space.

“no space in this region” error message

If you selected the correct region US South”, you will be able to choose the FREE “Starter Membership Plan”. After a couple of seconds, you will be greeted with an overview screen. Here you can add Cloud Foundry Apps directly or add service credentials to connect your application using IAM. We’ll skip this for now and just press Launch. We have liftoff. 🚀

Overview

You are greeted by the management panel of the nodes in your network. Here you can add, stop and remove peers. You are also able to view their logs.

Upon creating your starter plan network, you are able to create one more peer for org2. You can easily spin one up by pressing the Add Peer button.

You are also able to find the connection profile here. This is a configuration file which can be loaded into your SDK to set up the connection to your network. I wrote a bit more about this here.

Channels

There is already a default channel created. So if we want we can immediately deploy our code on that channel. But we can also create a new one.

Notice how it says “Request Channel” instead of “Create channel”? This is because invited members need to vote for a channel request.

New Channel

After giving your channel a name, creating a new channel will prompt you with the following pop-up. Here you can configure the members for your channel and their permissions.

Set member permissions

Depending on which permissions you set for your members (above), you can define your endorsement policy (below). An endorsement policy is a condition which needs to be met when updating a channel. You can select Any or All members to vote for a certain change.

Set channel policy

After submitting, all members will be notified and will need to review and vote on this request. Only when the policy if fulfilled, you can create the new channel.

Per voting request, you’ll be able to see an overview of the required votes. And who has already given them.

You created a new channel! Now you need to add peers to it in order for it to do something. You can do so by clicking on your newly created channel in the Channel tab. When clicking on a channel, you can (un)select different peers per channel.

Channel overview

Per channel, you have a way to monitor your network and members. You can see a detail of all the blocks in the network. This is also the place where you can install chaincode.

Installing chaincode

Installing chaincode is as easy as uploading a file. After selecting a peer, you can upload chaincode to a channel. You can upload separate files, but a zip is also possible. You are also able to deploy .bna files from Hyperledger Composer by following these steps.

Instantiating chaincode

After uploading your chaincode, you’ll need to instantiate chaincode per channel. You are also able to pass arguments to the init() function, as you would normally starting a network locally.

READY, deployed … Integrate

That’s about it to start a basic network. You can easily connect to it from your client using the JSON output connection profile which I mentioned at the top of this article. You just import this file and most of the connection configuration is already set up for you.

I highly recommend to still go through their official documentation since this is only a basic introduction. There is still more to explore here.

Originally posted on TheLedger

What to read next 🤓


Published by HackerNoon on 2018/08/06