From 8abf22f34bc8e74705ca53ec56e7f0bb934c3a1f Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Thu, 13 Jun 2019 11:01:09 -0600 Subject: [PATCH] Temporarily revert: Convert System Transfer accounts to credit-only (#4670) --- runtime/src/bank.rs | 17 +++++++++++------ sdk/src/system_instruction.rs | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 673530f6fe..b042d0fd6b 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1724,7 +1724,7 @@ mod tests { } #[test] - fn test_credit_only_accounts() { + fn test_need_credit_only_accounts() { let (genesis_block, mint_keypair) = create_genesis_block(10); let bank = Bank::new(&genesis_block); let payer0 = Keypair::new(); @@ -1739,13 +1739,18 @@ mod tests { let txs = vec![tx0, tx1, tx2]; let results = bank.process_transactions(&txs); - // If multiple transactions attempt to deposit into the same account, they should succeed, - // since System Transfer `To` accounts are given credit-only handling + // If multiple transactions attempt to deposit into the same account, only the first will + // succeed, even though such atomic adds are safe. A System Transfer `To` account should be + // given credit-only handling assert_eq!(results[0], Ok(())); - assert_eq!(results[1], Ok(())); - assert_eq!(results[2], Ok(())); - assert_eq!(bank.get_balance(&recipient), 3); + assert_eq!(results[1], Err(TransactionError::AccountInUse)); + assert_eq!(results[2], Err(TransactionError::AccountInUse)); + + // After credit-only account handling is implemented, the following checks should pass instead: + // assert_eq!(results[0], Ok(())); + // assert_eq!(results[1], Ok(())); + // assert_eq!(results[2], Ok(())); } #[test] diff --git a/sdk/src/system_instruction.rs b/sdk/src/system_instruction.rs index 40cc3dd991..edba60c9b6 100644 --- a/sdk/src/system_instruction.rs +++ b/sdk/src/system_instruction.rs @@ -90,7 +90,7 @@ pub fn assign(from_pubkey: &Pubkey, program_id: &Pubkey) -> Instruction { pub fn transfer(from_pubkey: &Pubkey, to_pubkey: &Pubkey, lamports: u64) -> Instruction { let account_metas = vec![ AccountMeta::new(*from_pubkey, true), - AccountMeta::new_credit_only(*to_pubkey, false), + AccountMeta::new(*to_pubkey, false), ]; Instruction::new( system_program::id(),