Skip to content

Commit

Permalink
HW CI: Try to fix wasm2wat & wat2wasm usage: Vol. 3
Browse files Browse the repository at this point in the history
  • Loading branch information
assafmo committed Aug 9, 2023
1 parent 6024d24 commit eadac6e
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ contract_with_floats.wasm: $(Rust_Crate_Source)
rm -f ./contract_with_floats.wasm
mv -f ./target/wasm32-unknown-unknown/release/test_contract.wasm ./contract_with_floats.wasm

# Older versions of wabt had the --enable-sign-extension flag, while on newer
# versions it's turned on by default and the flag is replaced with --disable-sign-extension
WASM2WAT_OPTS := $(shell wasm2wat --help | grep -Po '\-\-enable-sign-extension')
WAT2WAT_OPTS := $(shell wat2wasm --help | grep -Po '\-\-enable-sign-extension')

# Create a wasm with more than 192 memory pages (fails in init, handle & query, this is our limit)
# https://github.com/scrtlabs/SecretNetwork/blob/9eef8591b2c04c586ceee12f424b92062598123e/cosmwasm/packages/wasmi-runtime/src/wasm/memory.rs#L39
too-high-initial-memory.wasm: contract.wasm
wasm2wat --enable-all ./contract.wasm | perl -pe 's/\(memory \(;0;\) \d+\)/(memory (;0;) 193)/' > /tmp/too-high-initial-memory.wat
wat2wasm --enable-all /tmp/too-high-initial-memory.wat -o ./too-high-initial-memory.wasm
wasm2wat $(WASM2WAT_OPTS) ./contract.wasm | perl -pe 's/\(memory \(;0;\) \d+\)/(memory (;0;) 193)/' > /tmp/too-high-initial-memory.wat
wat2wasm $(WAT2WAT_OPTS) /tmp/too-high-initial-memory.wat -o ./too-high-initial-memory.wasm

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

setup:
apt-get install wabt
Expand Down

0 comments on commit eadac6e

Please sign in to comment.