Skip to content

Commit

Permalink
Merge branch 'extra-rest/v2.5.x' of https://github.com/bandprotocol/c…
Browse files Browse the repository at this point in the history
…hain into extra-rest/v2.4.x-add-relayer-stat
  • Loading branch information
satawatnack committed Apr 26, 2023
2 parents ceaf446 + 61e869e commit 4ea7a1e
Show file tree
Hide file tree
Showing 48 changed files with 1,085 additions and 856 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release

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

jobs:
build_static_bin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Build statically linked binaries
run: |
mkdir artifacts
docker build -t chain:static -f Dockerfile.static .
id=$(docker create chain:static)
docker cp $id:/usr/bin/bandd artifacts/bandd-${{ github.ref_name }}-linux-amd64
docker rm -v $id
- name: Create checksums
working-directory: artifacts
run: sha256sum * > checksums.txt && cat checksums.txt

- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/**
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Changelog

## [v2.5.1](https://github.com/bandprotocol/chain/releases/tag/v2.5.1)

- (bump) Use cosmos-sdk package v0.45.15 / tendermint v0.34.27
- (bump) Use go-owasm v0.2.3
- (chain) Support statically linked binary for bandd

## [v2.5.0](https://github.com/bandprotocol/chain/releases/tag/v2.5.0)

- (bump) Use cosmos-sdk package v0.45.14 / tendermint v0.34.26 / ibc-go v4.3.0
- (chain) add new rest paths to prepare for the moving from rest to grpc in 2.6.x

## [v2.4.1](https://github.com/bandprotocol/chain/releases/tag/v2.4.1)

- (bump) Use cosmos-sdk package v0.45.10 / tendermint v0.34.22 / ibc-go v3.3.1

## [v2.4.0](https://github.com/bandprotocol/chain/releases/tag/v2.4.0)
Expand Down
27 changes: 27 additions & 0 deletions Dockerfile.static
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM golang:1.19-alpine as go-builder

SHELL ["/bin/sh", "-ecuxo", "pipefail"]
RUN apk add --no-cache ca-certificates build-base linux-headers git gmp gmp-dev

WORKDIR /chain
COPY . /chain

RUN go mod download
RUN GO_OWASM_VERSION=$(go list -m github.com/bandprotocol/go-owasm | cut -d ' ' -f 2) && \
wget https://github.com/bandprotocol/go-owasm/releases/download/$GO_OWASM_VERSION/libgo_owasm_muslc.x86_64.a -O /lib/libgo_owasm_muslc.x86_64.a
RUN sha256sum /lib/libgo_owasm_muslc.x86_64.a | grep c56ad7694196175df51585cbc7f2543cfa8ba9a42c62dcfec76ca28a5842d073

# Copy the library you want to the final location that will be found by the linker flag `-lgo_owasm_muslc`
RUN cp /lib/libgo_owasm_muslc.x86_64.a /lib/libgo_owasm_muslc.a

# force it to use static lib (from above) not standard libgo_owasm.so file
RUN LEDGER_ENABLED=true BUILD_TAGS=muslc LINK_STATICALLY=true make install \
&& echo "Ensuring binary is statically linked ..." \
&& (file /go/bin/bandd | grep "statically linked")

# --------------------------------------------------------
FROM alpine:3.16

COPY --from=go-builder /go/bin/bandd /usr/bin/bandd

ENTRYPOINT ["/usr/bin/bandd"]
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,38 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin

DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf

export GO111MODULE = on

build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
build_tags += ledger
endif

build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

whitespace :=
empty = $(whitespace) $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(empty),$(comma),$(build_tags))

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=bandchain \
-X github.com/cosmos/cosmos-sdk/version.AppName=bandd \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags)"
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"

ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
BUILD_FLAGS := -tags "$(build_tags_comma_sep)" -ldflags '$(ldflags)'

all: install

Expand Down
4 changes: 2 additions & 2 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante"
"github.com/cosmos/ibc-go/v3/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v4/modules/core/ante"
"github.com/cosmos/ibc-go/v4/modules/core/keeper"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
Expand Down
52 changes: 36 additions & 16 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts"
icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"
"github.com/cosmos/ibc-go/v3/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v3/modules/core"
ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts"
icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types"
icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types"
"github.com/cosmos/ibc-go/v4/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v4/modules/core"
ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
Expand Down Expand Up @@ -963,6 +963,21 @@ func (app *BandApp) setupUpgradeHandlers() {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
},
)

app.UpgradeKeeper.SetUpgradeHandler(
"v2_5",
func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Starting module migrations...")

vm, err := app.mm.RunMigrations(ctx, app.configurator, vm)
if err != nil {
return vm, err
}

ctx.Logger().Info("Upgrade complete")
return vm, err
},
)
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
Expand All @@ -983,4 +998,9 @@ func (app *BandApp) setupUpgradeStoreLoaders() {

app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}

if upgradeInfo.Name == "v2_5" {
storeUpgrades := storetypes.StoreUpgrades{}
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
}
12 changes: 6 additions & 6 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts"
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"
ibctransfer "github.com/cosmos/ibc-go/v3/modules/apps/transfer"
ibctransafertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v3/modules/core"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts"
icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types"
ibctransfer "github.com/cosmos/ibc-go/v4/modules/apps/transfer"
ibctransafertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v4/modules/core"
ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host"

"github.com/bandprotocol/chain/v2/x/oracle"
oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types"
Expand Down
6 changes: 3 additions & 3 deletions app/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
v040 "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v040"
v043 "github.com/cosmos/cosmos-sdk/x/genutil/legacy/v043"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
ibcxfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
host "github.com/cosmos/ibc-go/v3/modules/core/24-host"
ibccoretypes "github.com/cosmos/ibc-go/v3/modules/core/types"
ibcxfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
host "github.com/cosmos/ibc-go/v4/modules/core/24-host"
ibccoretypes "github.com/cosmos/ibc-go/v4/modules/core/types"
"github.com/spf13/cobra"
tmjson "github.com/tendermint/tendermint/libs/json"
tmtypes "github.com/tendermint/tendermint/types"
Expand Down
3 changes: 3 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ func RegisterRoutes(cliCtx client.Context, r *mux.Router) {
r.HandleFunc("/bandchain/chain_id", GetChainIDFn(cliCtx)).Methods("GET")
r.HandleFunc("/bandchain/genesis", GetGenesisHandlerFn(cliCtx)).Methods("GET")
r.HandleFunc("/bandchain/evm-validators", GetEVMValidators(cliCtx)).Methods("GET")

r.HandleFunc("/bandchain/v1/chain_id", GetChainIDFn(cliCtx)).Methods("GET")
r.HandleFunc("/bandchain/v1/evm-validators", GetEVMValidators(cliCtx)).Methods("GET")
}
Loading

0 comments on commit 4ea7a1e

Please sign in to comment.