diff --git a/runtime/src/system_program.rs b/runtime/src/system_program.rs index 8702c5c01d..9049e999a3 100644 --- a/runtime/src/system_program.rs +++ b/runtime/src/system_program.rs @@ -85,7 +85,7 @@ pub fn entrypoint( // All system instructions require that accounts_keys[0] be a signer if keyed_accounts[FROM_ACCOUNT_INDEX].signer_key().is_none() { info!("account[from] is unsigned"); - Err(ProgramError::InvalidArgument)?; + Err(ProgramError::MissingRequiredSignature)?; } match instruction { @@ -96,7 +96,7 @@ pub fn entrypoint( } => create_system_account(keyed_accounts, lamports, space, &program_id), SystemInstruction::Assign { program_id } => { if !system_program::check_id(&keyed_accounts[FROM_ACCOUNT_INDEX].account.owner) { - Err(ProgramError::AssignOfUnownedAccount)?; + Err(ProgramError::IncorrectProgramId)?; } assign_account_to_program(keyed_accounts, &program_id) } @@ -245,7 +245,7 @@ mod tests { }; let data = serialize(&instruction).unwrap(); let result = entrypoint(&system_program::id(), &mut keyed_accounts, &data, 0); - assert_eq!(result, Err(ProgramError::AssignOfUnownedAccount)); + assert_eq!(result, Err(ProgramError::IncorrectProgramId)); assert_eq!(from_account.owner, new_program_owner); } diff --git a/runtime/tests/system.rs b/runtime/tests/system.rs index 0a3febc7dd..72b45e81a2 100644 --- a/runtime/tests/system.rs +++ b/runtime/tests/system.rs @@ -49,7 +49,7 @@ fn test_system_unsigned_transaction() { system_bank.bank.process_transaction(&tx), Err(BankError::InstructionError( 0, - InstructionError::ProgramError(ProgramError::InvalidArgument) + InstructionError::ProgramError(ProgramError::MissingRequiredSignature) )) ); assert_eq!(system_bank.bank.get_balance(&from_keypair.pubkey()), 50); diff --git a/sdk/src/native_program.rs b/sdk/src/native_program.rs index cdbd96f93a..d1eaed03bb 100644 --- a/sdk/src/native_program.rs +++ b/sdk/src/native_program.rs @@ -17,8 +17,11 @@ pub enum ProgramError { /// An account's userdata was too small UserdataTooSmall, - /// SystemInstruction::Assign was attempted on an account unowned by the system program - AssignOfUnownedAccount, + /// The account did not have the expected program id + IncorrectProgramId, + + /// A signature was required but not found + MissingRequiredSignature, /// CustomError allows on-chain programs to implement program-specific error types and see /// them returned by the Solana runtime. A CustomError may be any type that is serialized