Remove fee-payer guesswork from Message and Transaction (bp #10776) (#10785)

* 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

(cherry picked from commit 1c498369b5)

# Conflicts:
#	cli/src/nonce.rs
#	core/src/rpc.rs
#	ledger/src/blockstore.rs
#	programs/bpf/tests/programs.rs

* Fix merge

Co-authored-by: Greg Fitzgerald <greg@solana.com>
This commit is contained in:
mergify[bot]
2020-06-25 01:10:23 +00:00
committed by GitHub
parent 835bacce4f
commit 55b92c16da
47 changed files with 520 additions and 502 deletions

View File

@@ -396,16 +396,18 @@ mod test {
// Configure stake1
let stake1_keypair = Keypair::new();
let instructions = stake_instruction::create_account(
&payer.pubkey(),
&stake1_keypair.pubkey(),
&Authorized::auto(&payer.pubkey()),
&Lockup::default(),
one_sol,
);
let message = Message::new(&instructions, Some(&payer.pubkey()));
let stake1_signature = rpc_client
.send_transaction(&Transaction::new_signed_instructions(
.send_transaction(&Transaction::new(
&[&payer, &stake1_keypair],
&stake_instruction::create_account(
&payer.pubkey(),
&stake1_keypair.pubkey(),
&Authorized::auto(&payer.pubkey()),
&Lockup::default(),
one_sol,
),
message,
blockhash,
))
.unwrap();
@@ -426,35 +428,39 @@ mod test {
// Configure stake2 with non-compliant lockup
let stake2_keypair = Keypair::new();
let instructions = stake_instruction::create_account(
&payer.pubkey(),
&stake2_keypair.pubkey(),
&Authorized::auto(&payer.pubkey()),
&Lockup {
custodian: payer.pubkey(),
..Lockup::default()
},
one_sol,
);
let message = Message::new(&instructions, Some(&payer.pubkey()));
let stake2_signature = rpc_client
.send_transaction(&Transaction::new_signed_instructions(
.send_transaction(&Transaction::new(
&[&payer, &stake2_keypair],
&stake_instruction::create_account(
&payer.pubkey(),
&stake2_keypair.pubkey(),
&Authorized::auto(&payer.pubkey()),
&Lockup {
custodian: payer.pubkey(),
..Lockup::default()
},
one_sol,
),
message,
blockhash,
))
.unwrap();
// Configure stake3
let stake3_keypair = Keypair::new();
let instructions = stake_instruction::create_account(
&payer.pubkey(),
&stake3_keypair.pubkey(),
&Authorized::auto(&payer.pubkey()),
&Lockup::default(),
one_sol,
);
let message = Message::new(&instructions, Some(&payer.pubkey()));
let stake3_initialize_signature = rpc_client
.send_transaction(&Transaction::new_signed_instructions(
.send_transaction(&Transaction::new(
&[&payer, &stake3_keypair],
&stake_instruction::create_account(
&payer.pubkey(),
&stake3_keypair.pubkey(),
&Authorized::auto(&payer.pubkey()),
&Lockup::default(),
one_sol,
),
message,
blockhash,
))
.unwrap();
@@ -471,7 +477,7 @@ mod test {
.send_transaction_with_config(
&Transaction::new(
&[&payer, &stake3_keypair],
Message::new_with_payer(
Message::new(
&[stake_instruction::withdraw(
&stake3_keypair.pubkey(),
&stake3_keypair.pubkey(),
@@ -498,16 +504,18 @@ mod test {
// Configure stake4
let stake4_keypair = Keypair::new();
let instructions = stake_instruction::create_account(
&payer.pubkey(),
&stake4_keypair.pubkey(),
&Authorized::auto(&payer.pubkey()),
&Lockup::default(),
2 * one_sol,
);
let message = Message::new(&instructions, Some(&payer.pubkey()));
let stake4_initialize_signature = rpc_client
.send_transaction(&Transaction::new_signed_instructions(
.send_transaction(&Transaction::new(
&[&payer, &stake4_keypair],
&stake_instruction::create_account(
&payer.pubkey(),
&stake4_keypair.pubkey(),
&Authorized::auto(&payer.pubkey()),
&Lockup::default(),
2 * one_sol,
),
message,
blockhash,
))
.unwrap();
@@ -525,7 +533,7 @@ mod test {
.send_transaction_with_config(
&Transaction::new(
&[&payer, &stake5_keypair],
Message::new_with_payer(
Message::new(
&stake_instruction::split(
&stake4_keypair.pubkey(),
&payer.pubkey(),