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

Standard library support for guests #759

Open
wants to merge 89 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
53db5a5
Hints in linker
matthiasgoergens Dec 5, 2024
612befb
Snapshot
matthiasgoergens Dec 6, 2024
efde5b3
Clean up
matthiasgoergens Dec 6, 2024
d7949a6
Snapshot
matthiasgoergens Dec 6, 2024
e002be2
Clean up
matthiasgoergens Dec 6, 2024
8a4906f
Clean up
matthiasgoergens Dec 6, 2024
b789f43
Clean up
matthiasgoergens Dec 6, 2024
d0af9d8
Clean up
matthiasgoergens Dec 6, 2024
8333331
Remove commented out code
matthiasgoergens Dec 6, 2024
8597909
Clarify comment
matthiasgoergens Dec 6, 2024
1b14291
taplo fmt
matthiasgoergens Dec 6, 2024
f441913
Implement TODOs for Harvard Architecture PR
matthiasgoergens Dec 9, 2024
1f0c4c1
Merge remote-tracking branch 'origin/master' into matthias/harvard-ar…
matthiasgoergens Dec 9, 2024
80dcb44
Remove unimplemented ebreak
matthiasgoergens Dec 9, 2024
50806cb
Merge remote-tracking branch 'origin/master' into matthias/harvard-ar…
matthiasgoergens Dec 9, 2024
a4a37ad
Merge branch 'master' into matthias/harvard-architecture-todos
matthiasgoergens Dec 10, 2024
de95576
Merge branch 'master' into matthias/harvard-architecture-todos
matthiasgoergens Dec 10, 2024
7f67dae
Merge remote-tracking branch 'origin/master' into matthias/ceno_host
matthiasgoergens Dec 10, 2024
9280a9f
Clean up
matthiasgoergens Dec 10, 2024
1ac5c7c
Fix
matthiasgoergens Dec 10, 2024
c00a5cb
Expect
matthiasgoergens Dec 10, 2024
2b2a48c
Simpler
matthiasgoergens Dec 10, 2024
1ba9692
Simpler
matthiasgoergens Dec 10, 2024
73b4779
Simplify guest's memory allocator
matthiasgoergens Dec 10, 2024
35bacc3
Explain
matthiasgoergens Dec 10, 2024
c27881f
Explain
matthiasgoergens Dec 10, 2024
ef10c0a
Minimise diff
matthiasgoergens Dec 10, 2024
e46fd05
Fix
matthiasgoergens Dec 10, 2024
fecac1a
Minimise diff
matthiasgoergens Dec 10, 2024
42da8da
Doc
matthiasgoergens Dec 10, 2024
8fdb803
Don't hardcode the size of the region
matthiasgoergens Dec 10, 2024
1e16d24
Simpler
matthiasgoergens Dec 10, 2024
2f78d46
Deduplicate
matthiasgoergens Dec 10, 2024
39280bf
Done TODO
matthiasgoergens Dec 10, 2024
31805f6
Strings
matthiasgoergens Dec 10, 2024
5091d3d
Just for fun
matthiasgoergens Dec 10, 2024
10de0da
Simpler
matthiasgoergens Dec 10, 2024
f25139b
Merge remote-tracking branch 'origin/master' into matthias/harvard-ar…
matthiasgoergens Dec 12, 2024
80c8139
Merge remote-tracking branch 'origin/master' into matthias/guest-rust…
matthiasgoergens Dec 12, 2024
3c095fd
Snapshot
matthiasgoergens Dec 12, 2024
df363df
Merge branch 'matthias/harvard-architecture-todos' into matthias/stdl…
matthiasgoergens Dec 12, 2024
f512d90
Remove crap
matthiasgoergens Dec 12, 2024
31e3077
Don't need riscv crate
matthiasgoergens Dec 12, 2024
ee91b67
Merge branch 'matthias/simplify-allocator' into matthias/stdlib-with-rrs
matthiasgoergens Dec 12, 2024
e19ddbb
Unimplemented
matthiasgoergens Dec 12, 2024
355f23e
Merge branch 'master' into matthias/harvard-architecture-todos
matthiasgoergens Dec 12, 2024
572cd22
Rename as suggested
matthiasgoergens Dec 12, 2024
02f0828
Move as suggested
matthiasgoergens Dec 12, 2024
0349fa7
formatting
matthiasgoergens Dec 12, 2024
887a143
Instructions
matthiasgoergens Dec 12, 2024
df7f713
Panic less
matthiasgoergens Dec 12, 2024
a4d7a34
Remove push
matthiasgoergens Dec 12, 2024
b1cfa65
Remove Emulator
matthiasgoergens Dec 12, 2024
9bb2523
Merge remote-tracking branch 'origin/master' into matthias/saner
matthiasgoergens Dec 12, 2024
8556d02
Merge branch 'matthias/harvard-architecture-todos' into matthias/saner
matthiasgoergens Dec 12, 2024
1443741
Just for stdlib
matthiasgoergens Dec 12, 2024
bc3dba4
Merge remote-tracking branch 'origin/master' into matthias/ceno_host
matthiasgoergens Dec 13, 2024
ea77dbd
Show hint example
matthiasgoergens Dec 13, 2024
c438b43
Formatting
matthiasgoergens Dec 13, 2024
9a746bc
Remove pedantic
matthiasgoergens Dec 13, 2024
9d76268
Use bool as test case
matthiasgoergens Dec 13, 2024
863f3ad
Suggestion
matthiasgoergens Dec 13, 2024
4d8f924
Reshuffle crates
matthiasgoergens Dec 13, 2024
0d2e317
Merge remote-tracking branch 'origin/master' into matthias/flat-struc…
matthiasgoergens Dec 13, 2024
8b6c167
Merge remote-tracking branch 'origin/master' into matthias/ceno_host
matthiasgoergens Dec 13, 2024
5a95f70
Fix
matthiasgoergens Dec 13, 2024
77df864
Merge branch 'matthias/flat-structure-again' into matthias/ceno_host
matthiasgoergens Dec 13, 2024
4d43dca
Merge remote-tracking branch 'origin/master' into matthias/ceno_host
matthiasgoergens Dec 14, 2024
be90017
Merge branch 'matthias/ceno_host' into matthias/guest-rust-stdlib
matthiasgoergens Dec 14, 2024
58cc7f0
Merge branch 'matthias/guest-rust-stdlib' into matthias/stdlib-with-rrs
matthiasgoergens Dec 14, 2024
68e7e6d
Merge branch 'matthias/stdlib-with-rrs' into matthias/saner
matthiasgoergens Dec 14, 2024
5591e56
Remove `riscv` dependency
matthiasgoergens Dec 14, 2024
9d2e943
Merge branch 'matthias/fewer-dependencies' into matthias/ceno_host_wi…
matthiasgoergens Dec 14, 2024
df0ab05
Restore cargo.lock
matthiasgoergens Dec 14, 2024
6e8e04c
Minimise diff
matthiasgoergens Dec 14, 2024
ce93381
Merge branch 'matthias/ceno_host_with_small_additions' into matthias/…
matthiasgoergens Dec 14, 2024
cc94347
Merge branch 'matthias/simplify-allocator' into matthias/ceno_host_wi…
matthiasgoergens Dec 14, 2024
32b4800
Merge branch 'matthias/ceno_host_with_small_additions' into matthias/…
matthiasgoergens Dec 14, 2024
6342e37
Minimise diff, clean up
matthiasgoergens Dec 14, 2024
4503dba
Minimise diff
matthiasgoergens Dec 14, 2024
369098e
Standard library support
matthiasgoergens Dec 14, 2024
a105e43
json target
matthiasgoergens Dec 14, 2024
804ce19
Pseudo instructions
matthiasgoergens Dec 14, 2024
32bb0ed
Fix
matthiasgoergens Dec 14, 2024
8974df0
Merge remote-tracking branch 'origin/master' into matthias/saner
matthiasgoergens Dec 14, 2024
c24612a
Mostly works
matthiasgoergens Dec 14, 2024
38f4065
Panic
matthiasgoergens Dec 14, 2024
a6f81a0
Precise
matthiasgoergens Dec 14, 2024
29e758e
Need sources
matthiasgoergens Dec 14, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ report.json
table_cache_dev_*
.DS_Store
.env
proptest-regressions/
158 changes: 149 additions & 9 deletions Cargo.lock

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

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[workspace]
exclude = ["guest"]
exclude = ["ceno_rt", "examples"]
members = [
"ceno_emul",
"ceno_host",
"ceno_zkvm",
"examples-builder",
"mpcs",
"multilinear_extensions",
"poseidon",
"sumcheck",
"transcript",
"ceno_zkvm",
"poseidon",
]
resolver = "2"

Expand All @@ -22,6 +23,7 @@ repository = "https://github.com/scroll-tech/ceno"
version = "0.1.0"

[workspace.dependencies]
anyhow = { version = "1.0", default-features = false }
ark-std = "0.4"
cfg-if = "1.0"
criterion = { version = "0.5", features = ["html_reports"] }
Expand Down
5 changes: 1 addition & 4 deletions ceno_emul/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository.workspace = true
version.workspace = true

[dependencies]
anyhow = { version = "1.0", default-features = false }
anyhow.workspace = true
elf = "0.7"
itertools.workspace = true
num-derive.workspace = true
Expand All @@ -20,9 +20,6 @@ strum.workspace = true
strum_macros.workspace = true
tracing.workspace = true

[dev-dependencies]
ceno-examples = { path = "../examples-builder" }

[features]
default = ["forbid_overflow"]
forbid_overflow = []
13 changes: 13 additions & 0 deletions ceno_emul/src/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use std::{
fmt,
iter::Step,
ops::{self, Range},
};

Expand Down Expand Up @@ -106,6 +107,18 @@ impl WordAddr {
}
}

impl Step for WordAddr {
fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
u32::steps_between(&start.0, &end.0)
}
fn forward_checked(start: Self, count: usize) -> Option<Self> {
u32::forward_checked(start.0, count).map(Self)
}
fn backward_checked(start: Self, count: usize) -> Option<Self> {
u32::backward_checked(start.0, count).map(Self)
}
}

impl fmt::Debug for ByteAddr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "0x{:08x}", self.0)
Expand Down
32 changes: 32 additions & 0 deletions ceno_emul/src/host_utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::iter::from_fn;

use crate::{ByteAddr, EmuContext, VMState, WordAddr};

const WORD_SIZE: usize = 4;
const INFO_OUT_ADDR: WordAddr = ByteAddr(0xC000_0000).waddr();

pub fn read_all_messages(state: &VMState) -> Vec<String> {
let mut offset: WordAddr = WordAddr::from(0);
from_fn(move || match read_message(state, offset) {
out if out.is_empty() => None,
out => {
offset += out.len().div_ceil(WORD_SIZE) as u32 + 1;
Some(out)
}
})
.collect()
}

fn read_message(state: &VMState, offset: WordAddr) -> String {
let out_addr = INFO_OUT_ADDR + offset;
let byte_len = state.peek_memory(out_addr) as usize;

String::from_utf8_lossy(
&(out_addr + 1_usize..)
.map(|memory| state.peek_memory(memory))
.flat_map(u32::to_le_bytes)
.take(byte_len)
.collect::<Vec<_>>(),
)
.to_string()
}
2 changes: 2 additions & 0 deletions ceno_emul/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![deny(clippy::cargo)]
#![feature(step_trait)]
mod addr;
pub use addr::*;

Expand All @@ -20,3 +21,4 @@ mod elf;
pub use elf::Program;

pub mod disassemble;
pub mod host_utils;
Loading