banner



How Do I Know What I'm Registered As

m

Nima Kaviani HackerNoon profile picture

@ nimak

Nima Kaviani

Senior Deject Engineer

Project BlockHead: An Ethereum Smart Contract Service Broker for Kubernetes and Cloud Foundry

This blogpost is co-authored by Swetha Repakula , morgan bauer , and Jonathan Berkhahn

With the growing interest in blockchain engineering science, software developers are looking into integrating smart contracts into their applications. Applications adult and integrated with blockchain are typically composed of two parts:

  • A smart contract deployed to the blockchain network
  • A Web application that binds to the deployed contract and uses it.

A smart contract tin be thought of every bit a snippet of code available at a given accost in the blockchain network which is capable of receiving and processing input data, retrieving or updating ledger state, and returning results to the requesting party. The web applications using the contract are commonly referred to as Web3 applications.

Despite all the excitement in using blockchain, the end-to-cease multi-step process of deploying a smart contract and integrating it into a Spider web application is adequately cumbersome. An application programmer requires to:

  1. develop or reuse a smart contract
  2. compile the contract code
  3. retrieve the executable binary and the awarding binary interface (ABI)
  4. bring up a blockchain node (e.one thousand., Ethereum)
  5. create or import an account (i.due east. Wallet) into the node
  6. employ the account to deploy the binary code into the blockchain network
  7. verify deployment and retrieve the contract accost
  8. and finally utilize the combination of the account address, the contract address, and the contract ABI in a Spider web application to bind to the contract and employ it

In that location have been efforts to simplify the process of developing smart contracts. Truffle, for case, offers a development framework that brings up a local Ethereum network and allows developers to test-drive development of their smart contract applications.

Yet, when it comes to a deployment to the main Ethereum network (mainnet) or a test network (testnet), developers still need to manually go through the process of provisioning a blockchain node to ensure successful deployment and integration of their contracts with their applications.

Every bit open source platform engineers, nosotros strive to simplify the procedure of application development for software engineers. Platform-every bit-a-Service (PaaS) exists on the premise of making it easier for developers to deploy, scale, and manage their applications; and platforms like Kubernetes and Deject Foundry have come a long way in simplifying application lifecycle management. Following the same premise, nosotros believe PaaS platforms tin can and should simplify evolution of smart contract applications and arrive integral to the lifecycle of smart contract applications deployed to PaaS. This is why projection BlockHead was born.

Projection BlockHead takes advantage of the Open Service Broker API specification to build a service broker layer placed between the Spider web application and the blockchain network. Doing and so, the broker controls direction of the smart contract by automating creation and deployment of smart contracts and so exposing the required fix of data to the Web application.

Open up Service Broker API

The Open Service Banker API (OSB API) specification offers a common interface for the cosmos and integration of a service market into deject applications in such a fashion that services tin be maintained and managed independently from the applications and yet applications tin can easily demark and use services through the exposed APIs. Service brokers are responsible for ad a itemize of service offerings and service plans to the market place, and acting on requests from the marketplace for provisioning, bounden, unbinding, and deprovisioning.

Borrowing from the specification of the OSB API, provisioning reserves a resource on a service as an instance. In the context of the BlockHead broker, the service instance represents a blockchain node connected to the blockchain network. What a binding represents may also vary by service. Creation of a bounden provides the service instance with smart contract information for it to be compiled and deployed and become available to the application using the service. A platform marketplace may betrayal services from i or many service brokers, and an private service broker may back up one or many platform marketplaces using different URL prefixes and credentials. Motion picture higher up shows an example of interaction with the service broker API to provision a service."

More details on how to interact with a service broker can be constitute below:

BlockHead Service Banker

With projection BlockHead, nosotros aim to translate each OSB API call to a series of steps in the lifecycle of the smart contract and thus hide the complexity of interaction with a blockchain abroad from awarding developers.

The first version of the broker is built on tiptop of the Container Service Broker, a Deject Foundry community projection. By utilizing the container service broker, blockchain nodes can be run inside an isolated Docker container and operate independently when deploying and bounden smart contracts.

We employ the broker to deploy stateful Ethereum nodes on need. Each step in provisioning and bounden or unbinding and deprovisioning are and so modified to evangelize on creation / deletion of smart contracts or nodes. Picture below provides an overall compages for how the Blockhead service broker provisions Ethereum nodes and integrates with the Cloud Foundry applications:

The overall interaction model between the BlockHead service banker and Cloud Foundry applications

1. Deploying the Broker

The initial version of the BlockHead broker is published as a BOSH release. A BOSH release is a versioned collection of configuration properties, configuration templates, startup scripts, source code, binary artifacts, and anything else required to build and deploy software in a reproducible style.

In this blogpost we accept the BlockHead service broker deployed alongside a Cloud Foundry deployment. This allows us to benefit from capabilities in Cloud Foundry to push button Web3 applications and demark them to the contract service. For instructions on how to deploy Deject Foundry consult the documentation below.

Once you take a BOSH deployment surroundings with Cloud Foundry deployed on it, deploying the BlockHead broker is as simple as running the following script:

Since Kubernetes integrates with Open Service Banker API compliant brokers, in instance you accept a Kubernetes deployment, you can hook up the deployed BlockHead broker to your Kubernetes platform and bind to deployed smart contracts using Web3 applications deployed to Kubernetes. Y'all tin find out how to do the integration with Kubernetes HERE.

ii. Service Market place and Contract MarketPlace

For the broker to appear in the Cloud Foundry marketplace you lot need to starting time register information technology using the post-obit control:

                bosh run-errand -d docker-banker broker-registrar              

One time the broker is registered, you can query the marketplace and you lot will see the Ethereum service appear in the market:

Further to this, we have also adult a simple contract market that would allow united states to list contracts and then refer to them using their URL when binding an application to an Ethereum node. To have the contract marketplace deployed, yous can add together your smart contracts to the marketplace, build the docker image, push it up to a docker registry and then employ a command similar to the following to download and use it:

cf push button contract-market place --docker-image nimak/contract-market place

You tin verify that the application is upwardly and running by checking cf apps:

In our instance the marketplace is bachelor at the address below and navigating to the address we can find the website:

Notice on pinnacle of each contract definition there is a hyperlink reference to the lawmaking for the contract. This contract URL is what we use to bind the service to the application and deploy the contract. Note that deploying the contract marketplace is optional and if y'all have other means to supply a smart contract URL to the Ethereum service, it would totally work as well.

3. Provision the Service Instance

When a request to provision a service instance is issued, the broker starts up an Ethereum node. The Ethereum node exposes its Remote Procedure Call (RPC) api for interactions and makes the endpoints available through a given address and port number.

For the node creation to occur, you lot need to beginning deploy a Web3 application that is intended to employ the smart contract. For the case of this blog post, we will be using our simple-node-awarding that simply writes and reads a single value to and from the ledger. Note that since the app does non have the contract continued to it notwithstanding, we do non start the app when pushing it otherwise the deploy volition fail.

Verify that application nora is pushed to your Deject Foundry deployment:

Next, nosotros create the Ethereum service for the deployed awarding:

With the asking to create the service, the service broker creates a docker container with an Ethereum node running on it.

This can be verified with BOSH by connecting to the docker VM in the banker deployment and looking at the listing of docker containers information technology is running (Annotation that each docker container runs an example of the Ethereum node that corresponds to the created service).

You lot meet that the Ethereum node has its server running on port8545 which is mapped to port32771 externally and on the host vm.

four. Create Service Bounden

When binding to the service, the location of a smart contract in the form of a URL is passed to the broker. The broker downloads the contract, compiles information technology, extracts the ABI and pushes the binary to the Ethereum node using the business relationship created at the time of launching the service.

We mentioned earlier that the sample contract marketplace provides the link to the given contract, so we can only get the URL location of the contract and demark information technology to the application.

Notation that when binding the service we pass the contract_url in the course of an inlined JSON configuration to cf demark-service.

With the service binding going through successfully, we can issue a cf env control to see the updated list of environment variables for the awarding.

Under VCAP_SERVICES the configuration for eth involves credentials data for the eth_node such as contract abi, account address, contract address, transaction hash for the deployed contract, also as the host address and port mappings for the application to connect to the Ethereum node.

Going back to the sample node awarding referenced earlier, you lot meet that the lawmaking in the application uses these environment variables to be able to bind to the smart contract and use it.

And VOILA! with that information, you can define routes for you node.js application to get and ready values into the ledger using the smart contract:

5. Delete Service Binding

When unbinding the service, the broker assumes that the contract used during the bind phase is no longer required, as a event, upon receiving an unbind request, the broker detaches the service from the application and removes the injected contract data from VCAP_SERVICES, but keeps the node around for information technology to mayhap take other contracts deployed to information technology. Newly deployed contracts will use the aforementioned Ethereum node with the same account created during the service creation stage.

In case of our running instance, the following control would unbind the contract:

cf unbind-service nora simple

6. Deprovision Service Case

When a asking is issued to deprovision the service, the service banker proceeds to delete the docker container:

Challenges and Future Improvement Plans

one. Syncing the Ledger

Like many other blockchain networks, nodes in Ethereum require the total ledger to be present for subsequent transactions to accept result. This implies that the docker container created by the BlockHead service broker either needs to include the total ledger at the time it gets created or to sync the ledger afterward the container is created. The latter is very time intensive. The ledger size for the mainnet Ethereum is around 600GB and growing. Given the ledger size, it would take considerable amount of fourth dimension for the provisioned Ethereum node to sync its ledger and be fix, making the integration impractical.

An alternative solution is for the service banker to maintain a warm docker image with a fairly upwards-to-engagement copy of the ledger to utilize when creating a service. This requires the broker to run a side node that constantly syncs its ledger with the ledger for the Ethereum network and to periodically create and publish an Ethereum node docker epitome.

Currently, the service broker launches the Ethereum node in developer mode which implies starting with a fresh ledger. This helps usa quickly bring up a development surroundings to test Web3 applications against while avoiding the long look for ledger syncup. We plan to implement techniques that would allow quick startup of an Ethereum node confronting the mainnet or testnet for product purposes also.

two. Memory footprint

Syncing the ledger involves reading transaction blocks from other peers in the network, validating them, then adding them to the local copy of the ledger. Since writing to the disk is I/O intensive, an Ethereum node maintains a subset of the ledger in retention while performing validation and chaining of the nodes before writing the new blocks to the disk. This constrains retentivity usage on the VMs deploying Ethereum nodes and puts an upper bound to the number of containers that tin can be run and managed by the broker.

3. Account Direction

As mentioned earlier, Ethereum nodes need to bind to an Ethereum account before being capable of deploying contracts. This implies that the broker either needs to manage Ethereum accounts by both internally creating and and then exposing them to the awarding developers or past allowing the developers to import their own accounts to use with the broker.

Currently accounts get discarded upon deleting the smart contract service and the corresponding Ethereum node. This volition be revised for the accounts to be exportable / downloadable.

Summary

In this weblog mail we discussed the implementation of Project BlockHead equally a service broker to be used in PaaS platforms such as Cloud Foundry and Kubernetes. The goal of Projection BlockHead is to simplify how smart contracts are deployed and used in Web3 applications by taking away the complexity of deploying and managing blockchain nodes.

While we described the stop-to-end procedure of deploying and using the broker, application developers need to only care about Steps 3 to 6 of the procedure described above. This involves creating a smart contract service and bounden it to an awarding. Steps 1 and ii of deploying the service banker and the contract marketplace would potentially be done only in one case and typically managed past platform engineers and operations engineers, simplifying the overall process.

Project BlockHead came about as a hackathon project during Cloud Foundry Pinnacle 2018 in Boston and as you might take noticed virtually of the repositories we shared in this blog post are personal github repositories of our squad participating in the hackathon. Luckily the project has received good amount of interest from the community and hopefully in the well-nigh future it will find a new home equally an incubated project and exist properly CI/CD-ed. So come back to this web log post for further announcements as to where you can find the official project repository. It is an open source project and we certainly welcome any contribution to get in better.

Tags

# ethereum# project-blockhead# smart-contract-banker# smart-contracts# kubernetes

Related Stories

Source: https://hackernoon.com/project-blockhead-an-ethereum-smart-contract-service-broker-for-kubernetes-and-cloud-foundry-88390a3ac63f

Posted by: thornecovioll59.blogspot.com

0 Response to "How Do I Know What I'm Registered As"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel