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

Experiment with passing handles between nodes in Protobufs #673

Closed
1 of 2 tasks
wildarch opened this issue Mar 5, 2020 · 3 comments · Fixed by #1108
Closed
1 of 2 tasks

Experiment with passing handles between nodes in Protobufs #673

wildarch opened this issue Mar 5, 2020 · 3 comments · Fixed by #1108
Assignees

Comments

@wildarch
Copy link
Contributor

wildarch commented Mar 5, 2020

This would allow nodes to share channels with each other simply by passing them over an existing channel, encoding them in an ordinary protocol buffer.

The approach I am proposing for now is that we introduce methods in the Oak ABI to generate a kind of 'invite token' for a combination of a channel handle to send and a channel handle over which to send the token. This token can then be transmitted as part of an ordinary protobuf message, and the receiver can call upon the Oak ABI to exchange the invite token for an actual handle.

The experiment should answer the following questions:

  • Can we make this work in a way that is ergonomic and safe for users?
  • Can we ensure handles are passed in a way that is type-safe?

Related to #426 and #420.

@wildarch
Copy link
Contributor Author

@tiziano88 could you assign this bug to me btw?

@wildarch
Copy link
Contributor Author

wildarch commented Mar 27, 2020

I have some very early POC in https://github.com/wildarch/handle_extract (requires https://github.com/wildarch/prost as well). Right now this maps a proto like:

message TestMessage {
  oak.handle.Sender sender = 1 [(oak.handle.handle_type) = "TestHandleType"];
}

message TestHandleType {
  // ...
}

to a Rust struct that looks like:

struct TestMessage {
    sender: Sender<TestHandleType>,
}

And the other way around.

Next step will be to implement a procedural macro that generates an implementation of a trait like:

pub trait HandleExtract {
    fn extract(&mut self, handles: &mut Vec<Handle>);
    fn inject(&mut self, handles: &[Handle]);
}

@wildarch
Copy link
Contributor Author

wildarch commented Apr 3, 2020

The POC in https://github.com/wildarch/handle_extract now implements extraction and injection in a type-safe manner 🎉.

I'll now start working towards:

  • Minimizing the number of patches necessary in Prost to support the custom code generation that we need
  • Integrating the solution with Oak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant