Skip to content

Commit d2c34e0

Browse files
authored
Merge pull request #461 from CosmWasm/release-1-5
Release 1.5.0-rc.0
2 parents 0471410 + d5f7173 commit d2c34e0

File tree

7 files changed

+212
-53
lines changed

7 files changed

+212
-53
lines changed

.circleci/config.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
# All checks on the codebase that can run in parallel to build_shared_library
88
libwasmvm_sanity:
99
docker:
10-
- image: cimg/rust:1.67.0
10+
- image: cimg/rust:1.70.0
1111
steps:
1212
- checkout
1313
- run:
@@ -18,8 +18,8 @@ jobs:
1818
command: rustup component add rustfmt
1919
- restore_cache:
2020
keys:
21-
- cargocache-v3-libwasmvm_sanity-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
22-
- cargocache-v3-libwasmvm_sanity-rust:1.67.0-
21+
- cargocache-v3-libwasmvm_sanity-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
22+
- cargocache-v3-libwasmvm_sanity-rust:1.70.0-
2323
- run:
2424
name: Ensure libwasmvm/bindings.h is up-to-date
2525
working_directory: libwasmvm
@@ -62,7 +62,7 @@ jobs:
6262
- libwasmvm/target/release/.fingerprint
6363
- libwasmvm/target/release/build
6464
- libwasmvm/target/release/deps
65-
key: cargocache-v3-libwasmvm_sanity-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
65+
key: cargocache-v3-libwasmvm_sanity-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
6666

6767
libwasmvm_clippy:
6868
parameters:
@@ -113,15 +113,15 @@ jobs:
113113
command: |
114114
set -o errexit
115115
curl -sS --output rustup-init.exe https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe
116-
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.67.0 -y
116+
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.70.0 -y
117117
echo 'export PATH="$PATH;$USERPROFILE/.cargo/bin"' >> "$BASH_ENV"
118118
- run:
119119
name: Show Rust version information
120120
command: rustc --version; cargo --version; rustup --version
121121
- restore_cache:
122122
keys:
123-
- cachev4-libwasmvm_sanity_windows-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
124-
- cachev4-libwasmvm_sanity_windows-rust:1.67.0-
123+
- cachev4-libwasmvm_sanity_windows-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
124+
- cachev4-libwasmvm_sanity_windows-rust:1.70.0-
125125
- run:
126126
name: Run unit tests
127127
working_directory: libwasmvm
@@ -133,13 +133,13 @@ jobs:
133133
- libwasmvm/target/debug/.fingerprint
134134
- libwasmvm/target/debug/build
135135
- libwasmvm/target/debug/deps
136-
key: cachev4-libwasmvm_sanity_windows-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
136+
key: cachev4-libwasmvm_sanity_windows-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
137137

138138
libwasmvm_audit:
139139
docker:
140140
# The audit tool might use a more modern Rust version than the build jobs. See
141141
# "Tooling Rust compiler" in docs/COMPILER_VERSIONS.md
142-
- image: cimg/rust:1.69.0
142+
- image: cimg/rust:1.70.0
143143
steps:
144144
- checkout
145145
- run:
@@ -152,8 +152,8 @@ jobs:
152152
command: rustc --version; cargo --version; rustup --version
153153
- restore_cache:
154154
keys:
155-
- cargocache-v3-libwasmvm_audit-rust:1.69.0-{{ checksum "libwasmvm/Cargo.lock" }}
156-
- cargocache-v3-libwasmvm_audit-rust:1.69.0-
155+
- cargocache-v3-libwasmvm_audit-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
156+
- cargocache-v3-libwasmvm_audit-rust:1.70.0-
157157
- run:
158158
name: Install cargo-audit
159159
command: cargo install --debug cargo-audit --version 0.17.6
@@ -164,7 +164,7 @@ jobs:
164164
- save_cache:
165165
paths:
166166
- ~/.cargo/registry
167-
key: cargocache-v3-libwasmvm_audit-rust:1.69.0-{{ checksum "libwasmvm/Cargo.lock" }}
167+
key: cargocache-v3-libwasmvm_audit-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
168168

169169
format-go:
170170
docker:
@@ -248,16 +248,16 @@ jobs:
248248

249249
build_shared_library:
250250
docker:
251-
- image: cimg/rust:1.67.0
251+
- image: cimg/rust:1.70.0
252252
steps:
253253
- checkout
254254
- run:
255255
name: Show version information
256256
command: rustc --version; cargo --version; rustup --version
257257
- restore_cache:
258258
keys:
259-
- cargocache-v3-build_shared_library-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
260-
- cargocache-v3-build_shared_library-rust:1.67.0-
259+
- cargocache-v3-build_shared_library-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
260+
- cargocache-v3-build_shared_library-rust:1.70.0-
261261
- run:
262262
name: Create release build of libwasmvm
263263
command: make build-rust
@@ -274,7 +274,7 @@ jobs:
274274
- libwasmvm/target/release/.fingerprint
275275
- libwasmvm/target/release/build
276276
- libwasmvm/target/release/deps
277-
key: cargocache-v3-build_shared_library-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
277+
key: cargocache-v3-build_shared_library-rust:1.70.0-{{ checksum "libwasmvm/Cargo.lock" }}
278278

279279
# Test the Go project
280280
wasmvm_test:
@@ -420,7 +420,7 @@ workflows:
420420
matrix:
421421
parameters:
422422
# Run with MSRV and some modern stable Rust
423-
rust-version: ["1.67.0", "1.73.0"]
423+
rust-version: ["1.70.0", "1.73.0"]
424424
- libwasmvm_audit
425425
- format-go
426426
- wasmvm_no_cgo

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.PHONY: all build build-rust build-go test
22

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

88
USER_ID := $(shell id -u)
99
USER_GROUP = $(shell id -g)

docs/COMPILER_VERSIONS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ We currently use the following version:
6464
| Type | Rust version | Note |
6565
| ------------------------ | ------------ | --------------------------------- |
6666
| Production Rust compiler | 1.73.0 | Builders version 0017 |
67-
| Min Rust compiler | 1.67.0 | Supports builder versions >= 0015 |
68-
| Tooling Rust compiler | 1.69.0 | |
67+
| Min Rust compiler | 1.70.0 | Supports builder versions >= 0017 |
68+
| Tooling Rust compiler | 1.70.0 | |

internal/api/lib_test.go

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package api
22

33
import (
44
"crypto/sha256"
5+
"encoding/hex"
56
"encoding/json"
67
"fmt"
78
"io/ioutil"
89
"os"
910
"path/filepath"
11+
"strings"
1012
"testing"
1113
"time"
1214

@@ -907,6 +909,10 @@ func createReflectContract(t *testing.T, cache Cache) []byte {
907909
return createContract(t, cache, "../../testdata/reflect.wasm")
908910
}
909911

912+
func createFloaty2(t *testing.T, cache Cache) []byte {
913+
return createContract(t, cache, "../../testdata/floaty_2.0.wasm")
914+
}
915+
910916
func createContract(t *testing.T, cache Cache, wasmFile string) []byte {
911917
wasm, err := ioutil.ReadFile(wasmFile)
912918
require.NoError(t, err)
@@ -1055,3 +1061,100 @@ func TestCustomReflectQuerier(t *testing.T) {
10551061
require.NoError(t, err)
10561062
require.Equal(t, "SMALL FRYS :)", response.Text)
10571063
}
1064+
1065+
// TestFloats is a port of the float_instrs_are_deterministic test in cosmwasm-vm
1066+
func TestFloats(t *testing.T) {
1067+
type Value struct {
1068+
U32 *uint32 `json:"u32,omitempty"`
1069+
U64 *uint64 `json:"u64,omitempty"`
1070+
F32 *uint32 `json:"f32,omitempty"`
1071+
F64 *uint64 `json:"f64,omitempty"`
1072+
}
1073+
1074+
// helper to print the value in the same format as Rust's Debug trait
1075+
debugStr := func(value Value) string {
1076+
if value.U32 != nil {
1077+
return fmt.Sprintf("U32(%d)", *value.U32)
1078+
} else if value.U64 != nil {
1079+
return fmt.Sprintf("U64(%d)", *value.U64)
1080+
} else if value.F32 != nil {
1081+
return fmt.Sprintf("F32(%d)", *value.F32)
1082+
} else if value.F64 != nil {
1083+
return fmt.Sprintf("F64(%d)", *value.F64)
1084+
} else {
1085+
t.FailNow()
1086+
return ""
1087+
}
1088+
}
1089+
1090+
cache, cleanup := withCache(t)
1091+
defer cleanup()
1092+
checksum := createFloaty2(t, cache)
1093+
1094+
gasMeter := NewMockGasMeter(TESTING_GAS_LIMIT)
1095+
igasMeter := types.GasMeter(gasMeter)
1096+
// instantiate it with this store
1097+
store := NewLookup(gasMeter)
1098+
api := NewMockAPI()
1099+
querier := DefaultQuerier(MOCK_CONTRACT_ADDR, nil)
1100+
env := MockEnvBin(t)
1101+
1102+
// query instructions
1103+
query := []byte(`{"instructions":{}}`)
1104+
data, _, err := Query(cache, checksum, env, query, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
1105+
require.NoError(t, err)
1106+
var qres types.QueryResponse
1107+
err = json.Unmarshal(data, &qres)
1108+
require.NoError(t, err)
1109+
require.Equal(t, "", qres.Err)
1110+
var instructions []string
1111+
err = json.Unmarshal(qres.Ok, &instructions)
1112+
require.NoError(t, err)
1113+
// little sanity check
1114+
require.Equal(t, 70, len(instructions))
1115+
1116+
hasher := sha256.New()
1117+
const RUNS_PER_INSTRUCTION = 150
1118+
for _, instr := range instructions {
1119+
for seed := 0; seed < RUNS_PER_INSTRUCTION; seed++ {
1120+
// query some input values for the instruction
1121+
msg := fmt.Sprintf(`{"random_args_for":{"instruction":"%s","seed":%d}}`, instr, seed)
1122+
data, _, err = Query(cache, checksum, env, []byte(msg), &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
1123+
require.NoError(t, err)
1124+
err = json.Unmarshal(data, &qres)
1125+
require.NoError(t, err)
1126+
require.Equal(t, "", qres.Err)
1127+
var args []Value
1128+
err = json.Unmarshal(qres.Ok, &args)
1129+
require.NoError(t, err)
1130+
1131+
// build the run message
1132+
argStr, err := json.Marshal(args)
1133+
require.NoError(t, err)
1134+
msg = fmt.Sprintf(`{"run":{"instruction":"%s","args":%s}}`, instr, argStr)
1135+
1136+
// run the instruction
1137+
// this might throw a runtime error (e.g. if the instruction traps)
1138+
data, _, err = Query(cache, checksum, env, []byte(msg), &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
1139+
var result string
1140+
if err != nil {
1141+
assert.ErrorContains(t, err, "Error calling the VM: Error executing Wasm: ")
1142+
// remove the prefix to make the error message the same as in the cosmwasm-vm test
1143+
result = strings.Replace(err.Error(), "Error calling the VM: Error executing Wasm: ", "", 1)
1144+
} else {
1145+
err = json.Unmarshal(data, &qres)
1146+
require.NoError(t, err)
1147+
require.Equal(t, "", qres.Err)
1148+
var response Value
1149+
err = json.Unmarshal(qres.Ok, &response)
1150+
require.NoError(t, err)
1151+
result = debugStr(response)
1152+
}
1153+
// add the result to the hash
1154+
hasher.Write([]byte(fmt.Sprintf("%s%d%s", instr, seed, result)))
1155+
}
1156+
}
1157+
1158+
hash := hasher.Sum(nil)
1159+
require.Equal(t, "95f70fa6451176ab04a9594417a047a1e4d8e2ff809609b8f81099496bee2393", hex.EncodeToString(hash))
1160+
}

0 commit comments

Comments
 (0)