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

Feat/v0.50.x cosmos sdk upgrade #500

Merged
merged 29 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
91ae4ce
build(deps): bump versions for cosmos sdk v0.50.1
amimart Jan 10, 2024
8a39efc
feat(app)!: update app for v0.50.x sdk changes
amimart Jan 10, 2024
dca3eb2
feat(cmd): update cmd wiring
amimart Jan 10, 2024
bb35f38
fix(test): allow default genesis creation in testutil
amimart Jan 10, 2024
e19e0dd
refactor(cmd): remove unused cmd
amimart Jan 10, 2024
85362d4
feat(app): re implement app state export
amimart Jan 10, 2024
ab068fc
feat(app): update old migrations
amimart Jan 10, 2024
96f970c
feat(vesting): update module
amimart Jan 10, 2024
7daf645
build(proto): rework protobuf generation
amimart Jan 11, 2024
2447dc3
refactor(proto): update types for v0.50
amimart Jan 11, 2024
0a3f18d
chore(proto): gen proto
amimart Jan 11, 2024
524f2f7
build(mock): rework mock generation
amimart Jan 11, 2024
ca000b2
feat(mint): migrate mint module
amimart Jan 11, 2024
a2b5286
feat(logic): migrate logic module
amimart Jan 11, 2024
5c01946
feat(wasm): upgrade lib wasmvm in docker build
amimart Jan 11, 2024
5a68427
build(proto): save buf lock
amimart Jan 11, 2024
97233e3
build: repair chain init
amimart Jan 11, 2024
950da33
refactor: cleanup unused parts
amimart Jan 11, 2024
1907f41
test(starship): migrate starship tests
amimart Jan 11, 2024
0eac693
chore(proto): update generated proto
amimart Jan 11, 2024
9598873
test: migrate them
amimart Jan 16, 2024
b77089f
style: make shell linter happy
amimart Jan 16, 2024
6092a9d
build(proto): fix proto gen script
amimart Jan 17, 2024
be741a3
feat!: remove upgrades
amimart Jan 17, 2024
354bf5c
build(proto): fix docker gen in github actions
amimart Jan 17, 2024
a891039
docs(cmd): update generated cmd docs
amimart Jan 17, 2024
f6a8005
style: make linters happy
amimart Jan 17, 2024
9703e34
test(e2e): try to migrate starship tests
amimart Jan 17, 2024
e4e0c8a
ci: disable starship triggers
amimart Jan 17, 2024
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
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ indent_size = 2
[*.proto]
indent_size = 2

[*.sh]
indent_size = 2

[*.go]
indent_style = tab
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ jobs:
files: |
proto/**/*.proto

- name: Setup buf
if: steps.changed-proto-files.outputs.any_changed == 'true'
uses: bufbuild/[email protected]

- name: Build and generate proto
if: steps.changed-proto-files.outputs.any_changed == 'true'
run: |
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Test E2E

on:
push:
branches:
- main
pull_request:
branches:
- main
on: {}
# push:
# branches:
# - main
# pull_request:
# branches:
# - main

concurrency:
group: e2e-test-${{ github.ref }}
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ linters:
- asciicheck
- bidichk
- bodyclose
- contextcheck
- cyclop
- dupl
- durationcheck
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ FROM golang:1.21-alpine3.17 AS go-builder
WORKDIR /src

# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.2.4/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.2.4/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.5.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.5.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a

# hadolint ignore=DL4006
RUN set -eux \
&& apk add --no-cache ca-certificates=20230506-r0 build-base=0.5-r3 git=2.38.5-r0 linux-headers=5.19.5-r0 \
&& sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 682a54082e131eaff9beec80ba3e5908113916fcb8ddf7c668cb2d97cb94c13c \
&& sha256sum /lib/libwasmvm_muslc.x86_64.a | grep ce3d892377d2523cf563e01120cb1436f9343f80be952c93f66aa94f5737b661 \
&& sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 2687afbdae1bc6c7c8b05ae20dfb8ffc7ddc5b4e056697d0f37853dfe294e913 \
&& sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 465e3a088e96fd009a11bfd234c69fb8a0556967677e54511c084f815cf9ce63 \
&& cp "/lib/libwasmvm_muslc.$(uname -m).a" /lib/libwasmvm_muslc.a

COPY . /src/
Expand Down
78 changes: 17 additions & 61 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ LEDGER_ENABLED ?= true
# Docker images
DOCKER_IMAGE_GOLANG = golang:1.21-alpine3.17
DOCKER_IMAGE_GOLANG_CI = golangci/golangci-lint:v1.54
DOCKER_IMAGE_BUF = okp4/buf-cosmos:1.4.7
DOCKER_IMAGE_PROTO = ghcr.io/cosmos/proto-builder:0.14.0
DOCKER_IMAGE_BUF = bufbuild/buf:1.4.0
DOCKER_PROTO_RUN := docker run --rm --user $(id -u):$(id -g) -v $(HOME)/.cache:/root/.cache -v $(PWD):/workspace --workdir /workspace $(DOCKER_IMAGE_PROTO)
DOCKER_BUF_RUN := docker run --rm -v $(HOME)/.cache:/root/.cache -v $(PWD):/workspace --workdir /workspace $(DOCKER_IMAGE_BUF)
DOCKER_BUILDX_BUILDER = okp4-builder
DOCKER_IMAGE_MARKDOWNLINT = thegeeklab/markdownlint-cli:0.32.2
DOCKER_IMAGE_GOTEMPLATE = hairyhenderson/gomplate:v3.11.3-alpine
Expand Down Expand Up @@ -124,18 +127,7 @@ lint-go: ## Lint go source code
.PHONY: lint-proto
lint-proto: ## Lint proto files
@echo "${COLOR_CYAN}🔍️ lint proto${COLOR_RESET}"
@docker run --rm \
-v ${HOME}/.cache:/root/.cache \
-v `pwd`:/proto \
-w /proto \
${DOCKER_IMAGE_BUF} \
lint proto -v
@docker run --rm \
-v ${HOME}/.cache:/root/.cache \
-v `pwd`:/proto \
-w /proto \
${DOCKER_IMAGE_BUF} \
format -d --exit-code
@$(DOCKER_BUF_RUN) lint proto -v

## Format:
.PHONY: format
Expand All @@ -154,12 +146,7 @@ format-go: ## Format go files
.PHONY: format-proto
format-proto: ## Format proto files
@echo "${COLOR_CYAN}📐 Formatting proto files${COLOR_RESET}"
@docker run --rm \
-v ${HOME}/.cache:/root/.cache \
-v `pwd`:/proto \
-w /proto \
${DOCKER_IMAGE_BUF} \
format -w
@$(DOCKER_BUF_RUN) format -w

## Build:
.PHONY: build
Expand Down Expand Up @@ -226,18 +213,18 @@ chain-init: build ## Initialize the blockchain with default settings.
--keyring-backend test \
--home "${CHAIN_HOME}"; \
\
${CHAIN_BINARY} add-genesis-account validator 1000000000uknow \
${CHAIN_BINARY} genesis add-genesis-account validator 1000000000uknow \
--keyring-backend test \
--home "${CHAIN_HOME}"; \
\
NODE_ID=`${CHAIN_BINARY} tendermint show-node-id --home ${CHAIN_HOME}`; \
${CHAIN_BINARY} gentx validator 1000000uknow \
${CHAIN_BINARY} genesis gentx validator 1000000uknow \
--node-id $$NODE_ID \
--chain-id=okp4-${CHAIN} \
--keyring-backend test \
--home "${CHAIN_HOME}"; \
\
${CHAIN_BINARY} collect-gentxs \
${CHAIN_BINARY} genesis collect-gentxs \
--home "${CHAIN_HOME}"

chain-start: build ## Start the blockchain with existing configuration (see chain-init)
Expand Down Expand Up @@ -316,54 +303,24 @@ clean: ## Remove all the files from the target folder

## Proto:
.PHONY: proto
proto: proto-format lint-proto proto-build proto-gen doc-proto ## Generate all resources for proto files (go, doc, etc.)

.PHONY: proto-format
proto-format: ## Format Protobuf files
@echo "${COLOR_CYAN} 📐 Formatting Protobuf files${COLOR_RESET}"
@docker run --rm \
-v ${HOME}/.cache:/root/.cache \
-v `pwd`:/proto \
-w /proto \
${DOCKER_IMAGE_BUF} \
format -w -v

.PHONY: proto-build
proto-build: ## Build all Protobuf files
@echo "${COLOR_CYAN} 🔨️Build Protobuf files${COLOR_RESET}"
@docker run --rm \
-v ${HOME}/.cache:/root/.cache \
-v `pwd`:/proto \
-w /proto \
${DOCKER_IMAGE_BUF} \
build proto -v
proto: format-proto lint-proto proto-gen doc-proto ## Generate all resources for proto files (go, doc, etc.)

.PHONY: proto-gen
proto-gen: proto-build ## Generate all the code from the Protobuf files
proto-gen: ## Generate all the code from the Protobuf files
@echo "${COLOR_CYAN} 📝 Generating code from Protobuf files${COLOR_RESET}"
@docker run --rm \
-v ${HOME}/.cache:/root/.cache \
-v `pwd`:/proto \
-w /proto \
${DOCKER_IMAGE_BUF} \
generate proto --template buf.gen.proto.yaml -v
@cp -r github.com/okp4/okp4d/x/* x/
@sudo rm -rf github.com
@$(DOCKER_PROTO_RUN) sh ./scripts/protocgen-code.sh


## Documentation:
.PHONY: doc
doc: doc-proto doc-command doc-predicate ## Generate all the documentation

.PHONY: doc-proto
doc-proto: proto-gen ## Generate the documentation from the Protobuf files
@echo "${COLOR_CYAN} 📝 Generating doc from Protobuf files${COLOR_RESET}"
@$(DOCKER_PROTO_RUN) sh ./scripts/protocgen-doc.sh
@for MODULE in $(shell find proto -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq | xargs dirname) ; do \
echo "${COLOR_CYAN} 📖 Generate documentation for $${MODULE} module${COLOR_RESET}" ; \
docker run --rm \
-v ${HOME}/.cache:/root/.cache \
-v `pwd`:/proto \
-w /proto \
${DOCKER_IMAGE_BUF} \
generate --path $${MODULE} --template buf.gen.doc.yaml -v ; \
DEFAULT_DATASOURCE="./docs/proto/templates/default.yaml" ; \
MODULE_DATASOURCE="merge:./$${MODULE}/docs.yaml|$${DEFAULT_DATASOURCE}" ; \
DATASOURCE="docs=`[ -f $${MODULE}/docs.yaml ] && echo $$MODULE_DATASOURCE || echo $${DEFAULT_DATASOURCE}`" ; \
Expand All @@ -372,8 +329,7 @@ doc-proto: proto-gen ## Generate the documentation from the Protobuf files
-v `pwd`:/usr/src/okp4d \
-w /usr/src/okp4d \
${DOCKER_IMAGE_GOTEMPLATE} \
-d $$DATASOURCE -f docs/proto/docs.md -o docs/$${MODULE}.md ; \
rm -f docs/proto/docs.md ; \
-d $$DATASOURCE -f docs/$${MODULE}.md -o docs/$${MODULE}.md ; \
done
@docker run --rm \
-v `pwd`:/usr/src/okp4d \
Expand Down Expand Up @@ -420,7 +376,7 @@ mock: ## Generate all the mocks (for tests)
@mockgen -source=x/mint/types/expected_keepers.go -package testutil -destination x/mint/testutil/expected_keepers_mocks.go
@mockgen -source=x/vesting/types/expected_keepers.go -package testutil -destination x/vesting/testutil/expected_keepers_mocks.go
@mockgen -source=x/logic/types/expected_keepers.go -package testutil -destination x/logic/testutil/expected_keepers_mocks.go
@mockgen -destination x/logic/testutil/gas_mocks.go -package testutil github.com/cosmos/cosmos-sdk/store/types GasMeter
@mockgen -destination x/logic/testutil/gas_mocks.go -package testutil cosmossdk.io/store/types GasMeter

## Release:
.PHONY: release-assets
Expand Down
36 changes: 21 additions & 15 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
package app

import (
"errors"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"

errorsmod "cosmossdk.io/errors"
corestoretypes "cosmossdk.io/core/store"
circuitante "cosmossdk.io/x/circuit/ante"
circuitkeeper "cosmossdk.io/x/circuit/keeper"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"

ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
"github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
"github.com/cosmos/ibc-go/v8/modules/core/keeper"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions

IBCKeeper *keeper.Keeper
WasmConfig *wasmTypes.WasmConfig
TXCounterStoreKey storetypes.StoreKey
IBCKeeper *keeper.Keeper
WasmConfig *wasmTypes.WasmConfig
WasmKeeper *wasmkeeper.Keeper
TXCounterStoreService corestoretypes.KVStoreService
CircuitKeeper *circuitkeeper.Keeper
}

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
return nil, errors.New("account keeper is required for AnteHandler")
}
if options.BankKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
return nil, errors.New("bank keeper is required for AnteHandler")
}
if options.SignModeHandler == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
return nil, errors.New("sign mode handler is required for ante builder")
}
if options.WasmConfig == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder")
return nil, errors.New("wasm config is required for ante builder")
}
if options.TXCounterStoreKey == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder")
if options.TXCounterStoreService == nil {
return nil, errors.New("wasm store service is required for ante builder")
}

sigGasConsumer := options.SigGasConsumer
Expand All @@ -50,7 +54,9 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey),
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService),
wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()),
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
Expand Down
Loading
Loading