Skip to content

Commit

Permalink
Merge pull request #1743 from CosmWasm/sign_ext
Browse files Browse the repository at this point in the history
Allow sign extension Wasm opcodes in static validation
  • Loading branch information
webmaster128 authored Jun 26, 2023
2 parents 2530911 + 54f32f4 commit 50d0b6f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ and this project adheres to
- cosmwasm-vm: Add `Cache::save_wasm_unchecked` to save Wasm blobs that have
been checked before. This is useful for state-sync where we know the Wasm code
was checked when it was first uploaded. ([#1635])
- cosmwasm-vm: Allow sign extension Wasm opcodes in static validation. This
allows contracts to be compiled with Rust 1.70.0 and above. ([#1727])

[#1635]: https://github.com/CosmWasm/cosmwasm/pull/1635
[#1647]: https://github.com/CosmWasm/cosmwasm/pull/1647
[#1684]: https://github.com/CosmWasm/cosmwasm/pull/1684
[#1687]: https://github.com/CosmWasm/cosmwasm/pull/1687
[#1727]: https://github.com/CosmWasm/cosmwasm/issues/1727

### Changed

Expand Down
2 changes: 1 addition & 1 deletion packages/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ crc32fast = "1.3.2"
cosmwasm-std = { path = "../std", version = "1.2.7", default-features = false }
cosmwasm-crypto = { path = "../crypto", version = "1.2.7" }
hex = "0.4"
parity-wasm = "0.45"
parity-wasm = { version = "0.45", features = ["sign_ext"] }
schemars = "0.8.3"
serde = { version = "1.0.103", default-features = false, features = ["derive", "alloc"] }
serde_json = "1.0.40"
Expand Down
11 changes: 11 additions & 0 deletions packages/vm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ docker run --rm -v "$(pwd)":/code \
&& cp artifacts/floaty.wasm packages/vm/testdata/floaty_1.2.wasm
```

The `cyberpunk_rust170.wasm` for
https://github.com/CosmWasm/cosmwasm/issues/1727 is built as follows
(non-reproducible):

```sh
cd contracts/cyberpunk
rm -r target
RUSTFLAGS='-C link-arg=-s' cargo build --release --lib --target wasm32-unknown-unknown --locked
cp target/wasm32-unknown-unknown/release/cyberpunk.wasm ../../packages/vm/testdata/cyberpunk_rust170.wasm
```

## Testing

By default, this repository is built and tested with the singlepass backend. You
Expand Down
7 changes: 7 additions & 0 deletions packages/vm/src/compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ mod tests {
static CONTRACT_0_14: &[u8] = include_bytes!("../testdata/hackatom_0.14.wasm");
static CONTRACT_0_15: &[u8] = include_bytes!("../testdata/hackatom_0.15.wasm");
static CONTRACT: &[u8] = include_bytes!("../testdata/hackatom.wasm");
static CONTRACT_RUST_170: &[u8] = include_bytes!("../testdata/cyberpunk_rust170.wasm");

fn default_capabilities() -> HashSet<String> {
["staking".to_string()].into_iter().collect()
Expand All @@ -274,6 +275,12 @@ mod tests {
check_wasm(CONTRACT, &default_capabilities()).unwrap();
}

#[test]
fn check_wasm_allows_sign_ext() {
// See https://github.com/CosmWasm/cosmwasm/issues/1727
check_wasm(CONTRACT_RUST_170, &default_capabilities()).unwrap();
}

#[test]
fn check_wasm_old_contract() {
match check_wasm(CONTRACT_0_15, &default_capabilities()) {
Expand Down
Binary file added packages/vm/testdata/cyberpunk_rust170.wasm
Binary file not shown.

0 comments on commit 50d0b6f

Please sign in to comment.