Skip to content

Commit 4f21d57

Browse files
authored
Merge pull request #1500 from scrtlabs/support-rust-1.70-wasm
Support compiling contracts with Rust v1.70+
2 parents 30a5ef2 + eadac6e commit 4f21d57

File tree

22 files changed

+51
-58
lines changed

22 files changed

+51
-58
lines changed

β€Ž.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
make clean-enclave
5757
5858
Build-Contracts:
59-
runs-on: ubuntu-20.04
59+
runs-on: ubuntu-22.04
6060
steps:
6161
- uses: actions/checkout@v3
6262
- name: Download sccache

β€Žcosmwasm/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žcosmwasm/contracts/v010/compute-tests/test-compute-contract/Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,22 @@ contract_with_floats.wasm: $(Rust_Crate_Source)
1616
rm -f ./contract_with_floats.wasm
1717
mv -f ./target/wasm32-unknown-unknown/release/test_contract.wasm ./contract_with_floats.wasm
1818

19+
# Older versions of wabt had the --enable-sign-extension flag, while on newer
20+
# versions it's turned on by default and the flag is replaced with --disable-sign-extension
21+
WASM2WAT_OPTS := $(shell wasm2wat --help | grep -Po '\-\-enable-sign-extension')
22+
WAT2WAT_OPTS := $(shell wat2wasm --help | grep -Po '\-\-enable-sign-extension')
23+
1924
# Create a wasm with more than 192 memory pages (fails in init, handle & query, this is our limit)
2025
# https://github.com/scrtlabs/SecretNetwork/blob/9eef8591b2c04c586ceee12f424b92062598123e/cosmwasm/packages/wasmi-runtime/src/wasm/memory.rs#L39
2126
too-high-initial-memory.wasm: contract.wasm
22-
wasm2wat ./contract.wasm | perl -pe 's/\(memory \(;0;\) \d+\)/(memory (;0;) 193)/' > /tmp/too-high-initial-memory.wat
23-
wat2wasm /tmp/too-high-initial-memory.wat -o ./too-high-initial-memory.wasm
27+
wasm2wat $(WASM2WAT_OPTS) ./contract.wasm | perl -pe 's/\(memory \(;0;\) \d+\)/(memory (;0;) 193)/' > /tmp/too-high-initial-memory.wat
28+
wat2wasm $(WAT2WAT_OPTS) /tmp/too-high-initial-memory.wat -o ./too-high-initial-memory.wasm
2429

2530
# Create a wasm with more than 512 memory pages (fails in store, this is cosmwasm's limit)
2631
# https://github.com/scrtlabs/SecretNetwork/blob/9eef8591b2c04c586ceee12f424b92062598123e/cosmwasm/packages/sgx-vm/src/compatability.rs#L36
2732
static-too-high-initial-memory.wasm: contract.wasm
28-
wasm2wat ./contract.wasm | perl -pe 's/\(memory \(;0;\) \d+\)/(memory (;0;) 513)/' > /tmp/static-too-high-initial-memory.wat
29-
wat2wasm /tmp/static-too-high-initial-memory.wat -o ./static-too-high-initial-memory.wasm
33+
wasm2wat $(WASM2WAT_OPTS) ./contract.wasm | perl -pe 's/\(memory \(;0;\) \d+\)/(memory (;0;) 513)/' > /tmp/static-too-high-initial-memory.wat
34+
wat2wasm $(WAT2WAT_OPTS) /tmp/static-too-high-initial-memory.wat -o ./static-too-high-initial-memory.wasm
3035

3136
setup:
3237
apt-get install wabt
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.69
1+
1.71
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.69
1+
1.71
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.69
1+
1.71
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.69
1+
1.71

β€Žcosmwasm/enclaves/Cargo.lock

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žcosmwasm/enclaves/execute/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ serde_json = { git = "https://github.com/mesalock-linux/serde-json-sgx" }
6969
ctor = "0.1.13"
7070
derive_more = "0.99"
7171
pwasm-utils = { version = "0.12.0", default-features = false }
72-
parity-wasm = { version = "0.41.0", default-features = false }
72+
parity-wasm = { version = "0.45.0", default-features = false, features = [
73+
"sign_ext"
74+
] }
7375
base64 = { rev = "dc7389e10817b078f289386b3b6a852ab6c4c021", git = "https://github.com/mesalock-linux/rust-base64-sgx" }
7476
# for attestation
7577
chrono = { git = "https://github.com/mesalock-linux/chrono-sgx" }

β€Žcosmwasm/enclaves/shared/contract-engine/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ derive_more = "0.99"
4949
sha2 = "0.8.1"
5050
bech32 = "0.7.2"
5151
pwasm-utils = { version = "0.12.0", default-features = false, optional = true }
52-
parity-wasm = { version = "0.41.0", default-features = false, optional = true }
52+
parity-wasm = { version = "0.45.0", default-features = false, optional = true, features = [
53+
"sign_ext"
54+
] }
5355
wasm3 = { git = "https://github.com/scrtlabs/wasm3-rs", rev = "ad1c868" }
5456
walrus = { version = "0.19.0", git = "https://github.com/scrtlabs/walrus", rev = "c5777d4" }
5557
lru = { version = "0.7", default-features = false }

β€Žcosmwasm/enclaves/test/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žcosmwasm/packages/sgx-vm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ snafu = { version = "0.6.3" }
5353
sha2 = "0.10.7"
5454
hex = "0.4"
5555
memmap = "0.7"
56-
parity-wasm = "0.41"
56+
parity-wasm = { version = "0.45", features = ["sign_ext"] }
5757
# requirements specific to Secret Network
5858
lazy_static = "1.4"
5959
enclave-ffi-types = { path = "../../enclaves/ffi-types", features = [

β€Ždeployment/dockerfiles/base-images/secret-contract-optimizer.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust:1.69.0-slim-bullseye
1+
FROM rust:1.71.0-slim-bullseye
22

33
RUN rustup target add wasm32-unknown-unknown
44
RUN apt update && apt install -y binaryen clang && rm -rf /var/lib/apt/lists/*

β€Žgo-cosmwasm/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žscripts/install-wasm-tools.sh

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -81,34 +81,12 @@ cargo install pwasm-utils-cli --bin wasm-prune --force
8181
if [[ "$OSTYPE" == "linux-gnu" ]]; then
8282
set -e
8383

84-
BUILD_NUM=`curl -s https://storage.googleapis.com/wasm-llvm/builds/linux/lkgr.json | jq -r '.build'`
85-
if [ -z ${BUILD_NUM+x} ]; then
86-
echo "Could not fetch the latest build number.";
87-
exit 1;
88-
fi
89-
90-
tmp=`mktemp -d`
91-
pushd $tmp > /dev/null
92-
echo "Downloading wasm-binaries.tbz2";
93-
curl -L -o wasm-binaries.tbz2 https://storage.googleapis.com/wasm-llvm/builds/linux/$BUILD_NUM/wasm-binaries.tbz2
94-
95-
declare -a binaries=("wasm2wat" "wat2wasm") # Default binaries
96-
if [ "$#" -ne 0 ]; then
97-
echo "Installing selected binaries.";
98-
binaries=("$@");
99-
else
100-
echo "Installing default binaries.";
101-
fi
102-
103-
for bin in "${binaries[@]}"
104-
do
105-
echo "Installing $bin into ~/.cargo/bin"
106-
tar -xvjf wasm-binaries.tbz2 wasm-install/bin/$bin > /dev/null
107-
cp -f wasm-install/bin/$bin ~/.cargo/bin/
108-
done
109-
popd > /dev/null
84+
sudo apt-get install -y wabt
11085
fi
11186

11287
echo ""
11388
echo "Run source ~/.cargo/env now to update environment."
11489
echo ""
90+
91+
source ~/.cargo/env
92+
wasm2wat --version
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
Β (0)