banner



How Do I Know Where I'm Registered

k

Nima Kaviani HackerNoon profile picture

@ nimak

Nima Kaviani

Senior Cloud Engineer

Projection 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 involvement in blockchain technology, software developers are looking into integrating smart contracts into their applications. Applications developed and integrated with blockchain are typically equanimous of two parts:

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

A smart contract can be thought of as a snippet of code bachelor 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 normally referred to every bit Web3 applications.

Despite all the excitement in using blockchain, the end-to-finish multi-step procedure of deploying a smart contract and integrating it into a Web application is fairly cumbersome. An awarding developer requires to:

  1. develop or reuse a smart contract
  2. compile the contract lawmaking
  3. call up the executable binary and the application binary interface (ABI)
  4. bring upwardly a blockchain node (e.g., Ethereum)
  5. create or import an account (i.e. Wallet) into the node
  6. use the account to deploy the binary code into the blockchain network
  7. verify deployment and retrieve the contract address
  8. and finally utilize the combination of the account address, the contract address, and the contract ABI in a Web application to bind to the contract and use information technology

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

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

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

Project BlockHead takes reward of the Open up Service Broker API specification to build a service broker layer placed between the Web application and the blockchain network. Doing then, the banker controls management of the smart contract by automating creation and deployment of smart contracts then exposing the required prepare of information to the Web application.

Open Service Broker API

The Open Service Broker API (OSB API) specification offers a mutual interface for the creation and integration of a service market into cloud applications in such a way that services can be maintained and managed independently from the applications and yet applications can easily demark and use services through the exposed APIs. Service brokers are responsible for advertising a catalog of service offerings and service plans to the market, and interim on requests from the market for provisioning, binding, unbinding, and deprovisioning.

Borrowing from the specification of the OSB API, provisioning reserves a resource on a service equally 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 binding provides the service instance with smart contract information for it to be compiled and deployed and become bachelor to the awarding using the service. A platform marketplace may expose services from ane or many service brokers, and an individual service broker may support one or many platform marketplaces using different URL prefixes and credentials. 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 found below:

BlockHead Service Broker

With projection BlockHead, we aim to translate each OSB API call to a series of steps in the lifecycle of the smart contract and thus hibernate the complexity of interaction with a blockchain away from application developers.

The beginning version of the broker is built on top of the Container Service Broker, a Cloud Foundry community project. Past utilizing the container service broker, blockchain nodes tin can be run within an isolated Docker container and operate independently when deploying and binding smart contracts.

We utilize the banker to deploy stateful Ethereum nodes on need. Each step in provisioning and binding or unbinding and deprovisioning are then modified to deliver on creation / deletion of smart contracts or nodes. Picture beneath provides an overall compages for how the Blockhead service broker provisions Ethereum nodes and integrates with the Cloud Foundry applications:

The overall interaction model betwixt the BlockHead service broker and Cloud Foundry applications

ane. 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 way.

In this blogpost we take the BlockHead service broker deployed alongside a Cloud Foundry deployment. This allows us to benefit from capabilities in Cloud Foundry to push 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 environment with Cloud Foundry deployed on information technology, deploying the BlockHead banker is as simple as running the post-obit script:

Since Kubernetes integrates with Open Service Banker API compliant brokers, in case you have a Kubernetes deployment, you can hook upward the deployed BlockHead broker to your Kubernetes platform and bind to deployed smart contracts using Web3 applications deployed to Kubernetes. You lot can find out how to practise the integration with Kubernetes Hither.

2. Service MarketPlace and Contract MarketPlace

For the broker to announced in the Cloud Foundry marketplace you need to first register it using the following command:

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

In one case the banker is registered, you can query the marketplace and yous volition run across the Ethereum service appear in the marketplace:

Further to this, we have also developed a simple contract marketplace that would permit the states to list contracts and and then refer to them using their URL when binding an application to an Ethereum node. To have the contract marketplace deployed, you can add your smart contracts to the marketplace, build the docker image, push it up to a docker registry and then use a command similar to the post-obit to download and use information technology:

cf push contract-market place --docker-epitome nimak/contract-marketplace

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

In our example the market is bachelor at the address beneath and navigating to the accost we can find the website:

Notice on top 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 you have other ways to supply a smart contract URL to the Ethereum service, it would totally work as well.

3. Provision the Service Case

When a asking to provision a service case is issued, the banker starts upward an Ethereum node. The Ethereum node exposes its Remote Procedure Phone call (RPC) api for interactions and makes the endpoints bachelor through a given address and port number.

For the node creation to occur, yous demand to start deploy a Web3 application that is intended to use the smart contract. For the case of this weblog post, we volition be using our simple-node-application that only writes and reads a single value to and from the ledger. Note that since the app does not accept the contract connected to it yet, nosotros practice not start the app when pushing it otherwise the deploy will fail.

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

Adjacent, we create the Ethereum service for the deployed application:

With the request to create the service, the service broker creates a docker container with an Ethereum node running on information technology.

This can be verified with BOSH by connecting to the docker VM in the broker deployment and looking at the list of docker containers it is running (Note that each docker container runs an instance of the Ethereum node that corresponds to the created service).

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

4. Create Service Bounden

When binding to the service, the location of a smart contract in the form of a URL is passed to the banker. The banker downloads the contract, compiles it, 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 market place provides the link to the given contract, and so we can only get the URL location of the contract and demark it to the awarding.

Annotation that when binding the service we pass the contract_url in the form of an inlined JSON configuration to cf bind-service.

With the service bounden going through successfully, we can event a cf env control to see the updated listing of environs 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, every bit well as the host address and port mappings for the application to connect to the Ethereum node.

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

And VOILA! with that data, yous can define routes for you node.js awarding to get and set up values into the ledger using the smart contract:

5. Delete Service Bounden

When unbinding the service, the broker assumes that the contract used during the bind phase is no longer required, equally a consequence, upon receiving an unbind request, the broker detaches the service from the application and removes the injected contract information from VCAP_SERVICES, but keeps the node effectually for information technology to peradventure have other contracts deployed to information technology. Newly deployed contracts volition use the aforementioned Ethereum node with the same account created during the service creation phase.

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

cf unbind-service nora simple

six. Deprovision Service Instance

When a asking is issued to deprovision the service, the service broker gain to delete the docker container:

Challenges and Future Improvement Plans

1. Syncing the Ledger

Like many other blockchain networks, nodes in Ethereum require the full ledger to exist present for subsequent transactions to take effect. This implies that the docker container created by the BlockHead service banker either needs to include the total ledger at the fourth dimension information technology gets created or to sync the ledger later on the container is created. The latter is very time intensive. The ledger size for the mainnet Ethereum is effectually 600GB and growing. Given the ledger size, it would have considerable amount of time for the provisioned Ethereum node to sync its ledger and be ready, making the integration impractical.

An culling solution is for the service broker to maintain a warm docker image with a fairly up-to-date re-create of the ledger to use when creating a service. This requires the banker 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 prototype.

Currently, the service broker launches the Ethereum node in developer mode which implies starting with a fresh ledger. This helps u.s. apace bring up a evolution surround to examination Web3 applications against while fugitive the long wait for ledger syncup. We plan to implement techniques that would permit quick startup of an Ethereum node against the mainnet or testnet for production purposes as well.

2. Retentivity footprint

Syncing the ledger involves reading transaction blocks from other peers in the network, validating them, and and so calculation 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 retentiveness while performing validation and chaining of the nodes earlier writing the new blocks to the disk. This constrains memory usage on the VMs deploying Ethereum nodes and puts an upper jump to the number of containers that can exist run and managed by the banker.

3. Business relationship Management

As mentioned earlier, Ethereum nodes need to bind to an Ethereum account earlier 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 application developers or by allowing the developers to import their own accounts to apply with the broker.

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

Summary

In this blog mail we discussed the implementation of Project BlockHead as a service banker to exist used in PaaS platforms such as Cloud Foundry and Kubernetes. The goal of Project 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-finish procedure of deploying and using the broker, application developers need to only care about Steps 3 to 6 of the process described above. This involves creating a smart contract service and bounden it to an application. Steps 1 and 2 of deploying the service broker and the contract market place would potentially be done only once and typically managed by platform engineers and operations engineers, simplifying the overall process.

Projection BlockHead came near as a hackathon project during Cloud Foundry Height 2018 in Boston and equally yous might have noticed most of the repositories we shared in this blog post are personal github repositories of our team participating in the hackathon. Luckily the project has received good amount of involvement from the community and hopefully in the most hereafter it volition discover a new home every bit an incubated projection and be properly CI/CD-ed. So come back to this blog post for further announcements equally to where you can find the official project repository. It is an open source project and we certainly welcome any contribution to go far meliorate.

Tags

# ethereum# project-blockhead# smart-contract-broker# 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: stevesonapture.blogspot.com

0 Response to "How Do I Know Where I'm Registered"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel