Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
INTERNSHIP REPORT
Blockchain Design using HyperLedger Fabric
Akshay Goyal (B.E-CSE)Chitkara UniversityHimachal pradesh, India
Manil Puri (B.E-CSE)Chitkara UniversityHimachal pradesh, India
Mukul Mahajan (B.E-CSE)Chitkara UniversityHimachal pradesh, India
Rachit goel (B.E-CSE)Chitkara UniversityPatiala (Punjab), India
SupervisorPao-Ann HsiungProfessor, Department of Computer Science and Information EngineeringDirector, Smart Living Technology Research CenterNational Chung Cheng University, Chiayi, TAIWAN-62102.Honorary Professor, Amity Institute of Information Technology, Amity University, Noida, INDIAIET FellowE-mail: [email protected]
Preface and Acknowledgement
For three months from December 2017 till March 2018, We did an internship at National
Chung Cheng University, Taiwan. CCU is one of Top Rated Universities in the country. This
internship project is a part of our 4-year Bachelor’s Degree in Computer Science under TEEP
@ India Program 2017-2018.
We worked on a project on Smart Blockchain Security System Design. A smart network
management system will be developed for managing farms using nodes that correspond to
farming activities, including irrigation, adding fertilizers, and applying pesticides. This topic
suits our major in computer science, and also brought us to a very new and interesting area of
using Artificial Intelligence in Precision Farming. Through the project, we did not only gain a
lot of knowledge but more importantly, we also had a great chance to sharpen our skills in a
working environment. Not less important than the communication technologies that we have
learnt is the communication skills that we have been trained and practiced through giving
presentations, discussing with the professor.
We are very appreciated to Prof. Pao-Ann Hsiung, our guide and mentor. Prof. Pao gave us
very in-time valuable instructions and more importantly for his enthusiastic encouragements
and precious instructions during our internship period. He gave us in-time feedback on our
research.
Throughout the internship, we have also learnt many things about the Taiwanese culture whose
benefits are far beyond what we could learn in a normal project. In short, I would like to
National Chung Cheng University and Chitkara University,Office of International Programs
for introducing us to this great opportunity in which we have developed ourselves both
academically, professionally and socially.
Chapter 1
IntroductionWhen we reflect on the future of agriculture, we could not avoid thinking about the power of
technology to solve problems bedeviling this sector. Climate change, population growth and
food security concerns have pushed for innovative technological solutions to farming.
Artificial Intelligence is emerging as part of the solutions towards improved agricultural
productivity.Individual agricultural activities on the farm takes effort, for example planting,
maintaining, and harvesting crops need money, energy, labor and resources. What if we can
use technology to replace some of the human activities and guarantee efficiency? That’s
where artificial intelligence comes in.
Agriculture is slowly becoming digital and AI in agriculture is emerging in three major
categories, (i) agricultural robotics, (ii) soil and crop monitoring, and (iii) predictive analytics.
Farmers are increasingly using sensors and soil sampling to gather data and this data is stored
on farm management systems that allows for better processing and analysis. The availability
of this data and other related data is paving a way to deploy AI in agriculture.
AI in agriculture has unlocked the power of precision farming. The idea behind precision
farming is the goal to produce more output with less input. In other words, the goal here is to
raise the crop yield as much as possible while investing as little as possible. While
challenging before artificial intelligence, precision farming is thriving with the help of
technologies such as satellites and smart tractors, and robotics.
Problem statement and research objectives
1.1.1 Problem statement
As briefly described climate change, population growth and food security concerns have
pushed for innovative technological solutions to farming. Planting, maintaining, and
harvesting crops takes time, energy, money, labor, resources, and more. According to the UN
Food and Agricultural Organisation (FAO), the global population is set to reach 9.2 billion
by the year 2050. This means that the global agriculture sector is under more strain than ever
with 2 billion more mouths to feed within the next 33 years! With available acreage
estimated at just an additional 4%, it seems it is no longer an option to simply plant more
crop fields or breed more cattle. What is needed, therefore, is a greater efficiency within
current farming methods as farmers will be required to ‘do more with less’.
1.1.2 Research Objectives
Based on the observation that planting, maintaining, and harvesting crops takes time, energy,
money, labor, resources, and more, the main objective is that a smart network management
system will be developed for managing farms using nodes that correspond to farming
activities, including irrigation, adding fertilizers, and applying pesticides.
The main objective above can be decomposed to 5 smaller objectives:
Objective 1:Each node is capable of creating new transactions, either using function
blocks (FB) in IEC 61499.
Objective 2: A FB will implement data fusion in each node.
Objective 3: Kubernetes will be used to design and implement all the nodes that
conform to the IEC 61499 industrial distributed control standard. Each node will be in a
Docker container.
Objective 4: Deep neural network models will be used to trigger a node. For example, a
plant pathology model will be used to trigger the Pesticide Node and a crop model will
be used to trigger the Fertilizer Node.
Objective5: Smart contracts can be configured specifically for each farm.
1.2 Organisation of this report
The report is organized as follows. Chapter 2 will introduce a technical description about the
related concepts such as IEC 61499 standard, hyperledger fabric, kubernetes and docker.
Chapter 3 gives the conglomeration of the system to make the network. The conclusion and
future work will be given in Chapter 4.
Chapter 2
Technical descriptions
This chapter describes the concept of smart our smart network system and its constituent
programs like docker, hyperledger fabric and kubernetes, as well as the motivation of
transforming from the conventional farming methods to advanced precision farming. An
important part of the Smart Network System IEC61499 which supports the input of data
from various sensors to network will also be explained within this chapter.
This chapter is organized as follows: Section 2.1 describes the Hyperledger Fabric. Section
2.2 explains the concept Docker. Section 2.3 gives a description about Kubernetes and
Section 2.4 gives information about IEC61499.
2.1 Hyperledger Fabric
It’s intended as a foundation for developing blockchain distributed ledger applications with a
modular architecture. It allows components, such as consensus and membership services, to be
plug-and-play.
It covers key features of blockchain and distributed ledger technologies, current Hyperledger
projects and common use cases, and the differences between various types of Hyperledger
projects in the fields of finance, banking, Internet of Things, supply chains and manufacturing
technologies.
For installing hyperledger fabric How to install Hyperledger Fabric
2.1.1 Hyperledger Fabric core concepts
FABRIC CA (Certificate Authority)
MSP (Membership Service Provider)
PEERS
ORDERER
CHANNELS
CHAINCODE
ENDORSEMENT POLICY
I. FABRIC CA (Certificate Authority)
The Hyperledger Fabric CA is a Certificate Authority (CA) for Hyperledger Fabric.
It provides features such as:
registration of identities, or connects to LDAP as the user registry
issuance of Enrollment Certificates (ECerts)
certificate renewal and revocation
Hyperledger Fabric CA consists of both a server and a client component as described later in
this document.
II. MSP (Membership Service Provider)
Membership Service Provider (MSP) is a component that aims to offer an abstraction of a
membership operation architecture.
In particular, MSP abstracts away all cryptographic mechanisms and protocols behind issuing
and validating certificates, and user authentication. An MSP may define their own notion of
identity, and the rules by which those identities are governed (identity validation) and
authenticated (signature generation and verification).
III. PEERS
A peer receives ordered state updates in the form of blocks from the ordering service and
maintain the state and the ledger.
Peers can additionally take up a special role of an endorsing peer, or an endorser. The special
function of an endorsing peer occurs with respect to a particular chaincode and consists in
endorsing a transaction before it is committed. Every chaincode may specify an endorsement
policy that may refer to a set of endorsing peers.
IV. ORDERER
The orderers form the ordering service, i.e., a communication fabric that provides delivery
guarantees. The ordering service can be implemented in different ways: ranging from a
centralized service (used e.g., in development and testing) to distributed protocols that target
different network and node fault models.
V. CHANNELS
In a Hyperledger Fabric network, there can be multiple ledgers. These ledgers are called
channels, and each has its own set of peers that are allowed to participate — by proposing and
receiving transactions.
Channels can be dynamically created and reconfigured. Peers can also be added on the fly. The peer binary, which is used as the running process for each peer, may also be used as a client for managing the lifecycle of Fabric channels.
VI. CHAINCODE
The core of any blockchain platform is the ledger, a shared, tamper-proof history of the
universe. Specifically, it’s a record of all transactions within its scope. Chaincode is the term
for programs that run on top of the blockchain to implement the business logic of how
applications interact with the ledger. When a transaction is proposed, it triggers chaincode that
decides what state change should be applied to the ledger. For example, chaincode for the sale
of bitcoin would check that the seller actually has bitcoin to sell.
Since chaincode implements logic agreed on by members of the blockchain network, it is
sometimes called smart contracts.The only constraint is that all chaincodes are controlled by a
Peer according to the same interface — which is flexible enough that Hyperledger Fabric
actually uses chaincodes to implement some system-level features.
VII. ENDORSEMENT POLICY
Endorsement policies are used to instruct a peer on how to decide whether a transaction is
properly endorsed. When a peer receives a transaction, it invokes the VSCC (Validation
System Chaincode) associated with the transaction’s Chaincode as part of the transaction
validation flow to determine the validity of the transaction. Recall that a transaction contains
one or more endorsement from as many endorsing peers. VSCC is tasked to make the
following determinations:
all endorsements are valid (i.e. they are valid signatures from valid certificates over the
expected message)
there is an appropriate number of endorsements
endorsements come from the expected source(s)
Endorsement policies are a way of specifying the second and third points.
Fig 2.1.1 Basic Structure of Hyperledger Fabric
2.2 Docker
Docker is the company driving the container movement and the only container platform
provider to address every application across the hybrid cloud. Today’s businesses are under
pressure to digitally transform but are constrained by existing applications and infrastructure
while rationalizing an increasingly diverse portfolio of clouds, datacenters and application
architectures. Docker enables true independence between applications and infrastructure and
developers and IT ops to unlock their potential and creates a model for better collaboration and
innovation.
A container image is a lightweight, stand-alone, executable package of a piece of software that
includes everything needed to run it: code, runtime, system tools, system libraries, settings.
Available for both Linux and Windows based apps, containerized software will always run the
same, regardless of the environment. Containers isolate software from its surroundings, for
example differences between development and staging environments and help reduce conflicts
between teams running different software on the same infrastructure.
How to install Docker
2.2.1 Features of Docker1. Domain-specific language for building containers.
2. Each container has a single start process.
3. Union filesystem to conserve I/O when cloning containers.
4. Simple networking defaults—comparable to host-only networking in VMware.
5. Private registry for sharing images
2.2.2 Dockerfile -[build]-> Image -[run]-> Container
Creation of IMAGES
Three ways to acquire Docker images:
1. Docker Hub -
2. Build your own images via Dockerfile
3. Private registry - registry.hub.docker.com github.com/docker/docke
2.2.3 Running a Container1. Run a container in the background
$ docker run -d -name apache mattkaar/apache be09d6f98fcc54ade5696b757b0509423240a17ac9458688960f74c735
2. Run a container interactively with Bash
$ docker run -i -t -name apache mattkaar/apache /bin/bash
root@428707fdc19b:/#
2.3 Kubernetes
It is an open source platform that automates Linux container operations. It eliminates many of
the manual processes involved in deploying and scaling containerized applications. In other
words, you can cluster together groups of hosts running Linux containers, and Kubernetes
helps you easily and efficiently manage those clusters. These clusters can span hosts across
public, private, or hybrid clouds.
How to install Kubernetes
2.3.1 Key Concepts
Master Nodes Pod Service and Labels Container Node
Kubelet Kubernetes Proxy
I. Master
The controlling services in a Kubernetes cluster are called the master, or control plane,
components. These operate as the main management contact points for administrators, and also
provide many cluster-wide systems for the relatively dumb worker nodes. These services can
be installed on a single machine, or distributed across multiple machines.
II. Nodes
Servers that perform work are known as nodes. Node servers have a few requirements that are
necessary to communicate with the master components, configure the networking for
containers, and run the actual workloads assigned to them.
III. Pod
A pod is the basic unit that Kubernetes deals with. Containers themselves are not assigned to
hosts. Instead, closely related containers are grouped together in a pod. A pod generally
represents one or more containers that should be controlled as a single "application".
IV. Service and Labels
We have been using the term "service" throughout this guide in a very loose fashion, but
Kubernetes actually has a very specific definition for the word when describing work units. A
service, when described this way, is a unit that acts as a basic load balancer and ambassador for
other containers. A service groups together logical collections of pods that perform the same
function to present them as a single entity.
A Kubernetes organizational concept outside of the work-based units is labeling. A label is
basically an arbitrary tag that can be placed on the above work units to mark them as a part of a
group. These can then be selected for management purposes and action targeting.
V. Container
Containers are a method of operating system virtualization that allow you to run an application
and its dependencies in resource-isolated processes. Containers allow you to easily package an
application's code, configurations, and dependencies into easy to use building blocks that
deliver environmental consistency, operational efficiency, developer productivity, and version
control.
a. Kubelet
The main contact point for each node with the cluster group is through a small service called
kubelet. This service is responsible for relaying information to and from the control plane
services, as well as interacting with the etcd store to read configuration details or write new
values.
b. Proxy
In order to deal with individual host subnetting and in order to make services available to
external parties, a small proxy service is run on each node server. This process forwards
requests to the correct containers, can do primitive load balancing, and is generally responsible
for making sure the networking environment is predictable and accessible, but isolated.
Fig 2.3.1 Network Topology
2.4 IEC 61499
Part 1 of the IEC 61499 Standard defines an implementable reference architecture for the
development, reuse and deployment of Function Blocks in distributed and embedded industrial
control and automation systems, and Part 2 of the Standard defines requirements for software
tools to support the required engineering tasks. In recognition that these requirements alone are
insufficient to guarantee portability of software elements among tools, configurability of
distributed systems and devices by these tools, and interoperability of devices within these
systems, Part 4 of IEC 61499 defines requirements for Compliance Profiles intended to ensure
the attainment of these qualities by compliant distributed devices and software tools.
2.4.1 Why IEC 61499….
The qualities are defined as:
Portability: the extent to which software elements (FB types, data types, resource
types, device types, and system configurations) can be accepted and correctly
interpreted by multiple software tools
Configurability: the extent to which a system can be configured via selection of
functional units (FBs, resources, and devices), assigning their locations and parameters
and establishing their data and event interconnections
Interoperability: the extent to which functional units in a system are able to operate
together to perform the required set of automation, control, and data processing
functions.
2.4.2 Software Tools
4DIAC-IDE
This software tool, a product of the 4DIAC open source project, is distributed as a set of plug-
ins for the Eclipse Integrated Development Environment (IDE). 4DIAC-IDE supports the
specification of function block types as well as the development of system configurations
including the application model and the device configurations, as well as deployment of the
application to distributed devices.
nxtSTUDIO
An interesting feature is its use of Compound Automation Types (CATs) which include
control engineering via IEC 61499; HMI/SCADA visualization including symbols, operating
dialogues, etc; interconnection of hardwarespecific inputs/outputs; and documentation.
ISaGRAF Workbench
ISaGRAF announced the certification of its IEC 61499 solution compliance by TÜV Süd . The
TÜV Compliance Report does not confirm portability of IEC 61499 library elements produced
by the ISaGRAF Workbench to or from any software tool other than itself, not does it confirm
configurability by the Workbench of any runtime platform other than the ISaGRAF runtime.
2.4.3 Software Platforms
FBRT
Like the FBDK software tool, this runtime platform was developed in the Java language and
used for early feasibility testing and demonstration of the IEC 61499 architecture, using
embedded Java technology from Imsys Technologies . Subsequently, it was used in a number
of research projects with the now obsolescent Netmaster hardware platform.
FORTE
The 4DIAC-RTE (FORTE) is a small portable implementation of an IEC 61499 runtime
environment targeting small embedded control devices (16/32 Bit). It provides the execution of
basic function blocks, composite function blocks, and service interface function blocks. The
execution mechanisms in FORTE allow the real time constrained execution of IEC 61499
control configurations triggered by external events, where different parts of the configuration
can fulfill different real time constraints and the execution of low priority processes does not
disturb the execution of higher priority processes.
nxtRT61499F
The core of this runtime is based on the open source solution FORTE but enhanced with
additional services and functions.It is optimised for distributed control engineering and has
available extensions such as OPC-UA servers, WEB servers, etc. Configurability of this
platform by the FBDK and 4DIAC-IDE tools, as well as by the nxtSTUDIO tool, and its
interoperability with the FBRT and FORTE runtime platforms.
Chapter 3Making of Smart System Network
Our S3G LoRa sensors for soil, weather, and crops will be used for collecting related data.
A smart network management system will be developed for managing farms using nodes that correspond to farming activities, including irrigation, adding fertilizers, and applying pesticides.
Each node is capable of creating new transactions, either using function blocks (FB) in IEC 61499 or automatically via the execution of smart contracts.
A FB will implement data fusion in each node. Kubernetes will be used to design and implement all the nodes that conform to the IEC
61499 industrial distributed control standard. Each node will be in a Docker container. Deep neural network models will be used to trigger a node. For example, a plant
pathology model will be used to trigger the Pesticide Node and a crop model will be used to trigger the Fertilizer Node.
Smart contracts can be configured specifically for each farm.
Hyperledger fabric will be used to design and implement the HSAB. Each block will consist of one or more HSAB transactions, where each transaction corresponds to one agricultural activity such as irrigating, adding fertilizer, applying pesticide, harvesting, etc.. The HSAB will be implemented across two or more S3G LoRaWAN-based gateways such that food safety can be ensured. For parties that do not possess an S3G LoRaWAN-based gateway, a PC server installed with HSAB can also be used to interact with the HSAB blockchain.
3.1 Work related to chaincode
Data structure of the chaincode:
Invocation function:
Initialization of crop function:
Quary of crop function:
Getting History of crop function:
Reading of crop function:
Deletion of crop function:
Irrigation of crop function:
Adding fertilizer to crop function:
Applying pesticide to crop function:
Harvesting of crop function:
Commands for initialization and invocation:
Chaincode Deployment screenshots:
Installing chaincode
Instantiating chaincode
Querying chaincode:
Chapter 4Conclusion and Future work
Blockchain technology is a sophisticated, interesting, and emerging technology. It provides a
reliable way of confirming the party submitting a record to the blockchain, the time and date of
its submission, and the contents of the record at the time of submission, eliminating the need
for third-party intermediaries in certain situations. However, it is important to consider that
blockchain technology does not verify or address the reliability or the accuracy of the contents,
and additionally blockchain technology provides no storage for records, but instead the hashes
thereof.
Regarding economic advantages to legal recognition of blockchain technology, Vermont is
currently a hospitable environment for commerce related to blockchain technology even
though the State has not recognized this technology in statute at this time. The study committee
has not identified any specific legal or practical benefits from the legislation set forth in
Appendix B. However, the group has also not identified any risk inherent in blockchain
technology that would warrant withholding the recognition of validity set forth in the
legislation. While the committee does not doubt that blockchain technology and the industry
forming around it demonstrate significant economic activity and interest, it is unclear what
steps Vermont could take to lure any of that activity to the state.
Blockchain technology is already in use in the private sector, it can precisely help us with the
precision farming and secure the all the transaction and help us to achieve even more healthy
and secured food products.
The project has very great future scope and can be implemented as follows:-
Integrate deep learning into the design of the above-developed Blockchain Design such that it
is smart enough to learn application-related facts on itself. This is a very advanced research
topic and needs basic training in block chain design.
The contents will be as follows:
(a) Developing application programming interface (API) for the Blockchain Platform such
that its learning capabilities can be enhanced.
(b) Developing deep neural network models such that the Blockchain Platform can be
integrated with the models.
(c) Applying the blockchain platform with deep neural network models to precision
agriculture.
(d) Testing and verifying that the platform can be used for smart monitoring of crop growth
and pathology level predictions
References
[1] https://github.com/jollen/Hyperledger-Fabric-Install
[2] https://mlgblockchain.com/hyperledger-pre.html
[3] https://docs.docker.com/get-started/#a-brief-explanation-of-containers
[4] https://www.vultr.com/docs/how-to-use-docker-creating-your-first-docker-container
[5] https://kubernetes.io/docs/getting-started-guides/ubuntu/networking/
[6] http://www.think-foundry.com/deploy-hyperledger-fabric-on-kubernetes-part-1/
[7] http://www.think-foundry.com/deploy-hyperledger-fabric-on-kubernetes-part-2/
[8]http://www.osborneclarke.com/wp-content/uploads/2017/06/OSB100165_Blockchain-Report_v12-Interactive.pdf
[9] https://www.udemy.com/docker-for-developers/learn/v4/overview
[10] https://kubernetes.io/docs/tutorials/kubernetes-basics/
[11] https://hub.docker.com/explore/
[12] http://www.iec61499.de/
[13] https://webstore.iec.ch/publication/5506