From afc977e0440c556f739f429ae66d0cb1b62c969a Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Mon, 15 Sep 2025 16:22:48 -0300 Subject: [PATCH] change validate_execution logic --- nssa/core/src/program.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/nssa/core/src/program.rs b/nssa/core/src/program.rs index 233a0f7..82023f3 100644 --- a/nssa/core/src/program.rs +++ b/nssa/core/src/program.rs @@ -59,20 +59,23 @@ pub fn validate_execution( return false; } - // 3. Ownership change only allowed from default accounts - if pre.account.program_owner != post.program_owner && pre.account != Account::default() { + // 3. Program ownership changes are not allowed + if pre.account.program_owner != post.program_owner { return false; } + let account_program_owner = pre.account.program_owner; + // 4. Decreasing balance only allowed if owned by executing program - if post.balance < pre.account.balance && pre.account.program_owner != executing_program_id { + if post.balance < pre.account.balance && account_program_owner != executing_program_id { return false; } - // 5. Data changes only allowed if owned by executing program + // 5. Data changes only allowed if owned by executing program or if account pre state has + // default values if pre.account.data != post.data - && (pre.account != Account::default() && (executing_program_id != pre.account.program_owner - || executing_program_id != post.program_owner)) + && pre.account != Account::default() + && account_program_owner != executing_program_id { return false; }