Skip to content

Commit

Permalink
feat: enable sign ext for wasm generated with rust 1.70 (#344)
Browse files Browse the repository at this point in the history
* fix: enable sign ext

This fix #338.
And, this will be replaced with wasmparser in feature version.
(CosmWasm/cosmwasm#1786)

* Test contract compiled with Rust 1.70.0

* chore: update some contract's lock files

* chore: update some contract's lock files

---------

Co-authored-by: Simon Warta <simon@warta.it>
  • Loading branch information
loloicci and webmaster128 authored Feb 7, 2024
1 parent b947b68 commit 62a4a24
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/burner/Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/crypto-verify/Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/cyberpunk/Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/floaty/Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/hackatom/Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/ibc-reflect-send/Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/ibc-reflect/Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/query-queue/Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/queue/Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/reflect/Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/staking/Cargo.lock

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

4 changes: 2 additions & 2 deletions contracts/voting-with-uuid/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 packages/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ clru = "0.4.0"
cosmwasm-std = { path = "../std", version = "1.1.9+0.8.1", default-features = false }
cosmwasm-crypto = { path = "../crypto", version = "1.1.9+0.8.1" }
hex = "0.4"
parity-wasm = "0.42"
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 @@ -69,6 +69,17 @@ docker run --rm -v "$(pwd)":/code \
&& cp artifacts/floaty.wasm packages/vm/testdata/floaty_1.0.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 @@ -257,6 +257,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 @@ -268,6 +269,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 62a4a24

Please sign in to comment.