Skip to content

Commit

Permalink
Merge pull request #300 from bandprotocol/bump-cosmos
Browse files Browse the repository at this point in the history
[2.5] Bump cosmos (0.45.15), backport build statically linked binary
  • Loading branch information
RogerKSI authored Mar 23, 2023
2 parents 7e3aab9 + 654fe29 commit 21a8d6e
Show file tree
Hide file tree
Showing 6 changed files with 307 additions and 130 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/**
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 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
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"]
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,45 @@ 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)"

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

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

all: install

install: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/bandd
go install -mod=readonly $(BUILD_FLAGS) ./cmd/yoda


release: go.sum
env GOOS=linux GOARCH=amd64 \
go build -mod=readonly -o ./build/bandd_linux_amd64 $(BUILD_FLAGS) ./cmd/bandd
Expand Down
38 changes: 19 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/bandprotocol/chain/v2
go 1.19

require (
github.com/bandprotocol/go-owasm v0.2.2
github.com/bandprotocol/go-owasm v0.2.3
github.com/confio/ics23/go v0.9.0
github.com/cosmos/cosmos-sdk v0.45.14
github.com/cosmos/cosmos-sdk v0.45.15
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/ibc-go/v4 v4.3.0
github.com/ethereum/go-ethereum v1.10.22
Expand All @@ -26,7 +26,7 @@ require (
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.14.0
github.com/stretchr/testify v1.8.1
github.com/tendermint/tendermint v0.34.26
github.com/tendermint/tendermint v0.34.27
github.com/tendermint/tm-db v0.6.7
google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa
google.golang.org/grpc v1.52.3
Expand All @@ -38,24 +38,25 @@ require (
cosmossdk.io/api v0.2.6 // indirect
cosmossdk.io/core v0.5.1 // indirect
cosmossdk.io/depinject v1.0.0-alpha.3 // indirect
filippo.io/edwards25519 v1.0.0-beta.2 // indirect
github.com/99designs/keyring v1.1.6 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/DataDog/zstd v1.5.0 // indirect
github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect
github.com/Workiva/go-datastructures v1.0.53 // indirect
github.com/armon/go-metrics v0.4.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
github.com/btcsuite/btcd v0.22.2 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20220817183557-09c6e030a677 // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
github.com/cometbft/cometbft-db v0.7.0 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/cosmos-db v0.0.0-20221226095112-f3c38ecb5e32 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.1 // indirect
Expand All @@ -67,7 +68,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
Expand All @@ -93,11 +94,10 @@ require (
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect
github.com/improbable-eng/grpc-web v0.14.1 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
Expand All @@ -110,7 +110,6 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
Expand All @@ -132,25 +131,26 @@ require (
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.5.0 // indirect
github.com/zondax/hid v0.9.1 // indirect
github.com/zondax/ledger-go v0.14.1 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/exp v0.0.0-20221019170559-20944726eadf // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/term v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
)

replace (
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
// use informal system fork of tendermint
github.com/tendermint/tendermint => github.com/informalsystems/tendermint v0.34.26
// use cometbft
github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.27
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
Loading

0 comments on commit 21a8d6e

Please sign in to comment.