add test for empty intersection in circuit

This commit is contained in:
Sergio Chouhy
2026-03-25 17:33:27 -03:00
parent abc30c0ce0
commit 79d70b3a66
31 changed files with 131 additions and 11 deletions
+6 -2
View File
@@ -19,6 +19,10 @@ fn main() {
let mut account_post = account_pre.clone();
account_post.balance = account_post.balance.saturating_sub(balance_to_burn);
ProgramOutput::new(instruction_words, vec![pre], vec![AccountPostState::new(account_post)])
.write();
ProgramOutput::new(
instruction_words,
vec![pre],
vec![AccountPostState::new(account_post)],
)
.write();
}
+6 -2
View File
@@ -16,6 +16,10 @@ fn main() {
.checked_add(1)
.expect("Balance overflow");
ProgramOutput::new(instruction_words, vec![pre], vec![AccountPostState::new(account_post)])
.write();
ProgramOutput::new(
instruction_words,
vec![pre],
vec![AccountPostState::new(account_post)],
)
.write();
}
@@ -13,6 +13,10 @@ fn main() {
let mut account_post = account_pre.clone();
account_post.nonce.public_account_nonce_increment();
ProgramOutput::new(instruction_words, vec![pre], vec![AccountPostState::new(account_post)])
.write();
ProgramOutput::new(
instruction_words,
vec![pre],
vec![AccountPostState::new(account_post)],
)
.write();
}
@@ -13,6 +13,10 @@ fn main() {
let mut account_post = account_pre.clone();
account_post.program_owner = [0, 1, 2, 3, 4, 5, 6, 7];
ProgramOutput::new(instruction_words, vec![pre], vec![AccountPostState::new(account_post)])
.write();
ProgramOutput::new(
instruction_words,
vec![pre],
vec![AccountPostState::new(account_post)],
)
.write();
}
@@ -0,0 +1,53 @@
use nssa_core::program::{
AccountPostState, BlockId, ChainedCall, ProgramId, ProgramInput, ProgramOutput,
read_nssa_inputs,
};
use risc0_zkvm::serde::to_vec;
/// A program that sets a validity window on its output and chains to another program with a
/// potentially different validity window.
///
/// Instruction: (from_id, until_id, chained_program_id, chained_from, chained_until)
/// The initial output uses [from_id, until_id) and chains to `chained_program_id` with
/// [chained_from, chained_until).
type Instruction = (
Option<BlockId>,
Option<BlockId>,
ProgramId,
Option<BlockId>,
Option<BlockId>,
);
fn main() {
let (
ProgramInput {
pre_states,
instruction: (from_id, until_id, chained_program_id, chained_from, chained_until),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
let [pre] = <[_; 1]>::try_from(pre_states.clone())
.unwrap_or_else(|_| panic!("Expected exactly one pre state"));
let post = pre.account.clone();
let chained_instruction = to_vec(&(chained_from, chained_until)).unwrap();
let chained_call = ChainedCall {
program_id: chained_program_id,
instruction_data: chained_instruction,
pre_states,
pda_seeds: vec![],
};
ProgramOutput::new(
instruction_words,
vec![pre],
vec![AccountPostState::new(post)],
)
.valid_from_id(from_id)
.unwrap()
.valid_until_id(until_id)
.unwrap()
.with_chained_calls(vec![chained_call])
.write();
}