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:46 UTC

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

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