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

chore: update Cosmos SDK protos to v0.47.3 and IBC-Go protos to v7.2.0 #122

Merged
merged 6 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions scripts/sync-protobuf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,11 @@ COSMOS_ICS_DIR=$(mktemp -d /tmp/interchain-security-XXXXXXXX)

pushd "$COSMOS_ICS_DIR"
git clone "$COSMOS_ICS_GIT" .
git checkout "$COSMOS_ICS_COMMIT"

# We have to name the commit as a branch because
# proto-compiler uses the branch name as the commit
# output. Otherwise it will just output HEAD
git checkout -b "$COSMOS_ICS_COMMIT"
git switch -c "$COSMOS_ICS_COMMIT"

cd proto
buf mod update
Expand All @@ -127,12 +126,11 @@ COSMOS_SDK_DIR=$(mktemp -d /tmp/cosmos-sdk-XXXXXXXX)

pushd "$COSMOS_SDK_DIR"
git clone "$COSMOS_SDK_GIT" .
git checkout "$COSMOS_SDK_COMMIT"

# We have to name the commit as a branch because
# proto-compiler uses the branch name as the commit
# output. Otherwise it will just output HEAD
git checkout -b "$COSMOS_SDK_COMMIT"
git switch -c "$COSMOS_SDK_COMMIT"

cd proto
buf mod update
Expand All @@ -141,8 +139,6 @@ popd

cat << "EOF" >> "$COSMOS_SDK_DIR/proto-include/cosmos/staking/v1beta1/staking.proto"

import "tendermint/abci/types.proto";

// InfractionType indicates the infraction type a validator commited.
enum InfractionType {
option (gogoproto.goproto_enum_prefix) = false;
Expand All @@ -154,19 +150,13 @@ enum InfractionType {
// DOWNTIME defines a validator that missed signing too many blocks.
INFRACTION_TYPE_DOWNTIME = 2 [(gogoproto.enumvalue_customname) = "Downtime"];
}

// ValidatorUpdates defines an array of abci.ValidatorUpdate objects.
message ValidatorUpdates {
repeated tendermint.abci.ValidatorUpdate updates = 1 [(gogoproto.nullable) = false];
}
EOF

IBC_GO_DIR=$(mktemp -d /tmp/ibc-go-XXXXXXXX)

pushd "$IBC_GO_DIR"
git clone "$IBC_GO_GIT" .
git checkout "$IBC_GO_COMMIT"
git checkout -b "$IBC_GO_COMMIT"
git switch -c "$IBC_GO_COMMIT"

cd proto
buf export -v -o ../proto-include
Expand All @@ -193,6 +183,15 @@ cargo run --locked -- compile \
--ibc "$IBC_GO_DIR/proto-include" \
--out ../../src/prost

cd ../..

# Remove generated ICS23 code because it is not used,
# we instead re-exports the `ics23` crate type definitions.
rm -f src/prost/cosmos.ics23.v1.rs

# The Tendermint ABCI protos are unused from within ibc-proto
rm -f src/prost/tendermint.abci.rs

# Remove the temporary checkouts of the repositories
rm -rf "$COSMOS_ICS_DIR"
rm -rf "$COSMOS_SDK_DIR"
Expand Down
2 changes: 1 addition & 1 deletion src/COSMOS_SDK_COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eb1e3ebf6fcfd56e1f1d8f4c0a6192740bd8a6c1
666c345ad23ddda9523cc5cd1b71187d91c26f34
2 changes: 1 addition & 1 deletion src/IBC_GO_COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d32a71b6e13e771ec5e7964ead28b9a6fa2b4472
d02ab9db8fc80eb5e55041d3d6416370c33441f7
53 changes: 39 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ pub const IBC_GO_COMMIT: &str = include_str!("IBC_GO_COMMIT");
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("prost/proto_descriptor.bin");

pub mod cosmos {
pub mod app {
pub mod v1alpha1 {
include_proto!("cosmos.app.v1alpha1.rs");
}
}
pub mod auth {
pub mod v1beta1 {
include_proto!("cosmos.auth.v1beta1.rs");
Expand All @@ -52,6 +57,11 @@ pub mod cosmos {
pub code_hash: ::prost::alloc::vec::Vec<u8>,
}
}
pub mod module {
pub mod v1 {
include_proto!("cosmos.auth.module.v1.rs");
}
}
}
pub mod evidence {
pub mod v1beta1 {
Expand All @@ -62,23 +72,28 @@ pub mod cosmos {
pub mod v1beta1 {
include_proto!("cosmos.staking.v1beta1.rs");
}
pub mod module {
pub mod v1 {
include_proto!("cosmos.staking.module.v1.rs");
}
}
}
pub mod bank {
pub mod v1beta1 {
include_proto!("cosmos.bank.v1beta1.rs");
}
pub mod module {
pub mod v1 {
include_proto!("cosmos.bank.module.v1.rs");
}
}
}
pub mod base {
pub mod abci {
pub mod v1beta1 {
include_proto!("cosmos.base.abci.v1beta1.rs");
}
}
pub mod kv {
pub mod v1beta1 {
include_proto!("cosmos.base.kv.v1beta1.rs");
}
}
pub mod node {
pub mod v1beta1 {
include_proto!("cosmos.base.node.v1beta1.rs");
Expand All @@ -94,11 +109,6 @@ pub mod cosmos {
include_proto!("cosmos.base.reflection.v1beta1.rs");
}
}
pub mod store {
pub mod v1beta1 {
include_proto!("cosmos.base.store.v1beta1.rs");
}
}
pub mod v1beta1 {
include_proto!("cosmos.base.v1beta1.rs");
}
Expand All @@ -116,6 +126,11 @@ pub mod cosmos {
}
}
pub mod tx {
pub mod config {
pub mod v1 {
include_proto!("cosmos.tx.config.v1.rs");
}
}
pub mod signing {
pub mod v1beta1 {
include_proto!("cosmos.tx.signing.v1beta1.rs");
Expand All @@ -129,11 +144,21 @@ pub mod cosmos {
pub mod v1beta1 {
include_proto!("cosmos.upgrade.v1beta1.rs");
}
pub mod module {
pub mod v1 {
include_proto!("cosmos.upgrade.module.v1.rs");
}
}
}
pub mod gov {
pub mod v1beta1 {
include_proto!("cosmos.gov.v1beta1.rs");
}
pub mod module {
pub mod v1 {
include_proto!("cosmos.gov.module.v1.rs");
}
}
}
pub mod ics23 {
pub use ics23 as v1;
Expand Down Expand Up @@ -204,13 +229,13 @@ pub mod ibc {
}
pub mod lightclients {
pub mod localhost {
pub mod v1 {
include_proto!("ibc.lightclients.localhost.v1.rs");
pub mod v2 {
include_proto!("ibc.lightclients.localhost.v2.rs");
}
}
pub mod solomachine {
pub mod v1 {
include_proto!("ibc.lightclients.solomachine.v1.rs");
pub mod v3 {
include_proto!("ibc.lightclients.solomachine.v3.rs");
}
}
pub mod tendermint {
Expand Down
80 changes: 80 additions & 0 deletions src/prost/cosmos.app.v1alpha1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/// ModuleDescriptor describes an app module.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModuleDescriptor {
/// go_import names the package that should be imported by an app to load the
/// module in the runtime module registry. It is required to make debugging
/// of configuration errors easier for users.
#[prost(string, tag = "1")]
pub go_import: ::prost::alloc::string::String,
/// use_package refers to a protobuf package that this module
/// uses and exposes to the world. In an app, only one module should "use"
/// or own a single protobuf package. It is assumed that the module uses
/// all of the .proto files in a single package.
#[prost(message, repeated, tag = "2")]
pub use_package: ::prost::alloc::vec::Vec<PackageReference>,
/// can_migrate_from defines which module versions this module can migrate
/// state from. The framework will check that one module version is able to
/// migrate from a previous module version before attempting to update its
/// config. It is assumed that modules can transitively migrate from earlier
/// versions. For instance if v3 declares it can migrate from v2, and v2
/// declares it can migrate from v1, the framework knows how to migrate
/// from v1 to v3, assuming all 3 module versions are registered at runtime.
#[prost(message, repeated, tag = "3")]
pub can_migrate_from: ::prost::alloc::vec::Vec<MigrateFromInfo>,
}
/// PackageReference is a reference to a protobuf package used by a module.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PackageReference {
/// name is the fully-qualified name of the package.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// revision is the optional revision of the package that is being used.
/// Protobuf packages used in Cosmos should generally have a major version
/// as the last part of the package name, ex. foo.bar.baz.v1.
/// The revision of a package can be thought of as the minor version of a
/// package which has additional backwards compatible definitions that weren't
/// present in a previous version.
///
/// A package should indicate its revision with a source code comment
/// above the package declaration in one of its files containing the
/// text "Revision N" where N is an integer revision. All packages start
/// at revision 0 the first time they are released in a module.
///
/// When a new version of a module is released and items are added to existing
/// .proto files, these definitions should contain comments of the form
/// "Since: Revision N" where N is an integer revision.
///
/// When the module runtime starts up, it will check the pinned proto
/// image and panic if there are runtime protobuf definitions that are not
/// in the pinned descriptor which do not have
/// a "Since Revision N" comment or have a "Since Revision N" comment where
/// N is <= to the revision specified here. This indicates that the protobuf
/// files have been updated, but the pinned file descriptor hasn't.
///
/// If there are items in the pinned file descriptor with a revision
/// greater than the value indicated here, this will also cause a panic
/// as it may mean that the pinned descriptor for a legacy module has been
/// improperly updated or that there is some other versioning discrepancy.
/// Runtime protobuf definitions will also be checked for compatibility
/// with pinned file descriptors to make sure there are no incompatible changes.
///
/// This behavior ensures that:
/// * pinned proto images are up-to-date
/// * protobuf files are carefully annotated with revision comments which
/// are important good client UX
/// * protobuf files are changed in backwards and forwards compatible ways
#[prost(uint32, tag = "2")]
pub revision: u32,
}
/// MigrateFromInfo is information on a module version that a newer module
/// can migrate from.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MigrateFromInfo {
/// module is the fully-qualified protobuf name of the module config object
/// for the previous module version, ex: "cosmos.group.module.v1.Module".
#[prost(string, tag = "1")]
pub module: ::prost::alloc::string::String,
}
26 changes: 26 additions & 0 deletions src/prost/cosmos.auth.module.v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// Module is the config object for the auth module.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Module {
/// bech32_prefix is the bech32 account prefix for the app.
#[prost(string, tag = "1")]
pub bech32_prefix: ::prost::alloc::string::String,
/// module_account_permissions are module account permissions.
#[prost(message, repeated, tag = "2")]
pub module_account_permissions: ::prost::alloc::vec::Vec<ModuleAccountPermission>,
/// authority defines the custom module authority. If not set, defaults to the governance module.
#[prost(string, tag = "3")]
pub authority: ::prost::alloc::string::String,
}
/// ModuleAccountPermission represents permissions for a module account.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModuleAccountPermission {
/// account is the name of the module.
#[prost(string, tag = "1")]
pub account: ::prost::alloc::string::String,
/// permissions are the permissions this module has. Currently recognized
/// values are minter, burner and staking.
#[prost(string, repeated, tag = "2")]
pub permissions: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
Loading
Loading