Skip to content

Commit

Permalink
Merge branches 'main' and 'main' of github.com:initia-labs/miniwasm
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Jul 29, 2024
2 parents b55a795 + 10baa2c commit ab1dff1
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 7 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/build-and-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build and Upload to releases

on:
push:
tags:
- 'v*'

jobs:
build-linux-amd64:
uses: ./.github/workflows/build-linux-amd64.yml

build-linux-arm64:
uses: ./.github/workflows/build-linux-arm64.yml

build-darwin-amd64:
uses: ./.github/workflows/build-darwin-amd64.yml

build-darwin-arm64:
uses: ./.github/workflows/build-darwin-arm64.yml
68 changes: 68 additions & 0 deletions .github/workflows/build-darwin-amd64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build Darwin AMD64

on:
workflow_call:

jobs:
build:
runs-on: macos-13
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.4'

- name: Set environment variables
run: |
MINIWASM_NETWORK_NAME="miniwasm-1"
echo "MINIWASM_NETWORK_NAME=${MINIWASM_NETWORK_NAME}" >> $GITHUB_ENV
echo "GOARCH=amd64" >> $GITHUB_ENV
echo "GOOS=darwin" >> $GITHUB_ENV
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION="v0.0.0-${GITHUB_SHA::8}"
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "ARCH_NAME=x86_64" >> $GITHUB_ENV
WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | awk '{print $2}')
echo "WASMVM_VERSION=${WASMVM_VERSION}" >> $GITHUB_ENV
- name: Ensure dependencies
run: |
go mod tidy
go get github.com/CosmWasm/wasmvm/v2@${WASMVM_VERSION}
- name: Print environment variables
run: |
echo "GOARCH=${GOARCH}"
echo "GOOS=${GOOS}"
echo "VERSION=${VERSION}"
echo "ARCH_NAME=${ARCH_NAME}"
echo "WASMVM_VERSION=${WASMVM_VERSION}"
echo "MINIWASM_NETWORK_NAME=${MINIWASM_NETWORK_NAME}"
- name: Build and Package for Darwin ADM642
run: |
cd ../miniwasm \
&& make build \
&& cd ./build \
&& ls ~/go/pkg/mod/github.com/ \
&& ls ~/go/pkg/mod/github.com/\!cosm\!wasm/ \
&& cp ~/go/pkg/mod/github.com/\!cosm\!wasm/wasmvm/v2@${WASMVM_VERSION}/internal/api/libwasmvm.dylib ./ \
&& tar -czvf miniwasm_"$VERSION"_Darwin_"$ARCH_NAME".tar.gz ./minitiad libwasmvm.dylib \
&& mv ./miniwasm_"$VERSION"_Darwin_"$ARCH_NAME".tar.gz $GITHUB_WORKSPACE/ \
&& rm -rf ./libwasmvm.dylib ./minitiad
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
miniwasm_${{ env.VERSION }}_Darwin_${{ env.ARCH_NAME }}.tar.gz
64 changes: 64 additions & 0 deletions .github/workflows/build-darwin-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

name: Build Darwin ARM64

on:
workflow_call:

jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.4'
- name: Set environment variables
run: |
MINIWASM_NETWORK_NAME="miniwasm-1"
echo "MINIWASM_NETWORK_NAME=${MINIWASM_NETWORK_NAME}" >> $GITHUB_ENV
WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | awk '{print $2}')
echo "WASMVM_VERSION=${WASMVM_VERSION}" >> $GITHUB_ENV
echo "GOARCH=arm64" >> $GITHUB_ENV
echo "GOOS=darwin" >> $GITHUB_ENV
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION="v0.0.0-${GITHUB_SHA::8}"
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "ARCH_NAME=aarch64" >> $GITHUB_ENV
- name: Ensure dependencies
run: |
go mod tidy
go get github.com/CosmWasm/wasmvm/v2@${WASMVM_VERSION}
- name: Print environment variables
run: |
echo "GOARCH=${GOARCH}"
echo "GOOS=${GOOS}"
echo "VERSION=${VERSION}"
echo "ARCH_NAME=${ARCH_NAME}"
echo "MINIWASM_NETWORK_NAME=${MINIWASM_NETWORK_NAME}"
- name: Build and Package for Darwin ARM64
run: |
cd ../miniwasm \
&& make build \
&& cd ./build \
&& ls ~/go/pkg/mod/github.com/ \
&& ls ~/go/pkg/mod/github.com/\!cosm\!wasm/ \
&& cp ~/go/pkg/mod/github.com/\!cosm\!wasm/wasmvm/v2@${WASMVM_VERSION}/internal/api/libwasmvm.dylib ./ \
&& tar -czvf miniwasm_"$VERSION"_Darwin_"$ARCH_NAME".tar.gz ./minitiad libwasmvm.dylib \
&& mv ./miniwasm_"$VERSION"_Darwin_"$ARCH_NAME".tar.gz $GITHUB_WORKSPACE/ \
&& rm -rf ./libwasmvm.dylib ./minitiad
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
miniwasm_${{ env.VERSION }}_Darwin_${{ env.ARCH_NAME }}.tar.gz
52 changes: 52 additions & 0 deletions .github/workflows/build-linux-amd64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

name: Build Linux AMD64

on:
workflow_call

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

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.4'

- name: Set environment variables
run: |
echo "GOARCH=amd64" >> $GITHUB_ENV
echo "GOOS=linux" >> $GITHUB_ENV
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION="v0.0.0-${GITHUB_SHA::8}"
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "ARCH_NAME=x86_64" >> $GITHUB_ENV
- name: Print environment variables
run: |
echo "GOARCH=${GOARCH}"
echo "GOOS=${GOOS}"
echo "VERSION=${VERSION}"
- name: Build for Linux AMD64
run: |
export GOARCH=${GOARCH}
export GOOS=${GOOS}
make build-linux-with-shared-library
cd ./build
mkdir -p miniwasm_${VERSION}
mv libwasmvm.so miniwasm_${VERSION}/libwasmvm.${ARCH_NAME}.so
mv minitiad miniwasm_${VERSION}/
tar -czvf miniwasm_${VERSION}_Linux_${ARCH_NAME}.tar.gz miniwasm_${VERSION}
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
./build/miniwasm_${{ env.VERSION }}_Linux_${{ env.ARCH_NAME }}.tar.gz
77 changes: 77 additions & 0 deletions .github/workflows/build-linux-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

name: Build Linux ARM64

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set environment variables
run: |
echo "GOARCH=arm64" >> $GITHUB_ENV
echo "GOOS=linux" >> $GITHUB_ENV
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION="v0.0.0-${GITHUB_SHA::8}"
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "ARCH_NAME=aarch64" >> $GITHUB_ENV
- name: Build for ARM64
env:
DOCKER_BUILDKIT: 1
run: |
# Activate BuildKit and create a new builder
docker buildx create --use --name arm64-builder --platform linux/arm64
docker buildx inspect --bootstrap
# Building images for ARM64
docker buildx build --platform linux/arm64 --load --tag minitia/minitiad-shared:arm64 . -f Dockerfile.arm64
# Extract build output using ARM64 images
mkdir -p ./build
docker create --name temp minitia/minitiad-shared:arm64
docker cp temp:/usr/local/bin/minitiad ./build/
docker cp temp:/lib/libwasmvm.so ./build/
docker rm temp
# Packaging of results
cd ./build
mkdir -p miniwasm_${VERSION}
mv minitiad miniwasm_${VERSION}/
mv libwasmvm.so miniwasm_${VERSION}/libwasmvm.${ARCH_NAME}.so
tar -czvf miniwasm_${VERSION}_Linux_${ARCH_NAME}.tar.gz miniwasm_${VERSION}
mv miniwasm_${VERSION}_Linux_${ARCH_NAME}.tar.gz ../
# Check build results
cd ..
ls -l
file miniwasm_${VERSION}_Linux_${ARCH_NAME}.tar.gz
# remove builder
docker buildx rm arm64-builder
- name: List files
run: ls -l

- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
./miniwasm_${{ env.VERSION }}_Linux_${{ env.ARCH_NAME }}.tar.gz
35 changes: 35 additions & 0 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM arm64v8/golang:1.22-bullseye AS go-builder

# Install minimum necessary dependencies, build Cosmos SDK, remove packages
RUN apt update
RUN apt install -y curl git build-essential
# debug: for live editting in the image
RUN apt install -y vim

WORKDIR /code
COPY . /code/

RUN LEDGER_ENABLED=false make build

RUN cp /go/pkg/mod/github.com/\!cosm\!wasm/wasmvm/v2@v*/internal/api/libwasmvm.`uname -m`.so /lib/libwasmvm.so

FROM arm64v8/ubuntu:20.04

WORKDIR /root

COPY --from=go-builder /code/build/minitiad /usr/local/bin/minitiad
COPY --from=go-builder /lib/libwasmvm.so /lib/libwasmvm.so

# for new-metric setup
COPY --from=go-builder /code/contrib /root/contrib

# rest server
EXPOSE 1317
# grpc
EXPOSE 9090
# tendermint p2p
EXPOSE 26656
# tendermint rpc
EXPOSE 26657

CMD ["/usr/local/bin/minitiad", "version"]
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ require (
github.com/hashicorp/go-metrics v0.5.3
github.com/initia-labs/OPinit v0.3.2
github.com/initia-labs/initia v0.3.5
github.com/initia-labs/kvindexer v0.1.5
github.com/initia-labs/kvindexer v0.1.6
github.com/initia-labs/kvindexer/submodules/block v0.1.0
github.com/initia-labs/kvindexer/submodules/tx v0.1.0
github.com/initia-labs/kvindexer/submodules/wasm-nft v0.1.3
github.com/initia-labs/kvindexer/submodules/wasm-nft v0.1.4
github.com/initia-labs/kvindexer/submodules/wasm-pair v0.1.0
github.com/noble-assets/forwarding/v2 v2.0.0-20240514101621-172acc02aac6
github.com/pkg/errors v0.9.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -808,14 +808,14 @@ github.com/initia-labs/ibc-go/v8 v8.0.0-20240419124350-4275a05abe2c h1:FDwh5zZbm
github.com/initia-labs/ibc-go/v8 v8.0.0-20240419124350-4275a05abe2c/go.mod h1:wj3qx75iC/XNnsMqbPDCIGs0G6Y3E/lo3bdqCyoCy+8=
github.com/initia-labs/initia v0.3.5 h1:JsO0OZ+ZRQjzFusXSA2f7U1LNO6nApaCr+U6idJ+Pko=
github.com/initia-labs/initia v0.3.5/go.mod h1:nwtnVe3obacErGb7w6tq8Ych3U0d2f59rsgpVUeMnmM=
github.com/initia-labs/kvindexer v0.1.5 h1:YLR4d237dNkGR8pe2zRGxx3CFB2CU6hhUmeJsshUw/0=
github.com/initia-labs/kvindexer v0.1.5/go.mod h1:OV85HaQ9KVrg+zGPUlxT9RF9nAaM3Yq4/3MoHqGqhWk=
github.com/initia-labs/kvindexer v0.1.6 h1:RAnd89v/ZNtmsmBiD5ubBe1455UvIbH3dMxvPUYc5A8=
github.com/initia-labs/kvindexer v0.1.6/go.mod h1:OV85HaQ9KVrg+zGPUlxT9RF9nAaM3Yq4/3MoHqGqhWk=
github.com/initia-labs/kvindexer/submodules/block v0.1.0 h1:y+EXnksd/I2F96mzIoQA64nZUZON2P+99YrSzeLCLoY=
github.com/initia-labs/kvindexer/submodules/block v0.1.0/go.mod h1:4c+c59wVAnjuaJv/pcDYaUkeVmOqVV+orqEjya/RIjo=
github.com/initia-labs/kvindexer/submodules/tx v0.1.0 h1:6kbf6wmzXPN0XCQLasiFgq1AlZHkt5K3/ZG+IWw1nNs=
github.com/initia-labs/kvindexer/submodules/tx v0.1.0/go.mod h1:i0XeLbLa6xdgTR01WF8kaAO50vMmwxbeq0fKexwpFHU=
github.com/initia-labs/kvindexer/submodules/wasm-nft v0.1.3 h1:diSQs+zWNj0U5tdDS6KvXs388NM6zrdJmupztT+ULKQ=
github.com/initia-labs/kvindexer/submodules/wasm-nft v0.1.3/go.mod h1:1HD0/oH6kErv8F0J5ayGfLqerWSCPveGHSCbcfiBELw=
github.com/initia-labs/kvindexer/submodules/wasm-nft v0.1.4 h1:PCGaVt3oX6V4KLHkmBCo9m1brOkgZvaDVcM5ls0kS4w=
github.com/initia-labs/kvindexer/submodules/wasm-nft v0.1.4/go.mod h1:1HD0/oH6kErv8F0J5ayGfLqerWSCPveGHSCbcfiBELw=
github.com/initia-labs/kvindexer/submodules/wasm-pair v0.1.0 h1:Ns7bxZkwdby67aIq3VXFAzlpoLdGONJbDaMiqu6k408=
github.com/initia-labs/kvindexer/submodules/wasm-pair v0.1.0/go.mod h1:SEotHE6mJ3VKr9g4j0AoXHgEYz6qhL3i1bX1QRnVT6g=
github.com/initia-labs/movevm v0.3.4 h1:kzqs6uzTq0f5peZJNzLq/1qgnmAFfC+I9eCyPBducxM=
Expand Down
2 changes: 1 addition & 1 deletion shared.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY . /code/

RUN LEDGER_ENABLED=false make build

RUN cp /go/pkg/mod/github.com/\!cosm\!wasm/wasmvm@v*/internal/api/libwasmvm.`uname -m`.so /lib/libwasmvm.so
RUN cp /go/pkg/mod/github.com/\!cosm\!wasm/wasmvm/v2@v*/internal/api/libwasmvm.`uname -m`.so /lib/libwasmvm.so

FROM ubuntu:20.04

Expand Down

0 comments on commit ab1dff1

Please sign in to comment.