Skip to content

Commit d392f01

Browse files
committed
fix: enforce deferred proof verification
1 parent 5f75ca0 commit d392f01

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

crates/core/executor/src/executor.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,15 @@ pub enum ExecutionError {
253253
/// The unconstrained cycle limit was exceeded.
254254
#[error("unconstrained cycle limit exceeded")]
255255
UnconstrainedCycleLimitExceeded(u64),
256+
257+
/// Not all deferred proofs were verified during execution.
258+
#[error("unread deferred proofs: {actual}/{expected}")]
259+
UnreadDeferredProofs {
260+
/// The total number of deferred proofs that were provided.
261+
expected: usize,
262+
/// The actual number of deferred proofs that were verified.
263+
actual: usize,
264+
},
256265
}
257266

258267
impl<'a> Executor<'a> {
@@ -2059,7 +2068,7 @@ impl<'a> Executor<'a> {
20592068
let public_values = self.record.public_values;
20602069

20612070
if done {
2062-
self.postprocess();
2071+
self.postprocess()?;
20632072

20642073
// Push the remaining execution record with memory initialize & finalize events.
20652074
self.bump_record();
@@ -2108,7 +2117,7 @@ impl<'a> Executor<'a> {
21082117
Ok(done)
21092118
}
21102119

2111-
fn postprocess(&mut self) {
2120+
fn postprocess(&mut self) -> Result<(), ExecutionError> {
21122121
// Flush remaining stdout/stderr
21132122
for (fd, buf) in &self.io_buf {
21142123
if !buf.is_empty() {
@@ -2124,12 +2133,16 @@ impl<'a> Executor<'a> {
21242133
}
21252134
}
21262135

2127-
// Ensure that all proofs and input bytes were read, otherwise warn the user.
2136+
// Ensure that all proofs were read, otherwise return an error.
21282137
if self.state.proof_stream_ptr != self.state.proof_stream.len() {
2129-
tracing::warn!(
2130-
"Not all proofs were read. Proving will fail during recursion. Did you pass too
2138+
tracing::error!(
2139+
"Not all proofs were read. Proving would fail during recursion. Did you pass too
21312140
many proofs in or forget to call verify_sp1_proof?"
21322141
);
2142+
return Err(ExecutionError::UnreadDeferredProofs {
2143+
expected: self.state.proof_stream.len(),
2144+
actual: self.state.proof_stream_ptr,
2145+
});
21332146
}
21342147

21352148
if !self.state.input_stream.is_empty() {
@@ -2221,6 +2234,8 @@ impl<'a> Executor<'a> {
22212234
.push(MemoryInitializeFinalizeEvent::finalize_from_record(addr, &record));
22222235
}
22232236
}
2237+
2238+
Ok(())
22242239
}
22252240

22262241
fn get_syscall(&mut self, code: SyscallCode) -> Option<&Arc<dyn Syscall>> {

0 commit comments

Comments
 (0)