Giter VIP home page Giter VIP logo

student_22_determ-fp-sc's Introduction





Numerically-Intensive Deterministic Smart Contracts

School of Computer and Communication Sciences
Decentralized and Distributed Systems Lab
BSc Semester Project

June 2022



Presentation - Setup - Author - Thanks

Presentation

This project studies two smart contract applications and compares their implementation on three different execution platforms in terms of efficiency and ease of programming.

You can read our full report here for more details. This project was realized in the context of a BSc semester project in the DEDIS laboratory at EPFL.

Applications

The following applications were chosen as they encompass a wide range of common problems when coding smart contracts. Emphasis was placed on numerically intensive applications that use floating point arithmetic.

1. Revenue Distribution

A generic and flexible version of a revenue distribution application. We present the default naive implementation of such problem as well as a more sophisticated optimized approach. You can check out this paper for more details.

2. Neural Network

An arbitrary complex multilayer perceptron classifier that uses ReLu as activation function and stochastic gradient descent for training. Supports normalization, training and testing as operations on any shape of the network.

Execution Environments

We compared all the aforementioned applications on the following execution environments.

  • Ethereum Virtual Machine (EVM) : on Solidity
  • Web Assembly (WASM) : on C
  • Java Virtual Machine (JVM) : on Java

Setup

You can follow these steps to reproduce our results on every execution environments.

JVM

Maven should take car of all dependencies. Benchmarks can be instrumented to select what application to run, using the JMH framework.

EVM

We used the 0.7.0 version of Solidity compiler (solc). You can run the following commands to benchmark and test our applications.

pip3 install solc-select
solc-select install 0.7.0
solc-select use 0.7.0
cd path-to-Solidity-dir
cd bsol/ && sh install.sh && cd .. && bsol --sol path-to-file --execution-time --runs 1

Note: For this last step to run our instrumented version of Geth and not the original one, you can replace the Geth directory content located at /go/pkg/mod/github.com/ethereum (on your machine) with the content of Solidity/go-ethereum.

Although not very clean, this solution is quick and easy. You are free to create a new package and change the import directives.

You can modify the constants present in the benchmarking code to set the desired benchmarking parameters.

WASM

If necessary, install Emscripten using the following commands.

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install latest
./emsdk activate latest
# Activate PATH and other environment variables in the current terminal (has to be rerun when changing terminal)
source ./emsdk_env.sh

For the neural network application, you can proceed as follows.

cd path-to-neural-network
# This should work on any machine since the files are precompiled on WASM (so no need to build). If this does not work, launch a new emmake build
emcc Simulation.c ClassificationContract.c MatrixNNUtils.c Random.c ./gsl-2.7.1/.libs/libgsl.so.27 PATH/neural_network/gsl-2.7.1/cblas/*.o -I PATH/neural_network/gsl-2.7.1 -lm -s ALLOW_MEMORY_GROWTH=1
# To launch a new emmake build (if the previous command fails)
cd gsl-2.7.1
emmake make

And for the revenue distribution application, you only need to run these commands.

emcc [Non]OptimizedSimulation.c DistributionContract.c hashmap.c -s ALLOW_MEMORY_GROWTH=1

In both cases, you can modify the macros in the source code to set the desired benchmarking parameters.

Thanks

This project has been supervised by EPFL PhD Student Enis Ceyhun Alp, under the responsability of Prof. Bryan Ford.

We would like to express our gratitude for their support and help in the realization of this project.

Author

This work has been realized by EPFL BSc Student Alexis Schlomer. You can contact me for any inquiry using the following email address: [email protected].

student_22_determ-fp-sc's People

Contributors

alschlo avatar

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.