truebitfoundation / ocaml-offchain Goto Github PK
View Code? Open in Web Editor NEWFork of WebAssembly reference interpreter with support for generating proofs needed for blockchain verification
License: Apache License 2.0
Fork of WebAssembly reference interpreter with support for generating proofs needed for blockchain verification
License: Apache License 2.0
Link in the generic external calls and make them work. Also in the file system calls, we have to skip the external calls.
Probably these too have to be implemented:
193. Truncate64
194. Ftruncate64
When initializing, the breaks could be changed into static jumps / stack adjustments.
Currently only one computation can be run on VM at a time
Find out how to compile something from C or Rust to webasm, and then test if it works with the interpreter.
wasdk generated something with setTempRet0, hopefully this won't have to be implemented.
wasdk seems to compile filesystem.c to a simple wasm file. This file should be merged to the actual file to be executed, also some linking has to be done when importing builtins.
Make sure that it is implemented correctly.
Had the idea of turning this into a JSON RPC Server like Parity or Geth.
Then we write software that can act as a client.
Benefits:
Easier installation for other projects that depend on this (webasm-solidity, coindrop, etc)
Allow us to write client in any language(s) we want
Easier to document the API
There seems to be some kind of .data
file.
Probably what needs to be done is that there are builtin functions for keeping track of file descriptors, and instructions that can be used to read and write to some kind of data block.
We have to be able to load these binary files, and then run them, for example main
function or something.
These are the syscalls that should not be implemented, the output from recorded system calls can be used instead.
20. Getpid: skip
55. Setpgid: skip
64. Getpid: skip
65. Getpgrp: skip
77. Getrusage: skip
102. Socketcall: skip?
122. Uname: skip?
132. Getpgid: skip
147. Getsid: skip
191. Ugetrlimit: skip
195. Stat64: skip?
196. Lstat64: skip?
197. Fstat64: skip?
205. Getgroups32: skip
208, 210. Setresuid32, setresguid32: skip
209, 211. Getresuid, getresgid: skip
268. Statfs64: skip?
269. Fstatfs64: skip?
300. Fstatat: skip?
340. Prlimit64: skip
320. Utimensat: skip
But for example in stat, we should perhaps check that the file exists, and has correct size.
Figure out of to add external functions that can be used to access the data posted from blockchain.
Find out how the special function for input can be called from C.
Implement emscripten_memcpy_big
Currently the specification of the task is the hash of the initial state. Because of this, when a task is posted as wasm file, it has to be associated with an initial state hash. Then the solvers and verifiers can check if the wasm file and the initial state match.
There is a problem if the wasm file and the initial state do not match. The whole initial state could be posted instead, but it might be several times larger than the wasm file (if decoding the instructions is not implemented in solidity).
Solution alternatives:
The second alternative is easier, for example the ocaml runtime can be compiled into wasm: https://github.com/sebmarkbage/ocamlrun-wasm
The following system calls just need simple stubs. They could be handled using the generic system calls, but it will be more efficient to add stubs.
29. Pause:nothing to implement
34. Nice: nothing to implement
35. Sync: nothing to implement
42. Pipe: nothing to implement
51. Acct: nothing to implement, but what is it?
66. Setsid: nothing to implement
75. Setrlimit: nothing to implement
96. Getpriority: nothing to implement
97. Setpriority: nothing to implement
104. Setitimer: nothing to implement
114. Wait4: nothing to implement
118. Fsync: nothing to implement?
121. setdomainname: nothing to implement
125. Mprotect: nothing to implement
148. Fdatasync: Nothing
150. Mlock: nothing
151. Munlock: nothing
152. Mlockall: nothing
153. Munlockall: nothing
163. Mremap: nothing
199, 200, 201, 202: getuid32, getgid32, geteuid32, getgid32: nothing
203, 204, 213, 214. Setreuid32, setregid32, setuid32, getuid32: nothing
218. Mincore: nothing
219. Madvise: nothing
265. Clock_nanosleep: nothing
272. Fadvise64: nothing
299. Futimesat: nothing
303. Linkat: nothing
308. Pselect: nothing
331. Pipe2: nothing
Do we wanna do a windows CI for the repo as well?
Add automated testing.
Research different merkle tree's for best performance
This would increase performance
When setting up globals table, handle importing globals.
Instead of having initialized memory and tables, just have some instructions that will initialize the state.
Some test cases need to invoke the modules many times. Currently this is not supported.
Command line arguments should be allocated with malloc
, initialized, and then passed to main
as arguments.
There must be a cleaner way to implement them.
We need to license the repo properly.
The original repo's license for the interpreter and test folder are Apache V 2.0. i guess it should be fine to relicense it to MIT since its Apache. any thoughts?
Some of these might be easy to implement, but directory handling might be complex.
9. Link (not implemented?)
10. Unlink (remove files?)
12. Chdir, perhaps need something for keeping track of current directory, it will be similar to command line arguments
38. Rename
39. Mkdir: how to implement directories?
40. Rmdir
83. Symlink: how to handle?
133. Fchdir
183. Getcwd
220. Getdents
296. Mkdirat
301. Unlinkat
302. Renameat
304. Symlinkat
Some of these already have initial implementations
3. Read
4. Write
5. Open
6. Close
41. Dup: just open with new descriptor
63. Dup2: what does it do?
140. Llseek
145. Readv
146. Writev
180. Pread64
181. Pwrite64
295. Openat
330. Dup3
333. Preadv
334. Pwrited
i went through similar instructions on High Sierra:
brew install opam ocaml
opam init -y
eval $(opam config env)
opam install cryptokit yojson
Then encountered this error when executing make
to build wasm:
# Error: This expression has type bytes but an expression was expected of type
# string
Add some memory elements. Perhaps can be done at the same time as configuring globals.
This is needed because the emscripten JS runtime does some memory initialization.
These can probably be skipped for now
15. Chmod. Should we store file owners etc? At least not in input block, perhaps in a configuration file
94. Fchmod
198. Lchown
207. Fchown32
212. Chown32
298. Chownat
306. Fchmodat
Hopefully can be skipped
142. Newselect: do we have to implement something?
168. Poll: do we have to implement?
This would speed up hashing capabilities
Get the VM memory size etc. from command line or a configuration file instead of hard coded parameter.
After RPC Server is implemented, we can open up a port on the docker container to make installation/use a breeze
Add instructions for output. Should be quite similar to input instructions. But there might have to be an instruction that creates a new file with a given size.
When the program exits, the file system should be output to storage.
Linking imported functions has to be implemented properly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.