Skip to content

Commit

Permalink
Merge pull request #111 from xpladev/release/v1.4.x
Browse files Browse the repository at this point in the history
v1.4.0
  • Loading branch information
JoowonYun authored Feb 16, 2024
2 parents 453df45 + 6f54c1c commit 689b7af
Show file tree
Hide file tree
Showing 68 changed files with 541 additions and 256 deletions.
37 changes: 0 additions & 37 deletions .github/release-drafter-config.yaml

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Integration test
name: End-to-end test

on:
push:
Expand All @@ -17,17 +17,17 @@ jobs:
- name: Setup network
run: |
mkdir ~/genesis
cd integration_test && docker-compose up -d
cd tests/e2e && docker-compose up -d
docker ps
sleep 20
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x
go-version: 1.19.x

- name: Integration test
run: cd integration_test && go test
- name: End-to-end test
run: cd tests/e2e && go test

- name: Teardown
run: cd integration_test && docker-compose down
run: cd tests/e2e && docker-compose down
13 changes: 0 additions & 13 deletions .github/workflows/release-drafter.yaml

This file was deleted.

117 changes: 117 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: "Release"

on:
# can be used to re-release an existing tag
workflow_dispatch:

push:
tags:
- "v[0-9]+\\.[0-9]+\\.[0-9]+"
- "v[0-9]+\\.[0-9]+\\.[0-9]+-*"

jobs:
release:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Create release for ${{ github.ref_name }}
run: gh release create ${{ github.ref_name }} --prerelease --generate-notes --repo ${{ github.repository }}


artifacts:
if: startsWith(github.ref, 'refs/tags/')
needs: release
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
matrix:
build_type: ['build-release-arm64', 'build-release-amd64']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set version tag
run: echo "VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')" >> $GITHUB_ENV
- name: Create build directory
run: mkdir -p build/release
- name: Build ${{ matrix.build_type }}
run: make ${{ matrix.build_type }}
- name: Upload the artifacts to release
run: gh release upload ${{ github.ref_name }} ./build/release/*

calculate-checksums:
needs: artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Create build directory
run: mkdir -p build/release
- name: Download artifacts
run: gh release download ${{ github.ref_name }} --pattern '*.tar.gz' --dir build/release --repo ${{ github.repository }}
- name: Create checksums
run: |
cd build/release
sha256sum *.tar.gz > checksum.txt
- name: Display checksums
run: cat build/release/checksum.txt
- name: Upload the checksum to release
run: gh release upload ${{github.ref_name}} build/release/checksum.txt --repo ${{github.repository}}

generate-json:
needs: calculate-checksums
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Create build directory
run: mkdir -p build/release
- name: Download artifacts
run: gh release download ${{github.ref_name}} --pattern '*.tar.gz' --dir build/release --repo ${{github.repository}}
- name: Generate JSON file
run: |
cd build/release
binaries=()
for file in *.tar.gz; do
checksum=$(sha256sum $file | awk '{print $1}')
url="https://github.com/${{github.repository}}/releases/download/${{github.ref_name}}/$file?checksum=sha256:$checksum"
declare -A TRANSLATION_MATRIX
TRANSLATION_MATRIX=( ["Linux_x86_64"]="linux/amd64" ["Linux_arm64"]="linux/arm64" ["Darwin_arm64"]="darwin/arm64" )
os_architecture_translated=""
for key in "${!TRANSLATION_MATRIX[@]}"; do
if [[ "$file" == *"$key"* ]]; then
os_architecture_translated="${TRANSLATION_MATRIX[$key]}"
break
fi
done
if [ -z "$os_architecture_translated" ]
then
echo "Could not translate OS and architecture information from binary name: $file"
exit 1
fi
binaries+=(" \"$os_architecture_translated\": \"$url\"")
done
binaries_json=$(IFS=$',\n'; echo "${binaries[*]}")
cat << EOF > binaries.json.raw
{
"binaries": {
$binaries_json
}
}
EOF
- name: Pretty-print JSON file using jq
run: |
cd build/release
jq . < binaries.json.raw > binaries.json && rm binaries.json.raw
- name: Display JSON file
run: cat build/release/binaries.json
- name: Upload the JSON file to release
run: gh release upload ${{ github.ref_name }} build/release/binaries.json --repo ${{ github.repository }}
36 changes: 16 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,37 @@

### BUILD
FROM golang:1.19-alpine AS build
WORKDIR /localnet

# Create appuser.
RUN adduser -D -g '' valiuser
# Install required binaries
RUN apk add --update --no-cache zip git make cmake build-base linux-headers musl-dev libc-dev

# Copy source files
COPY . /localnet/

ENV LIBWASMVM_VERSION=v1.3.0

WORKDIR /
RUN git clone --depth 1 https://github.com/microsoft/mimalloc; cd mimalloc; mkdir build; cd build; cmake ..; make -j$(nproc); make install
ENV MIMALLOC_RESERVE_HUGE_OS_PAGES=4

# See https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASMVM_VERSION}/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASMVM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep b1610f9c8ad8bdebf5b8f819f71d238466f83521c74a2deb799078932e862722
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep b4aad4480f9b4c46635b4943beedbb72c929eab1d1b9467fe3b43e6dbf617e32

# Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc`
RUN cp /lib/libwasmvm_muslc.`uname -m`.a /lib/libwasmvm_muslc.a
WORKDIR /workspace
# Copy source files
COPY . .
# Download dependencies and CosmWasm libwasmvm if found.
RUN set -eux; \
export ARCH=$(uname -m); \
WASM_VERSION=$(go list -mod=readonly -m all | grep github.com/CosmWasm/wasmvm | awk '{print $2}'); \
if [ ! -z "${WASM_VERSION}" ]; then \
wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.${ARCH}.a; \
fi; \
go mod download;

# Build executable
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LDFLAGS='-linkmode=external -extldflags "-L/localnet/mimalloc/build -lmimalloc -Wl,-z,muldefs -static"' make build
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LDFLAGS='-linkmode=external -extldflags "-L/mimalloc/build -lmimalloc -Wl,-z,muldefs -static"' make build

# --------------------------------------------------------
FROM alpine:3.15 AS runtime

WORKDIR /opt
RUN [ "mkdir", "-p", "/opt/integration_test" ]
FROM alpine:3.18 AS runtime

COPY --from=build /localnet/build/xplad /usr/bin/xplad
COPY --from=build /localnet/integration_test /opt/integration_test
COPY --from=build /workspace/build/xplad /usr/bin/xplad
COPY --from=build /workspace/tests/e2e /opt/tests/e2e

# Expose Cosmos ports
EXPOSE 9090
Expand Down
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ NAME := xpla
APPNAME := xplad
LEDGER_ENABLED ?= true
TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7"
BUILDDIR ?= $(CURDIR)/build
GO_VERSION ?= "1.19"

# for dockerized protobuf tools
DOCKER := $(shell which docker)
DOCKER_COMPOSE := $(shell which docker-compose)
BUF_IMAGE=bufbuild/buf@sha256:3cb1f8a4b48bd5ad8f09168f10f607ddc318af202f5c057d52a45216793d85e5 #v1.4.0
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(BUF_IMAGE)

Expand Down Expand Up @@ -87,12 +90,56 @@ endif

all: install

.PHONY: install
install: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/xplad

.PHONY: build
build: go.sum
go build -mod=readonly $(BUILD_FLAGS) -o build/xplad ./cmd/xplad

build-release: build/linux/amd64 build/linux/arm64

build-release-amd64: go.sum $(BUILDDIR)/
$(DOCKER) buildx create --name xpla-builder || true
$(DOCKER) buildx use xpla-builder
$(DOCKER) buildx build \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg GIT_VERSION=$(VERSION) \
--build-arg GIT_COMMIT=$(COMMIT) \
--build-arg GOOS=linux \
--build-arg GOARCH=amd64 \
--platform linux/amd64 \
-t xpla:local-amd64 \
--load \
-f Dockerfile .
$(DOCKER) rm -f xpla-builder || true
$(DOCKER) create -ti --name xpla-builder xpla:local-amd64
$(DOCKER) cp xpla-builder:/usr/bin/xplad $(BUILDDIR)/release/xplad
tar -czvf $(BUILDDIR)/release/xpla_$(VERSION)_Linux_x86_64.tar.gz -C $(BUILDDIR)/release/ xplad
rm $(BUILDDIR)/release/xplad
$(DOCKER) rm -f xpla-builder

build-release-arm64: go.sum $(BUILDDIR)/
$(DOCKER) buildx create --name xpla-builder || true
$(DOCKER) buildx use xpla-builder
$(DOCKER) buildx build \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg GIT_VERSION=$(VERSION) \
--build-arg GIT_COMMIT=$(COMMIT) \
--build-arg GOOS=linux \
--build-arg GOARCH=arm64 \
--platform linux/arm64 \
-t xpla:local-arm64 \
--load \
-f Dockerfile .
$(DOCKER) rm -f xpla-builder || true
$(DOCKER) create -ti --name xpla-builder xpla:local-arm64
$(DOCKER) cp xpla-builder:/usr/bin/xplad $(BUILDDIR)/release/xplad
tar -czvf $(BUILDDIR)/release/xpla_$(VERSION)_Linux_arm64.tar.gz -C $(BUILDDIR)/release/ xplad
rm $(BUILDDIR)/release/xplad
$(DOCKER) rm -f xpla-builder

.PHONY: test
test: go.sum
go test -short ./...
Expand Down
10 changes: 10 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (
"github.com/xpladev/xpla/docs"

evmupgrade "github.com/xpladev/xpla/app/upgrades/evm"
"github.com/xpladev/xpla/app/upgrades/v1_4"
"github.com/xpladev/xpla/app/upgrades/volunteer"
xplareward "github.com/xpladev/xpla/app/upgrades/xpla_reward"
)
Expand Down Expand Up @@ -422,6 +423,12 @@ func (app *XplaApp) setUpgradeHandlers() {
volunteer.CreateUpgradeHandler(app.mm, app.configurator, &app.AppKeepers),
)

// v1_4 upgrade handler
app.UpgradeKeeper.SetUpgradeHandler(
v1_4.UpgradeName,
v1_4.CreateUpgradeHandler(app.mm, app.configurator, app.AppKeepers.AccountKeeper, &app.AppKeepers.StakingKeeper),
)

// When a planned update height is reached, the old binary will panic
// writing on disk the height and name of the update that triggered it
// This will read that value, and execute the preparations for the upgrade.
Expand Down Expand Up @@ -449,6 +456,9 @@ func (app *XplaApp) setUpgradeHandlers() {
storeUpgrades = &storetypes.StoreUpgrades{
Added: volunteer.AddModules,
}
case v1_4.UpgradeName:
storeUpgrades = &storetypes.StoreUpgrades{}

}

if storeUpgrades != nil {
Expand Down
6 changes: 3 additions & 3 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router"
routerkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/keeper"
routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
icacontroller "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller"
icacontrollerkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/keeper"
icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types"
Expand All @@ -69,9 +72,6 @@ import (
"github.com/evmos/evmos/v9/x/erc20"
erc20keeper "github.com/evmos/evmos/v9/x/erc20/keeper"
erc20types "github.com/evmos/evmos/v9/x/erc20/types"
"github.com/strangelove-ventures/packet-forward-middleware/v4/router"
routerkeeper "github.com/strangelove-ventures/packet-forward-middleware/v4/router/keeper"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"
tmos "github.com/tendermint/tendermint/libs/os"
rewardkeeper "github.com/xpladev/xpla/x/reward/keeper"
rewardtypes "github.com/xpladev/xpla/x/reward/types"
Expand Down
2 changes: 1 addition & 1 deletion app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types"
ibcfeetypes "github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
Expand All @@ -25,7 +26,6 @@ import (
evmtypes "github.com/evmos/ethermint/x/evm/types"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
erc20types "github.com/evmos/evmos/v9/x/erc20/types"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"
rewardtypes "github.com/xpladev/xpla/x/reward/types"
volunteertypes "github.com/xpladev/xpla/x/volunteer/types"
)
Expand Down
Loading

0 comments on commit 689b7af

Please sign in to comment.