Skip to content

Commit 1cbb558

Browse files
yihuangtomtau
authored andcommitted
Problem: cosmos-sdk 0.46 is not used (#828)
Solution: - changed app and modules based on the API breaking changes in 0.46 (the new modules are not yet added)
1 parent 41c662f commit 1cbb558

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1043
-3053
lines changed

.github/workflows/nix.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
flags: integration_tests
4747
- name: Tar debug files
4848
if: failure()
49-
run: tar cfz debug_files.tar.gz -C /tmp/pytest-of-runner .
49+
run: tar cfz debug_files.tar.gz -C "$TMPDIR/pytest-of-runner" .
5050
- uses: actions/upload-artifact@v2
5151
if: failure()
5252
with:

Makefile

+92-35
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,116 @@ GOLANG_CROSS_VERSION = v1.18
44

55

66
VERSION := $(shell echo $(shell git describe --tags 2>/dev/null ) | sed 's/^v//')
7+
TMVERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::')
78
COMMIT := $(shell git log -1 --format='%H')
89
NETWORK ?= mainnet
910
COVERAGE ?= coverage.txt
1011
BUILDDIR ?= $(CURDIR)/build
1112
LEDGER_ENABLED ?= true
13+
# RocksDB is a native dependency, so we don't assume the library is installed.
14+
# Instead, it must be explicitly enabled and we warn when it is not.
15+
ENABLE_ROCKSDB ?= false
16+
17+
export GO111MODULE = on
18+
19+
build_tags = netgo
20+
ifeq ($(LEDGER_ENABLED),true)
21+
ifeq ($(OS),Windows_NT)
22+
GCCEXE = $(shell where gcc.exe 2> NUL)
23+
ifeq ($(GCCEXE),)
24+
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
25+
else
26+
build_tags += ledger
27+
endif
28+
else
29+
UNAME_S = $(shell uname -s)
30+
ifeq ($(UNAME_S),OpenBSD)
31+
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
32+
else
33+
GCC = $(shell command -v gcc 2> /dev/null)
34+
ifeq ($(GCC),)
35+
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
36+
else
37+
build_tags += ledger
38+
endif
39+
endif
40+
endif
41+
endif
42+
43+
ifeq (secp,$(findstring secp,$(COSMOS_BUILD_OPTIONS)))
44+
build_tags += libsecp256k1_sdk
45+
endif
46+
47+
ifeq ($(ENABLE_ROCKSDB),true)
48+
BUILD_TAGS += rocksdb_build
49+
test_tags += rocksdb_build
50+
else
51+
$(warning RocksDB support is disabled; to build and test with RocksDB support, set ENABLE_ROCKSDB=true)
52+
endif
1253

1354
# DB backend selection
1455
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
15-
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
56+
build_tags += gcc
1657
endif
1758
ifeq (badgerdb,$(findstring badgerdb,$(COSMOS_BUILD_OPTIONS)))
18-
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=badgerdb
19-
BUILD_TAGS := $(BUILD_TAGS),badgerdb
59+
BUILD_TAGS += badgerdb
2060
endif
2161
# handle rocksdb
2262
ifeq (rocksdb,$(findstring rocksdb,$(COSMOS_BUILD_OPTIONS)))
23-
$(info ################################################################)
24-
$(info To use rocksdb, you need to install rocksdb first)
25-
$(info Please follow this guide https://github.com/rockset/rocksdb-cloud/blob/master/INSTALL.md)
26-
$(info ################################################################)
63+
ifneq ($(ENABLE_ROCKSDB),true)
64+
$(error Cannot use RocksDB backend unless ENABLE_ROCKSDB=true)
65+
endif
2766
CGO_ENABLED=1
28-
BUILD_TAGS := $(BUILD_TAGS),rocksdb
29-
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=rocksdb
67+
BUILD_TAGS += rocksdb
3068
endif
3169
# handle boltdb
3270
ifeq (boltdb,$(findstring boltdb,$(COSMOS_BUILD_OPTIONS)))
33-
BUILD_TAGS := $(BUILD_TAGS),boltdb
34-
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=boltdb
71+
BUILD_TAGS += boltdb
72+
endif
73+
74+
ifeq ($(NETWORK),testnet)
75+
BUILD_TAGS += testnet
76+
test_tags += testnet
3577
endif
3678

37-
ldflags += -X github.com/cosmos/cosmos-sdk/version.Name=crypto-org-chain-chain \
79+
build_tags += $(BUILD_TAGS)
80+
build_tags := $(strip $(build_tags))
81+
82+
whitespace :=
83+
whitespace += $(whitespace)
84+
comma := ,
85+
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
86+
87+
# process linker flags
88+
89+
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=crypto-org-chain-chain \
3890
-X github.com/cosmos/cosmos-sdk/version.AppName=chain-maind \
3991
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
40-
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)
92+
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
93+
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TMVERSION) \
94+
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
4195

42-
BUILD_FLAGS := -ldflags '$(ldflags)'
43-
TESTNET_FLAGS ?=
96+
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
97+
ldflags += -w -s
98+
endif
99+
ldflags += $(LDFLAGS)
100+
ldflags := $(strip $(ldflags))
44101

45-
ledger ?= HID
46-
ifeq ($(LEDGER_ENABLED),true)
47-
BUILD_TAGS := -tags $(BUILD_TAGS),cgo,ledger,!test_ledger_mock,!ledger_mock
48-
ifeq ($(ledger), ZEMU)
49-
BUILD_TAGS := $(BUILD_TAGS),ledger_zemu
50-
else
51-
BUILD_TAGS := $(BUILD_TAGS),!ledger_zemu
52-
endif
102+
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
103+
# check for nostrip option
104+
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
105+
BUILD_FLAGS += -trimpath
53106
endif
54107

55-
ifeq ($(NETWORK),testnet)
56-
BUILD_TAGS := $(BUILD_TAGS),testnet
57-
TEST_TAGS := "--tags=testnet"
108+
# Check for debug option
109+
ifeq (debug,$(findstring debug,$(COSMOS_BUILD_OPTIONS)))
110+
BUILD_FLAGS += -gcflags "all=-N -l"
58111
endif
59112

113+
TEST_FLAGS := -tags "$(test_tags)"
114+
115+
TESTNET_FLAGS ?=
116+
60117
SIMAPP = github.com/crypto-org-chain/chain-main/v4/app
61118
BINDIR ?= ~/go/bin
62119

@@ -68,13 +125,13 @@ download:
68125
git submodule update --init --recursive
69126

70127
install: check-network go.sum
71-
go install -mod=readonly $(BUILD_FLAGS) $(BUILD_TAGS) ./cmd/chain-maind
128+
go install -mod=readonly $(BUILD_FLAGS) ./cmd/chain-maind
72129

73130
build: check-network go.sum
74-
go build -mod=readonly $(BUILD_FLAGS) $(BUILD_TAGS) -o $(BUILDDIR)/chain-maind ./cmd/chain-maind
131+
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/chain-maind ./cmd/chain-maind
75132

76133
buildwindows: check-network go.sum
77-
go build -buildmode=exe -mod=readonly $(BUILD_FLAGS) $(BUILD_TAGS) -o $(BUILDDIR)/chain-maind ./cmd/chain-maind
134+
go build -buildmode=exe -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/chain-maind ./cmd/chain-maind
78135

79136

80137
.PHONY: build
@@ -98,7 +155,7 @@ go.sum: go.mod
98155
GO111MODULE=on go mod verify
99156

100157
test: check-network
101-
@go test $(TEST_TAGS) -v -mod=readonly $(PACKAGES) -coverprofile=$(COVERAGE) -covermode=atomic
158+
@go test $(TEST_FLAGS) -v -mod=readonly $(PACKAGES) -coverprofile=$(COVERAGE) -covermode=atomic
102159
.PHONY: test
103160

104161
# look into .golangci.yml for enabling / disabling linters
@@ -117,22 +174,22 @@ lint-ci:
117174

118175
test-sim-nondeterminism: check-network
119176
@echo "Running non-determinism test..."
120-
@go test $(TEST_TAGS) -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
177+
@go test $(TEST_FLAGS) -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
121178
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h
122179

123180
test-sim-custom-genesis-fast: check-network
124181
@echo "Running custom genesis simulation..."
125182
@echo "By default, ${HOME}/.chain-maind/config/genesis.json will be used."
126-
@go test $(TEST_TAGS) -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.gaiad/config/genesis.json \
127-
-Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h
183+
@go test $(TEST_FLAGS) -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.gaiad/config/genesis.json \
184+
-Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h -ExitOnFail
128185

129186
test-sim-import-export:
130187
@echo "Running Chain import/export simulation. This may take several minutes..."
131-
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 25 5 TestAppImportExport
188+
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 25 5 TestAppImportExport
132189

133190
test-sim-after-import:
134191
@echo "Running application simulation-after-import. This may take several minutes..."
135-
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) 50 5 TestAppSimulationAfterImport
192+
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppSimulationAfterImport
136193

137194
###############################################################################
138195
### Localnet ###

app/ante.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
sdk "github.com/cosmos/cosmos-sdk/types"
55
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
66
"github.com/cosmos/cosmos-sdk/x/auth/ante"
7-
ibcante "github.com/cosmos/ibc-go/v4/modules/core/ante"
8-
"github.com/cosmos/ibc-go/v4/modules/core/keeper"
7+
ibcante "github.com/cosmos/ibc-go/v5/modules/core/ante"
8+
"github.com/cosmos/ibc-go/v5/modules/core/keeper"
99
)
1010

1111
// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
@@ -34,20 +34,19 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
3434

3535
anteDecorators := []sdk.AnteDecorator{
3636
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
37-
ante.NewRejectExtensionOptionsDecorator(),
38-
ante.NewMempoolFeeDecorator(),
37+
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
3938
ante.NewValidateBasicDecorator(),
4039
ante.NewTxTimeoutHeightDecorator(),
4140
ante.NewValidateMemoDecorator(options.AccountKeeper),
4241
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
43-
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
42+
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
4443
// SetPubKeyDecorator must be called before all signature verification decorators
4544
ante.NewSetPubKeyDecorator(options.AccountKeeper),
4645
ante.NewValidateSigCountDecorator(options.AccountKeeper),
4746
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
4847
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
4948
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
50-
ibcante.NewAnteDecorator(options.IBCKeeper),
49+
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
5150
}
5251

5352
return sdk.ChainAnteDecorators(anteDecorators...), nil

0 commit comments

Comments
 (0)