fortanix / rust-sgx

The Fortanix Rust Enclave Development Platform
https://edp.fortanix.com
Mozilla Public License 2.0
422 stars 99 forks source link

async `enclave.run` function that does not create a new tokio runtime #534

Open DragonDev1906 opened 9 months ago

DragonDev1906 commented 9 months ago

Description I'm creating a custom runner that does more than just running the enclave. It also has other async code (network communication). At the moment the only way to use the custom runner is to call the (blocking) enclave.run method, which starts its own tokio runtime (unfortunately with an old version of tokio, see #403).

Problem or Motivation: Because I'm using async code outside of the enclave runner I currently need two tokio runtimes:

Proposed solution: Add a new async fn run_async() (or something similar), which uses an already existing runtime, does otherwise the same as enclave.run and returns a future representing the enclave running in the background. It could be almost the same as enclave.run, just not creating a runtime and returning the future instead of calling rt.block_on.

If there are restrictions of which runtime (version) this async fn can be used in: State the documentation of this function should state those.

Benefits:

Additional context: As stated above, ideally the enclave_runner would work with the newest tokio version, but I think this can be implemented without major impacts on other big PRs like the async usercall interface (#515)