Skip to content

Commit

Permalink
Merge pull request #138 from da1suk8/feat/bump_1.5.0
Browse files Browse the repository at this point in the history
feat: bump up wasmvm from v1.1.1 to v1.5.0
  • Loading branch information
da1suk8 authored Feb 5, 2024
2 parents 364b8c7 + 5f25791 commit 3b51958
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 50 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/builds_and_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.67.0
toolchain: 1.70.0
target: wasm32-unknown-unknown
profile: minimal
override: true
Expand All @@ -19,7 +19,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cargo
key: cargocache-v2-libwasmvm_sanity-rust:1.67.0-${{ hashFiles('Cargo.lock') }}
key: cargocache-v2-libwasmvm_sanity-rust:1.70.0-${{ hashFiles('Cargo.lock') }}
- name: Install shellcheck
run: sudo apt install shellcheck
- name: Show version information
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.67.0
toolchain: 1.70.0
target: x86_64-unknown-linux-gnu
profile: minimal
override: true
Expand All @@ -143,7 +143,7 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.cargo
key: cargocache-v2-build_shared_library-rust:1.67.0-${{ hashFiles('Cargo.lock') }}
key: cargocache-v2-build_shared_library-rust:1.70.0-${{ hashFiles('Cargo.lock') }}
- name: Show version information
run: rustc --version; cargo --version; rustup --version
- name: Create release build of libwasmvm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_to_git.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.67.0
toolchain: 1.70.0
profile: minimal
override: true
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Features
* bump up wasmvm from v1.1.1 to v1.4.1 ([#136](https://github.com/Finschia/wasmvm/pull/136))
* bump up wasmvm from v1.1.1 to v1.5.0 ([#138](https://github.com/Finschia/wasmvm/pull/138))

## [[1.1.1-0.11.6](https://github.com/Finschia/wasmvm/compare/v1.1.1+0.11.5...v1.1.1-0.11.6)] - 2023-10-18
### Changes
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ test-alpine: release-build-alpine

@# Run the demo binary on Alpine machines
@# See https://de.wikipedia.org/wiki/Alpine_Linux#Versionen for supported versions
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.18 ./demo ./testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.17 ./demo ./testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.16 ./demo ./testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.15 ./demo ./testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.14 ./demo ./testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.13 ./demo ./testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.12 ./demo ./testdata/hackatom.wasm

@# Run binary locally if you are on Linux
@# ./demo ./testdata/hackatom.wasm
Expand Down
12 changes: 7 additions & 5 deletions builders/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
# 1. Build the static Rust library
# 2. Execute Go tests that use and test this library
# For 2. we define the Go image here. For 1. we install Rust below.
FROM golang:1.19.7-alpine
#
# See also docs/COMPILER_VERSIONS.md
FROM golang:1.20.10-alpine

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH

# this comes from standard alpine nightly file
# https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile
# with some changes to support our toolchain, etc
RUN set -eux \
&& apk add --no-cache ca-certificates build-base
&& apk add --no-cache ca-certificates build-base

RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-musl/rustup-init" \
&& chmod +x rustup-init \
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.69.0 \
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.73.0 \
&& rm rustup-init \
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME

Expand Down
6 changes: 3 additions & 3 deletions builders/Dockerfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ RUN yum -y update \

# GET FROM https://github.com/rust-lang/docker-rust-nightly
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH

RUN wget "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init" \
&& chmod +x rustup-init \
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.69.0 \
&& ./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.73.0 \
&& rm rustup-init \
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME \
&& rustup --version \
Expand Down
6 changes: 3 additions & 3 deletions builders/Dockerfile.cross
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM rust:1.69.0-bullseye
FROM rust:1.73.0-bullseye

# Install build dependencies
RUN apt-get update \
&& apt install -y clang gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev build-essential cmake \
# Support for Windows cross-compile
mingw-w64
# Support for Windows cross-compile
mingw-w64

## ADD MACOS SUPPORT

Expand Down
6 changes: 3 additions & 3 deletions docs/COMPILER_VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ We currently use the following version:

| Type | Rust version | Note |
| ------------------------ | ------------ | --------------------------------- |
| Production Rust compiler | 1.69.0 | Builders version 0016 |
| Min Rust compiler | 1.67.0 | Supports builder versions >= 0015 |
| Tooling Rust compiler | 1.69.0 | |
| Production Rust compiler | 1.73.0 | Builders version 0017 |
| Min Rust compiler | 1.70.0 | Supports builder versions >= 0017 |
| Tooling Rust compiler | 1.70.0 | |
103 changes: 103 additions & 0 deletions internal/api/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package api

import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"os"
"path/filepath"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -906,6 +908,10 @@ func createReflectContract(t *testing.T, cache Cache) []byte {
return createContract(t, cache, "../../testdata/reflect.wasm")
}

func createFloaty2(t *testing.T, cache Cache) []byte {
return createContract(t, cache, "../../testdata/floaty_2.0.wasm")
}

func createContract(t *testing.T, cache Cache, wasmFile string) []byte {
wasm, err := os.ReadFile(wasmFile)
require.NoError(t, err)
Expand Down Expand Up @@ -1054,3 +1060,100 @@ func TestCustomReflectQuerier(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "SMALL FRYS :)", response.Text)
}

// TestFloats is a port of the float_instrs_are_deterministic test in cosmwasm-vm
func TestFloats(t *testing.T) {
type Value struct {
U32 *uint32 `json:"u32,omitempty"`
U64 *uint64 `json:"u64,omitempty"`
F32 *uint32 `json:"f32,omitempty"`
F64 *uint64 `json:"f64,omitempty"`
}

// helper to print the value in the same format as Rust's Debug trait
debugStr := func(value Value) string {
if value.U32 != nil {
return fmt.Sprintf("U32(%d)", *value.U32)
} else if value.U64 != nil {
return fmt.Sprintf("U64(%d)", *value.U64)
} else if value.F32 != nil {
return fmt.Sprintf("F32(%d)", *value.F32)
} else if value.F64 != nil {
return fmt.Sprintf("F64(%d)", *value.F64)
} else {
t.FailNow()
return ""
}
}

cache, cleanup := withCache(t)
defer cleanup()
checksum := createFloaty2(t, cache)

gasMeter := NewMockGasMeter(TESTING_GAS_LIMIT)
igasMeter := types.GasMeter(gasMeter)
// instantiate it with this store
store := NewLookup(gasMeter)
api := NewMockAPI()
querier := DefaultQuerier(MOCK_CONTRACT_ADDR, nil)
env := MockEnvBin(t)

// query instructions
query := []byte(`{"instructions":{}}`)
data, _, err := Query(cache, checksum, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
require.NoError(t, err)
var qres types.QueryResponse
err = json.Unmarshal(data, &qres)
require.NoError(t, err)
require.Equal(t, "", qres.Err)
var instructions []string
err = json.Unmarshal(qres.Ok, &instructions)
require.NoError(t, err)
// little sanity check
require.Equal(t, 70, len(instructions))

hasher := sha256.New()
const RUNS_PER_INSTRUCTION = 150
for _, instr := range instructions {
for seed := 0; seed < RUNS_PER_INSTRUCTION; seed++ {
// query some input values for the instruction
msg := fmt.Sprintf(`{"random_args_for":{"instruction":"%s","seed":%d}}`, instr, seed)
data, _, err = Query(cache, checksum, env, []byte(msg), &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
require.NoError(t, err)
err = json.Unmarshal(data, &qres)
require.NoError(t, err)
require.Equal(t, "", qres.Err)
var args []Value
err = json.Unmarshal(qres.Ok, &args)
require.NoError(t, err)

// build the run message
argStr, err := json.Marshal(args)
require.NoError(t, err)
msg = fmt.Sprintf(`{"run":{"instruction":"%s","args":%s}}`, instr, argStr)

// run the instruction
// this might throw a runtime error (e.g. if the instruction traps)
data, _, err = Query(cache, checksum, env, []byte(msg), &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
var result string
if err != nil {
assert.ErrorContains(t, err, "Error calling the VM: Error executing Wasm: ")
// remove the prefix to make the error message the same as in the cosmwasm-vm test
result = strings.Replace(err.Error(), "Error calling the VM: Error executing Wasm: ", "", 1)
} else {
err = json.Unmarshal(data, &qres)
require.NoError(t, err)
require.Equal(t, "", qres.Err)
var response Value
err = json.Unmarshal(qres.Ok, &response)
require.NoError(t, err)
result = debugStr(response)
}
// add the result to the hash
hasher.Write([]byte(fmt.Sprintf("%s%d%s", instr, seed, result)))
}
}

hash := hasher.Sum(nil)
require.Equal(t, "95f70fa6451176ab04a9594417a047a1e4d8e2ff809609b8f81099496bee2393", hex.EncodeToString(hash))
}
Binary file modified internal/api/libwasmvm.aarch64.so
Binary file not shown.
Binary file modified internal/api/libwasmvm.dylib
Binary file not shown.
Binary file modified internal/api/libwasmvm.x86_64.so
Binary file not shown.
Loading

0 comments on commit 3b51958

Please sign in to comment.