-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Automated generation of the Asc types
#3722
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
Conversation
* is to ToAscObj what Into is to From
Graph 360 enums
* didn't compile
* use non-zero data to test from_asc_bytes as well * just call to_asc_bytes to see if it panics because it now contains the padding logic * moved to runtime module * various other small refactorings and improvements
Add padding logic to derive(AscType) macro
maoueh
left a comment
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.
Can you also remove dead code that is commented but unsued.
My main concerns is the AssemblyScript padding that was introduced, just need to ensure we properly test it on existing subgraphs.
|
|
||
| let mut builder = tonic_build::configure().out_dir("src/protobuf"); | ||
|
|
||
| for (name, ptype) in types { |
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.
This will probably creates a lot of boilerplate in each of the chain we will support through Firehose.
We should probably have something in graph_chain_common that would do everything that is done here. Something like:
let mut builder = tonic_build::configure().out_dir("src/protobuf");
graph_chain_common::configure_tonic(builder, "proto/type.proto", "Cosmos")
Something in this line, can be done in another PR later also.
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.
yes, agree... for common code might be issues with proto file location as it's local to the crate. something to pay attention to
| @@ -0,0 +1,9 @@ | |||
| package firehose; | |||
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.
This can be re-used for all chains no?
Normally all packages should be fully qualifier but I see it's usage as a field descriptor in which case probably make sense to have firehose directly.
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.
Let's discuss
| if is_scalar(&tp_nm) { | ||
| format!("Option<{}>", tp_nm) | ||
| } else { | ||
| format!("graph::runtime::AscPtr<crate::protobuf::Asc{}>", tp_nm) |
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 imagine that's the reason for the introduction of the intermediary protobuf module. Should be documented in the top of the macro (each of them if it affects them all).
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.
there is https://crates.io/crates/protobuf (parser) and crate::protobuf
https://crates.io/crates/protobuf - is to parse proto files and annotate prost structs with meta info... unless we are missing your point... let's discuss
runtime/derive/src/lib.rs
Outdated
| } | ||
|
|
||
| //intended use is in build.rs with tonic_build's type_attribute(<...>, <...>) to generate type implementation of graph::runtime::ToAscObj | ||
| //attributes: optional list of required fields '__required__{name:TypeName}' and enumerations field decraration with types, i.e. sum{single: ModeInfoSingle,multi: ModeInfoMulti} |
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.
Do we still need support to manually pass required and enumeration explicitly?
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.
No, this is meta info derived from proto files
Co-authored-by: Matthieu Vachon <[email protected]>
evaporei
left a comment
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.
Congrats on making this one through 👏
I just added a few comments on very minor things to adjust.
After those I will definitely merge this ❤️
This PR resolves #2985 and #3011.