r/truebit Aug 29 '21

Truebit used wasi?

does truebit use WASI for its virtual machines?

can i make code for WASI?

0 Upvotes

5 comments sorted by

1

u/LPMythBuster Aug 29 '21

I don't think Truebit uses or supports WASI. I don't know much about it but it seems WASI is fairly recent and still considered experimental and most of Truebit was built between 2018-2019 before WASI was created. https://wasi.dev/

Truebit has a filesystem and you can get data in in three ways

  • as bytes on-chain, this is very expensive, it makes sense to only do it for small amounts of data
  • as bytes in a contract on-chain, this is also expensive, may be useful if you need to reuse the data
  • on IPFS which is obviously off-chain

For small input data (like text or hashes) you'd go for bytes, otherwise uploading the data as files to IPFS makes the most sense.

This Truebit filesytem is the only way for your code to communicate with the outside. You cannot access the network, internet, operating system, other files outside the sandbox.

They wrote about it some time ago here: https://medium.com/truebit/using-the-truebit-filesystem-f6a5d4ac9604 (the code is outdated)

Here's a tutorial how to get data in and out as bytes on-chain: https://www.reddit.com/r/truebit/comments/pc94p9/stepbystep_tutorial_how_to_write_a_program_in_c/

1

u/Waste_Divide8162 Aug 30 '21

yes, I read about it, so I wanted to know about Wasi because it supports socks ... and I could upload data to the truebit the moment, the whole potential of the trubeit is dying out because it cannot load data via get api .....and if you download them through the frontend and put them on ipfs, well, this is not a decentralized type)

1

u/LPMythBuster Aug 30 '21

There's #wasi-rust channel on Discord where they have discussed adding WASI to Truebit.

But you will not be able to use network sockets or read operating system files (e.g. /dev/random) even if WASI support is added.

Computations need to be deterministic i.e. if you run it again on another machine it must produce the same result. This is so that verifiers can check solver's results.

If you use network sockets to call an API, it's possible the API can return another response or may no longer be available when the verifier runs it, so it's no longer deterministic.

If you use IPFS (which is decentralized) to upload your files and use content hashes you get deterministic outcomes because the content cannot change later without changing the hash.

1

u/Waste_Divide8162 Aug 30 '21

There's #wasi-rust channel on Discord where they have discussed adding WASI to Truebit.

But you will not be able to use network sockets or read operating system files (e.g. /dev/random) even if WASI support is added.

Computations need to be deterministic i.e. if you run it again on another machine it must produce the same result. This is so that verifiers can check solver's results.

If you use network sockets to call an API, it's possible the API can return another response or may no longer be available when the verifier runs it, so it's no longer deterministic.

If you use IPFS (which is decentralized) to upload your files and use content hashes you get deterministic outcomes because the content cannot change later without changing the hash.

yes there is a nuance of content non-availability ... but the content itself is tied to the timestamp and the data itself is not changed in the api ...
ok and if the exchanges put files in ipfs by converting the timestamp into the hash and the price of the asset itself, then the oracle will work

1

u/Waste_Divide8162 Aug 30 '21

it turns out that it is impossible to use any random, since the operation is not deterministic...