Skip to content

Commit

Permalink
Update to rust 1.69.0 (risc0#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
mothran authored May 10, 2023
1 parent d83c7fe commit 364e3a6
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 15 deletions.
6 changes: 3 additions & 3 deletions risc0/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ struct ZipMapEntry {
// Sources for standard library, and where they should be mapped to.
const RUST_LIB_MAP : &[ZipMapEntry] = &[
ZipMapEntry {
filename: "53bbc8fc2afb2e10e3a90d7bf188bfd6598374ab.zip",
zip_url: "https://github.com/risc0/rust/archive/53bbc8fc2afb2e10e3a90d7bf188bfd6598374ab.zip",
src_prefix: "rust-53bbc8fc2afb2e10e3a90d7bf188bfd6598374ab/library",
filename: "7cef530cde6f761aa49665e2d98f32248b2a0d58.zip",
zip_url: "https://github.com/risc0/rust/archive/7cef530cde6f761aa49665e2d98f32248b2a0d58.zip",
src_prefix: "rust-7cef530cde6f761aa49665e2d98f32248b2a0d58/library",
dst_prefix: "library"
},
ZipMapEntry {
Expand Down
7 changes: 6 additions & 1 deletion risc0/zkvm/methods/guest/src/bin/multi_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use risc0_zkvm::{
};
use risc0_zkvm_methods::multi_test::{MultiTestSpec, SYS_MULTI_TEST};
use risc0_zkvm_platform::{
fileno,
fileno, memory,
syscall::{bigint, sys_bigint, sys_read, sys_write},
};

Expand Down Expand Up @@ -191,5 +191,10 @@ pub fn main() {
let f = black_box(1.0_f32);
black_box(f.min(1.0));
}
MultiTestSpec::Oom => {
use core::hint::black_box;
let len = memory::HEAP.len_bytes() + 1;
let _data = black_box(vec![0; len]);
}
}
}
1 change: 1 addition & 0 deletions risc0/zkvm/methods/src/multi_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub enum MultiTestSpec {
cycles: u32,
},
LibM,
Oom,
}

declare_syscall!(pub SYS_MULTI_TEST);
23 changes: 22 additions & 1 deletion risc0/zkvm/src/exec/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,17 @@ fn trace() {
value: 0x08000000,
}] = window
{
assert_eq!(cycle1 + 1, cycle2, "li should take 1 cycles: {:#?}", window);
// Note: it's possible that these instructions could lie between page
// boundaries. If that is the case, it means that the difference between cycle2
// and cycle1 could be multiples of page-in, which takes up 1094 cycles. Once we
// figure out a way to get reproducible builds, we should restrict the
// difference of cycles to a single number rather than taking the mod.
assert_eq!(
(cycle2 - cycle1) % 1094,
1,
"li should take multiples of page-in cycles + 1: {:#?}",
window
);
assert_eq!(
pc1 + WORD_SIZE as u32,
pc2,
Expand All @@ -477,3 +487,14 @@ fn trace() {
value: 1337
}));
}

#[test]
fn oom() {
let spec = to_vec(&MultiTestSpec::Oom).unwrap();
let env = ExecutorEnv::builder().add_input(&spec).build();
let mut exec = Executor::from_elf(env, MULTI_TEST_ELF).unwrap();
let err = exec.run().err().unwrap();
assert!(err
.to_string()
.contains("Guest panicked: panicked at 'Out of memory!'"));
}
1 change: 0 additions & 1 deletion risc0/zkvm/src/guest/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ unsafe impl GlobalAlloc for BumpPointerAlloc {
.pad_to_align()
.size()
/ WORD_SIZE;

syscall::sys_alloc_words(nwords) as *mut u8
}

Expand Down
5 changes: 0 additions & 5 deletions risc0/zkvm/src/guest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ mod handlers {
let msg = ::alloc::format!("{}", panic_info);
crate::guest::abort(&msg)
}

#[alloc_error_handler]
fn alloc_fault(_layout: Layout) -> ! {
crate::guest::abort("Memory allocation failure")
}
}

/// Used for defining a main entrypoint.
Expand Down
1 change: 0 additions & 1 deletion risc0/zkvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#![doc = include_str!("../README.md")]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc_error_handler))]
#![deny(rustdoc::broken_intra_doc_links)]
#![deny(missing_docs)]

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2022-10-28"
channel = "nightly-2023-03-06"
components = [ "rustfmt", "rust-src" ]
targets = [ "wasm32-unknown-unknown" ]
profile = "minimal"
2 changes: 1 addition & 1 deletion templates/bonsai/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2022-10-28"
channel = "nightly-2023-03-06"
components = [ "rustfmt", "rust-src" ]
profile = "minimal"
2 changes: 1 addition & 1 deletion templates/rust-starter/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2022-10-28"
channel = "nightly-2023-03-06"
components = [ "rustfmt", "rust-src" ]
profile = "minimal"

0 comments on commit 364e3a6

Please sign in to comment.