Background

Blockchain technologies have revolutionized different industries and impacted the lives of millions around the world. The most common use case for Distributed Ledger Technology (DLT) is the transfer of value from one account to another, solving the problems like the Bizantine Fault or Double Spending with a network of computers spread around the world.

The second blockchain generation enabled digital asset programmability within its network, bringing tokenomics and NFT. However, data processing and storage within those systems remained limited.

The Theta Network, a third-generation blockchain, enables decentralized data delivery with high transaction throughput using distributed nodes, with video streaming at its core functionality. Thanks to Smart Contracts and theta nodes' technical requirements, it is possible to deploy the first proof-of-concept Theta Edge Marketplace.

Repository: https://github.com/rval735/ThetaEdgeMarketplace

Webpage: https://thetaedgemarketplace.on.fleek.co

IPFS Explorer: https://explore.ipld.io/#/explore/QmX3pGBAQE6PQiPtd38T2FRi9i59E9CsgK6nVMhV6xJ8Yy

Long video (30min - Pass: thetahackaton): https://www.dailymotion.com/video/x80g1ic

Blockchain + DNN + IoT = Theta Edge Marketplace

Deep Neural Networks (DNN) are another disruptive technology that can automatize cognitive actions previously exclusive of humans : image recognition, audio noise reduction or natural language processing.

Given the explosive model size DNN have taken over the years, their development has taken multiple approaches to make them faster, more accurate or power efficient. One technique is the quantization of values for weights, activations, inputs or outputs.

Growth of the common DNN Fig 1. Growth of typical DNN models with millions of connections.

The last quantization frontier is a binary state (0 or 1), creating a Binary Neural Network (BNN). By taking weights and biases values to the lowest denominator, BNN reduces the memory footprint, with mostly bitwise operations promotes model compression, further explored by Review of Binarized Neural Networks. A drawback of BNN compared to continuous DNN is the reduced accuracy when tested on Image Classification tests.

Most research around BNN has focused on the translation of backpropagation, an algorithm designed for floating-point values, to engage with discrete sequences; such transformation exacerbates instabilities at training time.

When typical DNN require extensive feature-engineering to deploy on cloud GPU clusters , this project uses a different type. It employs evolutionary procedures to train diverse DNN, and particularly BNN. This shift allows asynchronous distributed CPUs to test code while working together to reach a solution. Previous research has shown how evolutionary procedures can help to overcome local minima.

Exploration Mechanics Fig 2. Exploration mechanics used in evolutionary algorithms compared to single entity gradient descent.

Contribution

This project is a proof-of-concept named Theta Edge Marketplace: a Decentralized Application (DAPP) that bridges Blockchain and Distributed Computation, implementing BNN training. Using smart contracts, a user can submit a task to the Theta Network, then encourage those with sufficient resources to solve tasks and use IPFS to upload their results. Fig. 3 shows the general idea.

Theta Edge Marketplace Overview Fig 3. Theta Edge Marketplace Overview with future applications running on top of the technology stack using IPFS and the Theta network.

The first deployment over the Theta Edge Marketplace is a Neuro-evolved BNN distributed across multiple compute nodes. It enables task distribution among participating nodes, thanks to embarrassingly parallelizable principles based on evolution. As an application of such deployment, the network learns to encrypt data. Fig. 4 demonstrates the general process from start to finish.

Step by Step Fig 4. Task resolution inside the Theta Edge Marketplace "Step by Step".

This IPFS webpage host this project DApp using the Theta Developer Network. It employs distributed storage for the DApp, to increase its resilience and aim for a censorship-resistant service.

Process Offloading

Training of typical DNN requires a lot of feature engineering when it distributes the workload among many nodes with large GP-GPU installed on them, forcing abstraction layers to simplify task parallelization.

Nonetheless, there are alternative procedures that employ evolution to create dynamic models adapted to particular tasks. Fig. 5 shows one BiSUNA agent that fabricates multiple models using "evolutionary routines".

Dynamic model creation Fig 5. One agent example evolving solve a task with better rewards

Because agents do not depend on each other, the training process is embarrassingly parallelizable. With the contribution from multiple users, it is possible to find the best solution for a problem. In this particular case, an encryption system as skillful as human-made cryptographic protocols (current publication under review).

Provided by the Theta Network and its Edge Compute capabilities, it is possible to offload model search to multiple nodes and find the most optimal solution to this problem. Fig. 6 shows multiple BiSUNA agents that create a Neuro encryption system, a task performed by each Theta node.

Encryption-Decryption Fig 6. Theta nodes searching for the best BiSUNA agents

Taking this project further, it seeds the possibility to produce a decentralized marketplace: A location where developers and researchers can submit heavy-duty tasks to multiple network participants. Encouraged by the TFuel embedded in the smart contract, users submit the results and receive rewards.

Software Artifacts

This project employs multiple technologies for the frontend, backend and task distribution:

Frontend:

Backend:

Task Distribution:

Currently, running the BNN task requires a macOS or Linux environment to execute. Fig. 7 shows the different artifacts and how they interact with each other.

Software used to create the Theta Edge Marketplace Fig 7. Software used to create the Theta Edge Marketplace

Accomplishments

Create from scratch a DApp using the Theta SDK, Truffle and React, then connect events with IPFS for the webpage, task upload and data retrieval. Also, accommodate the BiSUNA framework to report data for easier management of best results, something the framework did not initially do.

This project allowed training Binary Neural Networks in a distributed fashion using the power of multiple Theta nodes, incentivized by the possible first place in the table of submissions and the TFuel attached to each task. Smart contracts enforce funds transfer to the user of accepted submitted results.

Given the Theta Network architecture, transaction fees remain low and users can submit multiple solutions to improve the response quality. In this particular case, the BNN creates from scratch an OTP encryption system. Fig. 8 shows an screenshot of the BiSUNA agents encrypting images in the task distributed in this project using the Theta Edge Marketplace.

Results of encrypting images Fig 8. Results of encrypting images using BiSUNA Agents and their corresponding scores

Challenges

The first challenge was to learn JS, given that the author has been a C++/Swift developer in the past. Then transfer that knowledge to the async JS nature used in Truffle with React modules.

After that, learn Solidity to modify the example contract provided by the "Theta edge compute" to serve multiple clients creating tasks and providing solutions to those tasks.

Finally, put everything together in a barebones Web3 DApp served over IPFS. Lots of learning for sure. Fig. 9 has a screenshot of the alpha version.

Screenshot of the webpage Fig 9. Screenshot of the webpage with tasks and solutions registered

Conclusion

Thanks to the Theta Hackaton, the idea of spreading computation over heterogeneous nodes is possible. Facilitated by the Theta blockchain, it is possible to register results and receive rewards using a censorship-resistant system, skipping registration to a centralized cloud provider.

This project establishes a bridge between DLT, Distributed Computation and DNN, an objective with ongoing interest by the developer community.

The example task novelty allowed the creation of diverse encryption systems using neuroevolved BNN trained from zero nodes. It remains an area of active research that requires scrutiny from the scientific community; nonetheless, it is a breakthrough worth consideration.

Finally, this project could be a catalyst for other developers to deploy tasks using a bounty system tracked using the Theta Network, without intermediaries or costly cloud platforms. Everything is setting up for a decentralized super-intelligence platform.

Future work for the Theta Edge Marketplace

This project is just the proof-of-concept that brings forward a decentralized marketplace for distributed computation using the Theta Network. Even in its roadmap, Theta developers will integrate more functionality to simplify this same process, as shown with the Folding@Home initiative.

The first step to move from proof-of-concept to a beta version, the user experience would be under review, to integrate any task with the "Theta Edge Compute" SDK. It would simplify assignment approval and submission.

A change from beta to minimum-viable-product, the utilization of Zero-Knowledge Proofs would allow private data computations. It would attract clients with sensitive information to deploy tasks on the Theta Edge Compute Market.

By taking advantage of the hackathon price, this project can become a ´´killer app´´ for enterprises and research institutions looking to distribute workloads among multiple users without a centralized platform.

The future is very bright for DApps running on the Theta Network.

Hackaton extension

With the initial deadline, the project only used a Theta Private Key to retrieve data from the account and interact with the smart contract. That is a security risk.

Having the deadline for the hackathon extended, I worked to integrate the Theta Wallet Connect (TWC) to simplify the user experience and provide an alternative workflow to interact with the Theta Edge Marketplace. Fig. 10 & 11 showcase this improvement:

Using Theta Wallet Connect Fig 10. Using Theta Wallet Connect to get account details

Theta Wallet Connect smart contract Fig 11. Theta Wallet Connect Smart Contract interaction

To reach this state, the TWC javascript library had to be modified. It is because version 0.0.18 has bugs that prevent its correct use. The Theta team could use those changes to improve the library located in the open source repository.

Bio

R V is a Ph.D. student in his last year of studies developing BiSUNA. It is an alternative algorithm to train and deploy binary and continuous neuroevolved networks.

His financial survival in the 2020-2021 COVID year relies on donations to continue this framework development; visit the GitHub repository to check his crypto address if you enjoyed this post and would like help with anything that you can 😉.

Acronyms

DLT: Distributed Ledger Technology

NFT: Non-fungible tokens

IoT: Internet of Things

DNN: Deep Neural Network

BNN: Binary Neural Network

GPU: Graphics Processing Unit

GPGPU: General Purpose GPU

CPU: Central Processing Unit

DApp: Decentralized Application

OTP: One Time Pad

IPFS: InterPlanetary File System

ZKP: Zero-Knowledge Proofs

Built With

+ 7 more
Share this project:

Updates