Remove fee-payer guesswork from Message and Transaction (#10776)
* Make Message::new_with_payer the default constructor * Remove Transaction::new_[un]signed_instructions These guess the fee-payer instead of stating it explicitly
This commit is contained in:
@@ -19,6 +19,7 @@ use solana_perf::test_tx::test_tx;
|
||||
use solana_runtime::bank::Bank;
|
||||
use solana_sdk::genesis_config::GenesisConfig;
|
||||
use solana_sdk::hash::Hash;
|
||||
use solana_sdk::message::Message;
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
use solana_sdk::signature::Keypair;
|
||||
use solana_sdk::signature::Signature;
|
||||
@@ -116,9 +117,8 @@ fn make_programs_txs(txes: usize, hash: Hash) -> Vec<Transaction> {
|
||||
let to_key = Pubkey::new_rand();
|
||||
instructions.push(system_instruction::transfer(&from_key.pubkey(), &to_key, 1));
|
||||
}
|
||||
let mut new = Transaction::new_unsigned_instructions(&instructions);
|
||||
new.sign(&[&from_key], hash);
|
||||
new
|
||||
let message = Message::new(&instructions, Some(&from_key.pubkey()));
|
||||
Transaction::new(&[&from_key], message, hash)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
@@ -1711,7 +1711,7 @@ pub mod tests {
|
||||
&leader_vote_keypair.pubkey(),
|
||||
vote,
|
||||
);
|
||||
let vote_msg = Message::new_with_payer(&[vote_ix], Some(&leader_vote_keypair.pubkey()));
|
||||
let vote_msg = Message::new(&[vote_ix], Some(&leader_vote_keypair.pubkey()));
|
||||
let vote_tx = Transaction::new(&[&leader_vote_keypair], vote_msg, Hash::default());
|
||||
let shreds = entries_to_test_shreds(
|
||||
vec![next_entry_mut(&mut Hash::default(), 0, vec![vote_tx])],
|
||||
@@ -3425,7 +3425,7 @@ pub mod tests {
|
||||
bank.get_minimum_balance_for_rent_exemption(VoteState::size_of()),
|
||||
);
|
||||
|
||||
let message = Message::new_with_payer(&instructions, Some(&alice.pubkey()));
|
||||
let message = Message::new(&instructions, Some(&alice.pubkey()));
|
||||
let transaction = Transaction::new(
|
||||
&[&alice, &alice_vote_keypair],
|
||||
message,
|
||||
|
@@ -376,6 +376,7 @@ mod tests {
|
||||
};
|
||||
use solana_sdk::{
|
||||
hash::Hash,
|
||||
message::Message,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
system_program, system_transaction,
|
||||
@@ -571,11 +572,8 @@ mod tests {
|
||||
None,
|
||||
51,
|
||||
);
|
||||
let tx = Transaction::new_signed_instructions(
|
||||
&[&contract_funds, &contract_state],
|
||||
&ixs,
|
||||
blockhash,
|
||||
);
|
||||
let message = Message::new(&ixs, Some(&contract_funds.pubkey()));
|
||||
let tx = Transaction::new(&[&contract_funds, &contract_state], message, blockhash);
|
||||
process_transaction_and_notify(&bank_forks, &tx, &rpc.subscriptions, 1).unwrap();
|
||||
sleep(Duration::from_millis(200));
|
||||
|
||||
@@ -617,7 +615,8 @@ mod tests {
|
||||
&contract_state.pubkey(),
|
||||
&bob_pubkey,
|
||||
);
|
||||
let tx = Transaction::new_signed_instructions(&[&witness], &[ix], blockhash);
|
||||
let message = Message::new(&[ix], Some(&witness.pubkey()));
|
||||
let tx = Transaction::new(&[&witness], message, blockhash);
|
||||
process_transaction_and_notify(&bank_forks, &tx, &rpc.subscriptions, 1).unwrap();
|
||||
sleep(Duration::from_millis(200));
|
||||
|
||||
|
Reference in New Issue
Block a user