diff --git a/lee/state_machine/src/privacy_preserving_transaction/circuit/mod.rs b/lee/state_machine/src/privacy_preserving_transaction/circuit/mod.rs index 0ae952d80..1013287f7 100644 --- a/lee/state_machine/src/privacy_preserving_transaction/circuit/mod.rs +++ b/lee/state_machine/src/privacy_preserving_transaction/circuit/mod.rs @@ -133,7 +133,7 @@ pub fn execute_and_prove_with_padded_inputs( continue; }; let update_receipt = - program.prove_update_from_diff(pre.account.clone(), diff_data.into())?; + program.prove_update_from_diff(pre.account.clone(), diff_data)?; let update_output: UpdateFromDiffOutput = update_receipt .journal .decode() diff --git a/lee/state_machine/src/program/mod.rs b/lee/state_machine/src/program/mod.rs index fb45f9ea4..0fb689878 100644 --- a/lee/state_machine/src/program/mod.rs +++ b/lee/state_machine/src/program/mod.rs @@ -121,7 +121,7 @@ impl Program { pub(crate) fn execute_update_from_diff( &self, pre_state: Account, - diff_data: Vec, + diff_data: Data, ) -> Result { let mut env_builder = ExecutorEnv::builder(); env_builder.session_limit(Some(MAX_NUM_CYCLES_PUBLIC_EXECUTION)); @@ -149,7 +149,7 @@ impl Program { pub(crate) fn prove_update_from_diff( &self, pre_state: Account, - diff_data: Vec, + diff_data: Data, ) -> Result { let mut env_builder = ExecutorEnv::builder(); Self::write_update_from_diff_inputs(&pre_state, &diff_data, &mut env_builder)?; @@ -164,7 +164,7 @@ impl Program { fn write_update_from_diff_inputs( pre_state: &Account, - diff_data: &[u8], + diff_data: &Data, env_builder: &mut ExecutorEnvBuilder, ) -> Result<(), LeeError> { env_builder diff --git a/lee/state_machine/src/validated_state_diff/mod.rs b/lee/state_machine/src/validated_state_diff/mod.rs index e9dac4ba7..2551689b1 100644 --- a/lee/state_machine/src/validated_state_diff/mod.rs +++ b/lee/state_machine/src/validated_state_diff/mod.rs @@ -225,7 +225,7 @@ impl ValidatedStateDiff { .map_err(InvalidProgramBehaviorError::BalanceDiffFailed)?; let data = if let Some(diff_data) = diff.diff_data.clone() { - program.execute_update_from_diff(pre.account.clone(), diff_data.into())? + program.execute_update_from_diff(pre.account.clone(), diff_data)? } else { pre.account.data.clone() }; diff --git a/lez/programs/amm/src/tests.rs b/lez/programs/amm/src/tests.rs index 37ed15c59..09038820c 100644 --- a/lez/programs/amm/src/tests.rs +++ b/lez/programs/amm/src/tests.rs @@ -30,8 +30,8 @@ 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/lez/programs/bridge_lock/src/main.rs b/lez/programs/bridge_lock/src/main.rs index b4c3e8c37..092f86e7a 100644 --- a/lez/programs/bridge_lock/src/main.rs +++ b/lez/programs/bridge_lock/src/main.rs @@ -254,7 +254,7 @@ fn init_config( config_bytes(outbox_program_id, target_program_id) .to_vec() .try_into() - .expect("config bytes fit in account data"), + .expect("bridge-lock config fits under DATA_MAX_LENGTH"), ), }, config.account.program_owner.into(), diff --git a/lez/programs/cross_zone_inbox/src/main.rs b/lez/programs/cross_zone_inbox/src/main.rs index 2f4552c82..8bb140110 100644 --- a/lez/programs/cross_zone_inbox/src/main.rs +++ b/lez/programs/cross_zone_inbox/src/main.rs @@ -158,7 +158,7 @@ fn dispatch( shard .to_bytes() .try_into() - .expect("seen shard fits in account data"), + .expect("seen shard fits under DATA_MAX_LENGTH"), ), }, seen.account.program_owner.into(), @@ -248,7 +248,7 @@ fn init_config( config .to_bytes() .try_into() - .expect("inbox config fits in account data"), + .expect("inbox config fits under DATA_MAX_LENGTH"), ), }, config_meta.account.program_owner.into(), diff --git a/lez/programs/cross_zone_outbox/src/main.rs b/lez/programs/cross_zone_outbox/src/main.rs index 73ffd4fee..106c44cfd 100644 --- a/lez/programs/cross_zone_outbox/src/main.rs +++ b/lez/programs/cross_zone_outbox/src/main.rs @@ -96,7 +96,7 @@ fn main() { } .to_bytes() .try_into() - .expect("outbox record fits under DATA_MAX_LENGTH"); + .expect("OutboxRecord fits under DATA_MAX_LENGTH"); // Unconditional, since the pre-state is provably default by the assert above. let post = AccountDiffOutput::new_claimed( diff --git a/lez/programs/pinata/src/main.rs b/lez/programs/pinata/src/main.rs index 1da726742..5b95e286c 100644 --- a/lez/programs/pinata/src/main.rs +++ b/lez/programs/pinata/src/main.rs @@ -91,7 +91,7 @@ fn main() { data.next_data() .to_vec() .try_into() - .expect("challenge data fits in account data"), + .expect("pinata challenge data always fits under DATA_MAX_LENGTH"), ), }, pinata.account.program_owner.into(), diff --git a/lez/programs/ping_receiver/src/main.rs b/lez/programs/ping_receiver/src/main.rs index bc3587e57..f52b19d44 100644 --- a/lez/programs/ping_receiver/src/main.rs +++ b/lez/programs/ping_receiver/src/main.rs @@ -353,7 +353,7 @@ fn init_config( config_value .to_bytes() .try_into() - .expect("receiver config fits in account data"), + .expect("receiver config fits under DATA_MAX_LENGTH"), ), }, config.account.program_owner.into(), diff --git a/lez/programs/ping_sender/src/main.rs b/lez/programs/ping_sender/src/main.rs index 1b0a4ed05..34695bd32 100644 --- a/lez/programs/ping_sender/src/main.rs +++ b/lez/programs/ping_sender/src/main.rs @@ -176,7 +176,7 @@ fn init_config( outbox_bytes(outbox_program_id) .to_vec() .try_into() - .expect("outbox bytes fit in account data"), + .expect("ping-sender config fits under DATA_MAX_LENGTH"), ), }, config.account.program_owner.into(), diff --git a/lez/programs/token/src/tests.rs b/lez/programs/token/src/tests.rs index 14d930d1e..b20be18dc 100644 --- a/lez/programs/token/src/tests.rs +++ b/lez/programs/token/src/tests.rs @@ -33,8 +33,8 @@ 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/lez/programs/wrapped_token/src/main.rs b/lez/programs/wrapped_token/src/main.rs index 72fa03e81..4c19c71ca 100644 --- a/lez/programs/wrapped_token/src/main.rs +++ b/lez/programs/wrapped_token/src/main.rs @@ -139,7 +139,7 @@ fn mint( balance_bytes(new_balance) .to_vec() .try_into() - .expect("balance bytes fit in account data"), + .expect("wrapped-token balance always fits under DATA_MAX_LENGTH"), ), }, holding.account.program_owner.into(), @@ -373,7 +373,7 @@ fn init_config( config_value .to_bytes() .try_into() - .expect("wrapped-token config fits in account data"), + .expect("wrapped-token config fits under DATA_MAX_LENGTH"), ), }, config.account.program_owner.into(), diff --git a/test_programs/guest/src/bin/pinata_cooldown.rs b/test_programs/guest/src/bin/pinata_cooldown.rs index 19d238494..d68ce8d7b 100644 --- a/test_programs/guest/src/bin/pinata_cooldown.rs +++ b/test_programs/guest/src/bin/pinata_cooldown.rs @@ -103,7 +103,7 @@ fn main() { let updated_data: Data = updated_state .to_bytes() .try_into() - .expect("pinata state fits in account data"); + .expect("pinata account data always fits under DATA_MAX_LENGTH"); let pinata_post = AccountDiffOutput::new_claimed_if_default( AccountDiff {