Skip to content

Commit

Permalink
refactor: migrate to cosmos/gogoproto (backport #9356) (#9381)
Browse files Browse the repository at this point in the history
* refactor: migrate to `cosmos/gogoproto` (#9356)

* refactor: migrate to `cosmos/gogoproto`

* add changelog

* Update Makefile

Co-authored-by: Thane Thomson <[email protected]>

* update link

Co-authored-by: Thane Thomson <[email protected]>

* `go mod tidy`

Co-authored-by: Thane Thomson <[email protected]>
  • Loading branch information
julienrbrt and thanethomson authored Sep 7, 2022
1 parent 98ed397 commit 4626bc9
Show file tree
Hide file tree
Showing 84 changed files with 199 additions and 347 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/check-generated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.18'
go-version: "1.18"

- uses: actions/checkout@v3

Expand All @@ -42,11 +42,11 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.18'
go-version: "1.18"

- uses: actions/checkout@v3
with:
fetch-depth: 1 # we need a .git directory to run git diff
fetch-depth: 1 # we need a .git directory to run git diff

- name: "Check protobuf generated code"
run: |
Expand All @@ -59,7 +59,7 @@ jobs:
export GOBIN="${tools}/bin"
go install github.com/bufbuild/buf/cmd/buf
go install github.com/gogo/protobuf/protoc-gen-gogofaster@latest
go install github.com/cosmos/gogoproto/protoc-gen-gogofaster@latest
make proto-gen
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi

### IMPROVEMENTS

- [proto] \#9356 Migrate from `gogo/protobuf` to `cosmos/gogoproto` (@julienrbrt)
- [rpc] \#9276 Added `header` and `header_by_hash` queries to the RPC client (@samricotta)
- [abci] \#5706 Added `AbciVersion` to `RequestInfo` allowing applications to check ABCI version when connecting to Tendermint. (@marbar3778)

Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ specify exactly the dependency you want to update, eg.
## Protobuf

We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along
with [`gogoproto`](https://github.com/gogo/protobuf) to generate code for use
with [`gogoproto`](https://github.com/cosmos/gogoproto) to generate code for use
across Tendermint Core.

To generate proto stubs, lint, and check protos for breaking changes, you will
Expand Down Expand Up @@ -142,7 +142,6 @@ If you are a VS Code user, you may want to add the following to your `.vscode/se
"protoc": {
"options": [
"--proto_path=${workspaceRoot}/proto",
"--proto_path=${workspaceRoot}/third_party/proto"
]
}
}
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ mockery:

check-proto-deps:
ifeq (,$(shell which protoc-gen-gogofaster))
@go install github.com/gogo/protobuf/protoc-gen-gogofaster@latest
@go install github.com/cosmos/gogoproto/protoc-gen-gogofaster@latest
endif
.PHONY: check-proto-deps

Expand All @@ -174,6 +174,7 @@ proto-gen: check-proto-deps
@echo "Generating Protobuf files"
@go run github.com/bufbuild/buf/cmd/buf generate
@mv ./proto/tendermint/abci/types.pb.go ./abci/types/
@cp ./proto/tendermint/rpc/grpc/types.pb.go ./rpc/grpc
.PHONY: proto-gen

# These targets are provided for convenience and are intended for local
Expand Down
3 changes: 1 addition & 2 deletions abci/types/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package types
import (
"io"

"github.com/gogo/protobuf/proto"

"github.com/cosmos/gogoproto/proto"
"github.com/tendermint/tendermint/libs/protoio"
)

Expand Down
2 changes: 1 addition & 1 deletion abci/types/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/gogo/protobuf/proto"
"github.com/cosmos/gogoproto/proto"
"github.com/stretchr/testify/assert"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
Expand Down
2 changes: 1 addition & 1 deletion abci/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"

"github.com/gogo/protobuf/jsonpb"
"github.com/cosmos/gogoproto/jsonpb"
)

const (
Expand Down
39 changes: 20 additions & 19 deletions abci/types/types.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocksync/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

"github.com/gogo/protobuf/proto"
"github.com/cosmos/gogoproto/proto"

bcproto "github.com/tendermint/tendermint/proto/tendermint/blocksync"
"github.com/tendermint/tendermint/types"
Expand Down
2 changes: 1 addition & 1 deletion blocksync/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"math"
"testing"

"github.com/gogo/protobuf/proto"
"github.com/cosmos/gogoproto/proto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down
2 changes: 1 addition & 1 deletion buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins:
- name: gogofaster
out: ./proto/
opt:
- Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types
- Mgoogle/protobuf/timestamp.proto=github.com/cosmos/gogoproto/types
- Mgoogle/protobuf/duration.proto=github.com/golang/protobuf/ptypes/duration
- plugins=grpc
- paths=source_relative
1 change: 0 additions & 1 deletion buf.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
build:
roots:
- proto
- third_party/proto
lint:
use:
- BASIC
Expand Down
2 changes: 1 addition & 1 deletion consensus/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

"github.com/gogo/protobuf/proto"
"github.com/cosmos/gogoproto/proto"

cstypes "github.com/tendermint/tendermint/consensus/types"
"github.com/tendermint/tendermint/libs/bits"
Expand Down
2 changes: 1 addition & 1 deletion consensus/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/gogo/protobuf/proto"
"github.com/cosmos/gogoproto/proto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down
2 changes: 1 addition & 1 deletion consensus/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

"github.com/gogo/protobuf/proto"
"github.com/cosmos/gogoproto/proto"

cstypes "github.com/tendermint/tendermint/consensus/types"
"github.com/tendermint/tendermint/libs/bits"
Expand Down
2 changes: 1 addition & 1 deletion consensus/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"
"time"

"github.com/gogo/protobuf/proto"
"github.com/cosmos/gogoproto/proto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"
Expand Down
2 changes: 1 addition & 1 deletion consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"sort"
"time"

"github.com/gogo/protobuf/proto"
"github.com/cosmos/gogoproto/proto"

cfg "github.com/tendermint/tendermint/config"
cstypes "github.com/tendermint/tendermint/consensus/types"
Expand Down
2 changes: 1 addition & 1 deletion consensus/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"path/filepath"
"time"

"github.com/gogo/protobuf/proto"
"github.com/cosmos/gogoproto/proto"

auto "github.com/tendermint/tendermint/libs/autofile"
tmjson "github.com/tendermint/tendermint/libs/json"
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/adr-009-ABCI-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ See the [references](#references) for more.

The native proto library in Go generates inflexible and verbose code.
Many in the Go community have adopted a fork called
[gogoproto](https://github.com/gogo/protobuf) that provides a
[gogoproto](https://github.com/cosmos/gogoproto) that provides a
variety of features aimed to improve the developer experience.
While `gogoproto` is nice, it creates an additional dependency, and compiling
the protobuf types for other languages has been reported to fail when `gogoproto` is used.
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/adr-081-protobuf-mgmt.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ We currently aim to:
[cosmos-sdk-buf-linting-ci]: https://github.com/cosmos/cosmos-sdk/blob/e6571906043b6751951a42b6546431b1c38b05bd/.github/workflows/proto.yml#L15
[\#8003]: https://github.com/tendermint/tendermint/issues/8003
[Nix]: https://nixos.org/
[gogoprotobuf]: https://github.com/gogo/protobuf
[gogoprotobuf]: https://github.com/cosmos/gogoproto
[Prototool]: https://github.com/uber/prototool
[buf-docs-gen]: https://docs.buf.build/bsr/documentation
[redo]: https://redo.readthedocs.io/en/latest/
4 changes: 2 additions & 2 deletions evidence/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"sync/atomic"
"time"

"github.com/gogo/protobuf/proto"
gogotypes "github.com/gogo/protobuf/types"
"github.com/cosmos/gogoproto/proto"
gogotypes "github.com/cosmos/gogoproto/types"
dbm "github.com/tendermint/tm-db"

clist "github.com/tendermint/tendermint/libs/clist"
Expand Down
Loading

0 comments on commit 4626bc9

Please sign in to comment.