diff --git a/bench-tps/src/bench.rs b/bench-tps/src/bench.rs index 90427a619..55c6c51ff 100644 --- a/bench-tps/src/bench.rs +++ b/bench-tps/src/bench.rs @@ -564,7 +564,10 @@ fn fund_keys(client: &ThinClient, source: &Keypair, dests: &[Keypair], lamports: .map(|(k, m)| { ( k.clone(), - Transaction::new(SystemInstruction::new_move_many(&k.pubkey(), &m)), + Transaction::new_unsigned_instructions(SystemInstruction::new_move_many( + &k.pubkey(), + &m, + )), ) }) .collect(); diff --git a/core/src/replicator.rs b/core/src/replicator.rs index f7738178c..c283d9fd8 100644 --- a/core/src/replicator.rs +++ b/core/src/replicator.rs @@ -410,7 +410,7 @@ impl Replicator { self.slot, Signature::new(self.signature.as_ref()), ); - let mut tx = Transaction::new(vec![ix]); + let mut tx = Transaction::new_unsigned_instructions(vec![ix]); client .retry_transfer(&self.keypair, &mut tx, 10) .expect("transfer didn't work!"); diff --git a/core/src/storage_stage.rs b/core/src/storage_stage.rs index 73421827d..b27720867 100644 --- a/core/src/storage_stage.rs +++ b/core/src/storage_stage.rs @@ -293,7 +293,7 @@ impl StorageStage { entry_id, entry_height, ); - let tx = Transaction::new(vec![ix]); + let tx = Transaction::new_unsigned_instructions(vec![ix]); tx_sender.send(tx)?; seed.copy_from_slice(&signature.as_ref()[..32]); @@ -611,7 +611,7 @@ mod tests { 0, keypair.sign_message(b"test"), ); - let mining_proof_tx = Transaction::new(vec![mining_proof_ix]); + let mining_proof_tx = Transaction::new_unsigned_instructions(vec![mining_proof_ix]); let mining_txs = vec![mining_proof_tx]; let proof_entries = vec![Entry::new(&Hash::default(), 1, mining_txs)]; diff --git a/install/src/command.rs b/install/src/command.rs index eac8faece..7c40d1fc6 100644 --- a/install/src/command.rs +++ b/install/src/command.rs @@ -203,7 +203,7 @@ fn new_update_manifest( &update_manifest_keypair.pubkey(), 1, // lamports ); - let mut transaction = Transaction::new(vec![new_account]); + let mut transaction = Transaction::new_unsigned_instructions(vec![new_account]); transaction.sign(&[from_keypair], recect_blockhash); rpc_client.send_and_confirm_transaction(&mut transaction, from_keypair)?; @@ -225,7 +225,7 @@ fn store_update_manifest( &update_manifest_keypair.pubkey(), update_manifest, ); - let mut transaction = Transaction::new(vec![new_store]); + let mut transaction = Transaction::new_unsigned_instructions(vec![new_store]); transaction.sign(&[from_keypair, update_manifest_keypair], recect_blockhash); rpc_client.send_and_confirm_transaction(&mut transaction, from_keypair)?; Ok(()) diff --git a/programs/budget_api/src/budget_processor.rs b/programs/budget_api/src/budget_processor.rs index fd89376c0..c3b547ea5 100644 --- a/programs/budget_api/src/budget_processor.rs +++ b/programs/budget_api/src/budget_processor.rs @@ -196,7 +196,7 @@ mod tests { alice_client.transfer(1, &mallory_pubkey).unwrap(); let instruction = BudgetInstruction::new_apply_signature(&mallory_pubkey, &budget_pubkey, &bob_pubkey); - let mut transaction = Transaction::new(vec![instruction]); + let mut transaction = Transaction::new_unsigned_instructions(vec![instruction]); // Attack! Part 2: Point the instruction to the expected, but unsigned, key. transaction.account_keys.push(alice_pubkey); @@ -243,7 +243,7 @@ mod tests { &bob_pubkey, dt, ); - let mut transaction = Transaction::new(vec![instruction]); + let mut transaction = Transaction::new_unsigned_instructions(vec![instruction]); // Attack! Part 2: Point the instruction to the expected, but unsigned, key. transaction.account_keys.push(alice_pubkey); diff --git a/programs/config_api/src/config_processor.rs b/programs/config_api/src/config_processor.rs index ba22e5ba7..06a11ab0c 100644 --- a/programs/config_api/src/config_processor.rs +++ b/programs/config_api/src/config_processor.rs @@ -131,7 +131,7 @@ mod tests { let instruction = ConfigInstruction::new_store(&from_pubkey, &config_pubkey, &my_config); // Replace instruction data with a vector that's too large - let mut transaction = Transaction::new(vec![instruction]); + let mut transaction = Transaction::new_unsigned_instructions(vec![instruction]); transaction.instructions[0].data = vec![0; 123]; config_client.process_transaction(transaction).unwrap_err(); } @@ -153,7 +153,8 @@ mod tests { ConfigInstruction::new_store(&from_pubkey, &config_pubkey, &my_config); // Don't sign the transaction with `config_client` - let mut transaction = Transaction::new(vec![move_instruction, store_instruction]); + let mut transaction = + Transaction::new_unsigned_instructions(vec![move_instruction, store_instruction]); transaction.sign_unchecked(&[&system_keypair], bank.last_blockhash()); let system_client = BankClient::new(&bank, system_keypair); system_client.process_transaction(transaction).unwrap_err(); diff --git a/programs/exchange_api/src/exchange_transaction.rs b/programs/exchange_api/src/exchange_transaction.rs index 35c4418aa..ea8420cda 100644 --- a/programs/exchange_api/src/exchange_transaction.rs +++ b/programs/exchange_api/src/exchange_transaction.rs @@ -21,7 +21,7 @@ impl ExchangeTransaction { let space = mem::size_of::() as u64; let create_ix = SystemInstruction::new_program_account(owner_id, new, 1, space, &id()); let request_ix = ExchangeInstruction::new_account_request(owner_id, new); - let mut tx = Transaction::new(vec![create_ix, request_ix]); + let mut tx = Transaction::new_unsigned_instructions(vec![create_ix, request_ix]); tx.fee = fee; tx.sign(&[owner], recent_blockhash); tx @@ -39,7 +39,7 @@ impl ExchangeTransaction { let owner_id = &owner.pubkey(); let request_ix = ExchangeInstruction::new_transfer_request(owner_id, to, from, token, tokens); - let mut tx = Transaction::new(vec![request_ix]); + let mut tx = Transaction::new_unsigned_instructions(vec![request_ix]); tx.fee = fee; tx.sign(&[owner], recent_blockhash); tx @@ -71,7 +71,7 @@ impl ExchangeTransaction { src_account, dst_account, ); - let mut tx = Transaction::new(vec![create_ix, request_ix]); + let mut tx = Transaction::new_unsigned_instructions(vec![create_ix, request_ix]); tx.fee = fee; tx.sign(&[owner], recent_blockhash); tx @@ -86,7 +86,7 @@ impl ExchangeTransaction { ) -> Transaction { let owner_id = &owner.pubkey(); let request_ix = ExchangeInstruction::new_trade_cancellation(owner_id, trade, account); - let mut tx = Transaction::new(vec![request_ix]); + let mut tx = Transaction::new_unsigned_instructions(vec![request_ix]); tx.fee = fee; tx.sign(&[owner], recent_blockhash); tx @@ -115,7 +115,7 @@ impl ExchangeTransaction { from_trade_account, profit_account, ); - let mut tx = Transaction::new(vec![create_ix, request_ix]); + let mut tx = Transaction::new_unsigned_instructions(vec![create_ix, request_ix]); tx.fee = fee; tx.sign(&[owner], recent_blockhash); tx diff --git a/runtime/src/bank_client.rs b/runtime/src/bank_client.rs index d1c32c8e3..57051bcbc 100644 --- a/runtime/src/bank_client.rs +++ b/runtime/src/bank_client.rs @@ -43,7 +43,7 @@ impl<'a> BankClient<'a> { &self, instructions: Vec, ) -> Result<(), TransactionError> { - self.process_transaction(Transaction::new(instructions)) + self.process_transaction(Transaction::new_unsigned_instructions(instructions)) } /// Create and process a transaction from a single instruction. diff --git a/sdk/src/transaction.rs b/sdk/src/transaction.rs index 151d540f0..f60015302 100644 --- a/sdk/src/transaction.rs +++ b/sdk/src/transaction.rs @@ -83,7 +83,7 @@ impl Transaction { } } - pub fn new(instructions: Vec) -> Self { + pub fn new_unsigned_instructions(instructions: Vec) -> Self { let message = Message::new(instructions); Self::new_unsigned_message(message) } @@ -576,7 +576,7 @@ mod tests { #[should_panic] fn test_transaction_missing_key() { let keypair = Keypair::new(); - Transaction::new(vec![]).sign(&[&keypair], Hash::default()); + Transaction::new_unsigned_instructions(vec![]).sign(&[&keypair], Hash::default()); } #[test] @@ -586,7 +586,8 @@ mod tests { let keypair0 = Keypair::new(); let id0 = keypair0.pubkey(); let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]); - Transaction::new(vec![ix]).sign(&Vec::<&Keypair>::new(), Hash::default()); + Transaction::new_unsigned_instructions(vec![ix]) + .sign(&Vec::<&Keypair>::new(), Hash::default()); } #[test] @@ -596,7 +597,7 @@ mod tests { let keypair0 = Keypair::new(); let wrong_id = Pubkey::default(); let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(wrong_id, true)]); - Transaction::new(vec![ix]).sign(&[&keypair0], Hash::default()); + Transaction::new_unsigned_instructions(vec![ix]).sign(&[&keypair0], Hash::default()); } #[test] @@ -605,7 +606,7 @@ mod tests { let keypair0 = Keypair::new(); let id0 = keypair0.pubkey(); let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]); - let mut tx = Transaction::new(vec![ix]); + let mut tx = Transaction::new_unsigned_instructions(vec![ix]); tx.sign(&[&keypair0], Hash::default()); assert_eq!(tx.instructions[0], CompiledInstruction::new(0, &0, vec![0])); }