From 324070f754245255e5a4ec2d01e4db626e1d12b6 Mon Sep 17 00:00:00 2001 From: Max <82761650+MaxMustermann2@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:46:43 +0530 Subject: [PATCH] fix(app): reorder the EndBlockers (#98) * chore: update go version to 1.21.11 * fix(ci): disable buggy workflows till they can be fixed * fix(app): reorder the EndBlockers The `EndBlockers` do the following jobs: - `x/operator` saves the USD value for delegations, indexed by operator. - `x/dogfood` uses the USD value obtained from `x/operator` to calculate the new voting power and forwards the new validator set to Tendermint. It also decreases the hold count on pending undelegations maturing at that epoch, from the perspective of the dogfood-AVS. - `x/delegation` releases any matured undelegations and makes assets available for withdrawal. - `x/oracle` fetches the new voting power from `x/dogfood` and prepares for the next round. The new order is updated to reflect the above functions. As a consequence, delegations made during blocks just before the epoch ends will also accurately update the vote power of the validators. * chore: lint * fix(docker): update to new alpine * feat(ci): add `docker build` CI * chore(ci): run `lint` on workflows * chore(ci): run `lint` on workflows again * fix(ci): trigger Dockerbuild only if file changes * fix(ci): remove backticks from workflow name * fix(ci): lint the workflow again * fix(ci): use correct path to trigger --- .github/workflows/ante-benchmark.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/dependencies.yml | 2 +- .github/workflows/docker-localnet.yml | 32 +++++++++++++++++++++++++++ .github/workflows/docker.yml | 30 +++++++++++++++++++++++++ .github/workflows/goreleaser.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/proto-comment.yml | 3 +-- .github/workflows/test-comment.yml | 4 +--- .golangci.yml | 2 +- Dockerfile | 8 +++---- Makefile | 2 +- app/app.go | 10 ++++----- go.mod | 2 +- networks/local/exocore/Dockerfile | 8 +++---- 15 files changed, 85 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/docker-localnet.yml create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/ante-benchmark.yml b/.github/workflows/ante-benchmark.yml index 54036daa5..aa40533ba 100644 --- a/.github/workflows/ante-benchmark.yml +++ b/.github/workflows/ante-benchmark.yml @@ -29,7 +29,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@v4 with: - go-version: '1.21.9' + go-version: '1.21.11' check-latest: true - name: Run benchmark tests diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c3dfb697..eaa39e5e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: '1.21.9' + go-version: '1.21.11' check-latest: true - uses: technote-space/get-diff-action@v6.1.2 id: git_diff diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 1e846db7c..5c613edab 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: '1.21.9' + go-version: '1.21.11' check-latest: true - name: "Checkout Repository" uses: actions/checkout@v4 diff --git a/.github/workflows/docker-localnet.yml b/.github/workflows/docker-localnet.yml new file mode 100644 index 000000000..b4e82e365 --- /dev/null +++ b/.github/workflows/docker-localnet.yml @@ -0,0 +1,32 @@ +name: Docker build for localnet +on: + pull_request: + paths: + - networks/local/exocore/Dockerfile + - networks/Makefile + push: + paths: + - networks/local/exocore/Dockerfile + - networks/Makefile + branches: + - develop + - main + - master + - release/** + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build Docker image + run: make -C ./networks diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..9ed7fc649 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,30 @@ +name: Docker build in root directory +on: + pull_request: + paths: + - Dockerfile + push: + paths: + - Dockerfile + branches: + - develop + - main + - master + - release/** + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build Docker image + run: docker build . diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 7419114ea..3c451f402 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.21.9' + go-version: '1.21.11' check-latest: true - name: release dry run run: make release-dry-run diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9c9154031..ed0476abd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,7 +21,7 @@ jobs: # Required: setup-go, for all versions v3.0.0+ of golangci-lint - uses: actions/setup-go@v5 with: - go-version: '1.21.9' + go-version: '1.21.11' # Use pinned versions, not git versions check-latest: false # Match `golangci-lint-action` recommendation diff --git a/.github/workflows/proto-comment.yml b/.github/workflows/proto-comment.yml index 596243c10..8c727c076 100644 --- a/.github/workflows/proto-comment.yml +++ b/.github/workflows/proto-comment.yml @@ -17,8 +17,7 @@ on: jobs: download-artifact-and-comment: runs-on: ubuntu-latest - if: > - github.event.workflow_run.conclusion == 'success' + if: ${{ false }} steps: - name: 'Download artifact' uses: actions/github-script@v7.0.1 diff --git a/.github/workflows/test-comment.yml b/.github/workflows/test-comment.yml index 9fc63ddca..eac81ec3f 100644 --- a/.github/workflows/test-comment.yml +++ b/.github/workflows/test-comment.yml @@ -18,9 +18,7 @@ on: jobs: download-artifact-and-comment: runs-on: ubuntu-latest - if: > - github.event.workflow_run.event == 'pull_request' && - github.event.workflow_run.conclusion == 'success' + if: ${{ false }} steps: - name: Download artifact uses: actions/github-script@v7.0.1 diff --git a/.golangci.yml b/.golangci.yml index fe4c5c5e3..b31d2cb00 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,7 +2,7 @@ run: tests: false timeout: 5m concurrency: 4 - go: "1.21.9" + go: "1.21.11" linters: enable: diff --git a/Dockerfile b/Dockerfile index 4a64abccc..e07e0d824 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ # This is the published docker image for exocore. -FROM golang:1.21.9-alpine3.18 AS build-env +FROM golang:1.21.11-alpine3.19 AS build-env WORKDIR /go/src/github.com/ExocoreNetwork/exocore COPY go.mod go.sum ./ -RUN apk add --no-cache ca-certificates=20230506-r0 build-base=0.5-r3 git=2.40.1-r0 linux-headers=6.3-r0 +RUN apk add --no-cache ca-certificates=20240226-r0 build-base=0.5-r3 git=2.43.4-r0 linux-headers=6.5-r0 RUN --mount=type=bind,target=. --mount=type=secret,id=GITHUB_TOKEN \ git config --global url."https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/".insteadOf "https://github.com/"; \ @@ -16,14 +16,14 @@ COPY . . RUN make build && go install github.com/MinseokOh/toml-cli@latest -FROM alpine:3.18 +FROM alpine:3.19 WORKDIR /root COPY --from=build-env /go/src/github.com/ExocoreNetwork/exocore/build/exocored /usr/bin/exocored COPY --from=build-env /go/bin/toml-cli /usr/bin/toml-cli -RUN apk add --no-cache ca-certificates=20230506-r0 libstdc++=12.2.1_git20220924-r10 jq=1.6-r4 curl=8.5.0-r0 bash=5.2.15-r5 vim=9.0.2073-r0 lz4=1.9.4-r4 rclone=1.62.2-r6 \ +RUN apk add --no-cache ca-certificates=20240226-r0 libstdc++=13.2.1_git20231014-r0 jq=1.7.1-r0 curl=8.5.0-r0 bash=5.2.21-r0 vim=9.0.2127-r0 lz4=1.9.4-r5 rclone=1.65.0-r3 \ && addgroup -g 1000 exocore \ && adduser -S -h /home/exocore -D exocore -u 1000 -G exocore diff --git a/Makefile b/Makefile index 653c3663c..943e9a275 100644 --- a/Makefile +++ b/Makefile @@ -525,7 +525,7 @@ localnet-show-logstream: ############################################################################### PACKAGE_NAME:=github.com/ExocoreNetwork/exocore -GOLANG_CROSS_VERSION = v1.21.9 +GOLANG_CROSS_VERSION = v1.21.11 GOPATH ?= '$(HOME)/go' release-dry-run: docker run \ diff --git a/app/app.go b/app/app.go index fcf0ab5a0..cca9e7c28 100644 --- a/app/app.go +++ b/app/app.go @@ -939,12 +939,12 @@ func NewExocoreApp( app.mm.SetOrderEndBlockers( capabilitytypes.ModuleName, - crisistypes.ModuleName, // easy quit - stakingtypes.ModuleName, - operatorTypes.ModuleName, // after staking keeper - delegationTypes.ModuleName, // after operator keeper + crisistypes.ModuleName, // easy quit + operatorTypes.ModuleName, // first, so that USD value is recorded + stakingtypes.ModuleName, // uses the USD value recorded in operator to calculate vote power + delegationTypes.ModuleName, // process the undelegations matured by dogfood govtypes.ModuleName, // after staking keeper to ensure new vote powers - oracleTypes.ModuleName, // after staking keeper to ensure new vote powers + oracleTypes.ModuleName, // prepares for next round with new vote powers from staking keeper evmtypes.ModuleName, // can be anywhere feegrant.ModuleName, // can be anywhere // no-op modules diff --git a/go.mod b/go.mod index 81e9db711..35933663c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ExocoreNetwork/exocore -go 1.21.9 +go 1.21.11 require ( cosmossdk.io/errors v1.0.1 diff --git a/networks/local/exocore/Dockerfile b/networks/local/exocore/Dockerfile index 26042357a..d995356dc 100644 --- a/networks/local/exocore/Dockerfile +++ b/networks/local/exocore/Dockerfile @@ -1,5 +1,5 @@ -FROM golang:1.21.9-alpine3.18 AS build -RUN apk add --no-cache build-base=0.5-r3 linux-headers=6.3-r0 git=2.40.1-r0 +FROM golang:1.21.11-alpine3.19 AS build +RUN apk add --no-cache build-base=0.5-r3 git=2.43.4-r0 linux-headers=6.5-r0 # Set working directory for the build WORKDIR /go/work # Add source files @@ -9,8 +9,8 @@ COPY . ./ RUN LEDGER_ENABLED=false make build ##################################### -FROM alpine:3.18 AS run -RUN apk add --no-cache libstdc++=12.2.1_git20220924-r10 bash=5.2.15-r5 curl=8.5.0-r0 jq=1.6-r4 \ +FROM alpine:3.19 AS run +RUN apk add --no-cache libstdc++=13.2.1_git20231014-r0 bash=5.2.21-r0 curl=8.5.0-r0 jq=1.7.1-r0 \ && addgroup -g 1000 exocore \ && adduser -S -h /home/exocore -D exocore -u 1000 -G exocore EXPOSE 26656 26657 1317 9090 8545 8546