small refactor

This commit is contained in:
Sergio Chouhy
2026-04-02 17:40:58 -03:00
parent aa157bfbe7
commit 29d66d2c2d
17 changed files with 63 additions and 68 deletions
@@ -0,0 +1,35 @@
use nssa_core::program::{
AccountPostState, ChainedCall, ProgramId, ProgramInput, ProgramOutput, read_nssa_inputs,
};
use risc0_zkvm::serde::to_vec;
type Instruction = (ProgramId, u64); // (clock_program_id, timestamp)
/// A program that chain-calls the clock program with the clock accounts it received as pre-states.
/// Used in tests to verify that user transactions cannot modify clock accounts, even indirectly
/// via chain calls.
fn main() {
let (
ProgramInput {
pre_states,
instruction: (clock_program_id, timestamp),
},
instruction_words,
) = read_nssa_inputs::<Instruction>();
let post_states: Vec<_> = pre_states
.iter()
.map(|pre| AccountPostState::new(pre.account.clone()))
.collect();
let chained_call = ChainedCall {
program_id: clock_program_id,
instruction_data: to_vec(&timestamp).unwrap(),
pre_states: pre_states.clone(),
pda_seeds: vec![],
};
ProgramOutput::new(instruction_words, pre_states, post_states)
.with_chained_calls(vec![chained_call])
.write();
}