Skip to content

Commit 779cabb

Browse files
authored
Merge branch 'main' into refcell/telemetry
2 parents f6062ff + 23c90cc commit 779cabb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2476
-827
lines changed

Cargo.lock

Lines changed: 83 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/common/src/asterisc/io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ pub struct AsteriscIO;
1010
/// See https://jborza.com/post/2021-05-11-riscv-linux-syscalls/
1111
///
1212
/// **Note**: This is not an exhaustive list of system calls available to the `client` program,
13-
/// only the ones necessary for the [BasicKernelInterface] trait implementation. If an extension trait for
14-
/// the [BasicKernelInterface] trait is created for the `asterisc` kernel, this list should be extended
15-
/// accordingly.
13+
/// only the ones necessary for the [BasicKernelInterface] trait implementation. If an extension
14+
/// trait for the [BasicKernelInterface] trait is created for the `asterisc` kernel, this list
15+
/// should be extended accordingly.
1616
#[repr(u32)]
1717
pub(crate) enum SyscallNumber {
1818
/// Sets the Exited and ExitCode states to true and $a0 respectively.

crates/common/src/asterisc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//! This module contains raw syscall bindings for the `riscv64gc` target architecture, as well as a high-level
2-
//! implementation of the [crate::BasicKernelInterface] trait for the `asterisc` kernel.
1+
//! This module contains raw syscall bindings for the `riscv64gc` target architecture, as well as a
2+
//! high-level implementation of the [crate::BasicKernelInterface] trait for the `asterisc` kernel.
33
44
pub(crate) mod io;
55
mod syscall;

crates/common/src/cannon/io.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::{cannon::syscall, BasicKernelInterface, FileDescriptor, RegisterSize};
22
use anyhow::{anyhow, Result};
33

4-
/// Concrete implementation of the [BasicKernelInterface] trait for the `MIPS32rel1` target architecture. Exposes a safe
5-
/// interface for performing IO operations within the FPVM kernel.
4+
/// Concrete implementation of the [BasicKernelInterface] trait for the `MIPS32rel1` target
5+
/// architecture. Exposes a safe interface for performing IO operations within the FPVM kernel.
66
#[derive(Debug)]
77
pub struct CannonIO;
88

@@ -11,9 +11,9 @@ pub struct CannonIO;
1111
/// See [Cannon System Call Specification](https://specs.optimism.io/experimental/fault-proof/cannon-fault-proof-vm.html#syscalls)
1212
///
1313
/// **Note**: This is not an exhaustive list of system calls available to the `client` program,
14-
/// only the ones necessary for the [BasicKernelInterface] trait implementation. If an extension trait for
15-
/// the [BasicKernelInterface] trait is created for the `Cannon` kernel, this list should be extended
16-
/// accordingly.
14+
/// only the ones necessary for the [BasicKernelInterface] trait implementation. If an extension
15+
/// trait for the [BasicKernelInterface] trait is created for the `Cannon` kernel, this list should
16+
/// be extended accordingly.
1717
#[repr(u32)]
1818
pub(crate) enum SyscallNumber {
1919
/// Sets the Exited and ExitCode states to true and $a0 respectively.

crates/common/src/cannon/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//! This module contains raw syscall bindings for the `MIPS32r2` target architecture, as well as a high-level
2-
//! implementation of the [crate::BasicKernelInterface] trait for the `Cannon` kernel.
1+
//! This module contains raw syscall bindings for the `MIPS32r2` target architecture, as well as a
2+
//! high-level implementation of the [crate::BasicKernelInterface] trait for the `Cannon` kernel.
33
44
pub(crate) mod io;
55
mod syscall;

crates/common/src/cannon/syscall.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ pub(crate) unsafe fn syscall1(n: RegisterSize, arg1: RegisterSize) -> RegisterSi
6161
options(nostack, preserves_flags)
6262
);
6363

64-
(err == 0)
65-
.then_some(ret)
66-
.unwrap_or_else(|| ret.wrapping_neg())
64+
(err == 0).then_some(ret).unwrap_or_else(|| ret.wrapping_neg())
6765
}
6866

6967
/// Issues a raw system call with 3 arguments. (e.g. read, write)
@@ -97,16 +95,12 @@ pub(crate) unsafe fn syscall3(
9795
options(nostack, preserves_flags)
9896
);
9997

100-
let value = (err == 0)
101-
.then_some(ret)
102-
.unwrap_or_else(|| ret.wrapping_neg());
98+
let value = (err == 0).then_some(ret).unwrap_or_else(|| ret.wrapping_neg());
10399

104-
(value <= -4096isize as RegisterSize)
105-
.then_some(value)
106-
.ok_or_else(|| {
107-
// Truncation of the error value is guaranteed to never occur due to
108-
// the above check. This is the same check that musl uses:
109-
// https://git.musl-libc.org/cgit/musl/tree/src/internal/syscall_ret.c?h=v1.1.15
110-
-(value as i32)
111-
})
100+
(value <= -4096isize as RegisterSize).then_some(value).ok_or_else(|| {
101+
// Truncation of the error value is guaranteed to never occur due to
102+
// the above check. This is the same check that musl uses:
103+
// https://git.musl-libc.org/cgit/musl/tree/src/internal/syscall_ret.c?h=v1.1.15
104+
-(value as i32)
105+
})
112106
}

crates/common/src/executor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
//! This module contains utilities for handling async functions in the no_std environment. This allows for usage of
2-
//! async/await syntax for futures in a single thread.
1+
//! This module contains utilities for handling async functions in the no_std environment. This
2+
//! allows for usage of async/await syntax for futures in a single thread.
33
44
use alloc::boxed::Box;
55
use core::{
66
future::Future,
77
task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
88
};
99

10-
/// This function busy waits on a future until it is ready. It uses a no-op waker to poll the future in a
11-
/// thread-blocking loop.
10+
/// This function busy waits on a future until it is ready. It uses a no-op waker to poll the future
11+
/// in a thread-blocking loop.
1212
pub fn block_on<T>(f: impl Future<Output = T>) -> T {
1313
let mut f = Box::pin(f);
1414

crates/common/src/io.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,19 @@ mod native_io {
8585
// forget the file descriptor so that the `Drop` impl doesn't close it.
8686
std::mem::forget(file);
8787

88-
n.try_into()
89-
.map_err(|_| anyhow!("Failed to convert usize to RegisterSize"))
88+
n.try_into().map_err(|_| anyhow!("Failed to convert usize to RegisterSize"))
9089
}
9190

9291
fn read(fd: FileDescriptor, buf: &mut [u8]) -> Result<RegisterSize> {
9392
let raw_fd: RegisterSize = fd.into();
9493
let mut file = unsafe { File::from_raw_fd(raw_fd as i32) };
95-
let n = file
96-
.read(buf)
97-
.map_err(|e| anyhow!("Error reading from file descriptor: {e}"))?;
94+
let n =
95+
file.read(buf).map_err(|e| anyhow!("Error reading from file descriptor: {e}"))?;
9896

9997
// forget the file descriptor so that the `Drop` impl doesn't close it.
10098
std::mem::forget(file);
10199

102-
n.try_into()
103-
.map_err(|_| anyhow!("Failed to convert usize to RegisterSize"))
100+
n.try_into().map_err(|_| anyhow!("Failed to convert usize to RegisterSize"))
104101
}
105102

106103
fn exit(code: RegisterSize) -> ! {

crates/common/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#![doc = include_str!("../README.md")]
2-
#![warn(
3-
missing_debug_implementations,
4-
missing_docs,
5-
unreachable_pub,
6-
rustdoc::all
7-
)]
2+
#![warn(missing_debug_implementations, missing_docs, unreachable_pub, rustdoc::all)]
83
#![deny(unused_must_use, rust_2018_idioms)]
94
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
105
#![cfg_attr(target_arch = "mips", feature(asm_experimental_arch))]

crates/common/src/malloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ pub mod global_allocator {
2020
/// This function is unsafe because the caller must ensure:
2121
/// * The allocator has not already been initialized.
2222
/// * The provided memory region must be valid, non-null, and not used by anything else.
23-
/// * After aligning the start and end addresses, the size of the heap must be > 0, or the function
24-
/// will panic.
23+
/// * After aligning the start and end addresses, the size of the heap must be > 0, or the
24+
/// function will panic.
2525
pub unsafe fn init_allocator(heap_start_addr: *mut u8, heap_size: usize) {
2626
ALLOCATOR.lock().init(heap_start_addr, heap_size)
2727
}

0 commit comments

Comments
 (0)