Skip to content

Commit

Permalink
Collin/update prost build (#307)
Browse files Browse the repository at this point in the history
* Fix prost build after upgrade to using buf

* Update somm_proto and prost build
  • Loading branch information
cbrit committed Jul 18, 2024
1 parent d8bdaeb commit cec0a52
Show file tree
Hide file tree
Showing 18 changed files with 892 additions and 5 deletions.
5 changes: 5 additions & 0 deletions prost_build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Rust Proto Bindings Build

## Notes

For some reason, the `type_attribute` config method is not working the the `CellarIdSet` type, therefore whenever `prost_build` gets run, we have to manually add the `serde::Deserialize` and `serde::Serialize` attributes to it.
4 changes: 4 additions & 0 deletions prost_build/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ fn compile_protos(out_dir: &Path, tmp_dir: &Path) {
config
.type_attribute("ScheduledCorkProposal", "#[derive(serde::Deserialize, serde::Serialize)]")
.type_attribute("AxelarScheduledCorkProposal", "#[derive(serde::Deserialize, serde::Serialize)]")
.type_attribute("AddPublisherProposal", "#[derive(serde::Deserialize, serde::Serialize)]")
.type_attribute("AddManagedCellarIDsProposalWithDeposit", "#[derive(serde::Deserialize, serde::Serialize)]")
.type_attribute("AddAxelarManagedCellarIDsProposalWithDeposit", "#[derive(serde::Deserialize, serde::Serialize)]")
.type_attribute("axelar_cork::CellarIdSet", "#[derive(serde::Deserialize, serde::Serialize)]")
.compile_protos(&protos, &proto_include_paths)
.unwrap();

Expand Down
4 changes: 4 additions & 0 deletions somm_proto/src/prost/auction.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ pub struct Params {
pub auction_price_decrease_acceleration_rate: ::prost::alloc::string::String,
#[prost(uint64, tag = "6")]
pub minimum_auction_height: u64,
/// value between 0 and 1 the determines the % of somm received from bids that
/// gets burned
#[prost(string, tag = "7")]
pub somm_burn_ratio: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsRequest {}
Expand Down
4 changes: 2 additions & 2 deletions somm_proto/src/prost/axelarcork.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct AxelarCorkResults {
#[prost(message, repeated, tag = "1")]
pub cork_results: ::prost::alloc::vec::Vec<AxelarCorkResult>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, ::prost::Message)]
pub struct CellarIdSet {
#[prost(uint64, tag = "1")]
pub chain_id: u64,
Expand Down Expand Up @@ -768,7 +768,7 @@ pub struct AddAxelarManagedCellarIDsProposal {
pub publisher_domain: ::prost::alloc::string::String,
}
/// AddAxelarManagedCellarIDsProposalWithDeposit is a specific definition for CLI commands
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, ::prost::Message)]
pub struct AddAxelarManagedCellarIDsProposalWithDeposit {
#[prost(string, tag = "1")]
pub title: ::prost::alloc::string::String,
Expand Down
4 changes: 2 additions & 2 deletions somm_proto/src/prost/cork.v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct CorkResult {
#[prost(string, tag = "4")]
pub approval_percentage: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, ::prost::Message)]
pub struct CellarIdSet {
#[prost(string, repeated, tag = "1")]
pub ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
Expand Down Expand Up @@ -402,7 +402,7 @@ pub struct AddManagedCellarIDsProposal {
pub publisher_domain: ::prost::alloc::string::String,
}
/// AddManagedCellarIDsProposalWithDeposit is a specific definition for CLI commands
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, ::prost::Message)]
pub struct AddManagedCellarIDsProposalWithDeposit {
#[prost(string, tag = "1")]
pub title: ::prost::alloc::string::String,
Expand Down
1 change: 1 addition & 0 deletions somm_proto/src/prost/cosmos.msg.v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions somm_proto/src/prost/cosmos.query.v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions somm_proto/src/prost/cosmos_proto.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion somm_proto/src/prost/pubsub.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub struct DefaultSubscription {
}
/// governance proposal to add a publisher, with domain, adress, and ca_cert the same as the Publisher type
/// proof URL expected in the format: https://<domain>/<address>/cacert.pem and serving cacert.pem matching ca_cert
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, ::prost::Message)]
pub struct AddPublisherProposal {
#[prost(string, tag = "1")]
pub title: ::prost::alloc::string::String,
Expand Down
4 changes: 4 additions & 0 deletions third_party/proto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Third party vendored protos

The primary proto generation now uses buf and the buf schema registry, but some of these vendored protos are still necessary because the Rust code generator, found under `prost_build` in the root directory, needs them.

30 changes: 30 additions & 0 deletions third_party/proto/cosmos/msg/v1/msg.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
syntax = "proto3";

package cosmos.msg.v1;

import "google/protobuf/descriptor.proto";

// TODO(fdymylja): once we fully migrate to protov2 the go_package needs to be updated.
// We need this right now because gogoproto codegen needs to import the extension.
option go_package = "github.com/cosmos/cosmos-sdk/types/msgservice";

extend google.protobuf.ServiceOptions {
// service indicates that the service is a Msg service and that requests
// must be transported via blockchain transactions rather than gRPC.
// Tooling can use this annotation to distinguish between Msg services and
// other types of services via reflection.
bool service = 11110000;
}

extend google.protobuf.MessageOptions {
// signer must be used in cosmos messages in order
// to signal to external clients which fields in a
// given cosmos message must be filled with signer
// information (address).
// The field must be the protobuf name of the message
// field extended with this MessageOption.
// The field must either be of string kind, or of message
// kind in case the signer information is contained within
// a message inside the cosmos message.
repeated string signer = 11110000;
}
35 changes: 35 additions & 0 deletions third_party/proto/cosmos/query/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
syntax = "proto3";

package cosmos.query.v1;

import "google/protobuf/descriptor.proto";

// TODO: once we fully migrate to protov2 the go_package needs to be updated.
// We need this right now because gogoproto codegen needs to import the extension.
option go_package = "github.com/cosmos/cosmos-sdk/types/query";

extend google.protobuf.MethodOptions {
// module_query_safe is set to true when the query is safe to be called from
// within the state machine, for example from another module's Keeper, via
// ADR-033 calls or from CosmWasm contracts.
// Concretely, it means that the query is:
// 1. deterministic: given a block height, returns the exact same response
// upon multiple calls; and doesn't introduce any state-machine-breaking
// changes across SDK patch version.
// 2. consumes gas correctly.
//
// If you are a module developer and want to add this annotation to one of
// your own queries, please make sure that the corresponding query:
// 1. is deterministic and won't introduce state-machine-breaking changes
// without a coordinated upgrade path,
// 2. has its gas tracked, to avoid the attack vector where no gas is
// accounted for on potentially high-computation queries.
//
// For queries that potentially consume a large amount of gas (for example
// those with pagination, if the pagination field is incorrectly set), we
// also recommend adding Protobuf comments to warn module developers
// consuming these queries.
//
// When set to true, the query can safely be called
bool module_query_safe = 11110001;
}
16 changes: 16 additions & 0 deletions third_party/proto/cosmos_proto/cosmos.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package cosmos_proto;

import "google/protobuf/descriptor.proto";

option go_package = "github.com/regen-network/cosmos-proto";

extend google.protobuf.MessageOptions {
string interface_type = 93001;

string implements_interface = 93002;
}

extend google.protobuf.FieldOptions {
string accepts_interface = 93001;
}
145 changes: 145 additions & 0 deletions third_party/proto/gogoproto/gogo.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Protocol Buffers for Go with Gadgets
//
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax = "proto2";
package gogoproto;

import "google/protobuf/descriptor.proto";

option java_package = "com.google.protobuf";
option java_outer_classname = "GoGoProtos";
option go_package = "github.com/gogo/protobuf/gogoproto";

extend google.protobuf.EnumOptions {
optional bool goproto_enum_prefix = 62001;
optional bool goproto_enum_stringer = 62021;
optional bool enum_stringer = 62022;
optional string enum_customname = 62023;
optional bool enumdecl = 62024;
}

extend google.protobuf.EnumValueOptions {
optional string enumvalue_customname = 66001;
}

extend google.protobuf.FileOptions {
optional bool goproto_getters_all = 63001;
optional bool goproto_enum_prefix_all = 63002;
optional bool goproto_stringer_all = 63003;
optional bool verbose_equal_all = 63004;
optional bool face_all = 63005;
optional bool gostring_all = 63006;
optional bool populate_all = 63007;
optional bool stringer_all = 63008;
optional bool onlyone_all = 63009;

optional bool equal_all = 63013;
optional bool description_all = 63014;
optional bool testgen_all = 63015;
optional bool benchgen_all = 63016;
optional bool marshaler_all = 63017;
optional bool unmarshaler_all = 63018;
optional bool stable_marshaler_all = 63019;

optional bool sizer_all = 63020;

optional bool goproto_enum_stringer_all = 63021;
optional bool enum_stringer_all = 63022;

optional bool unsafe_marshaler_all = 63023;
optional bool unsafe_unmarshaler_all = 63024;

optional bool goproto_extensions_map_all = 63025;
optional bool goproto_unrecognized_all = 63026;
optional bool gogoproto_import = 63027;
optional bool protosizer_all = 63028;
optional bool compare_all = 63029;
optional bool typedecl_all = 63030;
optional bool enumdecl_all = 63031;

optional bool goproto_registration = 63032;
optional bool messagename_all = 63033;

optional bool goproto_sizecache_all = 63034;
optional bool goproto_unkeyed_all = 63035;
}

extend google.protobuf.MessageOptions {
optional bool goproto_getters = 64001;
optional bool goproto_stringer = 64003;
optional bool verbose_equal = 64004;
optional bool face = 64005;
optional bool gostring = 64006;
optional bool populate = 64007;
optional bool stringer = 67008;
optional bool onlyone = 64009;

optional bool equal = 64013;
optional bool description = 64014;
optional bool testgen = 64015;
optional bool benchgen = 64016;
optional bool marshaler = 64017;
optional bool unmarshaler = 64018;
optional bool stable_marshaler = 64019;

optional bool sizer = 64020;

optional bool unsafe_marshaler = 64023;
optional bool unsafe_unmarshaler = 64024;

optional bool goproto_extensions_map = 64025;
optional bool goproto_unrecognized = 64026;

optional bool protosizer = 64028;
optional bool compare = 64029;

optional bool typedecl = 64030;

optional bool messagename = 64033;

optional bool goproto_sizecache = 64034;
optional bool goproto_unkeyed = 64035;
}

extend google.protobuf.FieldOptions {
optional bool nullable = 65001;
optional bool embed = 65002;
optional string customtype = 65003;
optional string customname = 65004;
optional string jsontag = 65005;
optional string moretags = 65006;
optional string casttype = 65007;
optional string castkey = 65008;
optional string castvalue = 65009;

optional bool stdtime = 65010;
optional bool stdduration = 65011;
optional bool wktpointer = 65012;

optional string castrepeated = 65013;
}
31 changes: 31 additions & 0 deletions third_party/proto/google/api/annotations.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2015 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.api;

import "google/api/http.proto";
import "google/protobuf/descriptor.proto";

option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";

extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
Loading

0 comments on commit cec0a52

Please sign in to comment.