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

Onboarding middleware conflict resolve #25

Merged
merged 22 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a805bde
feat: add workflow to build, test, codecov for ci/cd
poorphd Jul 26, 2023
1ad3ad8
fix: seperate antehandler for simulation
poorphd Jul 26, 2023
f107ff3
fix: simulation errors
poorphd Jul 26, 2023
98bc8d3
fix: simulation workflow, update sims.yml, add GOPATH on makefile
poorphd Jul 26, 2023
a719d63
fix: removing unused keeper from handler options
poorphd Jul 27, 2023
ab3aadf
fix: update simulation target modules, refactor duplicated struct
dongsam Jul 27, 2023
9b0c741
remove x/recovery
tkkwon1998 Jul 28, 2023
bc64389
remove recovery proto
tkkwon1998 Jul 28, 2023
78077e5
remove recovery imports in app.go
tkkwon1998 Jul 28, 2023
11428d8
add placeholder for ICS4wrapper in transferKeeper init
tkkwon1998 Jul 28, 2023
2ff88d0
Merge pull request #109 from Plex-Engineer/plex/remove-recovery-module
tkkwon1998 Jul 31, 2023
8d209a5
Merge remote-tracking branch 'origin/canto-main' into simulation-cicd
poorphd Jul 31, 2023
4d1979a
fix: remove recovery from storeKeysPrefixes
poorphd Jul 31, 2023
f810e8d
fix: simulation seed randomness was removed to make the ci/cd result …
dongsam Jul 31, 2023
30ebfbc
chore: add branches rule for workflow
dongsam Jul 31, 2023
d780d52
Merge pull request #110 from b-harvest/simulation-cicd
tkkwon1998 Aug 1, 2023
9e54c11
Merge remote-tracking branch 'origin/canto-main' into onboarding-midd…
poorphd Jul 31, 2023
9bcebc8
Merge remote-tracking branch 'upstream/main' into onboarding-middlewa…
poorphd Aug 2, 2023
13f26e8
fix: SetupTestingCantoApp
poorphd Aug 2, 2023
b9e47d5
fix: coinswap module is added to simulation manager
poorphd Aug 2, 2023
6626290
fix: bug in coinswap module's param change simulation
poorphd Aug 3, 2023
6edd5d4
Merge commit 'd780d52648475e8887cacce73acec93ae59fb34b' into onboardi…
dongsam Aug 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/.codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# To validate:
# cat codecov.yml | curl --data-binary @- https://codecov.io/validate

codecov:
notify:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "50...80"

status:
project:
default:
target: auto
threshold: 1%
patch:
default:
enabled: no # disable patch since it is noisy and not correct
if_not_found: success

comment: true
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build Canto Core
# This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed
on:
pull_request:
push:
branches:
- main
- release/**
- upgrade/**
permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}-build
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go-arch: ["amd64"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "^1.18"
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
**/Makefile
Makefile
- name: Build
if: env.GIT_DIFF
run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build
117 changes: 117 additions & 0 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Sims
# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import)
# This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed
on:
pull_request:
push:
branches:
- main
- release/**
- upgrade/**
jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip-sims')"
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Install runsim
run: go install github.com/cosmos/tools/cmd/[email protected]
- name: Display go version
run: go version
- run: make build

test-sim-nondeterminism:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: actions/[email protected]
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary
if: env.GIT_DIFF
- name: test-sim-nondeterminism
run: |
make test-sim-nondeterminism
if: env.GIT_DIFF

install-runsim:
runs-on: ubuntu-latest
needs: build
steps:
- name: Install runsim
run: go install github.com/cosmos/tools/cmd/[email protected]
- uses: actions/[email protected]
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary

test-sim-import-export:
runs-on: ubuntu-latest
needs: [build, install-runsim]
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
with:
SUFFIX_FILTER: |
**/**.go
go.mod
go.sum
SET_ENV_NAME_INSERTIONS: 1
SET_ENV_NAME_LINES: 1
- uses: actions/[email protected]
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary
if: env.GIT_DIFF
- name: test-sim-import-export
run: |
make test-sim-import-export
if: env.GIT_DIFF

test-sim-after-import:
runs-on: ubuntu-latest
needs: [build, install-runsim]
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
with:
SUFFIX_FILTER: |
**/**.go
go.mod
go.sum
SET_ENV_NAME_INSERTIONS: 1
SET_ENV_NAME_LINES: 1
- uses: actions/[email protected]
with:
path: ~/go/bin
key: ${{ runner.os }}-go-runsim-binary
if: env.GIT_DIFF
- name: test-sim-after-import
run: |
make test-sim-after-import
if: env.GIT_DIFF
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests / Code Coverage
# Tests / Code Coverage workflow runs unit tests and uploads a code coverage report
# This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed
on:
pull_request:
push:
branches:
- main
- release/**
- upgrade/**
jobs:
cleanup-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"

test-coverage:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
- name: display go version
run: go version
- name: test & coverage report creation
run: make test-unit-cover
- name: filter out DONTCOVER
run: |
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
excludelist+=" $(find ./ -type f -name '*.pb.go')"
excludelist+=" $(find ./ -type f -name '*.pb.gw.go')"
excludelist+=" $(find ./ -type f -path './tests/mocks/*.go')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/Canto-Network\/Canto\/v6/g')
echo "Excluding ${filename} from coverage report..."
sed -i "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
- uses: codecov/[email protected]
with:
file: ./coverage.txt
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
.testnets
.bencher
DS_Store
node_modules
.idea
coverage.txt
build
55 changes: 44 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
#!/usr/bin/make -f

###
# Find OS and Go environment
# GO contains the Go binary
# FS contains the OS file separator
###
ifeq ($(OS),Windows_NT)
GO := $(shell where go.exe 2> NUL)
FS := \\
else
GO := $(shell command -v go 2> /dev/null)
FS := /
endif

ifeq ($(GO),)
$(error could not find go. Is it in PATH? $(GO))
endif

PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
DIFF_TAG=$(shell git rev-list --tags="v*" --max-count=1 --not $(shell git rev-list --tags="v*" "HEAD..origin"))
Expand All @@ -8,9 +25,10 @@ VERSION ?= $(shell echo $(shell git describe --tags $(or $(DIFF_TAG), $(DEFAULT_
TMVERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
GOPATH ?= $(shell $(GO) env GOPATH)
BINDIR ?= $(GOPATH)/bin
canto_BINARY = cantod
canto_DIR = canto
canto_DIR = cantod
BUILDDIR ?= $(CURDIR)/build
SIMAPP = ./app
HTTPS_GIT := https://github.com/canto/canto.git
Expand Down Expand Up @@ -188,7 +206,7 @@ RUNSIM = $(TOOLS_DESTDIR)/runsim
runsim: $(RUNSIM)
$(RUNSIM):
@echo "Installing runsim..."
@(cd /tmp && ${GO_MOD} go get github.com/cosmos/tools/cmd/runsim@master)
@(cd /tmp && go install github.com/cosmos/tools/cmd/runsim@v1.0.0)

statik: $(STATIK)
$(STATIK):
Expand Down Expand Up @@ -329,14 +347,14 @@ TEST_TARGETS := test-unit test-unit-cover test-race
# Test runs-specific rules. To add a new test target, just add
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
# append the new rule to the TEST_TARGETS list.
test-unit: ARGS=-timeout=10m -race
test-unit: ARGS=-timeout=30m -race
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)

test-race: ARGS=-race
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
$(TEST_TARGETS): run-tests

test-unit-cover: ARGS=-timeout=10m -race -coverprofile=coverage.txt -covermode=atomic
test-unit-cover: ARGS=-timeout=30m -race -coverprofile=coverage.txt -covermode=atomic
test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)

run-tests:
Expand All @@ -362,34 +380,49 @@ test-rpc-pending:
test-sim-nondeterminism:
@echo "Running non-determinism test..."
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h
-NumBlocks=20 -BlockSize=100 -Commit=true -Seed=42 -Period=1 -v -timeout 10m

test-sim-nondeterminism-long:
@echo "Running non-determinism-long test..."
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -Seed=42 -Period=1 -v -timeout 10h

test-sim-custom-genesis-fast:
@echo "Running custom genesis simulation..."
@echo "By default, ${HOME}/.$(canto_DIR)/config/genesis.json will be used."
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.$(canto_DIR)/config/genesis.json \
-Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h
-Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=5 -Period=1 -v -timeout 1h

test-sim-import-export: runsim
@echo "Running application import/export simulation. This may take several minutes..."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppImportExport
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -Seeds=1,10,100,1000 -ExitOnFail 50 5 TestAppImportExport

test-sim-import-export-long: runsim
@echo "Running application simulation-import-export-long. This may take several minutes..."
$(eval SEED := $(shell awk 'BEGIN{srand(); for (i=1; i<=50; i++) {n=int(10000*rand())+1; printf "%d%s", n, (i==50 ? "" : ",")}}'))
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -Seeds="$(SEED)" -ExitOnFail 500 5 TestAppImportExport

test-sim-after-import: runsim
@echo "Running application simulation-after-import. This may take several minutes..."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppSimulationAfterImport
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -Seeds=1,10,100,1000 -ExitOnFail 50 5 TestAppSimulationAfterImport

test-sim-after-import-long: runsim
@echo "Running application simulation-after-import-long. This may take several minutes..."
$(eval SEED := $(shell awk 'BEGIN{srand(); for (i=1; i<=50; i++) {n=int(10000*rand())+1; printf "%d%s", n, (i==50 ? "" : ",")}}'))
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -Seeds="$(SEED)" -ExitOnFail 500 5 TestAppSimulationAfterImport

test-sim-custom-genesis-multi-seed: runsim
@echo "Running multi-seed custom genesis simulation..."
@echo "By default, ${HOME}/.$(canto_DIR)/config/genesis.json will be used."
@$(BINDIR)/runsim -Genesis=${HOME}/.$(canto_DIR)/config/genesis.json -SimAppPkg=$(SIMAPP) -ExitOnFail 400 5 TestFullAppSimulation
@$(BINDIR)/runsim -Genesis=${HOME}/.$(canto_DIR)/config/genesis.json -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestFullAppSimulation

test-sim-multi-seed-long: runsim
@echo "Running long multi-seed application simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 500 50 TestFullAppSimulation
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 500 10 TestFullAppSimulation

test-sim-multi-seed-short: runsim
@echo "Running short multi-seed application simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 10 TestFullAppSimulation
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestFullAppSimulation

test-sim-benchmark-invariants:
@echo "Running simulation invariant benchmarks..."
Expand Down
6 changes: 5 additions & 1 deletion app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
// handle as totally normal Cosmos SDK tx
switch tx.(type) {
case sdk.Tx:
anteHandler = newCosmosAnteHandler(options)
if options.Simulation {
anteHandler = newCosmosSimulationAnteHandler(options)
} else {
anteHandler = newCosmosAnteHandler(options)
}
default:
return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "invalid transaction type: %T", tx)
}
Expand Down
Loading