0% found this document useful (0 votes)
5 views43 pages

Designing Decentralized Intelligent Apps

The document outlines the design, development, and deployment of Decentralized Intelligent Applications (DIApps), highlighting the challenges and considerations in creating such applications across different blockchain platforms. It emphasizes the importance of understanding user requirements, forming a skilled team, and conducting thorough testing throughout the development process. Additionally, it discusses the evolution of applications from traditional web models to decentralized and intelligent applications, with a focus on addressing specific problems such as contact tracing in the context of the COVID-19 pandemic.

Uploaded by

VIJAYA RAJA V
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views43 pages

Designing Decentralized Intelligent Apps

The document outlines the design, development, and deployment of Decentralized Intelligent Applications (DIApps), highlighting the challenges and considerations in creating such applications across different blockchain platforms. It emphasizes the importance of understanding user requirements, forming a skilled team, and conducting thorough testing throughout the development process. Additionally, it discusses the evolution of applications from traditional web models to decentralized and intelligent applications, with a focus on addressing specific problems such as contact tracing in the context of the COVID-19 pandemic.

Uploaded by

VIJAYA RAJA V
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Designing a DIApp

• The design aspects of DIApps have been often considered to be


somewhat challenging

• It is also a common perception that the solution space lacks a


common structure to define key components, resulting in an
inconsistent design strategy for applications

• The tools required by the user of an Ethereum-based DIApp are very


distinct from that of Hyperledger Fabric, and subsequently, that of EOS

• It is important to identify the design constraints of the application


before commencing the future steps.

• It is critical to understand the user requirements, analyze them, and


perform better research at an early stage of design.
Designing a DIApp - Research
• Does the solution demand full decentralization over a public network
for peer-to-peer interactions?

• Does the solution need to be implemented in a private network due to


the extreme sensitivity of the data and minimal exposure of the
business logic?

• Can the solution be implemented on a public network with all the


sensitive data encrypted on a public decentralized storage system?

• Can the same solution be implemented on a public network with all


the sensitive data stored in a private virtual decentralized storage
service?

• Does the solution require a permissioned network of authorized nodes


across multiple stakeholders of a consortium?.
Conceptualization
• Formulating the Proof of Concept is an essential step in the
development of solutions using emerging technologies.

• The development of proof of concepts for decentralized


applications is also important, as they ensure alignment
between the requirements and delivery of the solution.

• This helps maintain functional and design conformity right


from the early days of development.

• It is notable that the proof of concept specifications may


change due to the waves of design and architectural change in
the blockchain landscape
Product-market fit
• Does the DIApp solve a unique problem faced by various
stakeholders in the industry?

• Does the DIApp disintermediate a current entity that is


inefficient in the current process, or bring more order to the
process?

• Can the benefits of DIApps be achieved only by utilizing the


combination of blockchain and AI?

• Does the DIApp facilitate users to derive insights by using the


DIApp with the help of AI models?
Developing a DIApp
• Many organizations are still in the process of building
combined expertise in the respective technologies

• It is also essential to set up a team of members with

– complementary skill sets in smart contract development

– Web or mobile application development

– finally AI or data science modeling


Team formation
• Two smart contract developers with good knowledge of the
Solidity, Rust, and Golang programming languages

• One smart contract developer may be able to focus on feature


development and another smart contract developer work on
bug fixes, internal auditing, code quality reviews, and so on

• One full-stack web developer with basic knowledge of


blockchain to develop the frontend web application.

• If the target audience is on mobile, you might choose a


mobile application developer accordingly
Team formation
• One SMACK-stack developer may be required to set up the
analytics platform needed for building AI capabilities

• One machine learning or deep learning engineer may be


required to build the required models

• Finally, you may need one DevOps engineer to orchestrate the


infrastructure and deploy all the necessary components
across vendors or cloud platforms through a well-defined
Continuous Integration/Continuous Delivery (CI/CD) pipeline
Agile development
Authoring the test cases
• Before the software can be deployed, we can try to ensure the
correctness of the software

• confirm the fitness of the runtime environment by running a few


crucial tests

• Usually, these tests are implemented within the source code, in the
form of unit test files containing dummy input values being passed
to the functions,

• Later checked through assertion to ensure the correctness of the


software in the relatively new environment

• Each test case represents a scenario for the logic to perform and
provide a predetermined output scenario
Unit testing
• Under unit testing, we can test the core functionalities of each
module before integrating it with the other modules.

• Unit testing helps in verifying the correctness of these


modules by comparing the real output to the desired output

• This process repeats for each change made to the module

• Thereby preserving the correctness of the module each time a


change has been made

• Once the modules are unit tested and integrated, we can


perform integration testing
Integration testing
• DIApp is a hybrid composition of many technologies.

• Hence, it is important to test the behavior of each


heterogeneous component in order to ensure that they
provide accurate results.

• This is achieved by performing integration testing.

• Once the components are integrated, we can run a few test


cases that can formally verify the correctness of a few critical
components that rely upon one or more heterogeneous
components to provide output
Testing AI models
• Testing AI models and capabilities can be split into two phases.

• One phase of the testing is before the model reaches production.

• The other phase of the testing is applied post-production. Before bringing


the

• AI model to production, testing can be performed by verifying the


correctness and completeness of the training data.

• Similarly, once the AI models are deployed, we can test them frequently
for accuracy and availability.

• Turing tests can also be performed to understand whether the AI model


has able to replace a human response to the task
Deploying a DIApp
• Blockchain platforms demand a relatively larger stretch of
time to set up the network and make the whole ecosystem
functional.

• Accordingly, several blockchain platforms have understood


the need for DevOps as an integral part of developing those
platforms.

• DevOps knowledge is also essential in using these platforms


for developing applications and deploying solutions.
Scaling the application for production
• Deployment of the DIApp is the final crucial step in the life cycle.

• The application is designed, architected, and developed in a


manner supportive for the deployment of the application in a
scalable

• The scale is not only measured in terms of


– the number of users,
– but also depends on the cost,
– form factors,
– other economic attributes that may directly affect the operations.

• Docker, Kubernetes, Ansible, Terraform, and Mesos are available


for deploying DIApps and their dependencies
Scaling the application for production
• Deployment of the DIApp is the final crucial step in the life cycle.

• The application is designed, architected, and developed in a


manner supportive for the deployment of the application in a
scalable

• The scale is not only measured in terms of


– the number of users,
– but also depends on the cost,
– form factors,
– other economic attributes that may directly affect the operations.

• Docker, Kubernetes, Ansible, Terraform, and Mesos are available


for deploying DIApps and their dependencies
Explorers
• In public networks, blockchain explorers are available to look
up information concerning a transaction or block.

• If the DIApp solution is implemented in a private or


permissioned environment, these public blockchain explorers
may not be able to provide information on transactions

• we must be able to deploy existing blockchain explorers and


plug them into the endpoints of a private service

• Several open source implementations of blockchain explorers


are available, which could be downloaded and connected to
private services
Evolution of decentralized applications
Traditional web applications
• Traditional web applications such as blogs, chatrooms, and e-
commerce websites started with a simple web server

• Servers were hosted to accept limited client connections but


easily crashed after reaching the desired threshold

• So the majority of these applications have moved to an n-tier


architecture also called multi-tier or layer architecture

• The n-tier model separates the functions into many layers

• Most of the infrastructure used by companies can be


purchased or rented from cloud providers for a short period
Decentralized applications
• Decentralized application is not controlled by a single entity

• It facilitates a common bar of entry to use the app

• Decentralized apps. run on more than one server or computer

• such computers are not necessarily owned and operated by a


single entity or individual

• Interested parties who are willing to run the software for a


benefit or an incentive

• These applications do not experience a single point of failure


Decentralized intelligent applications
• Need for a new design pattern that favors a combination of
traceability, decentralization, and predictability

• Decentralized intelligent applications can use reliable


infrastructure in a peer-to-peer network

• This network is operated by more than one entity

• Transactions on this kind of network are usually confirmed in


a very short period of time at significantly lower fees

• A key differentiator between this pattern and others is the


closer integration of AI models with decentralized databases
Contrast and analysis
Traditional web Decentralized Decentralized
application (App) application (DApp, intelligent
dApp, or Dapp) application
(DIApp)
Network The client-server A distributed A distributed
model is used with network topology is network topology is
n-tier architectures. used to allow used to allow
anyone to join the anyone to join the
network. network.
Security Single points of The user is the Users can store and
failure are very owner of the data. operate on larger
likely. Data can be All the data and sizes of data with
hacked or leaked operations are the same key pair
due to weak secured by a unique security in order to
encryption or key pair. Limited own their own
centralized control data can be stored. data
over data.
Contrast and analysis
Traditional web Decentralized Decentralized
application (App) application (DApp, intelligent
dApp, or Dapp) application
(DIApp)
Cost Fixed costs in The costs of Prices are relatively
managing a transactions are stable in smaller yet
dedicated volatile since the decentralized
infrastructure costs depend on groups of nodes.
throughout the the price of the
year native token in the
blockchain.
Transparency Apps and data The logic of the app Logic and
operations are not and most of the operations are
transparent to the operations are transparent, with
user or other transparent. Private options to use
stakeholders transactions are privacy without
optionally allowed harming security
Contrast and analysis
Traditional web Decentralized Decentralized
application (App) application (DApp, intelligent
dApp, or Dapp) application
(DIApp)
Performance A large number of The throughput is Transaction
transactions can be low due to the large throughputs are
processed with distribution of higher. Finality is
immediate finality nodes. Finality is also achieved
slower. quickly
Privacy Complete privacy Anonymity is DIApps aim to
and the anonymity practiced through provide complete
of user data is wallets, but data privacy and
seldom practiced by management on anonymity to users
companies as data blockchain while providing
is hosted on a networks is a costly meaningful and
centralized or affair. The privacy of actionable insights
distributed the user depends using AI in a fair
database controlled on the application's manner
by organizations policies.
Building a sample DIApp
• we will cover the problem statement

• Find a solution to the stated problem

• Come up with a technical architecture as per the DIApp


design pattern

• Observe how to develop all the deliverables needed to launch


the DIApp.
Problem statement
• A novel coronavirus that goes by the name of Severe Acute
Respiratory Syndrome coronavirus 2 (SARS-CoV-2)

• It has created a new pandemic outbreak called Coronavirus


Disease 2019 (COVID-19)

• Although efforts made by local governments to reduce these


infections, some virus carriers appear to be asymptomatic

• This means that a person may be carrying the virus without


knowing it.

• Sometimes, the prescribed checkups could also fail to recognize


the virus in its early stage of incubating inside the patient's body
Current challenges
The two major challenges that are

• Detecting the virus in asymptomatic patients

• Tracing the transmission of the virus

To contain such infections, medical professionals resort to


contact tracing
Contact tracing
• The doctor has diagnosed the patient as positive for SARS-
CoV-2.

• A contact tracer is assigned to the case.

• The contact tracer interacts with the patient to identify the


activity of the patient.

• Depending on the jurisdiction/country, the contact tracer is


responsible for collecting accurate information about the
patient's whereabouts for a designated number of days or
weeks. For example, a patient that tests positive in India
might be asked to share their activity for the past 14 calendar
days
Contact tracing
• Based on the input provided by the patient, the contact
tracers may verify some information.

• If the information shared by the patient is convincing, more


contact tracers are hired to identify the first-degree people
infected by the patient.

• Once this manual search is over, the people who have been
contacted are tested for the virus.

• Depending on the jurisdiction, the people who have been


contacted may be placed under mandatory quarantine for up
to 14 days to check whether symptoms develop
Contact tracing
• The quarantined people are tested for the virus periodically.

• If there are no signs of the virus, the suspected people are


released. However, if they test positive, the same process
repeats.
Technical requirements
• Just (v0.5.11 and above): https://
[Link]/casey/just#installation

• Python (v3.6.9 and above):


[Link]

• [Link] (12.18.2 LTS and above):


[Link]

• Brave browser (v1.5.123 and above):


[Link]

• Jupyter Notebook: [Link]


Issues with contact tracing
• Some countries have automate this process digitally, it is very
difficult to track infections from non-human sources

• Several hypotheses claim the origin of the virus leads back to


bats, animals that live in forests and rural and urban areas

• Many researchers that the virus can remain on many forms of


surfaces for a few hours

• It is imperative to consider monitoring animals and non-living


objects for infections of the SARS-CoV-2 virus

• We need a digital contact tracing algorithm that can address the


possibility of infections among these two agents in the ecosystem
Solution approach
• Developing a sample application to track potential infections
from animals and non-living objects

• We must be able to track down the infection status at a


granular level for the sake of transparency.

• A public blockchain with a decentralized and open ledger can


offer this feature

• Manually tracking down all potential contacts is virtually


impossible

• Thus comes the need for blockchain and AI in tracing animals


and objects
Choosing the blockchain technology
• The Ethereum network has many testnets for developers to
deploy and test their applications

• One of the most famous test networks is called the Kovan


testnet.

• Kovan is a Proof of Authority (PoA)-based Ethereum blockchain


network

• The Kovan testnet is known for its speed of execution,


reliability, and free access to test ethers

• You can read more about the Kovan testnet here: [Link]
[Link]/website/
Choosing the blockchain technology
• Faucet is a piece of software used by smart contract
developers and users to acquire testnet tokens for free

• Kovan is a test network, so it is not intended to be used for


any production-grade Ethereum applications

• If you wish to deploy this example for a live use case, I


recommend that you either use the Ethereum mainnet or
prefer sidechains such as Matic

• If you wish to deploy it live, you can learn more about the
Matic sidechain here: [Link]
Choosing a decentralized database
• Digital contact tracing often involves collecting data.

• To enable accuracy and provide high-quality predictions, more


data could be collected at a high frequency.

• Over time, data can become very large.

• Such data should not be stored on a blockchain directly since it


incurs a high cost,

• May hamper the performance of a blockchain

• Hence, there is a need to store the activity of the animals or


objects in a decentralized database.
Choosing a decentralized database
• We may MóiBit REST API as the decentralized database for
this sample DIApp.

• MóiBit offers a developer-friendly API environment, which


makes it an easy choice.

• MóiBit is an IPFS-based decentralized storage service, each


change to a new file or an existing file generates a new hash

• Updating the data on MóiBit will be cheaper and faster


compared to blockchains

• Visit their documentation at https:// [Link]/.


Choosing an AI technique
• Tracking innumerable objects and animals across an area –
even a small one – will lead to a humongous quantity of data
points.

• It is virtually impossible to perform contact tracing manually


on these data points

• Due to some low-quality data points, the efforts of a manual


contact tracer could easily go to waste.

• As the number of positive cases increases, more pressure


mounts on the manual contact tracers
Choosing an AI technique
• This could also lead to inaccurate identification of infections.

• In order to reduce errors and automate the process of cleaning,


ordering, grouping, and predicting the infections, we can leverage AI
techniques.

• We'll use geospatial analysis to identify some anomalies in the data


points.

• Specifically, we will be using the Density-Based Spatial Clustering of


Applications with Noise (DBSCAN) algorithm to perform geospatial
analysis to identify potential infections among animals and objects

• To learn more about the DBSCAN algorithm, consult the following


Wikipedia article: [Link]
The technical architecture of the sample DIApp
Developing the smart contract
• The design and structure of the smart contract used to record the
proof each time the location history is updated.

• To develop the smart contract by using Solidity language.

• To know Solidity using the web : [Link]

• The solution aims to trace infections that originate from animals and
objects

• Let's assume that each sensor can be identified by a unique Ethereum


wallet address.

• The medical professionals and enforcement teams who may want to


identify the infected actors from a given animal or object
Developing the smart contract
• Each time the sensor has a new location to update on MóiBit, it
makes the update and receives a hash back from MóiBit.

• We are using that hash and the wallet address from the calling
sensor to maintain a mapping on the smart contract.

• Each time a new location coordinate is updated by a sensor, the


corresponding wallet address needs to be updated.

• Hence, we need to define a mapping to record any changes that


are made to the location history of each sensor

• We can do this with the following mapping:


mapping(address => string) private deviceIDToLatestCID;
Developing the smart contract
• From the preceding mapping, we can see that the address
serves as a unique key to an updated string value

• we need another mapping to track all the sensors by their


addresses to confirm they have ever updated their location

• We can achieve this by persisting a list of all the wallet


addresses in the following mapping:
mapping(address => uint256) private deviceIDExists;

• we will record the address of each and every sensor that has
ever updated its history to this smart contract with the
following array of wallet addresses:
address[] private deviceIDs;
Developing the smart contract
• From the preceding array declaration, designated users can
access the list of all the addresses that have ever updated
their location history in the smart contract.

• Do not confuse the deviceIDs array with the deviceIDExists


mapping.

• The array is used to directly access each and every sensor's


wallet address

• Before we move on to the functional aspects of this smart


contract, we have two more declarations: a modifier and an
event.

You might also like