Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@pienkowb
Copy link
Contributor

This PR resolves #2985 and #3011.

maoueh
maoueh previously requested changes Jul 25, 2022
Copy link
Contributor

@maoueh maoueh left a 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 {
Copy link
Contributor

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.

Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor

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)
Copy link
Contributor

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).

Copy link
Contributor

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

}

//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}
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor

@evaporei evaporei left a 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 ❤️

@evaporei evaporei dismissed maoueh’s stale review August 9, 2022 12:40

requested changes addressed

@evaporei evaporei merged commit 155c4f4 into graphprotocol:master Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automated type generation for new chains (Rust <> AS types)

6 participants