From b676c6c360ca38bf6a589bcea7879113eb4ebf77 Mon Sep 17 00:00:00 2001 From: jonesmarvin8 <83104039+jonesmarvin8@users.noreply.github.com> Date: Thu, 20 Aug 2026 15:54:05 -0400 Subject: [PATCH] chore(lee,lez): fix pre-existing rustfmt violations (#776) marvin/incremental-updates-2 was not cargo +nightly fmt --check clean; these files had drifted since the last fmt pass (mostly unwrapped long import lists). No functional changes. --- .../methods/guest/src/bin/hello_world.rs | 10 ++++-- .../src/bin/hello_world_with_authorization.rs | 10 ++++-- .../src/bin/hello_world_with_move_function.rs | 10 +++--- .../src/execution_state.rs | 9 +++--- lee/state_machine/core/src/program/mod.rs | 32 +++++++++++-------- .../guest/src/bin/malicious_launderer.rs | 4 ++- .../test_methods/guest/src/bin/noop.rs | 4 ++- lez/programs/amm/src/lib.rs | 3 +- lez/programs/amm/src/main.rs | 4 ++- lez/programs/amm/src/tests.rs | 19 ++++++++--- .../associated_token_account/src/burn.rs | 5 ++- .../associated_token_account/src/lib.rs | 1 - .../associated_token_account/src/transfer.rs | 5 ++- lez/programs/bridge_lock/src/main.rs | 4 +-- lez/programs/cross_zone_inbox/src/main.rs | 4 +-- lez/programs/ping_sender/src/main.rs | 4 +-- lez/programs/token/src/lib.rs | 1 - lez/programs/token/src/tests.rs | 3 +- .../guest/src/bin/pinata_cooldown.rs | 5 ++- 19 files changed, 87 insertions(+), 50 deletions(-) diff --git a/examples/program_deployment/methods/guest/src/bin/hello_world.rs b/examples/program_deployment/methods/guest/src/bin/hello_world.rs index 33362c0d9..8a26a127a 100644 --- a/examples/program_deployment/methods/guest/src/bin/hello_world.rs +++ b/examples/program_deployment/methods/guest/src/bin/hello_world.rs @@ -1,6 +1,9 @@ use lee_core::{ account::{Account, AccountDiff, BalanceDiff, Data}, - program::{AccountDiffOutput, Claim, ProgramCall, ProgramInput, ProgramOutput, read_lee_call, write_update_from_diff_output}, + program::{ + AccountDiffOutput, Claim, ProgramCall, ProgramInput, ProgramOutput, read_lee_call, + write_update_from_diff_output, + }, }; // Hello-world example program. @@ -82,6 +85,9 @@ fn main() { .write(); } -fn update_from_diff(_pre_state: Account, diff_data: Data) -> Result { +fn update_from_diff( + _pre_state: Account, + diff_data: Data, +) -> Result { Ok(diff_data) } diff --git a/examples/program_deployment/methods/guest/src/bin/hello_world_with_authorization.rs b/examples/program_deployment/methods/guest/src/bin/hello_world_with_authorization.rs index 5b2bf1f02..a1d87c5ef 100644 --- a/examples/program_deployment/methods/guest/src/bin/hello_world_with_authorization.rs +++ b/examples/program_deployment/methods/guest/src/bin/hello_world_with_authorization.rs @@ -1,6 +1,9 @@ use lee_core::{ account::{Account, AccountDiff, BalanceDiff, Data}, - program::{AccountDiffOutput, Claim, ProgramCall, ProgramInput, ProgramOutput, read_lee_call, write_update_from_diff_output}, + program::{ + AccountDiffOutput, Claim, ProgramCall, ProgramInput, ProgramOutput, read_lee_call, + write_update_from_diff_output, + }, }; // Hello-world with authorization example program. @@ -89,6 +92,9 @@ fn main() { .write(); } -fn update_from_diff(_pre_state: Account, diff_data: Data) -> Result { +fn update_from_diff( + _pre_state: Account, + diff_data: Data, +) -> Result { Ok(diff_data) } diff --git a/examples/program_deployment/methods/guest/src/bin/hello_world_with_move_function.rs b/examples/program_deployment/methods/guest/src/bin/hello_world_with_move_function.rs index 1c0eee034..6708d3bcb 100644 --- a/examples/program_deployment/methods/guest/src/bin/hello_world_with_move_function.rs +++ b/examples/program_deployment/methods/guest/src/bin/hello_world_with_move_function.rs @@ -48,10 +48,7 @@ fn write(pre_state: AccountWithMetadata, greeting: &[u8]) -> AccountDiffOutput { ) } -fn move_data( - from_pre: AccountWithMetadata, - to_pre: AccountWithMetadata, -) -> Vec { +fn move_data(from_pre: AccountWithMetadata, to_pre: AccountWithMetadata) -> Vec { // Construct the post state account values let from_data: Vec = from_pre.account.data.clone().into(); @@ -131,6 +128,9 @@ fn main() { .write(); } -fn update_from_diff(_pre_state: Account, diff_data: Data) -> Result { +fn update_from_diff( + _pre_state: Account, + diff_data: Data, +) -> Result { Ok(diff_data) } diff --git a/lee/privacy_preserving_circuit/src/execution_state.rs b/lee/privacy_preserving_circuit/src/execution_state.rs index e1244196d..1de934e4f 100644 --- a/lee/privacy_preserving_circuit/src/execution_state.rs +++ b/lee/privacy_preserving_circuit/src/execution_state.rs @@ -445,9 +445,9 @@ impl ExecutionState { }; let journal_words = to_vec(&expected_output).expect("UpdateFromDiffOutput must be serializable"); - env::verify(program_id, &journal_words).unwrap_or_else( - |_: Infallible| unreachable!("Infallible error is never constructed"), - ); + env::verify(program_id, &journal_words).unwrap_or_else(|_: Infallible| { + unreachable!("Infallible error is never constructed") + }); data } else { pre_account.data.clone() @@ -461,8 +461,7 @@ impl ExecutionState { if let Some(claim) = diff_output.required_claim() { // The invoked program can only claim accounts with default program id. assert_eq!( - pre_account.program_owner, - DEFAULT_PROGRAM_OWNER, + pre_account.program_owner, DEFAULT_PROGRAM_OWNER, "Cannot claim an initialized account {pre_account_id}" ); diff --git a/lee/state_machine/core/src/program/mod.rs b/lee/state_machine/core/src/program/mod.rs index 122de4a18..0c2903609 100644 --- a/lee/state_machine/core/src/program/mod.rs +++ b/lee/state_machine/core/src/program/mod.rs @@ -885,23 +885,27 @@ pub fn validate_execution( } } - // 5. Total balance is preserved: within this call's own diffs, every decrease must be - // balanced by an equal increase. - let Some(total_added) = WrappedBalanceSum::from_balances(post_diff.iter().filter_map( - |diff_output| match diff_output.diff().diff_balance { - BalanceDiff::Add(amount) => Some(amount), - BalanceDiff::Sub(_) => None, - }, - )) else { + // 5. Total balance is preserved: within this call's own diffs, every decrease must be balanced + // by an equal increase. + let Some(total_added) = + WrappedBalanceSum::from_balances(post_diff.iter().filter_map(|diff_output| { + match diff_output.diff().diff_balance { + BalanceDiff::Add(amount) => Some(amount), + BalanceDiff::Sub(_) => None, + } + })) + else { return Err(ExecutionValidationError::BalanceSumOverflow); }; - let Some(total_subbed) = WrappedBalanceSum::from_balances(post_diff.iter().filter_map( - |diff_output| match diff_output.diff().diff_balance { - BalanceDiff::Sub(amount) => Some(amount), - BalanceDiff::Add(_) => None, - }, - )) else { + let Some(total_subbed) = + WrappedBalanceSum::from_balances(post_diff.iter().filter_map(|diff_output| { + match diff_output.diff().diff_balance { + BalanceDiff::Sub(amount) => Some(amount), + BalanceDiff::Add(_) => None, + } + })) + else { return Err(ExecutionValidationError::BalanceSumOverflow); }; diff --git a/lee/state_machine/test_methods/guest/src/bin/malicious_launderer.rs b/lee/state_machine/test_methods/guest/src/bin/malicious_launderer.rs index 79d3b85c0..62ab1f50a 100644 --- a/lee/state_machine/test_methods/guest/src/bin/malicious_launderer.rs +++ b/lee/state_machine/test_methods/guest/src/bin/malicious_launderer.rs @@ -1,4 +1,6 @@ -use lee_core::program::{ChainedCall, ProgramCall, ProgramId, ProgramInput, ProgramOutput, read_lee_call}; +use lee_core::program::{ + ChainedCall, ProgramCall, ProgramId, ProgramInput, ProgramOutput, read_lee_call, +}; /// Instruction: (`auth_transfer_id`, `amount`) — both primitive, safe for `risc0_zkvm::serde`. type Instruction = (ProgramId, u128); diff --git a/lee/state_machine/test_methods/guest/src/bin/noop.rs b/lee/state_machine/test_methods/guest/src/bin/noop.rs index 9132142b5..ee7624335 100644 --- a/lee/state_machine/test_methods/guest/src/bin/noop.rs +++ b/lee/state_machine/test_methods/guest/src/bin/noop.rs @@ -17,7 +17,9 @@ fn main() { ) = match read_lee_call::() { ProgramCall::Execute(input, instruction_words) => (input, instruction_words), ProgramCall::UpdateFromDiff { .. } => { - unreachable!("noop program never writes diff_data, so update_from_diff is never dispatched") + unreachable!( + "noop program never writes diff_data, so update_from_diff is never dispatched" + ) } }; diff --git a/lez/programs/amm/src/lib.rs b/lez/programs/amm/src/lib.rs index 28accadc5..5782aa327 100644 --- a/lez/programs/amm/src/lib.rs +++ b/lez/programs/amm/src/lib.rs @@ -7,10 +7,9 @@ reason = "TODO: Fix later" )] -pub use amm_core as core; - use std::convert::Infallible; +pub use amm_core as core; use lee_core::{ account::{Account, AccountDiff, AccountId, BalanceDiff, Data}, program::AccountDiffOutput, diff --git a/lez/programs/amm/src/main.rs b/lez/programs/amm/src/main.rs index 2beac85a7..04e0f41c2 100644 --- a/lez/programs/amm/src/main.rs +++ b/lez/programs/amm/src/main.rs @@ -9,7 +9,9 @@ use std::num::NonZero; use amm_core::Instruction; -use lee_core::program::{ProgramCall, ProgramInput, ProgramOutput, read_lee_call, write_update_from_diff_output}; +use lee_core::program::{ + ProgramCall, ProgramInput, ProgramOutput, read_lee_call, write_update_from_diff_output, +}; fn main() { let ( diff --git a/lez/programs/amm/src/tests.rs b/lez/programs/amm/src/tests.rs index 09038820c..0bdfc7ef8 100644 --- a/lez/programs/amm/src/tests.rs +++ b/lez/programs/amm/src/tests.rs @@ -30,8 +30,7 @@ fn expected_diff(pre: &AccountWithMetadata, expected_post: &Account) -> AccountD } else { BalanceDiff::Sub(pre.account.balance - expected_post.balance) }; - let diff_data = - (expected_post.data != pre.account.data).then(|| expected_post.data.clone()); + let diff_data = (expected_post.data != pre.account.data).then(|| expected_post.data.clone()); AccountDiff { id: pre.account_id, diff_balance, @@ -3020,7 +3019,13 @@ fn new_definition_lp_asymmetric_amounts() { // check the minted LP amount let pool_post = post_states[0].clone(); - let pool_data: Data = pool_post.diff().diff_data.clone().unwrap().try_into().unwrap(); + let pool_data: Data = pool_post + .diff() + .diff_data + .clone() + .unwrap() + .try_into() + .unwrap(); let pool_def = PoolDefinition::try_from(&pool_data).unwrap(); assert_eq!( pool_def.liquidity_pool_supply, @@ -3053,7 +3058,13 @@ fn new_definition_lp_symmetric_amounts() { ); let pool_post = post_states[0].clone(); - let pool_data: Data = pool_post.diff().diff_data.clone().unwrap().try_into().unwrap(); + let pool_data: Data = pool_post + .diff() + .diff_data + .clone() + .unwrap() + .try_into() + .unwrap(); let pool_def = PoolDefinition::try_from(&pool_data).unwrap(); assert_eq!(pool_def.liquidity_pool_supply, expected_lp); diff --git a/lez/programs/associated_token_account/src/burn.rs b/lez/programs/associated_token_account/src/burn.rs index cf6fa0254..72c7c4ee3 100644 --- a/lez/programs/associated_token_account/src/burn.rs +++ b/lez/programs/associated_token_account/src/burn.rs @@ -1,4 +1,7 @@ -use lee_core::{account::AccountWithMetadata, program::{AccountDiffOutput, ChainedCall, ProgramId}}; +use lee_core::{ + account::AccountWithMetadata, + program::{AccountDiffOutput, ChainedCall, ProgramId}, +}; use token_core::TokenHolding; pub fn burn_from_associated_token_account( diff --git a/lez/programs/associated_token_account/src/lib.rs b/lez/programs/associated_token_account/src/lib.rs index 49eb6564a..4d99d5391 100644 --- a/lez/programs/associated_token_account/src/lib.rs +++ b/lez/programs/associated_token_account/src/lib.rs @@ -1,7 +1,6 @@ //! The Associated Token Account Program implementation. pub use associated_token_account_core as core; - use lee_core::{ account::{AccountDiff, AccountId, BalanceDiff}, program::AccountDiffOutput, diff --git a/lez/programs/associated_token_account/src/transfer.rs b/lez/programs/associated_token_account/src/transfer.rs index 8b7821818..6fa54e6c3 100644 --- a/lez/programs/associated_token_account/src/transfer.rs +++ b/lez/programs/associated_token_account/src/transfer.rs @@ -1,4 +1,7 @@ -use lee_core::{account::AccountWithMetadata, program::{AccountDiffOutput, ChainedCall, ProgramId}}; +use lee_core::{ + account::AccountWithMetadata, + program::{AccountDiffOutput, ChainedCall, ProgramId}, +}; use token_core::TokenHolding; pub fn transfer_from_associated_token_account( diff --git a/lez/programs/bridge_lock/src/main.rs b/lez/programs/bridge_lock/src/main.rs index 092f86e7a..ef7260cdb 100644 --- a/lez/programs/bridge_lock/src/main.rs +++ b/lez/programs/bridge_lock/src/main.rs @@ -8,8 +8,8 @@ use cross_zone_outbox_core::Instruction as OutboxInstruction; use lee_core::{ account::{Account, AccountDiff, AccountId, AccountWithMetadata, BalanceDiff, Data}, program::{ - AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput, - ProgramOutput, read_lee_call, write_update_from_diff_output, + AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput, ProgramOutput, + read_lee_call, write_update_from_diff_output, }, }; use wrapped_token_core::{Instruction as WrappedInstruction, MAX_MINT_AMOUNT}; diff --git a/lez/programs/cross_zone_inbox/src/main.rs b/lez/programs/cross_zone_inbox/src/main.rs index 8bb140110..f5aa0a0e7 100644 --- a/lez/programs/cross_zone_inbox/src/main.rs +++ b/lez/programs/cross_zone_inbox/src/main.rs @@ -8,8 +8,8 @@ use cross_zone_marker_core::inbox_source_marker_account_id; use lee_core::{ account::{Account, AccountDiff, AccountWithMetadata, BalanceDiff, Data}, program::{ - AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput, - ProgramOutput, read_lee_call, write_update_from_diff_output, + AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput, ProgramOutput, + read_lee_call, write_update_from_diff_output, }, }; diff --git a/lez/programs/ping_sender/src/main.rs b/lez/programs/ping_sender/src/main.rs index 34695bd32..fecb56624 100644 --- a/lez/programs/ping_sender/src/main.rs +++ b/lez/programs/ping_sender/src/main.rs @@ -4,8 +4,8 @@ use cross_zone_outbox_core::Instruction as OutboxInstruction; use lee_core::{ account::{Account, AccountDiff, AccountId, AccountWithMetadata, BalanceDiff, Data}, program::{ - AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput, - ProgramOutput, read_lee_call, write_update_from_diff_output, + AccountDiffOutput, ChainedCall, Claim, ProgramCall, ProgramId, ProgramInput, ProgramOutput, + read_lee_call, write_update_from_diff_output, }, }; use ping_core::{ diff --git a/lez/programs/token/src/lib.rs b/lez/programs/token/src/lib.rs index 781aebfac..fdae436c6 100644 --- a/lez/programs/token/src/lib.rs +++ b/lez/programs/token/src/lib.rs @@ -3,7 +3,6 @@ use std::convert::Infallible; use lee_core::account::{Account, Data}; - pub use token_core as core; pub mod burn; diff --git a/lez/programs/token/src/tests.rs b/lez/programs/token/src/tests.rs index b20be18dc..43d948b69 100644 --- a/lez/programs/token/src/tests.rs +++ b/lez/programs/token/src/tests.rs @@ -33,8 +33,7 @@ fn expected_diff(pre: &AccountWithMetadata, expected_post: &Account) -> AccountD } else { BalanceDiff::Sub(pre.account.balance - expected_post.balance) }; - let diff_data = - (expected_post.data != pre.account.data).then(|| expected_post.data.clone()); + let diff_data = (expected_post.data != pre.account.data).then(|| expected_post.data.clone()); AccountDiff { id: pre.account_id, diff_balance, diff --git a/test_programs/guest/src/bin/pinata_cooldown.rs b/test_programs/guest/src/bin/pinata_cooldown.rs index d68ce8d7b..9dd573250 100644 --- a/test_programs/guest/src/bin/pinata_cooldown.rs +++ b/test_programs/guest/src/bin/pinata_cooldown.rs @@ -137,6 +137,9 @@ fn main() { .write(); } -fn update_from_diff(_pre_state: Account, diff_data: Data) -> Result { +fn update_from_diff( + _pre_state: Account, + diff_data: Data, +) -> Result { Ok(diff_data) }