truebitfoundation / webasm-solidity Goto Github PK
View Code? Open in Web Editor NEW[DEPRECATED] On-chain interpreter for WebAssembly written in Solidity
License: MIT License
[DEPRECATED] On-chain interpreter for WebAssembly written in Solidity
License: MIT License
Perhaps the tasks should have a reference to the judge they use.
Put stuff to different directories.
If the verifier tries to get the state of a program after n steps, and there were not really n steps, currently there would be no result at all.
To be sure that on-chain and off-chain interpreter always match, the off-chain interpreter should also be implemented in Solidity. For this, some refactoring is first needed.
Some ideas:
https://github.com/TrueBitFoundation/webasm-solidity/wiki/Memory-abstraction
Add this to the user interface (app.html) and make corresponding changes in app.js
Noticed that the deleteChallenge method in interactive is public and doesn't include any requires. need to change this.
Check that the interpreter always fails if the hint is incorrect.
The task giver needs to be able to set the VM parameters like how much memory is available, stack size etc.
Then there has to be a way to build the initial state from these parameters.
Before a normal wasm task is submitted there can also be a preprocessing step. This preprocessing can involve a pipeline
-Preprocess code (initialize wasm task)
-Floating point
-Metering
-Linking (Optional)
Each of these steps could use their own verification games, or they can be combined into one game (aka the pipeline task). This single pipeline task can simply return the root hash of the preprocessed files.
In the case where a verifier challenges a task, and that task uses the preprocessing step, a verifier will dispute the preprocessing task first. Then once that passes, the game will carry on to the normal wasm task dispute.
Need to be able to timeout if a task doesnt get solved for a period of time
Need to be able to timeout if the solver doesnt post solution in time
Find out if there already is a good mechanism for loading data to blockchain without using too much gas.
At the moment, the solidity offchain interpreter isn't able to generate the proofs that are needed for running the onchain version.
Solidity compiler gives this type of warning quite a bit.
fs.sol:52:20: Warning: This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data.
I believe this is a breaking change in 0.5.0, so it would be good to change this sooner than later.
Right now the wasmInterpreterPath is expected to be ../ from the cwd. It would be best to be able to input the path as a parameter somewhere.
Perhaps splitting up the merkle-computer file into compute, and utils might make this easier.
Needs some changes to proof generation.
Making sure that the state posted by the solver is really final, or execution ended with error.
Test and implement the handling run time errors properly.
Add automated testing.
Going to implement these after they are working in the offchain intrepreter.
Need to test the following cases:
What is blocking this at the moment:
Currently travis only runs this test https://github.com/TrueBitFoundation/webasm-solidity/blob/master/test/judge.js
We need to add continuous integration support for the newly added tests such as:
test/task-lifecycle.js
test/task-lifecycle-ipfs.js
test/task-alphabet.js
test/task-alphabet-challenge.js
This will also involve adding ipfs to travis because all the tests above (beside task-lifecycle) depend on it.
Each floating point opcode should be changed into a function call. These functions implement the floating point ops with integer ops and use a fixed amount of steps, so they can be skipped by the interpreter.
Perhaps first it will be easiest to just pre-process it and always run the functions without skipping.
for example, when i run
./wasm -m -memory-size 16 -stack-size 14 -table-size 8 -globals-size 8 -call-stack-size 10 -case 0 ./factorial.wast -output
off-chain, it may show that
{"vm": { "code": "0x4ce57322d69eb9f405acdc0d13174b14595414a75df8c458a5e7c68739bb5f78", "stack": "0xd37da133d3b660a1aa6bdfe5f7f7a805c1ce5ce693da5138065878648e015319", "memory": "0x2733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981f", "input_size": "0xf9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5", "input_name": "0xf9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5", "input_data": "0xe026cc5a4aed3c22a58cbd3d2ac754c9352c5436f638042dca99034e83636516", "call_stack": "0x6b2a56fef280042cd8f791b2b1d47198ee5a21cfb40cc8c13e7adb5dab2db3b7", "globals": "0x9867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756af", "calltable": "0x9dc25e3b944260e342d33236a1c3aba8c451c07733651c561e0a53b843757217", "calltypes": "0x9867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756af", "pc": 1099511627775, "stack_ptr": 1, "call_ptr": 0, "memsize": 0 }, "hash": "0xb54475a73855987df7992919637f0bcbc8a434a03d77f903960f269f8b254ee7", "steps": 499, "files": []}
how can i get the task output result? thanks a log
Use inheritance to split it up to more manageable pieces.
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received -1362828628
at checkInt (internal/buffer.js:35:11)
at writeU_Int32BE (internal/buffer.js:625:3)
at Buffer.writeUInt32BE (internal/buffer.js:638:10)
at WebSocketFrame.toBuffer (D:\HJ\Projects\WAGON\webasm-solidity-master\node_modules\websocket\lib\WebSocketFrame.js:257:24)
at WebSocketConnection.sendFrame (D:\HJ\Projects\WAGON\webasm-solidity-master\node_modules\websocket\lib\WebSocketConnection.js:852:43)
at WebSocketConnection.fragmentAndSend (D:\HJ\Projects\WAGON\webasm-solidity-master\node_modules\websocket\lib\WebSocketConnection.js:788:14)
at WebSocketConnection.sendUTF (D:\HJ\Projects\WAGON\webasm-solidity-master\node_modules\websocket\lib\WebSocketConnection.js:728:10)
at W3CWebSocket.send (D:\HJ\Projects\WAGON\webasm-solidity-master\node_modules\websocket\lib\W3CWebSocket.js:116:26)
at WebsocketProvider.send (D:\HJ\Projects\WAGON\webasm-solidity-master\node_modules\web3-providers-ws\src\index.js:223:21)
at Timeout._onTimeout (D:\HJ\Projects\WAGON\webasm-solidity-master\node_modules\web3-providers-ws\src\index.js:203:19)
at ontimeout (timers.js:427:11)
at tryOnTimeout (timers.js:289:5)
at listOnTimeout (timers.js:252:5)
at Timer.processTimers (timers.js:212:10)
this error occured with createContract("Judge")
Judge.bin file is to heavy
how can I finish this work?
Try to find out the state of the verification game, and act accordingly.
There could be some kind of instruction that would trigger another verification game. For example there could be a function to execute another wasm program inside the wasm programs.
when running sh compile.sh
with solc 0.4.19 i get the following error and warnings:
fs.sol:126:43: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
function debug_forwardData(bytes32 id, address a) public returns (uint) {
^-------^
fs.sol:126:4: Warning: Function state mutability can be restricted to view
function debug_forwardData(bytes32 id, address a) public returns (uint) {
^
Spanning multiple lines.
Error: Documented parameter "limit
@param" not found in the parameter list of the function.
Need to find out how to handle signing messages.
Implement popcnt, ctz and clz operations in Solidity.
Also other operations have to be checked properly.
Implement downloading data from blockchain in the test node
Was running through the README and was able to run deploy-tasks.js with parity chain dev to create the config.json. But when I try to run app.js it gives a JSON error.
This is because deploy-tasks.js is outputting two json objects, instead of one, like app.js expects.
{ "interactive": "0x4d06047ed426e2a2f0bbe86cee268200d20b8d62", "tasks" : "0xcfa55b9b5c1c05e81a7f306a841ae6f3b489d057" }
{ "interactive": "0x7a0d30234e146a88cd65f0714ab7603b0568b16a", "tasks" : "0x6ec4905ff2bfbb1ee8f4c11006ef528df4d30b80" }
I can go in the file and delete the second object and then the app works.
There should be a way to run the WASM tests using the Solidity offchain interpreter.
Probably these lengths have to be a part of the global state ...
Make sure we do not get stuck when trying to load IPFS files.
https://github.com/TrueBitFoundation/webasm-solidity/blob/master/contracts/interactive.sol#L124
https://github.com/TrueBitFoundation/webasm-solidity/blob/master/contracts/interactive.sol#L127
Should just revert when not successful because it makes it seem like the tx went through
Should be deleted because if you don't have the proper data then there is a more underlying fault that probably wont be able to mended.
finalizeBundleIPFS returns a merkle root of the input files for a task. It is meant to be used by another smart contract, however there seem to be 2 issues with it:
It is not clear how an offchain solver is supposed to recreate the merkle root when initializing the challenge, as the data being used is different. This problem manifests itself at https://github.com/TrueBitFoundation/webasm-solidity/blob/master/contracts/interactive.sol#L125
The call is unoptimized. At only two files the call costs 1.5 mil gas
interactive.sol should be replaced by interactive2.sol, with interactive.sol being the final name
To run our wasm files with nodejs, we need to have a JS version of the runtime. Hardest part is figuring out generic system calls, and then we just need the input/output commands and getTotalMemory
.
Reading data from the blockchain.
A new merkle root will have to be added.
The first and last state should be VM state hashes, and other states should be register machine hashes.
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.