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

Implement Roughtime client pseudo-node #1086

Merged
merged 3 commits into from
Jun 8, 2020

Conversation

conradgrobler
Copy link
Collaborator

Checklist

  • Pull request affects core Oak functionality (e.g. runtime, SDK, ABI)
    • I have written tests that cover the code changes.
    • I have checked that these tests are run by Cloudbuild
    • I have updated documentation accordingly.
    • I have raised an issue to
      cover any TODOs and/or unfinished work.
  • Pull request includes prototype/experimental work that is under
    construction.

Fixes #730

Copy link
Contributor

@daviddrysdale daviddrysdale left a comment

Choose a reason for hiding this comment

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

Nice to see Roughtime functionality returning to the Runtime!

DEFAULT_MIN_OVERLAPPING_INTERVALS, DEFAULT_SERVER_RETRIES, DEFAULT_TIMEOUT_SECONDS,
},
};

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think we're mostly avoiding blank lines in use statements, and letting rustfmt handle the ordering (which will keep crate:: lines at the top I think).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed.

},
OakStatus,
};
use prost::Message as _;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is the as _ needed? I couldn't immediately see a clashing Message.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed. I thought it was needed to stop cargo from complaining about unused imports, but cargo did not complain after removing it.

match invocation.receive_request(runtime) {
Ok(request) => {
if request.method_name != "/oak.roughtime.RoughtimeService/GetRoughtime" {
let message = format!("Unknwon method_name: {}", request.method_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

s/Unknwon/Unknown/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

let mut message = Vec::new();
match reply.encode(&mut message) {
Ok(_) => {
let response = GrpcResponse {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: having both reply and response is a bit confusing; maybe rsp and grpc_rsp or somesuch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed.

}

// Interface exposed by the Roughtime client pseudo-Node to other nodes over a
// pair of Oak Channels.
service RoughtimeService {
rpc GetRoughTime(RoughTimeRequest) returns (RoughTimeResponse);
rpc GetRoughtime(RoughtimeRequest) returns (RoughtimeResponse);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably stick to standard naming conventions if possible: https://cloud.google.com/apis/design/naming_convention#method_names

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed.

Comment on lines 52 to 56
let timeout_seconds = if config.timeout_seconds == 0 {
DEFAULT_TIMEOUT_SECONDS
} else {
config.timeout_seconds as u64
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

If these values are meant to be optional, then perhaps should use proper types in the protos, e.g. https://developers.google.com/protocol-buffers/docs/reference/csharp/class/google/protobuf/well-known-types/u-int32-value, which prost should convert into Option<u32> , which you can then use as config.server_retries.unwrap_or(DEFAULT_SERVER_RETRIES) etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

fn process_invocation(&self, runtime: &RuntimeProxy, invocation: &Invocation) {
match invocation.receive_request(runtime) {
Ok(request) => {
if request.method_name != "/oak.roughtime.RoughtimeService/GetRoughtime" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be auto generated at some point? Do we have a GitHub issue to track that already?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created #1113

@conradgrobler conradgrobler force-pushed the rt_node branch 3 times, most recently from 7c79dd7 to a914ee1 Compare June 8, 2020 10:19
@@ -119,10 +121,10 @@ message RoughtimeClientConfiguration {
repeated RoughtimeServer servers = 1;
// Connection parameters; default values will be used if any parameter is
// zero.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// zero.
// unset.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@conradgrobler conradgrobler merged commit a2f74a4 into project-oak:master Jun 8, 2020
@conradgrobler conradgrobler deleted the rt_node branch June 8, 2020 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Roughtime from Rust
4 participants