Coder Social home page Coder Social logo

gcp-development / event-streaming-platform Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 318 KB

Event Streaming Platform (Blockchain)

License: MIT License

Java 100.00%
kafka minikube kubernetes blockchain kafka-streams proof-of-stake event-driven-architecture web3

event-streaming-platform's Introduction

Event Streaming Platform (Blockchain)

Motivation

Blockchain and Kafka are complementary, Kafka and the notion of blockchain share many traits, such as immutability, replication, distribution, and the decoupling of applications. This complementary relationship means that we are able to extend the functionality of a given DLT(distributed ledger technology) through sidechain or off-chain activities, such as analytics, integrations with traditional enterprise systems, or even the integration of certain chains and ledgers. 


Table of Contents


Kafka and Kubernetes

Apache Kafka is frequently deployed on the Kubernetes management system, which is used to automate deployment, scaling, and operation of containers across clusters of hosts. Cloud-native applications are independent, loosely coupled, and distributed services that deliver high scalability via the cloud. In the same way, the event-driven applications built on Kafka are loosely coupled and designed to scale across a distributed hybrid cloud environment.

image

By integrating these technologies, this PoC creates a platform for demonstrate blockchain concepts in a simple and easy way.

Souce Code:


Blockchain

What is Blockchain?

  • Blockchain is a transaction record database that is distributed, permission less and maintained around the world by a network of nodes.
  • Blockchain has a distributed group of nodes that oversee the network.
  • Blockchain uses decentralized technologies to provide peer-to-peer, permissionless, and immutable network to store transactions.

A blockchain network have the following characteristics:

  • No Central Authority
  • Verifiability and Auditability
  • Disintermediation
  • Confidentiality and Integrity
  • Robustness

A blockchain network have the following benefits:

  • No Third-Party Intermediaries
  • Greater Transparency
  • High Availability
  • High Security
  • Faster Dealings and Cost Savings
  • Improved Traceability

Block overview

image

  • Block version, version number of the block.
  • Previous block hash, the hash of the previous block.
  • Merkle tree root hash, Each transaction in the block is hashed and stored in a tree-like structure such that each hash is linked to its parent.
  • nBits, encoding of the block target. A block will be valid only if the hash of its header is below the target value.
  • Nonce, a variable decided by the miner creating the block changed In order to get a block hash under target value.
  • Timestamp, value is a source of variation for the block hash.

Blockchain overview

image

  • Blockchain contains a list of blocks cryptographically connect to the previous block.
  • The blocks are connected such that if there is any change in block(n-1) the connection between the next block will break.
  • This makes very hard to change any data in blockchain.
  • Each block contains set of transactions data that is linked in the next blocks so that anyone can trace the origin of data.
Consensus Mechanism

Validators

In Proof of Stake blockchains, validators are selected to produce the next block based on their stake. Designed with random functions in order to make the selection more fairer,because a larger amount staked by a validator could give them a higher chance of producing the next block. Proposed blocks by validators are then propagated to the rest of the network, who verify and add the approved block to the blockchain. 

Proof of Stake(PoS)

In order to participate in PoS, the validators has to produce some stake. In PoS the validators are selected in terms of some selection algorithm and the amount of stake locked in the network (ParticipantsPool) and only then that selected validator will be allowed to add the block. If the validator founds to be malicious, then they will lose all their stake.


Implementation

image

Transactions Producer

->This Java project will create the transactions for our basic blockchain.

Block Processor

->This Java project will process the transactions and create the new blocks for our basic blockchain.

Blocks Consumer

->This Java project will consume the blocks.

Basic Blockchain

->This Java project this library(JAR) contains the objects that form a basic blockchain.

1) Run the blocks-consumer

As a prerequisite the basic-blockchain project needs to create the JAR which the other projects will use.

Open the blocks-consumer project with Intellij community and run the project.

The listener will subscribe to the blockchain topic to consume any message saved there.

image

For troubleshooting any issue look at the logs generated by the log4j.

image

2) Run the block-processor

Open the block-processor project with Intellij community and run the project.

image

For troubleshooting any issue look at the logs generated by the log4j.

image

3) Run the transactions-producer

Open the transactions-producer project with Intellij community and run the project.

image

For troubleshooting any issue look at the logs generated by the log4j.

image

The transactions-producer project will insert 15 transactions in the transactions topic. This transactions topic is subscribed by the block-processor project and the blocks created inserted in the blockchain topic.

The run windows should look like this.

image

The blocks-consumer project is subscribed to the blockchain topic which will read any message insert into the blockchain topic.

The run windows should look like this.

image

The Blockchain created.

image

Source Code:


References:

Event-Driven
Benchmarking Apache Kafka: 2 Million Writes Per Second (On Three Cheap Machines)
Peercoin Introduction to Proof-of-Stake

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.