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

e2e: moving integration e2e to babylon-sdk #68

Merged
merged 16 commits into from
Dec 14, 2024
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:

jobs:
test:
uses: babylonchain/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0
uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.11.2
with:
run-unit-tests: true
run-integration-tests: true
integration-tests-command: |
make test-e2e

docker_pipeline:
uses: babylonchain/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0
uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.11.2
needs: ["test"]
secrets: inherit
with:
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/integration-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: integration-e2e
on:
push:
branches:
- '**'

jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build IBC Simulator BCD Image
run: make build-ibcsim-bcd

- name: Build Babylond Image
run: make build-babylond

- name: Cache Go
uses: actions/setup-go@v5
with:
go-version: 1.23

- name: Run Integration Tests
run: sudo make test-e2e-bcd-consumer-integration
Copy link
Contributor

@maurolacy maurolacy Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to create a comprehensive test-e2e target in the Makefile, and call it from here. I'm pushing a companion / follow-up PR with some small improvements, if you don't mind.

Update: #70.

4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ on:

jobs:
test:
uses: babylonchain/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0
uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.11.2
with:
run-unit-tests: true
run-integration-tests: true
integration-tests-command: |
make test-e2e

docker_pipeline:
uses: babylonchain/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0
uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.11.2
needs: ["test"]
secrets: inherit
with:
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
# Dependency directories (remove the comment below to include it)
vendor/

.vscode/

# Go workspace file
coverage.txt

demo/build/
tmp/

# E2E test files
contrib/images/ibcsim-bcd/.testnets/
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,21 @@ proto-lint:
.PHONY: all install \
build build-linux-static test test-all test-e2e \
proto-all proto-format proto-swagger-gen proto-lint

###############################################################################
### Integration e2e ###
###############################################################################

build-ibcsim-bcd:
$(MAKE) -C contrib/images ibcsim-bcd

build-babylond:
$(MAKE) -C contrib/images babylond

start-bcd-consumer-integration:
$(MAKE) -C contrib/images start-bcd-consumer-integration

test-e2e-bcd-consumer-integration: start-bcd-consumer-integration
@cd tests/e2e
@go test -run TestBCDConsumerIntegrationTestSuite -mod=readonly -timeout=60m -v github.com/babylonlabs-io/babylon-sdk/tests/e2e --tags=e2e
@cd -
23 changes: 23 additions & 0 deletions contrib/images/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
BABYLON_SDK_FULL_PATH := $(shell git rev-parse --show-toplevel)

babylond: babylond-rmi
docker build --tag babylonlabs-io/babylond -f babylond/Dockerfile ${BABYLON_SDK_FULL_PATH}

babylond-rmi:
docker rmi babylonlabs-io/babylond --force 2>/dev/null; true

ibcsim-bcd:
docker build --tag babylonlabs-io/ibcsim-bcd -f ibcsim-bcd/Dockerfile ${BABYLON_SDK_FULL_PATH}

ibcsim-bcd-rmi:
docker rmi babylonlabs-io/ibcsim-bcd 2>/dev/null; true

start-bcd-consumer-integration: stop-bcd-consumer-integration
ibcsim-bcd/pre-deployment.sh
docker compose -f ibcsim-bcd/docker-compose.yml up -d

stop-bcd-consumer-integration:
docker compose -f ibcsim-bcd/docker-compose.yml down
rm -rf ibcsim-bcd/.testnets

.PHONY: ibcsim-bcd ibcsim-bcd-rmi start-bcd-consumer-integration stop-bcd-consumer-integration babylond babylond-rmi
64 changes: 64 additions & 0 deletions contrib/images/babylond/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
FROM golang:1.23-alpine AS build-env

# Customize to your build env

# TARGETPLATFORM should be one of linux/amd64 or linux/arm64.
ARG TARGETPLATFORM="linux/amd64"
# Version to build. Default is empty
ARG VERSION="base/consumer-chain-support"
ARG BABYLON_BUILD_OPTIONS=""
ARG COSMOS_BUILD_OPTIONS=""

# Use muslc for static libs
ARG BUILD_TAGS="muslc"
ARG LEDGER_ENABLED="false"


# Install cli tools for building and final image
RUN apk add --update --no-cache make git bash gcc linux-headers eudev-dev ncurses-dev openssh curl jq
RUN apk add --no-cache musl-dev

# Build
WORKDIR /go/src/github.com/babylonlabs-io/babylon
# Clone repo
RUN git clone https://github.com/babylonlabs-io/babylon.git /go/src/github.com/babylonlabs-io/babylon
# If version is set, then checkout this version
RUN if [ -n "${VERSION}" ]; then \
git fetch origin tag ${VERSION} --no-tags ; \
git checkout -f ${VERSION}; \
fi

# Cosmwasm - Download correct libwasmvm version
RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | cut -d ' ' -f 2) && \
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \
-O /lib/libwasmvm_muslc.$(uname -m).a && \
# verify checksum
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
sha256sum /lib/libwasmvm_muslc.$(uname -m).a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$(uname -m) | cut -d ' ' -f 1)

RUN LEDGER_ENABLED=$LEDGER_ENABLED \
BABYLON_BUILD_OPTIONS=$BABYLON_BUILD_OPTIONS \
COSMOS_BUILD_OPTIONS=$COSMOS_BUILD_OPTIONS \
BUILD_TAGS=$BUILD_TAGS \
LINK_STATICALLY=true \
make build

FROM alpine:3.14 AS run
# Create a user
RUN addgroup --gid 1137 -S babylon && adduser --uid 1137 -S babylon -G babylon
RUN apk add bash curl jq

# Label should match your github repo
ARG VERSION
LABEL org.opencontainers.image.source="https://github.com/babylonlabs-io/babylond:${VERSION}"

# Install Libraries
# COPY --from=build-env /usr/lib/libgcc_s.so.1 /lib/
# COPY --from=build-env /lib/ld-musl*.so.1* /lib

COPY --from=build-env /go/src/github.com/babylonlabs-io/babylon/build/babylond /bin/babylond

# Set home directory and user
WORKDIR /home/babylon
RUN chown -R babylon /home/babylon
USER babylon
66 changes: 66 additions & 0 deletions contrib/images/ibcsim-bcd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
FROM debian:bullseye-slim AS build-env

RUN apt-get update && apt-get install -y git make gcc wget

WORKDIR /work

ARG TARGETARCH

# Download and install Go
ENV GOLANG_VERSION 1.21.4
RUN wget -q https://golang.org/dl/go${GOLANG_VERSION}.linux-${TARGETARCH}.tar.gz && \
tar -C /usr/local -xzf go${GOLANG_VERSION}.linux-${TARGETARCH}.tar.gz && \
rm go${GOLANG_VERSION}.linux-${TARGETARCH}.tar.gz
# Set Go environment variables
ENV PATH /usr/local/go/bin:$PATH
ENV GOPATH /go
ENV PATH $GOPATH/bin:$PATH

ENV GO111MODULE on
ENV RELAYER_TAG v2.5.2

# Install the relayer
RUN git clone https://github.com/cosmos/relayer.git
RUN cd relayer && git fetch origin && git checkout ${RELAYER_TAG} && make install && cd -

# build bcd
COPY . /work/babylon-sdk
RUN cd babylon-sdk && \
make build && \
cd -

FROM debian:bullseye-slim AS run

RUN apt-get update && apt-get install -y bash curl jq wget

# Install libraries
# Cosmwasm - Download correct libwasmvm version
COPY --from=build-env /work/babylon-sdk/demo/go.mod /tmp
RUN WASMVM_VERSION=$(grep github.com/CosmWasm/wasmvm /tmp/go.mod | cut -d' ' -f2) && \
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm.$(uname -m).so \
-O /lib/libwasmvm.$(uname -m).so && \
# verify checksum
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
sha256sum /lib/libwasmvm.$(uname -m).so | grep $(cat /tmp/checksums.txt | grep libwasmvm.$(uname -m) | cut -d ' ' -f 1)
RUN rm -f /tmp/go.mod

# Copy binaries
COPY --from=build-env /go/bin/rly /usr/bin/rly
COPY --from=build-env /work/babylon-sdk/demo/build/bcd /usr/bin/bcd

WORKDIR /ibcsim-bcd
COPY contrib/images/ibcsim-bcd/wrapper.sh /ibcsim-bcd/wrapper.sh
COPY contrib/images/ibcsim-bcd/setup-bcd.sh /ibcsim-bcd/setup-bcd.sh
COPY --from=build-env /work/babylon-sdk/tests/testdata/babylon_contract.wasm /ibcsim-bcd/babylon_contract.wasm
COPY --from=build-env /work/babylon-sdk/tests/testdata/btc_staking.wasm /ibcsim-bcd/btc_staking.wasm
COPY --from=build-env /work/babylon-sdk/tests/testdata/btc_finality.wasm /ibcsim-bcd/btc_finality.wasm

ENV BABYLON_HOME=/data/node1/babylond
ENV BABYLON_NODE_RPC="http://babylondnode1:26657"
ENV RELAYER_CONF_DIR=/data/relayer
ENV CONSUMER_CONF=/data/bcd
ENV UPDATE_CLIENTS_INTERVAL=20s

ENTRYPOINT ["/ibcsim-bcd/wrapper.sh"]
CMD []
STOPSIGNAL SIGTERM
67 changes: 67 additions & 0 deletions contrib/images/ibcsim-bcd/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
services:
babylondnode0:
container_name: babylondnode0
image: "babylonlabs-io/babylond"
command: >
babylond --home /babylondhome start --log_level trace --trace --log_format 'plain' 2>&1 | tee /babylondhome/babylond.log
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined
ports:
- "26656-26657:26656-26657"
- "1317:1317"
- "9090:9090"
- "2345:2345"
volumes:
- .testnets/node0/babylond:/babylondhome:Z
networks:
localnet:
ipv4_address: 192.168.10.2

babylondnode1:
container_name: babylondnode1
image: "babylonlabs-io/babylond"
command: >
babylond --home /babylondhome start --log_level trace --trace --log_format 'plain' 2>&1 | tee /babylondhome/babylond.log
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined
ports:
- "26666-26667:26656-26657"
- "1318:1317"
- "9091:9090"
- "2346:2345"
volumes:
- .testnets/node1/babylond:/babylondhome:Z
networks:
localnet:
ipv4_address: 192.168.10.3

ibcsim-bcd:
container_name: ibcsim-bcd
image: babylonlabs-io/ibcsim-bcd
ports:
- "5183:5183"
- "26676-26677:26656-26657"
- "1319:1317"
- "9092:9090"
- "2347:2345"
volumes:
- .testnets:/data:Z
networks:
localnet:
ipv4_address: 192.168.10.17
depends_on:
- babylondnode0
- babylondnode1
restart: unless-stopped

networks:
localnet:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.10.0/25
22 changes: 22 additions & 0 deletions contrib/images/ibcsim-bcd/pre-deployment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# Create new directory that will hold node and services' configuration
mkdir -p ibcsim-bcd/.testnets && chmod -R 777 ibcsim-bcd/.testnets
echo "Creating and configuring testnet directory..."
docker run --rm -v $(pwd)/ibcsim-bcd/.testnets:/data babylonlabs-io/babylond \
babylond testnet init-files --v 2 -o /data \
--starting-ip-address 192.168.10.2 --keyring-backend=test \
--chain-id chain-test --epoch-interval 10 \
--btc-finalization-timeout 2 --btc-confirmation-depth 1 \
--minimum-gas-prices 0.000006ubbn \
--btc-base-header 0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff7f2002000000 \
--btc-network regtest --additional-sender-account \
--slashing-pk-script "76a914010101010101010101010101010101010101010188ab" \
--slashing-rate 0.1 \
--min-commission-rate 0.05 \
--covenant-quorum 1 \
--covenant-pks "bb50e2d89a4ed70663d080659fe0ad4b9bc3e06c17a227433966cb59ceee020d" # should be updated if `covenant-keyring` dir is changed`

# Create separate subpaths for each component and copy relevant configuration
chmod -R 777 ibcsim-bcd/.testnets
echo "Testnet directory created and configured successfully."
Loading
Loading