Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.5.0-rc.0 #461

Merged
merged 8 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
# All checks on the codebase that can run in parallel to build_shared_library
libwasmvm_sanity:
docker:
- image: cimg/rust:1.67.0
- image: cimg/rust:1.70.0
steps:
- checkout
- run:
Expand All @@ -18,8 +18,8 @@ jobs:
command: rustup component add rustfmt
- restore_cache:
keys:
- cargocache-v3-libwasmvm_sanity-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.67.0-
- cargocache-v3-libwasmvm_sanity-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.70.0-
- run:
name: Ensure libwasmvm/bindings.h is up-to-date
working_directory: libwasmvm
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-libwasmvm_sanity-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-libwasmvm_sanity-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}

libwasmvm_clippy:
parameters:
Expand Down Expand Up @@ -113,15 +113,15 @@ jobs:
command: |
set -o errexit
curl -sS --output rustup-init.exe https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.67.0 -y
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.70.0 -y
echo 'export PATH="$PATH;$USERPROFILE/.cargo/bin"' >> "$BASH_ENV"
- run:
name: Show Rust version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cachev4-libwasmvm_sanity_windows-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cachev4-libwasmvm_sanity_windows-rust:1.67.0-
- cachev4-libwasmvm_sanity_windows-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cachev4-libwasmvm_sanity_windows-rust:1.70.0-
- run:
name: Run unit tests
working_directory: libwasmvm
Expand All @@ -133,13 +133,13 @@ jobs:
- libwasmvm/target/debug/.fingerprint
- libwasmvm/target/debug/build
- libwasmvm/target/debug/deps
key: cachev4-libwasmvm_sanity_windows-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cachev4-libwasmvm_sanity_windows-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}

libwasmvm_audit:
docker:
# The audit tool might use a more modern Rust version than the build jobs. See
# "Tooling Rust compiler" in docs/COMPILER_VERSIONS.md
- image: cimg/rust:1.69.0
- image: cimg/rust:1.70.0
steps:
- checkout
- run:
Expand All @@ -152,8 +152,8 @@ jobs:
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-v3-libwasmvm_audit-rust:1.69.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_audit-rust:1.69.0-
- cargocache-v3-libwasmvm_audit-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_audit-rust:1.70.0-
- run:
name: Install cargo-audit
command: cargo install --debug cargo-audit --version 0.17.6
Expand All @@ -164,7 +164,7 @@ jobs:
- save_cache:
paths:
- ~/.cargo/registry
key: cargocache-v3-libwasmvm_audit-rust:1.69.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-libwasmvm_audit-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}

format-go:
docker:
Expand Down Expand Up @@ -248,16 +248,16 @@ jobs:

build_shared_library:
docker:
- image: cimg/rust:1.67.0
- image: cimg/rust:1.70.0
steps:
- checkout
- run:
name: Show version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-v3-build_shared_library-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-build_shared_library-rust:1.67.0-
- cargocache-v3-build_shared_library-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-build_shared_library-rust:1.70.0-
- run:
name: Create release build of libwasmvm
command: make build-rust
Expand All @@ -274,7 +274,7 @@ jobs:
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-build_shared_library-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-build_shared_library-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}

# Test the Go project
wasmvm_test:
Expand Down Expand Up @@ -420,7 +420,7 @@ workflows:
matrix:
parameters:
# Run with MSRV and some modern stable Rust
rust-version: ["1.67.0", "1.73.0"]
rust-version: ["1.70.0", "1.73.0"]
- libwasmvm_audit
- format-go
- wasmvm_no_cgo
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.PHONY: all build build-rust build-go test

# Builds the Rust library libwasmvm
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0016
BUILDERS_PREFIX := cosmwasm/go-ext-builder:0017
# Contains a full Go dev environment in order to run Go tests on the built library
ALPINE_TESTER := cosmwasm/go-ext-builder:0016-alpine
ALPINE_TESTER := cosmwasm/go-ext-builder:0017-alpine

USER_ID := $(shell id -u)
USER_GROUP = $(shell id -g)
Expand Down
4 changes: 2 additions & 2 deletions docs/COMPILER_VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ We currently use the following version:
| Type | Rust version | Note |
| ------------------------ | ------------ | --------------------------------- |
| Production Rust compiler | 1.73.0 | Builders version 0017 |
| Min Rust compiler | 1.67.0 | Supports builder versions >= 0015 |
| Tooling Rust compiler | 1.69.0 | |
| 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,11 +2,13 @@ package api

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

Expand Down Expand Up @@ -907,6 +909,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 := ioutil.ReadFile(wasmFile)
require.NoError(t, err)
Expand Down Expand Up @@ -1055,3 +1061,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))
}
Loading