Skip to content

Commit

Permalink
Support Wasm compiled with Rust v1.70+
Browse files Browse the repository at this point in the history
Starting from v1.70, Rust uses the Wasm sign extenstion opcodes when comipling to Wasm. Our Wasm parser for static analysis had to be updated in order to correctly parse these opcodes.

Refs:
- https://github.com/WebAssembly/sign-extension-ops/blob/master/proposals/sign-extension-ops/Overview.md
- CosmWasm/cosmwasm#1727
- CosmWasm/cosmwasm#1743
  • Loading branch information
assafmo committed Aug 8, 2023
1 parent de39a8c commit 2db8a95
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions cosmwasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.69
1.71
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.69
1.71
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.69
1.71
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.69
1.71
16 changes: 11 additions & 5 deletions cosmwasm/enclaves/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion cosmwasm/enclaves/execute/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ serde_json = { git = "https://github.com/mesalock-linux/serde-json-sgx" }
ctor = "0.1.13"
derive_more = "0.99"
pwasm-utils = { version = "0.12.0", default-features = false }
parity-wasm = { version = "0.41.0", default-features = false }
parity-wasm = { version = "0.45.0", default-features = false, features = [
"sign_ext"
] }
base64 = { rev = "dc7389e10817b078f289386b3b6a852ab6c4c021", git = "https://github.com/mesalock-linux/rust-base64-sgx" }
# for attestation
chrono = { git = "https://github.com/mesalock-linux/chrono-sgx" }
Expand Down
4 changes: 3 additions & 1 deletion cosmwasm/enclaves/shared/contract-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ derive_more = "0.99"
sha2 = "0.8.1"
bech32 = "0.7.2"
pwasm-utils = { version = "0.12.0", default-features = false, optional = true }
parity-wasm = { version = "0.41.0", default-features = false, optional = true }
parity-wasm = { version = "0.45.0", default-features = false, optional = true, features = [
"sign_ext"
] }
wasm3 = { git = "https://github.com/scrtlabs/wasm3-rs", rev = "ad1c868" }
walrus = { version = "0.19.0", git = "https://github.com/scrtlabs/walrus", rev = "c5777d4" }
lru = { version = "0.7", default-features = false }
Expand Down
12 changes: 6 additions & 6 deletions cosmwasm/enclaves/test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cosmwasm/packages/sgx-vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ snafu = { version = "0.6.3" }
sha2 = "0.10.7"
hex = "0.4"
memmap = "0.7"
parity-wasm = "0.41"
parity-wasm = { version = "0.45", features = ["sign_ext"] }
# requirements specific to Secret Network
lazy_static = "1.4"
enclave-ffi-types = { path = "../../enclaves/ffi-types", features = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.69.0-slim-bullseye
FROM rust:1.71.0-slim-bullseye

RUN rustup target add wasm32-unknown-unknown
RUN apt update && apt install -y binaryen clang && rm -rf /var/lib/apt/lists/*
Expand Down
12 changes: 6 additions & 6 deletions go-cosmwasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 11 additions & 21 deletions scripts/install-wasm-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,34 +81,24 @@ cargo install pwasm-utils-cli --bin wasm-prune --force
if [[ "$OSTYPE" == "linux-gnu" ]]; then
set -e

BUILD_NUM=`curl -s https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json | jq -r '.build'`
if [ -z ${BUILD_NUM+x} ]; then
echo "Could not fetch the latest build number.";
exit 1;
fi

tmp=`mktemp -d`
pushd $tmp > /dev/null
echo "Downloading wasm-binaries.tbz2";
curl -L -o wasm-binaries.tbz2 https://storage.googleapis.com/wasm-llvm/builds/linux/$BUILD_NUM/wasm-binaries.tbz2

echo "Downloading wabt-1.0.33-ubuntu.tar.gz";
wget https://github.com/WebAssembly/wabt/releases/download/1.0.33/wabt-1.0.33-ubuntu.tar.gz

declare -a binaries=("wasm2wat" "wat2wasm") # Default binaries
if [ "$#" -ne 0 ]; then
echo "Installing selected binaries.";
binaries=("$@");
else
echo "Installing default binaries.";
fi
tar --strip-components=2 -xf wabt-1.0.33-ubuntu.tar.gz wabt-1.0.33/bin/wasm2wat wabt-1.0.33/bin/wat2wasm

echo "Installing wasm2wat & wat2wasm into ~/.cargo/bin"
cp -f wasm2wat ~/.cargo/bin/
cp -f wat2wasm ~/.cargo/bin/

for bin in "${binaries[@]}"
do
echo "Installing $bin into ~/.cargo/bin"
tar -xvjf wasm-binaries.tbz2 wasm-install/bin/$bin > /dev/null
cp -f wasm-install/bin/$bin ~/.cargo/bin/
done
popd > /dev/null
fi

echo ""
echo "Run source ~/.cargo/env now to update environment."
echo ""

source ~/.cargo/env
wasm2wat --version
Binary file modified x/compute/internal/keeper/testdata/contract.wasm
Binary file not shown.
Binary file modified x/compute/internal/keeper/testdata/contract_with_floats.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified x/compute/internal/keeper/testdata/v1-contract-v2.wasm
Binary file not shown.
Binary file modified x/compute/internal/keeper/testdata/v1-contract.wasm
Binary file not shown.
Binary file modified x/compute/internal/keeper/testdata/v1_random_test.wasm
Binary file not shown.

0 comments on commit 2db8a95

Please sign in to comment.