From 4c08184379ad323134ec5e50253af02b3f28d00a Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Wed, 15 Jan 2020 15:13:11 -0800 Subject: [PATCH] no check if no change (#7824) --- runtime/src/system_instruction_processor.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/runtime/src/system_instruction_processor.rs b/runtime/src/system_instruction_processor.rs index 73ef4e0d65..8b11449ffd 100644 --- a/runtime/src/system_instruction_processor.rs +++ b/runtime/src/system_instruction_processor.rs @@ -134,6 +134,11 @@ fn assign_account_to_program( keyed_account: &mut KeyedAccount, program_id: &Pubkey, ) -> Result<(), InstructionError> { + // no work to do, just return + if keyed_account.account.owner == *program_id { + return Ok(()); + } + if keyed_account.signer_key().is_none() { debug!("Assign: account must sign"); return Err(InstructionError::MissingRequiredSignature); @@ -713,6 +718,14 @@ mod tests { ), Err(InstructionError::MissingRequiredSignature) ); + // no change, no signature needed + assert_eq!( + assign_account_to_program( + &mut KeyedAccount::new(&from, false, &mut from_account), + &system_program::id(), + ), + Ok(()) + ); assert_eq!( process_instruction(