-
Notifications
You must be signed in to change notification settings - Fork 31
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
blockchain_block_v1 is not defined #155
Comments
Looks like you may be missing some include paths for the protoc command |
If i run the current path:
proto files in this path:
protoc cmd i tried:
same error:
but the
Any suggestion? I don't what i can do to make it works |
Does your protoc not take a |
The |
Today I encountered the same problem; the issue is that the So changing the definition to message blockchain_block_v1 {
bytes prev_hash = 1;
uint64 height = 2;
uint64 time = 3;
uint64 hbbft_round = 4;
repeated helium.blockchain_txn transactions = 5; //<= change this line to fix it
repeated blockchain_signature_v1 signatures = 6;
uint64 election_epoch = 7;
uint64 epoch_start = 8;
bytes rescue_signature = 9;
repeated blockchain_seen_vote_v1 seen_votes = 10;
bytes bba_completion = 11;
bytes snapshot_hash = 12;
repeated bytes rescue_signatures = 13;
} Not sure why this only seems to be a problem for the golang generation; it seems this is a bug in the proto file and all generator should have the same issue. |
Have a PR? The CI will show errors if this works or is broken. It’s not a problem for JavaScript, rust, erlang and C/C++ |
@madninja If you want I can create a PR, but for the golang generation to work I also needed 1 other change I have applied both changes in the project I am currently working on: I also found a commit in the python PR that had similar changes With these changes I can build all definitions for golang .. but it is still a bit complicated: you'll still need to map all files to a golang package and all services need to be in a separate package, otherwise things like the package="github.com/thisisdevelopment/helium-route-updater/pkg"
dir="api/helium"
go_opts="--go_opt=module=${package}"
grpc_opts="--go-grpc_opt=module=${package}"
for file in $(find ${dir} -not -path "${dir}/service/*" -name "*.proto"); do
file=${file##$dir/}
files="${files} ${file}"
subdir=$(dirname $file)
file_package=${package}/${dir}
if [ "${subdir}" != "." ]; then
file_package="${file_package}/${subdir}"
fi
go_opts="${go_opts} --go_opt=M${file}=${file_package}"
grpc_opts="${grpc_opts} --go-grpc_opt=M${file}=${file_package}"
done
protoc -I=$dir --go_out=pkg --go-grpc_out=pkg ${go_opts} ${grpc_opts} $files
for file in ${dir}/service/*.proto; do
service=${file##$dir/service/}
service_name=${service%%.proto}
protoc -I=$dir --go_out=pkg --go-grpc_out=pkg ${go_opts} ${grpc_opts} --go_opt=Mservice/${service}=${package}/${dir}/service/${service_name} --go-grpc_opt=Mservice/${service}=${package}/${dir}/service/${service_name} service/${service}
done ^ You can find this here |
Ugh yeah. I remember this. It’d break a number tot downstream applications |
It seems the protoc compiler behaves differently depending on the order of it encountering dupliclate symbol names: https://github.com/protocolbuffers/protobuf/blob/364328858e2694f4f85613cf168a96053eb434d6/src/google/protobuf/descriptor.cc#L4696 It seems the intent is to prevent it, but the current implementation allows it under some circumstances |
After some more testing I found that the error messages generated by protoc are order dependant; but it does generate errors in both cases; just different ones
syntax = "proto3";
package test;
option go_package = "github.com/thisisdevelopment/helium-route-updater/test";
enum origin {
hello = 0;
world = 1;
}
syntax = "proto3";
package test.world;
option go_package = "github.com/thisisdevelopment/helium-route-updater/test/world";
enum World {
Europe = 0;
Asia = 1;
}
The real reason the other builds are not giving errors is that they simply don't build all proto files:
const SERVICES: &[&str] = &[
"src/service/router.proto",
"src/service/state_channel.proto",
"src/service/local.proto",
"src/service/gateway.proto",
"src/service/transaction.proto",
"src/service/follower.proto",
"src/service/poc_mobile.proto",
"src/service/poc_lora.proto",
"src/service/poc_entropy.proto",
"src/service/packet_router.proto",
"src/service/iot_config.proto",
"src/service/downlink.proto",
"src/service/packet_verifier.proto",
];
const MESSAGES: &[&str] = &[
"src/blockchain_txn.proto",
"src/entropy.proto",
"src/data_rate.proto",
"src/region.proto",
"src/mapper.proto",
"src/reward_manifest.proto",
"src/blockchain_region_param_v1.proto",
]; Note that both builds have different proto files that they compile! And if I try to include all protofiles in the cpp build it will give the same errors as with the golang output:
After fixing that error, the error caused by the duplicate symbols pops up:
|
I'm tring to generate the pb file for my golang project, but every time i execute the
protoc
command i got some error.the protoc command:
output i got:
Can someone tell me how to fix this?
By the way i added
option go_package = "./proto";
for every porot file, so it's probably not a go-generate problemThe text was updated successfully, but these errors were encountered: