From c536c0f18cd3cb06015005d0605beee013a36c2a Mon Sep 17 00:00:00 2001 From: auricom <27022259+auricom@users.noreply.github.com> Date: Wed, 11 Sep 2024 10:08:09 +0200 Subject: [PATCH 1/3] ci: remove nix from gh workflows (#21572) --- .github/scripts/install-rocksdb.sh | 20 +++++++ .github/workflows/build.yml | 34 +++++++++--- .github/workflows/lint.yml | 36 ++++++++++--- .github/workflows/test.yml | 57 +++++++++++++++++--- flake.lock | 86 ------------------------------ flake.nix | 66 ----------------------- scripts/go-lint-all.bash | 2 +- scripts/go-mod-tidy-all.sh | 18 +------ simapp/default.nix | 46 ---------------- 9 files changed, 130 insertions(+), 235 deletions(-) create mode 100755 .github/scripts/install-rocksdb.sh delete mode 100644 flake.lock delete mode 100644 flake.nix delete mode 100644 simapp/default.nix diff --git a/.github/scripts/install-rocksdb.sh b/.github/scripts/install-rocksdb.sh new file mode 100755 index 000000000000..8579431bfc2a --- /dev/null +++ b/.github/scripts/install-rocksdb.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +if [ -z "$ROCKSDB_VERSION" ]; then + echo "ROCKSDB_VERSION is not set." + exit 1 +fi + +# Update and install dependencies +sudo apt update && sudo apt-get install -y libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev build-essential + +# Clone RocksDB repository +git clone https://github.com/facebook/rocksdb.git /home/runner/rocksdb +cd /home/runner/rocksdb || exit 1 +git checkout "v${ROCKSDB_VERSION}" + +# Build shared library +sudo make -j "$(nproc --all)" shared_lib +sudo cp --preserve=links ./librocksdb.* /usr/local/lib/ +sudo cp -r ./include/rocksdb/ /usr/local/include/ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5ce144c9f2d..0e29f4229f1e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,9 @@ concurrency: group: ci-${{ github.ref }}-build cancel-in-progress: true +env: + ROCKSDB_VERSION: 8.11.3 + jobs: build: runs-on: ubuntu-latest @@ -21,12 +24,33 @@ jobs: go-arch: ["amd64", "arm", "arm64"] steps: - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - uses: actions/setup-go@v5 with: go-version: "1.23" check-latest: true + - name: Fix permissions for cache + run: sudo chown $(whoami) /usr/local/lib /usr/local/include + - name: Restore rocksdb libraries cache + id: cache-rocksdb + if: matrix.go-arch == 'amd64' + uses: actions/cache/restore@v4 + with: + path: | + /usr/local/lib/librocksdb.* + /usr/local/include/rocksdb + key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-${{ matrix.go-arch }} + - name: Install rocksdb + if: matrix.go-arch == 'amd64' && steps.cache-rocksdb.outputs.cache-hit != 'true' + id: install_rocksdb + run: ./.github/scripts/install-rocksdb.sh + - name: Saves rocksdb libraries cache + if: matrix.go-arch == 'amd64' && steps.install_rocksdb.outcome == 'success' + uses: actions/cache/restore@v4 + with: + path: | + /usr/local/lib/librocksdb.* + /usr/local/include/rocksdb + key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-${{ matrix.go-arch }} ################### #### Build App #### ################### @@ -35,10 +59,8 @@ jobs: - name: Build Legacy run: GOARCH=${{ matrix.go-arch }} COSMOS_BUILD_OPTIONS=legacy make build - name: Build with rocksdb backend - if: | - env.GIT_DIFF && - matrix.go-arch == 'amd64' - run: nix run . -- version --long + if: matrix.go-arch == 'amd64' + run: GOARCH=${{ matrix.go-arch }} COSMOS_BUILD_OPTIONS="rocksdb" make build ################### ## Build Tooling ## ################### diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 846bde4c75a9..b5ea960668e3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,14 +8,16 @@ on: merge_group: permissions: contents: read + +env: + ROCKSDB_VERSION: 8.11.3 + jobs: golangci: name: golangci-lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - uses: actions/setup-go@v5 with: go-version: "1.23" @@ -28,13 +30,35 @@ jobs: Makefile **/Makefile .golangci.yml + - name: Fix permissions for cache + run: sudo chown $(whoami) /usr/local/lib /usr/local/include + - name: Restore rocksdb libraries cache + id: cache-rocksdb + uses: actions/cache/restore@v4 + with: + path: | + /usr/local/lib/librocksdb.* + /usr/local/include/rocksdb + key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-amd64 + - name: Install rocksdb + if: env.GIT_DIFF && steps.cache-rocksdb.outputs.cache-hit != 'true' + id: install_rocksdb + run: ./.github/scripts/install-rocksdb.sh + - name: Saves rocksdb libraries cache + if: steps.install_rocksdb.outcome == 'success' + uses: actions/cache/restore@v4 + with: + path: | + /usr/local/lib/librocksdb.* + /usr/local/include/rocksdb + key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-amd64 - name: run linting (long) if: env.GIT_DIFF id: lint_long run: | - nix develop -c make lint + make lint env: - NIX: 1 + ROCKSDB: 1 - uses: technote-space/get-diff-action@v6.1.2 if: steps.lint_long.outcome == 'skipped' with: @@ -57,8 +81,8 @@ jobs: - name: run linting (short) if: steps.lint_long.outcome == 'skipped' && env.GIT_DIFF run: | - nix develop -c make lint + make lint env: GIT_DIFF: ${{ env.GIT_DIFF }} LINT_DIFF: 1 - NIX: 1 + ROCKSDB: 1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0c3945eb1213..c1df906f9906 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,9 @@ concurrency: group: ci-${{ github.ref }}-tests cancel-in-progress: true +env: + ROCKSDB_VERSION: 8.11.3 + jobs: split-test-files: runs-on: ubuntu-latest @@ -774,11 +777,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - uses: actions/setup-go@v5 with: - go-version: "1.20" + go-version: "1.23" check-latest: true cache: true cache-dependency-path: store/go.sum @@ -789,11 +790,33 @@ jobs: store/**/*.go store/go.mod store/go.sum + - name: Fix permissions for cache + run: sudo chown $(whoami) /usr/local/lib /usr/local/include + - name: Restore rocksdb libraries cache + id: cache-rocksdb + uses: actions/cache/restore@v4 + with: + path: | + /usr/local/lib/librocksdb.* + /usr/local/include/rocksdb + key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-amd64 + - name: Install rocksdb + if: env.GIT_DIFF && steps.cache-rocksdb.outputs.cache-hit != 'true' + id: install_rocksdb + run: ./.github/scripts/install-rocksdb.sh + - name: Saves rocksdb libraries cache + if: steps.install_rocksdb.outcome == 'success' + uses: actions/cache/restore@v4 + with: + path: | + /usr/local/lib/librocksdb.* + /usr/local/include/rocksdb + key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-amd64 - name: tests if: env.GIT_DIFF run: | cd store - nix develop .. -c go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb' ./... + go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb' ./... - name: sonarcloud if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }} uses: SonarSource/sonarcloud-github-action@master @@ -809,8 +832,6 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - uses: actions/setup-go@v5 with: go-version: "1.23" @@ -824,11 +845,33 @@ jobs: store/v2/**/*.go store/v2/go.mod store/v2/go.sum + - name: Fix permissions for cache + run: sudo chown $(whoami) /usr/local/lib /usr/local/include + - name: Restore rocksdb libraries cache + id: cache-rocksdb + uses: actions/cache/restore@v4 + with: + path: | + /usr/local/lib/librocksdb.* + /usr/local/include/rocksdb + key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-amd64 + - name: Install rocksdb + if: env.GIT_DIFF && steps.cache-rocksdb.outputs.cache-hit != 'true' + id: install_rocksdb + run: ./.github/scripts/install-rocksdb.sh + - name: Saves rocksdb libraries cache + if: steps.install_rocksdb.outcome == 'success' + uses: actions/cache/restore@v4 + with: + path: | + /usr/local/lib/librocksdb.* + /usr/local/include/rocksdb + key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-amd64 - name: test & coverage report creation if: env.GIT_DIFF run: | cd store/v2 - nix develop ../.. -c go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb' ./... + go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock rocksdb' ./... - name: sonarcloud if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }} uses: SonarSource/sonarcloud-github-action@master diff --git a/flake.lock b/flake.lock deleted file mode 100644 index e442eb8cdd43..000000000000 --- a/flake.lock +++ /dev/null @@ -1,86 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "gomod2nix": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1714786460, - "narHash": "sha256-5RinsY4tUWnWyDVxXO4Ebz1fnOEAa6d24lt1yFDxeL0=", - "owner": "nix-community", - "repo": "gomod2nix", - "rev": "e50becd94abeff9e9be98302b929eab8afc2722a", - "type": "github" - }, - "original": { - "owner": "nix-community", - "ref": "pull/156/head", - "repo": "gomod2nix", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1723603349, - "narHash": "sha256-VMg6N7MryOuvSJ8Sj6YydarnUCkL7cvMdrMcnsJnJCE=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "daf7bb95821b789db24fc1ac21f613db0c1bf2cb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "gomod2nix": "gomod2nix", - "nixpkgs": "nixpkgs" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 4313af441445..000000000000 --- a/flake.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - gomod2nix = { - # https://github.com/nix-community/gomod2nix/pull/156 - url = "github:nix-community/gomod2nix/pull/156/head"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.flake-utils.follows = "flake-utils"; - }; - }; - - outputs = { self, nixpkgs, flake-utils, ... }@inputs: - { - overlays.default = self: super: rec { - simd = self.callPackage ./simapp { rev = self.shortRev or "dev"; }; - go = simd.go; # to build the tools (e.g. gomod2nix) using the same go version - rocksdb = super.rocksdb.overrideAttrs (_: rec { - version = "8.11.3"; - src = self.fetchFromGitHub { - owner = "facebook"; - repo = "rocksdb"; - rev = "v${version}"; - sha256 = "sha256-OpEiMwGxZuxb9o3RQuSrwZMQGLhe9xLT1aa3HpI4KPs="; - }; - }); - }; - } // - (flake-utils.lib.eachDefaultSystem - (system: - let - mkApp = drv: { - type = "app"; - program = "${drv}/bin/${drv.meta.mainProgram}"; - }; - pkgs = import nixpkgs { - inherit system; - config = { }; - overlays = [ - inputs.gomod2nix.overlays.default - self.overlays.default - ]; - }; - in - rec { - packages = rec { - default = simd; - inherit (pkgs) simd; - }; - apps = rec { - default = simd; - simd = mkApp pkgs.simd; - }; - devShells = rec { - default = with pkgs; mkShell { - buildInputs = [ - go_1_23 # Use Go 1.23 version - rocksdb - gomod2nix - ]; - }; - }; - legacyPackages = pkgs; - } - )); -} diff --git a/scripts/go-lint-all.bash b/scripts/go-lint-all.bash index 48d31d809ee5..565aa6a41649 100755 --- a/scripts/go-lint-all.bash +++ b/scripts/go-lint-all.bash @@ -6,7 +6,7 @@ REPO_ROOT="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd export REPO_ROOT LINT_TAGS="e2e,ledger,test_ledger_mock" -if [[ ! -z "${NIX:-}" ]]; then +if [[ ! -z "${ROCKSDB:-}" ]]; then LINT_TAGS+=",rocksdb" fi export LINT_TAGS diff --git a/scripts/go-mod-tidy-all.sh b/scripts/go-mod-tidy-all.sh index 41b020217b77..72b2b9d0e2f3 100755 --- a/scripts/go-mod-tidy-all.sh +++ b/scripts/go-mod-tidy-all.sh @@ -6,20 +6,4 @@ for modfile in $(find . -name go.mod); do echo "Updating $modfile" DIR=$(dirname $modfile) (cd $DIR; go mod tidy) -done - -# update gomod2nix.toml for simapp -# NOTE: gomod2nix should be built using the same go version as the project, the nix flake will make sure of that -# automatically. -cd simapp -if command -v nix &> /dev/null -then - nix develop .. -c gomod2nix - - if ! command -v gomod2nix &> /dev/null - then - echo "gomod2nix could not be found in PATH, installing..." - go install github.com/nix-community/gomod2nix@latest - fi - gomod2nix -fi +done \ No newline at end of file diff --git a/simapp/default.nix b/simapp/default.nix deleted file mode 100644 index e7efd1764801..000000000000 --- a/simapp/default.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ lib -, buildGoApplication -, rocksdb -, stdenv -, static ? stdenv.hostPlatform.isStatic -, rev ? "dev" -}: - -let - pname = "simd"; - version = "v0.0.1"; - tags = [ "ledger" "netgo" "rocksdb" "grocksdb_no_link" ]; - ldflags = lib.concatStringsSep "\n" ([ - "-X github.com/cosmos/cosmos-sdk/version.Name=${pname}" - "-X github.com/cosmos/cosmos-sdk/version.AppName=${pname}" - "-X github.com/cosmos/cosmos-sdk/version.Version=${version}" - "-X github.com/cosmos/cosmos-sdk/version.BuildTags=${lib.concatStringsSep "," tags}" - "-X github.com/cosmos/cosmos-sdk/version.Commit=${rev}" - ]); -in -buildGoApplication rec { - inherit pname version ldflags tags; - src = ./.; - pwd = src; - modules = ./gomod2nix.toml; - subPackages = [ "simd" ]; - doCheck = false; - buildInputs = [ rocksdb ]; - CGO_ENABLED = "1"; - CGO_LDFLAGS = - if static then "-lrocksdb -pthread -lstdc++ -ldl -lzstd -lsnappy -llz4 -lbz2 -lz" - else if stdenv.hostPlatform.isWindows then "-lrocksdb-shared" - else "-lrocksdb -pthread -lstdc++ -ldl"; - - postFixup = lib.optionalString stdenv.isDarwin '' - ${stdenv.cc.targetPrefix}install_name_tool -change "@rpath/librocksdb.8.dylib" "${rocksdb}/lib/librocksdb.dylib" $out/bin/${pname} - ''; - - meta = with lib; { - description = "example chain binary in cosmos-sdk repo"; - homepage = "https://github.com/cosmos/cosmos-sdk"; - license = licenses.asl20; - mainProgram = pname + stdenv.hostPlatform.extensions.executable; - platforms = platforms.all; - }; -} From f4816df891e49d9b29adeb37d3455ada1e36d53e Mon Sep 17 00:00:00 2001 From: hatti Date: Wed, 11 Sep 2024 16:09:46 +0800 Subject: [PATCH 2/3] docs(x/epochs): fix note box display failure (#21644) --- x/epochs/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x/epochs/README.md b/x/epochs/README.md index 0bb35998a084..dcd7eb7b5176 100644 --- a/x/epochs/README.md +++ b/x/epochs/README.md @@ -144,7 +144,7 @@ Query the currently running epochInfos query epochs epoch-infos ``` -::: details Example +:::details Example An example output: @@ -176,7 +176,7 @@ Query the current epoch by the specified identifier query epochs current-epoch [identifier] ``` -::: details Example +:::details Example Query the current `day` epoch: @@ -189,3 +189,5 @@ Which in this example outputs: ```sh current_epoch: "183" ``` + +::: From 04cec5b5e5c1dc7a884a464deb9ebd2a1b913e82 Mon Sep 17 00:00:00 2001 From: Hanlu Date: Wed, 11 Sep 2024 16:10:05 +0800 Subject: [PATCH 3/3] docs: Add missing symbol in README.md (#21640) --- docs/architecture/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/architecture/README.md b/docs/architecture/README.md index dc28394232ab..19902f06d9ab 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -36,7 +36,7 @@ Read about the [PROCESS](./PROCESS.md). ### Use RFC 2119 Keywords -When writing ADRs, follow the same best practices for writing RFCs. When writing RFCs, key words are used to signify the requirements in the specification. These words are often capitalized: "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL. They are to be interpreted as described in [RFC 2119](https://datatracker.ietf.org/doc/html/rfc2119). +When writing ADRs, follow the same best practices for writing RFCs. When writing RFCs, key words are used to signify the requirements in the specification. These words are often capitalized: "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL". They are to be interpreted as described in [RFC 2119](https://datatracker.ietf.org/doc/html/rfc2119). ## ADR Table of Contents