Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into faddat/ultratabledriven
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Feb 15, 2025
2 parents 8a2f628 + 4263311 commit 3b45760
Show file tree
Hide file tree
Showing 33 changed files with 1,667 additions and 650 deletions.
29 changes: 15 additions & 14 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.74.0
- image: cimg/rust:1.81.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.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.74.0-
- cargocache-v3-libwasmvm_sanity-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.81.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.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-libwasmvm_sanity-rust:1.81.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.74.0 -y
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.81.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.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cachev4-libwasmvm_sanity_windows-rust:1.74.0-
- cachev4-libwasmvm_sanity_windows-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cachev4-libwasmvm_sanity_windows-rust:1.81.0-
- run:
name: Run unit tests
working_directory: libwasmvm
Expand All @@ -133,7 +133,7 @@ jobs:
- libwasmvm/target/debug/.fingerprint
- libwasmvm/target/debug/build
- libwasmvm/target/debug/deps
key: cachev4-libwasmvm_sanity_windows-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cachev4-libwasmvm_sanity_windows-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}

libwasmvm_audit:
docker:
Expand All @@ -156,7 +156,7 @@ jobs:
- v3-libwasmvm_audit-rust:1.81.0-
- run:
name: Install cargo-audit
command: cargo install --debug cargo-audit --version 0.17.6
command: cargo install --debug cargo-audit --version 0.21.0 --locked
- run:
name: Run cargo-audit
working_directory: libwasmvm
Expand Down Expand Up @@ -267,16 +267,17 @@ jobs:

build_shared_library:
docker:
- image: cimg/rust:1.74.0
# libwasmvm versions built with 1.81 are broken, so we use 1.82 here
- image: cimg/rust:1.82.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.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-build_shared_library-rust:1.74.0-
- cargocache-v3-build_shared_library-rust:1.82.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-build_shared_library-rust:1.82.0-
- run:
name: Create release build of libwasmvm
command: make build-libwasmvm
Expand All @@ -293,7 +294,7 @@ jobs:
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-build_shared_library-rust:1.74.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-build_shared_library-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}

# Test the Go project and run benchmarks
wasmvm_test:
Expand Down Expand Up @@ -455,7 +456,7 @@ workflows:
matrix:
parameters:
# Run with MSRV and some modern stable Rust
rust-version: ["1.74.0", "1.80.0"]
rust-version: ["1.81.0", "1.82.0"]
- libwasmvm_audit
- format-go
- wasmvm_no_cgo
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/lint-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21.4'
go-version: "1.23.4"
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.6.0
uses: golangci/golangci-lint-action@v6
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.56.2
version: v1.62.2

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
37 changes: 34 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
run:
tests: true

linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- gofumpt
- goimports
- gci
- testifylint

linters-settings:
goimports:
local-prefixes: github.com/CosmWasm/wasmvm
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/cosmos/cosmos-sdk) # Custom section: groups all imports with the specified Prefix.
- prefix(github.com/cosmos/ibc-go)
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
# Skip generated files.
# Default: true
skip-generated: false
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
# Drops lexical ordering for custom sections.
# Default: false
no-lex-order: true

issues:
max-issues-per-linter: 0
max-same-issues: 0
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Builds the Rust library libwasmvm
BUILDERS_PREFIX := cosmwasm/libwasmvm-builder:0102
BUILDERS_PREFIX := cosmwasm/libwasmvm-builder:0103
# Contains a full Go dev environment including CGO support in order to run Go tests on the built shared library
# This image is currently not published.
ALPINE_TESTER := cosmwasm/alpine-tester:local
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ library that can be used via FFI. It is compiled like this:
# Run unit tests
(cd libwasmvm && cargo test)

# Create release build for your current system. Uses whatever default Rust
# Create a release build for your current system. Uses whatever default Rust
# version you have installed.
make build-libwasmvm

Expand Down Expand Up @@ -107,11 +107,11 @@ go build -tags "nolink_libwasmvm"
See [COMPILER_VERSIONS.md](docs/COMPILER_VERSIONS.md) for information on Go and
Rust compiler support.

The Rust implementation of the VM is compiled to a library called libwasmvm.
The Rust implementation of the VM is compiled into a library called libwasmvm.
This is then linked to the Go code when the final binary is built. For that
reason not all systems supported by Go are supported by this project.

Linux (tested on Ubuntu, Debian, Alpine) and macOS is supported. We are working
Linux (tested on Ubuntu, Debian, Alpine) and macOS are supported. We are working
on Windows support with very low priority (#288).

[#288]: https://github.com/CosmWasm/wasmvm/pull/288
Expand Down
2 changes: 1 addition & 1 deletion builders/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM --platform=linux/amd64 rust:1.82.0-alpine

RUN apk add --no-cache ca-certificates build-base
RUN apk add --no-cache ca-certificates build-base llvm17-dev clang17-static

# Install C compiler for cross-compilation. This is required by
# Wasmer in https://github.com/wasmerio/wasmer/blob/2.2.1/lib/vm/build.rs.
Expand Down
2 changes: 1 addition & 1 deletion builders/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
FROM --platform=linux/amd64 debian:11-slim

RUN apt update -y \
&& apt install -y gcc make gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu wget
&& apt install -y gcc make gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu wget clang

# GET FROM https://github.com/rust-lang/docker-rust-nightly
ENV RUSTUP_HOME=/usr/local/rustup \
Expand Down
2 changes: 1 addition & 1 deletion builders/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Versioned by a simple counter that is not bound to a specific CosmWasm version
# See builders/README.md
BUILDERS_PREFIX := cosmwasm/libwasmvm-builder:0102
BUILDERS_PREFIX := cosmwasm/libwasmvm-builder:0103

.PHONY: docker-image-debian
docker-image-debian:
Expand Down
2 changes: 0 additions & 2 deletions builders/guest/build_gnu_aarch64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export TARGET_DIR="/target" # write to /target in the guest's file system to avo
# No stripping implemented (see https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-2260007943).

echo "Starting aarch64-unknown-linux-gnu build"
export CC=clang
export CXX=clang++
export qemu_aarch64="qemu-aarch64 -L /usr/aarch64-linux-gnu"
export CC_aarch64_unknown_linux_gnu=clang
export AR_aarch64_unknown_linux_gnu=llvm-ar
Expand Down
3 changes: 1 addition & 2 deletions builders/guest/build_muslc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ export TARGET_DIR="/target" # write to /target in the guest's file system to avo
# No stripping implemented (see https://github.com/CosmWasm/wasmvm/issues/222#issuecomment-2260007943).

echo "Starting aarch64-unknown-linux-musl build"
export CC=/opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc
export CC_aarch64_unknown_linux_musl=/opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc
cargo build --release --target-dir="$TARGET_DIR" --target aarch64-unknown-linux-musl --example wasmvmstatic
unset CC

echo "Starting x86_64-unknown-linux-musl build"
cargo build --release --target-dir="$TARGET_DIR" --target x86_64-unknown-linux-musl --example wasmvmstatic
Expand Down
14 changes: 7 additions & 7 deletions docs/COMPILER_VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ The Go version here has the following goals:
versions reasonably wide to avoid unnecessary friction for users. I.e. just
because Cosmos SDK now uses Go 1.19 does not mean we make 1.19 the minimal
supported version here. However, the project should work with the latest
stable Go version. When the majority of our users is between 1.18 and 1.19, we
can slowly remove 1.17 support by bumping the min version to 1.18.
stable Go version. When the majority of our users are between 1.18 and 1.19,
we can slowly remove 1.17 support by bumping the min version to 1.18.
- Be stable enough to test Go code. We always pin the patch version to ensure CI
runs are reproducible. Those versions will contain security issues from time
to time, but that's fine for how they are used here.
Expand All @@ -31,10 +31,10 @@ Go version locations:
## Rust

In contrast to Go, the Rust compiler used here produces actual artifacts used
directly by consumer projects. This are the shared .dylib, .so, .dll libraries
directly by consumer projects. These are the shared .dylib, .so, .dll libraries
as well as the static .a libraries. Those libwasmvm builds contain all the Rust
code executing contracts, especially cosmwasm-vm. New Rust versions usually add
features which are not necessarily used or needed. But we should move with the
features that are not necessarily used or needed. But we should move with the
ecosystem to keep the dependency tree compiling. Also new Rust versions tend to
increase runtime speed through optimizer improvements, which never hurts.

Expand Down Expand Up @@ -63,6 +63,6 @@ We currently use the following version:

| Type | Rust version | Note |
| ------------------------ | ------------ | --------------------------------- |
| Production Rust compiler | 1.82.0 | Builders version 0102 |
| Min Rust compiler | 1.74.0 | Supports builder versions >= 0019 |
| Tooling Rust compiler | 1.75.0 | |
| Production Rust compiler | 1.82.0 | Builders version 0103 |
| Min Rust compiler | 1.82.0 | Supports builder versions >= 0103 |
| Tooling Rust compiler | 1.81.0 | |
2 changes: 1 addition & 1 deletion docs/MIGRATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- `QueryRequest.Grpc` was added. It is similar to `QueryRequest.Stargate` but
unlike that, it should always return protobuf encoded responses on all chains.
- `VM.StoreCode` now returns a `uint64` containing the gas cost in CosmWasm gas
and takes a gas limit as argument. This was previously calculated in wasmd.
and takes a gas limit as an argument. This was previously calculated in wasmd.
The change brings consistency with the other functions that cause gas usage.
- `GoAPI` now requires an additional `ValidateAddress` function that validates
whether the given string is a valid address. This was previously done
Expand Down
10 changes: 5 additions & 5 deletions ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestIBCHandshake(t *testing.T) {
require.NoError(t, err)
assert.NotNil(t, i.Ok)
iResponse := i.Ok
require.Equal(t, 0, len(iResponse.Messages))
require.Empty(t, iResponse.Messages)

// channel open
gasMeter2 := api.NewMockGasMeter(TESTING_GAS_LIMIT)
Expand All @@ -132,7 +132,7 @@ func TestIBCHandshake(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, conn.Ok)
connResponse := conn.Ok
require.Equal(t, 1, len(connResponse.Messages))
require.Len(t, connResponse.Messages, 1)

// check for the expected custom event
expected_events := []types.Event{{
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestIBCPacketDispatch(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, conn.Ok)
connResponse := conn.Ok
require.Equal(t, 1, len(connResponse.Messages))
require.Len(t, connResponse.Messages, 1)
id := connResponse.Messages[0].ID

// mock reflect init callback (to store address)
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestIBCPacketDispatch(t *testing.T) {
var accounts ListAccountsResponse
err = json.Unmarshal(qResponse, &accounts)
require.NoError(t, err)
require.Equal(t, 1, len(accounts.Accounts))
require.Len(t, accounts.Accounts, 1)
require.Equal(t, CHANNEL_ID, accounts.Accounts[0].ChannelID)
require.Equal(t, REFLECT_ADDR, accounts.Accounts[0].Account)

Expand Down Expand Up @@ -332,7 +332,7 @@ func TestIBCMsgGetChannel(t *testing.T) {
require.Equal(t, msg1.GetChannel(), msg4.GetChannel())
require.Equal(t, msg1.GetChannel(), msg5.GetChannel())
require.Equal(t, msg1.GetChannel(), msg6.GetChannel())
require.Equal(t, msg1.GetChannel().Endpoint.ChannelID, CHANNEL_ID)
require.Equal(t, CHANNEL_ID, msg1.GetChannel().Endpoint.ChannelID)
}

func TestIBCMsgGetCounterVersion(t *testing.T) {
Expand Down
8 changes: 3 additions & 5 deletions internal/api/iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"sync"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/CosmWasm/wasmvm/v2/internal/api/testdb"
Expand Down Expand Up @@ -352,8 +351,7 @@ func TestQueueIteratorRaces_TableDriven(t *testing.T) {
cache, cleanup := withCache(t)
defer cleanup()

// initially no frames
assert.Equal(t, 0, len(iteratorFrames))
require.Empty(t, iteratorFrames)

contract1 := setupQueueContractWithData(t, cache, 17, 22)
contract2 := setupQueueContractWithData(t, cache, 1, 19, 6, 35, 8)
Expand Down Expand Up @@ -403,8 +401,8 @@ func TestQueueIteratorRaces_TableDriven(t *testing.T) {
}
wg.Wait()

// all frames should be removed
assert.Equal(t, 0, len(iteratorFrames))
// when they finish, we should have removed all frames
require.Empty(t, iteratorFrames)
}

func TestQueueIteratorLimit_TableDriven(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func StoreCodeUnchecked(cache Cache, wasm []byte) ([]byte, error) {
w := makeView(wasm)
defer runtime.KeepAlive(wasm)
errmsg := uninitializedUnmanagedVector()
checksum, err := C.store_code(cache.ptr, w, cbool(true), cbool(true), &errmsg)
checksum, err := C.store_code(cache.ptr, w, cbool(false), cbool(true), &errmsg)
if err != nil {
return nil, errorWithMessage(err, errmsg)
}
Expand Down
Loading

0 comments on commit 3b45760

Please sign in to comment.