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

refactor(proto): improve buf usage #19570

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
38 changes: 18 additions & 20 deletions .github/workflows/proto-registry.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
# name: Buf Push
# Protobuf runs buf (https://buf.build/) push updated proto files to https://buf.build/cosmos/cosmos-sdk
# This workflow is only run when a .proto file has been changed
# on:
# push:
# tags:
# - "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
# - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" # Push events to matching v*-rc*, i.e. v1.0-rc1, v20.15.10-rc2
# - "v[0-9]+.[0-9]+.[0-9]+-beta[0-9]+" # Push events to matching v*-beta*, i.e. v1.0-beta1, v20.15.10-beta2
# - "v[0-9]+.[0-9]+.[0-9]+-alpha[0-9]+" # Push events to matching v*-alpha*, i.e. v1.0-alpha1, v20.15.10-alpha2
# paths:
# - "proto/**"
name: Buf Push
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" # Push events to matching v*-rc*, i.e. v1.0-rc1, v20.15.10-rc2
- "v[0-9]+.[0-9]+.[0-9]+-beta[0-9]+" # Push events to matching v*-beta*, i.e. v1.0-beta1, v20.15.10-beta2
- "v[0-9]+.[0-9]+.[0-9]+-alpha[0-9]+" # Push events to matching v*-alpha*, i.e. v1.0-alpha1, v20.15.10-alpha2
paths:
- "proto/**"

# jobs:
# root:
# runs-on: ubuntu-latest
# name: "Push to buf.build/cosmos/cosmos-sdk"
# steps:
# - uses: actions/checkout@v4
# - uses: bufbuild/[email protected]
# - run: buf push proto --tag ${{ github.ref_type == 'tag' && github.ref_name || github.sha }} # https://github.com/bufbuild/buf-push-action/issues/20

## TODO at each module tag to their own buf repository
jobs:
root:
runs-on: ubuntu-latest
name: "Push to buf.build/cosmos/cosmos-sdk"
steps:
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]
- run: buf push proto --tag ${{ github.ref_type == 'tag' && github.ref_name || github.sha }} # https://github.com/bufbuild/buf-push-action/issues/20
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
* [External Contributors](#external-contributors)
* [Requesting Reviews](#requesting-reviews)
* [Updating Documentation](#updating-documentation)
* [RFC & ADR](#rfc--adr)
* [RFC \& ADR](#rfc--adr)
* [Dependencies](#dependencies)
* [`go.work`](#gowork)
* [`go.mod`](#gomod)
* [Protobuf](#protobuf)
* [Branching Model and Release](#branching-model-and-release)
* [PR Targeting](#pr-targeting)
* [Code Owner Membership](#code-owner-membership)
* [Concept & Feature Approval Process](#concept--feature-approval-process)
* [Concept \& Feature Approval Process](#concept--feature-approval-process)
* [Strategy Discovery](#strategy-discovery)
* [Concept Approval](#concept-approval)
* [Time Bound Period](#time-bound-period)
Expand Down Expand Up @@ -262,6 +262,7 @@ When extracting a package to its own go modules, some extra steps are required,
* Add a CHANGELOG.md / README.md under the new package folder
* Add the package in [`labeler.yml`](./.github/pr_labeler.yml)
* Add the package in [`go.work.example`](./go.work.example)
* (if applicable) Add the proto directory in [`buf.work.yaml`](./buf.work.yaml)
* Add weekly dependabot checks (see [dependabot.yml](./.github/dependabot.yml))
* Add tests to github workflow [test.yml](.github/workflows/test.yml) (under submodules)
* Configure SonarCloud
Expand Down
39 changes: 15 additions & 24 deletions docs/build/building-modules/11-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,8 @@ The required interface for a module is located in the module.go. Everything beyo

A typical Cosmos SDK module can be structured as follows:

```shell
proto
└── {project_name}
   └── {module_name}
   └── {proto_version}
      ├── {module_name}.proto
      ├── genesis.proto
      ├── query.proto
      └── tx.proto
```

* `{module_name}.proto`: The module's common message type definitions.
* `genesis.proto`: The module's message type definitions related to genesis state.
* `query.proto`: The module's Query service and related message type definitions.
* `tx.proto`: The module's Msg service and related message type definitions.

```shell
x/{module_name}
├── client
│   ├── cli
│   │ ├── query.go
│   │   └── tx.go
│   └── testutil
│   ├── cli_test.go
│   └── suite.go
├── exported
│   └── exported.go
├── keeper
Expand All @@ -50,6 +27,15 @@ x/{module_name}
│   ├── keys.go
│   ├── msg_server.go
│   └── querier.go
├──proto
│  └── {project_name}
│   └── {module_name}
│   └── {proto_version}
│      ├── {module_name}.proto
│      ├── event.proto
│      ├── genesis.proto
│      ├── query.proto
│      └── tx.proto
├── simulation
│   ├── decoder.go
│   ├── genesis.go
Expand All @@ -76,10 +62,15 @@ x/{module_name}
└── README.md
```

* `client/`: The module's CLI client functionality implementation and the module's CLI testing suite.
* `exported/`: The module's exported types - typically interface types. If a module relies on keepers from another module, it is expected to receive the keepers as interface contracts through the `expected_keepers.go` file (see below) in order to avoid a direct dependency on the module implementing the keepers. However, these interface contracts can define methods that operate on and/or return types that are specific to the module that is implementing the keepers and this is where `exported/` comes into play. The interface types that are defined in `exported/` use canonical types, allowing for the module to receive the keepers as interface contracts through the `expected_keepers.go` file. This pattern allows for code to remain DRY and also alleviates import cycle chaos.
* `keeper/`: The module's `Keeper` and `MsgServer` implementation.
* `abci.go`: The module's `BeginBlocker` and `EndBlocker` implementations (this file is only required if `BeginBlocker` and/or `EndBlocker` need to be defined).
* `proto/`: The module's Protocol Buffers definition files.
* `{module_name}.proto`: The module's common message type definitions.
* `event.proto`: The module's message type definitions related to events.
* `genesis.proto`: The module's message type definitions related to genesis state.
* `query.proto`: The module's Query service and related message type definitions.
* `tx.proto`: The module's Msg service and related message type definitions.
* `simulation/`: The module's [simulation](./14-simulator.md) package defines functions used by the blockchain simulator application (`simapp`).
* `README.md`: The module's specification documents outlining important concepts, state storage structure, and message and event type definitions. Learn more how to write module specs in the [spec guidelines](../spec/SPEC_MODULE.md).
* `types/`: includes type definitions for messages, events, and genesis state, including the type definitions generated by Protocol Buffers.
Expand Down
2 changes: 1 addition & 1 deletion x/accounts/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/accounts
name: buf.build/cosmos/x-accounts
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/auth/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/auth
name: buf.build/cosmos/x-auth
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/authz/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/authz
name: buf.build/cosmos/x-authz
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/bank/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/bank
name: buf.build/cosmos/x-bank
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/circuit/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/circuit
name: buf.build/cosmos/x-circuit
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/consensus/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/consensus
name: buf.build/cosmos/x-consensus
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cometbft/cometbft:4a62c99d422068a5165429b62a7eb824df46cca9 # CometBFT v0.38
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/distribution
name: buf.build/cosmos/x-distribution
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/epochs/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/epochs
name: buf.build/cosmos/x-epochs
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/evidence/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/evidence
name: buf.build/cosmos/x-evidence
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/feegrant/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/feegrant
name: buf.build/cosmos/x-feegrant
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/gov/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/gov
name: buf.build/cosmos/x-gov
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/group/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/group
name: buf.build/cosmos/x-group
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/mint/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/mint
name: buf.build/cosmos/x-mint
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/nft/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/nft
name: buf.build/cosmos/x-nft
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/params/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/params
name: buf.build/cosmos/x-params # do we really need params extracted from the SDK?
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/protocolpool/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/protocolpool
name: buf.build/cosmos/x-protocolpool
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/slashing
name: buf.build/cosmos/x-slashing
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
2 changes: 1 addition & 1 deletion x/staking/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/staking
name: buf.build/cosmos/x-staking
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cometbft/cometbft:4a62c99d422068a5165429b62a7eb824df46cca9 # CometBFT v0.38
Expand Down
2 changes: 1 addition & 1 deletion x/upgrade/proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: v1
name: buf.build/mods/upgrade
name: buf.build/cosmos/x-upgrade
deps:
- buf.build/cosmos/cosmos-sdk # pin the Cosmos SDK version
- buf.build/cosmos/cosmos-proto
Expand Down
Loading