Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace current rpc with grpc #691

Merged
merged 4 commits into from
Jun 5, 2023
Merged

Conversation

GeminiCarrie
Copy link
Contributor

@GeminiCarrie GeminiCarrie commented May 16, 2023

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

This PR replaces current rpc with grpc.

issues

Type of change (select or add applied and delete the others)

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • API change with a documentation update
  • Additional test coverage
  • Code cleanup or just sync with upstream third-party crates

How has this been tested?

Checklist

  • Fork the repo and create your branch from master.
  • If you've added code that should be tested, add tests.
  • If you've changed APIs, update the documentation.
  • Ensure the tests pass (see CI results).
  • Make sure your code lints/format.

@@ -152,7 +152,13 @@ run_functional_tests() {

./teaclave_functional_tests -t end_to_end

# Run script tests
python3 -m grpc_tools.protoc \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we abstract these commands into a function? It seems to appear in many places.

@@ -58,10 +58,12 @@ simple_asn1 = { git = "https://github.com/acw/simple_asn1", rev = "7db7a48
gbdt = { git = "https://github.com/apache/incubator-teaclave-crates" }
getrandom = { git = "https://github.com/apache/incubator-teaclave-crates" }
image = { git = "https://github.com/apache/incubator-teaclave-crates" }
mio = { git = "https://github.com/GeminiCarrie/incubator-teaclave-crates", branch = "rustls_0.19.1"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rpc/README.md Outdated
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 represent a connection to the target service. Clients can use
the channel to send requests. When constructing a client, you can use the `SgxTrustedTlsClientConfig` to setup TLS and attestation configs, so that we 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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attested => attest

rpc/README.md Outdated

Similar with other RPC frameworks, there are several concepts of RPC in
Teaclave.
Re-export `tonic` to support general gRPC framework. `tonic` is a gRPC over HTTP/2 implementation focused on high performance, interoperability, and flexibility.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A link to tonic website can be given here.

rpc/README.md Outdated
messages, and forwarding requests to certain service. Similar with channel in
Teaclave, we implement `SgxTrustedTlsServer`, which can establish an attested TLS
channel with clients.
Server is an entity to listening a network address, processing incoming messages, and forwarding requests to certain service. Similar with the client, you can use `SgxTrustedTlsServerConfig` to setup TLS and attestation configs for chanenel with clients.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please seperate this one line to different ones as the left does for easy reading.

TeaclaveServiceResponseError::RequestError(error.to_string())
let msg = error.to_string();
let code = match error {
SchedulerServiceError::StorageError | SchedulerServiceError::TaskQueueEmpty => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems TaskQueueEmpty is not neccary to be data loss.

TeaclaveServiceResponseError::RequestError(error.to_string())
let msg = error.to_string();
let code = match error {
StorageServiceError::Database(_) => Code::DataLoss,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is database error necessarily be a data loss?

{
*ncases += 1;

let t = || -> f64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please resue the code of function test.

let response = self.get(r)?;
Ok(response).map(TeaclaveStorageResponse::Get)
}
TeaclaveStorageRequest::Put(r) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the code can be simplified by combinding different lines.

}

#[teaclave_rpc::async_trait]
impl TeaclaveStorage for ProxyService {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first inputs are all self. How about using an associated function here?

@GeminiCarrie GeminiCarrie force-pushed the grpc_new branch 3 times, most recently from 154ef58 to 8beec45 Compare June 2, 2023 08:27
Copy link
Contributor

@henrysun007 henrysun007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@henrysun007 henrysun007 merged commit 9b66438 into apache:master Jun 5, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants