diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 75241b1fa..a8c168614 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -43,6 +43,14 @@ jobs: BUILD_TAGS=rocksdb,grocksdb_clean_link go build -tags $BUILD_TAGS ./cmd/chain-maind - golangci-lint run --output.text.path stdout --path-prefix=./ --timeout 30m --build-tags $BUILD_TAGS + golangci-lint run --fix --output.text.path stdout --path-prefix=./ --timeout 30m --build-tags $BUILD_TAGS # Check only if there are differences in the source code if: steps.changed-files.outputs.any_changed == 'true' + - name: check working directory is clean + id: changes + run: | + set +e + (git diff --no-ext-diff --exit-code) + echo "changed=$?" >> $GITHUB_OUTPUT + - if: steps.changes.outputs.changed == 1 + run: echo "Working directory is dirty" && exit 1 \ No newline at end of file diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index de2a45812..4dda641a5 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -378,3 +378,38 @@ jobs: name: debug_files_grpc path: debug_files_grpc.tar.gz if-no-files-found: ignore + + + #test-versiondb: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/setup-go@v3 + # with: + # go-version: '1.22.7' + # - uses: actions/checkout@v3 + # - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 #v23 + # with: + # nix_path: nixpkgs=channel:nixos-22.11 + # extra_nix_config: | + # access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + # - id: changed-files + # uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 + # with: + # files: | + # **/*.go + # *.mod + # *.sum + # - name: test-versiondb + # run: | + # nix profile install nixpkgs#snappy + # nix profile install -f ./nix rocksdb + + # export PKG_CONFIG_PATH=~/.nix-profile/lib/pkgconfig + # export CGO_CFLAGS=$(pkg-config --cflags rocksdb) + # export CGO_CPPFLAGS=$CGO_CFLAGS + # export CGO_CXXFLAGS=$CGO_CFLAGS + # export CGO_LDFLAGS=$(pkg-config --libs rocksdb) + + # make test-versiondb + # Check only if there are differences in the source code + # if: steps.changed-files.outputs.any_changed == 'true' \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..cd82ba555 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,46 @@ +name: Tests +on: + pull_request: + push: + branches: + - master + - release/** + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test-versiondb: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.22 + check-latest: true + - uses: actions/checkout@v4 + - name: Install RocksDB Dependencies + run: | + sudo apt-get update + sudo apt-get -y install -y build-essential libsnappy-dev zlib1g-dev libbz2-dev libgflags-dev liblz4-dev libzstd-dev cmake + - name: Build and Install RocksDB + run: | + git clone https://github.com/facebook/rocksdb.git + cd rocksdb + git checkout v9.2.1 + mkdir build && cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_SNAPPY=ON -DWITH_LZ4=ON -DWITH_ZLIB=ON -DWITH_ZSTD=ON + sudo make -j4 + sudo make install + - uses: technote-space/get-diff-action@v6.1.2 + with: + PATTERNS: | + **/**.sol + **/**.go + go.mod + go.sum + - name: Test and Create Coverage Report + run: | + export COSMOS_BUILD_OPTIONS=rocksdb + make test-versiondb + if: env.GIT_DIFF \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 20d7cdc87..f608baea8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Improvements - [#1169](https://github.com/crypto-org-chain/chain-main/pull/1169) Update linter and tidy up code - [#1175](https://github.com/crypto-org-chain/chain-main/pull/1175) Add maxsupply module +- [#1179](https://github.com/crypto-org-chain/chain-main/pull/1179) fix(app): RootMultiStore interface and version mismatch *July 9, 2025* diff --git a/Makefile b/Makefile index b55e37608..977ffd9d3 100644 --- a/Makefile +++ b/Makefile @@ -193,6 +193,10 @@ test-sim-after-import: @echo "Running application simulation-after-import. This may take several minutes..." @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppSimulationAfterImport +test-versiondb: + @echo "Running test-versiondb..." + @go test -tags "rocksdb $(test_tags)" -mod=readonly $(SIMAPP) -run TestVersionDB + ############################################################################### ### Localnet ### ############################################################################### diff --git a/app/app.go b/app/app.go index 71f8fb9c0..a2c50637c 100644 --- a/app/app.go +++ b/app/app.go @@ -184,10 +184,12 @@ var ( _ servertypes.Application = (*ChainApp)(nil) ) +// RootMultiStore this is source from https://github.com/crypto-org-chain/cosmos-sdk/blob/release/v0.50.x/store/types/store.go type RootMultiStore interface { storetypes.MultiStore - LoadLatestVersion() error + // LatestVersion returns the latest version in the store + LatestVersion() int64 } // ChainApp extends an ABCI application, but with most of its parameters exported. diff --git a/app/versiondb_test.go b/app/versiondb_test.go new file mode 100644 index 000000000..0511cfb38 --- /dev/null +++ b/app/versiondb_test.go @@ -0,0 +1,29 @@ +//go:build rocksdb +// +build rocksdb + +package app_test + +import ( + "testing" + + dbm "github.com/cosmos/cosmos-db" + "github.com/crypto-org-chain/chain-main/v4/app" + + "cosmossdk.io/log" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/server" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli" +) + +func TestVersionDB(t *testing.T) { + db := dbm.NewMemDB() + + appOptions := make(simtestutil.AppOptionsMap, 0) + appOptions[flags.FlagHome] = app.DefaultNodeHome + appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue + appOptions["versiondb.enable"] = true + logger := log.NewNopLogger() + _ = app.New(logger, db, nil, false, appOptions, nil...) +} diff --git a/go.mod b/go.mod index bb1c5b1ae..fabd8003b 100644 --- a/go.mod +++ b/go.mod @@ -221,9 +221,9 @@ require ( ) replace ( - github.com/crypto-org-chain/cronos/memiavl => github.com/crypto-org-chain/cronos/memiavl v0.0.5-0.20241028093154-0f94930c27ce - github.com/crypto-org-chain/cronos/store => github.com/crypto-org-chain/cronos/store v0.0.5-0.20241028093154-0f94930c27ce - github.com/crypto-org-chain/cronos/versiondb => github.com/crypto-org-chain/cronos/versiondb v0.0.0-20241028093154-0f94930c27ce + github.com/crypto-org-chain/cronos/memiavl => github.com/crypto-org-chain/cronos/memiavl v0.0.5-0.20250305073811-995046a21efb + github.com/crypto-org-chain/cronos/store => github.com/crypto-org-chain/cronos/store v0.0.5-0.20250305073811-995046a21efb + github.com/crypto-org-chain/cronos/versiondb => github.com/crypto-org-chain/cronos/versiondb v0.0.0-20250305073811-995046a21efb ) replace ( diff --git a/go.sum b/go.sum index f688557d7..a2cd98be3 100644 --- a/go.sum +++ b/go.sum @@ -455,12 +455,12 @@ github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6 github.com/creachadair/tomledit v0.0.24/go.mod h1:9qHbShRWQzSCcn617cMzg4eab1vbLCOjOshAWSzWr8U= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/crypto-org-chain/cronos/memiavl v0.0.5-0.20241028093154-0f94930c27ce h1:yRF9Zsk4fzVBhBQEjkA4oE+Q3Q/Kgaj/UX4gK+xwaAs= -github.com/crypto-org-chain/cronos/memiavl v0.0.5-0.20241028093154-0f94930c27ce/go.mod h1:IyRvgFKOQPC/Qdx543PGl6WgeDOU+hWdv+xLz3stotc= -github.com/crypto-org-chain/cronos/store v0.0.5-0.20241028093154-0f94930c27ce h1:g6ltW2J6W10pp8poYCfjUwVkzHy2izh7/71EvUXRgjM= -github.com/crypto-org-chain/cronos/store v0.0.5-0.20241028093154-0f94930c27ce/go.mod h1:p+VxW2n9j8ojLreWScnqoDHyxGPRjI0ytkMMG5xh9o0= -github.com/crypto-org-chain/cronos/versiondb v0.0.0-20241028093154-0f94930c27ce h1:d2TZ+oXM6+qpQhM0800lUKrK5p/BmcDXUi1/Xo2LIho= -github.com/crypto-org-chain/cronos/versiondb v0.0.0-20241028093154-0f94930c27ce/go.mod h1:Y1uyFhZn/8jZkZfr3W/alzrO3DfcfWPuA3UwCM0Ah0g= +github.com/crypto-org-chain/cronos/memiavl v0.0.5-0.20250305073811-995046a21efb h1:fvn8JUhIx+9mbdcsv6RV8eEHPgYuIblfTSWWCGlzIm4= +github.com/crypto-org-chain/cronos/memiavl v0.0.5-0.20250305073811-995046a21efb/go.mod h1:/7T/7E/u7KfEZUCiktYdPLke7NjZVEbRf9qukn12TIU= +github.com/crypto-org-chain/cronos/store v0.0.5-0.20250305073811-995046a21efb h1:5YrjdC8proOb9g0cImpQJL6x8765xYV5JCaC1rGEoRY= +github.com/crypto-org-chain/cronos/store v0.0.5-0.20250305073811-995046a21efb/go.mod h1:sBd1Tm9gxgbhM5/P8x0Foior2oXoaJDKPUb009Ico1s= +github.com/crypto-org-chain/cronos/versiondb v0.0.0-20250305073811-995046a21efb h1:D9QvDZOQKcYJaCStgg3Slz5S+VdKRzP0ZCwvL+dYsKo= +github.com/crypto-org-chain/cronos/versiondb v0.0.0-20250305073811-995046a21efb/go.mod h1:3fjlBj7G0+zNiU2GZjSfGsVHqnZu9/9YIvFAZpEi0Ro= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= diff --git a/gomod2nix.toml b/gomod2nix.toml index b8016cac3..0800feea3 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -192,16 +192,16 @@ schema = 3 version = "v0.0.24" hash = "sha256-4vUukHONOjNn0qfQr4esK6TWfPWsIp+rbdz65og84lw=" [mod."github.com/crypto-org-chain/cronos/memiavl"] - version = "v0.0.5-0.20241028093154-0f94930c27ce" - hash = "sha256-F7tPkSvfW8ZbURrK5uvQ9kB1h3uKRfiQyEYql3J1Q6k=" + version = "v0.0.5-0.20250305073811-995046a21efb" + hash = "sha256-2iGJ1ibSXcBAor4qu5iv0VXK6aMyRIB24+xF3T28odU=" replaced = "github.com/crypto-org-chain/cronos/memiavl" [mod."github.com/crypto-org-chain/cronos/store"] - version = "v0.0.5-0.20241028093154-0f94930c27ce" - hash = "sha256-S5INWggeFs1vBrcuVyWyS34C5I2ux+NLJ+czqQqKzUc=" + version = "v0.0.5-0.20250305073811-995046a21efb" + hash = "sha256-j+JfESP1cGmtY8kvLJXzSFr2DmhCIF6zj9DWIygIdW4=" replaced = "github.com/crypto-org-chain/cronos/store" [mod."github.com/crypto-org-chain/cronos/versiondb"] - version = "v0.0.0-20241028093154-0f94930c27ce" - hash = "sha256-dVXYagl8K+JMrIt6dqcoQTjUwwMCqrMmAfpIZimWlyE=" + version = "v0.0.0-20250305073811-995046a21efb" + hash = "sha256-sIkqihphEhBq3WUvhQmLL1WcE2Dl6a0eKDYPrxD2nG8=" replaced = "github.com/crypto-org-chain/cronos/versiondb" [mod."github.com/danieljoos/wincred"] version = "v1.1.2"