Skip to content

Commit 08d36eb

Browse files
crodriguezvegaStevejackzampolinantstalepreshvmarkushin
authored
feat: 08-wasm light client proxy module for wasm clients (cosmos#5079)
Co-authored-by: Steve <[email protected]> Co-authored-by: Jack Zampolin <[email protected]> Co-authored-by: antstalepresh <[email protected]> Co-authored-by: Vladislav Markushin <[email protected]> Co-authored-by: Blas Rodriguez Irizar <[email protected]> Co-authored-by: Jacob Gadikian <[email protected]> Co-authored-by: vuong <[email protected]> Co-authored-by: Vishal Potpelliwar <[email protected]> Co-authored-by: Charly <[email protected]> Co-authored-by: Jim Fasarakis-Hilliard <[email protected]> Co-authored-by: Reece Williams <[email protected]> Co-authored-by: Damian Nolan <[email protected]> Co-authored-by: Cian Hatton <[email protected]> Co-authored-by: Adi <[email protected]> Co-authored-by: chatton <[email protected]> Co-authored-by: colin axnér <[email protected]> Co-authored-by: Charly <[email protected]> Co-authored-by: srdtrk <[email protected]> Co-authored-by: Muku <[email protected]> Co-authored-by: Pham Anh Minh <[email protected]> Co-authored-by: nguyen <[email protected]>
1 parent 013e42f commit 08d36eb

File tree

158 files changed

+19646
-332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+19646
-332
lines changed

.github/CODEOWNERS

+9-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
/modules/light-clients/ @colin-axner @AdityaSripal @damiannolan
2424
/proto/ibc/lightclients/ @colin-axner @AdityaSripal @damiannolan
2525

26+
# CODEOWNERS for 08-wasm light client module
27+
28+
/modules/light-clients/08-wasm/ @colin-axner @AdityaSripal @damiannolan @charleenfei @chatton @DimitrisJim @srdtrk
29+
2630
# CODEOWNERS for ICS 20
2731

2832
/modules/apps/transfer/ @colin-axner @AdityaSripal @damiannolan
@@ -38,9 +42,11 @@
3842
/modules/apps/29-fee/ @AdityaSripal @charleenfei @colin-axner @damiannolan
3943
/proto/ibc/applications/fee/ @AdityaSripal @charleenfei @colin-axner @damiannolan
4044

41-
# CODEOWNERS for docs
42-
/docs/ @colin-axner @AdityaSripal @crodriguezvega @charleenfei @damiannolan @chatton @DimitrisJim @srdtrk
43-
4445
# CODEOWNERS for callbacks middleware
4546

4647
/modules/apps/callbacks/ @colin-axner @AdityaSripal @damiannolan @srdtrk
48+
49+
# CODEOWNERS for docs
50+
51+
/docs/ @colin-axner @AdityaSripal @crodriguezvega @charleenfei @damiannolan @chatton @DimitrisJim @srdtrk
52+

.github/dependabot.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,14 @@ updates:
2828
interval: daily
2929
open-pull-requests-limit: 10
3030
labels:
31-
- dependencies
31+
- dependencies
32+
33+
- package-ecosystem: gomod
34+
directory: "/modules/light-clients/08-wasm"
35+
schedule:
36+
interval: daily
37+
open-pull-requests-limit: 10
38+
labels:
39+
- dependencies
40+
41+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build Wasm Simd Image
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
tag:
6+
description: 'The tag of the image to build'
7+
required: true
8+
type: string
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
ORG: cosmos
13+
IMAGE_NAME: ibc-go-wasm-simd
14+
GIT_TAG: "${{ inputs.tag }}"
15+
16+
jobs:
17+
build-image-at-tag:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
ref: "${{ env.GIT_TAG }}"
23+
fetch-depth: 0
24+
- uses: actions/setup-python@v4
25+
with:
26+
python-version: '3.10'
27+
- name: Install dependencies
28+
run: make python-install-deps
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
- name: Build image
36+
run: |
37+
# remove any `/` characters from the docker tag and replace them with a -
38+
39+
version="$(scripts/get-libwasm-version.py --get-version)"
40+
checksum="$(scripts/get-libwasm-version.py --get-checksum)"
41+
42+
docker_tag="$(echo $GIT_TAG | sed 's/\//-/')"
43+
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}
44+
docker push "${REGISTRY}/${ORG}/${IMAGE_NAME}:${docker_tag}"

.github/workflows/e2e-test-workflow-call.yml

+52
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ on:
7676
env:
7777
REGISTRY: ghcr.io
7878
IMAGE_NAME: ibc-go-simd
79+
IMAGE_NAME_WASM: ibc-go-wasm-simd
7980

8081
jobs:
8182
# test-details exists to provide an easy way to see the inputs for the e2e test.
@@ -129,6 +130,56 @@ jobs:
129130
build-args: |
130131
IBC_GO_VERSION=${{ github.ref_name }}
131132
133+
docker-build-wasm:
134+
runs-on: ubuntu-latest
135+
steps:
136+
- uses: actions/checkout@v4
137+
if: ${{ inputs.build-and-push-docker-image }}
138+
139+
- uses: actions/setup-python@v4
140+
if: ${{ inputs.build-and-push-docker-image }}
141+
with:
142+
python-version: '3.10'
143+
144+
- name: Install dependencies
145+
if: ${{ inputs.build-and-push-docker-image }}
146+
run: make python-install-deps
147+
148+
- name: Determine Build arguments
149+
if: ${{ inputs.build-and-push-docker-image }}
150+
id: build-args
151+
run: |
152+
echo "version=$(scripts/get-libwasm-version.py --get-version)" >> $GITHUB_OUTPUT
153+
echo "checksum=$(scripts/get-libwasm-version.py --get-checksum)" >> $GITHUB_OUTPUT
154+
155+
- name: Log in to the Container registry
156+
if: ${{ inputs.build-and-push-docker-image }}
157+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
158+
with:
159+
registry: ${{ env.REGISTRY }}
160+
username: ${{ github.actor }}
161+
password: ${{ secrets.GITHUB_TOKEN }}
162+
163+
- name: Extract metadata (tags, labels) for Docker
164+
if: ${{ inputs.build-and-push-docker-image }}
165+
id: meta
166+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934
167+
with:
168+
images: ${{ env.REGISTRY }}/cosmos/${{ env.IMAGE_NAME_WASM }}
169+
170+
- name: Build and push Docker image
171+
if: ${{ inputs.build-and-push-docker-image }}
172+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09
173+
with:
174+
context: .
175+
push: true
176+
tags: ${{ steps.meta.outputs.tags }}
177+
file: modules/light-clients/08-wasm/Dockerfile
178+
build-args: |
179+
LIBWASM_VERSION=${{ steps.build-args.outputs.version }}
180+
LIBWASM_CHECKSUM=${{ steps.build-args.outputs.checksum }}
181+
182+
132183
# dynamically build a matrix of test/test suite pairs to run.
133184
# this job runs a go tool located at cmd/build_test_matrix/main.go.
134185
# it walks the e2e/test directory in order to locate all test suite / test name
@@ -160,6 +211,7 @@ jobs:
160211
needs:
161212
- build-test-matrix
162213
- docker-build
214+
- docker-build-wasm
163215
env:
164216
CHAIN_IMAGE: '${{ inputs.chain-image }}'
165217
CHAIN_A_TAG: '${{ inputs.chain-a-tag }}'

.github/workflows/e2e.yaml

+1-21
Original file line numberDiff line numberDiff line change
@@ -40,34 +40,14 @@ jobs:
4040
echo "Using tag $tag"
4141
echo "simd-tag=$tag" >> $GITHUB_OUTPUT
4242
fi
43-
# build-e2e ensures that all test code compiles.
44-
build-e2e:
45-
if: ${{ !github.event.pull_request.draft && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
46-
runs-on: ubuntu-latest
47-
steps:
48-
- uses: actions/checkout@v4
49-
- uses: actions/setup-go@v4
50-
with:
51-
go-version: '1.21'
52-
- name: Build e2e
53-
run: |
54-
cd e2e
55-
find ./tests -type d | while IFS= read -r dir
56-
do
57-
if ls "${dir}"/*.go >/dev/null 2>&1; then
58-
go test -c "$dir"
59-
fi
60-
done
6143
6244
# e2e generates the e2e tests for the non-forked PRs. It does so by using the
6345
# e2e-test-workflow-call.yml each test runs the jobs defined in that file.
6446
e2e:
6547
# we will be running this job if the PR has not yet been marked for review, and we push additional changes.
6648
# we skip the job in this case.
6749
if: ${{ !github.event.pull_request.draft && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
68-
needs:
69-
- determine-image-tag # we are required to have a docker tag before we can build any images.
70-
- build-e2e # don't attempt any tests unless the e2e code compiles successfully.
50+
needs: determine-image-tag # we are required to have a docker tag before we can build any images.
7151
uses: ./.github/workflows/e2e-test-workflow-call.yml
7252
# unless we explicitly tell the workflow to inherit secrets, required secrets such as GITHUB_TOKEN will not be
7353
# provided to the workflow. This would cause privileged operations to fail.

.github/workflows/test.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
runs-on: ubuntu-latest
3737
strategy:
3838
matrix:
39-
go-arch: ['amd64', 'arm', 'arm64']
39+
go-arch: ['amd64', 'arm64']
4040
steps:
4141
- uses: actions/checkout@v4
4242
- uses: actions/setup-go@v4
@@ -51,13 +51,19 @@ jobs:
5151
go.sum
5252
- name: Build ibc-go
5353
run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build
54+
- name: Install compiler for arm64.
55+
if: matrix.go-arch == 'arm64'
56+
run: |
57+
sudo apt-get update
58+
sudo apt-get install -y gcc-aarch64-linux-gnu
59+
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
5460
- name: Build e2e
5561
run: |
5662
cd e2e
5763
find ./tests -type d | while IFS= read -r dir
5864
do
5965
if ls "${dir}"/*.go >/dev/null 2>&1; then
60-
GOARCH=${{ matrix.go-arch }} go test -c "$dir"
66+
CGO_ENABLED=1 GOARCH=${{ matrix.go-arch }} go test -c "$dir"
6167
fi
6268
done
6369

.github/workflows/wasm-client.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Wasm Light-Client
2+
# This workflow runs when a PR is opened that targets code that is part of the wasm light-client.
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/wasm-client.yml'
7+
- 'modules/light-clients/08-wasm/**'
8+
- 'proto/ibc/lightclients/wasm/**'
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/setup-go@v4
17+
with:
18+
go-version: '1.21'
19+
- uses: actions/checkout@v3
20+
- uses: golangci/[email protected]
21+
with:
22+
version: v1.54.2
23+
args: --timeout 10m
24+
working-directory: modules/light-clients/08-wasm
25+
26+
build:
27+
runs-on: ubuntu-latest
28+
strategy:
29+
matrix:
30+
go-arch: ['amd64', 'arm64']
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: actions/setup-go@v4
34+
with:
35+
go-version: '1.21'
36+
# Install cross compiler for ARM64. Export CC env variable.
37+
- name: Install compiler for arm64.
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y gcc-aarch64-linux-gnu
41+
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
42+
if: matrix.go-arch == 'arm64'
43+
- name: Build wasm-client
44+
run: |
45+
cd modules/light-clients/08-wasm
46+
GOARCH=${{ matrix.go-arch }} CGO_ENABLED=1 go build ./...
47+
48+
tests:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v3
52+
- uses: actions/setup-go@v4
53+
with:
54+
go-version: '1.21'
55+
- name: Go Test
56+
run: |
57+
cd modules/light-clients/08-wasm
58+
go test -v -mod=readonly ./...

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ artifacts
2727
baseapp/data/*
2828
client/lcd/keys/*
2929
mytestnet
30+
modules/light-clients/08-wasm/**/ibc_08-wasm_client_data/
3031

3132
# Testing
3233
coverage.txt
@@ -58,9 +59,14 @@ dependency-graph.png
5859

5960
*.history
6061

62+
tmp/
63+
*.wasm
6164
# Go
6265
go.work
6366
go.work.sum
6467

68+
# E2E WASM contract
69+
!ics10_grandpa_cw.wasm
70+
6571
# Python
6672
venv

Dockerfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ COPY go.sum .
2323

2424
RUN go mod download
2525

26-
RUN BUILD_TAGS=muslc make build
26+
RUN make build
2727

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

3535
ENTRYPOINT ["simd"]
36-

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
8686
endif
8787
ldflags += $(LDFLAGS)
8888
ldflags := $(strip $(ldflags))
89-
9089
BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
9190
# check for nostrip option
9291
ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
@@ -137,6 +136,11 @@ go.sum: go.mod
137136
go mod verify
138137
go mod tidy
139138

139+
python-install-deps:
140+
@echo "Installing python dependencies..."
141+
@pip3 install --upgrade pip
142+
@pip3 install -r requirements.txt
143+
140144
###############################################################################
141145
### Documentation ###
142146
###############################################################################

0 commit comments

Comments
 (0)