Skip to content

Commit

Permalink
Merge pull request #272 from scorpioborn/upgrade/cosmos-sdk-v0.47.5
Browse files Browse the repository at this point in the history
  • Loading branch information
3eyedraga authored Feb 5, 2024
2 parents c4f3ec1 + ad56c50 commit 1b17999
Show file tree
Hide file tree
Showing 259 changed files with 4,143 additions and 3,297 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ updates:
schedule:
interval: weekly
ignore:
- dependency-name: "github.com/tendermint/tendermint"
- dependency-name: "github.com/cometbft/cometbft"
update-types: ["version-update:semver-major", "version-update:semver-minor"]
open-pull-requests-limit: 10
33 changes: 22 additions & 11 deletions .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
name: Run Gosec
on:
push:
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
branches:
- master
pull_request:
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
branches:
- master
jobs:
tests:
permissions:
security-events: write

runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
path: /usr/local/go/bin
go-version: '1.18.10'
- name: Checkout Source
uses: actions/checkout@v2
- name: Set env vars
run: |
echo "${HOME}/goroot/bin" >> $GITHUB_PATH
uses: actions/checkout@v3

- name: Run Gosec Security Scanner
uses: cosmos/gosec@master
uses: securego/gosec@master
with:
# we let the report trigger content trigger a failure using the GitHub Security features.
args: "-no-fail -fmt sarif -out results.sarif ./..."

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
args: ./...
# Path to SARIF file relative to the root of the repository
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ jobs:
-
name: Run documentation linter
if: env.GIT_DIFF
run: make mdlint
run: make mdlint
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
install-tparse:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: 1.21
- name: Display go version
run: go version
- name: install tparse
run: |
export GO111MODULE="on" && go install github.com/mfridman/tparse@v0.11.1
export GO111MODULE="on" && go install github.com/mfridman/tparse@v0.13.1
- uses: actions/cache@v2.1.6
with:
path: ~/go/bin
Expand All @@ -33,7 +33,7 @@ jobs:
go-arch: ["amd64", "arm", "arm64"]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: 1.21
- uses: technote-space/get-diff-action@v4
Expand All @@ -49,7 +49,7 @@ jobs:
split-test-files:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: 1.21
- uses: actions/checkout@v2
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
part: ["00", "01", "02", "03"]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: 1.21
- uses: technote-space/get-diff-action@v4
Expand Down Expand Up @@ -162,7 +162,7 @@ jobs:
part: ["00", "01", "02", "03"]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: 1.21
- uses: technote-space/get-diff-action@v4
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
run:
tests: true
timeout: 10m
timeout: 15m
sort-results: true
allow-parallel-runners: true
exclude-dir: testutil/testdata_pulsar
Expand Down Expand Up @@ -30,7 +30,6 @@ linters:
- ineffassign
- makezero
- misspell
- nakedret
- nilnil
- promlinter
- staticcheck
Expand Down
37 changes: 17 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endif
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7"
TM_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::') # grab everything after the space in "github.com/cometbft/cometbft v0.34.7"
HTTPS_GIT := https://github.com/sge-network/sge.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR)/proto:/workspace --workdir /workspace bufbuild/buf
Expand Down Expand Up @@ -72,7 +72,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sge \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION)
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(TM_VERSION)

# DB backend selection
ifeq (cleveldb,$(findstring cleveldb,$(SGE_BUILD_OPTIONS)))
Expand Down Expand Up @@ -157,7 +157,7 @@ distclean: clean
### Proto ###
###############################################################################

proto-all: proto-format proto-gen
proto-all: proto-format proto-lint proto-gen

docs:
@echo
Expand All @@ -177,36 +177,33 @@ docs:
@echo
.PHONY: docs

protoVer=v0.8
protoImageName=sgenetwork/sge-proto-gen:$(protoVer)
containerProtoGen=cosmos-sdk-proto-gen-$(protoVer)
containerProtoFmt=cosmos-sdk-proto-fmt-$(protoVer)

# this can be used to regenrate the proto image
proto-image:
cd proto; docker build -t $(protoImageName) -f Dockerfile .
protoVer=0.13.1
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
# containerProtoGen=cosmos-sdk-proto-gen-$(protoVer)
# containerProtoFmt=cosmos-sdk-proto-fmt-$(protoVer)

proto-gen:
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
sh ./scripts/protocgen.sh; fi
@$(protoImage) sh ./scripts/protocgen.sh

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
@$(protoImage) sh ./scripts/protoc-swagger-gen.sh
$(MAKE) update-swagger-docs

proto-format:
@echo "Formatting Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;

proto-image-build:
@DOCKER_BUILDKIT=1 docker build -t $(protoImageName) -f ./proto/Dockerfile ./proto

proto-image-push:
docker push $(protoImageName)

proto-lint:
@$(DOCKER_BUF) lint --error-format=json
@$(protoImage) buf lint --error-format=json

proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=master
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=master


###############################################################################
Expand Down
43 changes: 29 additions & 14 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import (
"os"
"path/filepath"

dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/libs/log"
tmos "github.com/cometbft/cometbft/libs/os"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
Expand All @@ -17,24 +25,25 @@ import (
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdksimapp "github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibcclientHandler "github.com/cosmos/ibc-go/v5/modules/core/02-client/client"
ibcclientHandler "github.com/cosmos/ibc-go/v7/modules/core/02-client/client"

"github.com/sge-network/sge/app/keepers"
sgeappparams "github.com/sge-network/sge/app/params"
"github.com/sge-network/sge/app/upgrades"
Expand All @@ -45,12 +54,7 @@ import (
v5 "github.com/sge-network/sge/app/upgrades/v5"
v6 "github.com/sge-network/sge/app/upgrades/v6"
v7 "github.com/sge-network/sge/app/upgrades/v7"

abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"
v8 "github.com/sge-network/sge/app/upgrades/v8"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
Expand All @@ -61,7 +65,6 @@ func getGovProposalHandlers() []govclient.ProposalHandler {

govProposalHandlers = append(govProposalHandlers,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
ibcclientHandler.UpdateClientProposalHandler,
Expand All @@ -82,11 +85,12 @@ var (
v5.Upgrade,
v6.Upgrade,
v7.Upgrade,
v8.Upgrade,
}
)

var (
_ sdksimapp.App = (*SgeApp)(nil)
_ runtime.AppI = (*SgeApp)(nil)
_ servertypes.Application = (*SgeApp)(nil)
)

Expand Down Expand Up @@ -161,7 +165,6 @@ func NewSgeApp(
bApp,
cdc,
mAccPerms,
app.ModuleAccountAddrs(),
skipUpgradeHeights,
homePath,
invCheckPeriod,
Expand Down Expand Up @@ -191,8 +194,7 @@ func NewSgeApp(
// can do so safely.
app.mm.SetOrderInitGenesis(orderInitBlockers()...)

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.mm.RegisterInvariants(app.CrisisKeeper)

app.configurator = module.NewConfigurator(
app.appCodec,
Expand All @@ -201,6 +203,15 @@ func NewSgeApp(
)
app.mm.RegisterServices(app.configurator)

// v47 - no dependecy injection, so register new gRPC services.
//#nosec
autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules))
reflectionSvc, err := runtimeservices.NewReflectionService()
if err != nil {
panic(err)
}
reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc)

// create the simulation manager and define the order of the modules for deterministic simulations
//
// NOTE: this is not required apps that don't use the simulator for fuzz testing
Expand Down Expand Up @@ -363,6 +374,10 @@ func (app *SgeApp) RegisterTendermintService(clientCtx client.Context) {
tmservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query)
}

func (app *SgeApp) RegisterNodeService(clientCtx client.Context) {
nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter())
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
func (app *SgeApp) setupUpgradeStoreLoaders() {
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
Expand Down
13 changes: 5 additions & 8 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ package app_test
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/tendermint/tendermint/libs/log"
tmdb "github.com/tendermint/tm-db"

sdksimapp "github.com/cosmos/cosmos-sdk/simapp"

tmdb "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/sge-network/sge/app"
"github.com/stretchr/testify/require"
)

func TestApp(t *testing.T) {
Expand All @@ -26,7 +23,7 @@ func TestApp(t *testing.T) {
"",
0,
encCdc,
sdksimapp.EmptyAppOptions{},
simtestutil.EmptyAppOptions{},
)
}
require.NotPanics(t, panicFunc)
Expand Down
7 changes: 3 additions & 4 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (
"fmt"
"log"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
Expand All @@ -17,7 +16,7 @@ import (
// ExportAppStateAndValidators exports the state of the application for a genesis
// file.
func (app *SgeApp) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string,
forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string,
) (servertypes.ExportedApp, error) {
// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
Expand All @@ -30,7 +29,7 @@ func (app *SgeApp) ExportAppStateAndValidators(
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
}

genState := app.mm.ExportGenesis(ctx, app.appCodec)
genState := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
appState, err := json.MarshalIndent(genState, "", " ")
if err != nil {
return servertypes.ExportedApp{}, err
Expand Down
Loading

0 comments on commit 1b17999

Please sign in to comment.