From 452154576f13dd4bbce34a30ca27478b84138ebb Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Sat, 19 Jul 2025 20:49:45 -0300 Subject: [PATCH] nit --- .../sequencer/process_privacy_execution.rs | 1 - .../sequencer/process_public_execution.rs | 28 ++++++------------- .../examples/public_execution.rs | 1 - 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/risc0-selective-privacy-poc/examples/mocked_components/sequencer/process_privacy_execution.rs b/risc0-selective-privacy-poc/examples/mocked_components/sequencer/process_privacy_execution.rs index af240fc..d5931be 100644 --- a/risc0-selective-privacy-poc/examples/mocked_components/sequencer/process_privacy_execution.rs +++ b/risc0-selective-privacy-poc/examples/mocked_components/sequencer/process_privacy_execution.rs @@ -60,7 +60,6 @@ impl MockedSequencer { // At this point the privacy execution is considered valid. // // Update the state of the public accounts with the post-state of this privacy execution - output.public_accounts_post.into_iter().for_each(|account_post_state| { self.accounts.insert(account_post_state.address, account_post_state); }); diff --git a/risc0-selective-privacy-poc/examples/mocked_components/sequencer/process_public_execution.rs b/risc0-selective-privacy-poc/examples/mocked_components/sequencer/process_public_execution.rs index 770be37..dea7fc3 100644 --- a/risc0-selective-privacy-poc/examples/mocked_components/sequencer/process_public_execution.rs +++ b/risc0-selective-privacy-poc/examples/mocked_components/sequencer/process_public_execution.rs @@ -22,7 +22,7 @@ impl MockedSequencer { let program_output = nssa::execute_onchain::

(&input_accounts, instruction_data)?; // Perform consistency checks - if !self.program_output_is_valid(&input_accounts, &program_output) { + if !self.program_output_is_valid(&input_accounts, &program_output.accounts_post) { return Err(()); } @@ -35,26 +35,14 @@ impl MockedSequencer { /// Verifies that a program public execution didn't break the chain's rules. /// `input_accounts` are the accounts provided as inputs to the program. - /// `inputs_outputs` is the program output, which should consist of the accounts pre and - /// post-states. - fn program_output_is_valid(&self, input_accounts: &[Account], program_output: &ProgramOutput) -> bool { - let num_inputs = input_accounts.len(); - - // Fail if the number of accounts pre and post-states differ - if program_output.accounts_pre.len() != program_output.accounts_post.len() { + /// `output_accounts` are the accounts post states after execution of the program + fn program_output_is_valid(&self, input_accounts: &[Account], output_accounts: &[Account]) -> bool { + // Fail if the number of input and output accounts differ + if input_accounts.len() != output_accounts.len() { return false; } - // Fail if the accounts pre-states do not coincide with the input accounts. - if program_output.accounts_pre != input_accounts { - return false; - } - - for (account_pre, account_post) in program_output - .accounts_pre - .iter() - .zip(program_output.accounts_post.iter()) - { + for (account_pre, account_post) in input_accounts.iter().zip(output_accounts) { // Fail if the program modified the addresses of the input accounts if account_pre.address != account_post.address { return false; @@ -70,9 +58,9 @@ impl MockedSequencer { } } - let total_balance_pre: u128 = input_accounts.iter().map(|account| account.balance).sum(); - let total_balance_post: u128 = program_output.accounts_post.iter().map(|account| account.balance).sum(); // Fail if the execution didn't preserve the total supply. + let total_balance_pre: u128 = input_accounts.iter().map(|account| account.balance).sum(); + let total_balance_post: u128 = output_accounts.iter().map(|account| account.balance).sum(); if total_balance_pre != total_balance_post { return false; } diff --git a/risc0-selective-privacy-poc/examples/public_execution.rs b/risc0-selective-privacy-poc/examples/public_execution.rs index 1bedb07..c9325ae 100644 --- a/risc0-selective-privacy-poc/examples/public_execution.rs +++ b/risc0-selective-privacy-poc/examples/public_execution.rs @@ -1,6 +1,5 @@ use core::account::Account; - use nssa::program::TransferMultipleProgram; /// A public execution of the TransferMultipleProgram.