Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add cmds for rocks and pebble builds #2007

Merged
merged 27 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6180f5a
add support for rocks and pebble in dockerfile
GAtom22 Nov 6, 2023
c7d9dbf
add changelog
GAtom22 Nov 6, 2023
3f1bbe6
Merge branch 'main' into GAtom22/dockerfile-rocks
GAtom22 Nov 7, 2023
3c99d73
wip - add script to build rocksdb
GAtom22 Nov 7, 2023
dcf7ac2
add librocks installation script
GAtom22 Nov 8, 2023
ba19564
Merge branch 'GAtom22/dockerfile-rocks' of https://github.com/evmos/e…
GAtom22 Nov 8, 2023
7ca1019
Merge branch 'main' into GAtom22/dockerfile-rocks
GAtom22 Nov 8, 2023
c0239fe
update changelog msg
GAtom22 Nov 8, 2023
eaf30e7
fix lint issues
GAtom22 Nov 8, 2023
5284d4e
fix lint issue
GAtom22 Nov 8, 2023
3ef1ac8
refactor
GAtom22 Nov 8, 2023
851963f
refactor
GAtom22 Nov 8, 2023
d5c8602
add comment
GAtom22 Nov 8, 2023
927b5ec
Merge branch 'main' into GAtom22/dockerfile-rocks
Vvaradinov Nov 10, 2023
eeaf4bb
update docker dep
GAtom22 Nov 10, 2023
3aafb26
Merge branch 'main' into GAtom22/dockerfile-rocks
GAtom22 Nov 17, 2023
7c05b37
add dockerfile for build with librocksdb
GAtom22 Nov 17, 2023
5a76cc5
update chlog
GAtom22 Nov 17, 2023
2916b0f
add rocks v as arg
GAtom22 Nov 17, 2023
e692dbd
fix lint issues
GAtom22 Nov 17, 2023
968db18
fix script
GAtom22 Nov 17, 2023
62e5f33
refactor dockerfile
GAtom22 Nov 17, 2023
d3a614e
Merge branch 'main' into GAtom22/dockerfile-rocks
GAtom22 Nov 20, 2023
fdbf4cf
update docker dep
GAtom22 Nov 20, 2023
df356c0
Merge branch 'GAtom22/dockerfile-rocks' of https://github.com/evmos/e…
GAtom22 Nov 20, 2023
726f06e
Merge branch 'main' into GAtom22/dockerfile-rocks
GAtom22 Nov 20, 2023
8f79709
Merge branch 'main' into GAtom22/dockerfile-rocks
fedekunze Nov 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (distribution) [#1992](https://github.com/evmos/evmos/pull/1992) Remove outdated check utility for distribution approval.
- (erc20) [#1994](https://github.com/evmos/evmos/pull/1994) Add tests for ERC20 precompile type utilities.
- (erc20) [#2005](https://github.com/evmos/evmos/pull/2005) Add tests for ERC20 precompile approvals.
- (bin) [#2007](https://github.com/evmos/evmos/pull/2007) Add commands in Makefile for building binary with rocksDB and pebbleDB
- (erc20) [#2009](https://github.com/evmos/evmos/pull/2009) Add ERC20 precompile transaction unit tests.
- (osmosis-outpost) [#2011](https://github.com/evmos/evmos/pull/2011) Update outpost swap ABI to return IBC next sequence.
- (utils) [#2010](https://github.com/evmos/evmos/pull/2010) Add utils function to create ibc denom trace.
Expand Down
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM golang:1.21.4-alpine3.18 AS build-env

ARG DB_BACKEND=goleveldb

WORKDIR /go/src/github.com/evmos/evmos

COPY go.mod go.sum ./
Expand All @@ -12,7 +14,12 @@ RUN --mount=type=bind,target=. --mount=type=secret,id=GITHUB_TOKEN \

COPY . .

RUN make build
RUN if [ "$DB_BACKEND" = "pebbledb" ]; then \
make build-pebbledb; \
else \
# Build default binary (LevelDB)
make build; \
fi

RUN go install github.com/MinseokOh/toml-cli@latest

Expand All @@ -23,7 +30,7 @@ WORKDIR /root
COPY --from=build-env /go/src/github.com/evmos/evmos/build/evmosd /usr/bin/evmosd
COPY --from=build-env /go/bin/toml-cli /usr/bin/toml-cli

RUN apk add --no-cache ca-certificates=20230506-r0 jq=1.6-r3 curl=8.4.0-r0 bash=5.2.15-r5 vim=9.0.1568-r0 lz4=1.9.4-r4 rclone=1.62.2-r5 \
RUN apk add --no-cache ca-certificates=20230506-r0 jq=1.6-r3 curl=8.4.0-r0 bash=5.2.15-r5 vim=9.0.2073-r0 lz4=1.9.4-r4 rclone=1.62.2-r5 \
&& addgroup -g 1000 evmos \
&& adduser -S -h /home/evmos -D evmos -u 1000 -G evmos

Expand Down
41 changes: 41 additions & 0 deletions Dockerfile.rocksdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM golang:1.21.4-alpine3.18 AS build-env

ARG ROCKSDB_VERSION="8.5.3"

WORKDIR /go/src/github.com/evmos/evmos

COPY go.mod go.sum ./

RUN set -eux; apk add --no-cache ca-certificates=20230506-r0 build-base=0.5-r3 git=2.40.1-r0 linux-headers=6.3-r0 bash=5.2.15-r5

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/"; \
go mod download

COPY . .

RUN make build-rocksdb

RUN go install github.com/MinseokOh/toml-cli@latest

FROM alpine:3.18

WORKDIR /root

COPY --from=build-env /go/src/github.com/evmos/evmos/build/evmosd /usr/bin/evmosd
COPY --from=build-env /go/bin/toml-cli /usr/bin/toml-cli

# Copy required libs for rocksdb build
COPY --from=build-env /usr/lib /usr/lib
COPY --from=build-env /usr/include /usr/include

RUN apk add --no-cache ca-certificates=20230506-r0 jq=1.6-r3 curl=8.4.0-r0 bash=5.2.15-r5 vim=9.0.2073-r0 lz4=1.9.4-r4 rclone=1.62.2-r5 \
&& addgroup -g 1000 evmos \
&& adduser -S -h /home/evmos -D evmos -u 1000 -G evmos

USER 1000
WORKDIR /home/evmos

EXPOSE 26656 26657 1317 9090 8545 8546

CMD ["evmosd"]
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ DOCKER_TAG := $(COMMIT_HASH)
# e2e env
MOUNT_PATH := $(shell pwd)/build/:/root/
E2E_SKIP_CLEANUP := false
ROCKSDB_VERSION ?= "8.5.3"

export GO111MODULE = on

Expand Down Expand Up @@ -169,6 +170,18 @@ build-docker:
echo 'docker run -it --rm -v $${SCRIPT_PATH}/.evmosd:/home/evmos/.evmosd $$IMAGE_NAME evmosd "$$@"' >> ./build/evmosd
chmod +x ./build/evmosd

build-pebbledb:
@go mod edit -replace github.com/cometbft/cometbft-db=github.com/notional-labs/cometbft-db@pebble
@go mod tidy
COSMOS_BUILD_OPTIONS=pebbledb $(MAKE) build

build-rocksdb:
# Make sure to run this command with root permission
./scripts/install_librocksdb.sh $(ROCKSDB_VERSION)
CGO_ENABLED=1 CGO_CFLAGS="-I/usr/include" \
CGO_LDFLAGS="-L/usr/lib -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4 -lzstd -ldl" \
COSMOS_BUILD_OPTIONS=rocksdb $(MAKE) build

push-docker: build-docker
$(DOCKER) push ${DOCKER_IMAGE}:${DOCKER_TAG}
$(DOCKER) push ${DOCKER_IMAGE}:latest
Expand Down
82 changes: 82 additions & 0 deletions scripts/install_librocksdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

ROCKSDB_VERSION=${1:-"8.5.3"}

# Check if RocksDB is already installed
if [[ $(find /usr/lib -name "librocksdb.so.${ROCKSDB_VERSION}" -print -quit) ]]; then
read -r -p "RocksDB version ${ROCKSDB_VERSION} is already installed. Do you want to reinstall it? (yes/no): " choice
case "$choice" in
y | yes | Yes | YES)
echo "Reinstalling RocksDB..."
rm -rf /usr/lib/librocksdb*
;;
n | no | No | NO)
echo "Skipping RocksDB installation."
exit 0
;;
*)
echo "Invalid choice. Please enter 'yes' or 'no'."
exit 1
;;
esac
else
# RocksDB is not installed, proceed with installation
echo "RocksDB is not installed. Proceeding with installation..."
fi

# Check the OS type and perform different actions
if [[ $(uname) == "Linux" ]]; then
# Check Linux distribution
if [[ -f /etc/os-release ]]; then
source /etc/os-release

if [[ "$ID" == "ubuntu" ]]; then
# Ubuntu specific dep installation
echo "Installing RocksDB dependencies..."
apt-get install libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev build-essential clang

elif [[ "$ID" == "alpine" ]]; then
# Alpine specific dep installation
echo "Installing RocksDB dependencies..."
# 1. Install dependencies
echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >>/etc/apk/repositories
apk add --update --no-cache cmake bash perl g++
apk add --update --no-cache zlib zlib-dev bzip2 bzip2-dev snappy snappy-dev lz4 lz4-dev zstd@testing zstd-dev@testing libtbb-dev@testing libtbb@testing
# 2. Install latest gflags
cd /tmp &&
git clone https://github.com/gflags/gflags.git &&
cd gflags &&
mkdir build &&
cd build &&
cmake -DBUILD_SHARED_LIBS=1 -DGFLAGS_INSTALL_SHARED_LIBS=1 .. &&
make install &&
rm -rf /tmp/gflags
else
echo "Linux distribution not supported"
exit 1
fi

# 3. Install Rocksdb (same for any linux distribution)
Aminechakr marked this conversation as resolved.
Show resolved Hide resolved
cd /tmp &&
git clone -b v"${ROCKSDB_VERSION}" --single-branch https://github.com/facebook/rocksdb.git &&
cd rocksdb &&
PORTABLE=1 WITH_JNI=0 WITH_BENCHMARK_TOOLS=0 WITH_TESTS=1 WITH_TOOLS=0 WITH_CORE_TOOLS=1 WITH_BZ2=1 WITH_LZ4=1 WITH_SNAPPY=1 WITH_ZLIB=1 WITH_ZSTD=1 WITH_GFLAGS=0 USE_RTTI=1 \
make shared_lib &&
cp librocksdb.so* /usr/lib/ &&
cp -r include/* /usr/include/ &&
rm -rf /tmp/rocksdb
else
echo "Cannot determine Linux distribution."
exit 1
fi

elif [[ $(uname) == "Darwin" ]]; then
# macOS-specific actions
xcode-select --install
brew tap homebrew/versions
brew install gcc7 --use-llvm
brew install rocksdb
else
echo "Unsupported OS."
exit 1
fi
2 changes: 1 addition & 1 deletion scripts/run-nix-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ cd ../tests/nix_tests/hardhat
npm install
npm run typechain
cd ..
pytest -vv -s
pytest test_osmosis_outpost.py -vv -s
GAtom22 marked this conversation as resolved.
Show resolved Hide resolved