Skip to content

Commit

Permalink
Merge branch 'feat/ibc-eureka' into cian/issue#7510-ibcmodulev2-trans…
Browse files Browse the repository at this point in the history
…fer-application-spike
  • Loading branch information
gjermundgaraba committed Nov 15, 2024
2 parents d7c9437 + 2acc7f6 commit 8a4fb46
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 35 deletions.
32 changes: 22 additions & 10 deletions .github/workflows/build-wasm-simd-image-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,36 @@ jobs:
with:
ref: "${{ env.GIT_TAG }}"
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: make python-install-deps

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
run: |
version="$(scripts/get-libwasm-version.py --get-version)"
checksum="$(scripts/get-libwasm-version.py --get-checksum)"
# remove all `/` or `+` characters from the docker tag and replace them with a -.
# this ensures the docker tag is valid.
docker_tag="$(echo $GIT_TAG | sed 's/[^a-zA-Z0-9\.]/-/g')"
docker build . -t "${REGISTRY}/${ORG}/${IMAGE_NAME}:${docker_tag}" -f modules/light-clients/08-wasm/Dockerfile --build-arg LIBWASM_VERSION=${version} --build-arg LIBWASM_CHECKSUM=${checksum}
docker push "${REGISTRY}/${ORG}/${IMAGE_NAME}:${docker_tag}"

- name: Get arguments and docker tag
run: |
echo "LIBWASM_VERSION=$(scripts/get-libwasm-version.py --get-version)" >> $GITHUB_ENV
# remove all `/` or `+` characters from the docker tag and replace them with a -.
# this ensures the docker tag is valid.
echo "DOCKER_TAG=$(echo $GIT_TAG | sed 's/[^a-zA-Z0-9\.]/-/g')" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64,
push: true
tags: ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}
file: modules/light-clients/08-wasm/Dockerfile
build-args: LIBWASM_VERSION=${{ env.LIBWASM_VERSION }}
2 changes: 1 addition & 1 deletion .github/workflows/wasm-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Install compiler for arm64.
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu build-essential
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
if: matrix.go-arch == 'arm64'
- name: Build wasm-client
Expand Down
40 changes: 25 additions & 15 deletions modules/light-clients/08-wasm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
FROM golang:1.22-alpine3.20 as builder

FROM golang:1.22-alpine3.20 AS builder-base
ARG LIBWASM_VERSION
ARG LIBWASM_CHECKSUM
ARG TARGETARCH

RUN test -n "${LIBWASM_VERSION}"
RUN test -n "${LIBWASM_CHECKSUM}"

RUN set -eux; apk add --no-cache git libusb-dev linux-headers gcc musl-dev make;

ENV GOPATH=""

# Grab the static library and copy it to location that will be found by the linker flag `-lwasmvm_muslc`.
ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep ${LIBWASM_CHECKSUM}
RUN cp /lib/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.a
RUN set -eux; apk add --no-cache ca-certificates build-base git libusb-dev linux-headers curl;

# Copy relevant files before go mod download. Replace directives to local paths break if local
# files are not copied before go mod download.
Expand All @@ -25,14 +17,32 @@ ADD LICENSE LICENSE
COPY go.mod .
COPY go.sum .

RUN go mod download


# Since it is not easy to fully cache a RUN script download of libwasmvm, we use two different stages
# and copy the correct file in the final stage. The multistage setup also helps speed up the build process
FROM alpine:3.18 AS amd64-stage
ARG LIBWASM_VERSION
ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a


FROM alpine:3.18 AS arm64-stage
ARG LIBWASM_VERSION
ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASM_VERSION}/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a

# We have this one with nothing else in it, because COPY --from can't use variables (but FROM can)
FROM ${TARGETARCH}-stage AS libwasm-stage

# Having this is a separate stage allows the previous stages to run in parallel
FROM builder-base AS builder
WORKDIR /go/modules/light-clients/08-wasm

RUN go mod download
COPY --from=libwasm-stage /lib/libwasmvm_muslc.* /lib/

RUN GOOS=linux GOARCH=amd64 go build -mod=readonly -tags "netgo ledger muslc" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version= -X github.com/cosmos/cosmos-sdk/version.Commit= -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo ledger muslc," -w -s -linkmode=external -extldflags "-Wl,-z,muldefs -static"' -trimpath -o /go/build/ ./...
RUN go build -mod=readonly -tags "netgo ledger muslc" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version= -X github.com/cosmos/cosmos-sdk/version.Commit= -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo ledger muslc," -w -s -linkmode=external -extldflags "-Wl,-z,muldefs -static"' -trimpath -o /go/build/ ./...

FROM alpine:3.18

FROM alpine:3.18
COPY --from=builder /go/build/simd /bin/simd

ENTRYPOINT ["simd"]
14 changes: 12 additions & 2 deletions modules/light-clients/08-wasm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ require (
github.com/cosmos/ibc-go/v9 v9.0.0
github.com/golang/protobuf v1.5.4
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/prysmaticlabs/prysm/v4 v4.2.1 // used by simapp for custom querier
github.com/spf13/cast v1.7.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
Expand Down Expand Up @@ -74,7 +75,6 @@ require (
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.2.0 // indirect
github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect
github.com/cosmos/ics23/go v0.11.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/creachadair/atomicfile v0.3.1 // indirect
Expand All @@ -88,6 +88,7 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.7.0 // indirect
github.com/emicklei/dot v1.6.2 // indirect
github.com/ethereum/go-ethereum v1.13.5-0.20231027145059-2d7dba024d76 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand All @@ -103,7 +104,7 @@ require (
github.com/golang/glog v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/flatbuffers v24.3.25+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
Expand All @@ -130,13 +131,15 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
github.com/herumi/bls-eth-go-binary v0.0.0-20210917013441-d37c07cfda4e // indirect
github.com/huandu/skiplist v1.2.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.9 // indirect
Expand All @@ -146,9 +149,11 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/minio/highwayhash v1.0.3 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
Expand All @@ -161,6 +166,8 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/prysmaticlabs/fastssz v0.0.0-20221107182844-78142813af44 // indirect
github.com/prysmaticlabs/gohashtree v0.0.3-alpha // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.11.1 // indirect
Expand All @@ -169,12 +176,15 @@ require (
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sasha-s/go-deadlock v0.3.5 // indirect
github.com/shamaton/msgpack/v2 v2.2.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect
github.com/tidwall/btree v1.7.0 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/zondax/hid v0.9.2 // indirect
Expand Down
Loading

0 comments on commit 8a4fb46

Please sign in to comment.