Skip to content

Commit

Permalink
feat!(proto) remove optional fields in protos
Browse files Browse the repository at this point in the history
The cosmos fork of gogoproto, used to generate golang code from BSR,
doesn't support "optional" fields in proto3 syntax. Rather than sort
that out, we're removing use of optional to unblock integration work on
interchaintest.

This commit updates the protos; still to come is the required Rust
changes for compatibility.

Refs #2933.
  • Loading branch information
conorsch committed Aug 17, 2023
1 parent 897b320 commit fa59fa6
Show file tree
Hide file tree
Showing 17 changed files with 1,761 additions and 1,821 deletions.
16 changes: 6 additions & 10 deletions crates/proto/src/gen/penumbra.core.governance.v1alpha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,16 @@ pub mod proposal_outcome {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Failed {
/// The proposal was withdrawn during the voting period.
#[prost(string, optional, tag = "1")]
pub withdrawn_with_reason: ::core::option::Option<
::prost::alloc::string::String,
>,
#[prost(string, tag = "1")]
pub withdrawn_with_reason: ::prost::alloc::string::String,
}
/// The proposal did not pass, and was slashed.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Slashed {
/// The proposal was withdrawn during the voting period.
#[prost(string, optional, tag = "1")]
pub withdrawn_with_reason: ::core::option::Option<
::prost::alloc::string::String,
>,
#[prost(string, tag = "1")]
pub withdrawn_with_reason: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
Expand Down Expand Up @@ -355,8 +351,8 @@ pub mod proposal {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Signaling {
/// The commit to be voted upon, if any is relevant.
#[prost(string, optional, tag = "1")]
pub commit: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, tag = "1")]
pub commit: ::prost::alloc::string::String,
}
/// An emergency proposal can be passed instantaneously by a 2/3 majority of validators, without
/// waiting for the voting period to expire.
Expand Down
30 changes: 15 additions & 15 deletions crates/proto/src/gen/penumbra.core.governance.v1alpha1.serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1361,12 +1361,12 @@ impl serde::Serialize for proposal::Signaling {
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.commit.is_some() {
if !self.commit.is_empty() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.governance.v1alpha1.Proposal.Signaling", len)?;
if let Some(v) = self.commit.as_ref() {
struct_ser.serialize_field("commit", v)?;
if !self.commit.is_empty() {
struct_ser.serialize_field("commit", &self.commit)?;
}
struct_ser.end()
}
Expand Down Expand Up @@ -1432,12 +1432,12 @@ impl<'de> serde::Deserialize<'de> for proposal::Signaling {
if commit__.is_some() {
return Err(serde::de::Error::duplicate_field("commit"));
}
commit__ = map.next_value()?;
commit__ = Some(map.next_value()?);
}
}
}
Ok(proposal::Signaling {
commit: commit__,
commit: commit__.unwrap_or_default(),
})
}
}
Expand Down Expand Up @@ -1702,12 +1702,12 @@ impl serde::Serialize for proposal_outcome::Failed {
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.withdrawn_with_reason.is_some() {
if !self.withdrawn_with_reason.is_empty() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.governance.v1alpha1.ProposalOutcome.Failed", len)?;
if let Some(v) = self.withdrawn_with_reason.as_ref() {
struct_ser.serialize_field("withdrawnWithReason", v)?;
if !self.withdrawn_with_reason.is_empty() {
struct_ser.serialize_field("withdrawnWithReason", &self.withdrawn_with_reason)?;
}
struct_ser.end()
}
Expand Down Expand Up @@ -1774,12 +1774,12 @@ impl<'de> serde::Deserialize<'de> for proposal_outcome::Failed {
if withdrawn_with_reason__.is_some() {
return Err(serde::de::Error::duplicate_field("withdrawnWithReason"));
}
withdrawn_with_reason__ = map.next_value()?;
withdrawn_with_reason__ = Some(map.next_value()?);
}
}
}
Ok(proposal_outcome::Failed {
withdrawn_with_reason: withdrawn_with_reason__,
withdrawn_with_reason: withdrawn_with_reason__.unwrap_or_default(),
})
}
}
Expand Down Expand Up @@ -1865,12 +1865,12 @@ impl serde::Serialize for proposal_outcome::Slashed {
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.withdrawn_with_reason.is_some() {
if !self.withdrawn_with_reason.is_empty() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.governance.v1alpha1.ProposalOutcome.Slashed", len)?;
if let Some(v) = self.withdrawn_with_reason.as_ref() {
struct_ser.serialize_field("withdrawnWithReason", v)?;
if !self.withdrawn_with_reason.is_empty() {
struct_ser.serialize_field("withdrawnWithReason", &self.withdrawn_with_reason)?;
}
struct_ser.end()
}
Expand Down Expand Up @@ -1937,12 +1937,12 @@ impl<'de> serde::Deserialize<'de> for proposal_outcome::Slashed {
if withdrawn_with_reason__.is_some() {
return Err(serde::de::Error::duplicate_field("withdrawnWithReason"));
}
withdrawn_with_reason__ = map.next_value()?;
withdrawn_with_reason__ = Some(map.next_value()?);
}
}
}
Ok(proposal_outcome::Slashed {
withdrawn_with_reason: withdrawn_with_reason__,
withdrawn_with_reason: withdrawn_with_reason__.unwrap_or_default(),
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/proto/src/gen/penumbra.core.stake.v1alpha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ pub struct ValidatorStatus {
pub struct BondingState {
#[prost(enumeration = "bonding_state::BondingStateEnum", tag = "1")]
pub state: i32,
#[prost(uint64, optional, tag = "2")]
pub unbonding_epoch: ::core::option::Option<u64>,
#[prost(uint64, tag = "2")]
pub unbonding_epoch: u64,
}
/// Nested message and enum types in `BondingState`.
pub mod bonding_state {
Expand Down
10 changes: 5 additions & 5 deletions crates/proto/src/gen/penumbra.core.stake.v1alpha1.serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl serde::Serialize for BondingState {
if self.state != 0 {
len += 1;
}
if self.unbonding_epoch.is_some() {
if self.unbonding_epoch != 0 {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.stake.v1alpha1.BondingState", len)?;
Expand All @@ -152,8 +152,8 @@ impl serde::Serialize for BondingState {
.ok_or_else(|| serde::ser::Error::custom(format!("Invalid variant {}", self.state)))?;
struct_ser.serialize_field("state", &v)?;
}
if let Some(v) = self.unbonding_epoch.as_ref() {
struct_ser.serialize_field("unbondingEpoch", ToString::to_string(&v).as_str())?;
if self.unbonding_epoch != 0 {
struct_ser.serialize_field("unbondingEpoch", ToString::to_string(&self.unbonding_epoch).as_str())?;
}
struct_ser.end()
}
Expand Down Expand Up @@ -231,14 +231,14 @@ impl<'de> serde::Deserialize<'de> for BondingState {
return Err(serde::de::Error::duplicate_field("unbondingEpoch"));
}
unbonding_epoch__ =
map.next_value::<::std::option::Option<::pbjson::private::NumberDeserialize<_>>>()?.map(|x| x.0)
Some(map.next_value::<::pbjson::private::NumberDeserialize<_>>()?.0)
;
}
}
}
Ok(BondingState {
state: state__.unwrap_or_default(),
unbonding_epoch: unbonding_epoch__,
unbonding_epoch: unbonding_epoch__.unwrap_or_default(),
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/proto/src/gen/penumbra.core.transaction.v1alpha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ pub struct TransactionBody {
pub struct MemoData {
/// The encrypted data. It will only be populated if there are
/// outputs in the actions of the transaction. 528 bytes.
#[prost(bytes = "bytes", optional, tag = "1")]
pub encrypted_memo: ::core::option::Option<::prost::bytes::Bytes>,
#[prost(bytes = "bytes", tag = "1")]
pub encrypted_memo: ::prost::bytes::Bytes,
}
/// The parameters determining if a transaction should be accepted by the chain.
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
10 changes: 5 additions & 5 deletions crates/proto/src/gen/penumbra.core.transaction.v1alpha1.serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2102,12 +2102,12 @@ impl serde::Serialize for MemoData {
{
use serde::ser::SerializeStruct;
let mut len = 0;
if self.encrypted_memo.is_some() {
if !self.encrypted_memo.is_empty() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.transaction.v1alpha1.MemoData", len)?;
if let Some(v) = self.encrypted_memo.as_ref() {
struct_ser.serialize_field("encryptedMemo", pbjson::private::base64::encode(&v).as_str())?;
if !self.encrypted_memo.is_empty() {
struct_ser.serialize_field("encryptedMemo", pbjson::private::base64::encode(&self.encrypted_memo).as_str())?;
}
struct_ser.end()
}
Expand Down Expand Up @@ -2175,13 +2175,13 @@ impl<'de> serde::Deserialize<'de> for MemoData {
return Err(serde::de::Error::duplicate_field("encryptedMemo"));
}
encrypted_memo__ =
map.next_value::<::std::option::Option<::pbjson::private::BytesDeserialize<_>>>()?.map(|x| x.0)
Some(map.next_value::<::pbjson::private::BytesDeserialize<_>>()?.0)
;
}
}
}
Ok(MemoData {
encrypted_memo: encrypted_memo__,
encrypted_memo: encrypted_memo__.unwrap_or_default(),
})
}
}
Expand Down
24 changes: 12 additions & 12 deletions crates/proto/src/gen/penumbra.view.v1alpha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub struct TransactionPlannerRequest {
pub memo: ::core::option::Option<
super::super::core::transaction::v1alpha1::MemoPlaintext,
>,
/// Identifies the account group to query.
/// Identifies the account group to query. Defaults to 0.
#[prost(message, optional, tag = "14")]
pub account_group_id: ::core::option::Option<
super::super::core::crypto::v1alpha1::AccountGroupId,
Expand Down Expand Up @@ -110,7 +110,7 @@ pub mod transaction_planner_request {
pub target_asset: ::core::option::Option<
super::super::super::core::crypto::v1alpha1::AssetId,
>,
/// An optional fee to be paid for performing the Swap.
/// An fee to be paid for performing the Swap.
#[prost(message, optional, tag = "3")]
pub fee: ::core::option::Option<
super::super::super::core::crypto::v1alpha1::Fee,
Expand Down Expand Up @@ -526,18 +526,18 @@ pub struct TransactionInfoByHashRequest {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransactionInfoRequest {
/// If present, return only transactions after this height.
#[prost(uint64, optional, tag = "1")]
pub start_height: ::core::option::Option<u64>,
#[prost(uint64, tag = "1")]
pub start_height: u64,
/// If present, return only transactions before this height.
#[prost(uint64, optional, tag = "2")]
pub end_height: ::core::option::Option<u64>,
#[prost(uint64, tag = "2")]
pub end_height: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransactionInfo {
/// The height the transaction was included in a block, if known.
#[prost(uint64, optional, tag = "1")]
pub height: ::core::option::Option<u64>,
#[prost(uint64, tag = "1")]
pub height: u64,
/// The hash of the transaction.
#[prost(message, optional, tag = "2")]
pub id: ::core::option::Option<super::super::core::transaction::v1alpha1::Id>,
Expand Down Expand Up @@ -611,8 +611,8 @@ pub struct SpendableNoteRecord {
#[prost(uint64, tag = "5")]
pub height_created: u64,
/// Records whether the note was spent (and if so, at what height).
#[prost(uint64, optional, tag = "6")]
pub height_spent: ::core::option::Option<u64>,
#[prost(uint64, tag = "6")]
pub height_spent: u64,
/// The note position.
#[prost(uint64, tag = "7")]
pub position: u64,
Expand All @@ -639,8 +639,8 @@ pub struct SwapRecord {
pub output_data: ::core::option::Option<
super::super::core::dex::v1alpha1::BatchSwapOutputData,
>,
#[prost(uint64, optional, tag = "6")]
pub height_claimed: ::core::option::Option<u64>,
#[prost(uint64, tag = "6")]
pub height_claimed: u64,
#[prost(message, optional, tag = "7")]
pub source: ::core::option::Option<super::super::core::chain::v1alpha1::NoteSource>,
}
Expand Down
Loading

0 comments on commit fa59fa6

Please sign in to comment.