Polkadex-Substrate / polkadexTEE-worker

Polkadex Off-chain Orderbook
Apache License 2.0
10 stars 1 forks source link

Exchange websocket client with rustls client #114

Open haerdib opened 3 years ago

haerdib commented 3 years ago

Exchange websocket client with rustls client as soon as openfinex supports tls

Currently, there is a PR to solve https://github.com/integritee-network/worker/issues/352: https://github.com/integritee-network/worker/pull/362, providing some more information as well as diagrams. Definitely worht to take a look at.

According to this PR I think we can do the following:

  1. exchange the self programmed websocket client with the websocket client of forked no_std tungenstenite.
  2. add rustls to the connection: https://github.com/integritee-network/worker/blob/feature/fm-rpc-tls-202/primitives/tls_websocket_server/src/connection.rs, or example from rustls : https://github.com/integritee-network/worker/tree/feature/fm-rpc-tls-202/primitives/tls_websocket_server.

The current client is implemented with the mio polling outside, that was implemented so due to the thread issue (see tls example: https://github.com/apache/incubator-teaclave-sgx-sdk/blob/master/samplecode/tls/tlsclient/enclave/src/lib.rs). However, for thread spawning we could also use and ocall, which enters via ecall again, which has already been preimplemented: https://dingelish.github.io/sgx_tstd/sgx_tstd/thread/index.html. So we can also use the mio inside the enclave, according to example: https://github.com/apache/incubator-teaclave-sgx-sdk/blob/master/samplecode/mio/client/enclave/src/lib.rs

In case mio is used inside the enclave, don't forget to add sgx_pipe.edl to the edl file: https://github.com/apache/incubator-teaclave-sgx-sdk/blob/master/samplecode/mio/client/enclave/Enclave.edl#L23

(check out for example implementation https://github.com/Polkadex-Substrate/polkadexTEE-worker/blob/5/openfinex-client-v3/enclave/src/openfinex/openfinex_client.rs)

pavankanteti commented 3 years ago

@haerdib to provide more info