-
Notifications
You must be signed in to change notification settings - Fork 40
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
fix: only rebuild proto on changes #412
Conversation
1a7b766
to
8398d00
Compare
As a side note - it feels weird putting "fixes" under |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you! I left one question inline.
I am however unsure why the generated directory is included at all -- maybe to rebuild it if it accidentally got deleted? Though that seems excessive as the dev can see this happened using git.
I believe the motivation for this is described in #9 (comment) - but I'm not sure if it is still valid.
As a side note - it feels weird putting "fixes" under
Enhancements
in the changelog. Should there also be aFixes
?
Yes, there should be Fixes
section as well. Overall, I think we should have 3 categories (or maybe more) in the changelog: Features
, Enhancements
, and Fixes
(we had 2 of these in the last release).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This is not a super-deep review, but I did leave a couple of small comments inline. Regarding the general approach, I have the following comments:
- I would prefer to keep
proto
andrpc-proto
crates separate. The main reason is thatrpc-proto
is meant to be the interface definition only for the RPC component of the node (it doesn't quite work like that right now, but that's a separate issue) and it is meant to be consumed by external users. Whileproto
is mean to contain interfaces of all node components and to be used primarily internally. - I do like adding the
make proto
command to the Makefile and having this be the only way to re-build generated files and copy protobuf files intorpc-proto
. Whether the implementation of this command relies on a separate binary or build scripts gated by an environment variable is not super important - but I do think that using just the build scripts may be cleaner here. - I think it would be great if we added a CI check to make sure that updates to
.proto
files are properly propagated (i.e., someone didn't forget to run themake proto
command).
So, my recommendations for this PR would be:
- Revert the merging of
proto
andrpc-proto
crates. - Add
proto
command to the Makefile.
a. If possible, rely on the build scripts to recompile/copy the protobuf files. For example, maybe this command would just doBUILD_PROTO=1 cargo build
and the build scripts would be fully conditional onBUILD_PROTO
variable.
b. If the above doesn't work for some reason, create a separate binary to perform this tasks (similar to what is already in this PR). - Add a CI check to make sure
make proto
command does not cause a diff.
Cargo.toml
Outdated
"crates/rpc", | ||
"crates/store", | ||
"crates/utils", | ||
"crates/test-macro", | ||
] | ||
default-members = ["bin/faucet", "bin/node", "crates/proto", "crates/rpc-proto"] | ||
default-members = ["bin/faucet", "bin/node", "crates/proto"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering: do we need to have default-members
at all? If we don't have it, cargo build
etc. commands will be applied to all crates, right? Not sure that's a bad thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct; its actually somewhat annoying to have as you always have to include the package details for non-default-members.
I really wish github allowed replying to top level comments.. @bobbinth what about a more explicit approach of moving ownership of the proto definitions to the
Benefits:
|
e70b8e6
to
1d2e19c
Compare
I've implemented my latest idea. I'm waiting on CI to double-check that I don't need some --edit-- ah right this CI doesn't have nostd checks. Hmm. I can compile it locally without the std feature enabled but I'm unsure if that's sufficient evidence. I'm hoping to avoid adding |
crates/rpc-proto/src/lib.rs
Outdated
@@ -3,8 +3,7 @@ | |||
#[cfg(feature = "std")] | |||
extern crate std; | |||
|
|||
mod proto_files; | |||
pub use proto_files::PROTO_FILES; | |||
pub use miden_node_proto::PROTO_FILES; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is exporting a nostd
compliant const
from an otherwise non-compliant dependency fine? I think it is -- haven't experimented much with nostd
.
398d8c6
to
069dc2d
Compare
We can still add a CI check if we want; but should be difficult to get wrong with the build script |
I think this approach works, but I'm not sure I like it better than what we had before (assuming we get rid of the un-needed rebuilds). One reason is that I think there is benefit to keeping Another reason is that as I mentioned, ideally So, unless there are some complications (i.e., conditional build scripts don't work for some reason), I'd still prefer to keep the |
fbd5d66
to
8a224de
Compare
I've reverted to the original format and placing. I've just added a CI check which rebuilds and ensures there is no diff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good! Thank you!
/// Generate `mod.rs` which includes all files in the folder as submodules. | ||
fn generate_mod_rs(directory: impl AsRef<Path>) -> std::io::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
The proto files are being "rebuilt" on every compile at the moment. This is due to the
which is a directory that does not exist, causing it to trigger on every build.
There were several attempts at this; none were really good enough. My last attempt is changing very little but adds a few consistency improvements.
Notably, it adds a simple CI check to ensure changes the main
proto
files is propagated to all repo's which use them.To aid this, I've made the build script outputs more repeatable by