Skip to content

Commit

Permalink
Merge branch 'releases/v1.0.2' into releases/v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yang committed Feb 25, 2024
2 parents 98901bf + 1424193 commit 7539228
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 78 deletions.
39 changes: 19 additions & 20 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ builds:
binary: nibid
hooks:
pre:
- bash contrib/scripts/release_pre_darwin.sh
- cmd: bash contrib/scripts/release_pre_darwin.sh
output: false # enable for debug
env:
- TARGET={{ .Target }}
goos:
- darwin
goarch:
- amd64
- arm64
env:
- CC=o64-clang
- CC_darwin_amd64=o64-clang
- CC_darwin_arm64=oa64-clang
- 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}'
flags:
- -mod=readonly
- -trimpath
Expand All @@ -34,28 +39,28 @@ builds:
- osusergo
- ledger
- static
- static_wasm
- rocksdb
- static_wasm
- grocksdb_no_link
overrides:
- goos: darwin
goarch: arm64
env:
- CC=oa64-clang

- id: linux
main: ./cmd/nibid
binary: nibid
hooks:
pre:
- bash contrib/scripts/release_pre_linux.sh
- cmd: bash contrib/scripts/release_pre_linux.sh
output: false # enable for debug
env:
- TARGET={{ .Target }}
goos:
- linux
goarch:
- amd64
- arm64
env:
- CC=x86_64-linux-gnu-gcc
- CC_linux_amd64=x86_64-linux-gnu-gcc
- CC_linux_arm64=aarch64-linux-gnu-gcc
- 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}'
flags:
- -mod=readonly
- -trimpath
Expand All @@ -67,20 +72,14 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/types.DBBackend=rocksdb
- -linkmode=external
- -extldflags '-static -lrocksdb -lstdc++ -lm -ldl -lpthread'
- -extldflags '-static -lm -lbz2'
tags:
- netgo
- osusergo
- ledger
- muslc
- rocksdb
- grocksdb_no_link
- static
overrides:
- goos: linux
goarch: arm64
env:
- CC=aarch64-linux-gnu-gcc
- rocksdb
- muslc

universal_binaries:
- id: darwin
- id: darwin
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1799](https://github.com/NibiruChain/nibiru/pull/1799) refactor,docs(inflation): Document everything + delete unused code. Make perp and spot optional features in localnet.sh
* [#1808](https://github.com/NibiruChain/nibiru/pull/1808) - Bump `cosmos-sdk` to v0.47.9

## v1.0.2

### Dependencies

* [#1808](https://github.com/NibiruChain/nibiru/pull/1808) - Bump `cosmos-sdk` to v0.47.9

## [v1.0.1](https://github.com/NibiruChain/nibiru/releases/tag/v1.0.1) - 2024-02-09

### Dependencies

* [#1778](https://github.com/NibiruChain/nibiru/pull/1778) - chore: bump librocksdb to v8.9.1

## [v1.0.0](https://github.com/NibiruChain/nibiru/releases/tag/v1.0.0)

### Features
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19 AS builder
FROM golang:1.21 AS builder

WORKDIR /nibiru

Expand All @@ -24,4 +24,4 @@ RUN apk --no-cache add \
COPY --from=builder /nibiru/build/nibid /usr/local/bin/nibid

ENTRYPOINT ["nibid"]
CMD [ "start" ]
CMD [ "start" ]
1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ func NewNibiruApp(
app.initModuleManager(encodingConfig, skipGenesisInvariants)

app.setupUpgrades()

// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.

Expand Down
2 changes: 2 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/NibiruChain/nibiru/app/upgrades"
"github.com/NibiruChain/nibiru/app/upgrades/v1_0_2"
"github.com/NibiruChain/nibiru/app/upgrades/v1_1_0"
)

var Upgrades = []upgrades.Upgrade{
v1_0_2.Upgrade,
v1_1_0.Upgrade,
}

Expand Down
23 changes: 23 additions & 0 deletions app/upgrades/v1_0_2/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package v1_0_2

import (
"github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/NibiruChain/nibiru/app/upgrades"
)

const UpgradeName = "v1.0.2"

// pretty much a no-op store upgrade to test the upgrade process and include the newer version of rocksdb + cosmos-sdk
var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, cfg, fromVM)
}
},
StoreUpgrades: types.StoreUpgrades{},
}
93 changes: 62 additions & 31 deletions contrib/make/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,34 @@
### Build Flags ###
###############################################################################

# BRANCH: Current git branch
# COMMIT: Current commit hash
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')

# don't override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
VERSION := $(shell git describe --exact-match 2>/dev/null)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif


OS_NAME := $(shell uname -s | tr A-Z a-z)
ifeq ($(shell uname -m),x86_64)
ARCH_NAME := amd64
else
ARCH_NAME := arm64
endif
SUDO := $(shell if [ "$(shell id -u)" != "0" ]; then echo "sudo"; fi)

# SDK_PACK: Cosmos-SDK version
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
TM_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7"
ROCKSDB_VERSION := 8.1.1
# TM_VERSION: Tendermint Core version (CometBFT)
# grab everything after the space in "github.com/tendermint/tendermint v0.34.7"
TM_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
ROCKSDB_VERSION := 8.9.1
WASMVM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm | awk '{sub(/^v/, "", $$2); print $$2}')
DOCKER := $(shell which docker)
BUILDDIR ?= $(CURDIR)/build
Expand All @@ -34,7 +39,12 @@ TEMPDIR ?= $(CURDIR)/temp
export GO111MODULE = on

# process build tags
build_tags = netgo osusergo rocksdb grocksdb_no_link static_wasm muslc ledger
build_tags = netgo osusergo ledger static rocksdb
ifeq ($(OS_NAME),darwin)
build_tags += static_wasm grocksdb_no_link
else
build_tags += muslc
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

Expand All @@ -59,11 +69,11 @@ ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
CGO_CFLAGS := -I$(TEMPDIR)/include
CGO_LDFLAGS := -L$(TEMPDIR)/lib -lrocksdb -lstdc++ -lm -ldl
CGO_LDFLAGS := -L$(TEMPDIR)/lib
ifeq ($(OS_NAME),darwin)
CGO_LDFLAGS += -lz -lbz2
CGO_LDFLAGS += -lrocksdb -lstdc++ -lz -lbz2
else
CGO_LDFLAGS += -static -lwasmvm_muslc
CGO_LDFLAGS += -static -lm -lbz2
endif

###############################################################################
Expand All @@ -77,30 +87,51 @@ $(TEMPDIR)/:
rocksdblib: $(TEMPDIR)/
@mkdir -p $(TEMPDIR)/include
@mkdir -p $(TEMPDIR)/lib
ifeq (",$(wildcard $(TEMPDIR)/include/rocksdb)")
wget https://github.com/NibiruChain/gorocksdb/releases/download/v$(ROCKSDB_VERSION)/include.$(ROCKSDB_VERSION).tar.gz -O - | tar -xz -C $(TEMPDIR)/include/
endif
ifeq (",$(wildcard $(TEMPDIR)/lib/librocksdb.a)")
wget https://github.com/NibiruChain/gorocksdb/releases/download/v$(ROCKSDB_VERSION)/librocksdb_$(ROCKSDB_VERSION)_$(OS_NAME)_$(ARCH_NAME).tar.gz -O - | tar -xz -C $(TEMPDIR)/lib/
endif
@if [ ! -d $(TEMPDIR)/include/rocksdb ] ; \
then \
wget https://github.com/NibiruChain/gorocksdb/releases/download/v$(ROCKSDB_VERSION)/include.$(ROCKSDB_VERSION).tar.gz -O - | tar -xz -C $(TEMPDIR)/include/; \
fi
@if [ ! -f $(TEMPDIR)/lib/librocksdb.a ] ; \
then \
wget https://github.com/NibiruChain/gorocksdb/releases/download/v$(ROCKSDB_VERSION)/librocksdb_$(ROCKSDB_VERSION)_$(OS_NAME)_$(ARCH_NAME).tar.gz -O - | tar -xz -C $(TEMPDIR)/lib/; \
fi

wasmvmlib: $(TEMPDIR)/
@mkdir -p $(TEMPDIR)/lib
ifeq (",$(wildcard $(TEMPDIR)/lib/libwasmvm*.a)")
ifeq ($(OS_NAME),darwin)
wget https://github.com/CosmWasm/wasmvm/releases/download/v$(WASMVM_VERSION)/libwasmvmstatic_darwin.a -O $(TEMPDIR)/lib/libwasmvmstatic_darwin.a
else
ifeq ($(ARCH_NAME),amd64)
wget https://github.com/CosmWasm/wasmvm/releases/download/v$(WASMVM_VERSION)/libwasmvm_muslc.x86_64.a -O $(TEMPDIR)/lib/libwasmvm_muslc.a
else
wget https://github.com/CosmWasm/wasmvm/releases/download/v$(WASMVM_VERSION)/libwasmvm_muslc.aarch64.a -O $(TEMPDIR)/lib/libwasmvm_muslc.a
endif
endif
endif
@if [ ! -f $(TEMPDIR)/lib/libwasmvm*.a ] ; \
then \
if [ "$(OS_NAME)" = "darwin" ] ; \
then \
wget https://github.com/CosmWasm/wasmvm/releases/download/v$(WASMVM_VERSION)/libwasmvmstatic_darwin.a -O $(TEMPDIR)/lib/libwasmvmstatic_darwin.a; \
else \
if [ "$(ARCH_NAME)" = "amd64" ] ; \
then \
wget https://github.com/CosmWasm/wasmvm/releases/download/v$(WASMVM_VERSION)/libwasmvm_muslc.x86_64.a -O $(TEMPDIR)/lib/libwasmvm_muslc.a; \
else \
wget https://github.com/CosmWasm/wasmvm/releases/download/v$(WASMVM_VERSION)/libwasmvm_muslc.aarch64.a -O $(TEMPDIR)/lib/libwasmvm_muslc.a; \
fi; \
fi; \
fi

packages:
@if [ "$(OS_NAME)" = "linux" ] ; \
then \
if [ -f /etc/debian_version ] ; \
then \
$(SUDO) apt-get update; \
dpkg -s liblz4-dev > /dev/null 2>&1 || $(SUDO) apt-get install --no-install-recommends -y liblz4-dev; \
dpkg -s libsnappy-dev > /dev/null 2>&1 || $(SUDO) apt-get install --no-install-recommends -y libsnappy-dev; \
dpkg -s zlib1g-dev > /dev/null 2>&1 || $(SUDO) apt-get install --no-install-recommends -y zlib1g-dev; \
dpkg -s libbz2-dev > /dev/null 2>&1 || $(SUDO) apt-get install --no-install-recommends -y libbz2-dev; \
dpkg -s libzstd-dev > /dev/null 2>&1 || $(SUDO) apt-get install --no-install-recommends -y libzstd-dev; \
else \
echo "Please make sure you have installed the following libraries: lz4, snappy, z, bz2, zstd"; \
fi; \
fi

# command for make build and make install
build: BUILDARGS=-o $(BUILDDIR)/
build install: go.sum $(BUILDDIR)/ rocksdblib wasmvmlib
build install: go.sum $(BUILDDIR)/ rocksdblib wasmvmlib packages
CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go $@ -mod=readonly $(BUILD_FLAGS) $(BUILDARGS) ./...

# ensure build directory exists
Expand All @@ -111,4 +142,4 @@ go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify

.PHONY: build install
.PHONY: build install
12 changes: 8 additions & 4 deletions contrib/make/release.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
###############################################################################

PACKAGE_NAME := github.com/NibiruChain/nibiru
GOLANG_CROSS_VERSION ?= v1.19.4
GOLANG_CROSS_VERSION ?= v1.21.5

# The `make release` command is running a Docker container with the image
# `gorelease/goreleaser-cross:${GOLANG_CROSS_VERSION}`. This command:
# `-v "$(CURDIR)":/go/src/$(PACKAGE_NAME)`: mounts the current directory
# `release --clean`: executes the release inside the directory
release:
docker run \
--rm \
Expand All @@ -14,15 +18,15 @@ release:
-e CGO_ENABLED=1 \
-e GITHUB_TOKEN=${GITHUB_TOKEN} \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --rm-dist
release --clean

release-snapshot:
docker run \
--rm \
--platform linux/amd64 \
-v /tmp:/tmp \
-v "$(CURDIR)":/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
-e CGO_ENABLED=1 \
-e GITHUB_TOKEN=${GITHUB_TOKEN} \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --rm-dist --snapshot
release --clean --snapshot
10 changes: 5 additions & 5 deletions contrib/scripts/release_pre_darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
set -e

WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | awk '{sub(/^v/, "", $2); print $2}')
wget https://github.com/CosmWasm/wasmvm/releases/download/v${WASMVM_VERSION}/libwasmvmstatic_darwin.a -O /osxcross/target/SDK/MacOSX12.0.sdk/usr/lib/libwasmvmstatic_darwin.a
wget https://github.com/NibiruChain/gorocksdb/releases/download/v8.1.1/include.8.1.1.tar.gz -O /root/include.8.1.1.tar.gz
tar -xf /root/include.8.1.1.tar.gz -C /osxcross/target/SDK/MacOSX12.0.sdk/usr/include/
wget https://github.com/NibiruChain/gorocksdb/releases/download/v8.1.1/librocksdb_8.1.1_darwin_all.tar.gz -O /root/librocksdb_8.1.1_darwin_all.tar.gz
tar -xf /root/librocksdb_8.1.1_darwin_all.tar.gz -C /osxcross/target/SDK/MacOSX12.0.sdk/usr/lib/
ROCKSDB_VERSION=8.9.1

flock -x /tmp/wasmvm-lock -c "wget -c https://github.com/CosmWasm/wasmvm/releases/download/v${WASMVM_VERSION}/libwasmvmstatic_darwin.a -O /tmp/libwasmvmstatic_darwin.a && [ ! -f /usr/local/osxcross/SDK/MacOSX12.0.sdk/usr/lib/libwasmvmstatic_darwin.a ] && cp /tmp/libwasmvmstatic_darwin.a /usr/local/osxcross/SDK/MacOSX12.0.sdk/usr/lib/libwasmvmstatic_darwin.a; echo 'libwasmvm installed'"
flock -x /tmp/rocksdb-darwin-headers-lock -c "wget -c https://github.com/NibiruChain/gorocksdb/releases/download/v${ROCKSDB_VERSION}/include.${ROCKSDB_VERSION}.tar.gz -O /tmp/include.${ROCKSDB_VERSION}.tar.gz && [ ! -d /usr/local/osxcross/SDK/MacOSX12.0.sdk/usr/include/rocksdb ] && tar -xvf /tmp/include.${ROCKSDB_VERSION}.tar.gz -C /usr/local/osxcross/SDK/MacOSX12.0.sdk/usr/include/; echo 'rocksdb headers installed'"
flock -x /tmp/rocksdb-lib-lock -c "wget -c https://github.com/NibiruChain/gorocksdb/releases/download/v${ROCKSDB_VERSION}/librocksdb_${ROCKSDB_VERSION}_darwin_all.tar.gz -O /tmp/librocksdb_${ROCKSDB_VERSION}_darwin_all.tar.gz && [ ! -f /usr/local/osxcross/SDK/MacOSX12.0.sdk/usr/lib/librocksdb.a ] && tar -xvf /tmp/librocksdb_${ROCKSDB_VERSION}_darwin_all.tar.gz -C /usr/local/osxcross/SDK/MacOSX12.0.sdk/usr/lib/; echo 'librocksdb installed'"
30 changes: 22 additions & 8 deletions contrib/scripts/release_pre_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@
set -e

WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | awk '{sub(/^v/, "", $2); print $2}')
wget https://github.com/CosmWasm/wasmvm/releases/download/v${WASMVM_VERSION}/libwasmvm_muslc.x86_64.a -O /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.a
wget https://github.com/CosmWasm/wasmvm/releases/download/v${WASMVM_VERSION}/libwasmvm_muslc.aarch64.a -O /usr/lib/aarch64-linux-gnu/libwasmvm_muslc.a
wget https://github.com/NibiruChain/gorocksdb/releases/download/v8.1.1/include.8.1.1.tar.gz -O /root/include.8.1.1.tar.gz
tar -xvf /root/include.8.1.1.tar.gz -C /usr/include/
wget https://github.com/NibiruChain/gorocksdb/releases/download/v8.1.1/librocksdb_8.1.1_linux_amd64.tar.gz -O /root/librocksdb_8.1.1_linux_amd64.tar.gz
tar -xvf /root/librocksdb_8.1.1_linux_amd64.tar.gz -C /usr/lib/x86_64-linux-gnu/
wget https://github.com/NibiruChain/gorocksdb/releases/download/v8.1.1/librocksdb_8.1.1_linux_arm64.tar.gz -O /root/librocksdb_8.1.1_linux_arm64.tar.gz
tar -xvf /root/librocksdb_8.1.1_linux_arm64.tar.gz -C /usr/lib/aarch64-linux-gnu/
ROCKSDB_VERSION=8.9.1

flock -x /tmp/apt-lock -c "[ \"$(ls -A /var/lib/apt/lists)\" ] || apt-get update"
flock -x /tmp/rocksdb-linux-headers-lock -c "wget -c https://github.com/NibiruChain/gorocksdb/releases/download/v${ROCKSDB_VERSION}/include.${ROCKSDB_VERSION}.tar.gz -O /tmp/include.${ROCKSDB_VERSION}.tar.gz && [ ! -d /usr/include/rocksdb ] && tar -xvf /tmp/include.${ROCKSDB_VERSION}.tar.gz -C /usr/include/; echo 'rocksdb headers installed'"

if [ "$TARGET" == "linux_amd64_v1" ]; then
apt-get -o DPkg::Lock::Timeout=60 install --no-install-recommends -y libzstd-dev:amd64 libsnappy-dev:amd64 liblz4-dev:amd64 libbz2-dev:amd64 zlib1g-dev:amd64

wget -c https://github.com/CosmWasm/wasmvm/releases/download/v${WASMVM_VERSION}/libwasmvm_muslc.x86_64.a -O /tmp/libwasmvm_muslc.x86_64.a
cp /tmp/libwasmvm_muslc.x86_64.a /usr/lib/x86_64-linux-gnu/libwasmvm_muslc.a

wget -c https://github.com/NibiruChain/gorocksdb/releases/download/v${ROCKSDB_VERSION}/librocksdb_${ROCKSDB_VERSION}_linux_amd64.tar.gz -O /tmp/librocksdb_${ROCKSDB_VERSION}_linux_amd64.tar.gz
tar -xvf /tmp/librocksdb_${ROCKSDB_VERSION}_linux_amd64.tar.gz -C /usr/lib/x86_64-linux-gnu/
else
apt-get -o DPkg::Lock::Timeout=60 install --no-install-recommends -y libzstd-dev:arm64 libsnappy-dev:arm64 liblz4-dev:arm64 libbz2-dev:arm64 zlib1g-dev:arm64

wget -c https://github.com/CosmWasm/wasmvm/releases/download/v${WASMVM_VERSION}/libwasmvm_muslc.aarch64.a -O /tmp/libwasmvm_muslc.aarch64.a
cp /tmp/libwasmvm_muslc.aarch64.a /usr/lib/aarch64-linux-gnu/libwasmvm_muslc.a

wget -c https://github.com/NibiruChain/gorocksdb/releases/download/v${ROCKSDB_VERSION}/librocksdb_${ROCKSDB_VERSION}_linux_arm64.tar.gz -O /tmp/librocksdb_${ROCKSDB_VERSION}_linux_arm64.tar.gz
tar -xvf /tmp/librocksdb_${ROCKSDB_VERSION}_linux_arm64.tar.gz -C /usr/lib/aarch64-linux-gnu/
fi
Loading

0 comments on commit 7539228

Please sign in to comment.