feat: remove miden-rpc-proto crate and add miden-node-proto-build#723
feat: remove miden-rpc-proto crate and add miden-node-proto-build#723Mirko-von-Leipzig merged 26 commits intonextfrom
miden-rpc-proto crate and add miden-node-proto-build#723Conversation
d2e396e to
55baec6
Compare
rpc crate
rpc craterpc crate
284f095 to
db440c7
Compare
rpc craterpc crate and refactor proto codegen
bobbinth
left a comment
There was a problem hiding this comment.
Thank you! Not a review yet, but I wanted to understand the overall approach. The way I see it is as follows:
- We still keep protobuf files in the
protodirectory in the root of the repo as the "source of truth". - These files are then copied to the
miden-node-proto-buildcrate during the build process and are used to set the protobuf files for the tonic builder (which is passed-in externally).- I actually didn't see the code that copies the file from the root into the crate - but maybe I missed it.
- Then, in
miden-node-protowe importmiden-node-proto-buildas a dependency and use it to actually generate the bindings. - If someone wanted to use the protobuf files (e.g.,
miden-client) they would addmiden-node-proto-buildas a build dependency and this would allow them to generate the desired bindings.
Assuming this is roughly correct, I think it works (and is probably a cleaner design than what we had before) - but I don't think it addresses the original issue. That is, we still need to either remove the client code from the PRC crate or somehow simplify the support for TLS.
I also think that people will still probably try to use miden-node-rpc to access the RPC component as the client and maybe pointing them to miden-node-proto-build may be too much of a burden.
One solution is to add miden-node-rpc-client crate (which would basically replace the old miden-rpc-proto crate). This crate would expose bindings with TLS and other features configured. This crate can then be directly used in miden-client (i.e., no need to build anything).
Another option is to use a single miden-node-rpc crate but have client and server features. The server feature would be used by the node internally, and the client feature would be used externally (e.g., by the miden-client). This may be a bit more complicated to implement though.
I was hoping to only have the proto files directly in the
I agree they may still do this, but I think we can minimize this with a Warning This crate is intended for internal use only. For gRPC bindings please see the crate . This crate does not support TLS and cannot be used as a client for the official RPC endpoints. and a proper example in the
My hope is really to push users to the builder only. They may need both client and server for RPC - the latter for testing, or to create a proxy. In this case I think having both exposed by default, along with a solid example, should suffice as a jumping off point for users. The only suboptimal point for me is the lack of domain types - but tbh they shouldn't be relying on our "internal" types, that just shows a lack of documentation in our gRPC API. |
Yeah, I was mostly concerned about discoverability. Adding this to docs could work - but it'll need to be pretty prominent otherwise those searching for proto files won't find them. Moving the crate to the root level may be better.
For testing, just RPC is not enough - right? They'd have to run the full node. I think the builders could be for more sophisticated users and if we can provide the required functionality via a simple import (assuming it doesn't complicate things too much for us), that would be better. But maybe this can be a separate issue. To summarize:
|
It depends on what they want or need to test. I imagine basic testing could be done with server stubs and would be how I do unit testing. Or maybe by using snapshots - create the snapshots by running a node once, then use the RPC server to serve the snapshots for actual testing and CI. Its a pattern I'd like to move towards as well for more complex setups especially if it involved proving or things like proof-of-work.
I'm not convinced we want/need this, but let's tackle that separately :)
Correct yes. |
@bobbinth I am not sure if I am completely on the same page on this. In the rpc crate there is only a RpcApi server component, that is used on the node binary. Which client code do you mean? |
He meant the client exposed from |
rpc crate and refactor proto codegenproto crate and refactor proto codegen
There is the https://docs.rs/tonic-build/latest/tonic_build/struct.Builder.html#method.compile_fds_with_config which compiles using the file descriptors alone. I think the file descriptors fully describe the |
I'll revive that discussion and we can discuss it there. Let's leave that suggestion out of this PR :) |
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you. I left some comments inline.
One other thing: we should still remove the ApiClient from the rpc crate, right?
|
@bobbinth thanks! I addressed the comments.
About this, I am still not sure if I understand which code you mean. Maybe you mean the rpc ApiClient from the |
|
@bobbinth There is no ApiClient in the An alternative could be to add again a feature flag to the To actually delete the ApiClient from the crate we need a different solution. It could be to add bindings generation for the faucet, though I think that would add too much unnecessary boilerplate. Or perhaps to move the rpc client into a separate new crate. |
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you! I left a few more minor comments line.
There is no ApiClient in the
miden-node-rpccrate.
I was going more from this statement from the original issue:
Some users are using the gRPC client from our
rpccrate -- however this crate does not enable TLS because internally our infrastructure is still http only. This means users of this client need to additionally overridetonicwith the TLS features. This is obscure and the client errors aren't very helpful in pointing out the issue since its just a connection rejection.
But maybe this meant rpc-client, which we now have deleted? If so, then probably nothing else to do here.
Mirko-von-Leipzig
left a comment
There was a problem hiding this comment.
Thanks! I know this was quite the back and forth :)
There will likely be some follow-up items like creating an example, and refactoring our internal RPC crate, but that can probably be done in a separate PR.
bobbinth
left a comment
There was a problem hiding this comment.
All looks good! Thank you!
proto crate and refactor proto codegenmiden-rpc-proto crate and add miden-node-proto-build
Closes #658.
Removed the
miden-rpc-protocrate.Instead, added
miden-node-proto-build, that exposesProtoBuilderthat makes the bindings generation easier. This crate has a "internal" feature. When set, the ProtoBuilder compile() function will generate all the bindings (rpc, block-producer, and store, including the clients). If the feature is not set, only the rpc component will be built.