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: cosmos-sdk v0.42.x, modernized for easier migrations #14427

Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 2 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 6
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: actions/checkout@v3
- uses: golangci/golangci-lint-action@master
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.39
version: latest
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: env.GIT_DIFF
15 changes: 5 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
run:
tests: false
# # timeout for analysis, e.g. 30s, 5m, default is 1m
# timeout: 5m
tests: true
timeout: 5m
concurrency: 4

linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
# - errcheck
- errcheck
- goconst
- gocritic
- gofmt
- goimports
- gofumpt
- golint
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- maligned
- misspell
- nakedret
- prealloc
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unused
- unparam
- misspell
# - wsl
- nolintlint

issues:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ proto-check-breaking:
@$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master


TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc6/proto/tendermint
TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.24/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master
CONFIO_URL = https://raw.githubusercontent.com/confio/ics23/v0.6.3
Expand Down
48 changes: 11 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,27 @@ parent:
order: false
-->

<div align="center">
<h1> Cosmos SDK </h1>
</div>

![banner](docs/cosmos-sdk-image.jpg)

<div align="center">
<a href="https://github.com/cosmos/cosmos-sdk/releases/latest">
<img alt="Version" src="https://img.shields.io/github/tag/cosmos/cosmos-sdk.svg" />
</a>
<a href="https://github.com/cosmos/cosmos-sdk/blob/master/LICENSE">
<img alt="License: Apache-2.0" src="https://img.shields.io/github/license/cosmos/cosmos-sdk.svg" />
</a>
<a href="https://pkg.go.dev/github.com/cosmos/cosmos-sdk?tab=doc">
<img alt="GoDoc" src="https://godoc.org/github.com/cosmos/cosmos-sdk?status.svg" />
</a>
<a href="https://goreportcard.com/report/github.com/cosmos/cosmos-sdk">
<img alt="Go report card" src="https://goreportcard.com/badge/github.com/cosmos/cosmos-sdk" />
</a>
<a href="https://codecov.io/gh/cosmos/cosmos-sdk">
<img alt="Code Coverage" src="https://codecov.io/gh/cosmos/cosmos-sdk/branch/master/graph/badge.svg" />
</a>
</div>
<div align="center">
<a href="https://github.com/cosmos/cosmos-sdk">
<img alt="Lines Of Code" src="https://tokei.rs/b1/github/cosmos/cosmos-sdk" />
</a>
<a href="https://discord.gg/AzefAFd">
<img alt="Discord" src="https://img.shields.io/discord/669268347736686612.svg" />
</a>
<a href="https://sourcegraph.com/github.com/cosmos/cosmos-sdk?badge">
<img alt="Imported by" src="https://sourcegraph.com/github.com/cosmos/cosmos-sdk/-/badge.svg" />
</a>
<img alt="Sims" src="https://github.com/cosmos/cosmos-sdk/workflows/Sims/badge.svg" />
<img alt="Lint Satus" src="https://github.com/cosmos/cosmos-sdk/workflows/Lint/badge.svg" />
</div>
# This version of the SDK is deprecated

## Cosmos-SDK v0.42.x

This build of the cosmos-sdk has been updated for easier migrations:

* it uses iavl v0.19.4 with fast node on by default
* it's been linted so that if you encounter issues in your migration, those issues stand out when using a linter.
* it uses tendermint v0.34.24

**Please kindly note that this is unsupported software.**

## Cosmos-SDK Propaganda

The Cosmos-SDK is a framework for building blockchain applications in Golang.
It is being used to build [`Gaia`](https://github.com/cosmos/gaia), the first implementation of the Cosmos Hub.

**WARNING**: The SDK has mostly stabilized, but we are still making some
breaking changes.

**Note**: Requires [Go 1.15+](https://golang.org/dl/)
**Note**: Requires [Go 1.18+](https://golang.org/dl/)

## Quick Start

Expand Down
6 changes: 2 additions & 4 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ const (
runTxModeDeliver // Deliver a transaction
)

var (
_ abci.Application = (*BaseApp)(nil)
)
var _ abci.Application = (*BaseApp)(nil)

type (
// Enum mode for app.runTx
Expand All @@ -44,7 +42,7 @@ type (
)

// BaseApp reflects the ABCI application implementation.
type BaseApp struct { // nolint: maligned
type BaseApp struct { //nolint: maligned
// initialized on creation
logger log.Logger
name string // application name from abci.Info
Expand Down
4 changes: 1 addition & 3 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/binary"
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"os"
"strings"
Expand Down Expand Up @@ -134,7 +133,7 @@ func setupBaseAppWithSnapshots(t *testing.T, blocks uint, blockTxs int, options

snapshotInterval := uint64(2)
snapshotTimeout := 1 * time.Minute
snapshotDir, err := ioutil.TempDir("", "baseapp")
snapshotDir, err := os.MkdirTemp("", "baseapp")
require.NoError(t, err)
snapshotStore, err := snapshots.NewStore(dbm.NewMemDB(), snapshotDir)
require.NoError(t, err)
Expand Down Expand Up @@ -1292,7 +1291,6 @@ func TestTxGasLimits(t *testing.T) {

return newCtx, nil
})

}

routerOpt := func(bapp *BaseApp) {
Expand Down
6 changes: 3 additions & 3 deletions baseapp/msg_service_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func (msr *MsgServiceRouter) Handler(methodName string) MsgServiceHandler {
// service description, handler is an object which implements that gRPC service.
//
// This function PANICs:
// - if it is called before the service `Msg`s have been registered using
// RegisterInterfaces,
// - or if a service is being registered twice.
// - if it is called before the service `Msg`s have been registered using
// RegisterInterfaces,
// - or if a service is being registered twice.
func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler interface{}) {
// Adds a top-level query handler based on the gRPC service name.
for _, method := range sd.Methods {
Expand Down
1 change: 0 additions & 1 deletion client/broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,4 @@ func TestBroadcastError(t *testing.T) {
require.Equal(t, txHash, resp.TxHash)
}
}

}
6 changes: 3 additions & 3 deletions client/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config_test
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"os"
"testing"

Expand Down Expand Up @@ -53,12 +53,12 @@ func TestConfigCmd(t *testing.T) {
_, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
require.NoError(t, err)

//./build/simd config node //http://localhost:1
// ./build/simd config node //http://localhost:1
b := bytes.NewBufferString("")
cmd.SetOut(b)
cmd.SetArgs([]string{"node"})
cmd.Execute()
out, err := ioutil.ReadAll(b)
out, err := io.ReadAll(b)
require.NoError(t, err)
require.Equal(t, string(out), testNode1+"\n")
}
Expand Down
3 changes: 1 addition & 2 deletions client/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
"bytes"
"io/ioutil"
"os"
"text/template"

Expand Down Expand Up @@ -43,7 +42,7 @@ func writeConfigToFile(configFilePath string, config *ClientConfig) error {
return err
}

return ioutil.WriteFile(configFilePath, buffer.Bytes(), 0600)
return os.WriteFile(configFilePath, buffer.Bytes(), 0o600)
}

// ensureConfigPath creates a directory configPath if it does not exist
Expand Down
8 changes: 4 additions & 4 deletions client/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestContext_PrintObject(t *testing.T) {
require.NoError(t, err)
require.Equal(t,
`{"animal":{"@type":"/testdata.Dog","size":"big","name":"Spot"},"x":"10"}
`, string(buf.Bytes()))
`, buf.String())

// yaml
buf = &bytes.Buffer{}
Expand All @@ -65,7 +65,7 @@ func TestContext_PrintObject(t *testing.T) {
name: Spot
size: big
x: "10"
`, string(buf.Bytes()))
`, buf.String())

//
// amino
Expand All @@ -81,7 +81,7 @@ x: "10"
require.NoError(t, err)
require.Equal(t,
`{"type":"testdata/HasAnimal","value":{"animal":{"type":"testdata/Dog","value":{"size":"big","name":"Spot"}},"x":"10"}}
`, string(buf.Bytes()))
`, buf.String())

// yaml
buf = &bytes.Buffer{}
Expand All @@ -98,7 +98,7 @@ value:
name: Spot
size: big
x: "10"
`, string(buf.Bytes()))
`, buf.String())
}

func TestCLIQueryConn(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions client/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ $ %s debug addr cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
`, version.AppName),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {

addrString := args[0]
var addr []byte

Expand All @@ -147,7 +146,6 @@ $ %s debug addr cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg

if err3 != nil {
return fmt.Errorf("expected hex or bech32. Got errors: hex: %v, bech32 acc: %v, bech32 val: %v", err, err2, err3)

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func AddQueryFlagsToCmd(cmd *cobra.Command) {
cmd.Flags().Int64(FlagHeight, 0, "Use a specific height to query state at (this can error if the node is pruning state)")
cmd.Flags().StringP(tmcli.OutputFlag, "o", "text", "Output format (text|json)")

cmd.MarkFlagRequired(FlagChainID)
cmd.MarkFlagRequired(FlagChainID) // nolint: errcheck

cmd.SetErr(cmd.ErrOrStderr())
cmd.SetOut(cmd.OutOrStdout())
Expand Down
4 changes: 2 additions & 2 deletions client/grpc/reflection/reflection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.queryClient = queryClient
}

func (s IntegrationTestSuite) TestSimulateService() {
func (s IntegrationTestSuite) TestSimulateService() { //nolint:govet // this is a test and we're ok with copying locks.
// We will test the following interface for testing.
var iface = "cosmos.evidence.v1beta1.Evidence"
iface := "cosmos.evidence.v1beta1.Evidence"

// Test that "cosmos.evidence.v1beta1.Evidence" is included in the
// interfaces.
Expand Down
7 changes: 4 additions & 3 deletions client/grpc/tmservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ type queryServer struct {
interfaceRegistry codectypes.InterfaceRegistry
}

var _ ServiceServer = queryServer{}
var _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{}
var (
_ ServiceServer = queryServer{}
_ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{}
)

// NewQueryServer creates a new tendermint query server.
func NewQueryServer(clientCtx client.Context, interfaceRegistry codectypes.InterfaceRegistry) ServiceServer {
Expand Down Expand Up @@ -148,7 +150,6 @@ func (s queryServer) GetValidatorSetByHeight(ctx context.Context, req *GetValida
}

validatorsRes, err := rpc.GetValidators(s.clientCtx, &req.Height, &page, &limit)

if err != nil {
return nil, err
}
Expand Down
Loading