Skip to content

Commit

Permalink
Merge pull request #452 from CosmWasm/update-rust-ci
Browse files Browse the repository at this point in the history
Update minimal rust version
  • Loading branch information
chipshort committed Aug 28, 2023
2 parents 0082196 + 6d67073 commit 5b0a875
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 33 deletions.
24 changes: 12 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
# All checks on the codebase that can run in parallel to build_shared_library
libwasmvm_sanity:
docker:
- image: cimg/rust:1.65.0
- image: cimg/rust:1.67.0
steps:
- checkout
- run:
Expand All @@ -18,8 +18,8 @@ jobs:
command: rustup component add clippy rustfmt
- restore_cache:
keys:
- cargocache-v3-libwasmvm_sanity-rust:1.65.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.65.0-
- cargocache-v3-libwasmvm_sanity-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.67.0-
- run:
name: Ensure libwasmvm/bindings.h is up-to-date
working_directory: libwasmvm
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-libwasmvm_sanity-rust:1.65.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-libwasmvm_sanity-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}

# This performs all the Rust debug builds on Windows. Similar to libwasmvm_sanity
# but avoids duplicating things that are not platform dependent.
Expand All @@ -84,15 +84,15 @@ jobs:
command: |
set -o errexit
curl -sS --output rustup-init.exe https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.65.0 -y
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.67.0 -y
echo 'export PATH="$PATH;$USERPROFILE/.cargo/bin"' >> "$BASH_ENV"
- run:
name: Show Rust version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cachev4-libwasmvm_sanity_windows-rust:1.65.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cachev4-libwasmvm_sanity_windows-rust:1.65.0-
- cachev4-libwasmvm_sanity_windows-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cachev4-libwasmvm_sanity_windows-rust:1.67.0-
- run:
name: Run unit tests
working_directory: libwasmvm
Expand All @@ -104,7 +104,7 @@ jobs:
- libwasmvm/target/debug/.fingerprint
- libwasmvm/target/debug/build
- libwasmvm/target/debug/deps
key: cachev4-libwasmvm_sanity_windows-rust:1.65.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cachev4-libwasmvm_sanity_windows-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}

libwasmvm_audit:
docker:
Expand Down Expand Up @@ -219,16 +219,16 @@ jobs:

build_shared_library:
docker:
- image: cimg/rust:1.65.0
- image: cimg/rust:1.67.0
steps:
- checkout
- run:
name: Show version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-v3-build_shared_library-rust:1.65.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-build_shared_library-rust:1.65.0-
- cargocache-v3-build_shared_library-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-build_shared_library-rust:1.67.0-
- run:
name: Create release build of libwasmvm
command: make build-rust
Expand All @@ -245,7 +245,7 @@ jobs:
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-build_shared_library-rust:1.65.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-build_shared_library-rust:1.67.0-{{ checksum "libwasmvm/Cargo.lock" }}

# Test the Go project
wasmvm_test:
Expand Down
2 changes: 1 addition & 1 deletion docs/COMPILER_VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ We currently use the following version:
| Type | Rust version | Note |
| ------------------------ | ------------ | --------------------------------- |
| Production Rust compiler | 1.69.0 | Builders version 0016 |
| Min Rust compiler | 1.65.0 | Supports builder versions >= 0014 |
| Min Rust compiler | 1.67.0 | Supports builder versions >= 0015 |
| Tooling Rust compiler | 1.69.0 | |
2 changes: 1 addition & 1 deletion libwasmvm/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl BackendApi for GoApi {
let gas_info = GasInfo::with_cost(used_gas);

// return complete error message (reading from buffer for GoError::Other)
let default = || format!("Failed to canonicalize the address: {}", human);
let default = || format!("Failed to canonicalize the address: {human}");
unsafe {
if let Err(err) = go_error.into_result(error_msg, default) {
return (Err(err), gas_info);
Expand Down
16 changes: 8 additions & 8 deletions libwasmvm/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub extern "C" fn init_cache(
)
})
.unwrap_or_else(|err| {
eprintln!("Panic in do_init_cache: {:?}", err);
eprintln!("Panic in do_init_cache: {err:?}");
Err(Error::panic())
});
handle_c_error_ptr(r, error_msg) as *mut cache_t
Expand Down Expand Up @@ -93,7 +93,7 @@ pub extern "C" fn save_wasm(
let r = match to_cache(cache) {
Some(c) => catch_unwind(AssertUnwindSafe(move || do_save_wasm(c, wasm, unchecked)))
.unwrap_or_else(|err| {
eprintln!("Panic in do_save_wasm: {:?}", err);
eprintln!("Panic in do_save_wasm: {err:?}");
Err(Error::panic())
}),
None => Err(Error::unset_arg(CACHE_ARG)),
Expand Down Expand Up @@ -125,7 +125,7 @@ pub extern "C" fn remove_wasm(
let r = match to_cache(cache) {
Some(c) => catch_unwind(AssertUnwindSafe(move || do_remove_wasm(c, checksum)))
.unwrap_or_else(|err| {
eprintln!("Panic in do_remove_wasm: {:?}", err);
eprintln!("Panic in do_remove_wasm: {err:?}");
Err(Error::panic())
}),
None => Err(Error::unset_arg(CACHE_ARG)),
Expand Down Expand Up @@ -154,7 +154,7 @@ pub extern "C" fn load_wasm(
let r = match to_cache(cache) {
Some(c) => catch_unwind(AssertUnwindSafe(move || do_load_wasm(c, checksum)))
.unwrap_or_else(|err| {
eprintln!("Panic in do_load_wasm: {:?}", err);
eprintln!("Panic in do_load_wasm: {err:?}");
Err(Error::panic())
}),
None => Err(Error::unset_arg(CACHE_ARG)),
Expand Down Expand Up @@ -184,7 +184,7 @@ pub extern "C" fn pin(
let r = match to_cache(cache) {
Some(c) => {
catch_unwind(AssertUnwindSafe(move || do_pin(c, checksum))).unwrap_or_else(|err| {
eprintln!("Panic in do_pin: {:?}", err);
eprintln!("Panic in do_pin: {err:?}");
Err(Error::panic())
})
}
Expand Down Expand Up @@ -214,7 +214,7 @@ pub extern "C" fn unpin(
let r = match to_cache(cache) {
Some(c) => {
catch_unwind(AssertUnwindSafe(move || do_unpin(c, checksum))).unwrap_or_else(|err| {
eprintln!("Panic in do_unpin: {:?}", err);
eprintln!("Panic in do_unpin: {err:?}");
Err(Error::panic())
})
}
Expand Down Expand Up @@ -279,7 +279,7 @@ pub extern "C" fn analyze_code(
let r = match to_cache(cache) {
Some(c) => catch_unwind(AssertUnwindSafe(move || do_analyze_code(c, checksum)))
.unwrap_or_else(|err| {
eprintln!("Panic in do_analyze_code: {:?}", err);
eprintln!("Panic in do_analyze_code: {err:?}");
Err(Error::panic())
}),
None => Err(Error::unset_arg(CACHE_ARG)),
Expand Down Expand Up @@ -357,7 +357,7 @@ pub extern "C" fn get_metrics(
let r = match to_cache(cache) {
Some(c) => {
catch_unwind(AssertUnwindSafe(move || do_get_metrics(c))).unwrap_or_else(|err| {
eprintln!("Panic in do_get_metrics: {:?}", err);
eprintln!("Panic in do_get_metrics: {err:?}");
Err(Error::panic())
})
}
Expand Down
4 changes: 2 additions & 2 deletions libwasmvm/src/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ fn call_2_args(
)
}))
.unwrap_or_else(|err| {
eprintln!("Panic in do_call_2_args: {:?}", err);
eprintln!("Panic in do_call_2_args: {err:?}");
Err(Error::panic())
}),
None => Err(Error::unset_arg(CACHE_ARG)),
Expand Down Expand Up @@ -519,7 +519,7 @@ fn call_3_args(
)
}))
.unwrap_or_else(|err| {
eprintln!("Panic in do_call_3_args: {:?}", err);
eprintln!("Panic in do_call_3_args: {err:?}");
Err(Error::panic())
}),
None => Err(Error::unset_arg(CACHE_ARG)),
Expand Down
2 changes: 1 addition & 1 deletion libwasmvm/src/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Querier for GoQuerier {
let bin_result: Vec<u8> = output.unwrap_or_default();
let result = serde_json::from_slice(&bin_result).or_else(|e| {
Ok(SystemResult::Err(SystemError::InvalidResponse {
error: format!("Parsing Go response: {}", e),
error: format!("Parsing Go response: {e}"),
response: bin_result.into(),
}))
});
Expand Down
6 changes: 2 additions & 4 deletions libwasmvm/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ pub fn assert_approx_eq_impl<U: Into<Uint128>>(
if rel_diff > max_rel_diff {
match panic_msg {
Some(panic_msg) => panic!(
"assertion failed: `(left ≈ right)`\nleft: {}\nright: {}\nrelative difference: {}\nmax allowed relative difference: {}\n: {}",
left, right, rel_diff, max_rel_diff, panic_msg
"assertion failed: `(left ≈ right)`\nleft: {left}\nright: {right}\nrelative difference: {rel_diff}\nmax allowed relative difference: {max_rel_diff}\n: {panic_msg}"
),
None => panic!(
"assertion failed: `(left ≈ right)`\nleft: {}\nright: {}\nrelative difference: {}\nmax allowed relative difference: {}\n",
left, right, rel_diff, max_rel_diff
"assertion failed: `(left ≈ right)`\nleft: {left}\nright: {right}\nrelative difference: {rel_diff}\nmax allowed relative difference: {max_rel_diff}\n"
),
}
}
Expand Down
8 changes: 4 additions & 4 deletions libwasmvm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn handle_cpu_loop_with_cache() {
let res = call_instantiate_raw(&mut instance, &raw_env, &raw_info, b"{}");
let gas_left = instance.get_gas_left();
let gas_used = options.gas_limit - gas_left;
println!("Init gas left: {}, used: {}", gas_left, gas_used);
println!("Init gas left: {gas_left}, used: {gas_used}");
assert!(res.is_ok());
let backend = instance.recycle().unwrap();

Expand All @@ -52,7 +52,7 @@ fn handle_cpu_loop_with_cache() {
let res = call_execute_raw(&mut instance, &raw_env, &raw_info, raw_msg);
let gas_left = instance.get_gas_left();
let gas_used = options.gas_limit - gas_left;
println!("Handle gas left: {}, used: {}", gas_left, gas_used);
println!("Handle gas left: {gas_left}, used: {gas_used}");
assert!(res.is_err());
assert_eq!(gas_left, 0);
let _ = instance.recycle();
Expand All @@ -71,15 +71,15 @@ fn handle_cpu_loop_no_cache() {
let res = call_instantiate_raw(&mut instance, &raw_env, &raw_info, b"{}");
let gas_left = instance.get_gas_left();
let gas_used = gas_limit - gas_left;
println!("Init gas left: {}, used: {}", gas_left, gas_used);
println!("Init gas left: {gas_left}, used: {gas_used}");
assert!(res.is_ok());

// execute
let raw_msg = br#"{"cpu_loop":{}}"#;
let res = call_execute_raw(&mut instance, &raw_env, &raw_info, raw_msg);
let gas_left = instance.get_gas_left();
let gas_used = gas_limit - gas_left;
println!("Handle gas left: {}, used: {}", gas_left, gas_used);
println!("Handle gas left: {gas_left}, used: {gas_used}");
assert!(res.is_err());
assert_eq!(gas_left, 0);
}

0 comments on commit 5b0a875

Please sign in to comment.