Skip to content
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

fix(nibiru-std-proto-buf): sign mode proto clean script #113

Open
Unique-Divine opened this issue Jan 9, 2024 · 0 comments
Open

fix(nibiru-std-proto-buf): sign mode proto clean script #113

Unique-Divine opened this issue Jan 9, 2024 · 0 comments
Labels
scope: scripts Scope in the conventional commit sense is a noun describing the section of the codebase. type: bug/fix A pull request that fixes someting (pull) OR a ticket that highlights a bug (issue).

Comments

@Unique-Divine
Copy link
Member

Unique-Divine commented Jan 9, 2024

Context/Abstract

Non-critical error when running cargo run --bin proto_clean inside the scripts directory:

cleaning ../nibiru-std/src/proto/buf/cosmos.tx.signing.v1beta1.rs
Error cleaning import 'super::super::SignMode': CustomError("Unrecognized import submodule: super::super::SignMode")

  • I describe this as non-critical because it's easy to fix by manually editing the generated Rust file. Simply delete pub struct StakeAuthorization and pub mod stake_authorization in the cosmos.tx.signing.v1beta1.rs file, and the error goes away.

Underlying Issue

This came up in Cosmos SDK. The code generator in Go does not have any issues with this, so I expect it will be difficult to get the authors to change.

Problem 1: SignMode import broken

The error comes from this import of an enumeration in file cosmos.tx.signing.v1beta1.rs:

pub mod signature_descriptor {
    /// Data represents signature data
    #[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
    pub struct Data {
        /// sum is the oneof that specifies whether this represents single or multi-signature data
        #[prost(oneof="data::Sum", tags="1, 2")]
        pub sum: ::core::option::Option<data::Sum>,
    }
    /// Nested message and enum types in `Data`.
    pub mod data {
        /// Single is the signature data for a single signer
        #[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
        pub struct Single {
            /// mode is the signing mode of the single signer
            #[prost(enumeration="super::super::SignMode", tag="1")]
            pub mode: i32,
            /// signature is the raw signature bytes
            #[prost(bytes="bytes", tag="2")]
            pub signature: ::prost::bytes::Bytes,
        }
}} // ...

Later on in the file, SignMode is defined:

/// SignMode represents a signing mode with its own security guarantees.
///
/// This enum should be considered a registry of all known sign modes
/// in the Cosmos ecosystem. Apps are not expected to support all known
/// sign modes. Apps that would like to support custom  sign modes are
/// encouraged to open a small PR against this file to add a new case
/// to this SignMode enum describing their sign mode so that different
/// apps have a consistent version of this enum.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SignMode { // ...
}

Problem 2: Validators type defined as both struct and enum

Ignoring the SignMode error results in a different problem.

just fmt
cargo fmt --all
just clippy
cargo clippy --fix --allow-dirty --allow-staged
Checking nibiru-std v0.0.5 (/home/realu/warpath/NibiruChain/cw-nibiru/nibiru-std)
Checking bash-rs v0.1.0 (/home/realu/warpath/NibiruChain/cw-nibiru/packages/bash-rs)
Checking nibi-dev v0.1.0 (/home/realu/warpath/NibiruChain/cw-nibiru/packages/nibi-dev)
Checking cw3-flex-multisig v1.0.1 (/home/realu/warpath/NibiruChain/cw-nibiru/contracts/core-cw3-flex-msig)
Checking token-vesting v0.2.0 (/home/realu/warpath/NibiruChain/cw-nibiru/contracts/core-token-vesting)
Checking incentives v0.2.0 (/home/realu/warpath/NibiruChain/cw-nibiru/contracts/incentives)
Checking scripts v0.1.0 (/home/realu/warpath/NibiruChain/cw-nibiru/scripts)
error[E0428]: the name Validators is defined multiple times
--> nibiru-std/src/proto/buf/cosmos.staking.v1beta1.rs:31:5
|
24 | pub struct Validators {
| --------------------- previous definition of the type Validators here
...
31 | pub enum Validators {
| ^^^^^^^^^^^^^^^^^^^ Validators redefined here
|
= note: Validators must be defined only once in the type namespace of this module

warning: using tabs in doc comments is not recommended
--> nibiru-std/src/proto/buf/nibiru.oracle.v1.rs:16:9
|
16 | /// μ := weightedMedian,
| ^^^^ help: consider using four spaces per tab
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments
= note: #[warn(clippy::tabs_in_doc_comments)] on by default

warning: using tabs in doc comments is not recommended
--> nibiru-std/src/proto/buf/nibiru.oracle.v1.rs:17:9
|
17 | /// validRange := μ ± (μ * rewardBand / 2),
| ^^^^ help: consider using four spaces per tab
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments

error[E0119]: conflicting implementations of trait std::clone::Clone for type proto::cosmos::staking::v1beta1::stake_authorization::Validators
--> nibiru-std/src/proto/buf/cosmos.staking.v1beta1.rs:30:10
|
23 | #[derive(Clone, PartialEq, ::prost::Message)]
| ----- first implementation here
...
30 | #[derive(Clone, PartialEq, ::prost::Oneof)]
| ^^^^^ conflicting implementation for proto::cosmos::staking::v1beta1::stake_authorization::Validators
|
= note: this error originates in the derive macro Clone (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0119]: conflicting implementations of trait std::fmt::Debug for type proto::cosmos::staking::v1beta1::stake_authorization::Validators
--> nibiru-std/src/proto/buf/cosmos.staking.v1beta1.rs:30:28
|
23 | #[derive(Clone, PartialEq, ::prost::Message)]
| ---------------- first implementation here
...
30 | #[derive(Clone, PartialEq, ::prost::Oneof)]
| ^^^^^^^^^^^^^^ conflicting implementation for proto::cosmos::staking::v1beta1::stake_authorization::Validators
|
= note: this error originates in the derive macro ::prost::Oneof (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0119]: conflicting implementations of trait std::marker::StructuralPartialEq for type proto::cosmos::staking::v1beta1::stake_authorization::Validators
--> nibiru-std/src/proto/buf/cosmos.staking.v1beta1.rs:30:17
|
23 | #[derive(Clone, PartialEq, ::prost::Message)]
| --------- first implementation here
...
30 | #[derive(Clone, PartialEq, ::prost::Oneof)]
| ^^^^^^^^^ conflicting implementation for proto::cosmos::staking::v1beta1::stake_authorization::Validators
|
= note: this error originates in the derive macro PartialEq (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0119]: conflicting implementations of trait std::cmp::PartialEq for type proto::cosmos::staking::v1beta1::stake_authorization::Validators
--> nibiru-std/src/proto/buf/cosmos.staking.v1beta1.rs:30:17
|
23 | #[derive(Clone, PartialEq, ::prost::Message)]
| --------- first implementation here
...
30 | #[derive(Clone, PartialEq, ::prost::Oneof)]
| ^^^^^^^^^ conflicting implementation for proto::cosmos::staking::v1beta1::stake_authorization::Validators
|
= note: this error originates in the derive macro PartialEq (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0119, E0428.
For more information about an error, try rustc --explain E0119.
warning: nibiru-std (lib) generated 2 warnings
error: could not compile nibiru-std (lib) due to 5 previous errors; 2 warnings emitted
warning: build failed, waiting for other jobs to finish...
error: Recipe clippy failed on line 54 with exit code 101
error: Recipe tidy failed on line 84 with exit code 101

@Unique-Divine Unique-Divine added type: enhancement New feature or request scope: scripts Scope in the conventional commit sense is a noun describing the section of the codebase. type: bug/fix A pull request that fixes someting (pull) OR a ticket that highlights a bug (issue). and removed type: enhancement New feature or request labels Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: scripts Scope in the conventional commit sense is a noun describing the section of the codebase. type: bug/fix A pull request that fixes someting (pull) OR a ticket that highlights a bug (issue).
Projects
Status: No status
Development

No branches or pull requests

1 participant