Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
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
8 changes: 7 additions & 1 deletion bin/programs/client/src/kona.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern crate alloc;
/// The size of the LRU cache in the oracle.
const ORACLE_LRU_SIZE: usize = 1024;

#[client_entry(0x77359400)]
#[client_entry(100_000_000)]
fn main() -> Result<()> {
#[cfg(feature = "tracing-subscriber")]
{
Expand Down Expand Up @@ -80,6 +80,12 @@ fn main() -> Result<()> {
output_root = output_root
);

kona_common::io::print(&alloc::format!(
"Successfully validated L2 block #{} with output root {}\n",
number,
output_root
));

Ok::<_, anyhow::Error>(())
})
}
30 changes: 21 additions & 9 deletions crates/common/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ mod native_io {
let cursor_entry = cursor_entry_lock.entry(raw_fd).or_insert(0);

// Reset the cursor back to before the data we just wrote for the reader's consumption.
file.seek(SeekFrom::Start(*cursor_entry as u64))
.map_err(|e| anyhow!("Failed to reset file cursor to 0: {e}"))?;
// This is a best-effort operation, and may not work for all file descriptors.
let _ = file.seek(SeekFrom::Start(*cursor_entry as u64));

file.write_all(buf)
.map_err(|e| anyhow!("Error writing to buffer to file descriptor: {e}"))?;
Expand All @@ -103,16 +103,28 @@ mod native_io {
let raw_fd: usize = fd.into();
let mut file = unsafe { File::from_raw_fd(raw_fd as i32) };

let mut cursor_entry_lock = READ_CURSOR.lock();
let cursor_entry = cursor_entry_lock.entry(raw_fd).or_insert(0);
// If the file is seekable, we need to seek to the cursor position before reading.
// If not, it is likely a pipe or a socket. Read as normal.
let n = if file.stream_position().is_ok() {
let mut cursor_entry_lock = READ_CURSOR.lock();
let cursor_entry = cursor_entry_lock.entry(raw_fd).or_insert(0);

file.seek(SeekFrom::Start(*cursor_entry as u64)).map_err(|e| {
anyhow!(
"Error seeking to cursor position {cursor_entry} in file descriptor: {e}"
)
})?;

file.seek(SeekFrom::Start(*cursor_entry as u64))
.map_err(|e| anyhow!("Failed to reset file cursor to 0: {e}"))?;
let n = file
.read(buf)
.map_err(|e| anyhow!("Error reading from file descriptor: {e}"))?;

let n =
file.read(buf).map_err(|e| anyhow!("Error reading from file descriptor: {e}"))?;
*cursor_entry += n;

*cursor_entry += n;
n
} else {
file.read(buf).map_err(|e| anyhow!("Error reading from file descriptor: {e}"))?
};

std::mem::forget(file);

Expand Down