Giter Site home page Giter Site logo

helllyf / ocaml-offchain Goto Github PK

View Code? Open in Web Editor NEW

This project forked from truebitfoundation/ocaml-offchain

0.0 1.0 0.0 8.3 MB

Fork of WebAssembly reference interpreter with support for generating proofs needed for blockchain verification

License: MIT License

Dockerfile 0.01% Shell 0.35% C++ 0.32% Makefile 0.11% OCaml 14.63% JavaScript 2.97% WebAssembly 79.85% Standard ML 0.09% C 0.82% Batchfile 0.47% Python 0.37%

ocaml-offchain's Introduction

Build Status

Installation of the off-chain interpreter

These instructions were tested on Ubuntu 16.04.

First install dependencies

apt-get install -y wget gcc ocaml opam libzarith-ocaml-dev m4 pkg-config zlib1g-dev
opam init -y
eval $(opam config env)
opam install cryptokit yojson ctypes ctypes-foreign

Then go to the interpreter directory of the repo

cd interpreter
make

If the build fails it may be due to an outdated version of ocaml. To upgrade simply run opam switch 4.06.0, and then follow the steps above starting with eval $(opam config env).

This should generate the executable wasm in the interpreter directory.

Testing the off-chain interpreter

./wasm -m ../test/core/fac.wast

If there are no errors, it means that the tests were passed.

./wasm -t -m ../test/core/fac.wast

This command will print the trace messages, it will basically output every instruction that the interpreter runs.

Outputting proofs:

./wasm -case 0 -step 4 -m ../test/core/fac.wast

This will make a proof for step 4 in the computation. Because there are many test cases, one of them has to be selected, so for example -case 0 will select the first test case.

Using the JSON-RPC Server

cd server
npm install
node index.js

A client can communicate with the server like this:

var jayson = require('jayson');

// create a client
var client = jayson.client.http({
  port: 3000
});

// invoke *command* with *args*
client.request('*command*', [*args*], function(err, response) {
  if(err) throw err;
  console.log(response.result);
});

Docker

If you want to run these tests inside of a Docker container you can pull the latest docker image and try it out.

docker run --name tb-offchain -ti hswick/ocaml-offchain:latest`
cd webasm/interpreter
./wasm -t -m ../test/core/fac.wast

License

The license for the test folder is the original Apache 2.0 license.
We have re-licensed the interpreter folder to MIT.
The license for the rest of the repo is MIT.

ocaml-offchain's People

Contributors

rossberg avatar mrsmkl avatar sunfishcode avatar lukewagner avatar terminaldweller avatar jfbastien avatar pjuftring avatar binji avatar andrewscheidecker avatar kg avatar cellule avatar gahaas avatar bnjbvr avatar dschuff avatar ppopth avatar kripken avatar hswick avatar augustushuang avatar lindig avatar naturaltransformation avatar lgalfaso avatar flagxor avatar helllyf avatar vilie avatar mbebenita avatar msprotz avatar jakzale avatar jgravelle-google avatar gstraube avatar choikwa avatar

Watchers

 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.