Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sign extension Wasm opcodes in static validation #1743

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.