You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by hs...@apache.org on 2023/06/05 02:09:44 UTC

[incubator-teaclave] branch master updated (f6ab0a9a -> 9b664385)

This is an automated email from the ASF dual-hosted git repository.

hsun pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git


    from f6ab0a9a Bump version to 0.5.1
     new 1db660d3 Update rustls
     new ded9444d Replace rpc with tonic grpc
     new 014059a2 Update python sdk and examples
     new 9b664385 Replace empty requests and responses with "google/protobuf/empty.proto"

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                                         |    3 +
 attestation/Cargo.toml                             |    2 +-
 cli/Cargo.toml                                     |    2 +-
 cmake/scripts/test.sh                              |   18 +-
 cmake/tomls/Cargo.sgx_trusted_lib.lock             |  907 ++++++++---
 cmake/tomls/Cargo.sgx_trusted_lib.toml             |    2 +
 cmake/tomls/Cargo.sgx_untrusted_app.lock           |  417 ++++-
 cmake/tomls/Cargo.sgx_untrusted_app.toml           |    1 -
 cmake/tomls/Cargo.unix_app.lock                    |  348 +++-
 cmake/tomls/Cargo.unix_app.toml                    |    1 -
 config/runtime.config.toml                         |   12 +-
 docs/service-internals.md                          |   22 +-
 examples/README.md                                 |   10 +-
 examples/c/utils.h                                 |    4 +-
 examples/python/builtin_face_detection.py          |    4 -
 examples/python/builtin_gbdt_train.py              |    2 -
 examples/python/builtin_online_decrypt.py          |    1 -
 examples/python/builtin_ordered_set_intersect.py   |   15 +-
 examples/python/builtin_password_check.py          |   15 +-
 .../python/builtin_private_join_and_compute.py     |   15 +-
 examples/python/builtin_rsa_sign.py                |    6 +-
 examples/python/mesapy_deadloop_cancel.py          |    3 +-
 examples/python/mesapy_echo.py                     |    2 +-
 examples/python/mesapy_logistic_reg.py             |   15 +-
 examples/python/requirements.txt                   |    3 +
 examples/python/test_disable_function.py           |    6 +-
 examples/python/utils.py                           |    7 +-
 examples/python/wasm_c_simple_add.py               |    2 +-
 examples/python/wasm_rust_psi.py                   |   15 +-
 examples/rust/builtin_echo/Cargo.lock              |  812 +++++++++-
 examples/rust/builtin_echo/src/main.rs             |    4 +-
 .../rust/builtin_ordered_set_intersect/Cargo.lock  |  812 +++++++++-
 .../rust/builtin_ordered_set_intersect/src/main.rs |    6 +-
 rpc/Cargo.toml                                     |   19 +-
 rpc/README.md                                      |   50 +-
 rpc/proc_macro/Cargo.toml                          |   31 -
 rpc/proc_macro/src/lib.rs                          |   46 -
 rpc/src/channel.rs                                 |   66 -
 rpc/src/config.rs                                  |   25 +-
 rpc/src/endpoint.rs                                |   51 -
 rpc/src/interceptor.rs                             |   61 +
 rpc/src/lib.rs                                     |   34 +-
 .../service_enclave_utils => rpc}/src/macros.rs    |   15 +-
 rpc/src/protocol.rs                                |  139 --
 rpc/src/request.rs                                 |   66 -
 rpc/src/server.rs                                  |  129 --
 rpc/src/transport.rs                               |  119 --
 rpc/src/utils.rs                                   |   26 -
 sdk/python/teaclave.py                             |  760 ++++-----
 sdk/rust/Cargo.lock                                |  831 +++++++++-
 sdk/rust/Cargo.toml                                |   21 +-
 sdk/rust/src/lib.rs                                |  471 +++---
 services/access_control/enclave/Cargo.toml         |    1 +
 services/access_control/enclave/src/error.rs       |    5 +-
 services/access_control/enclave/src/lib.rs         |   54 +-
 services/access_control/enclave/src/service.rs     |  130 +-
 services/authentication/enclave/Cargo.toml         |    2 +-
 services/authentication/enclave/src/api_service.rs |  368 +++--
 services/authentication/enclave/src/error.rs       |   11 +-
 .../authentication/enclave/src/internal_service.rs |   67 +-
 services/authentication/enclave/src/lib.rs         |  117 +-
 services/execution/app/Cargo.toml                  |    4 +-
 services/execution/app/src/main.rs                 |   10 +-
 services/execution/enclave/Cargo.toml              |    3 +-
 services/execution/enclave/src/ecall.rs            |   11 +-
 services/execution/enclave/src/lib.rs              |   13 +-
 services/execution/enclave/src/service.rs          |   80 +-
 services/frontend/enclave/Cargo.toml               |   15 +-
 services/frontend/enclave/src/error.rs             |   13 +-
 services/frontend/enclave/src/lib.rs               |   45 +-
 services/frontend/enclave/src/service.rs           |  168 +-
 services/management/enclave/Cargo.toml             |    1 +
 services/management/enclave/src/error.rs           |   18 +-
 services/management/enclave/src/lib.rs             |   58 +-
 services/management/enclave/src/service.rs         |  527 +++---
 services/proto/Cargo.toml                          |   13 +-
 services/proto/build.rs                            |   54 +-
 services/proto/proto_gen/Cargo.lock                |  755 ---------
 services/proto/proto_gen/Cargo.toml                |   37 -
 services/proto/proto_gen/main.rs                   |  121 --
 services/proto/proto_gen/templates/proto.j2        |  129 --
 .../proto/teaclave_authentication_service.proto    |   17 +-
 .../src/proto/teaclave_frontend_service.proto      |   26 +-
 .../src/proto/teaclave_management_service.proto    |   13 +-
 .../src/proto/teaclave_scheduler_service.proto     |   14 +-
 .../proto/src/proto/teaclave_storage_service.proto |   14 +-
 .../proto/src/teaclave_access_control_service.rs   |  230 +--
 .../proto/src/teaclave_authentication_service.rs   |  417 +----
 services/proto/src/teaclave_common.rs              |   29 +-
 services/proto/src/teaclave_frontend_service.rs    | 1695 +++-----------------
 services/proto/src/teaclave_management_service.rs  |   13 +-
 services/proto/src/teaclave_scheduler_service.rs   |  308 +---
 services/proto/src/teaclave_storage_service.rs     |  299 +---
 services/scheduler/enclave/Cargo.toml              |    1 +
 services/scheduler/enclave/src/error.rs            |   12 +-
 services/scheduler/enclave/src/lib.rs              |   71 +-
 services/scheduler/enclave/src/publisher.rs        |   48 +-
 services/scheduler/enclave/src/service.rs          |  213 ++-
 services/storage/enclave/Cargo.toml                |    1 +
 services/storage/enclave/src/error.rs              |   11 +-
 services/storage/enclave/src/lib.rs                |   55 +-
 services/storage/enclave/src/proxy.rs              |   74 +-
 services/storage/enclave/src/service.rs            |  119 +-
 services/utils/service_enclave_utils/Cargo.toml    |    4 +-
 .../service_enclave_utils/proc_macro/Cargo.toml    |   33 -
 .../service_enclave_utils/proc_macro/src/lib.rs    |   57 -
 services/utils/service_enclave_utils/src/lib.rs    |   36 +-
 tests/functional/enclave/Cargo.toml                |    2 +
 tests/functional/enclave/Enclave.config.xml        |    2 +-
 .../enclave/src/access_control_service.rs          |  122 +-
 .../enclave/src/authentication_service.rs          |  165 +-
 .../enclave/src/end_to_end/builtin_echo.rs         |   38 +-
 .../enclave/src/end_to_end/builtin_gbdt_train.rs   |   91 +-
 .../enclave/src/end_to_end/mesapy_data_fusion.rs   |  157 +-
 .../enclave/src/end_to_end/mesapy_echo.rs          |   44 +-
 tests/functional/enclave/src/end_to_end/mod.rs     |   39 +-
 tests/functional/enclave/src/execution_service.rs  |   27 +-
 tests/functional/enclave/src/frontend_service.rs   |  388 +++--
 tests/functional/enclave/src/lib.rs                |    7 +-
 tests/functional/enclave/src/management_service.rs |  463 +++---
 tests/functional/enclave/src/scheduler_service.rs  |   57 +-
 tests/functional/enclave/src/storage_service.rs    |  109 +-
 tests/functional/enclave/src/utils.rs              |  187 ++-
 tests/integration/enclave/Cargo.toml               |   10 -
 tests/integration/enclave/src/lib.rs               |    7 +-
 tests/integration/enclave/src/teaclave_rpc.rs      |  141 --
 tests/scripts/functional_tests.py                  |  131 +-
 tests/utils/Cargo.toml                             |    2 +
 tests/utils/proc_macro/Cargo.toml                  |    4 +-
 tests/utils/proc_macro/src/lib.rs                  |   37 +-
 tests/utils/src/lib.rs                             |   70 +-
 types/Cargo.toml                                   |    1 +
 types/src/error.rs                                 |   19 +-
 worker/src/worker.rs                               |   10 +-
 134 files changed, 7158 insertions(+), 8266 deletions(-)
 delete mode 100644 rpc/proc_macro/Cargo.toml
 delete mode 100644 rpc/proc_macro/src/lib.rs
 delete mode 100644 rpc/src/channel.rs
 delete mode 100644 rpc/src/endpoint.rs
 create mode 100644 rpc/src/interceptor.rs
 copy {services/utils/service_enclave_utils => rpc}/src/macros.rs (81%)
 delete mode 100644 rpc/src/protocol.rs
 delete mode 100644 rpc/src/request.rs
 delete mode 100644 rpc/src/server.rs
 delete mode 100644 rpc/src/transport.rs
 delete mode 100644 rpc/src/utils.rs
 delete mode 100644 services/proto/proto_gen/Cargo.lock
 delete mode 100644 services/proto/proto_gen/Cargo.toml
 delete mode 100644 services/proto/proto_gen/main.rs
 delete mode 100644 services/proto/proto_gen/templates/proto.j2
 delete mode 100644 services/utils/service_enclave_utils/proc_macro/Cargo.toml
 delete mode 100644 services/utils/service_enclave_utils/proc_macro/src/lib.rs
 delete mode 100644 tests/integration/enclave/src/teaclave_rpc.rs


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org


[incubator-teaclave] 02/04: Replace rpc with tonic grpc

Posted by hs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hsun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git

commit ded9444dec44cab9b0430449e9f5233551e015cf
Author: GeminiCarrie <sp...@163.com>
AuthorDate: Wed May 10 04:52:42 2023 +0000

    Replace rpc with tonic grpc
---
 cmake/tomls/Cargo.sgx_trusted_lib.lock             |  804 +++++++---
 cmake/tomls/Cargo.sgx_trusted_lib.toml             |    1 +
 cmake/tomls/Cargo.sgx_untrusted_app.lock           |  401 ++++-
 cmake/tomls/Cargo.sgx_untrusted_app.toml           |    1 -
 cmake/tomls/Cargo.unix_app.lock                    |  336 +++-
 cmake/tomls/Cargo.unix_app.toml                    |    1 -
 config/runtime.config.toml                         |   12 +-
 docs/service-internals.md                          |   22 +-
 examples/c/utils.h                                 |    4 +-
 examples/rust/builtin_echo/Cargo.lock              |  812 +++++++++-
 examples/rust/builtin_echo/src/main.rs             |    4 +-
 .../rust/builtin_ordered_set_intersect/Cargo.lock  |  812 +++++++++-
 .../rust/builtin_ordered_set_intersect/src/main.rs |    6 +-
 rpc/Cargo.toml                                     |   17 +-
 rpc/README.md                                      |   50 +-
 rpc/proc_macro/Cargo.toml                          |   31 -
 rpc/proc_macro/src/lib.rs                          |   46 -
 rpc/src/channel.rs                                 |   66 -
 rpc/src/config.rs                                  |   25 +-
 rpc/src/endpoint.rs                                |   51 -
 rpc/src/interceptor.rs                             |   61 +
 rpc/src/lib.rs                                     |   34 +-
 rpc/src/{utils.rs => macros.rs}                    |   21 +-
 rpc/src/protocol.rs                                |  139 --
 rpc/src/request.rs                                 |   66 -
 rpc/src/server.rs                                  |  129 --
 rpc/src/transport.rs                               |  119 --
 sdk/rust/Cargo.lock                                |  831 +++++++++-
 sdk/rust/Cargo.toml                                |   21 +-
 sdk/rust/src/lib.rs                                |  393 ++---
 services/access_control/enclave/Cargo.toml         |    1 +
 services/access_control/enclave/src/error.rs       |    5 +-
 services/access_control/enclave/src/lib.rs         |   54 +-
 services/access_control/enclave/src/service.rs     |  130 +-
 services/authentication/enclave/Cargo.toml         |    2 +-
 services/authentication/enclave/src/api_service.rs |  362 ++---
 services/authentication/enclave/src/error.rs       |   11 +-
 .../authentication/enclave/src/internal_service.rs |   67 +-
 services/authentication/enclave/src/lib.rs         |  117 +-
 services/execution/app/Cargo.toml                  |    4 +-
 services/execution/app/src/main.rs                 |   10 +-
 services/execution/enclave/Cargo.toml              |    3 +-
 services/execution/enclave/src/ecall.rs            |   11 +-
 services/execution/enclave/src/lib.rs              |   13 +-
 services/execution/enclave/src/service.rs          |   80 +-
 services/frontend/enclave/Cargo.toml               |   15 +-
 services/frontend/enclave/src/error.rs             |   13 +-
 services/frontend/enclave/src/lib.rs               |   45 +-
 services/frontend/enclave/src/service.rs           |  143 +-
 services/management/enclave/Cargo.toml             |    1 +
 services/management/enclave/src/error.rs           |   18 +-
 services/management/enclave/src/lib.rs             |   58 +-
 services/management/enclave/src/service.rs         |  498 +++---
 services/proto/Cargo.toml                          |   13 +-
 services/proto/build.rs                            |   54 +-
 services/proto/proto_gen/Cargo.lock                |  755 ---------
 services/proto/proto_gen/Cargo.toml                |   37 -
 services/proto/proto_gen/main.rs                   |  121 --
 services/proto/proto_gen/templates/proto.j2        |  129 --
 .../proto/src/teaclave_access_control_service.rs   |  230 +--
 .../proto/src/teaclave_authentication_service.rs   |  417 +----
 services/proto/src/teaclave_common.rs              |   29 +-
 services/proto/src/teaclave_frontend_service.rs    | 1695 +++-----------------
 services/proto/src/teaclave_management_service.rs  |    7 +-
 services/proto/src/teaclave_scheduler_service.rs   |  311 +---
 services/proto/src/teaclave_storage_service.rs     |  306 +---
 services/scheduler/enclave/Cargo.toml              |    1 +
 services/scheduler/enclave/src/error.rs            |   12 +-
 services/scheduler/enclave/src/lib.rs              |   71 +-
 services/scheduler/enclave/src/publisher.rs        |   48 +-
 services/scheduler/enclave/src/service.rs          |  205 ++-
 services/storage/enclave/Cargo.toml                |    1 +
 services/storage/enclave/src/error.rs              |   11 +-
 services/storage/enclave/src/lib.rs                |   55 +-
 services/storage/enclave/src/proxy.rs              |   80 +-
 services/storage/enclave/src/service.rs            |  127 +-
 services/utils/service_enclave_utils/Cargo.toml    |    4 +-
 .../service_enclave_utils/proc_macro/Cargo.toml    |   33 -
 .../service_enclave_utils/proc_macro/src/lib.rs    |   57 -
 services/utils/service_enclave_utils/src/lib.rs    |   36 +-
 tests/functional/enclave/Cargo.toml                |    2 +
 tests/functional/enclave/Enclave.config.xml        |    2 +-
 .../enclave/src/access_control_service.rs          |  122 +-
 .../enclave/src/authentication_service.rs          |  165 +-
 .../enclave/src/end_to_end/builtin_echo.rs         |   38 +-
 .../enclave/src/end_to_end/builtin_gbdt_train.rs   |   91 +-
 .../enclave/src/end_to_end/mesapy_data_fusion.rs   |  157 +-
 .../enclave/src/end_to_end/mesapy_echo.rs          |   44 +-
 tests/functional/enclave/src/end_to_end/mod.rs     |   37 +-
 tests/functional/enclave/src/execution_service.rs  |   27 +-
 tests/functional/enclave/src/frontend_service.rs   |  388 +++--
 tests/functional/enclave/src/lib.rs                |    7 +-
 tests/functional/enclave/src/management_service.rs |  463 +++---
 tests/functional/enclave/src/scheduler_service.rs  |   57 +-
 tests/functional/enclave/src/storage_service.rs    |  109 +-
 tests/functional/enclave/src/utils.rs              |  187 ++-
 tests/integration/enclave/Cargo.toml               |   10 -
 tests/integration/enclave/src/lib.rs               |    7 +-
 tests/integration/enclave/src/teaclave_rpc.rs      |  141 --
 tests/utils/Cargo.toml                             |    2 +
 tests/utils/proc_macro/Cargo.toml                  |    4 +-
 tests/utils/proc_macro/src/lib.rs                  |   37 +-
 tests/utils/src/lib.rs                             |   70 +-
 types/Cargo.toml                                   |    1 +
 types/src/error.rs                                 |   19 +-
 worker/src/worker.rs                               |   10 +-
 106 files changed, 6512 insertions(+), 7507 deletions(-)

diff --git a/cmake/tomls/Cargo.sgx_trusted_lib.lock b/cmake/tomls/Cargo.sgx_trusted_lib.lock
index 8f4d145a..e26aec56 100644
--- a/cmake/tomls/Cargo.sgx_trusted_lib.lock
+++ b/cmake/tomls/Cargo.sgx_trusted_lib.lock
@@ -2,20 +2,59 @@
 # It is not intended for manual editing.
 version = 3
 
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
 [[package]]
 name = "aho-corasick"
-version = "0.7.20"
+version = "1.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
+checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04"
 dependencies = [
  "memchr",
 ]
 
 [[package]]
 name = "anyhow"
-version = "1.0.68"
+version = "1.0.71"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
+
+[[package]]
+name = "async-stream"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51"
+dependencies = [
+ "async-stream-impl",
+ "futures-core",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-stream-impl"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.27",
+ "syn 2.0.15",
+]
+
+[[package]]
+name = "async-trait"
+version = "0.1.68"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61"
+checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.27",
+ "syn 2.0.15",
+]
 
 [[package]]
 name = "autocfg"
@@ -55,15 +94,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
 
 [[package]]
 name = "bumpalo"
-version = "3.11.1"
+version = "3.12.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
+checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b"
 
 [[package]]
 name = "bytemuck"
-version = "1.12.3"
+version = "1.13.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aaa3a8d9a1ca92e282c96a32d6511b695d7d994d1d102ba85d279f9b2756947f"
+checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
 
 [[package]]
 name = "byteorder"
@@ -73,15 +112,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
 
 [[package]]
 name = "bytes"
-version = "1.3.0"
+version = "1.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c"
+checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
 
 [[package]]
 name = "cc"
-version = "1.0.78"
+version = "1.0.79"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d"
+checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
 
 [[package]]
 name = "cfg-if"
@@ -97,9 +136,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 
 [[package]]
 name = "chrono"
-version = "0.4.23"
+version = "0.4.24"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f"
+checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b"
 dependencies = [
  "num-integer",
  "num-traits",
@@ -123,30 +162,39 @@ dependencies = [
 
 [[package]]
 name = "core-foundation-sys"
-version = "0.8.3"
+version = "0.8.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
+checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
 
 [[package]]
 name = "crc"
 version = "2.0.0"
 source = "git+https://github.com/mrhooray/crc-rs?rev=86696be#86696be09b7605d27327bbe659ac6c0e990c267f"
 
+[[package]]
+name = "crc32fast"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
+dependencies = [
+ "cfg-if 1.0.0",
+]
+
 [[package]]
 name = "ctor"
 version = "0.1.26"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
 dependencies = [
- "quote 1.0.26",
- "syn 1.0.107",
+ "quote 1.0.27",
+ "syn 1.0.109",
 ]
 
 [[package]]
 name = "either"
-version = "1.8.0"
+version = "1.8.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
+checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
 
 [[package]]
 name = "encoding_rs"
@@ -168,13 +216,13 @@ dependencies = [
 
 [[package]]
 name = "errno"
-version = "0.2.8"
+version = "0.3.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
+checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
 dependencies = [
  "errno-dragonfly",
  "libc",
- "winapi",
+ "windows-sys 0.48.0",
 ]
 
 [[package]]
@@ -196,6 +244,22 @@ dependencies = [
  "instant",
 ]
 
+[[package]]
+name = "fixedbitset"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
+
+[[package]]
+name = "flate2"
+version = "1.0.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
+dependencies = [
+ "crc32fast",
+ "miniz_oxide",
+]
+
 [[package]]
 name = "fnv"
 version = "1.0.7"
@@ -228,9 +292,9 @@ dependencies = [
 
 [[package]]
 name = "futures"
-version = "0.3.26"
+version = "0.3.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84"
+checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40"
 dependencies = [
  "futures-channel",
  "futures-core",
@@ -243,9 +307,9 @@ dependencies = [
 
 [[package]]
 name = "futures-channel"
-version = "0.3.26"
+version = "0.3.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5"
+checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
 dependencies = [
  "futures-core",
  "futures-sink",
@@ -253,15 +317,15 @@ dependencies = [
 
 [[package]]
 name = "futures-core"
-version = "0.3.26"
+version = "0.3.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608"
+checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
 
 [[package]]
 name = "futures-executor"
-version = "0.3.26"
+version = "0.3.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e"
+checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0"
 dependencies = [
  "futures-core",
  "futures-task",
@@ -270,38 +334,38 @@ dependencies = [
 
 [[package]]
 name = "futures-io"
-version = "0.3.26"
+version = "0.3.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531"
+checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
 
 [[package]]
 name = "futures-macro"
-version = "0.3.26"
+version = "0.3.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70"
+checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
 dependencies = [
  "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "quote 1.0.27",
+ "syn 2.0.15",
 ]
 
 [[package]]
 name = "futures-sink"
-version = "0.3.26"
+version = "0.3.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364"
+checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e"
 
 [[package]]
 name = "futures-task"
-version = "0.3.26"
+version = "0.3.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366"
+checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
 
 [[package]]
 name = "futures-util"
-version = "0.3.26"
+version = "0.3.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1"
+checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
 dependencies = [
  "futures-channel",
  "futures-core",
@@ -341,20 +405,20 @@ dependencies = [
 
 [[package]]
 name = "ghost"
-version = "0.1.7"
+version = "0.1.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "41973d4c45f7a35af8753ba3457cc99d406d863941fd7f52663cff54a5ab99b3"
+checksum = "e77ac7b51b8e6313251737fcef4b1c01a2ea102bde68415b62c0ee9268fec357"
 dependencies = [
  "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "quote 1.0.27",
+ "syn 2.0.15",
 ]
 
 [[package]]
 name = "h2"
-version = "0.3.16"
+version = "0.3.18"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d"
+checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21"
 dependencies = [
  "bytes",
  "fnv",
@@ -365,7 +429,7 @@ dependencies = [
  "indexmap",
  "slab",
  "tokio",
- "tokio-util",
+ "tokio-util 0.7.8",
  "tracing",
 ]
 
@@ -379,6 +443,15 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
 name = "hashbrown_tstd"
 version = "0.12.0"
 
+[[package]]
+name = "heck"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
+dependencies = [
+ "unicode-segmentation",
+]
+
 [[package]]
 name = "hermit-abi"
 version = "0.1.19"
@@ -388,6 +461,12 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "hermit-abi"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
+
 [[package]]
 name = "hex"
 version = "0.4.3"
@@ -396,9 +475,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
 
 [[package]]
 name = "http"
-version = "0.2.8"
+version = "0.2.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399"
+checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482"
 dependencies = [
  "bytes",
  "fnv",
@@ -430,9 +509,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
 
 [[package]]
 name = "hyper"
-version = "0.14.25"
+version = "0.14.26"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899"
+checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4"
 dependencies = [
  "bytes",
  "futures-channel",
@@ -452,6 +531,18 @@ dependencies = [
  "want",
 ]
 
+[[package]]
+name = "hyper-timeout"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
+dependencies = [
+ "hyper",
+ "pin-project-lite",
+ "tokio",
+ "tokio-io-timeout",
+]
+
 [[package]]
 name = "hyper-tls"
 version = "0.5.0"
@@ -491,9 +582,9 @@ dependencies = [
 
 [[package]]
 name = "indexmap"
-version = "1.9.2"
+version = "1.9.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
+checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
 dependencies = [
  "autocfg",
  "hashbrown",
@@ -532,25 +623,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7e41b53715c6f0c4be49510bb82dee2c1e51c8586d885abe65396e82ed518548"
 dependencies = [
  "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "quote 1.0.27",
+ "syn 1.0.109",
 ]
 
 [[package]]
 name = "io-lifetimes"
-version = "1.0.6"
+version = "1.0.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3"
+checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220"
 dependencies = [
+ "hermit-abi 0.3.1",
  "libc",
- "windows-sys 0.45.0",
+ "windows-sys 0.48.0",
 ]
 
 [[package]]
 name = "ipnet"
-version = "2.7.1"
+version = "2.7.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146"
+checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f"
 
 [[package]]
 name = "itertools"
@@ -572,9 +664,9 @@ dependencies = [
 
 [[package]]
 name = "itoa"
-version = "1.0.5"
+version = "1.0.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
+checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
 
 [[package]]
 name = "jpeg-decoder"
@@ -584,9 +676,9 @@ checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2"
 
 [[package]]
 name = "js-sys"
-version = "0.3.60"
+version = "0.3.62"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
+checksum = "68c16e1bfd491478ab155fd8b4896b86f9ede344949b641e61501e07c2b8b4d5"
 dependencies = [
  "wasm-bindgen",
 ]
@@ -613,9 +705,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
 [[package]]
 name = "libc"
-version = "0.2.139"
+version = "0.2.144"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
+checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
 
 [[package]]
 name = "libm"
@@ -625,9 +717,9 @@ checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb"
 
 [[package]]
 name = "linux-raw-sys"
-version = "0.1.4"
+version = "0.3.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
+checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f"
 
 [[package]]
 name = "log"
@@ -656,9 +748,18 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
 
 [[package]]
 name = "mime"
-version = "0.3.16"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
+
+[[package]]
+name = "miniz_oxide"
+version = "0.7.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
+checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
+dependencies = [
+ "adler",
+]
 
 [[package]]
 name = "mio"
@@ -671,6 +772,12 @@ dependencies = [
  "windows-sys 0.48.0",
 ]
 
+[[package]]
+name = "multimap"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
+
 [[package]]
 name = "native-tls"
 version = "0.2.11"
@@ -793,21 +900,21 @@ name = "num_cpus"
 version = "1.14.0"
 source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
- "hermit-abi",
+ "hermit-abi 0.1.19",
  "libc",
 ]
 
 [[package]]
 name = "once_cell"
-version = "1.16.0"
+version = "1.17.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
+checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
 
 [[package]]
 name = "openssl"
-version = "0.10.45"
+version = "0.10.52"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1"
+checksum = "01b8574602df80f7b85fdfc5392fa884a4e3b3f4f35402c070ab34c3d3f78d56"
 dependencies = [
  "bitflags",
  "cfg-if 1.0.0",
@@ -820,13 +927,13 @@ dependencies = [
 
 [[package]]
 name = "openssl-macros"
-version = "0.1.0"
+version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
+checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
 dependencies = [
  "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "quote 1.0.27",
+ "syn 2.0.15",
 ]
 
 [[package]]
@@ -837,11 +944,10 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
 
 [[package]]
 name = "openssl-sys"
-version = "0.9.80"
+version = "0.9.87"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7"
+checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e"
 dependencies = [
- "autocfg",
  "cc",
  "libc",
  "pkg-config",
@@ -865,6 +971,36 @@ version = "2.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
 
+[[package]]
+name = "petgraph"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4"
+dependencies = [
+ "fixedbitset",
+ "indexmap",
+]
+
+[[package]]
+name = "pin-project"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"
+dependencies = [
+ "pin-project-internal",
+]
+
+[[package]]
+name = "pin-project-internal"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.27",
+ "syn 1.0.109",
+]
+
 [[package]]
 name = "pin-project-lite"
 version = "0.2.9"
@@ -879,9 +1015,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
 
 [[package]]
 name = "pkg-config"
-version = "0.3.26"
+version = "0.3.27"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
+checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
 
 [[package]]
 name = "ppv-lite86"
@@ -909,25 +1045,55 @@ dependencies = [
 
 [[package]]
 name = "prost"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537"
+checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
 dependencies = [
  "bytes",
  "prost-derive",
 ]
 
+[[package]]
+name = "prost-build"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5"
+dependencies = [
+ "bytes",
+ "heck",
+ "itertools 0.10.5",
+ "lazy_static",
+ "log",
+ "multimap",
+ "petgraph",
+ "prost",
+ "prost-types",
+ "regex",
+ "tempfile",
+ "which",
+]
+
 [[package]]
 name = "prost-derive"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b"
+checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
 dependencies = [
  "anyhow",
  "itertools 0.10.5",
  "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "quote 1.0.27",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "prost-types"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
+dependencies = [
+ "bytes",
+ "prost",
 ]
 
 [[package]]
@@ -941,9 +1107,9 @@ dependencies = [
 
 [[package]]
 name = "quote"
-version = "1.0.26"
+version = "1.0.27"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
+checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500"
 dependencies = [
  "proc-macro2 1.0.56",
 ]
@@ -1011,18 +1177,18 @@ dependencies = [
 
 [[package]]
 name = "redox_syscall"
-version = "0.2.16"
+version = "0.3.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
+checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
 dependencies = [
  "bitflags",
 ]
 
 [[package]]
 name = "regex"
-version = "1.7.0"
+version = "1.8.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
+checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370"
 dependencies = [
  "aho-corasick",
  "memchr",
@@ -1031,15 +1197,15 @@ dependencies = [
 
 [[package]]
 name = "regex-syntax"
-version = "0.6.28"
+version = "0.7.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
+checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c"
 
 [[package]]
 name = "reqwest"
-version = "0.11.16"
+version = "0.11.17"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254"
+checksum = "13293b639a097af28fc8a90f22add145a9c954e49d77da06263d58cf44d5fb91"
 dependencies = [
  "base64 0.21.0",
  "bytes",
@@ -1064,7 +1230,7 @@ dependencies = [
  "serde_urlencoded",
  "tokio",
  "tokio-native-tls",
- "tokio-util",
+ "tokio-util 0.7.8",
  "tower-service",
  "url",
  "wasm-bindgen",
@@ -1111,16 +1277,16 @@ dependencies = [
 
 [[package]]
 name = "rustix"
-version = "0.36.9"
+version = "0.37.19"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc"
+checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d"
 dependencies = [
  "bitflags",
  "errno",
  "io-lifetimes",
  "libc",
  "linux-raw-sys",
- "windows-sys 0.45.0",
+ "windows-sys 0.48.0",
 ]
 
 [[package]]
@@ -1163,9 +1329,9 @@ dependencies = [
 
 [[package]]
 name = "ryu"
-version = "1.0.12"
+version = "1.0.13"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
+checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
 
 [[package]]
 name = "schannel"
@@ -1211,29 +1377,29 @@ dependencies = [
 
 [[package]]
 name = "serde"
-version = "1.0.151"
+version = "1.0.162"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "97fed41fc1a24994d044e6db6935e69511a1153b52c15eb42493b26fa87feba0"
+checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6"
 dependencies = [
  "serde_derive",
 ]
 
 [[package]]
 name = "serde_derive"
-version = "1.0.151"
+version = "1.0.162"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8"
+checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6"
 dependencies = [
  "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "quote 1.0.27",
+ "syn 2.0.15",
 ]
 
 [[package]]
 name = "serde_json"
-version = "1.0.91"
+version = "1.0.96"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883"
+checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
 dependencies = [
  "itoa",
  "ryu",
@@ -1319,8 +1485,8 @@ name = "sgx_macros"
 version = "2.0.0"
 dependencies = [
  "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "quote 1.0.27",
+ "syn 1.0.109",
 ]
 
 [[package]]
@@ -1523,12 +1689,23 @@ dependencies = [
 
 [[package]]
 name = "syn"
-version = "1.0.107"
+version = "1.0.109"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.27",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
+checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
 dependencies = [
  "proc-macro2 1.0.56",
- "quote 1.0.26",
+ "quote 1.0.27",
  "unicode-ident",
 ]
 
@@ -1553,6 +1730,7 @@ dependencies = [
  "teaclave_test_utils",
  "teaclave_types",
  "thiserror",
+ "tokio",
 ]
 
 [[package]]
@@ -1611,6 +1789,7 @@ dependencies = [
  "teaclave_test_utils",
  "teaclave_types",
  "thiserror",
+ "tokio",
  "uuid",
 ]
 
@@ -1688,6 +1867,7 @@ dependencies = [
  "teaclave_types",
  "teaclave_worker",
  "thiserror",
+ "tokio",
  "url",
  "uuid",
 ]
@@ -1752,7 +1932,7 @@ dependencies = [
  "teaclave_types",
  "thiserror",
  "tokio",
- "tokio-util",
+ "tokio-util 0.7.8",
  "url",
 ]
 
@@ -1777,6 +1957,7 @@ dependencies = [
  "teaclave_test_utils",
  "teaclave_types",
  "thiserror",
+ "tokio",
 ]
 
 [[package]]
@@ -1810,6 +1991,7 @@ name = "teaclave_functional_tests_enclave"
 version = "0.5.1"
 dependencies = [
  "anyhow",
+ "futures",
  "inventory",
  "lazy_static",
  "log",
@@ -1826,6 +2008,7 @@ dependencies = [
  "teaclave_test_utils",
  "teaclave_types",
  "thiserror",
+ "tokio",
  "url",
  "uuid",
 ]
@@ -1837,22 +2020,16 @@ dependencies = [
  "anyhow",
  "log",
  "rand",
- "rustls",
  "rusty-leveldb",
  "serde",
  "serde_json",
  "sgx_types",
- "teaclave_attestation",
  "teaclave_binder",
- "teaclave_config",
  "teaclave_crypto",
- "teaclave_proto",
- "teaclave_rpc",
  "teaclave_service_enclave_utils",
  "teaclave_test_utils",
  "teaclave_types",
  "teaclave_worker",
- "thiserror",
 ]
 
 [[package]]
@@ -1887,6 +2064,7 @@ dependencies = [
  "teaclave_test_utils",
  "teaclave_types",
  "thiserror",
+ "tokio",
  "url",
  "uuid",
 ]
@@ -1896,17 +2074,15 @@ name = "teaclave_proto"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "base64 0.13.1",
- "cfg-if 0.1.10",
  "prost",
- "rand",
  "serde",
  "serde_json",
  "sgx_cov",
  "sgx_types",
  "teaclave_crypto",
- "teaclave_rpc",
  "teaclave_types",
+ "tonic",
+ "tonic-build",
  "url",
  "uuid",
 ]
@@ -1916,31 +2092,14 @@ name = "teaclave_rpc"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "cfg-if 0.1.10",
- "http",
- "libc",
  "log",
  "rustls",
- "serde",
- "serde_json",
- "sgx_libc",
  "teaclave_attestation",
- "teaclave_rpc_proc_macro",
  "teaclave_types",
- "thiserror",
- "threadpool",
+ "tonic",
  "webpki",
 ]
 
-[[package]]
-name = "teaclave_rpc_proc_macro"
-version = "0.5.1"
-dependencies = [
- "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
-]
-
 [[package]]
 name = "teaclave_runtime"
 version = "0.5.1"
@@ -1973,6 +2132,7 @@ dependencies = [
  "teaclave_test_utils",
  "teaclave_types",
  "thiserror",
+ "tokio",
  "uuid",
 ]
 
@@ -1990,17 +2150,8 @@ dependencies = [
  "teaclave_logger",
  "teaclave_proto",
  "teaclave_rpc",
- "teaclave_service_enclave_utils_proc_macro",
  "teaclave_types",
-]
-
-[[package]]
-name = "teaclave_service_enclave_utils_proc_macro"
-version = "0.5.1"
-dependencies = [
- "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "tokio",
 ]
 
 [[package]]
@@ -2039,14 +2190,17 @@ dependencies = [
  "teaclave_test_utils",
  "teaclave_types",
  "thiserror",
+ "tokio",
 ]
 
 [[package]]
 name = "teaclave_test_utils"
 version = "0.5.1"
 dependencies = [
+ "futures",
  "inventory",
  "teaclave_test_utils_proc_macro",
+ "tokio",
 ]
 
 [[package]]
@@ -2054,8 +2208,8 @@ name = "teaclave_test_utils_proc_macro"
 version = "0.0.1"
 dependencies = [
  "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "quote 1.0.27",
+ "syn 1.0.109",
 ]
 
 [[package]]
@@ -2075,6 +2229,7 @@ dependencies = [
  "teaclave_test_utils",
  "thiserror",
  "toml",
+ "tonic",
  "url",
  "uuid",
 ]
@@ -2130,44 +2285,35 @@ dependencies = [
 
 [[package]]
 name = "tempfile"
-version = "3.4.0"
+version = "3.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95"
+checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998"
 dependencies = [
  "cfg-if 1.0.0",
  "fastrand",
  "redox_syscall",
  "rustix",
- "windows-sys 0.42.0",
+ "windows-sys 0.45.0",
 ]
 
 [[package]]
 name = "thiserror"
-version = "1.0.38"
+version = "1.0.40"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0"
+checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"
 dependencies = [
  "thiserror-impl",
 ]
 
 [[package]]
 name = "thiserror-impl"
-version = "1.0.38"
+version = "1.0.40"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f"
+checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
 dependencies = [
  "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
-]
-
-[[package]]
-name = "threadpool"
-version = "1.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
-dependencies = [
- "num_cpus",
+ "quote 1.0.27",
+ "syn 2.0.15",
 ]
 
 [[package]]
@@ -2181,24 +2327,45 @@ dependencies = [
 
 [[package]]
 name = "tinyvec_macros"
-version = "0.1.0"
+version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
+checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
 
 [[package]]
 name = "tokio"
-version = "1.27.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001"
+version = "1.24.0"
+source = "git+https://github.com/tokio-rs/tokio.git?tag=tokio-1.24.0#dfe252d1fa82bdfefd7cba20f9a88cdd27e310cc"
 dependencies = [
  "autocfg",
  "bytes",
  "libc",
+ "memchr",
  "mio",
  "num_cpus",
  "pin-project-lite",
  "socket2",
- "windows-sys 0.45.0",
+ "tokio-macros",
+ "windows-sys 0.42.0",
+]
+
+[[package]]
+name = "tokio-io-timeout"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
+dependencies = [
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "1.8.2"
+source = "git+https://github.com/tokio-rs/tokio.git?tag=tokio-1.24.0#dfe252d1fa82bdfefd7cba20f9a88cdd27e310cc"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.27",
+ "syn 1.0.109",
 ]
 
 [[package]]
@@ -2211,11 +2378,47 @@ dependencies = [
  "tokio",
 ]
 
+[[package]]
+name = "tokio-rustls"
+version = "0.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
+dependencies = [
+ "rustls",
+ "tokio",
+ "webpki",
+]
+
+[[package]]
+name = "tokio-stream"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842"
+dependencies = [
+ "futures-core",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-util"
+version = "0.6.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "log",
+ "pin-project-lite",
+ "tokio",
+]
+
 [[package]]
 name = "tokio-util"
-version = "0.7.7"
+version = "0.7.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2"
+checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d"
 dependencies = [
  "bytes",
  "futures-core",
@@ -2227,13 +2430,84 @@ dependencies = [
 
 [[package]]
 name = "toml"
-version = "0.5.10"
+version = "0.5.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f"
+checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
 dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "tonic"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a"
+dependencies = [
+ "async-stream",
+ "async-trait",
+ "base64 0.13.1",
+ "bytes",
+ "flate2",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "hyper",
+ "hyper-timeout",
+ "percent-encoding",
+ "pin-project",
+ "prost",
+ "prost-derive",
+ "tokio",
+ "tokio-rustls",
+ "tokio-stream",
+ "tokio-util 0.6.10",
+ "tower",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+ "tracing-futures",
+]
+
+[[package]]
+name = "tonic-build"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "prost-build",
+ "quote 1.0.27",
+ "syn 1.0.109",
+]
+
+[[package]]
+name = "tower"
+version = "0.4.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
+dependencies = [
+ "futures-core",
+ "futures-util",
+ "indexmap",
+ "pin-project",
+ "pin-project-lite",
+ "rand",
+ "slab",
+ "tokio",
+ "tokio-util 0.7.8",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "tower-layer"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
+
 [[package]]
 name = "tower-service"
 version = "0.3.2"
@@ -2247,10 +2521,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
 dependencies = [
  "cfg-if 1.0.0",
+ "log",
  "pin-project-lite",
+ "tracing-attributes",
  "tracing-core",
 ]
 
+[[package]]
+name = "tracing-attributes"
+version = "0.1.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.27",
+ "syn 2.0.15",
+]
+
 [[package]]
 name = "tracing-core"
 version = "0.1.30"
@@ -2260,6 +2547,16 @@ dependencies = [
  "once_cell",
 ]
 
+[[package]]
+name = "tracing-futures"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
+dependencies = [
+ "pin-project",
+ "tracing",
+]
+
 [[package]]
 name = "try-lock"
 version = "0.2.4"
@@ -2268,15 +2565,15 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
 
 [[package]]
 name = "unicode-bidi"
-version = "0.3.8"
+version = "0.3.13"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
+checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
 
 [[package]]
 name = "unicode-ident"
-version = "1.0.6"
+version = "1.0.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
+checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
 
 [[package]]
 name = "unicode-normalization"
@@ -2287,6 +2584,12 @@ dependencies = [
  "tinyvec",
 ]
 
+[[package]]
+name = "unicode-segmentation"
+version = "1.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
+
 [[package]]
 name = "unicode-xid"
 version = "0.1.0"
@@ -2369,9 +2672,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
 
 [[package]]
 name = "wasm-bindgen"
-version = "0.2.83"
+version = "0.2.85"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
+checksum = "5b6cb788c4e39112fbe1822277ef6fb3c55cd86b95cb3d3c4c1c9597e4ac74b4"
 dependencies = [
  "cfg-if 1.0.0",
  "wasm-bindgen-macro",
@@ -2379,24 +2682,24 @@ dependencies = [
 
 [[package]]
 name = "wasm-bindgen-backend"
-version = "0.2.83"
+version = "0.2.85"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
+checksum = "35e522ed4105a9d626d885b35d62501b30d9666283a5c8be12c14a8bdafe7822"
 dependencies = [
  "bumpalo",
  "log",
  "once_cell",
  "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "quote 1.0.27",
+ "syn 2.0.15",
  "wasm-bindgen-shared",
 ]
 
 [[package]]
 name = "wasm-bindgen-futures"
-version = "0.4.33"
+version = "0.4.35"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d"
+checksum = "083abe15c5d88556b77bdf7aef403625be9e327ad37c62c4e4129af740168163"
 dependencies = [
  "cfg-if 1.0.0",
  "js-sys",
@@ -2406,32 +2709,32 @@ dependencies = [
 
 [[package]]
 name = "wasm-bindgen-macro"
-version = "0.2.83"
+version = "0.2.85"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
+checksum = "358a79a0cb89d21db8120cbfb91392335913e4890665b1a7981d9e956903b434"
 dependencies = [
- "quote 1.0.26",
+ "quote 1.0.27",
  "wasm-bindgen-macro-support",
 ]
 
 [[package]]
 name = "wasm-bindgen-macro-support"
-version = "0.2.83"
+version = "0.2.85"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
+checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869"
 dependencies = [
  "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "quote 1.0.27",
+ "syn 2.0.15",
  "wasm-bindgen-backend",
  "wasm-bindgen-shared",
 ]
 
 [[package]]
 name = "wasm-bindgen-shared"
-version = "0.2.83"
+version = "0.2.85"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
+checksum = "a901d592cafaa4d711bc324edfaff879ac700b19c3dfd60058d2b445be2691eb"
 
 [[package]]
 name = "wasm-streams"
@@ -2448,9 +2751,9 @@ dependencies = [
 
 [[package]]
 name = "web-sys"
-version = "0.3.60"
+version = "0.3.62"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
+checksum = "16b5f940c7edfdc6d12126d98c9ef4d1b3d470011c47c76a6581df47ad9ba721"
 dependencies = [
  "js-sys",
  "wasm-bindgen",
@@ -2475,6 +2778,17 @@ dependencies = [
  "webpki",
 ]
 
+[[package]]
+name = "which"
+version = "4.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
+dependencies = [
+ "either",
+ "libc",
+ "once_cell",
+]
+
 [[package]]
 name = "winapi"
 version = "0.3.9"
@@ -2503,13 +2817,13 @@ version = "0.42.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
 dependencies = [
- "windows_aarch64_gnullvm 0.42.1",
- "windows_aarch64_msvc 0.42.1",
- "windows_i686_gnu 0.42.1",
- "windows_i686_msvc 0.42.1",
- "windows_x86_64_gnu 0.42.1",
- "windows_x86_64_gnullvm 0.42.1",
- "windows_x86_64_msvc 0.42.1",
+ "windows_aarch64_gnullvm 0.42.2",
+ "windows_aarch64_msvc 0.42.2",
+ "windows_i686_gnu 0.42.2",
+ "windows_i686_msvc 0.42.2",
+ "windows_x86_64_gnu 0.42.2",
+ "windows_x86_64_gnullvm 0.42.2",
+ "windows_x86_64_msvc 0.42.2",
 ]
 
 [[package]]
@@ -2518,7 +2832,7 @@ version = "0.45.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
 dependencies = [
- "windows-targets 0.42.1",
+ "windows-targets 0.42.2",
 ]
 
 [[package]]
@@ -2532,17 +2846,17 @@ dependencies = [
 
 [[package]]
 name = "windows-targets"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
+checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
 dependencies = [
- "windows_aarch64_gnullvm 0.42.1",
- "windows_aarch64_msvc 0.42.1",
- "windows_i686_gnu 0.42.1",
- "windows_i686_msvc 0.42.1",
- "windows_x86_64_gnu 0.42.1",
- "windows_x86_64_gnullvm 0.42.1",
- "windows_x86_64_msvc 0.42.1",
+ "windows_aarch64_gnullvm 0.42.2",
+ "windows_aarch64_msvc 0.42.2",
+ "windows_i686_gnu 0.42.2",
+ "windows_i686_msvc 0.42.2",
+ "windows_x86_64_gnu 0.42.2",
+ "windows_x86_64_gnullvm 0.42.2",
+ "windows_x86_64_msvc 0.42.2",
 ]
 
 [[package]]
@@ -2562,9 +2876,9 @@ dependencies = [
 
 [[package]]
 name = "windows_aarch64_gnullvm"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
+checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
 
 [[package]]
 name = "windows_aarch64_gnullvm"
@@ -2574,9 +2888,9 @@ checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
 
 [[package]]
 name = "windows_aarch64_msvc"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
+checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
 
 [[package]]
 name = "windows_aarch64_msvc"
@@ -2586,9 +2900,9 @@ checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
 
 [[package]]
 name = "windows_i686_gnu"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
+checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
 
 [[package]]
 name = "windows_i686_gnu"
@@ -2598,9 +2912,9 @@ checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
 
 [[package]]
 name = "windows_i686_msvc"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
+checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
 
 [[package]]
 name = "windows_i686_msvc"
@@ -2610,9 +2924,9 @@ checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
 
 [[package]]
 name = "windows_x86_64_gnu"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
+checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
 
 [[package]]
 name = "windows_x86_64_gnu"
@@ -2622,9 +2936,9 @@ checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
 
 [[package]]
 name = "windows_x86_64_gnullvm"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
+checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
 
 [[package]]
 name = "windows_x86_64_gnullvm"
@@ -2634,9 +2948,9 @@ checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
 
 [[package]]
 name = "windows_x86_64_msvc"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
+checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
 
 [[package]]
 name = "windows_x86_64_msvc"
diff --git a/cmake/tomls/Cargo.sgx_trusted_lib.toml b/cmake/tomls/Cargo.sgx_trusted_lib.toml
index 333f7c6c..4bacf775 100644
--- a/cmake/tomls/Cargo.sgx_trusted_lib.toml
+++ b/cmake/tomls/Cargo.sgx_trusted_lib.toml
@@ -65,4 +65,5 @@ ring              = { git = "https://github.com/apache/incubator-teaclave-crates
 rustface          = { git = "https://github.com/apache/incubator-teaclave-crates" }
 rustls            = { git = "https://github.com/apache/incubator-teaclave-crates" }
 rusty-machine     = { git = "https://github.com/apache/incubator-teaclave-crates" }
+tokio             = { git = "https://github.com/tokio-rs/tokio.git", tag = "tokio-1.24.0"}
 yasna             = { git = "https://github.com/sccommunity/yasna.rs", branch = "teaclave-sgx" }
diff --git a/cmake/tomls/Cargo.sgx_untrusted_app.lock b/cmake/tomls/Cargo.sgx_untrusted_app.lock
index 30880024..16b0b014 100644
--- a/cmake/tomls/Cargo.sgx_untrusted_app.lock
+++ b/cmake/tomls/Cargo.sgx_untrusted_app.lock
@@ -2,6 +2,12 @@
 # It is not intended for manual editing.
 version = 3
 
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
 [[package]]
 name = "aho-corasick"
 version = "0.7.20"
@@ -26,6 +32,39 @@ version = "1.0.68"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61"
 
+[[package]]
+name = "async-stream"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51"
+dependencies = [
+ "async-stream-impl",
+ "futures-core",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-stream-impl"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.26",
+ "syn 2.0.15",
+]
+
+[[package]]
+name = "async-trait"
+version = "0.1.68"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.26",
+ "syn 2.0.15",
+]
+
 [[package]]
 name = "atty"
 version = "0.2.14"
@@ -174,6 +213,15 @@ version = "0.8.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
 
+[[package]]
+name = "crc32fast"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
+dependencies = [
+ "cfg-if 1.0.0",
+]
+
 [[package]]
 name = "ctor"
 version = "0.1.26"
@@ -240,6 +288,22 @@ dependencies = [
  "instant",
 ]
 
+[[package]]
+name = "fixedbitset"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
+
+[[package]]
+name = "flate2"
+version = "1.0.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
+dependencies = [
+ "crc32fast",
+ "miniz_oxide",
+]
+
 [[package]]
 name = "fnv"
 version = "1.0.7"
@@ -416,7 +480,7 @@ dependencies = [
  "indexmap",
  "slab",
  "tokio",
- "tokio-util",
+ "tokio-util 0.7.7",
  "tracing",
 ]
 
@@ -530,6 +594,18 @@ dependencies = [
  "want",
 ]
 
+[[package]]
+name = "hyper-timeout"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
+dependencies = [
+ "hyper",
+ "pin-project-lite",
+ "tokio",
+ "tokio-io-timeout",
+]
+
 [[package]]
 name = "hyper-tls"
 version = "0.5.0"
@@ -703,6 +779,15 @@ version = "0.3.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
 
+[[package]]
+name = "miniz_oxide"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
+dependencies = [
+ "adler",
+]
+
 [[package]]
 name = "mio"
 version = "0.8.6"
@@ -715,6 +800,12 @@ dependencies = [
  "windows-sys 0.45.0",
 ]
 
+[[package]]
+name = "multimap"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
+
 [[package]]
 name = "native-tls"
 version = "0.2.11"
@@ -911,6 +1002,36 @@ version = "2.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
 
+[[package]]
+name = "petgraph"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4"
+dependencies = [
+ "fixedbitset",
+ "indexmap",
+]
+
+[[package]]
+name = "pin-project"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"
+dependencies = [
+ "pin-project-internal",
+]
+
+[[package]]
+name = "pin-project-internal"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.26",
+ "syn 1.0.107",
+]
+
 [[package]]
 name = "pin-project-lite"
 version = "0.2.9"
@@ -979,19 +1100,39 @@ dependencies = [
 
 [[package]]
 name = "prost"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537"
+checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
 dependencies = [
  "bytes",
  "prost-derive",
 ]
 
+[[package]]
+name = "prost-build"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5"
+dependencies = [
+ "bytes",
+ "heck",
+ "itertools 0.10.5",
+ "lazy_static",
+ "log",
+ "multimap",
+ "petgraph",
+ "prost",
+ "prost-types",
+ "regex",
+ "tempfile",
+ "which",
+]
+
 [[package]]
 name = "prost-derive"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b"
+checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
 dependencies = [
  "anyhow",
  "itertools 0.10.5",
@@ -1000,6 +1141,16 @@ dependencies = [
  "syn 1.0.107",
 ]
 
+[[package]]
+name = "prost-types"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
+dependencies = [
+ "bytes",
+ "prost",
+]
+
 [[package]]
 name = "quick-error"
 version = "1.2.3"
@@ -1267,7 +1418,7 @@ dependencies = [
  "serde_urlencoded",
  "tokio",
  "tokio-native-tls",
- "tokio-util",
+ "tokio-util 0.7.7",
  "tower-service",
  "url",
  "wasm-bindgen",
@@ -1481,18 +1632,6 @@ dependencies = [
  "sgx_types",
 ]
 
-[[package]]
-name = "sgx_libc"
-version = "2.0.0"
-dependencies = [
- "sgx_ffi",
- "sgx_oc",
- "sgx_sync",
- "sgx_tlibc_sys",
- "sgx_trts",
- "sgx_types",
-]
-
 [[package]]
 name = "sgx_macros"
 version = "2.0.0"
@@ -1746,6 +1885,17 @@ dependencies = [
  "unicode-ident",
 ]
 
+[[package]]
+name = "syn"
+version = "2.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.26",
+ "unicode-ident",
+]
+
 [[package]]
 name = "teaclave_access_control_service"
 version = "0.5.1"
@@ -1866,6 +2016,7 @@ dependencies = [
  "teaclave_file_agent",
  "teaclave_logger",
  "teaclave_service_app_utils",
+ "tokio",
 ]
 
 [[package]]
@@ -1891,6 +2042,7 @@ dependencies = [
  "teaclave_types",
  "teaclave_worker",
  "thiserror",
+ "tokio",
  "url",
  "uuid",
 ]
@@ -1955,7 +2107,7 @@ dependencies = [
  "teaclave_types",
  "thiserror",
  "tokio",
- "tokio-util",
+ "tokio-util 0.7.7",
  "url",
 ]
 
@@ -2050,17 +2202,15 @@ name = "teaclave_proto"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "base64 0.13.1",
- "cfg-if 0.1.10",
  "prost",
- "rand 0.8.5",
  "serde",
  "serde_json",
  "sgx_cov",
  "sgx_types",
  "teaclave_crypto",
- "teaclave_rpc",
  "teaclave_types",
+ "tonic",
+ "tonic-build",
  "url",
  "uuid",
 ]
@@ -2070,31 +2220,14 @@ name = "teaclave_rpc"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "cfg-if 0.1.10",
- "http",
- "libc",
  "log",
  "rustls",
- "serde",
- "serde_json",
- "sgx_libc",
  "teaclave_attestation",
- "teaclave_rpc_proc_macro",
  "teaclave_types",
- "thiserror",
- "threadpool",
+ "tonic",
  "webpki",
 ]
 
-[[package]]
-name = "teaclave_rpc_proc_macro"
-version = "0.5.1"
-dependencies = [
- "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
-]
-
 [[package]]
 name = "teaclave_runtime"
 version = "0.5.1"
@@ -2147,17 +2280,8 @@ dependencies = [
  "teaclave_logger",
  "teaclave_proto",
  "teaclave_rpc",
- "teaclave_service_enclave_utils_proc_macro",
  "teaclave_types",
-]
-
-[[package]]
-name = "teaclave_service_enclave_utils_proc_macro"
-version = "0.5.1"
-dependencies = [
- "proc-macro2 1.0.56",
- "quote 1.0.26",
- "syn 1.0.107",
+ "tokio",
 ]
 
 [[package]]
@@ -2191,8 +2315,10 @@ dependencies = [
 name = "teaclave_test_utils"
 version = "0.5.1"
 dependencies = [
+ "futures",
  "inventory",
  "teaclave_test_utils_proc_macro",
+ "tokio",
 ]
 
 [[package]]
@@ -2221,6 +2347,7 @@ dependencies = [
  "teaclave_test_utils",
  "thiserror",
  "toml",
+ "tonic",
  "url",
  "uuid",
 ]
@@ -2307,15 +2434,6 @@ dependencies = [
  "syn 1.0.107",
 ]
 
-[[package]]
-name = "threadpool"
-version = "1.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
-dependencies = [
- "num_cpus",
-]
-
 [[package]]
 name = "tinyvec"
 version = "1.6.0"
@@ -2344,9 +2462,31 @@ dependencies = [
  "num_cpus",
  "pin-project-lite",
  "socket2",
+ "tokio-macros",
  "windows-sys 0.45.0",
 ]
 
+[[package]]
+name = "tokio-io-timeout"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
+dependencies = [
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.26",
+ "syn 2.0.15",
+]
+
 [[package]]
 name = "tokio-native-tls"
 version = "0.3.1"
@@ -2357,6 +2497,42 @@ dependencies = [
  "tokio",
 ]
 
+[[package]]
+name = "tokio-rustls"
+version = "0.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
+dependencies = [
+ "rustls",
+ "tokio",
+ "webpki",
+]
+
+[[package]]
+name = "tokio-stream"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842"
+dependencies = [
+ "futures-core",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-util"
+version = "0.6.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "log",
+ "pin-project-lite",
+ "tokio",
+]
+
 [[package]]
 name = "tokio-util"
 version = "0.7.7"
@@ -2380,6 +2556,77 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "tonic"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a"
+dependencies = [
+ "async-stream",
+ "async-trait",
+ "base64 0.13.1",
+ "bytes",
+ "flate2",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "hyper",
+ "hyper-timeout",
+ "percent-encoding",
+ "pin-project",
+ "prost",
+ "prost-derive",
+ "tokio",
+ "tokio-rustls",
+ "tokio-stream",
+ "tokio-util 0.6.10",
+ "tower",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+ "tracing-futures",
+]
+
+[[package]]
+name = "tonic-build"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "prost-build",
+ "quote 1.0.26",
+ "syn 1.0.107",
+]
+
+[[package]]
+name = "tower"
+version = "0.4.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
+dependencies = [
+ "futures-core",
+ "futures-util",
+ "indexmap",
+ "pin-project",
+ "pin-project-lite",
+ "rand 0.8.5",
+ "slab",
+ "tokio",
+ "tokio-util 0.7.7",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "tower-layer"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
+
 [[package]]
 name = "tower-service"
 version = "0.3.2"
@@ -2393,10 +2640,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
 dependencies = [
  "cfg-if 1.0.0",
+ "log",
  "pin-project-lite",
+ "tracing-attributes",
  "tracing-core",
 ]
 
+[[package]]
+name = "tracing-attributes"
+version = "0.1.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74"
+dependencies = [
+ "proc-macro2 1.0.56",
+ "quote 1.0.26",
+ "syn 2.0.15",
+]
+
 [[package]]
 name = "tracing-core"
 version = "0.1.30"
@@ -2406,6 +2666,16 @@ dependencies = [
  "once_cell",
 ]
 
+[[package]]
+name = "tracing-futures"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
+dependencies = [
+ "pin-project",
+ "tracing",
+]
+
 [[package]]
 name = "try-lock"
 version = "0.2.3"
@@ -2633,6 +2903,17 @@ dependencies = [
  "webpki",
 ]
 
+[[package]]
+name = "which"
+version = "4.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
+dependencies = [
+ "either",
+ "libc",
+ "once_cell",
+]
+
 [[package]]
 name = "winapi"
 version = "0.3.9"
diff --git a/cmake/tomls/Cargo.sgx_untrusted_app.toml b/cmake/tomls/Cargo.sgx_untrusted_app.toml
index f41e982f..c83473d6 100644
--- a/cmake/tomls/Cargo.sgx_untrusted_app.toml
+++ b/cmake/tomls/Cargo.sgx_untrusted_app.toml
@@ -39,7 +39,6 @@ exclude = [
 # We cannot remove these crates, because proto crates depend on them
 sgx_crypto        = { path = "../../../third_party/rust-sgx-sdk/sgx_crypto" }
 sgx_cov           = { path = "../../../third_party/rust-sgx-sdk/sgx_tests/cov" }
-sgx_libc          = { path = "../../../third_party/rust-sgx-sdk/sgx_libc" }
 sgx_macros        = { path = "../../../third_party/rust-sgx-sdk/sgx_macros" }
 sgx_rand          = { path = "../../../third_party/rust-sgx-sdk/sgx_rand" }
 sgx_tprotected_fs = { path = "../../../third_party/rust-sgx-sdk/sgx_protected_fs/tfs" }
diff --git a/cmake/tomls/Cargo.unix_app.lock b/cmake/tomls/Cargo.unix_app.lock
index 389a6442..f7050aaa 100644
--- a/cmake/tomls/Cargo.unix_app.lock
+++ b/cmake/tomls/Cargo.unix_app.lock
@@ -2,6 +2,12 @@
 # It is not intended for manual editing.
 version = 3
 
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
 [[package]]
 name = "aead"
 version = "0.5.1"
@@ -286,6 +292,15 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "crc32fast"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
+dependencies = [
+ "cfg-if 1.0.0",
+]
+
 [[package]]
 name = "crypto-common"
 version = "0.1.6"
@@ -455,6 +470,22 @@ dependencies = [
  "version_check",
 ]
 
+[[package]]
+name = "fixedbitset"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
+
+[[package]]
+name = "flate2"
+version = "1.0.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"
+dependencies = [
+ "crc32fast",
+ "miniz_oxide",
+]
+
 [[package]]
 name = "fnv"
 version = "1.0.7"
@@ -478,6 +509,7 @@ checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0"
 dependencies = [
  "futures-channel",
  "futures-core",
+ "futures-executor",
  "futures-io",
  "futures-sink",
  "futures-task",
@@ -500,12 +532,34 @@ version = "0.3.25"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac"
 
+[[package]]
+name = "futures-executor"
+version = "0.3.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "futures-util",
+]
+
 [[package]]
 name = "futures-io"
 version = "0.3.25"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb"
 
+[[package]]
+name = "futures-macro"
+version = "0.3.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "futures-sink"
 version = "0.3.25"
@@ -527,6 +581,7 @@ dependencies = [
  "futures-channel",
  "futures-core",
  "futures-io",
+ "futures-macro",
  "futures-sink",
  "futures-task",
  "memchr",
@@ -611,7 +666,7 @@ dependencies = [
  "indexmap",
  "slab",
  "tokio",
- "tokio-util",
+ "tokio-util 0.7.4",
  "tracing",
 ]
 
@@ -743,6 +798,18 @@ dependencies = [
  "want",
 ]
 
+[[package]]
+name = "hyper-timeout"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
+dependencies = [
+ "hyper",
+ "pin-project-lite",
+ "tokio",
+ "tokio-io-timeout",
+]
+
 [[package]]
 name = "iana-time-zone"
 version = "0.1.53"
@@ -934,6 +1001,15 @@ version = "0.3.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
 
+[[package]]
+name = "miniz_oxide"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
+dependencies = [
+ "adler",
+]
+
 [[package]]
 name = "mio"
 version = "0.8.5"
@@ -962,10 +1038,16 @@ dependencies = [
  "mime",
  "spin 0.9.4",
  "tokio",
- "tokio-util",
+ "tokio-util 0.7.4",
  "version_check",
 ]
 
+[[package]]
+name = "multimap"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
+
 [[package]]
 name = "nu-ansi-term"
 version = "0.46.0"
@@ -1097,6 +1179,36 @@ version = "2.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
 
+[[package]]
+name = "petgraph"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4"
+dependencies = [
+ "fixedbitset",
+ "indexmap",
+]
+
+[[package]]
+name = "pin-project"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"
+dependencies = [
+ "pin-project-internal",
+]
+
+[[package]]
+name = "pin-project-internal"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "pin-project-lite"
 version = "0.2.9"
@@ -1175,19 +1287,39 @@ dependencies = [
 
 [[package]]
 name = "prost"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537"
+checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
 dependencies = [
  "bytes",
  "prost-derive",
 ]
 
+[[package]]
+name = "prost-build"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5"
+dependencies = [
+ "bytes",
+ "heck",
+ "itertools",
+ "lazy_static",
+ "log",
+ "multimap",
+ "petgraph",
+ "prost",
+ "prost-types",
+ "regex",
+ "tempfile",
+ "which",
+]
+
 [[package]]
 name = "prost-derive"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b"
+checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
 dependencies = [
  "anyhow",
  "itertools",
@@ -1196,6 +1328,16 @@ dependencies = [
  "syn",
 ]
 
+[[package]]
+name = "prost-types"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
+dependencies = [
+ "bytes",
+ "prost",
+]
+
 [[package]]
 name = "quick-error"
 version = "1.2.3"
@@ -1360,7 +1502,7 @@ dependencies = [
  "time 0.3.17",
  "tokio",
  "tokio-stream",
- "tokio-util",
+ "tokio-util 0.7.4",
  "ubyte",
  "version_check",
  "yansi",
@@ -1406,7 +1548,7 @@ dependencies = [
  "state",
  "time 0.3.17",
  "tokio",
- "tokio-rustls",
+ "tokio-rustls 0.23.4",
  "uncased",
 ]
 
@@ -1575,18 +1717,6 @@ dependencies = [
  "sgx_types",
 ]
 
-[[package]]
-name = "sgx_libc"
-version = "2.0.0"
-dependencies = [
- "sgx_ffi",
- "sgx_oc",
- "sgx_sync",
- "sgx_tlibc_sys",
- "sgx_trts",
- "sgx_types",
-]
-
 [[package]]
 name = "sgx_oc"
 version = "2.0.0"
@@ -1909,6 +2039,7 @@ dependencies = [
  "teaclave_proto",
  "teaclave_rpc",
  "teaclave_types",
+ "tokio",
  "url",
 ]
 
@@ -1964,17 +2095,15 @@ name = "teaclave_proto"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "base64 0.13.1",
- "cfg-if 0.1.10",
  "prost",
- "rand",
  "serde",
  "serde_json",
  "sgx_cov",
  "sgx_types",
  "teaclave_crypto",
- "teaclave_rpc",
  "teaclave_types",
+ "tonic",
+ "tonic-build",
  "url",
  "uuid",
 ]
@@ -1984,37 +2113,22 @@ name = "teaclave_rpc"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "cfg-if 0.1.10",
- "http",
- "libc",
  "log",
  "rustls 0.19.1",
- "serde",
- "serde_json",
- "sgx_libc",
  "teaclave_attestation",
- "teaclave_rpc_proc_macro",
  "teaclave_types",
- "thiserror",
- "threadpool",
+ "tonic",
  "webpki 0.21.4",
 ]
 
-[[package]]
-name = "teaclave_rpc_proc_macro"
-version = "0.5.1"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
 [[package]]
 name = "teaclave_test_utils"
 version = "0.5.1"
 dependencies = [
+ "futures",
  "inventory",
  "teaclave_test_utils_proc_macro",
+ "tokio",
 ]
 
 [[package]]
@@ -2043,6 +2157,7 @@ dependencies = [
  "teaclave_test_utils",
  "thiserror",
  "toml",
+ "tonic",
  "url",
  "uuid",
 ]
@@ -2108,15 +2223,6 @@ dependencies = [
  "once_cell",
 ]
 
-[[package]]
-name = "threadpool"
-version = "1.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
-dependencies = [
- "num_cpus",
-]
-
 [[package]]
 name = "time"
 version = "0.1.45"
@@ -2189,6 +2295,16 @@ dependencies = [
  "windows-sys",
 ]
 
+[[package]]
+name = "tokio-io-timeout"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
+dependencies = [
+ "pin-project-lite",
+ "tokio",
+]
+
 [[package]]
 name = "tokio-macros"
 version = "1.8.2"
@@ -2200,6 +2316,17 @@ dependencies = [
  "syn",
 ]
 
+[[package]]
+name = "tokio-rustls"
+version = "0.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
+dependencies = [
+ "rustls 0.19.1",
+ "tokio",
+ "webpki 0.21.4",
+]
+
 [[package]]
 name = "tokio-rustls"
 version = "0.23.4"
@@ -2222,6 +2349,20 @@ dependencies = [
  "tokio",
 ]
 
+[[package]]
+name = "tokio-util"
+version = "0.6.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "log",
+ "pin-project-lite",
+ "tokio",
+]
+
 [[package]]
 name = "tokio-util"
 version = "0.7.4"
@@ -2245,6 +2386,77 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "tonic"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a"
+dependencies = [
+ "async-stream",
+ "async-trait",
+ "base64 0.13.1",
+ "bytes",
+ "flate2",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "hyper",
+ "hyper-timeout",
+ "percent-encoding",
+ "pin-project",
+ "prost",
+ "prost-derive",
+ "tokio",
+ "tokio-rustls 0.22.0",
+ "tokio-stream",
+ "tokio-util 0.6.10",
+ "tower",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+ "tracing-futures",
+]
+
+[[package]]
+name = "tonic-build"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757"
+dependencies = [
+ "proc-macro2",
+ "prost-build",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "tower"
+version = "0.4.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
+dependencies = [
+ "futures-core",
+ "futures-util",
+ "indexmap",
+ "pin-project",
+ "pin-project-lite",
+ "rand",
+ "slab",
+ "tokio",
+ "tokio-util 0.7.4",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "tower-layer"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
+
 [[package]]
 name = "tower-service"
 version = "0.3.2"
@@ -2258,6 +2470,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
 dependencies = [
  "cfg-if 1.0.0",
+ "log",
  "pin-project-lite",
  "tracing-attributes",
  "tracing-core",
@@ -2284,6 +2497,16 @@ dependencies = [
  "valuable",
 ]
 
+[[package]]
+name = "tracing-futures"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
+dependencies = [
+ "pin-project",
+ "tracing",
+]
+
 [[package]]
 name = "tracing-log"
 version = "0.1.3"
@@ -2555,6 +2778,17 @@ dependencies = [
  "webpki 0.21.4",
 ]
 
+[[package]]
+name = "which"
+version = "4.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
+dependencies = [
+ "either",
+ "libc",
+ "once_cell",
+]
+
 [[package]]
 name = "winapi"
 version = "0.3.9"
diff --git a/cmake/tomls/Cargo.unix_app.toml b/cmake/tomls/Cargo.unix_app.toml
index a2a9efd3..c9cc713b 100644
--- a/cmake/tomls/Cargo.unix_app.toml
+++ b/cmake/tomls/Cargo.unix_app.toml
@@ -33,7 +33,6 @@ exclude = [
 
 sgx_cov           = { path = "../../../third_party/rust-sgx-sdk/sgx_tests/cov" }
 sgx_crypto        = { path = "../../../third_party/rust-sgx-sdk/sgx_crypto" }
-sgx_libc          = { path = "../../../third_party/rust-sgx-sdk/sgx_libc" }
 sgx_rand          = { path = "../../../third_party/rust-sgx-sdk/sgx_rand" }
 sgx_tprotected_fs = { path = "../../../third_party/rust-sgx-sdk/sgx_protected_fs/tfs" }
 sgx_tse           = { path = "../../../third_party/rust-sgx-sdk/sgx_tse" }
diff --git a/config/runtime.config.toml b/config/runtime.config.toml
index 96a7529b..b1187eb3 100644
--- a/config/runtime.config.toml
+++ b/config/runtime.config.toml
@@ -24,12 +24,12 @@ authentication = { listen_address = "0.0.0.0:7776" }
 frontend       = { listen_address = "0.0.0.0:7777" }
 
 [internal_endpoints]
-authentication = { listen_address = "0.0.0.0:17776", advertised_address = "localhost:17776" }
-management     = { listen_address = "0.0.0.0:17777", advertised_address = "localhost:17777" }
-storage        = { listen_address = "0.0.0.0:17778", advertised_address = "localhost:17778" }
-access_control = { listen_address = "0.0.0.0:17779", advertised_address = "localhost:17779" }
-execution      = { listen_address = "0.0.0.0:17770", advertised_address = "localhost:17770" }
-scheduler      = { listen_address = "0.0.0.0:17780", advertised_address = "localhost:17780" }
+authentication = { listen_address = "0.0.0.0:17776", advertised_address = "https://localhost:17776" }
+management     = { listen_address = "0.0.0.0:17777", advertised_address = "https://localhost:17777" }
+storage        = { listen_address = "0.0.0.0:17778", advertised_address = "https://localhost:17778" }
+access_control = { listen_address = "0.0.0.0:17779", advertised_address = "https://localhost:17779" }
+execution      = { listen_address = "0.0.0.0:17770", advertised_address = "https://localhost:17770" }
+scheduler      = { listen_address = "0.0.0.0:17780", advertised_address = "https://localhost:17780" }
 
 [audit]
 enclave_info = { path = "enclave_info.toml" }
diff --git a/docs/service-internals.md b/docs/service-internals.md
index 02fd2d51..3743ba07 100644
--- a/docs/service-internals.md
+++ b/docs/service-internals.md
@@ -42,13 +42,7 @@ message with `token` inside (in string type).
 
 With this definition, the build system will help to generate utility functions,
 traits, and structures for clients to send RPC requests, and for service to
-implement functions of handling requests. This is done by a build time tool
-called [`proto_gen`](https://github.com/apache/incubator-teaclave/tree/master/services/proto/proto_gen).
-
-There is another layer in the `teaclave_proto` crate to help convert protobuf's
-simple data type to Rust's more concise data type. For example, a URL is defined
-in the string type in protobuf, while in Rust we can use the `Url` struct to
-store a URL.
+implement functions of handling requests. This is done by [`tonic_build`](https://github.com/hyperium/tonic/tree/master/tonic-build).
 
 For more protocol definitions for other services, please see proto files in
 the [`proto` directory](https://github.com/apache/incubator-teaclave/tree/master/services/proto/src/proto).
@@ -113,16 +107,16 @@ let attested_tls_config = RemoteAttestation::new(attestation_config)
     .generate_and_endorse()?
     .attested_tls_config()
     .ok_or_else(|| anyhow!("cannot get attested TLS config"))?;
-let server_config = SgxTrustedTlsServerConfig::from_attested_tls_config(attested_tls_config)?;
-
-let mut server = SgxTrustedTlsServer::<
-    TeaclaveAuthenticationApiResponse,
-    TeaclaveAuthenticationApiRequest,
->::new(addr, server_config);
+let server_config = SgxTrustedTlsServerConfig::from_attested_tls_config(attested_tls_config)?.into();
 
 let service = api_service::TeaclaveAuthenticationApiService::new(db_client, jwt_secret);
 
-match server.start(service) {}
+Server::builder()
+    .tls_config(tls_config)
+    .map_err(|_| anyhow!("TeaclaveAuthenticationApiServer tls config error"))?
+    .add_service(TeaclaveAuthenticationApiServer::new(service))
+    .serve(addr)
+    .await?;
 ```
 
 ## Topology
diff --git a/examples/c/utils.h b/examples/c/utils.h
index 7901fa76..61f89376 100644
--- a/examples/c/utils.h
+++ b/examples/c/utils.h
@@ -18,8 +18,8 @@
  *
  */
 
-const char *authentication_service_address = "localhost:7776";
-const char *frontend_service_address = "localhost:7777";
+const char *authentication_service_address = "https://localhost:7776";
+const char *frontend_service_address = "https://localhost:7777";
 const char *enclave_info_path = "../../release/services/enclave_info.toml";
 #ifdef DCAP
 const char *as_root_ca_cert_path = "../../keys/dcap_root_ca_cert.pem";
diff --git a/examples/rust/builtin_echo/Cargo.lock b/examples/rust/builtin_echo/Cargo.lock
index 06034884..2e06e3a3 100644
--- a/examples/rust/builtin_echo/Cargo.lock
+++ b/examples/rust/builtin_echo/Cargo.lock
@@ -2,6 +2,12 @@
 # It is not intended for manual editing.
 version = 3
 
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
 [[package]]
 name = "aho-corasick"
 version = "0.7.20"
@@ -17,6 +23,39 @@ version = "1.0.66"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
 
+[[package]]
+name = "async-stream"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e"
+dependencies = [
+ "async-stream-impl",
+ "futures-core",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-stream-impl"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "async-trait"
+version = "0.1.68"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.12",
+]
+
 [[package]]
 name = "autocfg"
 version = "1.1.0"
@@ -41,6 +80,12 @@ version = "0.6.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
 
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
 [[package]]
 name = "builtin_echo"
 version = "0.5.1"
@@ -90,12 +135,67 @@ dependencies = [
  "num-traits",
 ]
 
+[[package]]
+name = "crc32fast"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
+dependencies = [
+ "cfg-if 1.0.0",
+]
+
 [[package]]
 name = "either"
 version = "1.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
 
+[[package]]
+name = "errno"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0"
+dependencies = [
+ "errno-dragonfly",
+ "libc",
+ "windows-sys",
+]
+
+[[package]]
+name = "errno-dragonfly"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
+dependencies = [
+ "cc",
+ "libc",
+]
+
+[[package]]
+name = "fastrand"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
+dependencies = [
+ "instant",
+]
+
+[[package]]
+name = "fixedbitset"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
+
+[[package]]
+name = "flate2"
+version = "1.0.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
+dependencies = [
+ "crc32fast",
+ "miniz_oxide",
+]
+
 [[package]]
 name = "fnv"
 version = "1.0.7"
@@ -111,6 +211,45 @@ dependencies = [
  "percent-encoding",
 ]
 
+[[package]]
+name = "futures-channel"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
+dependencies = [
+ "futures-core",
+]
+
+[[package]]
+name = "futures-core"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
+
+[[package]]
+name = "futures-sink"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e"
+
+[[package]]
+name = "futures-task"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
+
+[[package]]
+name = "futures-util"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "pin-project-lite",
+ "pin-utils",
+]
+
 [[package]]
 name = "getrandom"
 version = "0.2.8"
@@ -122,6 +261,40 @@ dependencies = [
  "wasi",
 ]
 
+[[package]]
+name = "h2"
+version = "0.3.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d"
+dependencies = [
+ "bytes",
+ "fnv",
+ "futures-core",
+ "futures-sink",
+ "futures-util",
+ "http",
+ "indexmap",
+ "slab",
+ "tokio",
+ "tokio-util 0.7.7",
+ "tracing",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+
+[[package]]
+name = "heck"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
+dependencies = [
+ "unicode-segmentation",
+]
+
 [[package]]
 name = "hermit-abi"
 version = "0.1.19"
@@ -131,6 +304,12 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "hermit-abi"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
+
 [[package]]
 name = "hex"
 version = "0.4.3"
@@ -148,12 +327,65 @@ dependencies = [
  "itoa",
 ]
 
+[[package]]
+name = "http-body"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"
+dependencies = [
+ "bytes",
+ "http",
+ "pin-project-lite",
+]
+
 [[package]]
 name = "httparse"
 version = "1.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"
 
+[[package]]
+name = "httpdate"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
+
+[[package]]
+name = "hyper"
+version = "0.14.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "httparse",
+ "httpdate",
+ "itoa",
+ "pin-project-lite",
+ "socket2",
+ "tokio",
+ "tower-service",
+ "tracing",
+ "want",
+]
+
+[[package]]
+name = "hyper-timeout"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
+dependencies = [
+ "hyper",
+ "pin-project-lite",
+ "tokio",
+ "tokio-io-timeout",
+]
+
 [[package]]
 name = "idna"
 version = "0.3.0"
@@ -164,6 +396,36 @@ dependencies = [
  "unicode-normalization",
 ]
 
+[[package]]
+name = "indexmap"
+version = "1.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
+dependencies = [
+ "autocfg",
+ "hashbrown",
+]
+
+[[package]]
+name = "instant"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
+dependencies = [
+ "cfg-if 1.0.0",
+]
+
+[[package]]
+name = "io-lifetimes"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb"
+dependencies = [
+ "hermit-abi 0.3.1",
+ "libc",
+ "windows-sys",
+]
+
 [[package]]
 name = "itertools"
 version = "0.10.5"
@@ -196,9 +458,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
 [[package]]
 name = "libc"
-version = "0.2.138"
+version = "0.2.140"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
+checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f"
 
 [[package]]
 name = "log"
@@ -215,6 +483,33 @@ version = "2.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
 
+[[package]]
+name = "miniz_oxide"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
+dependencies = [
+ "adler",
+]
+
+[[package]]
+name = "mio"
+version = "0.8.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
+dependencies = [
+ "libc",
+ "log",
+ "wasi",
+ "windows-sys",
+]
+
+[[package]]
+name = "multimap"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
+
 [[package]]
 name = "num-bigint"
 version = "0.2.6"
@@ -251,7 +546,7 @@ version = "1.14.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5"
 dependencies = [
- "hermit-abi",
+ "hermit-abi 0.1.19",
  "libc",
 ]
 
@@ -278,6 +573,48 @@ version = "2.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
 
+[[package]]
+name = "petgraph"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4"
+dependencies = [
+ "fixedbitset",
+ "indexmap",
+]
+
+[[package]]
+name = "pin-project"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"
+dependencies = [
+ "pin-project-internal",
+]
+
+[[package]]
+name = "pin-project-internal"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
+
+[[package]]
+name = "pin-utils"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
+
 [[package]]
 name = "ppv-lite86"
 version = "0.2.17"
@@ -286,41 +623,71 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.47"
+version = "1.0.54"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
+checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534"
 dependencies = [
  "unicode-ident",
 ]
 
 [[package]]
 name = "prost"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537"
+checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
 dependencies = [
  "bytes",
  "prost-derive",
 ]
 
+[[package]]
+name = "prost-build"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5"
+dependencies = [
+ "bytes",
+ "heck",
+ "itertools",
+ "lazy_static",
+ "log",
+ "multimap",
+ "petgraph",
+ "prost",
+ "prost-types",
+ "regex",
+ "tempfile",
+ "which",
+]
+
 [[package]]
 name = "prost-derive"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b"
+checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
 dependencies = [
  "anyhow",
  "itertools",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "prost-types"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
+dependencies = [
+ "bytes",
+ "prost",
 ]
 
 [[package]]
 name = "quote"
-version = "1.0.21"
+version = "1.0.26"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
+checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
 dependencies = [
  "proc-macro2",
 ]
@@ -364,6 +731,15 @@ dependencies = [
  "rand_core",
 ]
 
+[[package]]
+name = "redox_syscall"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
+dependencies = [
+ "bitflags",
+]
+
 [[package]]
 name = "regex"
 version = "1.7.0"
@@ -396,13 +772,27 @@ dependencies = [
  "winapi",
 ]
 
+[[package]]
+name = "rustix"
+version = "0.37.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e78cc525325c06b4a7ff02db283472f3c042b7ff0c391f96c6d5ac6f4f91b75"
+dependencies = [
+ "bitflags",
+ "errno",
+ "io-lifetimes",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys",
+]
+
 [[package]]
 name = "rustls"
-version = "0.17.0"
+version = "0.19.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1"
+checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7"
 dependencies = [
- "base64 0.11.0",
+ "base64 0.13.1",
  "log",
  "ring",
  "sct",
@@ -442,7 +832,7 @@ checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
 ]
 
 [[package]]
@@ -530,6 +920,25 @@ version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
 
+[[package]]
+name = "slab"
+version = "0.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "socket2"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662"
+dependencies = [
+ "libc",
+ "winapi",
+]
+
 [[package]]
 name = "spin"
 version = "0.5.2"
@@ -547,6 +956,17 @@ dependencies = [
  "unicode-ident",
 ]
 
+[[package]]
+name = "syn"
+version = "2.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
 [[package]]
 name = "teaclave_attestation"
 version = "0.5.1"
@@ -588,6 +1008,7 @@ dependencies = [
  "teaclave_proto",
  "teaclave_rpc",
  "teaclave_types",
+ "tokio",
  "url",
 ]
 
@@ -620,16 +1041,14 @@ name = "teaclave_proto"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "base64 0.13.1",
- "cfg-if 0.1.10",
  "prost",
- "rand",
  "serde",
  "serde_json",
  "sgx_types",
  "teaclave_crypto",
- "teaclave_rpc",
  "teaclave_types",
+ "tonic",
+ "tonic-build",
  "url",
  "uuid",
 ]
@@ -639,29 +1058,14 @@ name = "teaclave_rpc"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "cfg-if 0.1.10",
- "http",
  "log",
  "rustls",
- "serde",
- "serde_json",
  "teaclave_attestation",
- "teaclave_rpc_proc_macro",
  "teaclave_types",
- "thiserror",
- "threadpool",
+ "tonic",
  "webpki",
 ]
 
-[[package]]
-name = "teaclave_rpc_proc_macro"
-version = "0.5.1"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
 [[package]]
 name = "teaclave_types"
 version = "0.5.1"
@@ -678,10 +1082,24 @@ dependencies = [
  "teaclave_crypto",
  "thiserror",
  "toml",
+ "tonic",
  "url",
  "uuid",
 ]
 
+[[package]]
+name = "tempfile"
+version = "3.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998"
+dependencies = [
+ "cfg-if 1.0.0",
+ "fastrand",
+ "redox_syscall",
+ "rustix",
+ "windows-sys",
+]
+
 [[package]]
 name = "thiserror"
 version = "1.0.37"
@@ -699,16 +1117,7 @@ checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
-]
-
-[[package]]
-name = "threadpool"
-version = "1.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
-dependencies = [
- "num_cpus",
+ "syn 1.0.105",
 ]
 
 [[package]]
@@ -726,6 +1135,94 @@ version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
 
+[[package]]
+name = "tokio"
+version = "1.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001"
+dependencies = [
+ "autocfg",
+ "bytes",
+ "libc",
+ "mio",
+ "num_cpus",
+ "pin-project-lite",
+ "socket2",
+ "tokio-macros",
+ "windows-sys",
+]
+
+[[package]]
+name = "tokio-io-timeout"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
+dependencies = [
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.12",
+]
+
+[[package]]
+name = "tokio-rustls"
+version = "0.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
+dependencies = [
+ "rustls",
+ "tokio",
+ "webpki",
+]
+
+[[package]]
+name = "tokio-stream"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313"
+dependencies = [
+ "futures-core",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-util"
+version = "0.6.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "log",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-util"
+version = "0.7.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "pin-project-lite",
+ "tokio",
+ "tracing",
+]
+
 [[package]]
 name = "toml"
 version = "0.5.9"
@@ -735,6 +1232,132 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "tonic"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a"
+dependencies = [
+ "async-stream",
+ "async-trait",
+ "base64 0.13.1",
+ "bytes",
+ "flate2",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "hyper",
+ "hyper-timeout",
+ "percent-encoding",
+ "pin-project",
+ "prost",
+ "prost-derive",
+ "tokio",
+ "tokio-rustls",
+ "tokio-stream",
+ "tokio-util 0.6.10",
+ "tower",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+ "tracing-futures",
+]
+
+[[package]]
+name = "tonic-build"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757"
+dependencies = [
+ "proc-macro2",
+ "prost-build",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "tower"
+version = "0.4.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
+dependencies = [
+ "futures-core",
+ "futures-util",
+ "indexmap",
+ "pin-project",
+ "pin-project-lite",
+ "rand",
+ "slab",
+ "tokio",
+ "tokio-util 0.7.7",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "tower-layer"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
+
+[[package]]
+name = "tower-service"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
+
+[[package]]
+name = "tracing"
+version = "0.1.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
+dependencies = [
+ "cfg-if 1.0.0",
+ "log",
+ "pin-project-lite",
+ "tracing-attributes",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-attributes"
+version = "0.1.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
+dependencies = [
+ "once_cell",
+]
+
+[[package]]
+name = "tracing-futures"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
+dependencies = [
+ "pin-project",
+ "tracing",
+]
+
+[[package]]
+name = "try-lock"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
+
 [[package]]
 name = "unicode-bidi"
 version = "0.3.8"
@@ -756,6 +1379,12 @@ dependencies = [
  "tinyvec",
 ]
 
+[[package]]
+name = "unicode-segmentation"
+version = "1.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
+
 [[package]]
 name = "untrusted"
 version = "0.7.1"
@@ -785,6 +1414,16 @@ dependencies = [
  "sha1",
 ]
 
+[[package]]
+name = "want"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0"
+dependencies = [
+ "log",
+ "try-lock",
+]
+
 [[package]]
 name = "wasi"
 version = "0.11.0+wasi-snapshot-preview1"
@@ -812,7 +1451,7 @@ dependencies = [
  "once_cell",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
  "wasm-bindgen-shared",
 ]
 
@@ -834,7 +1473,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
  "wasm-bindgen-backend",
  "wasm-bindgen-shared",
 ]
@@ -874,6 +1513,17 @@ dependencies = [
  "webpki",
 ]
 
+[[package]]
+name = "which"
+version = "4.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
+dependencies = [
+ "either",
+ "libc",
+ "once_cell",
+]
+
 [[package]]
 name = "winapi"
 version = "0.3.9"
@@ -896,6 +1546,72 @@ version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
 
+[[package]]
+name = "windows-sys"
+version = "0.45.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
+
 [[package]]
 name = "yasna"
 version = "0.3.2"
diff --git a/examples/rust/builtin_echo/src/main.rs b/examples/rust/builtin_echo/src/main.rs
index f595274d..6f3d1c1d 100644
--- a/examples/rust/builtin_echo/src/main.rs
+++ b/examples/rust/builtin_echo/src/main.rs
@@ -43,7 +43,7 @@ fn echo(message: &str) -> Result<Vec<u8>> {
     let bytes = fs::read(AS_ROOT_CA_CERT_PATH)?;
     let as_root_ca_cert = pem::parse(bytes)?.contents;
     let mut client = teaclave_client_sdk::AuthenticationService::connect(
-        "localhost:7776",
+        "https://localhost:7776",
         &enclave_info,
         &as_root_ca_cert,
     )?;
@@ -52,7 +52,7 @@ fn echo(message: &str) -> Result<Vec<u8>> {
     let token = client.user_login(USER_ID, USER_PASSWORD)?;
 
     let mut client = teaclave_client_sdk::FrontendService::connect(
-        "localhost:7777",
+        "https://localhost:7777",
         &enclave_info,
         &as_root_ca_cert,
     )?;
diff --git a/examples/rust/builtin_ordered_set_intersect/Cargo.lock b/examples/rust/builtin_ordered_set_intersect/Cargo.lock
index a0dcae17..05a35429 100644
--- a/examples/rust/builtin_ordered_set_intersect/Cargo.lock
+++ b/examples/rust/builtin_ordered_set_intersect/Cargo.lock
@@ -2,6 +2,12 @@
 # It is not intended for manual editing.
 version = 3
 
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
 [[package]]
 name = "aho-corasick"
 version = "0.7.20"
@@ -17,6 +23,39 @@ version = "1.0.66"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
 
+[[package]]
+name = "async-stream"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e"
+dependencies = [
+ "async-stream-impl",
+ "futures-core",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-stream-impl"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "async-trait"
+version = "0.1.68"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.12",
+]
+
 [[package]]
 name = "autocfg"
 version = "1.1.0"
@@ -41,6 +80,12 @@ version = "0.6.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
 
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
 [[package]]
 name = "builtin_ordered_set_intersect"
 version = "0.5.1"
@@ -90,12 +135,67 @@ dependencies = [
  "num-traits",
 ]
 
+[[package]]
+name = "crc32fast"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
+dependencies = [
+ "cfg-if 1.0.0",
+]
+
 [[package]]
 name = "either"
 version = "1.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
 
+[[package]]
+name = "errno"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0"
+dependencies = [
+ "errno-dragonfly",
+ "libc",
+ "windows-sys",
+]
+
+[[package]]
+name = "errno-dragonfly"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
+dependencies = [
+ "cc",
+ "libc",
+]
+
+[[package]]
+name = "fastrand"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
+dependencies = [
+ "instant",
+]
+
+[[package]]
+name = "fixedbitset"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
+
+[[package]]
+name = "flate2"
+version = "1.0.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
+dependencies = [
+ "crc32fast",
+ "miniz_oxide",
+]
+
 [[package]]
 name = "fnv"
 version = "1.0.7"
@@ -111,6 +211,45 @@ dependencies = [
  "percent-encoding",
 ]
 
+[[package]]
+name = "futures-channel"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2"
+dependencies = [
+ "futures-core",
+]
+
+[[package]]
+name = "futures-core"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c"
+
+[[package]]
+name = "futures-sink"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e"
+
+[[package]]
+name = "futures-task"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
+
+[[package]]
+name = "futures-util"
+version = "0.3.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "pin-project-lite",
+ "pin-utils",
+]
+
 [[package]]
 name = "getrandom"
 version = "0.2.8"
@@ -122,6 +261,40 @@ dependencies = [
  "wasi",
 ]
 
+[[package]]
+name = "h2"
+version = "0.3.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d"
+dependencies = [
+ "bytes",
+ "fnv",
+ "futures-core",
+ "futures-sink",
+ "futures-util",
+ "http",
+ "indexmap",
+ "slab",
+ "tokio",
+ "tokio-util 0.7.7",
+ "tracing",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+
+[[package]]
+name = "heck"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
+dependencies = [
+ "unicode-segmentation",
+]
+
 [[package]]
 name = "hermit-abi"
 version = "0.1.19"
@@ -131,6 +304,12 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "hermit-abi"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
+
 [[package]]
 name = "hex"
 version = "0.4.3"
@@ -148,12 +327,65 @@ dependencies = [
  "itoa",
 ]
 
+[[package]]
+name = "http-body"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"
+dependencies = [
+ "bytes",
+ "http",
+ "pin-project-lite",
+]
+
 [[package]]
 name = "httparse"
 version = "1.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"
 
+[[package]]
+name = "httpdate"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
+
+[[package]]
+name = "hyper"
+version = "0.14.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "httparse",
+ "httpdate",
+ "itoa",
+ "pin-project-lite",
+ "socket2",
+ "tokio",
+ "tower-service",
+ "tracing",
+ "want",
+]
+
+[[package]]
+name = "hyper-timeout"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
+dependencies = [
+ "hyper",
+ "pin-project-lite",
+ "tokio",
+ "tokio-io-timeout",
+]
+
 [[package]]
 name = "idna"
 version = "0.3.0"
@@ -164,6 +396,36 @@ dependencies = [
  "unicode-normalization",
 ]
 
+[[package]]
+name = "indexmap"
+version = "1.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
+dependencies = [
+ "autocfg",
+ "hashbrown",
+]
+
+[[package]]
+name = "instant"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
+dependencies = [
+ "cfg-if 1.0.0",
+]
+
+[[package]]
+name = "io-lifetimes"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb"
+dependencies = [
+ "hermit-abi 0.3.1",
+ "libc",
+ "windows-sys",
+]
+
 [[package]]
 name = "itertools"
 version = "0.10.5"
@@ -196,9 +458,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
 [[package]]
 name = "libc"
-version = "0.2.138"
+version = "0.2.140"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
+checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f"
 
 [[package]]
 name = "log"
@@ -215,6 +483,33 @@ version = "2.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
 
+[[package]]
+name = "miniz_oxide"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
+dependencies = [
+ "adler",
+]
+
+[[package]]
+name = "mio"
+version = "0.8.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
+dependencies = [
+ "libc",
+ "log",
+ "wasi",
+ "windows-sys",
+]
+
+[[package]]
+name = "multimap"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
+
 [[package]]
 name = "num-bigint"
 version = "0.2.6"
@@ -251,7 +546,7 @@ version = "1.14.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5"
 dependencies = [
- "hermit-abi",
+ "hermit-abi 0.1.19",
  "libc",
 ]
 
@@ -278,6 +573,48 @@ version = "2.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
 
+[[package]]
+name = "petgraph"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4"
+dependencies = [
+ "fixedbitset",
+ "indexmap",
+]
+
+[[package]]
+name = "pin-project"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"
+dependencies = [
+ "pin-project-internal",
+]
+
+[[package]]
+name = "pin-project-internal"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
+
+[[package]]
+name = "pin-utils"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
+
 [[package]]
 name = "ppv-lite86"
 version = "0.2.17"
@@ -286,41 +623,71 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.47"
+version = "1.0.54"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
+checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534"
 dependencies = [
  "unicode-ident",
 ]
 
 [[package]]
 name = "prost"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537"
+checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
 dependencies = [
  "bytes",
  "prost-derive",
 ]
 
+[[package]]
+name = "prost-build"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5"
+dependencies = [
+ "bytes",
+ "heck",
+ "itertools",
+ "lazy_static",
+ "log",
+ "multimap",
+ "petgraph",
+ "prost",
+ "prost-types",
+ "regex",
+ "tempfile",
+ "which",
+]
+
 [[package]]
 name = "prost-derive"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b"
+checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
 dependencies = [
  "anyhow",
  "itertools",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "prost-types"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
+dependencies = [
+ "bytes",
+ "prost",
 ]
 
 [[package]]
 name = "quote"
-version = "1.0.21"
+version = "1.0.26"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
+checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
 dependencies = [
  "proc-macro2",
 ]
@@ -364,6 +731,15 @@ dependencies = [
  "rand_core",
 ]
 
+[[package]]
+name = "redox_syscall"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
+dependencies = [
+ "bitflags",
+]
+
 [[package]]
 name = "regex"
 version = "1.7.0"
@@ -396,13 +772,27 @@ dependencies = [
  "winapi",
 ]
 
+[[package]]
+name = "rustix"
+version = "0.37.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e78cc525325c06b4a7ff02db283472f3c042b7ff0c391f96c6d5ac6f4f91b75"
+dependencies = [
+ "bitflags",
+ "errno",
+ "io-lifetimes",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys",
+]
+
 [[package]]
 name = "rustls"
-version = "0.17.0"
+version = "0.19.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1"
+checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7"
 dependencies = [
- "base64 0.11.0",
+ "base64 0.13.1",
  "log",
  "ring",
  "sct",
@@ -442,7 +832,7 @@ checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
 ]
 
 [[package]]
@@ -530,6 +920,25 @@ version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
 
+[[package]]
+name = "slab"
+version = "0.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "socket2"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662"
+dependencies = [
+ "libc",
+ "winapi",
+]
+
 [[package]]
 name = "spin"
 version = "0.5.2"
@@ -547,6 +956,17 @@ dependencies = [
  "unicode-ident",
 ]
 
+[[package]]
+name = "syn"
+version = "2.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
 [[package]]
 name = "teaclave_attestation"
 version = "0.5.1"
@@ -588,6 +1008,7 @@ dependencies = [
  "teaclave_proto",
  "teaclave_rpc",
  "teaclave_types",
+ "tokio",
  "url",
 ]
 
@@ -620,16 +1041,14 @@ name = "teaclave_proto"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "base64 0.13.1",
- "cfg-if 0.1.10",
  "prost",
- "rand",
  "serde",
  "serde_json",
  "sgx_types",
  "teaclave_crypto",
- "teaclave_rpc",
  "teaclave_types",
+ "tonic",
+ "tonic-build",
  "url",
  "uuid",
 ]
@@ -639,29 +1058,14 @@ name = "teaclave_rpc"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "cfg-if 0.1.10",
- "http",
  "log",
  "rustls",
- "serde",
- "serde_json",
  "teaclave_attestation",
- "teaclave_rpc_proc_macro",
  "teaclave_types",
- "thiserror",
- "threadpool",
+ "tonic",
  "webpki",
 ]
 
-[[package]]
-name = "teaclave_rpc_proc_macro"
-version = "0.5.1"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
 [[package]]
 name = "teaclave_types"
 version = "0.5.1"
@@ -678,10 +1082,24 @@ dependencies = [
  "teaclave_crypto",
  "thiserror",
  "toml",
+ "tonic",
  "url",
  "uuid",
 ]
 
+[[package]]
+name = "tempfile"
+version = "3.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998"
+dependencies = [
+ "cfg-if 1.0.0",
+ "fastrand",
+ "redox_syscall",
+ "rustix",
+ "windows-sys",
+]
+
 [[package]]
 name = "thiserror"
 version = "1.0.37"
@@ -699,16 +1117,7 @@ checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
-]
-
-[[package]]
-name = "threadpool"
-version = "1.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
-dependencies = [
- "num_cpus",
+ "syn 1.0.105",
 ]
 
 [[package]]
@@ -726,6 +1135,94 @@ version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
 
+[[package]]
+name = "tokio"
+version = "1.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001"
+dependencies = [
+ "autocfg",
+ "bytes",
+ "libc",
+ "mio",
+ "num_cpus",
+ "pin-project-lite",
+ "socket2",
+ "tokio-macros",
+ "windows-sys",
+]
+
+[[package]]
+name = "tokio-io-timeout"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
+dependencies = [
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.12",
+]
+
+[[package]]
+name = "tokio-rustls"
+version = "0.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
+dependencies = [
+ "rustls",
+ "tokio",
+ "webpki",
+]
+
+[[package]]
+name = "tokio-stream"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313"
+dependencies = [
+ "futures-core",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-util"
+version = "0.6.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "log",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-util"
+version = "0.7.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "pin-project-lite",
+ "tokio",
+ "tracing",
+]
+
 [[package]]
 name = "toml"
 version = "0.5.9"
@@ -735,6 +1232,132 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "tonic"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a"
+dependencies = [
+ "async-stream",
+ "async-trait",
+ "base64 0.13.1",
+ "bytes",
+ "flate2",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "hyper",
+ "hyper-timeout",
+ "percent-encoding",
+ "pin-project",
+ "prost",
+ "prost-derive",
+ "tokio",
+ "tokio-rustls",
+ "tokio-stream",
+ "tokio-util 0.6.10",
+ "tower",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+ "tracing-futures",
+]
+
+[[package]]
+name = "tonic-build"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757"
+dependencies = [
+ "proc-macro2",
+ "prost-build",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "tower"
+version = "0.4.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
+dependencies = [
+ "futures-core",
+ "futures-util",
+ "indexmap",
+ "pin-project",
+ "pin-project-lite",
+ "rand",
+ "slab",
+ "tokio",
+ "tokio-util 0.7.7",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "tower-layer"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
+
+[[package]]
+name = "tower-service"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
+
+[[package]]
+name = "tracing"
+version = "0.1.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
+dependencies = [
+ "cfg-if 1.0.0",
+ "log",
+ "pin-project-lite",
+ "tracing-attributes",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-attributes"
+version = "0.1.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
+dependencies = [
+ "once_cell",
+]
+
+[[package]]
+name = "tracing-futures"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
+dependencies = [
+ "pin-project",
+ "tracing",
+]
+
+[[package]]
+name = "try-lock"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
+
 [[package]]
 name = "unicode-bidi"
 version = "0.3.8"
@@ -756,6 +1379,12 @@ dependencies = [
  "tinyvec",
 ]
 
+[[package]]
+name = "unicode-segmentation"
+version = "1.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
+
 [[package]]
 name = "untrusted"
 version = "0.7.1"
@@ -785,6 +1414,16 @@ dependencies = [
  "sha1",
 ]
 
+[[package]]
+name = "want"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0"
+dependencies = [
+ "log",
+ "try-lock",
+]
+
 [[package]]
 name = "wasi"
 version = "0.11.0+wasi-snapshot-preview1"
@@ -812,7 +1451,7 @@ dependencies = [
  "once_cell",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
  "wasm-bindgen-shared",
 ]
 
@@ -834,7 +1473,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
  "wasm-bindgen-backend",
  "wasm-bindgen-shared",
 ]
@@ -874,6 +1513,17 @@ dependencies = [
  "webpki",
 ]
 
+[[package]]
+name = "which"
+version = "4.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
+dependencies = [
+ "either",
+ "libc",
+ "once_cell",
+]
+
 [[package]]
 name = "winapi"
 version = "0.3.9"
@@ -896,6 +1546,72 @@ version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
 
+[[package]]
+name = "windows-sys"
+version = "0.45.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
+
 [[package]]
 name = "yasna"
 version = "0.3.2"
diff --git a/examples/rust/builtin_ordered_set_intersect/src/main.rs b/examples/rust/builtin_ordered_set_intersect/src/main.rs
index 75ead1f6..55d0e024 100644
--- a/examples/rust/builtin_ordered_set_intersect/src/main.rs
+++ b/examples/rust/builtin_ordered_set_intersect/src/main.rs
@@ -64,7 +64,7 @@ impl PlatformAdmin {
         let bytes = fs::read(AS_ROOT_CA_CERT_PATH)?;
         let as_root_ca_cert = pem::parse(bytes)?.contents;
         let mut client = teaclave_client_sdk::AuthenticationService::connect(
-            "localhost:7776",
+            "https://localhost:7776",
             &enclave_info,
             &as_root_ca_cert,
         )?;
@@ -91,7 +91,7 @@ impl Client {
         let bytes = fs::read(AS_ROOT_CA_CERT_PATH)?;
         let as_root_ca_cert = pem::parse(bytes)?.contents;
         let mut client = teaclave_client_sdk::AuthenticationService::connect(
-            "localhost:7776",
+            "https://localhost:7776",
             &enclave_info,
             &as_root_ca_cert,
         )?;
@@ -102,7 +102,7 @@ impl Client {
         let token = client.user_login(&user_data.user_id, &user_data.user_password)?;
 
         let mut client = teaclave_client_sdk::FrontendService::connect(
-            "localhost:7777",
+            "https://localhost:7777",
             &enclave_info,
             &as_root_ca_cert,
         )?;
diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml
index 7bb664c7..42c649e4 100644
--- a/rpc/Cargo.toml
+++ b/rpc/Cargo.toml
@@ -26,31 +26,24 @@ edition = "2021"
 [features]
 default = []
 app = [
-    "libc",
     "teaclave_types/app",
     "teaclave_attestation/app"
 ]
 mesalock_sgx = [
-    "sgx_libc",
     "teaclave_types/mesalock_sgx",
     "teaclave_attestation/mesalock_sgx",
 ]
+libos = [
+    "app",
+    "teaclave_attestation/libos",
+]
 
 [dependencies]
 anyhow     = { version = "1.0.26" }
-cfg-if     = { version = "0.1.9" }
-http       = { version = "0.2" }
-libc       = { version = "0.2.66", optional = true }
 log        = { version = "0.4.17", features = ["release_max_level_info"] }
 rustls     = { version = "0.19.0", features = ["dangerous_configuration"] }
-serde      = { version = "1.0.92", features = ["derive"] }
-serde_json = { version = "1.0.39" }
-thiserror  = { version = "1.0.9" }
-threadpool = { version = "1.8.0" }
+tonic      = { version = "0.6.1", features = ["tls", "compression"] }
 webpki     = { version = "0.21.0" }
 
 teaclave_types       = { path = "../types" }
 teaclave_attestation = { path = "../attestation" }
-teaclave_rpc_proc_macro = { path = "./proc_macro" }
-
-sgx_libc = { version = "2.0.0", optional = true }
diff --git a/rpc/README.md b/rpc/README.md
index d26e70bc..1fca4dbb 100644
--- a/rpc/README.md
+++ b/rpc/README.md
@@ -1,43 +1,37 @@
----
-permalink: /docs/codebase/rpc
+--- 
+permalink: /docs/codebase/rpc 
 ---
 
 # RPC
 
-This directory contains an RPC implementation over attested TLS connection
-written in Rust, providing trusted channels to send and handle requests.
-RPC interfaces and request/response messages can be defined in ProtoBuf and
-used for generating Rust structs and traits to implement services or client
-function to send requests.
+This directory contains TLS configuration over an attested TLS connection,
+providing trusted channels to send and handle requests.
 
-Similar with other RPC frameworks, there are several concepts of RPC in
-Teaclave.
+Re-export [Tonic](https://github.com/hyperium/tonic) to support the general
+gRPC framework. `Tonic` is a gRPC over HTTP/2 implementation focused on high
+performance, interoperability, and flexibility.
 
 ## Channel and Client
 
-A channel in RPC represent a connection to the target service. Clients can use
-the channel to send requests. In Teaclave, we implement `SgxTrustedTlsChannel`,
-which can establish and attested a remote connection. For example, to connect
-the management service, you need to establish a trusted channel with the service
-first. Then, create a client of management service with the channel. At last,
-you can use this client to send requests like `InvokeTask`.
+A channel in gRPC represents a connection to the target service. Clients can
+use the channel to send requests. When constructing a client, you can use the
+`SgxTrustedTlsClientConfig` to set up TLS and attestation configurations so
+that we can establish and attest to a remote connection. For example, to
+connect the management service, you need to establish a trusted channel with
+the service first. Then, create a client for the management service with the
+channel. At last, you can use this client to send requests like `InvokeTask`.
 
-When constructing a client, you can use the `SgxTrustedTlsClientConfig` to setup
-TLS and attestation configs.
 
 ## Server and Service
 
-Server is an entity to listening a network address, processing incoming
-messages, and forwarding requests to certain service. Similar with channel in
-Teaclave, we implement `SgxTrustedTlsServer`, which can establish an attested TLS
-channel with clients.
+A server is an entity that listens to a network address, processes incoming
+messages, and forwards requests to certain services. Similar to the client, you
+can use `SgxTrustedTlsServerConfig` to set up TLS and attestation
+configurations for the channel with clients.
 
-Similar with the client, you can use `SgxTrustedTlsServerConfig` to setup TLS
-and attestation configs.
 
-## Protocol
+## Interceptor
 
-There are many RPC protocols that can be implemented in the RPC framework. Currently,
-there's only one simple protocol called `JsonProtocol`. Simply speaking, for
-the json protocol, one RPC message will contain a length of the following
-requests (in big endian) and a json serialized request.
+In Teaclave, we implement `CredentialService` based on the `Interceptor` trait
+to add a credential to the MetadataMap of each request before it is sent, so
+servers can check the authentication credential of each request.
diff --git a/rpc/proc_macro/Cargo.toml b/rpc/proc_macro/Cargo.toml
deleted file mode 100644
index 08ae6932..00000000
--- a/rpc/proc_macro/Cargo.toml
+++ /dev/null
@@ -1,31 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-[package]
-name = "teaclave_rpc_proc_macro"
-version = "0.5.1"
-authors = ["Teaclave Contributors <de...@teaclave.apache.org>"]
-license = "Apache-2.0"
-edition = "2021"
-
-[lib]
-proc-macro = true
-
-[dependencies]
-proc-macro2 = "1.0"
-quote = "1.0"
-syn = { version = "1.0", features = ["full"] }
diff --git a/rpc/proc_macro/src/lib.rs b/rpc/proc_macro/src/lib.rs
deleted file mode 100644
index ef2522b2..00000000
--- a/rpc/proc_macro/src/lib.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-extern crate proc_macro;
-use proc_macro2::{Ident, Span};
-use quote::quote;
-use syn::parse_macro_input;
-use syn::ItemStruct;
-
-use proc_macro::TokenStream;
-
-#[proc_macro_attribute]
-pub fn into_request(attr: TokenStream, input: TokenStream) -> TokenStream {
-    let attr_str = attr.to_string();
-    let splits: Vec<&str> = attr_str.split("::").map(|s| s.trim()).collect();
-    let name = Ident::new(splits[0], Span::call_site());
-    let item = Ident::new(splits[1], Span::call_site());
-    let f = parse_macro_input!(input as ItemStruct);
-    let struct_ident = &f.ident;
-    let q = quote!(
-    #f
-
-
-    impl teaclave_rpc::IntoRequest<#name> for #struct_ident {
-        fn into_request(self) -> teaclave_rpc::Request<#name> {
-            teaclave_rpc::Request::new(#name::#item(self.into()))
-        }
-    }
-    );
-
-    q.into()
-}
diff --git a/rpc/src/channel.rs b/rpc/src/channel.rs
deleted file mode 100644
index 63a18ef8..00000000
--- a/rpc/src/channel.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use crate::config::SgxTrustedTlsClientConfig;
-use crate::transport::{ClientTransport, SgxTrustedTlsTransport};
-use crate::Request;
-use anyhow::anyhow;
-use anyhow::Result;
-use http::Uri;
-use serde::{Deserialize, Serialize};
-use std::sync::Arc;
-
-pub struct SgxTrustedTlsChannel<U, V>
-where
-    U: Serialize + std::fmt::Debug,
-    V: for<'de> Deserialize<'de> + std::fmt::Debug,
-{
-    transport: SgxTrustedTlsTransport<rustls::ClientSession>,
-    maker: std::marker::PhantomData<(U, V)>,
-}
-
-impl<U, V> SgxTrustedTlsChannel<U, V>
-where
-    U: Serialize + std::fmt::Debug,
-    V: for<'de> Deserialize<'de> + std::fmt::Debug,
-{
-    pub fn new(
-        address: &str,
-        client_config: &SgxTrustedTlsClientConfig,
-    ) -> Result<SgxTrustedTlsChannel<U, V>> {
-        let uri = address.parse::<Uri>()?;
-        let hostname = uri.host().ok_or_else(|| anyhow!("Invalid hostname."))?;
-        let stream = std::net::TcpStream::connect(address)?;
-        let hostname = webpki::DNSNameRef::try_from_ascii_str(hostname)?;
-        let session =
-            rustls::ClientSession::new(&Arc::new(client_config.client_config.clone()), hostname);
-        let tls_stream = rustls::StreamOwned::new(session, stream);
-        let transport = SgxTrustedTlsTransport::new(tls_stream);
-
-        Ok(Self {
-            transport,
-            maker: std::marker::PhantomData::<(U, V)>,
-        })
-    }
-
-    pub fn invoke(
-        &mut self,
-        input: Request<U>,
-    ) -> teaclave_types::TeaclaveServiceResponseResult<V> {
-        self.transport.send(input)
-    }
-}
diff --git a/rpc/src/config.rs b/rpc/src/config.rs
index cb952698..10a56559 100644
--- a/rpc/src/config.rs
+++ b/rpc/src/config.rs
@@ -15,6 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use crate::transport::{ClientTlsConfig, ServerTlsConfig};
 use anyhow::{anyhow, bail, Result};
 use log::debug;
 use std::sync::{Arc, RwLock};
@@ -29,6 +30,9 @@ use teaclave_attestation::verifier::AttestationReportVerifier;
 use teaclave_attestation::AttestedTlsConfig;
 use teaclave_types::EnclaveAttr;
 
+// Yout should set the 'h2' negotiation flag for tonic grpc.
+pub const ALPN_H2: &str = "h2";
+
 #[derive(Clone)]
 pub struct SgxTrustedTlsServerConfig {
     server_config: rustls::ServerConfig,
@@ -79,7 +83,7 @@ impl SgxTrustedTlsServerConfig {
     }
 
     // Disable this function for non-SGX targets.
-    #[cfg(feature = "mesalock_sgx")]
+    #[cfg(any(feature = "mesalock_sgx", feature = "libos"))]
     pub fn attestation_report_verifier(
         mut self,
         accepted_enclave_attrs: Vec<EnclaveAttr>,
@@ -133,6 +137,16 @@ impl SgxTrustedTlsServerConfig {
     }
 }
 
+impl From<SgxTrustedTlsServerConfig> for ServerTlsConfig {
+    fn from(config: SgxTrustedTlsServerConfig) -> Self {
+        let mut config_service = config.server_config;
+        config_service.set_protocols(&[ALPN_H2.as_bytes().to_vec()]);
+        let mut tls_config = ServerTlsConfig::new();
+        let tls_config = tls_config.rustls_server_config(config_service);
+        tls_config.to_owned()
+    }
+}
+
 pub struct SgxTrustedTlsClientConfig {
     pub client_config: rustls::ClientConfig,
     pub attested_tls_config: Option<Arc<RwLock<AttestedTlsConfig>>>,
@@ -224,3 +238,12 @@ impl SgxTrustedTlsClientConfig {
         Ok(config)
     }
 }
+
+impl From<SgxTrustedTlsClientConfig> for ClientTlsConfig {
+    fn from(config: SgxTrustedTlsClientConfig) -> Self {
+        let mut client_config = config.client_config;
+        // Yout must set the 'h2' negotiation flag.
+        client_config.set_protocols(&[ALPN_H2.as_bytes().to_vec()]);
+        ClientTlsConfig::new().rustls_client_config(client_config)
+    }
+}
diff --git a/rpc/src/endpoint.rs b/rpc/src/endpoint.rs
deleted file mode 100644
index 3cba4533..00000000
--- a/rpc/src/endpoint.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use crate::channel::SgxTrustedTlsChannel;
-use crate::config::SgxTrustedTlsClientConfig;
-use anyhow::Result;
-use serde::{Deserialize, Serialize};
-
-pub struct Endpoint {
-    url: String,
-    config: SgxTrustedTlsClientConfig,
-}
-
-impl Endpoint {
-    pub fn new(url: &str) -> Self {
-        let config = SgxTrustedTlsClientConfig::new();
-        Self {
-            url: url.to_string(),
-            config,
-        }
-    }
-
-    pub fn connect<U, V>(&self) -> Result<SgxTrustedTlsChannel<U, V>>
-    where
-        U: Serialize + std::fmt::Debug,
-        V: for<'de> Deserialize<'de> + std::fmt::Debug,
-    {
-        SgxTrustedTlsChannel::<U, V>::new(&self.url, &self.config)
-    }
-
-    pub fn config(self, config: SgxTrustedTlsClientConfig) -> Self {
-        Self {
-            url: self.url,
-            config,
-        }
-    }
-}
diff --git a/rpc/src/interceptor.rs b/rpc/src/interceptor.rs
new file mode 100644
index 00000000..83673494
--- /dev/null
+++ b/rpc/src/interceptor.rs
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use teaclave_types::UserRole;
+use tonic::{
+    codegen::InterceptedService, service::Interceptor, transport::Channel, IntoRequest, Request,
+    Status,
+};
+
+pub type CredentialService = InterceptedService<Channel, UserCredential>;
+
+// To verify authentication credentials of the request.
+#[derive(Debug, Default, Clone)]
+pub struct UserCredential {
+    pub id: String,
+    pub token: String,
+    pub role: UserRole,
+}
+
+impl Interceptor for UserCredential {
+    fn call(&mut self, request: Request<()>) -> Result<Request<()>, Status> {
+        let mut req = request.into_request();
+        let meta = req.metadata_mut();
+        meta.insert("id", self.id.parse().unwrap());
+        meta.insert("token", self.token.parse().unwrap());
+        meta.insert("role", self.role.to_string().parse().unwrap());
+        Ok(req)
+    }
+}
+
+impl UserCredential {
+    pub fn new(id: impl ToString, token: impl ToString) -> Self {
+        Self {
+            id: id.to_string(),
+            token: token.to_string(),
+            role: UserRole::default(),
+        }
+    }
+
+    pub fn with_role(id: impl ToString, token: impl ToString, role: UserRole) -> Self {
+        Self {
+            id: id.to_string(),
+            token: token.to_string(),
+            role,
+        }
+    }
+}
diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs
index 69cbc3f3..84ef1c8f 100644
--- a/rpc/src/lib.rs
+++ b/rpc/src/lib.rs
@@ -15,30 +15,16 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#[cfg(feature = "mesalock_sgx")]
-extern crate sgx_trts;
+pub mod config;
+pub mod interceptor;
+mod macros;
 
-use serde::{Deserialize, Serialize};
-use teaclave_types::TeaclaveServiceResponseError;
+pub use interceptor::{CredentialService, UserCredential};
 
-pub trait TeaclaveService<V, U>
-where
-    U: Serialize + std::fmt::Debug,
-    V: for<'de> Deserialize<'de> + std::fmt::Debug,
-{
-    fn handle_request(
-        &self,
-        request: Request<V>,
-    ) -> std::result::Result<U, TeaclaveServiceResponseError>;
+pub use tonic::{
+    async_trait, metadata::MetadataMap, service::interceptor::InterceptedService, Code,
+    IntoRequest, Request, Response, Status,
+};
+pub mod transport {
+    pub use tonic::transport::*;
 }
-
-pub mod channel;
-pub mod config;
-pub mod endpoint;
-mod protocol;
-mod request;
-pub use request::{IntoRequest, Request};
-pub use teaclave_rpc_proc_macro::into_request;
-#[cfg(any(feature = "mesalock_sgx", feature = "app"))]
-pub mod server;
-mod transport;
diff --git a/rpc/src/utils.rs b/rpc/src/macros.rs
similarity index 69%
rename from rpc/src/utils.rs
rename to rpc/src/macros.rs
index 39f8d905..f192eea3 100644
--- a/rpc/src/utils.rs
+++ b/rpc/src/macros.rs
@@ -15,12 +15,17 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#[allow(dead_code)]
-#[cfg(feature = "mesalock_sgx")]
-pub(crate) fn get_tcs_num() -> usize {
-    if sgx_trts::enclave::rsgx_is_supported_EDMM() {
-        sgx_trts::enclave::SgxGlobalData::new().get_dyn_tcs_num() as usize
-    } else {
-        (sgx_trts::enclave::SgxGlobalData::new().get_tcs_max_num() - 1) as usize
-    }
+#[macro_export]
+macro_rules! ensure {
+    ($cond:expr,$err:expr $(,)?) => {
+        if !$cond {
+            return std::result::Result::Err($err.into());
+        }
+    };
+
+    ($cond:expr,$code:expr,$err:expr $(,)?) => {
+        if !$cond {
+            return std::result::Result::Err($crate::Status::new($code, $err.to_string()));
+        }
+    };
 }
diff --git a/rpc/src/protocol.rs b/rpc/src/protocol.rs
deleted file mode 100644
index af2f09ca..00000000
--- a/rpc/src/protocol.rs
+++ /dev/null
@@ -1,139 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#![allow(clippy::nonstandard_macro_braces)]
-
-use log::trace;
-use serde::{Deserialize, Serialize};
-use std::io;
-use std::vec::Vec;
-use teaclave_types::TeaclaveServiceResponseError;
-use thiserror::Error;
-
-#[derive(Error, Debug)]
-pub enum ProtocolError {
-    #[error("IoError")]
-    IoError(#[from] io::Error),
-    #[error("SerdeError")]
-    SerdeError(#[from] serde_json::error::Error),
-    #[error(transparent)]
-    Other(#[from] anyhow::Error),
-}
-
-impl From<ProtocolError> for TeaclaveServiceResponseError {
-    fn from(error: ProtocolError) -> Self {
-        match error {
-            ProtocolError::IoError(e) => {
-                TeaclaveServiceResponseError::ConnectionError(format!("{}", e))
-            }
-            ProtocolError::SerdeError(_) => {
-                TeaclaveServiceResponseError::InternalError("serde".to_string())
-            }
-            ProtocolError::Other(_) => {
-                TeaclaveServiceResponseError::InternalError("internal".to_string())
-            }
-        }
-    }
-}
-
-pub(crate) struct JsonProtocol<'a, T>
-where
-    T: io::Read + io::Write,
-{
-    pub transport: &'a mut T,
-    max_frame_len: u64,
-}
-
-impl<'a, T> JsonProtocol<'a, T>
-where
-    T: io::Read + io::Write,
-{
-    pub fn new(transport: &'a mut T) -> JsonProtocol<'a, T> {
-        Self {
-            transport,
-            // Default max frame length is 32MB
-            max_frame_len: 32 * 1_024 * 1_024,
-        }
-    }
-
-    pub fn read_message<V>(&mut self) -> std::result::Result<V, ProtocolError>
-    where
-        V: for<'de> Deserialize<'de> + std::fmt::Debug,
-    {
-        let mut header = [0u8; 8];
-
-        self.transport.read_exact(&mut header)?;
-        let buf_len = u64::from_be_bytes(header);
-        if buf_len > self.max_frame_len {
-            return Err(ProtocolError::Other(anyhow::anyhow!(
-                "Exceed max frame length"
-            )));
-        }
-
-        let mut recv_buf: Vec<u8> = vec![0u8; buf_len as usize];
-        self.transport.read_exact(&mut recv_buf)?;
-
-        trace!("Recv: {}", std::string::String::from_utf8_lossy(&recv_buf));
-        let r: V = serde_json::from_slice(&recv_buf)?;
-
-        Ok(r)
-    }
-
-    pub fn write_message<U>(&mut self, message: U) -> std::result::Result<(), ProtocolError>
-    where
-        U: Serialize + std::fmt::Debug,
-    {
-        let send_buf = serde_json::to_vec(&message)?;
-
-        trace!("Send: {}", std::string::String::from_utf8_lossy(&send_buf));
-
-        let buf_len = send_buf.len() as u64;
-        let header = buf_len.to_be_bytes();
-
-        self.transport.write_all(&header)?;
-        self.transport.write_all(&send_buf)?;
-        self.transport.flush()?;
-
-        Ok(())
-    }
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-#[serde(tag = "result")]
-#[serde(rename_all = "snake_case")]
-pub enum JsonProtocolResult<T, E> {
-    Ok(T),
-    Err(E),
-}
-
-impl<T, E> From<std::result::Result<T, E>> for JsonProtocolResult<T, E> {
-    fn from(result: std::result::Result<T, E>) -> Self {
-        match result {
-            Ok(t) => JsonProtocolResult::Ok(t),
-            Err(e) => JsonProtocolResult::Err(e),
-        }
-    }
-}
-
-impl<T, E> From<JsonProtocolResult<T, E>> for std::result::Result<T, E> {
-    fn from(result: JsonProtocolResult<T, E>) -> Self {
-        match result {
-            JsonProtocolResult::Ok(t) => Ok(t),
-            JsonProtocolResult::Err(e) => Err(e),
-        }
-    }
-}
diff --git a/rpc/src/request.rs b/rpc/src/request.rs
deleted file mode 100644
index 026714c0..00000000
--- a/rpc/src/request.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use serde::{Deserialize, Serialize};
-use std::collections::HashMap;
-
-#[derive(Debug, Serialize, Deserialize, Clone)]
-pub struct Request<T> {
-    #[serde(skip_serializing_if = "HashMap::is_empty")]
-    #[serde(default)]
-    pub metadata: HashMap<String, String>,
-    pub message: T,
-}
-
-impl<T> Request<T> {
-    pub fn new(message: T) -> Self {
-        Request {
-            metadata: HashMap::<String, String>::default(),
-            message,
-        }
-    }
-
-    pub fn map<F, U>(self, f: F) -> Request<U>
-    where
-        F: FnOnce(T) -> U,
-    {
-        let message = f(self.message);
-
-        Request {
-            metadata: self.metadata,
-            message,
-        }
-    }
-
-    pub fn metadata(&self) -> &HashMap<String, String> {
-        &self.metadata
-    }
-
-    pub fn metadata_mut(&mut self) -> &mut HashMap<String, String> {
-        &mut self.metadata
-    }
-}
-
-pub trait IntoRequest<T> {
-    fn into_request(self) -> Request<T>;
-}
-
-impl<T> IntoRequest<T> for T {
-    fn into_request(self) -> Request<Self> {
-        Request::new(self)
-    }
-}
diff --git a/rpc/src/server.rs b/rpc/src/server.rs
deleted file mode 100644
index 27c3fc7e..00000000
--- a/rpc/src/server.rs
+++ /dev/null
@@ -1,129 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use crate::config::SgxTrustedTlsServerConfig;
-use crate::transport::{ServerTransport, SgxTrustedTlsTransport};
-use crate::TeaclaveService;
-use anyhow::Result;
-#[cfg(not(feature = "mesalock_sgx"))]
-use libc::setsockopt;
-use log::{debug, error, warn};
-use serde::{Deserialize, Serialize};
-#[cfg(feature = "mesalock_sgx")]
-use sgx_libc as libc;
-#[cfg(feature = "mesalock_sgx")]
-use sgx_libc::ocall::setsockopt;
-use std::{io, mem, os::unix::io::AsRawFd};
-
-pub struct SgxTrustedTlsServer<U, V>
-where
-    U: Serialize + std::fmt::Debug,
-    V: for<'de> Deserialize<'de> + std::fmt::Debug,
-{
-    addr: std::net::SocketAddr,
-    tls_config: SgxTrustedTlsServerConfig,
-    tcp_nodelay: bool,
-    n_workers: usize,
-    maker: std::marker::PhantomData<(U, V)>,
-}
-
-impl<U, V> SgxTrustedTlsServer<U, V>
-where
-    U: Serialize + std::fmt::Debug,
-    V: for<'de> Deserialize<'de> + std::fmt::Debug,
-{
-    pub fn new(
-        addr: std::net::SocketAddr,
-        server_config: SgxTrustedTlsServerConfig,
-    ) -> SgxTrustedTlsServer<U, V> {
-        Self {
-            addr,
-            tls_config: server_config,
-            tcp_nodelay: true,
-            n_workers: 8,
-            maker: std::marker::PhantomData::<(U, V)>,
-        }
-    }
-
-    pub fn tcp_nodelay(self, enabled: bool) -> Self {
-        Self {
-            tcp_nodelay: enabled,
-            ..self
-        }
-    }
-
-    pub fn n_workers(self, n: usize) -> Self {
-        Self {
-            n_workers: n,
-            ..self
-        }
-    }
-
-    pub fn start<X>(&mut self, service: X) -> Result<()>
-    where
-        X: 'static + TeaclaveService<V, U> + Clone + core::marker::Send,
-    {
-        let pool = threadpool::ThreadPool::new(self.n_workers);
-        let listener = std::net::TcpListener::bind(self.addr)?;
-        unsafe {
-            let optval: libc::c_int = 1;
-            let ret = setsockopt(
-                listener.as_raw_fd(),
-                libc::SOL_SOCKET,
-                libc::SO_REUSEPORT,
-                &optval as *const _ as *const libc::c_void,
-                mem::size_of_val(&optval) as libc::socklen_t,
-            );
-            if ret != 0 {
-                return Err(io::Error::last_os_error().into());
-            }
-        }
-        let mut tls_config_ref = self.tls_config.server_config();
-        for stream in listener.incoming() {
-            match stream {
-                Ok(stream) => {
-                    // Before introducing async into enclave, we check
-                    // freshness for every incoming connection.
-                    if self.tls_config.need_refresh() {
-                        debug!("Attestation report is outdated, need to refresh");
-                        self.tls_config.refresh_server_config()?;
-                        tls_config_ref = self.tls_config.server_config();
-                    }
-
-                    if let Err(e) = stream.set_nodelay(self.tcp_nodelay) {
-                        warn!("Cannot set_nodelay: {:}", e);
-                        continue;
-                    }
-                    let session = rustls::ServerSession::new(&tls_config_ref);
-                    let tls_stream = rustls::StreamOwned::new(session, stream);
-                    let mut transport = SgxTrustedTlsTransport::new(tls_stream);
-                    let service = service.clone();
-                    pool.execute(move || match transport.serve(service) {
-                        Ok(_) => (),
-                        Err(e) => {
-                            debug!("serve error: {:?}", e);
-                        }
-                    });
-                }
-                Err(e) => {
-                    error!("Incoming error: {:}", e);
-                }
-            }
-        }
-        Ok(())
-    }
-}
diff --git a/rpc/src/transport.rs b/rpc/src/transport.rs
deleted file mode 100644
index 9cea7132..00000000
--- a/rpc/src/transport.rs
+++ /dev/null
@@ -1,119 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use crate::protocol;
-use crate::Request;
-use crate::TeaclaveService;
-use anyhow::Result;
-use log::warn;
-use serde::{Deserialize, Serialize};
-
-pub(crate) trait ClientTransport {
-    fn send<U, V>(
-        &mut self,
-        request: Request<U>,
-    ) -> teaclave_types::TeaclaveServiceResponseResult<V>
-    where
-        U: Serialize + std::fmt::Debug,
-        V: for<'de> Deserialize<'de> + std::fmt::Debug;
-}
-
-pub(crate) trait ServerTransport {
-    fn serve<U, V, X>(&mut self, service: X) -> Result<()>
-    where
-        U: Serialize + std::fmt::Debug,
-        V: for<'de> Deserialize<'de> + std::fmt::Debug,
-        X: TeaclaveService<V, U>;
-}
-pub(crate) struct SgxTrustedTlsTransport<S>
-where
-    S: rustls::Session,
-{
-    stream: rustls::StreamOwned<S, std::net::TcpStream>,
-}
-
-impl<S> SgxTrustedTlsTransport<S>
-where
-    S: rustls::Session,
-{
-    pub fn new(stream: rustls::StreamOwned<S, std::net::TcpStream>) -> SgxTrustedTlsTransport<S> {
-        SgxTrustedTlsTransport::<S> { stream }
-    }
-}
-
-impl<S> ClientTransport for SgxTrustedTlsTransport<S>
-where
-    S: rustls::Session,
-{
-    fn send<U, V>(
-        &mut self,
-        request: Request<U>,
-    ) -> teaclave_types::TeaclaveServiceResponseResult<V>
-    where
-        U: Serialize + std::fmt::Debug,
-        V: for<'de> Deserialize<'de> + std::fmt::Debug,
-    {
-        let mut protocol = protocol::JsonProtocol::new(&mut self.stream);
-        protocol.write_message(request)?;
-        protocol.read_message::<protocol::JsonProtocolResult<
-                V,
-                teaclave_types::TeaclaveServiceResponseError,
-            >>()?
-            .into()
-    }
-}
-
-impl<S> ServerTransport for SgxTrustedTlsTransport<S>
-where
-    S: rustls::Session,
-{
-    fn serve<U, V, X>(&mut self, service: X) -> Result<()>
-    where
-        U: Serialize + std::fmt::Debug,
-        V: for<'de> Deserialize<'de> + std::fmt::Debug,
-        X: TeaclaveService<V, U>,
-    {
-        use crate::protocol::{JsonProtocol, JsonProtocolResult};
-        use teaclave_types::TeaclaveServiceResponseError;
-        let mut protocol = JsonProtocol::new(&mut self.stream);
-
-        loop {
-            let request: Request<V> = match protocol.read_message::<Request<V>>() {
-                Ok(r) => r,
-                Err(e) => match e {
-                    protocol::ProtocolError::IoError(e) => {
-                        log::debug!("Connection disconnected: {:?}", e);
-                        return Ok(());
-                    }
-                    _ => {
-                        warn!("Connection error: {:?}", e);
-                        let response: JsonProtocolResult<U, TeaclaveServiceResponseError> =
-                            Err(TeaclaveServiceResponseError::RequestError(
-                                "invalid request".to_string(),
-                            ))
-                            .into();
-                        protocol.write_message(response)?;
-                        return Ok(());
-                    }
-                },
-            };
-            let response: JsonProtocolResult<U, TeaclaveServiceResponseError> =
-                service.handle_request(request).into();
-            protocol.write_message(response)?;
-        }
-    }
-}
diff --git a/sdk/rust/Cargo.lock b/sdk/rust/Cargo.lock
index 4ee93bf6..554cc4e0 100644
--- a/sdk/rust/Cargo.lock
+++ b/sdk/rust/Cargo.lock
@@ -2,6 +2,12 @@
 # It is not intended for manual editing.
 version = 3
 
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
 [[package]]
 name = "aho-corasick"
 version = "0.7.20"
@@ -17,6 +23,39 @@ version = "1.0.66"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
 
+[[package]]
+name = "async-stream"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e"
+dependencies = [
+ "async-stream-impl",
+ "futures-core",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-stream-impl"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "async-trait"
+version = "0.1.68"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.11",
+]
+
 [[package]]
 name = "autocfg"
 version = "1.1.0"
@@ -41,11 +80,17 @@ version = "0.6.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
 
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
 [[package]]
 name = "bumpalo"
-version = "3.11.1"
+version = "3.12.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
+checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535"
 
 [[package]]
 name = "bytes"
@@ -81,12 +126,67 @@ dependencies = [
  "num-traits",
 ]
 
+[[package]]
+name = "crc32fast"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
+dependencies = [
+ "cfg-if 1.0.0",
+]
+
 [[package]]
 name = "either"
 version = "1.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
 
+[[package]]
+name = "errno"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
+dependencies = [
+ "errno-dragonfly",
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "errno-dragonfly"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
+dependencies = [
+ "cc",
+ "libc",
+]
+
+[[package]]
+name = "fastrand"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
+dependencies = [
+ "instant",
+]
+
+[[package]]
+name = "fixedbitset"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
+
+[[package]]
+name = "flate2"
+version = "1.0.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
+dependencies = [
+ "crc32fast",
+ "miniz_oxide",
+]
+
 [[package]]
 name = "fnv"
 version = "1.0.7"
@@ -102,6 +202,45 @@ dependencies = [
  "percent-encoding",
 ]
 
+[[package]]
+name = "futures-channel"
+version = "0.3.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac"
+dependencies = [
+ "futures-core",
+]
+
+[[package]]
+name = "futures-core"
+version = "0.3.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd"
+
+[[package]]
+name = "futures-sink"
+version = "0.3.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2"
+
+[[package]]
+name = "futures-task"
+version = "0.3.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879"
+
+[[package]]
+name = "futures-util"
+version = "0.3.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "pin-project-lite",
+ "pin-utils",
+]
+
 [[package]]
 name = "getrandom"
 version = "0.2.8"
@@ -113,6 +252,40 @@ dependencies = [
  "wasi",
 ]
 
+[[package]]
+name = "h2"
+version = "0.3.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d"
+dependencies = [
+ "bytes",
+ "fnv",
+ "futures-core",
+ "futures-sink",
+ "futures-util",
+ "http",
+ "indexmap",
+ "slab",
+ "tokio",
+ "tokio-util 0.7.7",
+ "tracing",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+
+[[package]]
+name = "heck"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
+dependencies = [
+ "unicode-segmentation",
+]
+
 [[package]]
 name = "hermit-abi"
 version = "0.1.19"
@@ -122,6 +295,12 @@ dependencies = [
  "libc",
 ]
 
+[[package]]
+name = "hermit-abi"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
+
 [[package]]
 name = "hex"
 version = "0.4.3"
@@ -139,12 +318,65 @@ dependencies = [
  "itoa",
 ]
 
+[[package]]
+name = "http-body"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"
+dependencies = [
+ "bytes",
+ "http",
+ "pin-project-lite",
+]
+
 [[package]]
 name = "httparse"
 version = "1.8.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"
 
+[[package]]
+name = "httpdate"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
+
+[[package]]
+name = "hyper"
+version = "0.14.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "httparse",
+ "httpdate",
+ "itoa",
+ "pin-project-lite",
+ "socket2",
+ "tokio",
+ "tower-service",
+ "tracing",
+ "want",
+]
+
+[[package]]
+name = "hyper-timeout"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"
+dependencies = [
+ "hyper",
+ "pin-project-lite",
+ "tokio",
+ "tokio-io-timeout",
+]
+
 [[package]]
 name = "idna"
 version = "0.3.0"
@@ -155,6 +387,36 @@ dependencies = [
  "unicode-normalization",
 ]
 
+[[package]]
+name = "indexmap"
+version = "1.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
+dependencies = [
+ "autocfg",
+ "hashbrown",
+]
+
+[[package]]
+name = "instant"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
+dependencies = [
+ "cfg-if 1.0.0",
+]
+
+[[package]]
+name = "io-lifetimes"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb"
+dependencies = [
+ "hermit-abi 0.3.1",
+ "libc",
+ "windows-sys 0.45.0",
+]
+
 [[package]]
 name = "itertools"
 version = "0.10.5"
@@ -187,9 +449,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
 
 [[package]]
 name = "libc"
-version = "0.2.138"
+version = "0.2.140"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
+checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
 
 [[package]]
 name = "log"
@@ -206,6 +474,33 @@ version = "2.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
 
+[[package]]
+name = "miniz_oxide"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
+dependencies = [
+ "adler",
+]
+
+[[package]]
+name = "mio"
+version = "0.8.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
+dependencies = [
+ "libc",
+ "log",
+ "wasi",
+ "windows-sys 0.45.0",
+]
+
+[[package]]
+name = "multimap"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
+
 [[package]]
 name = "num-bigint"
 version = "0.2.6"
@@ -242,7 +537,7 @@ version = "1.14.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5"
 dependencies = [
- "hermit-abi",
+ "hermit-abi 0.1.19",
  "libc",
 ]
 
@@ -269,6 +564,48 @@ version = "2.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
 
+[[package]]
+name = "petgraph"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4"
+dependencies = [
+ "fixedbitset",
+ "indexmap",
+]
+
+[[package]]
+name = "pin-project"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"
+dependencies = [
+ "pin-project-internal",
+]
+
+[[package]]
+name = "pin-project-internal"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
+
+[[package]]
+name = "pin-utils"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
+
 [[package]]
 name = "ppv-lite86"
 version = "0.2.17"
@@ -277,41 +614,71 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.47"
+version = "1.0.54"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
+checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534"
 dependencies = [
  "unicode-ident",
 ]
 
 [[package]]
 name = "prost"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537"
+checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001"
 dependencies = [
  "bytes",
  "prost-derive",
 ]
 
+[[package]]
+name = "prost-build"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5"
+dependencies = [
+ "bytes",
+ "heck",
+ "itertools",
+ "lazy_static",
+ "log",
+ "multimap",
+ "petgraph",
+ "prost",
+ "prost-types",
+ "regex",
+ "tempfile",
+ "which",
+]
+
 [[package]]
 name = "prost-derive"
-version = "0.11.8"
+version = "0.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b"
+checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe"
 dependencies = [
  "anyhow",
  "itertools",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "prost-types"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a"
+dependencies = [
+ "bytes",
+ "prost",
 ]
 
 [[package]]
 name = "quote"
-version = "1.0.21"
+version = "1.0.26"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
+checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
 dependencies = [
  "proc-macro2",
 ]
@@ -355,6 +722,15 @@ dependencies = [
  "rand_core",
 ]
 
+[[package]]
+name = "redox_syscall"
+version = "0.2.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
+dependencies = [
+ "bitflags",
+]
+
 [[package]]
 name = "regex"
 version = "1.7.0"
@@ -387,13 +763,27 @@ dependencies = [
  "winapi",
 ]
 
+[[package]]
+name = "rustix"
+version = "0.36.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e"
+dependencies = [
+ "bitflags",
+ "errno",
+ "io-lifetimes",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.45.0",
+]
+
 [[package]]
 name = "rustls"
-version = "0.17.0"
+version = "0.19.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1"
+checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7"
 dependencies = [
- "base64 0.11.0",
+ "base64 0.13.1",
  "log",
  "ring",
  "sct",
@@ -433,7 +823,7 @@ checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
 ]
 
 [[package]]
@@ -521,6 +911,25 @@ version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
 
+[[package]]
+name = "slab"
+version = "0.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "socket2"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662"
+dependencies = [
+ "libc",
+ "winapi",
+]
+
 [[package]]
 name = "spin"
 version = "0.5.2"
@@ -538,6 +947,17 @@ dependencies = [
  "unicode-ident",
 ]
 
+[[package]]
+name = "syn"
+version = "2.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21e3787bb71465627110e7d87ed4faaa36c1f61042ee67badb9e2ef173accc40"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
 [[package]]
 name = "teaclave_attestation"
 version = "0.5.1"
@@ -579,6 +999,7 @@ dependencies = [
  "teaclave_proto",
  "teaclave_rpc",
  "teaclave_types",
+ "tokio",
  "url",
 ]
 
@@ -611,16 +1032,14 @@ name = "teaclave_proto"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "base64 0.13.1",
- "cfg-if 0.1.10",
  "prost",
- "rand",
  "serde",
  "serde_json",
  "sgx_types",
  "teaclave_crypto",
- "teaclave_rpc",
  "teaclave_types",
+ "tonic",
+ "tonic-build",
  "url",
  "uuid",
 ]
@@ -630,29 +1049,14 @@ name = "teaclave_rpc"
 version = "0.5.1"
 dependencies = [
  "anyhow",
- "cfg-if 0.1.10",
- "http",
  "log",
  "rustls",
- "serde",
- "serde_json",
  "teaclave_attestation",
- "teaclave_rpc_proc_macro",
  "teaclave_types",
- "thiserror",
- "threadpool",
+ "tonic",
  "webpki",
 ]
 
-[[package]]
-name = "teaclave_rpc_proc_macro"
-version = "0.5.1"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
 [[package]]
 name = "teaclave_types"
 version = "0.5.1"
@@ -669,10 +1073,24 @@ dependencies = [
  "teaclave_crypto",
  "thiserror",
  "toml",
+ "tonic",
  "url",
  "uuid",
 ]
 
+[[package]]
+name = "tempfile"
+version = "3.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95"
+dependencies = [
+ "cfg-if 1.0.0",
+ "fastrand",
+ "redox_syscall",
+ "rustix",
+ "windows-sys 0.42.0",
+]
+
 [[package]]
 name = "thiserror"
 version = "1.0.37"
@@ -690,16 +1108,7 @@ checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
-]
-
-[[package]]
-name = "threadpool"
-version = "1.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
-dependencies = [
- "num_cpus",
+ "syn 1.0.105",
 ]
 
 [[package]]
@@ -717,6 +1126,94 @@ version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
 
+[[package]]
+name = "tokio"
+version = "1.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001"
+dependencies = [
+ "autocfg",
+ "bytes",
+ "libc",
+ "mio",
+ "num_cpus",
+ "pin-project-lite",
+ "socket2",
+ "tokio-macros",
+ "windows-sys 0.45.0",
+]
+
+[[package]]
+name = "tokio-io-timeout"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"
+dependencies = [
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.11",
+]
+
+[[package]]
+name = "tokio-rustls"
+version = "0.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
+dependencies = [
+ "rustls",
+ "tokio",
+ "webpki",
+]
+
+[[package]]
+name = "tokio-stream"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313"
+dependencies = [
+ "futures-core",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-util"
+version = "0.6.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "log",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-util"
+version = "0.7.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "pin-project-lite",
+ "tokio",
+ "tracing",
+]
+
 [[package]]
 name = "toml"
 version = "0.5.9"
@@ -726,6 +1223,132 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "tonic"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a"
+dependencies = [
+ "async-stream",
+ "async-trait",
+ "base64 0.13.1",
+ "bytes",
+ "flate2",
+ "futures-core",
+ "futures-util",
+ "h2",
+ "http",
+ "http-body",
+ "hyper",
+ "hyper-timeout",
+ "percent-encoding",
+ "pin-project",
+ "prost",
+ "prost-derive",
+ "tokio",
+ "tokio-rustls",
+ "tokio-stream",
+ "tokio-util 0.6.10",
+ "tower",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+ "tracing-futures",
+]
+
+[[package]]
+name = "tonic-build"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9403f1bafde247186684b230dc6f38b5cd514584e8bec1dd32514be4745fa757"
+dependencies = [
+ "proc-macro2",
+ "prost-build",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "tower"
+version = "0.4.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
+dependencies = [
+ "futures-core",
+ "futures-util",
+ "indexmap",
+ "pin-project",
+ "pin-project-lite",
+ "rand",
+ "slab",
+ "tokio",
+ "tokio-util 0.7.7",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "tower-layer"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
+
+[[package]]
+name = "tower-service"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
+
+[[package]]
+name = "tracing"
+version = "0.1.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
+dependencies = [
+ "cfg-if 1.0.0",
+ "log",
+ "pin-project-lite",
+ "tracing-attributes",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-attributes"
+version = "0.1.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 1.0.105",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
+dependencies = [
+ "once_cell",
+]
+
+[[package]]
+name = "tracing-futures"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
+dependencies = [
+ "pin-project",
+ "tracing",
+]
+
+[[package]]
+name = "try-lock"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
+
 [[package]]
 name = "unicode-bidi"
 version = "0.3.8"
@@ -747,6 +1370,12 @@ dependencies = [
  "tinyvec",
 ]
 
+[[package]]
+name = "unicode-segmentation"
+version = "1.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
+
 [[package]]
 name = "untrusted"
 version = "0.7.1"
@@ -776,6 +1405,16 @@ dependencies = [
  "sha1",
 ]
 
+[[package]]
+name = "want"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0"
+dependencies = [
+ "log",
+ "try-lock",
+]
+
 [[package]]
 name = "wasi"
 version = "0.11.0+wasi-snapshot-preview1"
@@ -803,7 +1442,7 @@ dependencies = [
  "once_cell",
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
  "wasm-bindgen-shared",
 ]
 
@@ -825,7 +1464,7 @@ checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
 dependencies = [
  "proc-macro2",
  "quote",
- "syn",
+ "syn 1.0.105",
  "wasm-bindgen-backend",
  "wasm-bindgen-shared",
 ]
@@ -865,6 +1504,17 @@ dependencies = [
  "webpki",
 ]
 
+[[package]]
+name = "which"
+version = "4.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
+dependencies = [
+ "either",
+ "libc",
+ "once_cell",
+]
+
 [[package]]
 name = "winapi"
 version = "0.3.9"
@@ -887,6 +1537,87 @@ version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
 
+[[package]]
+name = "windows-sys"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.45.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
+
 [[package]]
 name = "yasna"
 version = "0.3.2"
diff --git a/sdk/rust/Cargo.toml b/sdk/rust/Cargo.toml
index eb9ffd26..5cf7a71d 100644
--- a/sdk/rust/Cargo.toml
+++ b/sdk/rust/Cargo.toml
@@ -27,16 +27,17 @@ edition = "2021"
 crate-type = ["lib", "cdylib", "staticlib"]
 
 [dependencies]
-teaclave_types = { path = "../../types", features = ["app"] }
-teaclave_attestation = { path = "../../attestation" }
-teaclave_rpc = { path = "../../rpc" }
-teaclave_proto = { path = "../../services/proto" }
-anyhow       = { version = "1.0.26" }
-url          = { version = "2.1.1" }
-serde_json    = { version = "1.0.39" }
-serde         = { version = "1.0.92" }
-pem = "0.7.0"
-libc = "0.2.68"
+teaclave_types        = { path = "../../types", features = ["app"] }
+teaclave_attestation  = { path = "../../attestation" }
+teaclave_rpc          = { path = "../../rpc" }
+teaclave_proto        = { path = "../../services/proto" }
+anyhow                = { version = "1.0.26" }
+url                   = { version = "2.1.1" }
+serde_json            = { version = "1.0.39" }
+serde                 = { version = "1.0.92" }
+pem                   = { version = "0.7.0" }
+libc                  = { version = "0.2.68" }
+tokio                 = { version = "1.0", features = ["rt-multi-thread", "time", "macros"] }
 
 [patch.crates-io]
 sgx_tprotected_fs = { path = "../../third_party/rust-sgx-sdk/sgx_protected_fs/tfs" }
diff --git a/sdk/rust/src/lib.rs b/sdk/rust/src/lib.rs
index a212624e..f015c670 100644
--- a/sdk/rust/src/lib.rs
+++ b/sdk/rust/src/lib.rs
@@ -15,20 +15,19 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use anyhow::Result;
+use anyhow::{bail, Result};
 use std::collections::HashMap;
-use std::convert::TryInto;
+use std::convert::{TryFrom, TryInto};
 use teaclave_attestation::verifier;
 use teaclave_proto::teaclave_authentication_service::TeaclaveAuthenticationApiClient;
-use teaclave_proto::teaclave_authentication_service_proto as authentication_proto;
 use teaclave_proto::teaclave_frontend_service::TeaclaveFrontendClient;
-use teaclave_proto::teaclave_frontend_service_proto as frontend_proto;
-use teaclave_rpc::config::SgxTrustedTlsClientConfig;
-use teaclave_rpc::endpoint::Endpoint;
+use teaclave_rpc::transport::{Channel, Uri};
+use teaclave_rpc::{config::SgxTrustedTlsClientConfig, CredentialService, UserCredential};
 use teaclave_types::FileAuthTag;
+use tokio::runtime::Runtime;
 use url::Url;
 
-pub use teaclave_proto::teaclave_authentication_service::{
+use teaclave_proto::teaclave_authentication_service_proto::{
     UserLoginRequest, UserLoginResponse, UserRegisterRequest, UserRegisterResponse,
 };
 pub use teaclave_proto::teaclave_frontend_service::GetFunctionResponse as Function;
@@ -48,38 +47,49 @@ pub use teaclave_types::{
 
 pub mod bindings;
 
+// This macro is intended for use cases where you are invoking from synchronous code to asynchronous code.
+macro_rules! do_request_with_credential {
+    ($client:ident,$fun:ident,$request:ident) => {{
+        let response = $client.rt.block_on($client.client.$fun($request))?;
+        Ok(response.into_inner())
+    }};
+}
+
 pub struct AuthenticationClient {
-    api_client: TeaclaveAuthenticationApiClient,
+    client: TeaclaveAuthenticationApiClient<CredentialService>,
+    rt: Runtime,
+    channel: Channel,
 }
 
 pub struct AuthenticationService;
 
 impl AuthenticationClient {
-    pub fn new(api_client: TeaclaveAuthenticationApiClient) -> Self {
-        Self { api_client }
+    pub fn new(channel: Channel, rt: Runtime) -> Self {
+        Self {
+            client: TeaclaveAuthenticationApiClient::with_interceptor(
+                channel.clone(),
+                UserCredential::default(),
+            ),
+            channel,
+            rt,
+        }
     }
 
     pub fn set_credential(&mut self, id: &str, token: &str) {
-        let mut metadata = HashMap::new();
-        metadata.insert("id".to_string(), id.to_string());
-        metadata.insert("token".to_string(), token.to_string());
-        self.api_client.set_metadata(metadata);
+        let cred = UserCredential::new(id, token);
+        self.client = TeaclaveAuthenticationApiClient::with_interceptor(self.channel.clone(), cred);
     }
 
     pub fn user_register_with_request(
         &mut self,
         request: UserRegisterRequest,
     ) -> Result<UserRegisterResponse> {
-        let response = self.api_client.user_register(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, user_register, request)
     }
 
     pub fn user_register_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: authentication_proto::UserRegisterRequest =
-            serde_json::from_str(serialized_request)?;
-        let response: authentication_proto::UserRegisterResponse =
-            self.user_register_with_request(request.try_into()?)?.into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.user_register_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -102,16 +112,13 @@ impl AuthenticationClient {
         &mut self,
         request: UserLoginRequest,
     ) -> Result<UserLoginResponse> {
-        let response = self.api_client.user_login(request)?;
-
-        Ok(response)
+        let response = self.rt.block_on(self.client.user_login(request))?;
+        Ok(response.into_inner())
     }
 
     pub fn user_login_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: authentication_proto::UserLoginRequest =
-            serde_json::from_str(serialized_request)?;
-        let response: authentication_proto::UserLoginResponse =
-            self.user_login_with_request(request.try_into()?)?.into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.user_login_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -134,15 +141,31 @@ impl AuthenticationService {
         let enclave_attr = enclave_info
             .get_enclave_attr("teaclave_authentication_service")
             .expect("enclave attr");
-        let config = SgxTrustedTlsClientConfig::new().attestation_report_verifier(
-            vec![enclave_attr],
-            as_root_ca_cert,
-            verifier::universal_quote_verifier,
-        );
-        let channel = Endpoint::new(url).config(config).connect()?;
-        let client = TeaclaveAuthenticationApiClient::new(channel)?;
-
-        Ok(AuthenticationClient::new(client))
+        let tls_config = SgxTrustedTlsClientConfig::new()
+            .attestation_report_verifier(
+                vec![enclave_attr],
+                as_root_ca_cert,
+                verifier::universal_quote_verifier,
+            )
+            .into();
+        let rt = tokio::runtime::Builder::new_current_thread()
+            .enable_all()
+            .build()
+            .unwrap();
+        let dst = url.parse::<Uri>()?;
+        if dst.scheme().is_none() {
+            bail!("Invaild Uri: no scheme");
+        }
+        let endpoint = Channel::builder(dst);
+        let client = rt.block_on(async {
+            endpoint
+                .tls_config(tls_config)
+                .unwrap()
+                .connect()
+                .await
+                .unwrap()
+        });
+        Ok(AuthenticationClient::new(client, rt))
     }
 }
 
@@ -158,40 +181,65 @@ impl FrontendService {
         let enclave_attr = enclave_info
             .get_enclave_attr("teaclave_frontend_service")
             .expect("enclave attr");
-        let config = SgxTrustedTlsClientConfig::new().attestation_report_verifier(
-            vec![enclave_attr],
-            as_root_ca_cert,
-            verifier::universal_quote_verifier,
-        );
-        let channel = Endpoint::new(url).config(config).connect()?;
-        let client = TeaclaveFrontendClient::new(channel)?;
+        let tls_config = teaclave_rpc::config::SgxTrustedTlsClientConfig::new()
+            .attestation_report_verifier(
+                vec![enclave_attr],
+                as_root_ca_cert,
+                verifier::universal_quote_verifier,
+            )
+            .into();
+
+        let rt = tokio::runtime::Builder::new_current_thread()
+            .enable_all()
+            .build()
+            .unwrap();
+        let dst = url.parse::<Uri>()?;
+        if dst.scheme().is_none() {
+            bail!("Invaild Uri: no scheme");
+        }
 
-        Ok(FrontendClient::new(client))
+        let endpoint = Channel::builder(dst);
+        let client = rt.block_on(async {
+            let channel = endpoint
+                .tls_config(tls_config)
+                .unwrap()
+                .connect()
+                .await
+                .unwrap();
+            channel
+        });
+
+        Ok(FrontendClient::new(client, rt))
     }
 }
 
 pub struct FrontendClient {
-    api_client: TeaclaveFrontendClient,
+    client: TeaclaveFrontendClient<CredentialService>,
+    rt: Runtime,
+    channel: Channel,
 }
 
 impl FrontendClient {
-    pub fn new(api_client: TeaclaveFrontendClient) -> Self {
-        Self { api_client }
+    pub fn new(channel: Channel, rt: Runtime) -> Self {
+        Self {
+            client: TeaclaveFrontendClient::with_interceptor(
+                channel.clone(),
+                UserCredential::default(),
+            ),
+            channel,
+            rt,
+        }
     }
 
+    // The id in AuthenticationServiceRequest is the username.
     pub fn set_credential(&mut self, id: &str, token: &str) {
-        let mut metadata = HashMap::new();
-        metadata.insert("id".to_string(), id.to_string());
-        metadata.insert("token".to_string(), token.to_string());
-        self.api_client.set_metadata(metadata);
+        let cred = UserCredential::new(id, token);
+        self.client = TeaclaveFrontendClient::with_interceptor(self.channel.clone(), cred);
     }
 
     pub fn register_function_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: frontend_proto::RegisterFunctionRequest =
-            serde_json::from_str(serialized_request)?;
-        let response: frontend_proto::RegisterFunctionResponse = self
-            .register_function_with_request(request.try_into()?)?
-            .into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.register_function_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -201,9 +249,7 @@ impl FrontendClient {
         &mut self,
         request: RegisterFunctionRequest,
     ) -> Result<RegisterFunctionResponse> {
-        let response = self.api_client.register_function(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, register_function, request)
     }
 
     #[allow(clippy::too_many_arguments)]
@@ -244,22 +290,19 @@ impl FrontendClient {
         let request = builder.build();
         let response = self.register_function_with_request(request)?;
 
-        Ok(response.function_id.to_string())
+        Ok(response.function_id)
     }
 
     pub fn get_function_with_request(
         &mut self,
         request: GetFunctionRequest,
     ) -> Result<GetFunctionResponse> {
-        let response = self.api_client.get_function(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, get_function, request)
     }
 
     pub fn get_function_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: frontend_proto::GetFunctionRequest = serde_json::from_str(serialized_request)?;
-        let response: frontend_proto::GetFunctionResponse =
-            self.get_function_with_request(request.try_into()?)?.into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.get_function_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -277,11 +320,8 @@ impl FrontendClient {
         &mut self,
         serialized_request: &str,
     ) -> Result<String> {
-        let request: frontend_proto::GetFunctionUsageStatsRequest =
-            serde_json::from_str(serialized_request)?;
-        let response: frontend_proto::GetFunctionUsageStatsResponse = self
-            .get_function_usage_stats_with_request(request.try_into()?)?
-            .into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.get_function_usage_stats_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -299,26 +339,19 @@ impl FrontendClient {
         &mut self,
         request: GetFunctionUsageStatsRequest,
     ) -> Result<GetFunctionUsageStatsResponse> {
-        let response = self.api_client.get_function_usage_stats(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, get_function_usage_stats, request)
     }
 
     pub fn register_input_file_with_request(
         &mut self,
         request: RegisterInputFileRequest,
     ) -> Result<RegisterInputFileResponse> {
-        let response = self.api_client.register_input_file(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, register_input_file, request)
     }
 
     pub fn register_input_file_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: frontend_proto::RegisterInputFileRequest =
-            serde_json::from_str(serialized_request)?;
-        let response: frontend_proto::RegisterInputFileResponse = self
-            .register_input_file_with_request(request.try_into()?)?
-            .into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.register_input_file_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -335,24 +368,19 @@ impl FrontendClient {
         let request = RegisterInputFileRequest::new(url, cmac, file_crypto);
         let response = self.register_input_file_with_request(request)?;
 
-        Ok(response.data_id.to_string())
+        Ok(response.data_id)
     }
 
     pub fn register_output_file_with_request(
         &mut self,
         request: RegisterOutputFileRequest,
     ) -> Result<RegisterOutputFileResponse> {
-        let response = self.api_client.register_output_file(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, register_output_file, request)
     }
 
     pub fn register_output_file_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: frontend_proto::RegisterOutputFileRequest =
-            serde_json::from_str(serialized_request)?;
-        let response: frontend_proto::RegisterOutputFileResponse = self
-            .register_output_file_with_request(request.try_into()?)?
-            .into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.register_output_file_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -363,13 +391,12 @@ impl FrontendClient {
         let request = RegisterOutputFileRequest::new(url, file_crypto);
         let response = self.register_output_file_with_request(request)?;
 
-        Ok(response.data_id.to_string())
+        Ok(response.data_id)
     }
 
     pub fn create_task_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: frontend_proto::CreateTaskRequest = serde_json::from_str(serialized_request)?;
-        let response: frontend_proto::CreateTaskResponse =
-            self.create_task_with_request(request.try_into()?)?.into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.create_task_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -379,9 +406,7 @@ impl FrontendClient {
         &mut self,
         request: CreateTaskRequest,
     ) -> Result<CreateTaskResponse> {
-        let response = self.api_client.create_task(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, create_task, request)
     }
 
     pub fn create_task(
@@ -422,22 +447,19 @@ impl FrontendClient {
 
         let response = self.create_task_with_request(request)?;
 
-        Ok(response.task_id.to_string())
+        Ok(response.task_id)
     }
 
     pub fn assign_data_with_request(
         &mut self,
         request: AssignDataRequest,
     ) -> Result<AssignDataResponse> {
-        let response = self.api_client.assign_data(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, assign_data, request)
     }
 
     pub fn assign_data_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: frontend_proto::AssignDataRequest = serde_json::from_str(serialized_request)?;
-        let response: frontend_proto::AssignDataResponse =
-            self.assign_data_with_request(request.try_into()?)?.into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.assign_data_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -472,9 +494,7 @@ impl FrontendClient {
         &mut self,
         request: ApproveTaskRequest,
     ) -> Result<ApproveTaskResponse> {
-        let response = self.api_client.approve_task(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, approve_task, request)
     }
 
     pub fn approve_task(&mut self, task_id: &str) -> Result<()> {
@@ -485,9 +505,8 @@ impl FrontendClient {
     }
 
     pub fn approve_task_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: frontend_proto::ApproveTaskRequest = serde_json::from_str(serialized_request)?;
-        let response: frontend_proto::ApproveTaskResponse =
-            self.approve_task_with_request(request.try_into()?)?.into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.approve_task_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -497,15 +516,12 @@ impl FrontendClient {
         &mut self,
         request: InvokeTaskRequest,
     ) -> Result<InvokeTaskResponse> {
-        let response = self.api_client.invoke_task(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, invoke_task, request)
     }
 
     pub fn invoke_task_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: frontend_proto::InvokeTaskRequest = serde_json::from_str(serialized_request)?;
-        let response: frontend_proto::InvokeTaskResponse =
-            self.invoke_task_with_request(request.try_into()?)?.into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.invoke_task_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -519,15 +535,12 @@ impl FrontendClient {
     }
 
     pub fn get_task_with_request(&mut self, request: GetTaskRequest) -> Result<GetTaskResponse> {
-        let response = self.api_client.get_task(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, get_task, request)
     }
 
     pub fn get_task_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: frontend_proto::GetTaskRequest = serde_json::from_str(serialized_request)?;
-        let response: frontend_proto::GetTaskResponse =
-            self.get_task_with_request(request.try_into()?)?.into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.get_task_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -537,7 +550,8 @@ impl FrontendClient {
         loop {
             let request = GetTaskRequest::new(task_id.try_into()?);
             let response = self.get_task_with_request(request)?;
-            match response.result {
+            let result = teaclave_types::TaskResult::try_from(response.result)?;
+            match result {
                 TaskResult::NotReady => {
                     std::thread::sleep(std::time::Duration::from_secs(1));
                 }
@@ -555,15 +569,12 @@ impl FrontendClient {
         &mut self,
         request: CancelTaskRequest,
     ) -> Result<CancelTaskResponse> {
-        let response = self.api_client.cancel_task(request)?;
-
-        Ok(response)
+        do_request_with_credential!(self, cancel_task, request)
     }
 
     pub fn cancel_task_serialized(&mut self, serialized_request: &str) -> Result<String> {
-        let request: frontend_proto::CancelTaskRequest = serde_json::from_str(serialized_request)?;
-        let response: frontend_proto::CancelTaskResponse =
-            self.cancel_task_with_request(request.try_into()?)?.into();
+        let request = serde_json::from_str(serialized_request)?;
+        let response = self.cancel_task_with_request(request)?;
         let serialized_response = serde_json::to_string(&response)?;
 
         Ok(serialized_response)
@@ -594,36 +605,35 @@ mod tests {
     const ADMIN_ID: &str = "admin";
     const ADMIN_PASSWORD: &str = "teaclave";
 
-    #[test]
-    fn test_authentication_service() {
+    fn get_frontend_client() -> FrontendClient {
         let enclave_info = EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
         let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
         let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
-        let mut client =
-            AuthenticationService::connect("localhost:7776", &enclave_info, &as_root_ca_cert)
-                .unwrap();
+        let mut client = AuthenticationService::connect(
+            "https://localhost:7776",
+            &enclave_info,
+            &as_root_ca_cert,
+        )
+        .unwrap();
         let token = client.user_login(ADMIN_ID, ADMIN_PASSWORD).unwrap();
         client.set_credential(ADMIN_ID, &token);
         let _ = client.user_register(USER_ID, USER_PASSWORD, "PlatformAdmin", "");
-        client.user_login(USER_ID, USER_PASSWORD).unwrap();
+        let token = client.user_login(USER_ID, USER_PASSWORD).unwrap();
+        let mut client =
+            FrontendService::connect("https://localhost:7777", &enclave_info, &as_root_ca_cert)
+                .unwrap();
+        client.set_credential(USER_ID, &token);
+        client
     }
 
     #[test]
-    fn test_frontend_service() {
-        let enclave_info = EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
-        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
-        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
-        let mut client =
-            AuthenticationService::connect("localhost:7776", &enclave_info, &as_root_ca_cert)
-                .unwrap();
-        let token = client.user_login(ADMIN_ID, ADMIN_PASSWORD).unwrap();
-        client.set_credential(ADMIN_ID, &token);
-        let _ = client.user_register(USER_ID, USER_PASSWORD, "PlatformAdmin", "");
-        let token = client.user_login(USER_ID, USER_PASSWORD).unwrap();
+    fn test_authentication_service() {
+        get_frontend_client();
+    }
 
-        let mut client =
-            FrontendService::connect("localhost:7777", &enclave_info, &as_root_ca_cert).unwrap();
-        client.set_credential(USER_ID, &token);
+    #[test]
+    fn test_frontend_service() {
+        let mut client = get_frontend_client();
         let function_id = client
             .register_function(
                 "builtin-echo",
@@ -685,27 +695,14 @@ mod tests {
 
     #[test]
     fn test_frontend_service_with_request() {
-        let enclave_info = EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
-        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
-        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
-        let mut client =
-            AuthenticationService::connect("localhost:7776", &enclave_info, &as_root_ca_cert)
-                .unwrap();
-        let token = client.user_login(ADMIN_ID, ADMIN_PASSWORD).unwrap();
-        client.set_credential(ADMIN_ID, &token);
-        let _ = client.user_register(USER_ID, USER_PASSWORD, "PlatformAdmin", "");
-        let token = client.user_login(USER_ID, USER_PASSWORD).unwrap();
-
-        let mut client =
-            FrontendService::connect("localhost:7777", &enclave_info, &as_root_ca_cert).unwrap();
-        client.set_credential(USER_ID, &token);
-        let request = RegisterFunctionRequest::default();
+        let mut client = get_frontend_client();
+        let request = RegisterFunctionRequestBuilder::new().build();
         let function_id = client
             .register_function_with_request(request)
             .unwrap()
             .function_id;
 
-        let request = GetFunctionRequest::new(function_id);
+        let request = GetFunctionRequest::new(function_id.try_into().unwrap());
         let response = client.get_function_with_request(request);
         assert!(response.is_ok());
 
@@ -720,7 +717,7 @@ mod tests {
             .outputs_ownership(hashmap!("output" =>  vec!["frontend_user", "mock_user"]));
         let response = client.create_task_with_request(request);
         assert!(response.is_ok());
-        let task_id = response.unwrap().task_id;
+        let task_id = response.unwrap().task_id.try_into().unwrap();
 
         let request = GetTaskRequest::new(task_id);
         let response = client.get_task_with_request(request);
@@ -729,20 +726,7 @@ mod tests {
 
     #[test]
     fn test_assign_data() {
-        let enclave_info = EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
-        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
-        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
-        let mut client =
-            AuthenticationService::connect("localhost:7776", &enclave_info, &as_root_ca_cert)
-                .unwrap();
-        let token = client.user_login(ADMIN_ID, ADMIN_PASSWORD).unwrap();
-        client.set_credential(ADMIN_ID, &token);
-        let _ = client.user_register(USER_ID, USER_PASSWORD, "PlatformAdmin", "");
-        let token = client.user_login(USER_ID, USER_PASSWORD).unwrap();
-
-        let mut client =
-            FrontendService::connect("localhost:7777", &enclave_info, &as_root_ca_cert).unwrap();
-        client.set_credential(USER_ID, &token);
+        let mut client = get_frontend_client();
         let function_id = "function-00000000-0000-0000-0000-000000000002";
         let function_arguments = hashmap!("arg1" => "arg1_value");
         let outputs_ownership = hashmap!("output" => vec![USER_ID.to_string()]);
@@ -767,20 +751,7 @@ mod tests {
 
     #[test]
     fn test_assign_data_err() {
-        let enclave_info = EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
-        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
-        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
-        let mut client =
-            AuthenticationService::connect("localhost:7776", &enclave_info, &as_root_ca_cert)
-                .unwrap();
-        let token = client.user_login(ADMIN_ID, ADMIN_PASSWORD).unwrap();
-        client.set_credential(ADMIN_ID, &token);
-        let _ = client.user_register(USER_ID, USER_PASSWORD, "PlatformAdmin", "");
-        let token = client.user_login(USER_ID, USER_PASSWORD).unwrap();
-
-        let mut client =
-            FrontendService::connect("localhost:7777", &enclave_info, &as_root_ca_cert).unwrap();
-        client.set_credential(USER_ID, &token);
+        let mut client = get_frontend_client();
         let function_id = "function-00000000-0000-0000-0000-000000000002";
         let function_arguments = hashmap!("arg1" => "arg1_value");
         let outputs_ownership = hashmap!("output" => vec!["incorrect_user".to_string()]);
@@ -806,20 +777,7 @@ mod tests {
 
     #[test]
     fn test_approve_task() {
-        let enclave_info = EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
-        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
-        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
-        let mut client =
-            AuthenticationService::connect("localhost:7776", &enclave_info, &as_root_ca_cert)
-                .unwrap();
-        let token = client.user_login(ADMIN_ID, ADMIN_PASSWORD).unwrap();
-        client.set_credential(ADMIN_ID, &token);
-        let _ = client.user_register(USER_ID, USER_PASSWORD, "PlatformAdmin", "");
-        let token = client.user_login(USER_ID, USER_PASSWORD).unwrap();
-
-        let mut client =
-            FrontendService::connect("localhost:7777", &enclave_info, &as_root_ca_cert).unwrap();
-        client.set_credential(USER_ID, &token);
+        let mut client = get_frontend_client();
         let function_id = "function-00000000-0000-0000-0000-000000000002";
         let function_arguments = hashmap!("arg1" => "arg1_value");
         let outputs_ownership = hashmap!("output" => vec![USER_ID.to_string()]);
@@ -845,20 +803,7 @@ mod tests {
 
     #[test]
     fn test_cancel_task() {
-        let enclave_info = EnclaveInfo::from_file(ENCLAVE_INFO_PATH).unwrap();
-        let bytes = fs::read(AS_ROOT_CA_CERT_PATH).unwrap();
-        let as_root_ca_cert = pem::parse(bytes).unwrap().contents;
-        let mut client =
-            AuthenticationService::connect("localhost:7776", &enclave_info, &as_root_ca_cert)
-                .unwrap();
-        let token = client.user_login(ADMIN_ID, ADMIN_PASSWORD).unwrap();
-        client.set_credential(ADMIN_ID, &token);
-        let _ = client.user_register(USER_ID, USER_PASSWORD, "PlatformAdmin", "");
-        let token = client.user_login(USER_ID, USER_PASSWORD).unwrap();
-
-        let mut client =
-            FrontendService::connect("localhost:7777", &enclave_info, &as_root_ca_cert).unwrap();
-        client.set_credential(USER_ID, &token);
+        let mut client = get_frontend_client();
         let function_id = "function-00000000-0000-0000-0000-000000000002";
         let function_arguments = hashmap!("arg1" => "arg1_value");
         let outputs_ownership = hashmap!("output" => vec![USER_ID.to_string()]);
diff --git a/services/access_control/enclave/Cargo.toml b/services/access_control/enclave/Cargo.toml
index 6e61bc17..cf33cda4 100644
--- a/services/access_control/enclave/Cargo.toml
+++ b/services/access_control/enclave/Cargo.toml
@@ -49,6 +49,7 @@ log        = { version = "0.4.17", features = ["release_max_level_info"] }
 serde      = { version = "1.0.92" }
 serde_json = { version = "1.0.39" }
 thiserror  = { version = "1.0.9" }
+tokio      = { version = "1.0", features = ["rt-multi-thread", "time", "macros"] }
 ring       = { version = "0.16.5" }
 rand       = { version = "0.8.5" }
 
diff --git a/services/access_control/enclave/src/error.rs b/services/access_control/enclave/src/error.rs
index 87fa7de4..033005a6 100644
--- a/services/access_control/enclave/src/error.rs
+++ b/services/access_control/enclave/src/error.rs
@@ -15,7 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use teaclave_types::TeaclaveServiceResponseError;
 use thiserror::Error;
 
 #[derive(Error, Debug)]
@@ -24,8 +23,8 @@ pub(crate) enum TeaclavAccessControlError {
     AccessControlError,
 }
 
-impl From<TeaclavAccessControlError> for TeaclaveServiceResponseError {
+impl From<TeaclavAccessControlError> for teaclave_rpc::Status {
     fn from(error: TeaclavAccessControlError) -> Self {
-        TeaclaveServiceResponseError::RequestError(error.to_string())
+        teaclave_rpc::Status::permission_denied(error.to_string())
     }
 }
diff --git a/services/access_control/enclave/src/lib.rs b/services/access_control/enclave/src/lib.rs
index c6dbb7b9..056e713b 100644
--- a/services/access_control/enclave/src/lib.rs
+++ b/services/access_control/enclave/src/lib.rs
@@ -30,11 +30,8 @@ use teaclave_config::build::{
     ACCESS_CONTROL_INBOUND_SERVICES, AS_ROOT_CA_CERT, AUDITOR_PUBLIC_KEYS,
 };
 use teaclave_config::RuntimeConfig;
-use teaclave_proto::teaclave_access_control_service::{
-    TeaclaveAccessControlRequest, TeaclaveAccessControlResponse,
-};
-use teaclave_rpc::config::SgxTrustedTlsServerConfig;
-use teaclave_rpc::server::SgxTrustedTlsServer;
+use teaclave_proto::teaclave_access_control_service::TeaclaveAccessControlServer;
+use teaclave_rpc::{config::SgxTrustedTlsServerConfig, transport::Server};
 use teaclave_service_enclave_utils::ServiceEnclave;
 use teaclave_types::{EnclaveInfo, TeeServiceError, TeeServiceResult};
 
@@ -42,7 +39,10 @@ mod acs;
 mod error;
 mod service;
 
-fn start_service(config: &RuntimeConfig) -> Result<()> {
+// Sets the number of worker threads the Runtime will use.
+const N_WORKERS: usize = 8;
+
+async fn start_service(config: &RuntimeConfig) -> Result<()> {
     let listen_address = config.internal_endpoints.access_control.listen_address;
     let attestation_config = AttestationConfig::from_teaclave_config(config)?;
     let attested_tls_config = RemoteAttestation::new(attestation_config)
@@ -61,34 +61,40 @@ fn start_service(config: &RuntimeConfig) -> Result<()> {
             None => Err(anyhow!("cannot get enclave attribute of {}", service)),
         })
         .collect::<Result<_>>()?;
+
     let server_config = SgxTrustedTlsServerConfig::from_attested_tls_config(attested_tls_config)?
         .attestation_report_verifier(
-        accepted_enclave_attrs,
-        AS_ROOT_CA_CERT,
-        verifier::universal_quote_verifier,
-    )?;
-
+            accepted_enclave_attrs,
+            AS_ROOT_CA_CERT,
+            verifier::universal_quote_verifier,
+        )?
+        .into();
     acs::init_acs()?;
-    let mut server = SgxTrustedTlsServer::<
-        TeaclaveAccessControlResponse,
-        TeaclaveAccessControlRequest,
-    >::new(listen_address, server_config);
+
     let service = service::TeaclaveAccessControlService::new();
-    match server.start(service) {
-        Ok(_) => (),
-        Err(e) => {
-            error!("Service exit, error: {}.", e);
-        }
-    }
+
+    Server::builder()
+        .tls_config(server_config)
+        .map_err(|_| anyhow::anyhow!("TeaclaveFrontendServer tls config error"))?
+        .add_service(TeaclaveAccessControlServer::new(service))
+        .serve(listen_address)
+        .await?;
     Ok(())
 }
 
 #[handle_ecall]
 fn handle_start_service(input: &StartServiceInput) -> TeeServiceResult<StartServiceOutput> {
-    match start_service(&input.config) {
+    let result = tokio::runtime::Builder::new_multi_thread()
+        .worker_threads(N_WORKERS)
+        .enable_all()
+        .build()
+        .map_err(|_| TeeServiceError::SgxError)?
+        .block_on(start_service(&input.config));
+
+    match result {
         Ok(_) => Ok(StartServiceOutput),
         Err(e) => {
-            log::error!("Failed to start the service: {}", e);
+            error!("Failed to run service: {}", e);
             Err(TeeServiceError::ServiceError)
         }
     }
@@ -122,7 +128,7 @@ pub mod tests {
         if crate::acs::init_acs().is_err() {
             return false;
         }
-        run_tests!(
+        run_async_tests!(
             service::tests::user_access_data,
             service::tests::user_access_function,
             service::tests::user_access_task,
diff --git a/services/access_control/enclave/src/service.rs b/services/access_control/enclave/src/service.rs
index 4c67512e..b733dddc 100644
--- a/services/access_control/enclave/src/service.rs
+++ b/services/access_control/enclave/src/service.rs
@@ -22,11 +22,10 @@ use teaclave_proto::teaclave_access_control_service::{
     AuthorizeFunctionResponse, AuthorizeStagedTaskRequest, AuthorizeStagedTaskResponse,
     AuthorizeTaskRequest, AuthorizeTaskResponse, TeaclaveAccessControl,
 };
-use teaclave_rpc::Request;
-use teaclave_service_enclave_utils::{bail, teaclave_service};
+use teaclave_rpc::{Request, Response};
+use teaclave_service_enclave_utils::bail;
 use teaclave_types::TeaclaveServiceResponseResult;
 
-#[teaclave_service(teaclave_access_control_service, TeaclaveAccessControl)]
 #[derive(Clone)]
 pub(crate) struct TeaclaveAccessControlService {
     access_control_module: AccessControlModule,
@@ -40,60 +39,61 @@ impl TeaclaveAccessControlService {
     }
 }
 
+#[teaclave_rpc::async_trait]
 impl TeaclaveAccessControl for TeaclaveAccessControlService {
-    fn authorize_data(
+    async fn authorize_data(
         &self,
         request: Request<AuthorizeDataRequest>,
     ) -> TeaclaveServiceResponseResult<AuthorizeDataResponse> {
-        let request = request.message;
+        let request = request.into_inner();
         let request =
             EnforceRequest::UserAccessData(request.subject_user_id, request.object_data_id);
         match self.access_control_module.enforce_request(request) {
             Ok(accept) => {
                 let response = AuthorizeDataResponse::new(accept);
-                Ok(response)
+                Ok(Response::new(response))
             }
             Err(_) => Err(TeaclavAccessControlError::AccessControlError.into()),
         }
     }
 
-    fn authorize_function(
+    async fn authorize_function(
         &self,
         request: Request<AuthorizeFunctionRequest>,
     ) -> TeaclaveServiceResponseResult<AuthorizeFunctionResponse> {
-        let request = request.message;
+        let request = request.into_inner();
         let request =
             EnforceRequest::UserAccessFunction(request.subject_user_id, request.object_function_id);
         match self.access_control_module.enforce_request(request) {
             Ok(accept) => {
                 let response = AuthorizeFunctionResponse::new(accept);
-                Ok(response)
+                Ok(Response::new(response))
             }
             Err(_) => Err(TeaclavAccessControlError::AccessControlError.into()),
         }
     }
 
-    fn authorize_task(
+    async fn authorize_task(
         &self,
         request: Request<AuthorizeTaskRequest>,
     ) -> TeaclaveServiceResponseResult<AuthorizeTaskResponse> {
-        let request = request.message;
+        let request = request.into_inner();
         let request =
             EnforceRequest::UserAccessTask(request.subject_user_id, request.object_task_id);
         match self.access_control_module.enforce_request(request) {
             Ok(accept) => {
                 let response = AuthorizeTaskResponse::new(accept);
-                Ok(response)
+                Ok(Response::new(response))
             }
             Err(_) => Err(TeaclavAccessControlError::AccessControlError.into()),
         }
     }
 
-    fn authorize_staged_task(
+    async fn authorize_staged_task(
         &self,
         request: Request<AuthorizeStagedTaskRequest>,
     ) -> TeaclaveServiceResponseResult<AuthorizeStagedTaskResponse> {
-        let request = request.message;
+        let request = request.into_inner();
         let enforce_access_function_request = EnforceRequest::TaskAccessFunction(
             request.subject_task_id.clone(),
             request.object_function_id,
@@ -104,7 +104,7 @@ impl TeaclaveAccessControl for TeaclaveAccessControlService {
         {
             Ok(accept) => {
                 if !accept {
-                    return Ok(AuthorizeStagedTaskResponse::new(false));
+                    return Ok(Response::new(AuthorizeStagedTaskResponse::new(false)));
                 }
             }
             Err(_) => bail!(TeaclavAccessControlError::AccessControlError),
@@ -120,7 +120,7 @@ impl TeaclaveAccessControl for TeaclaveAccessControlService {
             {
                 Ok(accept) => {
                     if !accept {
-                        return Ok(AuthorizeStagedTaskResponse::new(false));
+                        return Ok(Response::new(AuthorizeStagedTaskResponse::new(false)));
                     }
                 }
                 Err(_) => bail!(TeaclavAccessControlError::AccessControlError),
@@ -137,13 +137,13 @@ impl TeaclaveAccessControl for TeaclaveAccessControlService {
             {
                 Ok(accept) => {
                     if !accept {
-                        return Ok(AuthorizeStagedTaskResponse::new(false));
+                        return Ok(Response::new(AuthorizeStagedTaskResponse::new(false)));
                     }
                 }
                 Err(_) => bail!(TeaclavAccessControlError::AccessControlError),
             }
         }
-        Ok(AuthorizeStagedTaskResponse { accept: true })
+        Ok(Response::new(AuthorizeStagedTaskResponse { accept: true }))
     }
 }
 
@@ -152,102 +152,101 @@ pub mod tests {
     use super::*;
     use teaclave_rpc::IntoRequest;
 
-    pub fn user_access_data() {
+    pub async fn user_access_data() {
         let service = TeaclaveAccessControlService::new();
         let request = AuthorizeDataRequest::new("mock_user_a", "mock_data").into_request();
-        let response = service.authorize_data(request);
+        let response = service.authorize_data(request).await;
         assert!(response.is_ok());
-        assert!(response.unwrap().accept);
+        assert!(response.unwrap().into_inner().accept);
 
         let request = AuthorizeDataRequest::new("mock_user_b", "mock_data").into_request();
-        let response = service.authorize_data(request);
+        let response = service.authorize_data(request).await;
         assert!(response.is_ok());
-        assert!(response.unwrap().accept);
+        assert!(response.unwrap().into_inner().accept);
 
         let request = AuthorizeDataRequest::new("mock_user_c", "mock_data").into_request();
-        let response = service.authorize_data(request);
+        let response = service.authorize_data(request).await;
         assert!(response.is_ok());
-        assert!(response.unwrap().accept);
+        assert!(response.unwrap().into_inner().accept);
 
         let request = AuthorizeDataRequest::new("mock_user_d", "mock_data").into_request();
-        let response = service.authorize_data(request);
+        let response = service.authorize_data(request).await;
         assert!(response.is_ok());
-        assert!(!response.unwrap().accept);
+        assert!(!response.unwrap().into_inner().accept);
 
         let request = AuthorizeDataRequest::new("mock_user_a", "mock_data_b").into_request();
-        let response = service.authorize_data(request);
+        let response = service.authorize_data(request).await;
         assert!(response.is_ok());
-        assert!(!response.unwrap().accept);
+        assert!(!response.unwrap().into_inner().accept);
     }
 
-    pub fn user_access_function() {
+    pub async fn user_access_function() {
         let service = TeaclaveAccessControlService::new();
         let request =
             AuthorizeFunctionRequest::new("mock_public_function_owner", "mock_public_function")
                 .into_request();
-        let response = service.authorize_function(request);
+        let response = service.authorize_function(request).await;
         assert!(response.is_ok());
-        assert!(response.unwrap().accept);
-
+        assert!(response.unwrap().into_inner().accept);
         let request =
             AuthorizeFunctionRequest::new("mock_private_function_owner", "mock_private_function")
                 .into_request();
-        let response = service.authorize_function(request);
+        let response = service.authorize_function(request).await;
         assert!(response.is_ok());
-        assert!(response.unwrap().accept);
+        assert!(response.unwrap().into_inner().accept);
 
         let request =
             AuthorizeFunctionRequest::new("mock_private_function_owner", "mock_public_function")
                 .into_request();
-        let response = service.authorize_function(request);
+        let response = service.authorize_function(request).await;
         assert!(response.is_ok());
-        assert!(response.unwrap().accept);
+        assert!(response.unwrap().into_inner().accept);
 
         let request =
             AuthorizeFunctionRequest::new("mock_public_function_owner", "mock_private_function")
                 .into_request();
-        let response = service.authorize_function(request);
+        let response = service.authorize_function(request).await;
         assert!(response.is_ok());
-        assert!(!response.unwrap().accept);
+        assert!(!response.unwrap().into_inner().accept);
     }
 
-    pub fn user_access_task() {
+    pub async fn user_access_task() {
         let service = TeaclaveAccessControlService::new();
         let request = AuthorizeTaskRequest::new("mock_participant_a", "mock_task").into_request();
-        let response = service.authorize_task(request);
+        let response = service.authorize_task(request).await;
         assert!(response.is_ok());
-        assert!(response.unwrap().accept);
+        assert!(response.unwrap().into_inner().accept);
 
         let request = AuthorizeTaskRequest::new("mock_participant_b", "mock_task").into_request();
-        let response = service.authorize_task(request);
+        let response = service.authorize_task(request).await;
         assert!(response.is_ok());
-        assert!(response.unwrap().accept);
+        assert!(response.unwrap().into_inner().accept);
 
         let request = AuthorizeTaskRequest::new("mock_participant_c", "mock_task").into_request();
-        let response = service.authorize_task(request);
+        let response = service.authorize_task(request).await;
         assert!(response.is_ok());
-        assert!(!response.unwrap().accept);
+        assert!(!response.unwrap().into_inner().accept);
     }
 
-    pub fn task_access_function() {
+    pub async fn task_access_function() {
         let service = TeaclaveAccessControlService::new();
         let mut request = get_correct_authorized_stage_task_req();
         request.object_function_id = "mock_staged_allowed_private_function".to_string();
-        let response = service.authorize_staged_task(request.into_request());
+        let response = service.authorize_staged_task(request.into_request()).await;
         assert!(response.is_ok());
-        assert!(response.unwrap().accept);
+        assert!(response.unwrap().into_inner().accept);
 
         let mut request = get_correct_authorized_stage_task_req();
         request.object_function_id = "mock_staged_public_function".to_string();
-        let response = service.authorize_staged_task(request.into_request());
+        let response = service.authorize_staged_task(request.into_request()).await;
         assert!(response.is_ok());
-        assert!(response.unwrap().accept);
+        assert!(response.unwrap().into_inner().accept);
 
         let mut request = get_correct_authorized_stage_task_req();
         request.object_function_id = "mock_staged_disallowed_private_function".to_string();
-        let response = service.authorize_staged_task(request.into_request());
+        let response = service.authorize_staged_task(request.into_request()).await;
         assert!(response.is_ok());
-        assert!(!response.unwrap().accept);
+        assert!(!response.unwrap().into_inner().accept);
     }
 
     fn get_correct_authorized_stage_task_req() -> AuthorizeStagedTaskRequest {
@@ -266,43 +265,42 @@ pub mod tests {
             ],
         }
     }
-    pub fn task_access_data() {
+
+    pub async fn task_access_data() {
         let service = TeaclaveAccessControlService::new();
         let request = get_correct_authorized_stage_task_req().into_request();
-        let response = service.authorize_staged_task(request);
+        let response = service.authorize_staged_task(request).await;
         assert!(response.is_ok());
-        assert!(response.unwrap().accept);
-
+        assert!(response.unwrap().into_inner().accept);
         let mut request = get_correct_authorized_stage_task_req();
         request
             .object_input_data_id_list
             .push("mock_staged_disallowed_data1".to_string());
-        let response = service.authorize_staged_task(request.into_request());
+        let response = service.authorize_staged_task(request.into_request()).await;
         assert!(response.is_ok());
-        assert!(!response.unwrap().accept);
-
+        assert!(!response.unwrap().into_inner().accept);
         let mut request = get_correct_authorized_stage_task_req();
         request
             .object_input_data_id_list
             .push("mock_staged_disallowed_data2".to_string());
-        let response = service.authorize_staged_task(request.into_request());
+        let response = service.authorize_staged_task(request.into_request()).await;
         assert!(response.is_ok());
-        assert!(!response.unwrap().accept);
+        assert!(!response.unwrap().into_inner().accept);
 
         let mut request = get_correct_authorized_stage_task_req();
         request
             .object_output_data_id_list
             .push("mock_staged_disallowed_data1".to_string());
-        let response = service.authorize_staged_task(request.into_request());
+        let response = service.authorize_staged_task(request.into_request()).await;
         assert!(response.is_ok());
-        assert!(!response.unwrap().accept);
+        assert!(!response.unwrap().into_inner().accept);
 
         let mut request = get_correct_authorized_stage_task_req();
         request
             .object_output_data_id_list
             .push("mock_staged_disallowed_data2".to_string());
-        let response = service.authorize_staged_task(request.into_request());
+        let response = service.authorize_staged_task(request.into_request()).await;
         assert!(response.is_ok());
-        assert!(!response.unwrap().accept);
+        assert!(!response.unwrap().into_inner().accept);
     }
 }
diff --git a/services/authentication/enclave/Cargo.toml b/services/authentication/enclave/Cargo.toml
index 13387d5d..9362af64 100644
--- a/services/authentication/enclave/Cargo.toml
+++ b/services/authentication/enclave/Cargo.toml
@@ -48,8 +48,8 @@ cfg-if    = { version = "0.1.9" }
 log       = { version = "0.4.17", features = ["release_max_level_info"] }
 serde     = { version = "1.0.92" }
 serde_json = { version = "1.0.39" }
-
 thiserror = { version = "1.0.9" }
+tokio     = { version = "1.0", features = ["rt-multi-thread", "time", "macros"] }
 ring      = { version = "0.16.5" }
 rand      = { version = "0.8.5" }
 jsonwebtoken = { version = "7.2.0" }
diff --git a/services/authentication/enclave/src/api_service.rs b/services/authentication/enclave/src/api_service.rs
index 38d605b1..7fccd04a 100644
--- a/services/authentication/enclave/src/api_service.rs
+++ b/services/authentication/enclave/src/api_service.rs
@@ -20,29 +20,24 @@ use crate::error::AuthenticationServiceError;
 use crate::user_db::DbClient;
 use crate::user_info::UserInfo;
 
+use std::sync::{Arc, Mutex};
 use std::time::{Duration, SystemTime, UNIX_EPOCH};
 #[allow(unused_imports)]
 use std::untrusted::time::SystemTimeEx;
 use teaclave_proto::teaclave_authentication_service::*;
-use teaclave_rpc::Request;
-use teaclave_service_enclave_utils::{bail, ensure, teaclave_service};
+use teaclave_rpc::{Request, Response};
+use teaclave_service_enclave_utils::{bail, ensure};
 use teaclave_types::{TeaclaveServiceResponseResult, UserRole};
-
-#[teaclave_service(
-    teaclave_authentication_service,
-    TeaclaveAuthenticationApi,
-    TeaclaveAuthenticationError
-)]
 #[derive(Clone)]
 pub(crate) struct TeaclaveAuthenticationApiService {
-    db_client: DbClient,
+    db_client: Arc<Mutex<DbClient>>,
     jwt_secret: Vec<u8>,
 }
 
 impl TeaclaveAuthenticationApiService {
     pub(crate) fn new(db_client: DbClient, jwt_secret: Vec<u8>) -> Self {
         Self {
-            db_client,
+            db_client: Arc::new(Mutex::new(db_client)),
             jwt_secret,
         }
     }
@@ -52,7 +47,7 @@ impl TeaclaveAuthenticationApiService {
         id: &str,
         token: &str,
     ) -> Result<UserRole, AuthenticationError> {
-        let user: UserInfo = match self.db_client.get_user(id) {
+        let user: UserInfo = match self.db_client.lock().unwrap().get_user(id) {
             Ok(value) => value,
             Err(_) => bail!(AuthenticationError::InvalidUserId),
         };
@@ -66,32 +61,42 @@ impl TeaclaveAuthenticationApiService {
             Err(_) => bail!(AuthenticationError::IncorrectToken),
         }
     }
-}
 
-impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
-    fn user_register(
+    fn validate_credential_in_request<T>(
         &self,
-        request: Request<UserRegisterRequest>,
-    ) -> TeaclaveServiceResponseResult<UserRegisterResponse> {
+        request: &Request<T>,
+    ) -> Result<UserRole, AuthenticationServiceError> {
         let id: String = request
-            .metadata
+            .metadata()
             .get("id")
+            .and_then(|x| x.to_str().ok())
             .ok_or(AuthenticationServiceError::MissingUserId)?
             .into();
         let token: String = request
-            .metadata
+            .metadata()
             .get("token")
+            .and_then(|x| x.to_str().ok())
             .ok_or(AuthenticationServiceError::MissingToken)?
             .into();
-
         let requester_role = self.validate_user_credential(&id, &token)?;
+        Ok(requester_role)
+    }
+}
 
-        let request = request.message;
+#[teaclave_rpc::async_trait]
+impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
+    async fn user_register(
+        &self,
+        request: Request<UserRegisterRequest>,
+    ) -> TeaclaveServiceResponseResult<UserRegisterResponse> {
+        let requester_role = self.validate_credential_in_request(&request)?;
+
+        let request = request.get_ref();
         ensure!(
             !request.id.is_empty(),
             AuthenticationServiceError::InvalidUserId
         );
-        if self.db_client.get_user(&request.id).is_ok() {
+        if self.db_client.lock().unwrap().get_user(&request.id).is_ok() {
             bail!(AuthenticationServiceError::UserIdExist);
         }
         let role = UserRole::new(&request.role, &request.attribute);
@@ -101,39 +106,35 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
         );
 
         ensure!(
-            authorize_user_register(&requester_role, &request),
+            authorize_user_register(&requester_role, request),
             AuthenticationServiceError::PermissionDenied
         );
 
         let new_user = UserInfo::new(&request.id, &request.password, role);
-        match self.db_client.create_user(&new_user) {
-            Ok(_) => Ok(UserRegisterResponse {}),
+        match self.db_client.lock().unwrap().create_user(&new_user) {
+            Ok(_) => Ok(Response::new(UserRegisterResponse {})),
             Err(e) => bail!(AuthenticationServiceError::Service(e.into())),
         }
     }
 
-    fn user_update(
+    async fn user_update(
         &self,
         request: Request<UserUpdateRequest>,
     ) -> TeaclaveServiceResponseResult<UserUpdateResponse> {
-        let id: String = request
-            .metadata
-            .get("id")
-            .ok_or(AuthenticationServiceError::MissingUserId)?
-            .into();
-        let token: String = request
-            .metadata
-            .get("token")
-            .ok_or(AuthenticationServiceError::MissingToken)?
-            .into();
-        let requester_role = self.validate_user_credential(&id, &token)?;
+        let requester_role = self.validate_credential_in_request(&request)?;
 
-        let request = request.message;
+        let request = request.get_ref();
         ensure!(
             !request.id.is_empty(),
             AuthenticationServiceError::InvalidUserId
         );
-        if self.db_client.get_user(&request.id).is_err() {
+        if self
+            .db_client
+            .lock()
+            .unwrap()
+            .get_user(&request.id)
+            .is_err()
+        {
             bail!(AuthenticationServiceError::InvalidUserId);
         }
         let role = UserRole::new(&request.role, &request.attribute);
@@ -143,22 +144,22 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
         );
 
         ensure!(
-            authorize_user_update(&requester_role, &request),
+            authorize_user_update(&requester_role, request),
             AuthenticationServiceError::PermissionDenied
         );
 
         let updated_user = UserInfo::new(&request.id, &request.password, role);
-        match self.db_client.update_user(&updated_user) {
-            Ok(_) => Ok(UserUpdateResponse {}),
+        match self.db_client.lock().unwrap().update_user(&updated_user) {
+            Ok(_) => Ok(Response::new(UserUpdateResponse {})),
             Err(e) => bail!(AuthenticationServiceError::Service(e.into())),
         }
     }
 
-    fn user_login(
+    async fn user_login(
         &self,
         request: Request<UserLoginRequest>,
     ) -> TeaclaveServiceResponseResult<UserLoginResponse> {
-        let request = request.message;
+        let request = request.get_ref();
         ensure!(!request.id.is_empty(), AuthenticationError::InvalidUserId);
         ensure!(
             !request.password.is_empty(),
@@ -166,6 +167,8 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
         );
         let user = self
             .db_client
+            .lock()
+            .unwrap()
             .get_user(&request.id)
             .map_err(|_| AuthenticationError::UserIdNotFound)?;
         if !user.verify_password(&request.password) {
@@ -176,64 +179,52 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
                 .map_err(|e| AuthenticationServiceError::Service(e.into()))?;
             let exp = (now + Duration::from_secs(24 * 60 * 60)).as_secs();
             match user.get_token(exp, &self.jwt_secret) {
-                Ok(token) => Ok(UserLoginResponse { token }),
+                Ok(token) => Ok(Response::new(UserLoginResponse { token })),
                 Err(e) => bail!(AuthenticationServiceError::Service(e)),
             }
         }
     }
 
-    fn user_change_password(
+    async fn user_change_password(
         &self,
         request: Request<UserChangePasswordRequest>,
     ) -> TeaclaveServiceResponseResult<UserChangePasswordResponse> {
+        let requester_role = self.validate_credential_in_request(&request)?;
+
         let id: String = request
-            .metadata
+            .metadata()
             .get("id")
-            .ok_or(AuthenticationServiceError::MissingUserId)?
+            .and_then(|x| x.to_str().ok())
+            .unwrap()
             .into();
-        let token: String = request
-            .metadata
-            .get("token")
-            .ok_or(AuthenticationServiceError::MissingToken)?
-            .into();
-        let requester_role = self.validate_user_credential(&id, &token)?;
-
-        let request = request.message;
+        let request = request.get_ref();
         ensure!(
             !request.password.is_empty(),
             AuthenticationError::InvalidPassword
         );
         let updated_user = UserInfo::new(&id, &request.password, requester_role);
 
-        match self.db_client.update_user(&updated_user) {
-            Ok(_) => Ok(UserChangePasswordResponse {}),
+        match self.db_client.lock().unwrap().update_user(&updated_user) {
+            Ok(_) => Ok(Response::new(UserChangePasswordResponse {})),
             Err(e) => bail!(AuthenticationServiceError::Service(e.into())),
         }
     }
 
-    fn reset_user_password(
+    async fn reset_user_password(
         &self,
         request: Request<ResetUserPasswordRequest>,
     ) -> TeaclaveServiceResponseResult<ResetUserPasswordResponse> {
-        let id: String = request
-            .metadata
-            .get("id")
-            .ok_or(AuthenticationServiceError::MissingUserId)?
-            .into();
-        let token: String = request
-            .metadata
-            .get("token")
-            .ok_or(AuthenticationServiceError::MissingToken)?
-            .into();
-        let requester_role = self.validate_user_credential(&id, &token)?;
+        let requester_role = self.validate_credential_in_request(&request)?;
 
-        let request = request.message;
+        let request = request.get_ref();
         ensure!(
             !request.id.is_empty(),
             AuthenticationServiceError::InvalidUserId
         );
         let user = self
             .db_client
+            .lock()
+            .unwrap()
             .get_user(&request.id)
             .map_err(|_| AuthenticationServiceError::PermissionDenied)?;
 
@@ -247,37 +238,29 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
             .to_simple()
             .encode_lower(&mut encode_buffer);
         let updated_user = UserInfo::new(&request.id, new_password, user.role);
-        match self.db_client.update_user(&updated_user) {
-            Ok(_) => Ok(ResetUserPasswordResponse {
+        match self.db_client.lock().unwrap().update_user(&updated_user) {
+            Ok(_) => Ok(Response::new(ResetUserPasswordResponse {
                 password: new_password.to_string(),
-            }),
+            })),
             Err(e) => bail!(AuthenticationServiceError::Service(e.into())),
         }
     }
 
-    fn delete_user(
+    async fn delete_user(
         &self,
         request: Request<DeleteUserRequest>,
     ) -> TeaclaveServiceResponseResult<DeleteUserResponse> {
-        let id: String = request
-            .metadata
-            .get("id")
-            .ok_or(AuthenticationServiceError::MissingUserId)?
-            .into();
-        let token: String = request
-            .metadata
-            .get("token")
-            .ok_or(AuthenticationServiceError::MissingToken)?
-            .into();
-        let requester_role = self.validate_user_credential(&id, &token)?;
+        let requester_role = self.validate_credential_in_request(&request)?;
 
-        let request = request.message;
+        let request = request.get_ref();
         ensure!(
             !request.id.is_empty(),
             AuthenticationServiceError::InvalidUserId
         );
         let user = self
             .db_client
+            .lock()
+            .unwrap()
             .get_user(&request.id)
             .map_err(|_| AuthenticationServiceError::PermissionDenied)?;
 
@@ -285,46 +268,40 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
             authorize_delete_user(&requester_role, &user),
             AuthenticationServiceError::PermissionDenied
         );
-        match self.db_client.delete_user(&request.id) {
-            Ok(_) => Ok(DeleteUserResponse {}),
+        match self.db_client.lock().unwrap().delete_user(&request.id) {
+            Ok(_) => Ok(Response::new(DeleteUserResponse {})),
             Err(e) => bail!(AuthenticationServiceError::Service(e.into())),
         }
     }
 
-    fn list_users(
+    async fn list_users(
         &self,
         request: Request<ListUsersRequest>,
     ) -> TeaclaveServiceResponseResult<ListUsersResponse> {
-        let id: String = request
-            .metadata
-            .get("id")
-            .ok_or(AuthenticationServiceError::MissingUserId)?
-            .into();
-        let token: String = request
-            .metadata
-            .get("token")
-            .ok_or(AuthenticationServiceError::MissingToken)?
-            .into();
-        let requester_role = self.validate_user_credential(&id, &token)?;
+        let requester_role = self.validate_credential_in_request(&request)?;
 
-        let request = request.message;
+        let request = request.get_ref();
         ensure!(
             !request.id.is_empty(),
             AuthenticationServiceError::InvalidUserId
         );
 
         ensure!(
-            authorize_list_users(&requester_role, &request),
+            authorize_list_users(&requester_role, request),
             AuthenticationServiceError::PermissionDenied
         );
 
         let users = match requester_role {
-            UserRole::PlatformAdmin => self.db_client.list_users(),
-            _ => self.db_client.list_users_by_attribute(&request.id),
+            UserRole::PlatformAdmin => self.db_client.lock().unwrap().list_users(),
+            _ => self
+                .db_client
+                .lock()
+                .unwrap()
+                .list_users_by_attribute(&request.id),
         };
 
         match users {
-            Ok(ids) => Ok(ListUsersResponse { ids }),
+            Ok(ids) => Ok(Response::new(ListUsersResponse { ids })),
             Err(e) => bail!(AuthenticationServiceError::Service(e.into())),
         }
     }
@@ -393,9 +370,8 @@ pub mod tests {
     use crate::user_db::*;
     use crate::user_info::*;
     use rand::RngCore;
-    use std::collections::HashMap;
     use std::vec;
-    use teaclave_rpc::IntoRequest;
+    use teaclave_rpc::{IntoRequest, MetadataMap};
 
     fn get_mock_service() -> TeaclaveAuthenticationApiService {
         let database = Database::open("").unwrap();
@@ -406,94 +382,104 @@ pub mod tests {
         crate::create_platform_admin_user(client, "admin", "teaclave").unwrap();
 
         TeaclaveAuthenticationApiService {
-            db_client: database.get_client(),
+            db_client: Arc::new(Mutex::new(database.get_client())),
             jwt_secret,
         }
     }
 
-    pub fn test_user_register() {
+    pub async fn test_user_register() {
         let service = get_mock_service();
         let request = UserLoginRequest::new("admin", "teaclave").into_request();
-        let response = service.user_login(request).unwrap();
+        let response = service.user_login(request).await.unwrap().into_inner();
 
-        let mut metadata = HashMap::new();
-        metadata.insert("id".to_owned(), "admin".to_owned());
-        metadata.insert("token".to_owned(), response.token);
+        let mut metadata = MetadataMap::new();
+        metadata.insert("id", "admin".parse().unwrap());
+        metadata.insert("token", response.token.parse().unwrap());
         let mut request =
             UserRegisterRequest::new("test_register_id", "test_password", "PlatformAdmin", "")
                 .into_request();
-        request.metadata = metadata;
-        assert!(service.user_register(request).is_ok());
+        let meta = request.metadata_mut();
+        *meta = metadata;
+        assert!(service.user_register(request).await.is_ok());
     }
 
-    pub fn test_user_update() {
+    pub async fn test_user_update() {
         let service = get_mock_service();
         let request = UserLoginRequest::new("admin", "teaclave").into_request();
-        let response = service.user_login(request).unwrap();
+        let response = service.user_login(request).await.unwrap().into_inner();
 
-        let mut metadata = HashMap::new();
-        metadata.insert("id".to_owned(), "admin".to_owned());
-        metadata.insert("token".to_owned(), response.token);
+        let mut metadata = MetadataMap::new();
+        metadata.insert("id", "admin".parse().unwrap());
+        metadata.insert("token", response.token.parse().unwrap());
         let mut request =
             UserRegisterRequest::new("test_update_id", "test_password", "PlatformAdmin", "")
                 .into_request();
-        request.metadata = metadata.clone();
-        assert!(service.user_register(request).is_ok());
+        let meta = request.metadata_mut();
+        *meta = metadata.clone();
+        assert!(service.user_register(request).await.is_ok());
 
         let mut request =
             UserUpdateRequest::new("test_update_id", "updated_password", "PlatformAdmin", "")
                 .into_request();
-        request.metadata = metadata.clone();
-        service.user_update(request).unwrap();
+        let meta = request.metadata_mut();
+        *meta = metadata.clone();
+        service.user_update(request).await.unwrap();
 
         let mut request =
             UserUpdateRequest::new("test_nonexist_id", "updated_password", "PlatformAdmin", "")
                 .into_request();
-        request.metadata = metadata;
-        assert!(service.user_update(request).is_err());
+        let meta = request.metadata_mut();
+        *meta = metadata;
+        assert!(service.user_update(request).await.is_err());
 
         let request = UserLoginRequest::new("test_update_id", "updated_password").into_request();
-        let response = service.user_login(request);
+        let response = service.user_login(request).await;
         assert!(response.is_ok());
     }
 
-    pub fn test_user_login() {
+    pub async fn test_user_login() {
         let service = get_mock_service();
 
         let request = UserLoginRequest::new("admin", "teaclave").into_request();
-        let response = service.user_login(request).unwrap();
+        let response = service.user_login(request).await.unwrap().into_inner();
 
-        let mut metadata = HashMap::new();
-        metadata.insert("id".to_owned(), "admin".to_owned());
-        metadata.insert("token".to_owned(), response.token);
+        let mut metadata = MetadataMap::new();
+        metadata.insert("id", "admin".parse().unwrap());
+        metadata.insert("token", response.token.parse().unwrap());
 
         let mut request =
             UserRegisterRequest::new("test_login_id", "test_password", "FunctionOwner", "")
                 .into_request();
-        request.metadata = metadata;
-        assert!(service.user_register(request).is_ok());
+        let meta = request.metadata_mut();
+        *meta = metadata;
+        assert!(service.user_register(request).await.is_ok());
 
         let request = UserLoginRequest::new("test_login_id", "test_password").into_request();
-        let response = service.user_login(request);
+        let response = service.user_login(request).await;
         assert!(response.is_ok());
 
-        let token = response.unwrap().token;
-        let user = service.db_client.get_user("test_login_id").unwrap();
+        let token = response.unwrap().into_inner().token;
+        let user = service
+            .db_client
+            .lock()
+            .unwrap()
+            .get_user("test_login_id")
+            .unwrap();
         assert!(user.validate_token(&service.jwt_secret, &token).is_ok());
 
         debug!("saved user_info: {:?}", user);
         let request = UserLoginRequest::new("test_login_id", "test_password1").into_request();
-        assert!(service.user_login(request).is_err());
+        assert!(service.user_login(request).await.is_err());
     }
 
-    pub fn test_user_change_password() {
+    pub async fn test_user_change_password() {
         let service = get_mock_service();
         let request = UserLoginRequest::new("admin", "teaclave").into_request();
-        let response = service.user_login(request).unwrap();
+        let response = service.user_login(request).await.unwrap().into_inner();
 
-        let mut metadata = HashMap::new();
-        metadata.insert("id".to_owned(), "admin".to_owned());
-        metadata.insert("token".to_owned(), response.token);
+        let mut metadata = MetadataMap::new();
+        metadata.insert("id", "admin".parse().unwrap());
+        metadata.insert("token", response.token.parse().unwrap());
         let mut request = UserRegisterRequest::new(
             "test_user_change_password_id",
             "test_password",
@@ -501,38 +487,39 @@ pub mod tests {
             "",
         )
         .into_request();
-        request.metadata = metadata;
-        assert!(service.user_register(request).is_ok());
+        *request.metadata_mut() = metadata;
+        assert!(service.user_register(request).await.is_ok());
 
         let request =
             UserLoginRequest::new("test_user_change_password_id", "test_password").into_request();
-        let response = service.user_login(request).unwrap();
-        let mut metadata = HashMap::new();
-        metadata.insert("id".to_owned(), "test_user_change_password_id".to_owned());
-        metadata.insert("token".to_owned(), response.token);
+        let response = service.user_login(request).await.unwrap().into_inner();
+        let mut metadata = MetadataMap::new();
+        metadata.insert("id", "test_user_change_password_id".parse().unwrap());
+        metadata.insert("token", response.token.parse().unwrap());
 
         let mut request = UserChangePasswordRequest::new("updated_password").into_request();
-        request.metadata = metadata.clone();
-        service.user_change_password(request).unwrap();
+        *request.metadata_mut() = metadata.clone();
+        service.user_change_password(request).await.unwrap();
 
         let mut request = UserChangePasswordRequest::new("").into_request();
-        request.metadata = metadata;
-        assert!(service.user_change_password(request).is_err());
+        *request.metadata_mut() = metadata;
+
+        assert!(service.user_change_password(request).await.is_err());
 
         let request = UserLoginRequest::new("test_user_change_password_id", "updated_password")
             .into_request();
-        let response = service.user_login(request);
+        let response = service.user_login(request).await;
         assert!(response.is_ok());
     }
 
-    pub fn test_reset_user_password() {
+    pub async fn test_reset_user_password() {
         let service = get_mock_service();
         let request = UserLoginRequest::new("admin", "teaclave").into_request();
-        let response = service.user_login(request).unwrap();
+        let response = service.user_login(request).await.unwrap().into_inner();
 
-        let mut metadata = HashMap::new();
-        metadata.insert("id".to_owned(), "admin".to_owned());
-        metadata.insert("token".to_owned(), response.token);
+        let mut metadata = MetadataMap::new();
+        metadata.insert("id", "admin".parse().unwrap());
+        metadata.insert("token", response.token.parse().unwrap());
         let mut request = UserRegisterRequest::new(
             "test_reset_user_password_id",
             "test_password",
@@ -540,57 +527,64 @@ pub mod tests {
             "",
         )
         .into_request();
-        request.metadata = metadata.clone();
-        assert!(service.user_register(request).is_ok());
+        *request.metadata_mut() = metadata.clone();
+        assert!(service.user_register(request).await.is_ok());
 
         let mut request =
             ResetUserPasswordRequest::new("test_reset_user_password_id").into_request();
-        request.metadata = metadata;
-        let response = service.reset_user_password(request);
+        *request.metadata_mut() = metadata.clone();
+        let response = service.reset_user_password(request).await;
         assert!(response.is_ok());
 
-        let request =
-            UserLoginRequest::new("test_reset_user_password_id", response.unwrap().password)
-                .into_request();
-        let response = service.user_login(request);
+        let request = UserLoginRequest::new(
+            "test_reset_user_password_id",
+            response.unwrap().into_inner().password,
+        )
+        .into_request();
+        let response = service.user_login(request).await;
         assert!(response.is_ok());
     }
 
-    pub fn test_delete_user() {
+    pub async fn test_delete_user() {
         let service = get_mock_service();
 
         let request = UserLoginRequest::new("admin", "teaclave").into_request();
-        let response = service.user_login(request).unwrap();
+        let response = service.user_login(request).await.unwrap().into_inner();
 
-        let mut metadata = HashMap::new();
-        metadata.insert("id".to_owned(), "admin".to_owned());
-        metadata.insert("token".to_owned(), response.token);
+        let mut metadata = MetadataMap::new();
+        metadata.insert("id", "admin".parse().unwrap());
+        metadata.insert("token", response.token.parse().unwrap());
 
         let mut request =
             UserRegisterRequest::new("test_delete_user_id", "test_password", "FunctionOwner", "")
                 .into_request();
-        request.metadata = metadata;
-        assert!(service.user_register(request).is_ok());
+        *request.metadata_mut() = metadata;
+        assert!(service.user_register(request).await.is_ok());
 
         let request = UserLoginRequest::new("test_delete_user_id", "test_password").into_request();
-        let response = service.user_login(request);
+        let response = service.user_login(request).await;
         assert!(response.is_ok());
 
-        let token = response.unwrap().token;
-        let user = service.db_client.get_user("test_delete_user_id").unwrap();
+        let token = response.unwrap().into_inner().token;
+        let user = service
+            .db_client
+            .lock()
+            .unwrap()
+            .get_user("test_delete_user_id")
+            .unwrap();
         assert!(user.validate_token(&service.jwt_secret, &token).is_ok());
 
         let request = UserLoginRequest::new("admin", "teaclave").into_request();
-        let response = service.user_login(request).unwrap();
-        let mut metadata = HashMap::new();
-        metadata.insert("id".to_owned(), "admin".to_owned());
-        metadata.insert("token".to_owned(), response.token);
+        let response = service.user_login(request).await.unwrap().into_inner();
+        let mut metadata = MetadataMap::new();
+        metadata.insert("id", "admin".parse().unwrap());
+        metadata.insert("token", response.token.parse().unwrap());
         let mut request = DeleteUserRequest::new("test_delete_user_id").into_request();
-        request.metadata = metadata;
-        assert!(service.delete_user(request).is_ok());
+        *request.metadata_mut() = metadata;
+        assert!(service.delete_user(request).await.is_ok());
 
         debug!("saved user_info: {:?}", user);
         let request = UserLoginRequest::new("test_delete_user_id", "test_password").into_request();
-        assert!(service.user_login(request).is_err());
+        assert!(service.user_login(request).await.is_err());
     }
 }
diff --git a/services/authentication/enclave/src/error.rs b/services/authentication/enclave/src/error.rs
index d276fca4..b8d34af8 100644
--- a/services/authentication/enclave/src/error.rs
+++ b/services/authentication/enclave/src/error.rs
@@ -15,7 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use teaclave_types::TeaclaveServiceResponseError;
 use thiserror::Error;
 
 #[derive(Error, Debug)]
@@ -40,11 +39,9 @@ impl From<AuthenticationError> for AuthenticationServiceError {
     }
 }
 
-impl From<AuthenticationError> for TeaclaveServiceResponseError {
+impl From<AuthenticationError> for teaclave_rpc::Status {
     fn from(error: AuthenticationError) -> Self {
-        TeaclaveServiceResponseError::RequestError(
-            AuthenticationServiceError::from(error).to_string(),
-        )
+        teaclave_rpc::Status::unauthenticated(AuthenticationServiceError::from(error).to_string())
     }
 }
 
@@ -68,9 +65,9 @@ pub(crate) enum AuthenticationServiceError {
     MissingToken,
 }
 
-impl From<AuthenticationServiceError> for TeaclaveServiceResponseError {
+impl From<AuthenticationServiceError> for teaclave_rpc::Status {
     fn from(error: AuthenticationServiceError) -> Self {
         log::debug!("AuthenticationServiceError: {:?}", error);
-        TeaclaveServiceResponseError::RequestError(error.to_string())
+        teaclave_rpc::Status::unauthenticated(error.to_string())
     }
 }
diff --git a/services/authentication/enclave/src/internal_service.rs b/services/authentication/enclave/src/internal_service.rs
index b3fbb653..3d26fcf4 100644
--- a/services/authentication/enclave/src/internal_service.rs
+++ b/services/authentication/enclave/src/internal_service.rs
@@ -18,49 +18,50 @@
 use crate::error::AuthenticationError;
 use crate::user_db::DbClient;
 use crate::user_info::UserInfo;
+use std::sync::{Arc, Mutex};
 use teaclave_proto::teaclave_authentication_service::{
     TeaclaveAuthenticationInternal, UserAuthenticateRequest, UserAuthenticateResponse,
 };
-use teaclave_rpc::Request;
-use teaclave_service_enclave_utils::{bail, teaclave_service};
+use teaclave_rpc::{ensure, Request, Response};
+use teaclave_service_enclave_utils::bail;
 use teaclave_types::TeaclaveServiceResponseResult;
-
-#[teaclave_service(teaclave_authentication_service, TeaclaveAuthenticationInternal)]
 #[derive(Clone)]
 pub(crate) struct TeaclaveAuthenticationInternalService {
-    db_client: DbClient,
+    db_client: Arc<Mutex<DbClient>>,
     jwt_secret: Vec<u8>,
 }
 
 impl TeaclaveAuthenticationInternalService {
     pub(crate) fn new(db_client: DbClient, jwt_secret: Vec<u8>) -> Self {
         Self {
-            db_client,
+            db_client: Arc::new(Mutex::new(db_client)),
             jwt_secret,
         }
     }
 }
 
+#[teaclave_rpc::async_trait]
 impl TeaclaveAuthenticationInternal for TeaclaveAuthenticationInternalService {
-    fn user_authenticate(
+    async fn user_authenticate(
         &self,
         request: Request<UserAuthenticateRequest>,
     ) -> TeaclaveServiceResponseResult<UserAuthenticateResponse> {
-        let request = request.message;
-        if request.credential.id.is_empty() {
-            bail!(AuthenticationError::InvalidUserId);
-        }
-        if request.credential.token.is_empty() {
-            bail!(AuthenticationError::InvalidToken);
-        }
-        let user: UserInfo = match self.db_client.get_user(&request.credential.id) {
+        let request = request.into_inner();
+        ensure!(
+            request.credential.is_some(),
+            AuthenticationError::IncorrectToken
+        );
+        let cred = request.credential.unwrap();
+        ensure!(!cred.id.is_empty(), AuthenticationError::InvalidUserId);
+        ensure!(!cred.token.is_empty(), AuthenticationError::InvalidToken);
+        let user: UserInfo = match self.db_client.lock().unwrap().get_user(&cred.id) {
             Ok(value) => value,
             Err(_) => bail!(AuthenticationError::InvalidUserId),
         };
         let claims = user
-            .validate_token(&self.jwt_secret, &request.credential.token)
+            .validate_token(&self.jwt_secret, &cred.token)
             .map_err(|_| AuthenticationError::IncorrectToken)?;
-        Ok(UserAuthenticateResponse { claims })
+        Ok(Response::new(UserAuthenticateResponse::new(claims)))
     }
 }
 
@@ -90,27 +91,27 @@ pub mod tests {
         );
         database.get_client().create_user(&user).unwrap();
         TeaclaveAuthenticationInternalService {
-            db_client: database.get_client(),
+            db_client: Arc::new(Mutex::new(database.get_client())),
             jwt_secret,
         }
     }
 
-    pub fn test_user_authenticate() {
+    pub async fn test_user_authenticate() {
         let id = "test_authenticate_id";
         let service = get_mock_service();
-        let user = service.db_client.get_user(id).unwrap();
+        let user = service.db_client.lock().unwrap().get_user(id).unwrap();
 
         let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
         let exp = (now + Duration::from_secs(24 * 60 * 60)).as_secs(); // 1 day
         let token = user.get_token(exp, &service.jwt_secret).unwrap();
 
-        let response = get_authenticate_response(id, &token, &service);
+        let response = get_authenticate_response(id, &token, &service).await;
         assert!(response.is_ok());
         let token = validate_token(id, &service.jwt_secret, &token);
         debug!("valid token: {:?}", token.unwrap());
     }
 
-    pub fn test_invalid_algorithm() {
+    pub async fn test_invalid_algorithm() {
         let id = "test_authenticate_id";
         let service = get_mock_service();
         let my_claims = get_correct_claim(id);
@@ -119,7 +120,7 @@ pub mod tests {
             Some(jsonwebtoken::Algorithm::HS256),
             &service.jwt_secret,
         );
-        let response = get_authenticate_response(id, &token, &service);
+        let response = get_authenticate_response(id, &token, &service).await;
         assert!(response.is_err());
         let error = validate_token(id, &service.jwt_secret, &token);
         assert!(error.is_err());
@@ -129,13 +130,13 @@ pub mod tests {
         }
     }
 
-    pub fn test_invalid_issuer() {
+    pub async fn test_invalid_issuer() {
         let id = "test_authenticate_id";
         let service = get_mock_service();
         let mut my_claims = get_correct_claim(id);
         my_claims.iss = "wrong issuer".to_string();
         let token = gen_token(my_claims, None, &service.jwt_secret);
-        let response = get_authenticate_response(id, &token, &service);
+        let response = get_authenticate_response(id, &token, &service).await;
         assert!(response.is_err());
         let error = validate_token(id, &service.jwt_secret, &token);
         assert!(error.is_err());
@@ -145,13 +146,13 @@ pub mod tests {
         }
     }
 
-    pub fn test_expired_token() {
+    pub async fn test_expired_token() {
         let id = "test_authenticate_id";
         let service = get_mock_service();
         let mut my_claims = get_correct_claim(id);
         my_claims.exp -= 24 * 60 + 1;
         let token = gen_token(my_claims, None, &service.jwt_secret);
-        let response = get_authenticate_response(id, &token, &service);
+        let response = get_authenticate_response(id, &token, &service).await;
         assert!(response.is_err());
         let error = validate_token(id, &service.jwt_secret, &token);
         assert!(error.is_err());
@@ -161,14 +162,14 @@ pub mod tests {
         }
     }
 
-    pub fn test_invalid_user() {
+    pub async fn test_invalid_user() {
         let id = "test_authenticate_id";
         let service = get_mock_service();
         let mut my_claims = get_correct_claim(id);
         my_claims.sub = "wrong user".to_string();
         my_claims.role = UserRole::PlatformAdmin.to_string();
         let token = gen_token(my_claims, None, &service.jwt_secret);
-        let response = get_authenticate_response(id, &token, &service);
+        let response = get_authenticate_response(id, &token, &service).await;
         assert!(response.is_err());
         let error = validate_token(id, &service.jwt_secret, &token);
         assert!(error.is_err());
@@ -178,12 +179,12 @@ pub mod tests {
         }
     }
 
-    pub fn test_wrong_secret() {
+    pub async fn test_wrong_secret() {
         let id = "test_authenticate_id";
         let service = get_mock_service();
         let my_claims = get_correct_claim(id);
         let token = gen_token(my_claims, None, b"bad secret");
-        let response = get_authenticate_response(id, &token, &service);
+        let response = get_authenticate_response(id, &token, &service).await;
         assert!(response.is_err());
         let error = validate_token(id, &service.jwt_secret, &token);
         assert!(error.is_err());
@@ -219,14 +220,14 @@ pub mod tests {
         jsonwebtoken::encode(&header, &claim, &secret).unwrap()
     }
 
-    fn get_authenticate_response(
+    async fn get_authenticate_response(
         id: &str,
         token: &str,
         service: &TeaclaveAuthenticationInternalService,
     ) -> TeaclaveServiceResponseResult<UserAuthenticateResponse> {
         let credential = UserCredential::new(id, token);
         let request = UserAuthenticateRequest::new(credential).into_request();
-        service.user_authenticate(request)
+        service.user_authenticate(request).await
     }
 
     fn validate_token(
diff --git a/services/authentication/enclave/src/lib.rs b/services/authentication/enclave/src/lib.rs
index 02d87311..921a10ab 100644
--- a/services/authentication/enclave/src/lib.rs
+++ b/services/authentication/enclave/src/lib.rs
@@ -22,7 +22,6 @@ use anyhow::{anyhow, Result};
 
 use rand::RngCore;
 use std::sync::{Arc, RwLock};
-use std::thread;
 
 use teaclave_attestation::{verifier, AttestationConfig, AttestedTlsConfig, RemoteAttestation};
 use teaclave_binder::proto::{
@@ -35,11 +34,9 @@ use teaclave_config::build::{
 };
 use teaclave_config::RuntimeConfig;
 use teaclave_proto::teaclave_authentication_service::{
-    TeaclaveAuthenticationApiRequest, TeaclaveAuthenticationApiResponse,
-    TeaclaveAuthenticationInternalRequest, TeaclaveAuthenticationInternalResponse,
+    TeaclaveAuthenticationApiServer, TeaclaveAuthenticationInternalServer,
 };
-use teaclave_rpc::config::SgxTrustedTlsServerConfig;
-use teaclave_rpc::server::SgxTrustedTlsServer;
+use teaclave_rpc::{config::SgxTrustedTlsServerConfig, transport::Server};
 use teaclave_service_enclave_utils::{base_dir_for_db, ServiceEnclave};
 use teaclave_types::{EnclaveInfo, TeeServiceError, TeeServiceResult, UserRole};
 
@@ -49,7 +46,7 @@ mod internal_service;
 mod user_db;
 mod user_info;
 
-fn start_internal_endpoint(
+async fn start_internal_endpoint(
     addr: std::net::SocketAddr,
     db_client: user_db::DbClient,
     jwt_secret: Vec<u8>,
@@ -58,53 +55,42 @@ fn start_internal_endpoint(
 ) -> Result<()> {
     let server_config = SgxTrustedTlsServerConfig::from_attested_tls_config(attested_tls_config)?
         .attestation_report_verifier(
-        accepted_enclave_attrs,
-        AS_ROOT_CA_CERT,
-        verifier::universal_quote_verifier,
-    )?;
-
-    let mut server = SgxTrustedTlsServer::<
-        TeaclaveAuthenticationInternalResponse,
-        TeaclaveAuthenticationInternalRequest,
-    >::new(addr, server_config);
-
+            accepted_enclave_attrs,
+            AS_ROOT_CA_CERT,
+            verifier::universal_quote_verifier,
+        )?
+        .into();
     let service =
         internal_service::TeaclaveAuthenticationInternalService::new(db_client, jwt_secret);
-
-    match server.start(service) {
-        Ok(_) => Ok(()),
-        Err(e) => {
-            error!("Service exit, error: {}.", e);
-            Err(anyhow!("cannot start internal endpoint"))
-        }
-    }
+    Server::builder()
+        .tls_config(server_config)
+        .map_err(|_| anyhow!("TeaclaveFrontendServer tls config error"))?
+        .add_service(TeaclaveAuthenticationInternalServer::new(service))
+        .serve(addr)
+        .await?;
+    Ok(())
 }
 
-fn start_api_endpoint(
+async fn start_api_endpoint(
     addr: std::net::SocketAddr,
     db_client: user_db::DbClient,
     jwt_secret: Vec<u8>,
     attested_tls_config: Arc<RwLock<AttestedTlsConfig>>,
 ) -> Result<()> {
-    let server_config = SgxTrustedTlsServerConfig::from_attested_tls_config(attested_tls_config)?;
-
-    let mut server = SgxTrustedTlsServer::<
-        TeaclaveAuthenticationApiResponse,
-        TeaclaveAuthenticationApiRequest,
-    >::new(addr, server_config);
+    let tls_config =
+        SgxTrustedTlsServerConfig::from_attested_tls_config(attested_tls_config)?.into();
 
     let service = api_service::TeaclaveAuthenticationApiService::new(db_client, jwt_secret);
-
-    match server.start(service) {
-        Ok(_) => Ok(()),
-        Err(e) => {
-            error!("Service exit, error: {}.", e);
-            Err(anyhow!("cannot start API endpoint"))
-        }
-    }
+    Server::builder()
+        .tls_config(tls_config)
+        .map_err(|_| anyhow!("TeaclaveAuthenticationApiServer tls config error"))?
+        .add_service(TeaclaveAuthenticationApiServer::new(service))
+        .serve(addr)
+        .await?;
+    Ok(())
 }
 
-fn start_service(config: &RuntimeConfig) -> Result<()> {
+async fn start_service(config: &RuntimeConfig) -> Result<()> {
     info!("Starting Authentication...");
 
     let enclave_info = EnclaveInfo::verify_and_new(
@@ -146,33 +132,30 @@ fn start_service(config: &RuntimeConfig) -> Result<()> {
     }
 
     let client = database.get_client();
-    let api_endpoint_thread_handler = thread::spawn(move || {
-        let _ = start_api_endpoint(
-            api_listen_address,
-            client,
-            api_jwt_secret,
-            attested_tls_config_ref,
-        );
-    });
+    let api_endpoint_thread_handler = tokio::spawn(start_api_endpoint(
+        api_listen_address,
+        client,
+        api_jwt_secret,
+        attested_tls_config_ref,
+    ));
+
     info!(" Starting Authentication: setup API endpoint finished ...");
 
     let client = database.get_client();
-    let internal_endpoint_thread_handler = thread::spawn(move || {
-        let _ = start_internal_endpoint(
-            internal_listen_address,
-            client,
-            internal_jwt_secret,
-            attested_tls_config,
-            accepted_enclave_attrs,
-        );
-    });
+    let internal_endpoint_thread_handler = tokio::spawn(start_internal_endpoint(
+        internal_listen_address,
+        client,
+        internal_jwt_secret,
+        attested_tls_config,
+        accepted_enclave_attrs,
+    ));
     info!(" Starting Authentication: setup Internal endpoint finished ...");
 
-    api_endpoint_thread_handler
-        .join()
+    let _ = api_endpoint_thread_handler
+        .await
         .expect("cannot join API endpoint thread");
-    internal_endpoint_thread_handler
-        .join()
+    let _ = internal_endpoint_thread_handler
+        .await
         .expect("cannot join internal endpoint thread");
 
     info!(" Starting Authentication: start listening ...");
@@ -192,10 +175,16 @@ pub(crate) fn create_platform_admin_user(
 
 #[handle_ecall]
 fn handle_start_service(input: &StartServiceInput) -> TeeServiceResult<StartServiceOutput> {
-    match start_service(&input.config) {
+    let result = tokio::runtime::Builder::new_current_thread()
+        .enable_all()
+        .build()
+        .map_err(|_| TeeServiceError::SgxError)?
+        .block_on(start_service(&input.config));
+
+    match result {
         Ok(_) => Ok(StartServiceOutput),
         Err(e) => {
-            log::error!("Failed to start the service: {}", e);
+            error!("Failed to run service: {}", e);
             Err(TeeServiceError::ServiceError)
         }
     }
@@ -226,7 +215,7 @@ pub mod tests {
     use teaclave_test_utils::*;
 
     pub fn run_tests() -> bool {
-        run_tests!(
+        run_async_tests!(
             api_service::tests::test_user_login,
             api_service::tests::test_user_register,
             api_service::tests::test_user_update,
diff --git a/services/execution/app/Cargo.toml b/services/execution/app/Cargo.toml
index 92e111c2..eb41af8c 100644
--- a/services/execution/app/Cargo.toml
+++ b/services/execution/app/Cargo.toml
@@ -29,7 +29,8 @@ default =[]
 libos = [
   "teaclave_execution_service_enclave/libos",
   "teaclave_config/build_config",
-  "teaclave_logger"
+  "teaclave_logger",
+  "tokio"
   ]
 
 [dependencies]
@@ -38,6 +39,7 @@ anyhow      = { version = "1.0.26" }
 libc        = { version = "0.2.66" }
 log         = { version = "0.4.17", features = ["release_max_level_info"] }
 signal-hook = { version = "0.1.13" }
+tokio       = { version = "1.0", features = ["rt-multi-thread", "time", "macros"], optional = true }
 
 teaclave_config                    = { path = "../../../config" }
 teaclave_logger                    = { path = "../../../logger", optional = true }
diff --git a/services/execution/app/src/main.rs b/services/execution/app/src/main.rs
index 10d7a821..7d39ed67 100644
--- a/services/execution/app/src/main.rs
+++ b/services/execution/app/src/main.rs
@@ -28,8 +28,14 @@ fn main() {
     let config_path = "runtime.config.toml";
     let config = teaclave_config::RuntimeConfig::from_toml(config_path)
         .expect("Failed to load config file.");
-    if let Err(e) = teaclave_execution_service_enclave::start_service(&config) {
-        log::error!("app will exit, error {:?}", e);
+    let result = tokio::runtime::Builder::new_multi_thread()
+        .worker_threads(8)
+        .enable_all()
+        .build()
+        .expect("failed to create tokio runtime")
+        .block_on(teaclave_execution_service_enclave::start_service(&config));
+    if result.is_err() {
+        log::error!("app will exit, error {:?}", result);
     }
 }
 
diff --git a/services/execution/enclave/Cargo.toml b/services/execution/enclave/Cargo.toml
index 7600e53d..967ad8ca 100644
--- a/services/execution/enclave/Cargo.toml
+++ b/services/execution/enclave/Cargo.toml
@@ -48,7 +48,7 @@ libos = [
   "teaclave_crypto/app",
   "teaclave_file_agent",
   "teaclave_proto/app",
-  "teaclave_rpc/app",
+  "teaclave_rpc/libos",
   "teaclave_service_enclave_utils/libos",
   "teaclave_types/app",
   "teaclave_worker/app",
@@ -62,6 +62,7 @@ anyhow        = { version = "1.0.26" }
 serde_json    = { version = "1.0.39" }
 serde         = { version = "1.0.92", features = ["derive"] }
 thiserror     = { version = "1.0.9" }
+tokio         = { version = "1.0", features = ["rt-multi-thread", "time", "macros"] }
 gbdt          = { version = "0.1.0", features = ["input", "enable_training"] }
 uuid          = { version = "0.8.1", features = ["v4"] }
 url           = { version = "2.1.1", features = ["serde"]}
diff --git a/services/execution/enclave/src/ecall.rs b/services/execution/enclave/src/ecall.rs
index a6a68d2d..08cc14da 100644
--- a/services/execution/enclave/src/ecall.rs
+++ b/services/execution/enclave/src/ecall.rs
@@ -25,11 +25,16 @@ use teaclave_types::{TeeServiceError, TeeServiceResult};
 
 #[handle_ecall]
 fn handle_start_service(input: &StartServiceInput) -> TeeServiceResult<StartServiceOutput> {
-    match super::start_service(&input.config) {
+    let result = tokio::runtime::Builder::new_current_thread()
+        .enable_all()
+        .build()
+        .map_err(|_| TeeServiceError::SgxError)?
+        .block_on(super::start_service(&input.config));
+
+    match result {
         Ok(_) => Ok(StartServiceOutput),
-        // terminate the enclave for executor
         Err(e) => {
-            log::error!("Service shutdown, reason: {}", e);
+            log::error!("Failed to run service: {}", e);
             Err(TeeServiceError::EnclaveForceTermination)
         }
     }
diff --git a/services/execution/enclave/src/lib.rs b/services/execution/enclave/src/lib.rs
index 7f092ce5..40ef4a16 100644
--- a/services/execution/enclave/src/lib.rs
+++ b/services/execution/enclave/src/lib.rs
@@ -18,25 +18,24 @@
 #![feature(strict_provenance)]
 
 extern crate sgx_types;
-#[cfg(feature = "mesalock_sgx")]
-use std::untrusted::path::PathEx;
-
 use anyhow::{anyhow, ensure, Result};
 use log::info;
 use teaclave_attestation::{verifier, AttestationConfig, RemoteAttestation};
 use teaclave_config::build::{AS_ROOT_CA_CERT, AUDITOR_PUBLIC_KEYS};
 use teaclave_config::RuntimeConfig;
 use teaclave_service_enclave_utils::create_trusted_scheduler_endpoint;
-
 use teaclave_types::EnclaveInfo;
 
+#[cfg(feature = "mesalock_sgx")]
+use std::untrusted::path::PathEx;
+
 #[cfg(feature = "mesalock_sgx")]
 mod ecall;
 mod file_handler;
 mod service;
 mod task_file_manager;
 
-pub fn start_service(config: &RuntimeConfig) -> Result<()> {
+pub async fn start_service(config: &RuntimeConfig) -> Result<()> {
     info!("Starting Execution...");
 
     let attestation_config = AttestationConfig::from_teaclave_config(config)?;
@@ -77,9 +76,9 @@ pub fn start_service(config: &RuntimeConfig) -> Result<()> {
 
     info!(" Starting Execution: start ...");
     let mut service =
-        service::TeaclaveExecutionService::new(scheduler_service_endpoint, fusion_base)?;
+        service::TeaclaveExecutionService::new(scheduler_service_endpoint, fusion_base).await?;
 
-    service.start()
+    service.start().await
 }
 
 #[cfg(feature = "enclave_unit_test")]
diff --git a/services/execution/enclave/src/service.rs b/services/execution/enclave/src/service.rs
index 96d470a5..ace342ac 100644
--- a/services/execution/enclave/src/service.rs
+++ b/services/execution/enclave/src/service.rs
@@ -24,7 +24,7 @@ use std::thread;
 use crate::task_file_manager::TaskFileManager;
 use teaclave_proto::teaclave_common::{ExecutorCommand, ExecutorStatus};
 use teaclave_proto::teaclave_scheduler_service::*;
-use teaclave_rpc::endpoint::Endpoint;
+use teaclave_rpc::transport::{channel::Endpoint, Channel};
 use teaclave_types::*;
 use teaclave_worker::Worker;
 
@@ -37,30 +37,19 @@ static WORKER_BASE_DIR: &str = "/tmp/teaclave_agent/";
 pub(crate) struct TeaclaveExecutionService {
     #[allow(dead_code)]
     worker: Arc<Worker>,
-    scheduler_client: Arc<Mutex<TeaclaveSchedulerClient>>,
+    scheduler_client: TeaclaveSchedulerClient<Channel>,
     fusion_base: PathBuf,
     id: Uuid,
     status: ExecutorStatus,
 }
 
 impl TeaclaveExecutionService {
-    pub(crate) fn new(
+    pub(crate) async fn new(
         scheduler_service_endpoint: Endpoint,
         fusion_base: impl AsRef<Path>,
     ) -> Result<Self> {
-        let mut i = 0;
-        let channel = loop {
-            match scheduler_service_endpoint.connect() {
-                Ok(channel) => break channel,
-                Err(_) => {
-                    anyhow::ensure!(i < 10, "failed to connect to scheduler service");
-                    log::debug!("Failed to connect to scheduler service, retry {}", i);
-                    i += 1;
-                }
-            }
-            std::thread::sleep(std::time::Duration::from_secs(3));
-        };
-        let scheduler_client = Arc::new(Mutex::new(TeaclaveSchedulerClient::new(channel)?));
+        let channel = scheduler_service_endpoint.connect().await?;
+        let scheduler_client = TeaclaveSchedulerClient::new(channel);
 
         Ok(TeaclaveExecutionService {
             worker: Arc::new(Worker::default()),
@@ -71,7 +60,7 @@ impl TeaclaveExecutionService {
         })
     }
 
-    pub(crate) fn start(&mut self) -> Result<()> {
+    pub(crate) async fn start(&mut self) -> Result<()> {
         let (tx, rx) = mpsc::channel();
         let mut current_task: Arc<Option<StagedTask>> = Arc::new(None);
         let mut task_handle: Option<thread::JoinHandle<()>> = None;
@@ -79,17 +68,17 @@ impl TeaclaveExecutionService {
         loop {
             std::thread::sleep(std::time::Duration::from_secs(3));
 
-            match self.heartbeat() {
+            match self.heartbeat().await {
                 Ok(ExecutorCommand::Stop) => {
                     log::info!("Executor {} is stopped", self.id);
                     return Err(anyhow::anyhow!("EnclaveForceTermination"));
                 }
                 Ok(ExecutorCommand::NewTask) if self.status == ExecutorStatus::Idle => {
-                    match self.pull_task() {
+                    match self.pull_task().await {
                         Ok(task) => {
                             self.status = ExecutorStatus::Executing;
-                            self.update_task_status(&task.task_id, TaskStatus::Running)?;
-                            log::info!("Executor {} accepted a new task, executing...", self.id);
+                            self.update_task_status(&task.task_id, TaskStatus::Running)
+                                .await?;
                             let tx_task = tx.clone();
                             let fusion_base = self.fusion_base.clone();
                             current_task = Arc::new(Some(task));
@@ -132,6 +121,7 @@ impl TeaclaveExecutionService {
                     let task_copy = current_task.clone();
                     match self
                         .update_task_result(&task_copy.as_ref().as_ref().unwrap().task_id, result)
+                        .await
                     {
                         Ok(_) => (),
                         Err(e) => {
@@ -156,62 +146,40 @@ impl TeaclaveExecutionService {
         }
     }
 
-    fn pull_task(&mut self) -> Result<StagedTask> {
+    async fn pull_task(&mut self) -> Result<StagedTask> {
         let request = PullTaskRequest {
-            executor_id: self.id,
+            executor_id: self.id.to_string(),
         };
-        let response = self
... 12026 lines suppressed ...


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org


[incubator-teaclave] 01/04: Update rustls

Posted by hs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hsun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git

commit 1db660d35e2698c1e1a97cd21ca2264f27fad0a2
Author: GeminiCarrie <sp...@163.com>
AuthorDate: Wed May 10 04:42:13 2023 +0000

    Update rustls
---
 attestation/Cargo.toml                   |   2 +-
 cli/Cargo.toml                           |   2 +-
 cmake/tomls/Cargo.sgx_trusted_lib.lock   | 133 ++++++++++++++++++++++---------
 cmake/tomls/Cargo.sgx_trusted_lib.toml   |   1 +
 cmake/tomls/Cargo.sgx_untrusted_app.lock |  16 ++--
 cmake/tomls/Cargo.unix_app.lock          |  12 +--
 rpc/Cargo.toml                           |   2 +-
 tests/integration/enclave/Cargo.toml     |   2 +-
 8 files changed, 112 insertions(+), 58 deletions(-)

diff --git a/attestation/Cargo.toml b/attestation/Cargo.toml
index bf94baaa..972dda7b 100644
--- a/attestation/Cargo.toml
+++ b/attestation/Cargo.toml
@@ -58,7 +58,7 @@ libc             = { version = "0.2.66", optional = true }
 log              = { version = "0.4.17", features = ["release_max_level_info"] }
 num-bigint       = { version = "0.2.2" }
 percent-encoding = { version = "2.1.0" }
-rustls           = { version = "0.17.0", features = ["dangerous_configuration"] }
+rustls           = { version = "0.19.0", features = ["dangerous_configuration"] }
 serde            = { version = "1.0.92", features = ["derive"] }
 serde_json       = { version = "1.0.39" }
 thiserror        = { version = "1.0.9" }
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index cd50bc32..06728757 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -33,6 +33,6 @@ teaclave_attestation = { path = "../attestation" }
 env_logger = { version = "0.7.1" }
 webpki-roots     = { version = "0.21.0" }
 webpki     = { version = "0.21.0" }
-rustls     = { version = "0.17.0", features = ["dangerous_configuration"] }
+rustls     = { version = "0.19.0", features = ["dangerous_configuration"] }
 http       = { version = "0.2" }
 pem = "0.7.0"
diff --git a/cmake/tomls/Cargo.sgx_trusted_lib.lock b/cmake/tomls/Cargo.sgx_trusted_lib.lock
index 1e832dc0..8f4d145a 100644
--- a/cmake/tomls/Cargo.sgx_trusted_lib.lock
+++ b/cmake/tomls/Cargo.sgx_trusted_lib.lock
@@ -23,12 +23,6 @@ version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
 
-[[package]]
-name = "base64"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
-
 [[package]]
 name = "base64"
 version = "0.12.3"
@@ -324,7 +318,7 @@ dependencies = [
 [[package]]
 name = "gbdt"
 version = "0.1.1"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "cfg-if 0.1.10",
  "rand",
@@ -337,7 +331,7 @@ dependencies = [
 [[package]]
 name = "getrandom"
 version = "0.2.6"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "cfg-if 1.0.0",
  "libc",
@@ -484,7 +478,7 @@ dependencies = [
 [[package]]
 name = "image"
 version = "0.23.14"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "bytemuck",
  "byteorder",
@@ -669,13 +663,12 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
 [[package]]
 name = "mio"
 version = "0.8.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "libc",
  "log",
  "wasi 0.11.0+wasi-snapshot-preview1",
- "windows-sys 0.45.0",
+ "windows-sys 0.48.0",
 ]
 
 [[package]]
@@ -798,7 +791,7 @@ dependencies = [
 [[package]]
 name = "num_cpus"
 version = "1.14.0"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "hermit-abi",
  "libc",
@@ -958,7 +951,7 @@ dependencies = [
 [[package]]
 name = "rand"
 version = "0.8.5"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "libc",
  "rand_chacha",
@@ -968,7 +961,7 @@ dependencies = [
 [[package]]
 name = "rand_chacha"
 version = "0.3.1"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "ppv-lite86",
  "rand_core 0.6.4 (git+https://github.com/apache/incubator-teaclave-crates)",
@@ -986,7 +979,7 @@ dependencies = [
 [[package]]
 name = "rand_core"
 version = "0.6.4"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "getrandom",
 ]
@@ -1084,7 +1077,7 @@ dependencies = [
 [[package]]
 name = "ring"
 version = "0.16.20"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "cc",
  "libc",
@@ -1107,7 +1100,7 @@ dependencies = [
 [[package]]
 name = "rustface"
 version = "0.1.7"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "byteorder",
  "image",
@@ -1132,10 +1125,10 @@ dependencies = [
 
 [[package]]
 name = "rustls"
-version = "0.17.0"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+version = "0.19.1"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
- "base64 0.11.0",
+ "base64 0.13.1",
  "log",
  "ring",
  "sct",
@@ -1158,7 +1151,7 @@ dependencies = [
 [[package]]
 name = "rusty-machine"
 version = "0.5.4"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "num 0.1.42",
  "rand",
@@ -2510,13 +2503,13 @@ version = "0.42.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
 dependencies = [
- "windows_aarch64_gnullvm",
- "windows_aarch64_msvc",
- "windows_i686_gnu",
- "windows_i686_msvc",
- "windows_x86_64_gnu",
- "windows_x86_64_gnullvm",
- "windows_x86_64_msvc",
+ "windows_aarch64_gnullvm 0.42.1",
+ "windows_aarch64_msvc 0.42.1",
+ "windows_i686_gnu 0.42.1",
+ "windows_i686_msvc 0.42.1",
+ "windows_x86_64_gnu 0.42.1",
+ "windows_x86_64_gnullvm 0.42.1",
+ "windows_x86_64_msvc 0.42.1",
 ]
 
 [[package]]
@@ -2525,7 +2518,16 @@ version = "0.45.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
 dependencies = [
- "windows-targets",
+ "windows-targets 0.42.1",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
+dependencies = [
+ "windows-targets 0.48.0",
 ]
 
 [[package]]
@@ -2534,13 +2536,28 @@ version = "0.42.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
 dependencies = [
- "windows_aarch64_gnullvm",
- "windows_aarch64_msvc",
- "windows_i686_gnu",
- "windows_i686_msvc",
- "windows_x86_64_gnu",
- "windows_x86_64_gnullvm",
- "windows_x86_64_msvc",
+ "windows_aarch64_gnullvm 0.42.1",
+ "windows_aarch64_msvc 0.42.1",
+ "windows_i686_gnu 0.42.1",
+ "windows_i686_msvc 0.42.1",
+ "windows_x86_64_gnu 0.42.1",
+ "windows_x86_64_gnullvm 0.42.1",
+ "windows_x86_64_msvc 0.42.1",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
+dependencies = [
+ "windows_aarch64_gnullvm 0.48.0",
+ "windows_aarch64_msvc 0.48.0",
+ "windows_i686_gnu 0.48.0",
+ "windows_i686_msvc 0.48.0",
+ "windows_x86_64_gnu 0.48.0",
+ "windows_x86_64_gnullvm 0.48.0",
+ "windows_x86_64_msvc 0.48.0",
 ]
 
 [[package]]
@@ -2549,42 +2566,84 @@ version = "0.42.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
 
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
+
 [[package]]
 name = "windows_aarch64_msvc"
 version = "0.42.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
 
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
+
 [[package]]
 name = "windows_i686_gnu"
 version = "0.42.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
 
+[[package]]
+name = "windows_i686_gnu"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
+
 [[package]]
 name = "windows_i686_msvc"
 version = "0.42.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
 
+[[package]]
+name = "windows_i686_msvc"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
+
 [[package]]
 name = "windows_x86_64_gnu"
 version = "0.42.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
 
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
+
 [[package]]
 name = "windows_x86_64_gnullvm"
 version = "0.42.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
 
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
+
 [[package]]
 name = "windows_x86_64_msvc"
 version = "0.42.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
 
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.48.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
+
 [[package]]
 name = "winreg"
 version = "0.10.1"
diff --git a/cmake/tomls/Cargo.sgx_trusted_lib.toml b/cmake/tomls/Cargo.sgx_trusted_lib.toml
index b07e2c81..333f7c6c 100644
--- a/cmake/tomls/Cargo.sgx_trusted_lib.toml
+++ b/cmake/tomls/Cargo.sgx_trusted_lib.toml
@@ -58,6 +58,7 @@ simple_asn1       = { git = "https://github.com/acw/simple_asn1", rev = "7db7a48
 gbdt              = { git = "https://github.com/apache/incubator-teaclave-crates" }
 getrandom         = { git = "https://github.com/apache/incubator-teaclave-crates" }
 image             = { git = "https://github.com/apache/incubator-teaclave-crates" }
+mio               = { git = "https://github.com/apache/incubator-teaclave-crates" }
 num_cpus          = { git = "https://github.com/apache/incubator-teaclave-crates" }
 rand              = { git = "https://github.com/apache/incubator-teaclave-crates" }
 ring              = { git = "https://github.com/apache/incubator-teaclave-crates" }
diff --git a/cmake/tomls/Cargo.sgx_untrusted_app.lock b/cmake/tomls/Cargo.sgx_untrusted_app.lock
index a83bd377..30880024 100644
--- a/cmake/tomls/Cargo.sgx_untrusted_app.lock
+++ b/cmake/tomls/Cargo.sgx_untrusted_app.lock
@@ -52,12 +52,6 @@ version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
 
-[[package]]
-name = "base64"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
-
 [[package]]
 name = "base64"
 version = "0.13.1"
@@ -1310,7 +1304,7 @@ dependencies = [
 [[package]]
 name = "rustface"
 version = "0.1.7"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "byteorder",
  "image",
@@ -1321,11 +1315,11 @@ dependencies = [
 
 [[package]]
 name = "rustls"
-version = "0.17.0"
+version = "0.19.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1"
+checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7"
 dependencies = [
- "base64 0.11.0",
+ "base64 0.13.1",
  "log",
  "ring",
  "sct",
@@ -1335,7 +1329,7 @@ dependencies = [
 [[package]]
 name = "rusty-machine"
 version = "0.5.4"
-source = "git+https://github.com/apache/incubator-teaclave-crates#4c9325839e94bb8e280898f94c98a79cdc025312"
+source = "git+https://github.com/apache/incubator-teaclave-crates#ede1f68d891798fe6cf995e33281f01d59be9320"
 dependencies = [
  "num 0.1.42",
  "rand 0.8.5",
diff --git a/cmake/tomls/Cargo.unix_app.lock b/cmake/tomls/Cargo.unix_app.lock
index 4870b39a..389a6442 100644
--- a/cmake/tomls/Cargo.unix_app.lock
+++ b/cmake/tomls/Cargo.unix_app.lock
@@ -1412,11 +1412,11 @@ dependencies = [
 
 [[package]]
 name = "rustls"
-version = "0.17.0"
+version = "0.19.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1"
+checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7"
 dependencies = [
- "base64 0.11.0",
+ "base64 0.13.1",
  "log",
  "ring",
  "sct 0.6.1",
@@ -1860,7 +1860,7 @@ dependencies = [
  "log",
  "num-bigint",
  "percent-encoding",
- "rustls 0.17.0",
+ "rustls 0.19.1",
  "serde",
  "serde_json",
  "sgx_crypto",
@@ -1887,7 +1887,7 @@ dependencies = [
  "hex",
  "http",
  "pem",
- "rustls 0.17.0",
+ "rustls 0.19.1",
  "structopt",
  "teaclave_attestation",
  "teaclave_crypto",
@@ -1988,7 +1988,7 @@ dependencies = [
  "http",
  "libc",
  "log",
- "rustls 0.17.0",
+ "rustls 0.19.1",
  "serde",
  "serde_json",
  "sgx_libc",
diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml
index 0d92b7fb..7bb664c7 100644
--- a/rpc/Cargo.toml
+++ b/rpc/Cargo.toml
@@ -42,7 +42,7 @@ cfg-if     = { version = "0.1.9" }
 http       = { version = "0.2" }
 libc       = { version = "0.2.66", optional = true }
 log        = { version = "0.4.17", features = ["release_max_level_info"] }
-rustls     = { version = "0.17.0", features = ["dangerous_configuration"] }
+rustls     = { version = "0.19.0", features = ["dangerous_configuration"] }
 serde      = { version = "1.0.92", features = ["derive"] }
 serde_json = { version = "1.0.39" }
 thiserror  = { version = "1.0.9" }
diff --git a/tests/integration/enclave/Cargo.toml b/tests/integration/enclave/Cargo.toml
index 83aa258c..d289618f 100644
--- a/tests/integration/enclave/Cargo.toml
+++ b/tests/integration/enclave/Cargo.toml
@@ -51,7 +51,7 @@ serde       = { version = "1.0.92" }
 serde_json  = { version = "1.0.39" }
 thiserror   = { version = "1.0.9" }
 rand        = { version = "0.8.5" }
-rustls      = { version = "0.17.0", features = ["dangerous_configuration"] }
+rustls      = { version = "0.19.0", features = ["dangerous_configuration"] }
 
 rusty-leveldb = { path = "../../../common/rusty_leveldb_sgx", default-features = false, optional = true }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org


[incubator-teaclave] 04/04: Replace empty requests and responses with "google/protobuf/empty.proto"

Posted by hs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hsun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git

commit 9b664385eda976cd983918e831aee24068a5a0cd
Author: GeminiCarrie <sp...@163.com>
AuthorDate: Thu Jun 1 12:27:02 2023 +0000

    Replace empty requests and responses with "google/protobuf/empty.proto"
---
 sdk/python/teaclave.py                             | 23 +++---
 sdk/rust/src/lib.rs                                | 88 +++++++---------------
 services/authentication/enclave/src/api_service.rs | 16 ++--
 services/frontend/enclave/src/service.rs           | 25 +++---
 services/management/enclave/src/service.rs         | 41 +++++-----
 .../proto/teaclave_authentication_service.proto    | 17 ++---
 .../src/proto/teaclave_frontend_service.proto      | 26 ++-----
 .../src/proto/teaclave_management_service.proto    | 13 ++--
 .../src/proto/teaclave_scheduler_service.proto     | 14 ++--
 .../proto/src/proto/teaclave_storage_service.proto | 14 ++--
 services/proto/src/teaclave_management_service.rs  |  6 --
 services/proto/src/teaclave_scheduler_service.rs   |  5 +-
 services/proto/src/teaclave_storage_service.rs     |  9 +--
 services/scheduler/enclave/src/service.rs          | 14 ++--
 services/storage/enclave/src/proxy.rs              | 28 +++----
 services/storage/enclave/src/service.rs            | 46 ++++-------
 tests/functional/enclave/src/end_to_end/mod.rs     |  6 +-
 17 files changed, 145 insertions(+), 246 deletions(-)

diff --git a/sdk/python/teaclave.py b/sdk/python/teaclave.py
index c19d325e..43032641 100644
--- a/sdk/python/teaclave.py
+++ b/sdk/python/teaclave.py
@@ -35,6 +35,7 @@ from cryptography import x509
 from cryptography.hazmat.backends import default_backend
 
 from google.protobuf.json_format import MessageToDict
+from google.protobuf.empty_pb2 import Empty
 from grpclib.client import Channel, _ChannelState
 from grpclib.protocol import H2Protocol
 
@@ -372,7 +373,7 @@ class UserRegisterRequest(Request):
 
     def __init__(self, metadata: Metadata, user_id: str, user_password: str,
                  role: str, attribute: str):
-        super().__init__("UserRegister", auth.UserRegisterResponse, metadata)
+        super().__init__("UserRegister", Empty, metadata)
         self.message = auth.UserRegisterRequest(id=user_id,
                                                 password=user_password,
                                                 role=role,
@@ -383,7 +384,7 @@ class UserUpdateRequest(Request):
 
     def __init__(self, metadata: Metadata, user_id: str, user_password: str,
                  role: str, attribute: str):
-        super().__init__("UserUpdate", auth.UserUpdateResponse)
+        super().__init__("UserUpdate", Empty)
         self.message = auth.UserUpdateRequest(id=user_id,
                                               password=user_password,
                                               role=role,
@@ -401,8 +402,7 @@ class UserLoginRequest(Request):
 class UserChangePasswordRequest(Request):
 
     def __init__(self, metadata: Metadata, password: str):
-        super().__init__("UserChangePassword", auth.UserChangePasswordResponse,
-                         metadata)
+        super().__init__("UserChangePassword", Empty, metadata)
         self.message = auth.UserChangePasswordRequest(password=password)
 
 
@@ -417,7 +417,7 @@ class ResetUserPasswordRequest(Request):
 class DeleteUserRequest(Request):
 
     def __init__(self, metadata: Metadata, user_id: str):
-        super().__init__("DeleteUser", auth.DeleteUserResponse, metadata)
+        super().__init__("DeleteUser", Empty, metadata)
         self.message = auth.DeleteUserRequest(id=user_id)
 
 
@@ -650,15 +650,14 @@ class ListFunctionsRequest(Request):
 class DeleteFunctionRequest(Request):
 
     def __init__(self, metadata: Metadata, function_id: str):
-        super().__init__("ListFunctions", fe.DeleteFunctionResponse, metadata)
+        super().__init__("ListFunctions", Empty, metadata)
         self.message = fe.DeleteFunctionRequest(function_id=function_id)
 
 
 class DisableFunctionRequest(Request):
 
     def __init__(self, metadata: Metadata, function_id: str):
-        super().__init__("DisableFunction", fe.DisableFunctionResponse,
-                         metadata)
+        super().__init__("DisableFunction", Empty, metadata)
         self.message = fe.DisableFunctionRequest(function_id=function_id)
 
 
@@ -734,7 +733,7 @@ class AssignDataRequest(Request):
 
     def __init__(self, metadata: Metadata, task_id: str, inputs: List[DataMap],
                  outputs: List[DataMap]):
-        super().__init__("AssignData", fe.AssignDataResponse, metadata)
+        super().__init__("AssignData", Empty, metadata)
         inputs = [x.message for x in inputs]
         outputs = [x.message for x in outputs]
         self.message = fe.AssignDataRequest(task_id=task_id,
@@ -745,21 +744,21 @@ class AssignDataRequest(Request):
 class ApproveTaskRequest(Request):
 
     def __init__(self, metadata: Metadata, task_id: str):
-        super().__init__("ApproveTask", fe.ApproveTaskResponse, metadata)
+        super().__init__("ApproveTask", Empty, metadata)
         self.message = fe.ApproveTaskRequest(task_id=task_id)
 
 
 class InvokeTaskRequest(Request):
 
     def __init__(self, metadata: Metadata, task_id: str):
-        super().__init__("InvokeTask", fe.InvokeTaskResponse, metadata)
+        super().__init__("InvokeTask", Empty, metadata)
         self.message = fe.InvokeTaskRequest(task_id=task_id)
 
 
 class CancelTaskRequest(Request):
 
     def __init__(self, metadata: Metadata, task_id: str):
-        super().__init__("CancelTask", fe.CancelTaskResponse, metadata)
+        super().__init__("CancelTask", Empty, metadata)
         self.message = fe.CancelTaskRequest(task_id=task_id)
 
 
diff --git a/sdk/rust/src/lib.rs b/sdk/rust/src/lib.rs
index f015c670..d38ec933 100644
--- a/sdk/rust/src/lib.rs
+++ b/sdk/rust/src/lib.rs
@@ -28,17 +28,16 @@ use tokio::runtime::Runtime;
 use url::Url;
 
 use teaclave_proto::teaclave_authentication_service_proto::{
-    UserLoginRequest, UserLoginResponse, UserRegisterRequest, UserRegisterResponse,
+    UserLoginRequest, UserLoginResponse, UserRegisterRequest,
 };
 pub use teaclave_proto::teaclave_frontend_service::GetFunctionResponse as Function;
 pub use teaclave_proto::teaclave_frontend_service::{
-    ApproveTaskRequest, ApproveTaskResponse, AssignDataRequest, AssignDataResponse,
-    CancelTaskRequest, CancelTaskResponse, CreateTaskRequest, CreateTaskResponse,
-    GetFunctionRequest, GetFunctionResponse, GetFunctionUsageStatsRequest,
+    ApproveTaskRequest, AssignDataRequest, CancelTaskRequest, CreateTaskRequest,
+    CreateTaskResponse, GetFunctionRequest, GetFunctionResponse, GetFunctionUsageStatsRequest,
     GetFunctionUsageStatsResponse, GetTaskRequest, GetTaskResponse, InvokeTaskRequest,
-    InvokeTaskResponse, RegisterFunctionRequest, RegisterFunctionRequestBuilder,
-    RegisterFunctionResponse, RegisterInputFileRequest, RegisterInputFileResponse,
-    RegisterOutputFileRequest, RegisterOutputFileResponse,
+    RegisterFunctionRequest, RegisterFunctionRequestBuilder, RegisterFunctionResponse,
+    RegisterInputFileRequest, RegisterInputFileResponse, RegisterOutputFileRequest,
+    RegisterOutputFileResponse,
 };
 pub use teaclave_types::{
     EnclaveInfo, Executor, FileCrypto, FunctionArgument, FunctionInput, FunctionOutput,
@@ -80,19 +79,14 @@ impl AuthenticationClient {
         self.client = TeaclaveAuthenticationApiClient::with_interceptor(self.channel.clone(), cred);
     }
 
-    pub fn user_register_with_request(
-        &mut self,
-        request: UserRegisterRequest,
-    ) -> Result<UserRegisterResponse> {
+    pub fn user_register_with_request(&mut self, request: UserRegisterRequest) -> Result<()> {
         do_request_with_credential!(self, user_register, request)
     }
 
     pub fn user_register_serialized(&mut self, serialized_request: &str) -> Result<String> {
         let request = serde_json::from_str(serialized_request)?;
-        let response = self.user_register_with_request(request)?;
-        let serialized_response = serde_json::to_string(&response)?;
-
-        Ok(serialized_response)
+        self.user_register_with_request(request)?;
+        Ok(String::new())
     }
 
     pub fn user_register(
@@ -103,9 +97,7 @@ impl AuthenticationClient {
         attribute: &str,
     ) -> Result<()> {
         let request = UserRegisterRequest::new(user_id, user_password, role, attribute);
-        let _response = self.user_register_with_request(request)?;
-
-        Ok(())
+        self.user_register_with_request(request)
     }
 
     pub fn user_login_with_request(
@@ -450,19 +442,14 @@ impl FrontendClient {
         Ok(response.task_id)
     }
 
-    pub fn assign_data_with_request(
-        &mut self,
-        request: AssignDataRequest,
-    ) -> Result<AssignDataResponse> {
+    pub fn assign_data_with_request(&mut self, request: AssignDataRequest) -> Result<()> {
         do_request_with_credential!(self, assign_data, request)
     }
 
     pub fn assign_data_serialized(&mut self, serialized_request: &str) -> Result<String> {
         let request = serde_json::from_str(serialized_request)?;
-        let response = self.assign_data_with_request(request)?;
-        let serialized_response = serde_json::to_string(&response)?;
-
-        Ok(serialized_response)
+        self.assign_data_with_request(request)?;
+        Ok(String::new())
     }
 
     pub fn assign_data(
@@ -485,53 +472,37 @@ impl FrontendClient {
             }
         }
         let request = AssignDataRequest::new(task_id.try_into()?, input_data, output_data);
-        let _ = self.assign_data_with_request(request)?;
-
-        Ok(())
+        self.assign_data_with_request(request)
     }
 
-    pub fn approve_task_with_request(
-        &mut self,
-        request: ApproveTaskRequest,
-    ) -> Result<ApproveTaskResponse> {
+    pub fn approve_task_with_request(&mut self, request: ApproveTaskRequest) -> Result<()> {
         do_request_with_credential!(self, approve_task, request)
     }
 
     pub fn approve_task(&mut self, task_id: &str) -> Result<()> {
         let request = ApproveTaskRequest::new(task_id.try_into()?);
-        let _ = self.approve_task_with_request(request)?;
-
-        Ok(())
+        self.approve_task_with_request(request)
     }
 
     pub fn approve_task_serialized(&mut self, serialized_request: &str) -> Result<String> {
         let request = serde_json::from_str(serialized_request)?;
-        let response = self.approve_task_with_request(request)?;
-        let serialized_response = serde_json::to_string(&response)?;
-
-        Ok(serialized_response)
+        self.approve_task_with_request(request)?;
+        Ok(String::new())
     }
 
-    pub fn invoke_task_with_request(
-        &mut self,
-        request: InvokeTaskRequest,
-    ) -> Result<InvokeTaskResponse> {
+    pub fn invoke_task_with_request(&mut self, request: InvokeTaskRequest) -> Result<()> {
         do_request_with_credential!(self, invoke_task, request)
     }
 
     pub fn invoke_task_serialized(&mut self, serialized_request: &str) -> Result<String> {
         let request = serde_json::from_str(serialized_request)?;
-        let response = self.invoke_task_with_request(request)?;
-        let serialized_response = serde_json::to_string(&response)?;
-
-        Ok(serialized_response)
+        self.invoke_task_with_request(request)?;
+        Ok(String::new())
     }
 
     pub fn invoke_task(&mut self, task_id: &str) -> Result<()> {
         let request = InvokeTaskRequest::new(task_id.try_into()?);
-        let _ = self.invoke_task_with_request(request)?;
-
-        Ok(())
+        self.invoke_task_with_request(request)
     }
 
     pub fn get_task_with_request(&mut self, request: GetTaskRequest) -> Result<GetTaskResponse> {
@@ -565,26 +536,19 @@ impl FrontendClient {
         }
     }
 
-    pub fn cancel_task_with_request(
-        &mut self,
-        request: CancelTaskRequest,
-    ) -> Result<CancelTaskResponse> {
+    pub fn cancel_task_with_request(&mut self, request: CancelTaskRequest) -> Result<()> {
         do_request_with_credential!(self, cancel_task, request)
     }
 
     pub fn cancel_task_serialized(&mut self, serialized_request: &str) -> Result<String> {
         let request = serde_json::from_str(serialized_request)?;
-        let response = self.cancel_task_with_request(request)?;
-        let serialized_response = serde_json::to_string(&response)?;
-
-        Ok(serialized_response)
+        self.cancel_task_with_request(request)?;
+        Ok(String::new())
     }
 
     pub fn cancel_task(&mut self, task_id: &str) -> Result<()> {
         let request = CancelTaskRequest::new(task_id.try_into()?);
-        let _ = self.cancel_task_with_request(request)?;
-
-        Ok(())
+        self.cancel_task_with_request(request)
     }
 }
 
diff --git a/services/authentication/enclave/src/api_service.rs b/services/authentication/enclave/src/api_service.rs
index 7fccd04a..875dcd27 100644
--- a/services/authentication/enclave/src/api_service.rs
+++ b/services/authentication/enclave/src/api_service.rs
@@ -88,7 +88,7 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
     async fn user_register(
         &self,
         request: Request<UserRegisterRequest>,
-    ) -> TeaclaveServiceResponseResult<UserRegisterResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let requester_role = self.validate_credential_in_request(&request)?;
 
         let request = request.get_ref();
@@ -112,7 +112,7 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
 
         let new_user = UserInfo::new(&request.id, &request.password, role);
         match self.db_client.lock().unwrap().create_user(&new_user) {
-            Ok(_) => Ok(Response::new(UserRegisterResponse {})),
+            Ok(_) => Ok(Response::new(())),
             Err(e) => bail!(AuthenticationServiceError::Service(e.into())),
         }
     }
@@ -120,7 +120,7 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
     async fn user_update(
         &self,
         request: Request<UserUpdateRequest>,
-    ) -> TeaclaveServiceResponseResult<UserUpdateResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let requester_role = self.validate_credential_in_request(&request)?;
 
         let request = request.get_ref();
@@ -150,7 +150,7 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
 
         let updated_user = UserInfo::new(&request.id, &request.password, role);
         match self.db_client.lock().unwrap().update_user(&updated_user) {
-            Ok(_) => Ok(Response::new(UserUpdateResponse {})),
+            Ok(_) => Ok(Response::new(())),
             Err(e) => bail!(AuthenticationServiceError::Service(e.into())),
         }
     }
@@ -188,7 +188,7 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
     async fn user_change_password(
         &self,
         request: Request<UserChangePasswordRequest>,
-    ) -> TeaclaveServiceResponseResult<UserChangePasswordResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let requester_role = self.validate_credential_in_request(&request)?;
 
         let id: String = request
@@ -205,7 +205,7 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
         let updated_user = UserInfo::new(&id, &request.password, requester_role);
 
         match self.db_client.lock().unwrap().update_user(&updated_user) {
-            Ok(_) => Ok(Response::new(UserChangePasswordResponse {})),
+            Ok(_) => Ok(Response::new(())),
             Err(e) => bail!(AuthenticationServiceError::Service(e.into())),
         }
     }
@@ -249,7 +249,7 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
     async fn delete_user(
         &self,
         request: Request<DeleteUserRequest>,
-    ) -> TeaclaveServiceResponseResult<DeleteUserResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let requester_role = self.validate_credential_in_request(&request)?;
 
         let request = request.get_ref();
@@ -269,7 +269,7 @@ impl TeaclaveAuthenticationApi for TeaclaveAuthenticationApiService {
             AuthenticationServiceError::PermissionDenied
         );
         match self.db_client.lock().unwrap().delete_user(&request.id) {
-            Ok(_) => Ok(Response::new(DeleteUserResponse {})),
+            Ok(_) => Ok(Response::new(())),
             Err(e) => bail!(AuthenticationServiceError::Service(e.into())),
         }
     }
diff --git a/services/frontend/enclave/src/service.rs b/services/frontend/enclave/src/service.rs
index d2ac9b21..31a2d317 100644
--- a/services/frontend/enclave/src/service.rs
+++ b/services/frontend/enclave/src/service.rs
@@ -25,13 +25,12 @@ use teaclave_proto::teaclave_authentication_service::{
 };
 use teaclave_proto::teaclave_common::UserCredential;
 use teaclave_proto::teaclave_frontend_service::{
-    ApproveTaskRequest, ApproveTaskResponse, AssignDataRequest, AssignDataResponse,
-    CancelTaskRequest, CancelTaskResponse, CreateTaskRequest, CreateTaskResponse,
-    DeleteFunctionRequest, DeleteFunctionResponse, DisableFunctionRequest, DisableFunctionResponse,
-    GetFunctionRequest, GetFunctionResponse, GetFunctionUsageStatsRequest,
-    GetFunctionUsageStatsResponse, GetInputFileRequest, GetInputFileResponse, GetOutputFileRequest,
-    GetOutputFileResponse, GetTaskRequest, GetTaskResponse, InvokeTaskRequest, InvokeTaskResponse,
-    ListFunctionsRequest, ListFunctionsResponse, RegisterFunctionRequest, RegisterFunctionResponse,
+    ApproveTaskRequest, AssignDataRequest, CancelTaskRequest, CreateTaskRequest,
+    CreateTaskResponse, DeleteFunctionRequest, DisableFunctionRequest, GetFunctionRequest,
+    GetFunctionResponse, GetFunctionUsageStatsRequest, GetFunctionUsageStatsResponse,
+    GetInputFileRequest, GetInputFileResponse, GetOutputFileRequest, GetOutputFileResponse,
+    GetTaskRequest, GetTaskResponse, InvokeTaskRequest, ListFunctionsRequest,
+    ListFunctionsResponse, RegisterFunctionRequest, RegisterFunctionResponse,
     RegisterFusionOutputRequest, RegisterFusionOutputResponse, RegisterInputFileRequest,
     RegisterInputFileResponse, RegisterInputFromOutputRequest, RegisterInputFromOutputResponse,
     RegisterOutputFileRequest, RegisterOutputFileResponse, TeaclaveFrontend, UpdateFunctionRequest,
@@ -327,7 +326,7 @@ impl TeaclaveFrontend for TeaclaveFrontendService {
     async fn delete_function(
         &self,
         request: Request<DeleteFunctionRequest>,
-    ) -> TeaclaveServiceResponseResult<DeleteFunctionResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         authentication_and_forward_to_management!(
             self,
             request,
@@ -339,7 +338,7 @@ impl TeaclaveFrontend for TeaclaveFrontendService {
     async fn disable_function(
         &self,
         request: Request<DisableFunctionRequest>,
-    ) -> TeaclaveServiceResponseResult<DisableFunctionResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         authentication_and_forward_to_management!(
             self,
             request,
@@ -377,14 +376,14 @@ impl TeaclaveFrontend for TeaclaveFrontendService {
     async fn assign_data(
         &self,
         request: Request<AssignDataRequest>,
-    ) -> TeaclaveServiceResponseResult<AssignDataResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         authentication_and_forward_to_management!(self, request, assign_data, Endpoints::AssignData)
     }
 
     async fn approve_task(
         &self,
         request: Request<ApproveTaskRequest>,
-    ) -> TeaclaveServiceResponseResult<ApproveTaskResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         authentication_and_forward_to_management!(
             self,
             request,
@@ -396,14 +395,14 @@ impl TeaclaveFrontend for TeaclaveFrontendService {
     async fn invoke_task(
         &self,
         request: Request<InvokeTaskRequest>,
-    ) -> TeaclaveServiceResponseResult<InvokeTaskResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         authentication_and_forward_to_management!(self, request, invoke_task, Endpoints::InvokeTask)
     }
 
     async fn cancel_task(
         &self,
         request: Request<CancelTaskRequest>,
-    ) -> TeaclaveServiceResponseResult<CancelTaskResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         authentication_and_forward_to_management!(self, request, cancel_task, Endpoints::CancelTask)
     }
 }
diff --git a/services/management/enclave/src/service.rs b/services/management/enclave/src/service.rs
index 0abbd12e..5f666d67 100644
--- a/services/management/enclave/src/service.rs
+++ b/services/management/enclave/src/service.rs
@@ -24,13 +24,12 @@ use teaclave_proto::teaclave_frontend_service::{
     from_proto_file_ids, from_proto_ownership, to_proto_file_ids, to_proto_ownership,
 };
 use teaclave_proto::teaclave_frontend_service::{
-    ApproveTaskRequest, ApproveTaskResponse, AssignDataRequest, AssignDataResponse,
-    CancelTaskRequest, CancelTaskResponse, CreateTaskRequest, CreateTaskResponse,
-    DeleteFunctionRequest, DeleteFunctionResponse, DisableFunctionRequest, DisableFunctionResponse,
-    GetFunctionRequest, GetFunctionResponse, GetFunctionUsageStatsRequest,
-    GetFunctionUsageStatsResponse, GetInputFileRequest, GetInputFileResponse, GetOutputFileRequest,
-    GetOutputFileResponse, GetTaskRequest, GetTaskResponse, InvokeTaskRequest, InvokeTaskResponse,
-    ListFunctionsRequest, ListFunctionsResponse, RegisterFunctionRequest, RegisterFunctionResponse,
+    ApproveTaskRequest, AssignDataRequest, CancelTaskRequest, CreateTaskRequest,
+    CreateTaskResponse, DeleteFunctionRequest, DisableFunctionRequest, GetFunctionRequest,
+    GetFunctionResponse, GetFunctionUsageStatsRequest, GetFunctionUsageStatsResponse,
+    GetInputFileRequest, GetInputFileResponse, GetOutputFileRequest, GetOutputFileResponse,
+    GetTaskRequest, GetTaskResponse, InvokeTaskRequest, ListFunctionsRequest,
+    ListFunctionsResponse, RegisterFunctionRequest, RegisterFunctionResponse,
     RegisterFusionOutputRequest, RegisterFusionOutputResponse, RegisterInputFileRequest,
     RegisterInputFileResponse, RegisterInputFromOutputRequest, RegisterInputFromOutputResponse,
     RegisterOutputFileRequest, RegisterOutputFileResponse, UpdateFunctionRequest,
@@ -452,7 +451,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
     async fn delete_function(
         &self,
         request: Request<DeleteFunctionRequest>,
-    ) -> TeaclaveServiceResponseResult<DeleteFunctionResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let user_id = get_request_user_id(&request)?;
         let function_id = request
             .into_inner()
@@ -471,8 +470,8 @@ impl TeaclaveManagement for TeaclaveManagementService {
         self.delete_from_db(&function_id)
             .await
             .map_err(|_| ManagementServiceError::InvalidFunctionId)?;
-        let response = DeleteFunctionResponse {};
-        Ok(Response::new(response))
+
+        Ok(Response::new(()))
     }
 
     // access control: function.owner == user_id
@@ -482,7 +481,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
     async fn disable_function(
         &self,
         request: Request<DisableFunctionRequest>,
-    ) -> TeaclaveServiceResponseResult<DisableFunctionResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let user_id = get_request_user_id(&request)?;
         let role = get_request_role(&request)?;
         let function_id = request
@@ -537,8 +536,8 @@ impl TeaclaveManagement for TeaclaveManagementService {
 
         function.user_allowlist.clear();
         self.write_to_db(&function).await?;
-        let response = DisableFunctionResponse {};
-        Ok(Response::new(response))
+
+        Ok(Response::new(()))
     }
 
     // access contro: user_id = request.user_id
@@ -699,7 +698,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
     async fn assign_data(
         &self,
         request: Request<AssignDataRequest>,
-    ) -> TeaclaveServiceResponseResult<AssignDataResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let user_id = get_request_user_id(&request)?;
         let request = request.into_inner();
         let task_id = request
@@ -745,7 +744,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
         let ts: TaskState = task.into();
         self.write_to_db(&ts).await?;
 
-        Ok(Response::new(AssignDataResponse {}))
+        Ok(Response::new(()))
     }
 
     // access_control:
@@ -754,7 +753,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
     async fn approve_task(
         &self,
         request: Request<ApproveTaskRequest>,
-    ) -> TeaclaveServiceResponseResult<ApproveTaskResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let user_id = get_request_user_id(&request)?;
 
         let task_id = request
@@ -781,7 +780,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
         let ts: TaskState = task.into();
         self.write_to_db(&ts).await?;
 
-        Ok(Response::new(ApproveTaskResponse {}))
+        Ok(Response::new(()))
     }
 
     // access_control:
@@ -790,7 +789,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
     async fn invoke_task(
         &self,
         request: Request<InvokeTaskRequest>,
-    ) -> TeaclaveServiceResponseResult<InvokeTaskResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let user_id = get_request_user_id(&request)?;
         let task_id = request
             .into_inner()
@@ -851,7 +850,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
 
         function_usage.use_numbers = function_current_use_numbers + 1;
         self.write_to_db(&function_usage).await?;
-        Ok(Response::new(InvokeTaskResponse {}))
+        Ok(Response::new(()))
     }
 
     // access_control:
@@ -860,7 +859,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
     async fn cancel_task(
         &self,
         request: Request<CancelTaskRequest>,
-    ) -> TeaclaveServiceResponseResult<CancelTaskResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let user_id = get_request_user_id(&request)?;
         let role = get_request_role(&request)?;
         let task_id = request
@@ -913,7 +912,7 @@ impl TeaclaveManagement for TeaclaveManagementService {
             }
         }
 
-        Ok(Response::new(CancelTaskResponse {}))
+        Ok(Response::new(()))
     }
 }
 
diff --git a/services/proto/src/proto/teaclave_authentication_service.proto b/services/proto/src/proto/teaclave_authentication_service.proto
index 77e42ed0..bdac5f79 100644
--- a/services/proto/src/proto/teaclave_authentication_service.proto
+++ b/services/proto/src/proto/teaclave_authentication_service.proto
@@ -22,6 +22,7 @@ syntax = "proto3";
 package teaclave_authentication_service_proto;
 
 import "teaclave_common.proto";
+import "google/protobuf/empty.proto";
 
 message UserRegisterRequest {
   string id = 1;
@@ -30,8 +31,6 @@ message UserRegisterRequest {
   string attribute = 4;
 }
 
-message UserRegisterResponse { }
-
 message UserUpdateRequest {
     string id = 1;
     string password = 2;
@@ -39,8 +38,6 @@ message UserUpdateRequest {
     string attribute = 4;
 }
 
-message UserUpdateResponse { }
-
 message UserLoginRequest {
   string id = 1;
   string password = 2;
@@ -85,21 +82,17 @@ message UserChangePasswordRequest {
   string password = 1;
 }
 
-message UserChangePasswordResponse {}
-
 message DeleteUserRequest {
   string id = 1;
 }
 
-message DeleteUserResponse {}
-
 service TeaclaveAuthenticationApi {
-  rpc UserRegister(UserRegisterRequest) returns (UserRegisterResponse);
-  rpc UserUpdate(UserUpdateRequest) returns (UserUpdateResponse);
+  rpc UserRegister(UserRegisterRequest) returns (google.protobuf.Empty);
+  rpc UserUpdate(UserUpdateRequest) returns (google.protobuf.Empty);
   rpc UserLogin (UserLoginRequest) returns (UserLoginResponse);
-  rpc UserChangePassword (UserChangePasswordRequest) returns (UserChangePasswordResponse);
+  rpc UserChangePassword (UserChangePasswordRequest) returns (google.protobuf.Empty);
   rpc ResetUserPassword (ResetUserPasswordRequest) returns (ResetUserPasswordResponse);
-  rpc DeleteUser (DeleteUserRequest) returns (DeleteUserResponse);
+  rpc DeleteUser (DeleteUserRequest) returns (google.protobuf.Empty);
   rpc ListUsers(ListUsersRequest) returns (ListUsersResponse);
 }
 
diff --git a/services/proto/src/proto/teaclave_frontend_service.proto b/services/proto/src/proto/teaclave_frontend_service.proto
index 07c23987..2a94a3a0 100644
--- a/services/proto/src/proto/teaclave_frontend_service.proto
+++ b/services/proto/src/proto/teaclave_frontend_service.proto
@@ -23,6 +23,7 @@ syntax = "proto3";
 package teaclave_frontend_service_proto;
 
 import "teaclave_common.proto";
+import "google/protobuf/empty.proto";
 
 message RegisterInputFileRequest {
   string url = 1;
@@ -183,15 +184,10 @@ message DeleteFunctionRequest {
   string function_id = 1;
 }
 
-message DeleteFunctionResponse { }
-
 message DisableFunctionRequest {
   string function_id = 1;
 }
 
-message DisableFunctionResponse { }
-
-
 message ListFunctionsRequest {
   string user_id = 1;
 }
@@ -244,26 +240,18 @@ message AssignDataRequest {
   repeated DataMap outputs = 3;
 }
 
-message AssignDataResponse { }
-
 message ApproveTaskRequest {
   string task_id = 1;
 }
 
-message ApproveTaskResponse { }
-
 message InvokeTaskRequest {
   string task_id = 1;
 }
 
-message InvokeTaskResponse { }
-
 message CancelTaskRequest {
   string task_id = 1;
 }
 
-message CancelTaskResponse { }
-
 service TeaclaveFrontend {
   rpc RegisterInputFile (RegisterInputFileRequest) returns (RegisterInputFileResponse);
   rpc RegisterOutputFile (RegisterOutputFileRequest) returns (RegisterOutputFileResponse);
@@ -278,12 +266,12 @@ service TeaclaveFrontend {
   rpc GetFunctionUsageStats (GetFunctionUsageStatsRequest) returns (GetFunctionUsageStatsResponse);
   rpc UpdateFunction (UpdateFunctionRequest) returns (UpdateFunctionResponse);
   rpc ListFunctions (ListFunctionsRequest) returns (ListFunctionsResponse);
-  rpc DeleteFunction (DeleteFunctionRequest) returns (DeleteFunctionResponse);
-  rpc DisableFunction (DisableFunctionRequest) returns (DisableFunctionResponse);
+  rpc DeleteFunction (DeleteFunctionRequest) returns (google.protobuf.Empty);
+  rpc DisableFunction (DisableFunctionRequest) returns (google.protobuf.Empty);
   rpc CreateTask (CreateTaskRequest) returns (CreateTaskResponse);
   rpc GetTask (GetTaskRequest) returns (GetTaskResponse);
-  rpc AssignData (AssignDataRequest) returns (AssignDataResponse);
-  rpc ApproveTask (ApproveTaskRequest) returns (ApproveTaskResponse);
-  rpc InvokeTask (InvokeTaskRequest) returns (InvokeTaskResponse);
-  rpc CancelTask (CancelTaskRequest) returns (CancelTaskResponse);
+  rpc AssignData (AssignDataRequest) returns (google.protobuf.Empty);
+  rpc ApproveTask (ApproveTaskRequest) returns (google.protobuf.Empty);
+  rpc InvokeTask (InvokeTaskRequest) returns (google.protobuf.Empty);
+  rpc CancelTask (CancelTaskRequest) returns (google.protobuf.Empty);
 }
diff --git a/services/proto/src/proto/teaclave_management_service.proto b/services/proto/src/proto/teaclave_management_service.proto
index 7d9639ab..21285c53 100644
--- a/services/proto/src/proto/teaclave_management_service.proto
+++ b/services/proto/src/proto/teaclave_management_service.proto
@@ -23,6 +23,7 @@ syntax = "proto3";
 package teaclave_management_service_proto;
 
 import "teaclave_frontend_service.proto";
+import "google/protobuf/empty.proto";
 
 service TeaclaveManagement {
   rpc RegisterInputFile (teaclave_frontend_service_proto.RegisterInputFileRequest) returns (teaclave_frontend_service_proto.RegisterInputFileResponse);
@@ -37,13 +38,13 @@ service TeaclaveManagement {
   rpc UpdateFunction (teaclave_frontend_service_proto.UpdateFunctionRequest) returns (teaclave_frontend_service_proto.UpdateFunctionResponse);
   rpc GetFunction (teaclave_frontend_service_proto.GetFunctionRequest) returns (teaclave_frontend_service_proto.GetFunctionResponse);
   rpc GetFunctionUsageStats (teaclave_frontend_service_proto.GetFunctionUsageStatsRequest) returns (teaclave_frontend_service_proto.GetFunctionUsageStatsResponse);
-  rpc DeleteFunction (teaclave_frontend_service_proto.DeleteFunctionRequest) returns (teaclave_frontend_service_proto.DeleteFunctionResponse);
-  rpc DisableFunction (teaclave_frontend_service_proto.DisableFunctionRequest) returns (teaclave_frontend_service_proto.DisableFunctionResponse);
+  rpc DeleteFunction (teaclave_frontend_service_proto.DeleteFunctionRequest) returns (google.protobuf.Empty);
+  rpc DisableFunction (teaclave_frontend_service_proto.DisableFunctionRequest) returns (google.protobuf.Empty);
   rpc ListFunctions (teaclave_frontend_service_proto.ListFunctionsRequest) returns (teaclave_frontend_service_proto.ListFunctionsResponse);
   rpc CreateTask (teaclave_frontend_service_proto.CreateTaskRequest) returns (teaclave_frontend_service_proto.CreateTaskResponse);
   rpc GetTask (teaclave_frontend_service_proto.GetTaskRequest) returns (teaclave_frontend_service_proto.GetTaskResponse);
-  rpc AssignData (teaclave_frontend_service_proto.AssignDataRequest) returns (teaclave_frontend_service_proto.AssignDataResponse);
-  rpc ApproveTask (teaclave_frontend_service_proto.ApproveTaskRequest) returns (teaclave_frontend_service_proto.ApproveTaskResponse);
-  rpc InvokeTask (teaclave_frontend_service_proto.InvokeTaskRequest) returns (teaclave_frontend_service_proto.InvokeTaskResponse);
-  rpc CancelTask (teaclave_frontend_service_proto.CancelTaskRequest) returns (teaclave_frontend_service_proto.CancelTaskResponse);
+  rpc AssignData (teaclave_frontend_service_proto.AssignDataRequest) returns (google.protobuf.Empty);
+  rpc ApproveTask (teaclave_frontend_service_proto.ApproveTaskRequest) returns (google.protobuf.Empty);
+  rpc InvokeTask (teaclave_frontend_service_proto.InvokeTaskRequest) returns (google.protobuf.Empty);
+  rpc CancelTask (teaclave_frontend_service_proto.CancelTaskRequest) returns (google.protobuf.Empty);
 }
diff --git a/services/proto/src/proto/teaclave_scheduler_service.proto b/services/proto/src/proto/teaclave_scheduler_service.proto
index 9f9f3ad1..35711c03 100644
--- a/services/proto/src/proto/teaclave_scheduler_service.proto
+++ b/services/proto/src/proto/teaclave_scheduler_service.proto
@@ -22,8 +22,8 @@ syntax = "proto3";
 package teaclave_scheduler_service_proto;
 
 import "teaclave_common.proto";
+import "google/protobuf/empty.proto";
 
-message SubscribeRequest {}
 message SubscribeResponse {
   bool success = 1;
 }
@@ -47,29 +47,27 @@ message UpdateTaskStatusRequest {
   string task_id = 1;
   teaclave_common_proto.TaskStatus task_status = 2;
 }
-message UpdateTaskStatusResponse {}
 
 message UpdateTaskResultRequest {
   string task_id = 1;
   teaclave_common_proto.TaskResult result = 2;
 }
-message UpdateTaskResultResponse {}
+
 
 message PublishTaskRequest {
   bytes staged_task = 1;
 }
-message PublishTaskResponse {}
 
 service TeaclaveScheduler {
   // Publisher
-  rpc PublishTask(PublishTaskRequest) returns (PublishTaskResponse);
+  rpc PublishTask(PublishTaskRequest) returns (google.protobuf.Empty);
 
   // Subscriber
-  rpc Subscribe(SubscribeRequest) returns (SubscribeResponse);
+  rpc Subscribe(google.protobuf.Empty) returns (SubscribeResponse);
   rpc PullTask(PullTaskRequest) returns (PullTaskResponse);
 
-  rpc UpdateTaskStatus(UpdateTaskStatusRequest) returns (UpdateTaskStatusResponse);
-  rpc UpdateTaskResult(UpdateTaskResultRequest) returns (UpdateTaskResultResponse);
+  rpc UpdateTaskStatus(UpdateTaskStatusRequest) returns (google.protobuf.Empty);
+  rpc UpdateTaskResult(UpdateTaskResultRequest) returns (google.protobuf.Empty);
 
   rpc Heartbeat(HeartbeatRequest) returns (HeartbeatResponse);
 }
diff --git a/services/proto/src/proto/teaclave_storage_service.proto b/services/proto/src/proto/teaclave_storage_service.proto
index 0e78952b..5b2a58d4 100644
--- a/services/proto/src/proto/teaclave_storage_service.proto
+++ b/services/proto/src/proto/teaclave_storage_service.proto
@@ -21,6 +21,8 @@
 syntax = "proto3";
 package teaclave_storage_service_proto;
 
+import "google/protobuf/empty.proto";
+
 message GetRequest {
   bytes key = 1;
 }
@@ -34,21 +36,15 @@ message PutRequest {
   bytes value = 2;
 }
 
-message PutResponse { }
-
 message DeleteRequest {
   bytes key = 1;
 }
 
-message DeleteResponse { }
-
 message EnqueueRequest {
   bytes key = 1;
   bytes value = 2;
 }
 
-message EnqueueResponse { }
-
 message DequeueRequest {
   bytes key = 1;
 }
@@ -67,9 +63,9 @@ message GetKeysByPrefixResponse {
 
 service TeaclaveStorage {
   rpc Get(GetRequest) returns (GetResponse);
-  rpc Put(PutRequest) returns (PutResponse);
-  rpc Delete(DeleteRequest) returns (DeleteResponse);
-  rpc Enqueue(EnqueueRequest) returns (EnqueueResponse);
+  rpc Put(PutRequest) returns (google.protobuf.Empty);
+  rpc Delete(DeleteRequest) returns (google.protobuf.Empty);
+  rpc Enqueue(EnqueueRequest) returns (google.protobuf.Empty);
   rpc Dequeue(DequeueRequest) returns (DequeueResponse);
   rpc GetKeysByPrefix(GetKeysByPrefixRequest) returns (GetKeysByPrefixResponse);
 }
diff --git a/services/proto/src/teaclave_management_service.rs b/services/proto/src/teaclave_management_service.rs
index 2339e401..4d178dcd 100644
--- a/services/proto/src/teaclave_management_service.rs
+++ b/services/proto/src/teaclave_management_service.rs
@@ -54,9 +54,7 @@ pub type GetFunctionUsageStatsRequest =
 pub type GetFunctionUsageStatsResponse =
     crate::teaclave_frontend_service::GetFunctionUsageStatsResponse;
 pub type DeleteFunctionRequest = crate::teaclave_frontend_service::DeleteFunctionRequest;
-pub type DeleteFunctionResponse = crate::teaclave_frontend_service::DeleteFunctionResponse;
 pub type DisableFunctionRequest = crate::teaclave_frontend_service::DisableFunctionRequest;
-pub type DisableFunctionResponse = crate::teaclave_frontend_service::DisableFunctionResponse;
 pub type GetFunctionRequest = crate::teaclave_frontend_service::GetFunctionRequest;
 pub type GetFunctionResponse = crate::teaclave_frontend_service::GetFunctionResponse;
 pub type ListFunctionsRequest = crate::teaclave_frontend_service::ListFunctionsRequest;
@@ -66,10 +64,6 @@ pub type CreateTaskResponse = crate::teaclave_frontend_service::CreateTaskRespon
 pub type GetTaskRequest = crate::teaclave_frontend_service::GetTaskRequest;
 pub type GetTaskResponse = crate::teaclave_frontend_service::GetTaskResponse;
 pub type AssignDataRequest = crate::teaclave_frontend_service::AssignDataRequest;
-pub type AssignDataResponse = crate::teaclave_frontend_service::AssignDataResponse;
 pub type ApproveTaskRequest = crate::teaclave_frontend_service::ApproveTaskRequest;
-pub type ApproveTaskResponse = crate::teaclave_frontend_service::ApproveTaskResponse;
 pub type InvokeTaskRequest = crate::teaclave_frontend_service::InvokeTaskRequest;
-pub type InvokeTaskResponse = crate::teaclave_frontend_service::InvokeTaskResponse;
 pub type CancelTaskRequest = crate::teaclave_frontend_service::CancelTaskRequest;
-pub type CancelTaskResponse = crate::teaclave_frontend_service::CancelTaskResponse;
diff --git a/services/proto/src/teaclave_scheduler_service.rs b/services/proto/src/teaclave_scheduler_service.rs
index abaca663..a8c43396 100644
--- a/services/proto/src/teaclave_scheduler_service.rs
+++ b/services/proto/src/teaclave_scheduler_service.rs
@@ -25,10 +25,7 @@ pub use proto::{
     HeartbeatRequest, PublishTaskRequest, PullTaskRequest, UpdateTaskResultRequest,
     UpdateTaskStatusRequest,
 };
-pub use proto::{
-    HeartbeatResponse, PublishTaskResponse, PullTaskResponse, SubscribeRequest, SubscribeResponse,
-    UpdateTaskResultResponse, UpdateTaskStatusResponse,
-};
+pub use proto::{HeartbeatResponse, PullTaskResponse, SubscribeResponse};
 use teaclave_types::Storable;
 use teaclave_types::{StagedTask, TaskFailure, TaskOutputs, TaskResult, TaskStatus};
 use uuid::Uuid;
diff --git a/services/proto/src/teaclave_storage_service.rs b/services/proto/src/teaclave_storage_service.rs
index d65f6c58..817b85cf 100644
--- a/services/proto/src/teaclave_storage_service.rs
+++ b/services/proto/src/teaclave_storage_service.rs
@@ -20,9 +20,8 @@ pub use proto::teaclave_storage_client::TeaclaveStorageClient;
 pub use proto::teaclave_storage_server::TeaclaveStorage;
 pub use proto::teaclave_storage_server::TeaclaveStorageServer;
 pub use proto::{
-    DeleteRequest, DeleteResponse, DequeueRequest, DequeueResponse, EnqueueRequest,
-    EnqueueResponse, GetKeysByPrefixRequest, GetKeysByPrefixResponse, GetRequest, GetResponse,
-    PutRequest, PutResponse,
+    DeleteRequest, DequeueRequest, DequeueResponse, EnqueueRequest, GetKeysByPrefixRequest,
+    GetKeysByPrefixResponse, GetRequest, GetResponse, PutRequest,
 };
 
 impl GetRequest {
@@ -107,9 +106,7 @@ pub enum TeaclaveStorageRequest {
 #[serde(tag = "response", content = "content", rename_all = "snake_case")]
 pub enum TeaclaveStorageResponse {
     Get(GetResponse),
-    Put(PutResponse),
-    Delete(DeleteResponse),
-    Enqueue(EnqueueResponse),
     Dequeue(DequeueResponse),
     GetKeysByPrefix(GetKeysByPrefixResponse),
+    Empty(()),
 }
diff --git a/services/scheduler/enclave/src/service.rs b/services/scheduler/enclave/src/service.rs
index e3be03bd..07aa7b10 100644
--- a/services/scheduler/enclave/src/service.rs
+++ b/services/scheduler/enclave/src/service.rs
@@ -241,7 +241,7 @@ impl TeaclaveScheduler for TeaclaveSchedulerService {
     async fn publish_task(
         &self,
         request: Request<PublishTaskRequest>,
-    ) -> TeaclaveServiceResponseResult<PublishTaskResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         // XXX: Publisher is not implemented
 
         let mut resources = self.resources.lock().await;
@@ -249,13 +249,13 @@ impl TeaclaveScheduler for TeaclaveSchedulerService {
         let staged_task =
             StagedTask::from_slice(&request.get_ref().staged_task).map_err(tonic_error)?;
         resources.task_queue.push_back(staged_task);
-        Ok(Response::new(PublishTaskResponse {}))
+        Ok(Response::new(()))
     }
 
     // Subscriber
     async fn subscribe(
         &self,
-        _request: Request<SubscribeRequest>,
+        _request: Request<()>,
     ) -> TeaclaveServiceResponseResult<SubscribeResponse> {
         // TODO: subscribe a specific topic
         unimplemented!()
@@ -336,7 +336,7 @@ impl TeaclaveScheduler for TeaclaveSchedulerService {
     async fn update_task_status(
         &self,
         request: Request<UpdateTaskStatusRequest>,
-    ) -> TeaclaveServiceResponseResult<UpdateTaskStatusResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let resources = self.resources.lock().await;
 
         let task_id = Uuid::parse_str(&request.get_ref().task_id).map_err(tonic_error)?;
@@ -351,13 +351,13 @@ impl TeaclaveScheduler for TeaclaveSchedulerService {
 
         let ts = TaskState::from(task);
         resources.put_into_db(&ts).await.map_err(tonic_error)?;
-        Ok(Response::new(UpdateTaskStatusResponse {}))
+        Ok(Response::new(()))
     }
 
     async fn update_task_result(
         &self,
         request: Request<UpdateTaskResultRequest>,
-    ) -> TeaclaveServiceResponseResult<UpdateTaskResultResponse> {
+    ) -> TeaclaveServiceResponseResult<()> {
         let resources = self.resources.lock().await;
 
         let request = request.into_inner();
@@ -382,6 +382,6 @@ impl TeaclaveScheduler for TeaclaveSchedulerService {
 
         let ts = TaskState::from(task);
         resources.put_into_db(&ts).await.map_err(tonic_error)?;
-        Ok(Response::new(UpdateTaskResultResponse {}))
+        Ok(Response::new(()))
     }
 }
diff --git a/services/storage/enclave/src/proxy.rs b/services/storage/enclave/src/proxy.rs
index a2bfdfc9..f17dbe6b 100644
--- a/services/storage/enclave/src/proxy.rs
+++ b/services/storage/enclave/src/proxy.rs
@@ -33,7 +33,7 @@ impl ProxyService {
 }
 
 macro_rules! send_request {
-    ($service: ident,$request:expr,$fun:ident) => {{
+    ($service: ident,$request:expr,$fun:ident,$response:ident) => {{
         let (sender, mut receiver) = unbounded_channel();
         let request = $request.into_inner();
         $service
@@ -44,7 +44,7 @@ macro_rules! send_request {
             })
             .map_err(|_| StorageServiceError::Service(anyhow!("send ProxyRequest error")))?;
         match receiver.recv().await {
-            Some(Ok(TeaclaveStorageResponse::$fun(re))) => return Ok(Response::new(re)),
+            Some(Ok(TeaclaveStorageResponse::$response(re))) => return Ok(Response::new(re)),
             _ => return Err(teaclave_rpc::Status::internal("invalid response")),
         }
     }};
@@ -53,39 +53,33 @@ macro_rules! send_request {
 #[teaclave_rpc::async_trait]
 impl TeaclaveStorage for ProxyService {
     async fn get(&self, request: Request<GetRequest>) -> Result<Response<GetResponse>, Status> {
-        send_request!(self, request, Get)
+        send_request!(self, request, Get, Get)
     }
 
-    async fn put(&self, request: Request<PutRequest>) -> Result<Response<PutResponse>, Status> {
-        send_request!(self, request, Put)
+    async fn put(&self, request: Request<PutRequest>) -> Result<Response<()>, Status> {
+        send_request!(self, request, Put, Empty)
     }
 
-    async fn delete(
-        &self,
-        request: Request<DeleteRequest>,
-    ) -> Result<Response<DeleteResponse>, Status> {
-        send_request!(self, request, Delete)
+    async fn delete(&self, request: Request<DeleteRequest>) -> Result<Response<()>, Status> {
+        send_request!(self, request, Delete, Empty)
     }
 
-    async fn enqueue(
-        &self,
-        request: Request<EnqueueRequest>,
-    ) -> Result<Response<EnqueueResponse>, Status> {
-        send_request!(self, request, Enqueue)
+    async fn enqueue(&self, request: Request<EnqueueRequest>) -> Result<Response<()>, Status> {
+        send_request!(self, request, Enqueue, Empty)
     }
 
     async fn dequeue(
         &self,
         request: Request<DequeueRequest>,
     ) -> Result<Response<DequeueResponse>, Status> {
-        send_request!(self, request, Dequeue)
+        send_request!(self, request, Dequeue, Dequeue)
     }
 
     async fn get_keys_by_prefix(
         &self,
         request: Request<GetKeysByPrefixRequest>,
     ) -> Result<Response<GetKeysByPrefixResponse>, Status> {
-        send_request!(self, request, GetKeysByPrefix)
+        send_request!(self, request, GetKeysByPrefix, GetKeysByPrefix)
     }
 }
 
diff --git a/services/storage/enclave/src/service.rs b/services/storage/enclave/src/service.rs
index 9a98890c..7326f01f 100644
--- a/services/storage/enclave/src/service.rs
+++ b/services/storage/enclave/src/service.rs
@@ -170,30 +170,18 @@ impl TeaclaveStorageService {
         request: teaclave_rpc::Request<TeaclaveStorageRequest>,
     ) -> std::result::Result<TeaclaveStorageResponse, StorageServiceError> {
         match request.into_inner() {
-            TeaclaveStorageRequest::Get(r) => {
-                let response = self.get(r)?;
-                Ok(response).map(TeaclaveStorageResponse::Get)
-            }
-            TeaclaveStorageRequest::Put(r) => {
-                let response = self.put(r)?;
-                Ok(response).map(TeaclaveStorageResponse::Put)
-            }
-            TeaclaveStorageRequest::Delete(r) => {
-                let response = self.delete(r)?;
-                Ok(response).map(TeaclaveStorageResponse::Delete)
-            }
+            TeaclaveStorageRequest::Get(r) => self.get(r).map(TeaclaveStorageResponse::Get),
+            TeaclaveStorageRequest::Put(r) => self.put(r).map(TeaclaveStorageResponse::Empty),
+            TeaclaveStorageRequest::Delete(r) => self.delete(r).map(TeaclaveStorageResponse::Empty),
             TeaclaveStorageRequest::Enqueue(r) => {
-                let response = self.enqueue(r)?;
-                Ok(response).map(TeaclaveStorageResponse::Enqueue)
+                self.enqueue(r).map(TeaclaveStorageResponse::Empty)
             }
             TeaclaveStorageRequest::Dequeue(r) => {
-                let response = self.dequeue(r)?;
-                Ok(response).map(TeaclaveStorageResponse::Dequeue)
-            }
-            TeaclaveStorageRequest::GetKeysByPrefix(r) => {
-                let response = self.get_keys_by_prefix(r)?;
-                Ok(response).map(TeaclaveStorageResponse::GetKeysByPrefix)
+                self.dequeue(r).map(TeaclaveStorageResponse::Dequeue)
             }
+            TeaclaveStorageRequest::GetKeysByPrefix(r) => self
+                .get_keys_by_prefix(r)
+                .map(TeaclaveStorageResponse::GetKeysByPrefix),
         }
     }
 }
@@ -206,7 +194,7 @@ impl TeaclaveStorageService {
         }
     }
 
-    fn put(&self, request: PutRequest) -> std::result::Result<PutResponse, StorageServiceError> {
+    fn put(&self, request: PutRequest) -> std::result::Result<(), StorageServiceError> {
         self.database
             .borrow_mut()
             .put(&request.key, &request.value)
@@ -216,13 +204,10 @@ impl TeaclaveStorageService {
             .borrow_mut()
             .flush()
             .map_err(StorageServiceError::Database)?;
-        Ok(PutResponse {})
+        Ok(())
     }
 
-    fn delete(
-        &self,
-        request: DeleteRequest,
-    ) -> std::result::Result<DeleteResponse, StorageServiceError> {
+    fn delete(&self, request: DeleteRequest) -> std::result::Result<(), StorageServiceError> {
         self.database
             .borrow_mut()
             .delete(&request.key)
@@ -232,17 +217,14 @@ impl TeaclaveStorageService {
             .borrow_mut()
             .flush()
             .map_err(StorageServiceError::Database)?;
-        Ok(DeleteResponse {})
+        Ok(())
     }
 
-    fn enqueue(
-        &self,
-        request: EnqueueRequest,
-    ) -> std::result::Result<EnqueueResponse, StorageServiceError> {
+    fn enqueue(&self, request: EnqueueRequest) -> std::result::Result<(), StorageServiceError> {
         let mut db = self.database.borrow_mut();
         let mut queue = DBQueue::open(&mut db, &request.key);
         match queue.enqueue(&request.value) {
-            Ok(_) => Ok(EnqueueResponse {}),
+            Ok(_) => Ok(()),
             Err(e) => bail!(e),
         }
     }
diff --git a/tests/functional/enclave/src/end_to_end/mod.rs b/tests/functional/enclave/src/end_to_end/mod.rs
index 93383712..1f8e9863 100644
--- a/tests/functional/enclave/src/end_to_end/mod.rs
+++ b/tests/functional/enclave/src/end_to_end/mod.rs
@@ -69,8 +69,7 @@ async fn approve_task(
     task_id: &ExternalID,
 ) -> anyhow::Result<()> {
     let request = ApproveTaskRequest::new(task_id.clone());
-    let response = client.approve_task(request).await?.into_inner();
-    log::debug!("Approve task: {:?}", response);
+    client.approve_task(request).await?;
     Ok(())
 }
 
@@ -79,7 +78,6 @@ async fn invoke_task(
     task_id: &ExternalID,
 ) -> anyhow::Result<()> {
     let request = InvokeTaskRequest::new(task_id.clone());
-    let response = client.invoke_task(request).await?.into_inner();
-    log::debug!("Invoke task: {:?}", response);
+    client.invoke_task(request).await?;
     Ok(())
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org


[incubator-teaclave] 03/04: Update python sdk and examples

Posted by hs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hsun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git

commit 014059a223fd8ddf3aab375e0b44e8375b3b5e60
Author: GeminiCarrie <sp...@163.com>
AuthorDate: Wed May 10 06:15:57 2023 +0000

    Update python sdk and examples
---
 .gitignore                                         |   3 +
 cmake/scripts/test.sh                              |  18 +-
 examples/README.md                                 |  10 +-
 examples/python/builtin_face_detection.py          |   4 -
 examples/python/builtin_gbdt_train.py              |   2 -
 examples/python/builtin_online_decrypt.py          |   1 -
 examples/python/builtin_ordered_set_intersect.py   |  15 +-
 examples/python/builtin_password_check.py          |  15 +-
 .../python/builtin_private_join_and_compute.py     |  15 +-
 examples/python/builtin_rsa_sign.py                |   6 +-
 examples/python/mesapy_deadloop_cancel.py          |   3 +-
 examples/python/mesapy_echo.py                     |   2 +-
 examples/python/mesapy_logistic_reg.py             |  15 +-
 examples/python/requirements.txt                   |   3 +
 examples/python/test_disable_function.py           |   6 +-
 examples/python/utils.py                           |   7 +-
 examples/python/wasm_c_simple_add.py               |   2 +-
 examples/python/wasm_rust_psi.py                   |  15 +-
 sdk/python/teaclave.py                             | 761 ++++++++++-----------
 tests/scripts/functional_tests.py                  | 131 +++-
 20 files changed, 500 insertions(+), 534 deletions(-)

diff --git a/.gitignore b/.gitignore
index 4190671d..ba070e54 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,3 +32,6 @@ cov_report
 examples/c/builtin_echo
 examples/c/builtin_ordered_set_intersect
 examples/python/out.jpg
+# ignore grpc files during building and testing
+sdk/python/*_pb2.py
+sdk/python/*_grpc.py
diff --git a/cmake/scripts/test.sh b/cmake/scripts/test.sh
index e61e531e..0d2474dd 100755
--- a/cmake/scripts/test.sh
+++ b/cmake/scripts/test.sh
@@ -79,6 +79,14 @@ wait_port() {
   done
 }
 
+generate_python_grpc_stubs() {
+  python3 -m grpc_tools.protoc \
+          --proto_path=${TEACLAVE_PROJECT_ROOT}/services/proto/src/proto \
+          --python_out=${TEACLAVE_PROJECT_ROOT}/sdk/python \
+          --grpclib_python_out=${TEACLAVE_PROJECT_ROOT}/sdk/python \
+          ${TEACLAVE_PROJECT_ROOT}/services/proto/src/proto/*.proto
+}
+
 run_integration_tests() {
   trap cleanup INT TERM ERR
 
@@ -152,7 +160,9 @@ run_functional_tests() {
 
   ./teaclave_functional_tests -t end_to_end
 
-  # Run script tests
+  generate_python_grpc_stubs
+  
+  export PYTHONPATH=${TEACLAVE_PROJECT_ROOT}/sdk/python
   ./scripts/functional_tests.py -v
 
   popd
@@ -283,6 +293,8 @@ run_examples() {
   sleep 3    # wait for execution services
   popd
 
+  generate_python_grpc_stubs
+
   # run builtin examples
   builtin_examples
 
@@ -328,6 +340,8 @@ run_libos_examples() {
   sleep 3    # wait for execution services
   popd
 
+  generate_python_grpc_stubs
+          
   # run builtin examples
   builtin_examples
 
@@ -374,6 +388,8 @@ run_cancel_test() {
   echo "executor 1 pid: $exe_pid1"
   echo "executor 2 pid: $exe_pid2"
 
+  generate_python_grpc_stubs
+
   pushd ${TEACLAVE_PROJECT_ROOT}/examples/python
   export PYTHONPATH=${TEACLAVE_PROJECT_ROOT}/sdk/python
   python3 mesapy_deadloop_cancel.py
diff --git a/examples/README.md b/examples/README.md
index 7cba2cf5..8eeda5df 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -10,8 +10,14 @@ results with the Teclave's client SDK in both single and multi-party setups.
 
 Before trying these examples, please make sure all services in the Teaclave
 platform has been properly launched. Also, for examples implemented in Python,
-don't forget to set the `PYTHONPATH` to the `sdk` path so that the scripts can
-successfully import the `teaclave` module.
+don't forget to generate protocol stub files and set the `PYTHONPATH` to the
+`sdk` path so that the scripts can successfully import the `teaclave` module.
+
+Generate stub files by grpcio-tools and grpclib.
+
+```
+python3 -m grpc_tools.protoc --proto_path=../../services/proto/src/proto --python_out=. --grpclib_python_out=. ../../services/proto/src/proto/{teaclave_authentication_service.proto,teaclave_frontend_service.proto,teaclave_common.proto}
+```
 
 For instance, use the following command to invoke an echo function in Teaclave:
 
diff --git a/examples/python/builtin_face_detection.py b/examples/python/builtin_face_detection.py
index a0743735..570f9f9a 100644
--- a/examples/python/builtin_face_detection.py
+++ b/examples/python/builtin_face_detection.py
@@ -17,13 +17,9 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import os
-import sys
 import json
 
 from PIL import Image, ImageDraw
-import requests
-
 from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service
 from teaclave import FunctionArgument
 
diff --git a/examples/python/builtin_gbdt_train.py b/examples/python/builtin_gbdt_train.py
index 9b125104..bc932109 100644
--- a/examples/python/builtin_gbdt_train.py
+++ b/examples/python/builtin_gbdt_train.py
@@ -17,8 +17,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import sys
-
 from teaclave import FunctionInput, FunctionOutput, FunctionArgument, OwnerList, DataMap
 from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service
 
diff --git a/examples/python/builtin_online_decrypt.py b/examples/python/builtin_online_decrypt.py
index 9a30b3b0..302857da 100644
--- a/examples/python/builtin_online_decrypt.py
+++ b/examples/python/builtin_online_decrypt.py
@@ -17,7 +17,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import sys
 import base64
 
 from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service
diff --git a/examples/python/builtin_ordered_set_intersect.py b/examples/python/builtin_ordered_set_intersect.py
index 277cef70..d084bf2b 100644
--- a/examples/python/builtin_ordered_set_intersect.py
+++ b/examples/python/builtin_ordered_set_intersect.py
@@ -17,10 +17,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import sys
-
 from teaclave import FunctionInput, FunctionOutput, FunctionArgument, OwnerList, DataMap
-from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service, PlatformAdmin
+from utils import connect_authentication_service, connect_frontend_service, PlatformAdmin
 
 # In the example, user 0 creates the task and user 0, 1, upload their private data.
 # Then user 0 invokes the task and user 0, 1 get the result.
@@ -63,13 +61,6 @@ USER_DATA_1 = UserData("user1", "password",
                        ], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
 
 
-class DataList:
-
-    def __init__(self, data_name, data_id):
-        self.data_name = data_name
-        self.data_id = data_id
-
-
 class Client:
 
     def __init__(self, user_id, user_password):
@@ -143,8 +134,8 @@ class Client:
         output_id = client.register_output_file(url, schema, key, iv)
 
         print(f"[+] {self.user_id} assigning data to task")
-        client.assign_data_to_task(task_id, [DataList(input_label, input_id)],
-                                   [DataList(output_label, output_id)])
+        client.assign_data_to_task(task_id, [DataMap(input_label, input_id)],
+                                   [DataMap(output_label, output_id)])
 
     def approve_task(self, task_id):
         client = self.client
diff --git a/examples/python/builtin_password_check.py b/examples/python/builtin_password_check.py
index 1715be0d..dac68646 100644
--- a/examples/python/builtin_password_check.py
+++ b/examples/python/builtin_password_check.py
@@ -17,10 +17,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import sys
-
-from teaclave import FunctionInput, FunctionOutput, FunctionArgument, OwnerList, DataMap
-from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service, PlatformAdmin
+from teaclave import FunctionInput, OwnerList, DataMap
+from utils import connect_authentication_service, connect_frontend_service, PlatformAdmin
 
 # In the example, user 0 creates the task and user 0, 1, upload their private data.
 # Then user 0 invokes the task and user 0, 1 get the result.
@@ -69,13 +67,6 @@ USER_DATA_1 = UserData("user1", "password",
                        ], [], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
 
 
-class DataList:
-
-    def __init__(self, data_name, data_id):
-        self.data_name = data_name
-        self.data_id = data_id
-
-
 class Client:
 
     def __init__(self, user_id, user_password):
@@ -134,7 +125,7 @@ class Client:
         input_id = client.register_input_file(url, schema, key, iv, cmac)
 
         print(f"[+] {self.user_id} assigning data to task")
-        client.assign_data_to_task(task_id, [DataList(input_label, input_id)],
+        client.assign_data_to_task(task_id, [DataMap(input_label, input_id)],
                                    [])
 
     def approve_task(self, task_id):
diff --git a/examples/python/builtin_private_join_and_compute.py b/examples/python/builtin_private_join_and_compute.py
index 0b7c89b6..a5e77c9b 100644
--- a/examples/python/builtin_private_join_and_compute.py
+++ b/examples/python/builtin_private_join_and_compute.py
@@ -17,10 +17,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import sys
-
 from teaclave import FunctionInput, FunctionOutput, FunctionArgument, OwnerList, DataMap
-from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service, PlatformAdmin
+from utils import connect_authentication_service, connect_frontend_service, PlatformAdmin
 
 # In the example, user 3 creates the task and user 0, 1, 2 upload their private data.
 # Then user 3 invokes the task and user 0, 1, 2 get the result.
@@ -70,13 +68,6 @@ USER_DATA_2 = UserData("user2", "password",
 USER_DATA_3 = UserData("user3", "password")
 
 
-class DataList:
-
-    def __init__(self, data_name, data_id):
-        self.data_name = data_name
-        self.data_id = data_id
-
-
 class ConfigClient:
 
     def __init__(self, user_id, user_password):
@@ -173,8 +164,8 @@ class DataClient:
         output_id = client.register_output_file(url, schema, key, iv)
 
         print(f"[+] {self.user_id} assigning data to task")
-        client.assign_data_to_task(task_id, [DataList(input_label, input_id)],
-                                   [DataList(output_label, output_id)])
+        client.assign_data_to_task(task_id, [DataMap(input_label, input_id)],
+                                   [DataMap(output_label, output_id)])
 
     def approve_task(self, task_id):
         client = self.client
diff --git a/examples/python/builtin_rsa_sign.py b/examples/python/builtin_rsa_sign.py
index 3ba494a1..63128d66 100644
--- a/examples/python/builtin_rsa_sign.py
+++ b/examples/python/builtin_rsa_sign.py
@@ -17,10 +17,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import sys
-
-from teaclave import FunctionInput, FunctionOutput, FunctionArgument, OwnerList, DataMap
-from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service, PlatformAdmin
+from teaclave import FunctionInput, FunctionArgument, OwnerList, DataMap
+from utils import connect_authentication_service, connect_frontend_service, PlatformAdmin
 
 
 def get_client(user_id, user_password):
diff --git a/examples/python/mesapy_deadloop_cancel.py b/examples/python/mesapy_deadloop_cancel.py
index a4b0eaa1..c4311da6 100644
--- a/examples/python/mesapy_deadloop_cancel.py
+++ b/examples/python/mesapy_deadloop_cancel.py
@@ -17,10 +17,9 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import sys
 import time
 
-from teaclave import FunctionInput, FunctionOutput, OwnerList, DataMap, TaskStatus
+from teaclave import TaskStatus
 from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service, PlatformAdmin
 
 
diff --git a/examples/python/mesapy_echo.py b/examples/python/mesapy_echo.py
index b60df003..71093744 100644
--- a/examples/python/mesapy_echo.py
+++ b/examples/python/mesapy_echo.py
@@ -19,7 +19,7 @@
 
 import sys
 
-from teaclave import FunctionInput, FunctionOutput, FunctionArgument, OwnerList, DataMap
+from teaclave import FunctionArgument
 from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service, PlatformAdmin
 
 
diff --git a/examples/python/mesapy_logistic_reg.py b/examples/python/mesapy_logistic_reg.py
index 2b8c8b81..409275e7 100644
--- a/examples/python/mesapy_logistic_reg.py
+++ b/examples/python/mesapy_logistic_reg.py
@@ -20,11 +20,9 @@
 An example about Logistic Regression in MesaPy.
 """
 
-import sys
-import binascii
 from typing import List
 from teaclave import FunctionInput, FunctionOutput, FunctionArgument, OwnerList, DataMap
-from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service, PlatformAdmin
+from utils import connect_authentication_service, connect_frontend_service
 
 from enum import Enum
 
@@ -79,13 +77,6 @@ class OutputData:
         self.label = label
 
 
-class DataList:
-
-    def __init__(self, data_name, data_id):
-        self.data_name = data_name
-        self.data_id = data_id
-
-
 class ConfigClient:
 
     def __init__(self, user_id, user_password):
@@ -161,7 +152,7 @@ class ConfigClient:
             key = da.file_key
             iv = da.iv
             input_id = client.register_input_file(url, schema, key, iv, cmac)
-            input_data_list.append(DataList(da.label, input_id))
+            input_data_list.append(DataMap(da.label, input_id))
         print(f"[+] {self.user_id} registering output file")
         output_data_list = []
         for out_data in outputs:
@@ -170,7 +161,7 @@ class ConfigClient:
             key = out_data.file_key
             iv = out_data.iv
             output_id = client.register_output_file(out_url, schema, key, iv)
-            output_data_list.append(DataList(out_data.label, output_id))
+            output_data_list.append(DataMap(out_data.label, output_id))
         print(f"[+] {self.user_id} assigning data to task")
 
         client.assign_data_to_task(task_id, input_data_list, output_data_list)
diff --git a/examples/python/requirements.txt b/examples/python/requirements.txt
index 6f3b7486..82d36f2f 100644
--- a/examples/python/requirements.txt
+++ b/examples/python/requirements.txt
@@ -3,3 +3,6 @@ toml
 cryptography
 requests
 Pillow
+grpclib
+grpcio 
+grpcio-tools
diff --git a/examples/python/test_disable_function.py b/examples/python/test_disable_function.py
index dbea609d..9923f6e9 100644
--- a/examples/python/test_disable_function.py
+++ b/examples/python/test_disable_function.py
@@ -17,10 +17,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import sys
-
-from teaclave import FunctionInput, FunctionOutput, FunctionArgument, OwnerList, DataMap
-from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service, PlatformAdmin
+from teaclave import FunctionArgument
+from utils import connect_authentication_service, connect_frontend_service, PlatformAdmin
 
 
 class UserData:
diff --git a/examples/python/utils.py b/examples/python/utils.py
index 41299fa7..70115647 100644
--- a/examples/python/utils.py
+++ b/examples/python/utils.py
@@ -45,7 +45,7 @@ class PlatformAdmin:
     def __init__(self, user_id: str, user_password: str):
         self.client = AuthenticationService(AUTHENTICATION_SERVICE_ADDRESS,
                                             AS_ROOT_CA_CERT_PATH,
-                                            ENCLAVE_INFO_PATH).connect()
+                                            ENCLAVE_INFO_PATH)
         token = self.client.user_login(user_id, user_password)
         self.client.metadata = {"id": user_id, "token": token}
 
@@ -55,10 +55,9 @@ class PlatformAdmin:
 
 def connect_authentication_service():
     return AuthenticationService(AUTHENTICATION_SERVICE_ADDRESS,
-                                 AS_ROOT_CA_CERT_PATH,
-                                 ENCLAVE_INFO_PATH).connect()
+                                 AS_ROOT_CA_CERT_PATH, ENCLAVE_INFO_PATH)
 
 
 def connect_frontend_service():
     return FrontendService(FRONTEND_SERVICE_ADDRESS, AS_ROOT_CA_CERT_PATH,
-                           ENCLAVE_INFO_PATH).connect()
+                           ENCLAVE_INFO_PATH)
diff --git a/examples/python/wasm_c_simple_add.py b/examples/python/wasm_c_simple_add.py
index 867cba3a..ee6762b4 100644
--- a/examples/python/wasm_c_simple_add.py
+++ b/examples/python/wasm_c_simple_add.py
@@ -19,7 +19,7 @@
 
 import sys
 
-from teaclave import FunctionInput, FunctionOutput, FunctionArgument, OwnerList, DataMap
+from teaclave import FunctionArgument
 from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service, PlatformAdmin
 
 
diff --git a/examples/python/wasm_rust_psi.py b/examples/python/wasm_rust_psi.py
index 61fc1c53..60176e88 100644
--- a/examples/python/wasm_rust_psi.py
+++ b/examples/python/wasm_rust_psi.py
@@ -17,10 +17,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import sys
-
 from teaclave import FunctionInput, FunctionOutput, FunctionArgument, OwnerList, DataMap
-from utils import USER_ID, USER_PASSWORD, connect_authentication_service, connect_frontend_service, PlatformAdmin
+from utils import connect_authentication_service, connect_frontend_service, PlatformAdmin
 
 
 class UserData:
@@ -66,13 +64,6 @@ USER_DATA_1 = UserData("user1", "password",
                        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
 
 
-class DataList:
-
-    def __init__(self, data_name, data_id):
-        self.data_name = data_name
-        self.data_id = data_id
-
-
 class Client:
 
     def __init__(self, user_id, user_password):
@@ -168,8 +159,8 @@ class Client:
         output_id = client.register_output_file(url, schema, key, iv)
 
         print(f"[+] {self.user_id} assigning data to task")
-        client.assign_data_to_task(task_id, [DataList(input_label, input_id)],
-                                   [DataList(output_label, output_id)])
+        client.assign_data_to_task(task_id, [DataMap(input_label, input_id)],
+                                   [DataMap(output_label, output_id)])
 
     def approve_task(self, task_id):
         client = self.client
diff --git a/sdk/python/teaclave.py b/sdk/python/teaclave.py
index 2fec9cd8..c19d325e 100644
--- a/sdk/python/teaclave.py
+++ b/sdk/python/teaclave.py
@@ -23,26 +23,33 @@ trusted TLS channel and communicate with Teaclave services (e.g., the
 authentication service and frontend service) through RPC protocols.
 """
 
-import struct
 import json
 import base64
 import toml
-import os
 import time
+import os
 import ssl
-import socket
-
-from typing import Tuple, Dict, List, Any
-from enum import IntEnum
 
 import cryptography
 from cryptography import x509
 from cryptography.hazmat.backends import default_backend
 
+from google.protobuf.json_format import MessageToDict
+from grpclib.client import Channel, _ChannelState
+from grpclib.protocol import H2Protocol
+
 from OpenSSL.crypto import load_certificate, FILETYPE_PEM, FILETYPE_ASN1
 from OpenSSL.crypto import X509Store, X509StoreContext
 from OpenSSL import crypto
 
+import teaclave_authentication_service_pb2 as auth
+import teaclave_frontend_service_pb2 as fe
+from teaclave_authentication_service_grpc import TeaclaveAuthenticationApiStub
+from teaclave_frontend_service_grpc import TeaclaveFrontendStub
+from teaclave_common_pb2 import TaskStatus, FileCryptoInfo
+
+from typing import Tuple, Dict, List, Any
+
 __all__ = [
     'FrontendService', 'AuthenticationService', 'FunctionArgument',
     'FunctionInput', 'FunctionOutput', 'OwnerList', 'DataMap'
@@ -51,19 +58,13 @@ __all__ = [
 Metadata = Dict[str, str]
 
 
-class TaskStatus(IntEnum):
-    Created = 0
-    DataAssigned = 1
-    Approved = 2
-    Staged = 3
-    Running = 4
-    Finished = 10
-    Canceled = 20
-    Failed = 99
-
-
 class Request:
-    pass
+    message = None
+
+    def __init__(self, method, response, metadata=dict()):
+        self.method = method
+        self.metadata = metadata
+        self.response = response
 
 
 class TeaclaveException(Exception):
@@ -71,8 +72,8 @@ class TeaclaveException(Exception):
 
 
 class TeaclaveService:
-    channel = None
     metadata = None
+    stub = None
 
     def __init__(self,
                  name: str,
@@ -80,38 +81,79 @@ class TeaclaveService:
                  as_root_ca_cert_path: str,
                  enclave_info_path: str,
                  dump_report=False):
-        self._context = ssl._create_unverified_context()
         self._name = name
         self._address = address
         self._as_root_ca_cert_path = as_root_ca_cert_path
         self._enclave_info_path = enclave_info_path
-        self._closed = False
         self._dump_report = dump_report
 
+        self._channel = TeaclaveChannel(self._name, self._address,
+                                        self._as_root_ca_cert_path,
+                                        self._enclave_info_path)
+        self._loop = self._channel._loop
+
+    def call_method(self, request):
+        return self._loop.run_until_complete(
+            getattr(self.stub, request.method)(request.message,
+                                               metadata=request.metadata))
+
     def __enter__(self):
         return self
 
     def __exit__(self, *exc):
-        if not self._closed:
-            self.close()
+        self.close()
 
     def close(self):
-        self._closed = True
-        if self.channel: self.channel.close()
+        if self._channel: self._channel.close()
 
-    def check_channel(self):
-        if not self.channel: raise TeaclaveException("Channel is None")
+    def __del__(self) -> None:
+        self.close()
 
     def check_metadata(self):
         if not self.metadata: raise TeaclaveException("Metadata is None")
 
-    def connect(self):
-        """Establish trusted connection and verify remote attestation report.
-        """
-        sock = socket.create_connection(self._address)
-        channel = self._context.wrap_socket(sock,
-                                            server_hostname=self._address[0])
-        cert = channel.getpeercert(binary_form=True)
+    def check_channel(self):
+        self._channel.check_channel()
+
+    def get_metadata(self):
+        return self.metadata
+
+
+def create_context() -> ssl.SSLContext:
+    ctx = ssl._create_unverified_context()
+    ctx.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
+    ctx.set_ciphers('ECDHE+AESGCM:ECDHE+CHACHA20:DHE+AESGCM:DHE+CHACHA20')
+    ctx.set_alpn_protocols(['h2'])
+    try:
+        ctx.set_npn_protocols(['h2'])
+    except NotImplementedError:
+        pass
+    return ctx
+
+
+class TeaclaveChannel(Channel):
+
+    def __init__(self,
+                 name: str,
+                 address: Tuple[str, int],
+                 as_root_ca_cert_path: str,
+                 enclave_info_path: str,
+                 dump_report=False):
+        context = create_context()
+        super().__init__(host=address[0], port=address[1], ssl=context)
+        self._name = name
+        self._as_root_ca_cert_path = as_root_ca_cert_path
+        self._enclave_info_path = enclave_info_path
+        self._dump_report = dump_report
+
+    def check_channel(self):
+        if self._state == _ChannelState.TRANSIENT_FAILURE:
+            raise TeaclaveException("Channel is None")
+
+    async def __connect__(self) -> H2Protocol:
+        protocol = await super().__connect__()
+        sslobj = protocol.connection._transport.get_extra_info('ssl_object')
+        cert = sslobj.getpeercert(binary_form=True)
         if not cert: raise TeaclaveException("Peer cert is None")
         try:
             self._verify_report(self._as_root_ca_cert_path,
@@ -119,9 +161,7 @@ class TeaclaveService:
         except Exception as e:
             raise TeaclaveException(
                 f"Failed to verify attestation report: {e}")
-        self.channel = channel
-
-        return self
+        return protocol
 
     def _verify_report(self, as_root_ca_cert_path: str, enclave_info_path: str,
                        cert: Dict[str, Any], endpoint_name: str):
@@ -244,9 +284,9 @@ class FunctionInput:
     """
 
     def __init__(self, name: str, description: str, optional=False):
-        self.name = name
-        self.description = description
-        self.optional = optional
+        self.message = fe.FunctionInput(name=name,
+                                        description=description,
+                                        optional=optional)
 
 
 class FunctionOutput:
@@ -260,9 +300,9 @@ class FunctionOutput:
     """
 
     def __init__(self, name: str, description: str, optional=False):
-        self.name = name
-        self.description = description
-        self.optional = optional
+        self.message = fe.FunctionOutput(name=name,
+                                         description=description,
+                                         optional=optional)
 
 
 class FunctionArgument:
@@ -280,9 +320,9 @@ class FunctionArgument:
                  key: str,
                  default_value: str = "",
                  allow_overwrite=True):
-        self.key = key
-        self.default_value = default_value
-        self.allow_overwrite = allow_overwrite
+        self.message = fe.FunctionArgument(key=key,
+                                           default_value=default_value,
+                                           allow_overwrite=allow_overwrite)
 
 
 class OwnerList:
@@ -295,8 +335,7 @@ class OwnerList:
     """
 
     def __init__(self, data_name: str, uids: List[str]):
-        self.data_name = data_name
-        self.uids = uids
+        self.message = fe.OwnerList(data_name=data_name, uids=uids)
 
 
 class DataMap:
@@ -309,8 +348,7 @@ class DataMap:
     """
 
     def __init__(self, data_name, data_id):
-        self.data_name = data_name
-        self.data_id = data_id
+        self.message = fe.DataMap(data_name=data_name, data_id=data_id)
 
 
 class CryptoInfo:
@@ -324,73 +362,70 @@ class CryptoInfo:
     """
 
     def __init__(self, schema: str, key: List[int], iv: List[int]):
-        self.schema = schema
-        self.key = key
-        self.iv = iv
+
+        self.message = FileCryptoInfo(schema=schema,
+                                      key=bytes(key),
+                                      iv=bytes(iv))
 
 
 class UserRegisterRequest(Request):
 
     def __init__(self, metadata: Metadata, user_id: str, user_password: str,
                  role: str, attribute: str):
-        self.request = "user_register"
-        self.metadata = metadata
-        self.id = user_id
-        self.password = user_password
-        self.role = role
-        self.attribute = attribute
+        super().__init__("UserRegister", auth.UserRegisterResponse, metadata)
+        self.message = auth.UserRegisterRequest(id=user_id,
+                                                password=user_password,
+                                                role=role,
+                                                attribute=attribute)
 
 
 class UserUpdateRequest(Request):
 
     def __init__(self, metadata: Metadata, user_id: str, user_password: str,
                  role: str, attribute: str):
-        self.request = "user_update"
-        self.metadata = metadata
-        self.id = user_id
-        self.password = user_password
-        self.role = role
-        self.attribute = attribute
+        super().__init__("UserUpdate", auth.UserUpdateResponse)
+        self.message = auth.UserUpdateRequest(id=user_id,
+                                              password=user_password,
+                                              role=role,
+                                              attribute=attribute)
 
 
 class UserLoginRequest(Request):
 
     def __init__(self, user_id: str, user_password: str):
-        self.request = "user_login"
-        self.id = user_id
-        self.password = user_password
+        super().__init__("UserLogin", auth.UserLoginResponse)
+        self.message = auth.UserLoginRequest(id=user_id,
+                                             password=user_password)
 
 
 class UserChangePasswordRequest(Request):
 
     def __init__(self, metadata: Metadata, password: str):
-        self.request = "user_change_password"
-        self.metadata = metadata
-        self.password = password
+        super().__init__("UserChangePassword", auth.UserChangePasswordResponse,
+                         metadata)
+        self.message = auth.UserChangePasswordRequest(password=password)
 
 
 class ResetUserPasswordRequest(Request):
 
     def __init__(self, metadata: Metadata, user_id: str):
-        self.request = "reset_user_password"
-        self.metadata = metadata
-        self.id = user_id
+        super().__init__("ResetUserPassword", auth.ResetUserPasswordResponse,
+                         metadata)
+        self.message = auth.ResetUserPasswordRequest(id=user_id)
 
 
 class DeleteUserRequest(Request):
 
     def __init__(self, metadata: Metadata, user_id: str):
-        self.request = "delete_user"
-        self.metadata = metadata
-        self.id = user_id
+        super().__init__("DeleteUser", auth.DeleteUserResponse, metadata)
+        self.message = auth.DeleteUserRequest(id=user_id)
 
 
 class ListUsersRequest(Request):
 
     def __init__(self, metadata: Metadata, user_id: str):
-        self.request = "list_users"
-        self.metadata = metadata
-        self.id = user_id
+        super().__init__("ListUsers", auth.ListUsersResponse, metadata)
+        self.message = auth.ListUsersRequest(id=user_id)
 
 
 class AuthenticationService(TeaclaveService):
@@ -414,9 +449,13 @@ class AuthenticationService(TeaclaveService):
                  dump_report=False):
         super().__init__("authentication", address, as_root_ca_cert_path,
                          enclave_info_path, dump_report)
+        self.stub = TeaclaveAuthenticationApiStub(self._channel)
 
-    def user_register(self, user_id: str, user_password: str, role: str,
-                      attribute: str):
+    def user_register(self,
+                      user_id: str,
+                      user_password: str,
+                      role="",
+                      attribute=""):
         """Register a new user.
 
         Args:
@@ -430,18 +469,17 @@ class AuthenticationService(TeaclaveService):
         self.check_metadata()
         request = UserRegisterRequest(self.metadata, user_id, user_password,
                                       role, attribute)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            pass
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
-            raise TeaclaveException(f"Failed to register user ({reason})")
-
-    def user_update(self, user_id: str, user_password: str, role: str,
-                    attribute: str):
+        try:
+            response = self.call_method(request)
+            return response
+        except Exception as e:
+            raise TeaclaveException(f"Failed to register user  {str(e)}")
+
+    def user_update(self,
+                    user_id: str,
+                    user_password: str,
+                    role: str,
+                    attribute=""):
         """Update an existing user.
 
         Args:
@@ -455,15 +493,11 @@ class AuthenticationService(TeaclaveService):
         self.check_metadata()
         request = UserUpdateRequest(self.metadata, user_id, user_password,
                                     role, attribute)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            pass
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
-            raise TeaclaveException(f"Failed to update user ({reason})")
+        try:
+            response = self.call_method(request)
+            return response
+        except Exception as e:
+            raise TeaclaveException(f"Failed to update user  {str(e)}")
 
     def user_login(self, user_id: str, user_password: str) -> str:
         """Login and get a session token.
@@ -477,17 +511,14 @@ class AuthenticationService(TeaclaveService):
 
             str: User login token.
         """
-        self.check_channel()
+        self._channel.check_channel()
         request = UserLoginRequest(user_id, user_password)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]["token"]
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
-            raise TeaclaveException(f"Failed to login user ({reason})")
+        try:
+            response = self.call_method(request)
+            self.metadata = {"id": user_id, "token": response.token}
+            return response.token
+        except Exception as e:
+            raise TeaclaveException(f"Failed to login user  {str(e)}")
 
     def user_change_password(self, user_password: str):
         """Change password.
@@ -499,15 +530,11 @@ class AuthenticationService(TeaclaveService):
         self.check_channel()
         self.check_metadata()
         request = UserChangePasswordRequest(self.metadata, user_password)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            pass
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
-            raise TeaclaveException(f"Failed to change password ({reason})")
+        try:
+            response = self.call_method(request)
+            return response
+        except Exception as e:
+            raise TeaclaveException(f"Failed to change password  {str(e)}")
 
     def reset_user_password(self, user_id: str) -> str:
         """Reset password of a managed user.
@@ -523,15 +550,12 @@ class AuthenticationService(TeaclaveService):
         self.check_channel()
         self.check_metadata()
         request = ResetUserPasswordRequest(self.metadata, user_id)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]["password"]
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
-            raise TeaclaveException(f"Failed to reset password ({reason})")
+        try:
+            response = self.call_method(request)
+            return response
+        except Exception as e:
+            reason = str(e)
+            raise TeaclaveException(f"Failed to reset password  {reason}")
 
     def delete_user(self, user_id: str) -> str:
         """Delete a user.
@@ -543,14 +567,11 @@ class AuthenticationService(TeaclaveService):
         self.check_channel()
         self.check_metadata()
         request = DeleteUserRequest(self.metadata, user_id)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            pass
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            response = self.call_method(request)
+            return response
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(f"Failed to delete user ({reason})")
 
     def list_users(self, user_id: str) -> str:
@@ -565,15 +586,13 @@ class AuthenticationService(TeaclaveService):
             str: User list
         """
         self.check_channel()
+        self.check_metadata()
         request = ListUsersRequest(self.metadata, user_id)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]["ids"]
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            response = self.call_method(request)
+            return response
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(f"Failed to list user ({reason})")
 
 
@@ -584,18 +603,23 @@ class RegisterFunctionRequest(Request):
                  arguments: List[FunctionArgument],
                  inputs: List[FunctionInput], outputs: List[FunctionOutput],
                  user_allowlist: List[str], usage_quota: int):
-        self.request = "register_function"
-        self.metadata = metadata
-        self.name = name
-        self.description = description
-        self.executor_type = executor_type
-        self.public = public
-        self.payload = payload
-        self.arguments = arguments
-        self.inputs = inputs
-        self.outputs = outputs
-        self.user_allowlist = user_allowlist
-        self.usage_quota = usage_quota
+        super().__init__("RegisterFunction", fe.RegisterFunctionResponse,
+                         metadata)
+        arguments = [x.message for x in arguments]
+        inputs = [x.message for x in inputs]
+        outputs = [x.message for x in outputs]
+
+        self.message = fe.RegisterFunctionRequest(
+            name=name,
+            description=description,
+            executor_type=executor_type,
+            public=public,
+            payload=bytes(payload),
+            arguments=arguments,
+            inputs=inputs,
+            outputs=outputs,
+            user_allowlist=user_allowlist,
+            usage_quota=usage_quota)
 
 
 class UpdateFunctionRequest(Request):
@@ -605,97 +629,87 @@ class UpdateFunctionRequest(Request):
                  payload: List[int], arguments: List[FunctionArgument],
                  inputs: List[FunctionInput], outputs: List[FunctionOutput],
                  user_allowlist: List[str], usage_quota: int):
-        self.request = "update_function"
-        self.metadata = metadata
-        self.function_id = function_id
-        self.name = name
-        self.description = description
-        self.executor_type = executor_type
-        self.public = public
-        self.payload = payload
-        self.arguments = arguments
-        self.inputs = inputs
-        self.outputs = outputs
-        self.user_allowlist = user_allowlist
-        self.usage_quota = usage_quota
+        super().__init__("UpdateFunction", fe.UpdateFunctionResponse, metadata)
+        arguments = [x.message for x in arguments]
+        inputs = [x.message for x in inputs]
+        outputs = [x.message for x in outputs]
+
+        self.message = fe.UpdateFunctionRequest(function_id, name, description,
+                                                executor_type, public, payload,
+                                                arguments, inputs, outputs,
+                                                user_allowlist, usage_quota)
 
 
 class ListFunctionsRequest(Request):
 
     def __init__(self, metadata: Metadata, user_id: str):
-        self.request = "list_functions"
-        self.metadata = metadata
-        self.user_id = user_id
+        super().__init__("ListFunctions", fe.ListFunctionsResponse, metadata)
+        self.message = fe.ListFunctionsRequest(user_id=user_id)
 
 
 class DeleteFunctionRequest(Request):
 
     def __init__(self, metadata: Metadata, function_id: str):
-        self.request = "delete_function"
-        self.metadata = metadata
-        self.function_id = function_id
+        super().__init__("ListFunctions", fe.DeleteFunctionResponse, metadata)
+        self.message = fe.DeleteFunctionRequest(function_id=function_id)
 
 
 class DisableFunctionRequest(Request):
 
     def __init__(self, metadata: Metadata, function_id: str):
-        self.request = "disable_function"
-        self.metadata = metadata
-        self.function_id = function_id
+        super().__init__("DisableFunction", fe.DisableFunctionResponse,
+                         metadata)
+        self.message = fe.DisableFunctionRequest(function_id=function_id)
 
 
 class GetFunctionRequest(Request):
 
     def __init__(self, metadata: Metadata, function_id: str):
-        self.request = "get_function"
-        self.metadata = metadata
-        self.function_id = function_id
+        super().__init__("GetFunction", fe.GetFunctionResponse, metadata)
+        self.message = fe.GetFunctionRequest(function_id=function_id)
 
 
 class GetFunctionUsageStatsRequest(Request):
 
     def __init__(self, metadata: Metadata, function_id: str):
-        self.request = "get_function_usage_stats"
-        self.metadata = metadata
-        self.function_id = function_id
+        super().__init__("GetFunctionUsageStats",
+                         fe.GetFunctionUsageStatsResponse, metadata)
+        self.message = fe.GetFunctionUsageStatsRequest(function_id=function_id)
 
 
 class RegisterInputFileRequest(Request):
 
     def __init__(self, metadata: Metadata, url: str, cmac: List[int],
                  crypto_info: CryptoInfo):
-        self.request = "register_input_file"
-        self.metadata = metadata
-        self.url = url
-        self.cmac = cmac
-        self.crypto_info = crypto_info
+        super().__init__("RegisterInputFile", fe.RegisterInputFileResponse,
+                         metadata)
+        self.message = fe.RegisterInputFileRequest(
+            url=url, cmac=bytes(cmac), crypto_info=crypto_info.message)
 
 
 class RegisterOutputFileRequest(Request):
 
     def __init__(self, metadata: Metadata, url: str, crypto_info: CryptoInfo):
-        self.request = "register_output_file"
-        self.metadata = metadata
-        self.url = url
-        self.crypto_info = crypto_info
+        super().__init__("RegisterOutputFile", fe.RegisterOutputFileResponse,
+                         metadata)
+        self.message = fe.RegisterOutputFileRequest(
+            url=url, crypto_info=crypto_info.message)
 
 
 class UpdateInputFileRequest(Request):
 
     def __init__(self, metadata: Metadata, data_id: str, url: str):
-        self.request = "update_input_file"
-        self.metadata = metadata
-        self.data_id = data_id
-        self.url = url
+        super().__init__("UpdateInputFile", fe.UpdateInputFileResponse,
+                         metadata)
+        self.message = fe.UpdateInputFileRequest(data_id=data_id, url=url)
 
 
 class UpdateOutputFileRequest(Request):
 
     def __init__(self, metadata: Metadata, data_id: str, url: str):
-        self.request = "update_output_file"
-        self.metadata = metadata
-        self.data_id = data_id
-        self.url = url
+        super().__init__("UpdateInputFile", fe.UpdateOutputFileResponse,
+                         metadata)
+        self.message = fe.UpdateOutputFileRequest(data_id=data_id, url=url)
 
 
 class CreateTaskRequest(Request):
@@ -704,56 +718,56 @@ class CreateTaskRequest(Request):
                  function_arguments: Dict[str, Any], executor: str,
                  inputs_ownership: List[OwnerList],
                  outputs_ownership: List[OwnerList]):
-        self.request = "create_task"
-        self.metadata = metadata
-        self.function_id = function_id
-        self.function_arguments = function_arguments
-        self.executor = executor
-        self.inputs_ownership = inputs_ownership
-        self.outputs_ownership = outputs_ownership
+        super().__init__("CreateTask", fe.CreateTaskResponse, metadata)
+        inputs_ownership = [x.message for x in inputs_ownership]
+        outputs_ownership = [x.message for x in outputs_ownership]
+
+        self.message = fe.CreateTaskRequest(
+            function_id=function_id,
+            function_arguments=function_arguments,
+            executor=executor,
+            inputs_ownership=inputs_ownership,
+            outputs_ownership=outputs_ownership)
 
 
 class AssignDataRequest(Request):
 
     def __init__(self, metadata: Metadata, task_id: str, inputs: List[DataMap],
                  outputs: List[DataMap]):
-        self.request = "assign_data"
-        self.metadata = metadata
-        self.task_id = task_id
-        self.inputs = inputs
-        self.outputs = outputs
+        super().__init__("AssignData", fe.AssignDataResponse, metadata)
+        inputs = [x.message for x in inputs]
+        outputs = [x.message for x in outputs]
+        self.message = fe.AssignDataRequest(task_id=task_id,
+                                            inputs=inputs,
+                                            outputs=outputs)
 
 
 class ApproveTaskRequest(Request):
 
     def __init__(self, metadata: Metadata, task_id: str):
-        self.request = "approve_task"
-        self.metadata = metadata
-        self.task_id = task_id
+        super().__init__("ApproveTask", fe.ApproveTaskResponse, metadata)
+        self.message = fe.ApproveTaskRequest(task_id=task_id)
 
 
 class InvokeTaskRequest(Request):
 
     def __init__(self, metadata: Metadata, task_id: str):
-        self.request = "invoke_task"
-        self.metadata = metadata
-        self.task_id = task_id
+        super().__init__("InvokeTask", fe.InvokeTaskResponse, metadata)
+        self.message = fe.InvokeTaskRequest(task_id=task_id)
 
 
 class CancelTaskRequest(Request):
 
     def __init__(self, metadata: Metadata, task_id: str):
-        self.request = "cancel_task"
-        self.metadata = metadata
-        self.task_id = task_id
+        super().__init__("CancelTask", fe.CancelTaskResponse, metadata)
+        self.message = fe.CancelTaskRequest(task_id=task_id)
 
 
 class GetTaskRequest(Request):
 
     def __init__(self, metadata: Metadata, task_id: str):
-        self.request = "get_task"
-        self.metadata = metadata
-        self.task_id = task_id
+        super().__init__("GetTask", fe.GetTaskResponse, metadata)
+        self.message = fe.GetTaskRequest(task_id=task_id)
 
 
 class FrontendService(TeaclaveService):
@@ -776,6 +790,7 @@ class FrontendService(TeaclaveService):
                  dump_report=False):
         super().__init__("frontend", address, as_root_ca_cert_path,
                          enclave_info_path, dump_report)
+        self.stub = TeaclaveFrontendStub(self._channel)
 
     def register_function(
         self,
@@ -796,14 +811,11 @@ class FrontendService(TeaclaveService):
                                           executor_type, public, payload,
                                           arguments, inputs, outputs,
                                           user_allowlist, usage_quota)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]["function_id"]
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            response = self.call_method(request)
+            return response.function_id
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(f"Failed to register function ({reason})")
 
     def update_function(
@@ -826,53 +838,45 @@ class FrontendService(TeaclaveService):
                                         description, executor_type, public,
                                         payload, arguments, inputs, outputs,
                                         user_allowlist, usage_quota)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]["function_id"]
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
-            raise TeaclaveException(f"Failed to update function ({reason})")
+        try:
+            response = self.call_method(request)
+            return response.function_id
+        except Exception as e:
+            reason = str(e)
+            raise TeaclaveException(f"Failed to register function ({reason})")
 
     def list_functions(self, user_id: str):
         self.check_metadata()
         self.check_channel()
         request = ListFunctionsRequest(self.metadata, user_id)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]
-        else:
-            raise TeaclaveException("Failed to list functions")
+        try:
+            response = self.call_method(request)
+        except Exception as e:
+            raise TeaclaveException(f"Failed to list functions ({str(e)})")
+        return MessageToDict(response,
+                             preserving_proto_field_name=True,
+                             use_integers_for_enums=True)
 
     def get_function(self, function_id: str):
         self.check_metadata()
         self.check_channel()
         request = GetFunctionRequest(self.metadata, function_id)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            response = self.call_method(request)
+            return response
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(f"Failed to get function ({reason})")
 
-    def get_function_usage_stats(self, user_id: str, function_id: str):
+    def get_function_usage_stats(self, function_id: str):
         self.check_metadata()
         self.check_channel()
         request = GetFunctionUsageStatsRequest(self.metadata, function_id)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            response = self.call_method(request)
+            return response
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(
                 f"Failed to get function usage statistics ({reason})")
 
@@ -880,23 +884,23 @@ class FrontendService(TeaclaveService):
         self.check_metadata()
         self.check_channel()
         request = DeleteFunctionRequest(self.metadata, function_id)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]
-        else:
-            raise TeaclaveException("Failed to delete function")
+        try:
+            response = self.call_method(request)
+            return response
+        except Exception as e:
+            reason = str(e)
+            raise TeaclaveException(f"Failed to delete function ({reason})")
 
     def disable_function(self, function_id: str):
         self.check_metadata()
         self.check_channel()
         request = DisableFunctionRequest(self.metadata, function_id)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]
-        else:
-            raise TeaclaveException("Failed to disable function")
+        try:
+            response = self.call_method(request)
+            return response
+        except Exception as e:
+            reason = str(e)
+            raise TeaclaveException(f"Failed to disable function ({reason})")
 
     def register_input_file(self, url: str, schema: str, key: List[int],
                             iv: List[int], cmac: List[int]):
@@ -904,14 +908,11 @@ class FrontendService(TeaclaveService):
         self.check_channel()
         request = RegisterInputFileRequest(self.metadata, url, cmac,
                                            CryptoInfo(schema, key, iv))
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]["data_id"]
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            response = self.call_method(request)
+            return response.data_id
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(
                 f"Failed to register input file ({reason})")
 
@@ -921,14 +922,11 @@ class FrontendService(TeaclaveService):
         self.check_channel()
         request = RegisterOutputFileRequest(self.metadata, url,
                                             CryptoInfo(schema, key, iv))
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]["data_id"]
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            response = self.call_method(request)
+            return response.data_id
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(
                 f"Failed to register output file ({reason})")
 
@@ -944,14 +942,11 @@ class FrontendService(TeaclaveService):
         request = CreateTaskRequest(self.metadata, function_id,
                                     function_arguments, executor,
                                     inputs_ownership, outputs_ownership)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            return response["content"]["task_id"]
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            response = self.call_method(request)
+            return response.task_id
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(f"Failed to create task ({reason})")
 
     def assign_data_to_task(self, task_id: str, inputs: List[DataMap],
@@ -959,14 +954,10 @@ class FrontendService(TeaclaveService):
         self.check_metadata()
         self.check_channel()
         request = AssignDataRequest(self.metadata, task_id, inputs, outputs)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            pass
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            self.call_method(request)
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(
                 f"Failed to assign data to task ({reason})")
 
@@ -974,137 +965,83 @@ class FrontendService(TeaclaveService):
         self.check_metadata()
         self.check_channel()
         request = ApproveTaskRequest(self.metadata, task_id)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            pass
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            self.call_method(request)
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(f"Failed to approve task ({reason})")
 
     def invoke_task(self, task_id: str):
         self.check_metadata()
         self.check_channel()
         request = InvokeTaskRequest(self.metadata, task_id)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            pass
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            self.call_method(request)
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(f"Failed to invoke task ({reason})")
 
     def cancel_task(self, task_id: str):
         self.check_metadata()
         self.check_channel()
         request = CancelTaskRequest(self.metadata, task_id)
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] == "ok":
-            pass
-        else:
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            self.call_method(request)
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(f"Failed to cancel task ({reason})")
 
-    def get_task(self, task_id: str) -> dict:
+    def get_task(self, task_id: str):
         self.check_metadata()
         self.check_channel()
         request = GetTaskRequest(self.metadata, task_id)
-
-        _write_message(self.channel, request)
-        response = _read_message(self.channel)
-        if response["result"] != "ok":
-            reason = "unknown"
-            if "request_error" in response:
-                reason = response["request_error"]
+        try:
+            response = self.call_method(request)
+            return MessageToDict(response,
+                                 preserving_proto_field_name=True,
+                                 use_integers_for_enums=True)
+        except Exception as e:
+            reason = str(e)
             raise TeaclaveException(f"Failed to get task result ({reason})")
-        return response["content"]
 
     def get_task_result(self, task_id: str):
         self.check_metadata()
         self.check_channel()
         request = GetTaskRequest(self.metadata, task_id)
-
         while True:
-            _write_message(self.channel, request)
-            response = _read_message(self.channel)
-            if response["result"] != "ok":
-                reason = "unknown"
-                if "request_error" in response:
-                    reason = response["request_error"]
+            try:
+                time.sleep(1)
+                response = self.call_method(request)
+                if response.status == TaskStatus.Finished:
+                    break
+                elif response.status == TaskStatus.Canceled:
+                    raise TeaclaveException("Task Canceled, Error: " +
+                                            response.result.Err.reason)
+                elif response.status == TaskStatus.Failed:
+                    raise TeaclaveException("Task Failed, Error: " +
+                                            response.result.Err.reason)
+            except Exception as e:
+                reason = str(e)
                 raise TeaclaveException(
                     f"Failed to get task result ({reason})")
-            time.sleep(1)
-            if response["content"]["status"] == TaskStatus.Finished:
-                break
-            elif response["content"]["status"] == TaskStatus.Canceled:
-                raise TeaclaveException(
-                    "Task Canceled, Error: " +
-                    response["content"]["result"]["result"]["Err"]["reason"])
-            elif response["content"]["status"] == TaskStatus.Failed:
-                raise TeaclaveException(
-                    "Task Failed, Error: " +
-                    response["content"]["result"]["result"]["Err"]["reason"])
 
-        return response["content"]["result"]["result"]["Ok"]["return_value"]
+        return response.result.Ok.return_value
 
     def get_output_cmac_by_tag(self, task_id: str, tag: str):
         self.check_metadata()
         self.check_channel()
         request = GetTaskRequest(self.metadata, task_id)
         while True:
-            _write_message(self.channel, request)
-            response = _read_message(self.channel)
-            if response["result"] != "ok":
-                reason = "unknown"
-                if "request_error" in response:
-                    reason = response["request_error"]
+            try:
+                time.sleep(1)
+                response = self.call_method(request)
+                if response.status == TaskStatus.Finished:
+                    break
+            except Exception as e:
+                reason = str(e)
                 raise TeaclaveException(
-                    f"Failed to get output cmac by tag ({reason})")
-            time.sleep(1)
-            if response["content"]["status"] == TaskStatus.Finished:
-                break
-
-        return response["content"]["result"]["result"]["Ok"]["tags_map"][tag]
-
-
-def _write_message(sock: ssl.SSLSocket, message: Any):
-
-    class RequestEncoder(json.JSONEncoder):
-
-        def default(self, o):
-            if isinstance(o, Request):
-                request = o.__dict__["request"]
-                j = {}
-                j["message"] = {}
-                j["message"][request] = {}
-                for k, v in o.__dict__.items():
-                    if k == "metadata": j[k] = v
-                    elif k == "request": continue
-                    else: j["message"][request][k] = v
-                return j
-            else:
-                return o.__dict__
-
-    message = json.dumps(message, cls=RequestEncoder,
-                         separators=(',', ':')).encode()
-    sock.sendall(struct.pack(">Q", len(message)))
-    sock.sendall(message)
-
-
-def _read_message(sock: ssl.SSLSocket):
-    response_len = struct.unpack(">Q", sock.read(8))
-    raw = bytearray()
-    total_recv = 0
-    while total_recv < response_len[0]:
-        data = sock.recv()
-        total_recv += len(data)
-        raw += data
-    response = json.loads(raw)
-    return response
+                    f"Failed to get task result ({reason})")
+        response = MessageToDict(response,
+                                 preserving_proto_field_name=True,
+                                 use_integers_for_enums=True)
+        return base64.b64decode(response["result"]["Ok"]["tags_map"][tag])
diff --git a/tests/scripts/functional_tests.py b/tests/scripts/functional_tests.py
index b7e248b9..04bb223c 100755
--- a/tests/scripts/functional_tests.py
+++ b/tests/scripts/functional_tests.py
@@ -33,6 +33,14 @@ from OpenSSL.crypto import load_certificate, FILETYPE_PEM, FILETYPE_ASN1
 from OpenSSL.crypto import X509Store, X509StoreContext
 from OpenSSL import crypto
 
+import h2.connection
+import h2.events
+
+from io import BytesIO
+from h2.config import H2Configuration
+from urllib.parse import unquote
+from teaclave_authentication_service_pb2 import UserLoginRequest, UserLoginResponse
+
 HOSTNAME = 'localhost'
 AUTHENTICATION_SERVICE_ADDRESS = (HOSTNAME, 7776)
 CONTEXT = ssl._create_unverified_context()
@@ -52,19 +60,6 @@ else:
     ENCLAVE_INFO_PATH = "../../release/tests/enclave_info.toml"
 
 
-def write_message(sock, message):
-    message = json.dumps(message)
-    message = message.encode()
-    sock.write(struct.pack(">Q", len(message)))
-    sock.write(message)
-
-
-def read_message(sock):
-    response_len = struct.unpack(">Q", sock.read(8))
-    response = sock.read(response_len[0])
-    return response
-
-
 def verify_report(cert, endpoint_name):
 
     def load_certificates(pem_bytes):
@@ -121,50 +116,114 @@ def verify_report(cert, endpoint_name):
         raise Exception("mr_signer error")
 
 
+def encode_message(message):
+    message_bin = message.SerializeToString()
+    header = struct.pack('?', False) + struct.pack('>I', len(message_bin))
+    return header + message_bin
+
+
+def decode_message(message_bin, message_type):
+    f = BytesIO(message_bin)
+    meta = f.read(5)
+    message_len = struct.unpack('>I', meta[1:])[0]
+    message_body = f.read(message_len)
+    message = message_type.FromString(message_body)
+    return message
+
+
 class TestAuthenticationService(unittest.TestCase):
 
     def setUp(self):
         sock = socket.create_connection(AUTHENTICATION_SERVICE_ADDRESS)
+        CONTEXT.set_alpn_protocols(['h2'])
         self.socket = CONTEXT.wrap_socket(sock, server_hostname=HOSTNAME)
         cert = self.socket.getpeercert(binary_form=True)
         verify_report(cert, "authentication")
+        config = H2Configuration(client_side=True, header_encoding='ascii')
+        self.connection = h2.connection.H2Connection(config)
+        self.connection.initiate_connection()
+        self.socket.sendall(self.connection.data_to_send())
+        self.stream_id = 1
+
+    def set_headers(self, method_path):
+        headers = [(':method', 'POST'), (':path', method_path),
+                   (':authority', HOSTNAME), (':scheme', 'https'),
+                   ('content-type', 'application/grpc')]
+        return headers
+
+    def send_message(self, message, method_path):
+        headers = self.set_headers(method_path)
+        self.connection.send_headers(self.stream_id, headers)
+        message_data = encode_message(message)
+        self.connection.send_data(self.stream_id,
+                                  message_data,
+                                  end_stream=True)
+        self.socket.sendall(self.connection.data_to_send())
+
+    def recv_message(self):
+        body = None
+        headers = None
+        response_stream_ended = False
+        max_frame_size = self.connection.max_outbound_frame_size
+        print(max_frame_size)
+        while not response_stream_ended:
+            # read raw data from the socket
+            data = self.socket.recv(max_frame_size)
+            if not data:
+                break
+
+            # feed raw data into h2, and process resulting events
+            events = self.connection.receive_data(data)
+            for event in events:
+                if isinstance(event, h2.events.ResponseReceived):
+                    headers = dict(event.headers)
+                if isinstance(event, h2.events.DataReceived):
+                    # update flow control so the server doesn't starve us
+                    self.connection.acknowledge_received_data(
+                        event.flow_controlled_length, event.stream_id)
+                    # more response body data received
+                    body += event.data
+                if isinstance(event, h2.events.StreamEnded):
+                    # response body completed, let's exit the loop
+                    response_stream_ended = True
+                    break
+            # send any pending data to the server
+            self.socket.sendall(self.connection.data_to_send())
+        return (headers, body)
 
     def tearDown(self):
+        self.connection.close_connection()
+        self.socket.sendall(self.connection.data_to_send())
         self.socket.close()
 
     def test_invalid_request(self):
+        path = '/teaclave_authentication_service_proto.TeaclaveAuthenticationApi/InvalidRequest'
         user_id = "invalid_id"
         user_password = "invalid_password"
 
-        message = {
-            "invalid_request": "user_login",
-            "id": user_id,
-            "password": user_password
-        }
-        write_message(self.socket, message)
+        message = UserLoginRequest(id=user_id, password=user_password)
+        self.send_message(message, path)
 
-        response = read_message(self.socket)
-        self.assertEqual(
-            response, b'{"result":"err","request_error":"invalid request"}')
+        (headers, response) = self.recv_message()
+        self.assertEqual(response, None)
+        # https://grpc.github.io/grpc/core/md_doc_statuscodes.html
+        # grpc status UNIMPLEMENTED: 12
+        self.assertEqual(headers['grpc-status'], '12')
 
     def test_login_permission_denied(self):
+        path = '/teaclave_authentication_service_proto.TeaclaveAuthenticationApi/UserLogin'
         user_id = "invalid_id"
         user_password = "invalid_password"
 
-        message = {
-            "message": {
-                "user_login": {
-                    "id": user_id,
-                    "password": user_password
-                }
-            }
-        }
-        write_message(self.socket, message)
-
-        response = read_message(self.socket)
-        self.assertEqual(
-            response,
-            b'{"result":"err","request_error":"authentication failed"}')
+        message = UserLoginRequest(id=user_id, password=user_password)
+        self.send_message(message, path)
+        (headers, body) = self.recv_message()
+        self.assertEqual(body, None)
+        self.assertEqual(headers['grpc-status'], '16')
+        message = unquote(headers['grpc-message'],
+                          encoding='utf-8',
+                          errors='replace')
+        self.assertEqual(message, 'authentication failed')
 
 
 if __name__ == '__main__':


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org