Skip to content

Commit

Permalink
feat: 08-wasm light client proxy module for wasm clients (#5079)
Browse files Browse the repository at this point in the history
Co-authored-by: Steve <steve@strange.love>
Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com>
Co-authored-by: antstalepresh <stalepresh121@outlook.com>
Co-authored-by: Vladislav Markushin <negigic@gmail.com>
Co-authored-by: Blas Rodriguez Irizar <rodrigblas@gmail.com>
Co-authored-by: Jacob Gadikian <jacobgadikian@gmail.com>
Co-authored-by: vuong <nguyenvuong1122000@gmail.com>
Co-authored-by: Vishal Potpelliwar <71565171+vishal-kanna@users.noreply.github.com>
Co-authored-by: Charly <charly@interchain.berlin>
Co-authored-by: Jim Fasarakis-Hilliard <d.f.hilliard@gmail.com>
Co-authored-by: Reece Williams <31943163+Reecepbcups@users.noreply.github.com>
Co-authored-by: Damian Nolan <damiannolan@gmail.com>
Co-authored-by: Cian Hatton <cian@interchain.io>
Co-authored-by: Adi <103246632+adiraviraj@users.noreply.github.com>
Co-authored-by: chatton <github.qpeyb@simplelogin.fr>
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
Co-authored-by: Charly <charly@interchain.io>
Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
Co-authored-by: Muku <44918265+muku314115@users.noreply.github.com>
Co-authored-by: Pham Anh Minh <1phamminh0811@gmail.com>
Co-authored-by: nguyen <trinity6569@gmail.com>
  • Loading branch information
22 people authored Nov 15, 2023
1 parent 013e42f commit 08d36eb
Show file tree
Hide file tree
Showing 158 changed files with 19,646 additions and 332 deletions.
12 changes: 9 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
/modules/light-clients/ @colin-axner @AdityaSripal @damiannolan
/proto/ibc/lightclients/ @colin-axner @AdityaSripal @damiannolan

# CODEOWNERS for 08-wasm light client module

/modules/light-clients/08-wasm/ @colin-axner @AdityaSripal @damiannolan @charleenfei @chatton @DimitrisJim @srdtrk

# CODEOWNERS for ICS 20

/modules/apps/transfer/ @colin-axner @AdityaSripal @damiannolan
Expand All @@ -38,9 +42,11 @@
/modules/apps/29-fee/ @AdityaSripal @charleenfei @colin-axner @damiannolan
/proto/ibc/applications/fee/ @AdityaSripal @charleenfei @colin-axner @damiannolan

# CODEOWNERS for docs
/docs/ @colin-axner @AdityaSripal @crodriguezvega @charleenfei @damiannolan @chatton @DimitrisJim @srdtrk

# CODEOWNERS for callbacks middleware

/modules/apps/callbacks/ @colin-axner @AdityaSripal @damiannolan @srdtrk

# CODEOWNERS for docs

/docs/ @colin-axner @AdityaSripal @crodriguezvega @charleenfei @damiannolan @chatton @DimitrisJim @srdtrk

12 changes: 11 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,14 @@ updates:
interval: daily
open-pull-requests-limit: 10
labels:
- dependencies
- dependencies

- package-ecosystem: gomod
directory: "/modules/light-clients/08-wasm"
schedule:
interval: daily
open-pull-requests-limit: 10
labels:
- dependencies


44 changes: 44 additions & 0 deletions .github/workflows/build-wasm-simd-image-from-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build Wasm Simd Image
on:
workflow_dispatch:
inputs:
tag:
description: 'The tag of the image to build'
required: true
type: string

env:
REGISTRY: ghcr.io
ORG: cosmos
IMAGE_NAME: ibc-go-wasm-simd
GIT_TAG: "${{ inputs.tag }}"

jobs:
build-image-at-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: "${{ env.GIT_TAG }}"
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: make python-install-deps
- name: Log in to the Container registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
run: |
# remove any `/` characters from the docker tag and replace them with a -
version="$(scripts/get-libwasm-version.py --get-version)"
checksum="$(scripts/get-libwasm-version.py --get-checksum)"
docker_tag="$(echo $GIT_TAG | sed 's/\//-/')"
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}"
52 changes: 52 additions & 0 deletions .github/workflows/e2e-test-workflow-call.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ibc-go-simd
IMAGE_NAME_WASM: ibc-go-wasm-simd

jobs:
# test-details exists to provide an easy way to see the inputs for the e2e test.
Expand Down Expand Up @@ -129,6 +130,56 @@ jobs:
build-args: |
IBC_GO_VERSION=${{ github.ref_name }}
docker-build-wasm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
if: ${{ inputs.build-and-push-docker-image }}

- uses: actions/setup-python@v4
if: ${{ inputs.build-and-push-docker-image }}
with:
python-version: '3.10'

- name: Install dependencies
if: ${{ inputs.build-and-push-docker-image }}
run: make python-install-deps

- name: Determine Build arguments
if: ${{ inputs.build-and-push-docker-image }}
id: build-args
run: |
echo "version=$(scripts/get-libwasm-version.py --get-version)" >> $GITHUB_OUTPUT
echo "checksum=$(scripts/get-libwasm-version.py --get-checksum)" >> $GITHUB_OUTPUT
- name: Log in to the Container registry
if: ${{ inputs.build-and-push-docker-image }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
if: ${{ inputs.build-and-push-docker-image }}
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934
with:
images: ${{ env.REGISTRY }}/cosmos/${{ env.IMAGE_NAME_WASM }}

- name: Build and push Docker image
if: ${{ inputs.build-and-push-docker-image }}
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
file: modules/light-clients/08-wasm/Dockerfile
build-args: |
LIBWASM_VERSION=${{ steps.build-args.outputs.version }}
LIBWASM_CHECKSUM=${{ steps.build-args.outputs.checksum }}
# dynamically build a matrix of test/test suite pairs to run.
# this job runs a go tool located at cmd/build_test_matrix/main.go.
# it walks the e2e/test directory in order to locate all test suite / test name
Expand Down Expand Up @@ -160,6 +211,7 @@ jobs:
needs:
- build-test-matrix
- docker-build
- docker-build-wasm
env:
CHAIN_IMAGE: '${{ inputs.chain-image }}'
CHAIN_A_TAG: '${{ inputs.chain-a-tag }}'
Expand Down
22 changes: 1 addition & 21 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,14 @@ jobs:
echo "Using tag $tag"
echo "simd-tag=$tag" >> $GITHUB_OUTPUT
fi
# build-e2e ensures that all test code compiles.
build-e2e:
if: ${{ !github.event.pull_request.draft && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Build e2e
run: |
cd e2e
find ./tests -type d | while IFS= read -r dir
do
if ls "${dir}"/*.go >/dev/null 2>&1; then
go test -c "$dir"
fi
done
# e2e generates the e2e tests for the non-forked PRs. It does so by using the
# e2e-test-workflow-call.yml each test runs the jobs defined in that file.
e2e:
# we will be running this job if the PR has not yet been marked for review, and we push additional changes.
# we skip the job in this case.
if: ${{ !github.event.pull_request.draft && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
needs:
- determine-image-tag # we are required to have a docker tag before we can build any images.
- build-e2e # don't attempt any tests unless the e2e code compiles successfully.
needs: determine-image-tag # we are required to have a docker tag before we can build any images.
uses: ./.github/workflows/e2e-test-workflow-call.yml
# unless we explicitly tell the workflow to inherit secrets, required secrets such as GITHUB_TOKEN will not be
# provided to the workflow. This would cause privileged operations to fail.
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-arch: ['amd64', 'arm', 'arm64']
go-arch: ['amd64', 'arm64']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
Expand All @@ -51,13 +51,19 @@ jobs:
go.sum
- name: Build ibc-go
run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build
- name: Install compiler for arm64.
if: matrix.go-arch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Build e2e
run: |
cd e2e
find ./tests -type d | while IFS= read -r dir
do
if ls "${dir}"/*.go >/dev/null 2>&1; then
GOARCH=${{ matrix.go-arch }} go test -c "$dir"
CGO_ENABLED=1 GOARCH=${{ matrix.go-arch }} go test -c "$dir"
fi
done
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/wasm-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Wasm Light-Client
# This workflow runs when a PR is opened that targets code that is part of the wasm light-client.
on:
pull_request:
paths:
- '.github/workflows/wasm-client.yml'
- 'modules/light-clients/08-wasm/**'
- 'proto/ibc/lightclients/wasm/**'
permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- uses: actions/checkout@v3
- uses: golangci/golangci-lint-action@v3.6.0
with:
version: v1.54.2
args: --timeout 10m
working-directory: modules/light-clients/08-wasm

build:
runs-on: ubuntu-latest
strategy:
matrix:
go-arch: ['amd64', 'arm64']
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
# Install cross compiler for ARM64. Export CC env variable.
- name: Install compiler for arm64.
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
if: matrix.go-arch == 'arm64'
- name: Build wasm-client
run: |
cd modules/light-clients/08-wasm
GOARCH=${{ matrix.go-arch }} CGO_ENABLED=1 go build ./...
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Go Test
run: |
cd modules/light-clients/08-wasm
go test -v -mod=readonly ./...
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ artifacts
baseapp/data/*
client/lcd/keys/*
mytestnet
modules/light-clients/08-wasm/**/ibc_08-wasm_client_data/

# Testing
coverage.txt
Expand Down Expand Up @@ -58,9 +59,14 @@ dependency-graph.png

*.history

tmp/
*.wasm
# Go
go.work
go.work.sum

# E2E WASM contract
!ics10_grandpa_cw.wasm

# Python
venv
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ COPY go.sum .

RUN go mod download

RUN BUILD_TAGS=muslc make build
RUN make build

FROM alpine:3.18
ARG IBC_GO_VERSION
Expand All @@ -33,4 +33,3 @@ LABEL "org.cosmos.ibc-go" "${IBC_GO_VERSION}"
COPY --from=builder /go/build/simd /bin/simd

ENTRYPOINT ["simd"]

6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
# check for nostrip option
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
Expand Down Expand Up @@ -137,6 +136,11 @@ go.sum: go.mod
go mod verify
go mod tidy

python-install-deps:
@echo "Installing python dependencies..."
@pip3 install --upgrade pip
@pip3 install -r requirements.txt

###############################################################################
### Documentation ###
###############################################################################
Expand Down
Loading

0 comments on commit 08d36eb

Please sign in to comment.