A proof of concept to explore long running processes alongside an Evernode smart contract.
This is a Proof of Concept (PoC) only. It is not intended for production use. Exception handling and security measures have been omitted to keep the code simple and easy to understand. The goal is to demonstrate core technical concepts and functionality as a starting point for further research, development and learning.
This set of three projects demonstrates how an Evernode smart contract can:
- Start a new detached process inside the Docker container it is running in
- Have that process feed results back into the smart contract
The projects use a simple CPU benchmarking application as an example. Here's how it works:
- The client application requests a cluster to perform a CPU benchmark on its UNL instances.
- The smart contract starts the benchmarking app for each UNL (Unique Node List) node of the cluster
- On each node the app measures the execution time of the CPU benchmark
- The results are fed back into the smart contract
- The smart contract consolidates all the results
- It then reports the overall outcome back to the client application
- Allows smart contracts to perform complex, time-consuming tasks off-chain in detached processes
- Demonstrates a pattern for aggregating results from multiple nodes
- Provides a template for building powerful, distributed smart contract applications
The project showcases some of the remarkable features of Evernode smart contracts, which go far beyond simple on-chain logic. By seamlessly integrating detached processes and aggregation, developers can now build highly scalable and capable decentralized applications (dApps) that push the boundaries of what's possible in the blockchain space.
Local hpdevkit
Evernode Cluster
- Clone the repository.
cd
into each of the 3 project directories and runnpm install
.cd
intosmart-contract
directory and runnpm build
.cd
intobenchmark-app
directory and runnpm run prepare
. (This will build the benchmark app and copy the self-contained file into thedist/
directory ofsmart-contract
project. Do this every time after changes were made to thebenchmark-app
.)- With a new console window,
cd
intosmart-contract
, runnpm start
. - With another console window,
cd
intoclient-app
, runnpm start
. (Look intopackage.json
: Thestart
script will use all the default nodes as connection servers. That's important for local usage, since DNS wouldn't help thebenchmark-app
to connect to the cluster.) - Wait a few seconds until results show up in the console window.
- Clone the repository.
cd
into each of the 3 project directories and runnpm install
.cd
intosmart-contract
directory and runnpm build
.cd
intobenchmark-app
directory and runnpm run prepare
. (This will build the benchmark app and copy the self-contained file into thedist/
directory ofsmart-contract
project. Do this every time after changes were made to thebenchmark-app
.)- Deploy the smart contract to an Evernode instance or cluster. Click here for instructions how to do that: Single instance, Cluster
- With another console window,
cd
intoclient-app
,node src/app.js <wss-url:port_of_an_instance>
. (Here a single wss-URL of the cluster should be enough, since it should be accessible for every member of the cluster.) - Wait a few seconds until results show up in the console window.