Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

WASM: Run a WASM binary on Wasmtime running in SGX #5

Open
mbestavros opened this issue Aug 7, 2019 · 5 comments
Open

WASM: Run a WASM binary on Wasmtime running in SGX #5

mbestavros opened this issue Aug 7, 2019 · 5 comments
Labels

Comments

@mbestavros
Copy link
Contributor

We'd like to build out a series of demos for our progress on Enarx's WASM support.

This one is the most advanced: running WASM through Wasmtime running on top of SGX. This is the closest representation of the eventual use case we envision for WASM in Enarx.

Some additional possibilities include building out architecture for an eventual end-user, and setting this up in a client-server setting.

@mbestavros mbestavros changed the title Demo: Run a WASM binary on Wasmtime running in SGX WASM Demo #3: Run a WASM binary on Wasmtime running in SGX Aug 7, 2019
@mbestavros mbestavros changed the title WASM Demo #3: Run a WASM binary on Wasmtime running in SGX WASM: Run a WASM binary on Wasmtime running in SGX Aug 9, 2019
@axelsimon axelsimon added the Goal label Nov 6, 2019
@kevingzhang
Copy link

I watched a youtube video https://youtu.be/8IvWPeavjiQ?t=1957 . They have wasmi in SGX back in 2018.May I ask what the benefit is to run wasmtime (rather than wasmi) in SGX?

@npmccallum
Copy link
Contributor

@kevingzhang wasmi is an interpreter (slow). wasmtime is a JIT (fast).

@kevingzhang
Copy link

Thank you @npmccallum for your super quick response. I never expect an answer so soon.
Yeah, the interpreter is slower than JIT or AoT. I think there is at least one advantage: Metering. If running a wasm need some kind of metering such as Gas in Etherium, I am not sure wasmtime can meter how much gas a wasm consume and force to quit when running out of gas.

@npmccallum
Copy link
Contributor

@kevingzhang Can you explain that situation in greater detail?

@kevingzhang
Copy link

Sure.
Gas is a payment model for Etherium and other major blockchain projects.
A client has a bunch of functions to be run by others (in Etherium case, they are called miners, in our cases, they may be called hosts). The miners or hosts won't do the job for free, they need to earn some money called Gas. The client will set a gas limit upfront. The client think the gas limit would be enough to run his function, and if the gas is run out before the function exits, the miner will quit execution and take the gas already metered. If the gas is not run out for the whole computation, the remaining gas will return to the client.

This is similar to cloud computing but a prepaid model.

This model can protect the miners from DDoS or Infinity Loop attack. If there is not such a gas system, the attacker simply submits an infinity loop in function to exhaust all miners' computing power to stop the blockchain.

In Etherium, code is running inside EVM, a special virtual machine. All opcode is measured with a predefined price. When code is running inside the EVM, the gas meter calculates how much gas remains. The gas limit runs out, EVM will throw a gas-run-out exception then exit. In this case, the state of blockchain will roll back to the original state without any change, as if the function is never run.

From the business point of view, likely our Knarx will be run as a cloud / edge / blockchain computing platform, metering is an important part.

Have you already designed something on metering wasm execution?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants