diff --git a/bench-exchange/src/bench.rs b/bench-exchange/src/bench.rs index 8a0438b56..cdff1fb30 100644 --- a/bench-exchange/src/bench.rs +++ b/bench-exchange/src/bench.rs @@ -14,6 +14,7 @@ use solana_metrics::datapoint_info; use solana_sdk::{ client::{Client, SyncClient}, commitment_config::CommitmentConfig, + message::Message, pubkey::Pubkey, signature::{Keypair, Signer}, timing::{duration_as_ms, duration_as_s}, @@ -457,16 +458,14 @@ fn swapper( .map(|(signer, swap, profit)| { let s: &Keypair = &signer; let owner = &signer.pubkey(); - Transaction::new_signed_instructions( - &[s], - &[exchange_instruction::swap_request( - owner, - &swap.0.pubkey, - &swap.1.pubkey, - &profit, - )], - blockhash, - ) + let instruction = exchange_instruction::swap_request( + owner, + &swap.0.pubkey, + &swap.1.pubkey, + &profit, + ); + let message = Message::new(&[instruction], Some(&s.pubkey())); + Transaction::new(&[s], message, blockhash) }) .collect(); @@ -588,28 +587,26 @@ fn trader( let owner_pubkey = &owner.pubkey(); let trade_pubkey = &trade.pubkey(); let space = mem::size_of::() as u64; - Transaction::new_signed_instructions( - &[owner.as_ref(), trade], - &[ - system_instruction::create_account( - owner_pubkey, - trade_pubkey, - 1, - space, - &id(), - ), - exchange_instruction::trade_request( - owner_pubkey, - trade_pubkey, - *side, - pair, - tokens, - price, - src, - ), - ], - blockhash, - ) + let instructions = [ + system_instruction::create_account( + owner_pubkey, + trade_pubkey, + 1, + space, + &id(), + ), + exchange_instruction::trade_request( + owner_pubkey, + trade_pubkey, + *side, + pair, + tokens, + price, + src, + ), + ]; + let message = Message::new(&instructions, Some(&owner_pubkey)); + Transaction::new(&[owner.as_ref(), trade], message, blockhash) }) .collect(); @@ -747,13 +744,9 @@ pub fn fund_keys(client: &T, source: &Keypair, dests: &[Arc] let mut to_fund_txs: Vec<_> = chunk .par_iter() .map(|(k, m)| { - ( - k.clone(), - Transaction::new_unsigned_instructions(&system_instruction::transfer_many( - &k.pubkey(), - &m, - )), - ) + let instructions = system_instruction::transfer_many(&k.pubkey(), &m); + let message = Message::new(&instructions, Some(&k.pubkey())); + (k.clone(), Transaction::new_unsigned(message)) }) .collect(); @@ -848,9 +841,10 @@ pub fn create_token_accounts( ); let request_ix = exchange_instruction::account_request(owner_pubkey, &new_keypair.pubkey()); + let message = Message::new(&[create_ix, request_ix], Some(&owner_pubkey)); ( (from_keypair, new_keypair), - Transaction::new_unsigned_instructions(&[create_ix, request_ix]), + Transaction::new_unsigned(message), ) }) .collect(); diff --git a/bench-tps/src/bench.rs b/bench-tps/src/bench.rs index d60d7eea9..15cc31f44 100644 --- a/bench-tps/src/bench.rs +++ b/bench-tps/src/bench.rs @@ -14,6 +14,7 @@ use solana_sdk::{ commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, hash::Hash, + message::Message, pubkey::Pubkey, signature::{Keypair, Signer}, system_instruction, system_transaction, @@ -652,10 +653,9 @@ impl<'a> FundingTransactions<'a> for Vec<(&'a Keypair, Transaction)> { let to_fund_txs: Vec<(&Keypair, Transaction)> = to_fund .par_iter() .map(|(k, t)| { - let tx = Transaction::new_unsigned_instructions( - &system_instruction::transfer_many(&k.pubkey(), &t), - ); - (*k, tx) + let instructions = system_instruction::transfer_many(&k.pubkey(), &t); + let message = Message::new(&instructions, Some(&k.pubkey())); + (*k, Transaction::new_unsigned(message)) }) .collect(); make_txs.stop(); @@ -1023,11 +1023,9 @@ fn fund_move_keys( .iter() .map(|key| (key.pubkey(), total / NUM_FUNDING_KEYS as u64)) .collect(); - let tx = Transaction::new_signed_instructions( - &[funding_key], - &system_instruction::transfer_many(&funding_key.pubkey(), &pubkey_amounts), - blockhash, - ); + let instructions = system_instruction::transfer_many(&funding_key.pubkey(), &pubkey_amounts); + let message = Message::new(&instructions, Some(&funding_key.pubkey())); + let tx = Transaction::new(&[funding_key], message, blockhash); client.send_message(&[funding_key], tx.message).unwrap(); let mut balance = 0; for _ in 0..20 { diff --git a/cli/src/checks.rs b/cli/src/checks.rs index e0f216954..f1c651487 100644 --- a/cli/src/checks.rs +++ b/cli/src/checks.rs @@ -137,11 +137,11 @@ mod tests { let pubkey0 = Pubkey::new(&[0; 32]); let pubkey1 = Pubkey::new(&[1; 32]); let ix0 = system_instruction::transfer(&pubkey0, &pubkey1, 1); - let message0 = Message::new(&[ix0]); + let message0 = Message::new(&[ix0], Some(&pubkey0)); let ix0 = system_instruction::transfer(&pubkey0, &pubkey1, 1); let ix1 = system_instruction::transfer(&pubkey1, &pubkey0, 1); - let message1 = Message::new(&[ix0, ix1]); + let message1 = Message::new(&[ix0, ix1], Some(&pubkey0)); let mut mocks = HashMap::new(); mocks.insert(RpcRequest::GetBalance, account_balance_response.clone()); @@ -225,13 +225,13 @@ mod tests { let pubkey0 = Pubkey::new(&[0; 32]); let pubkey1 = Pubkey::new(&[1; 32]); let ix0 = system_instruction::transfer(&pubkey0, &pubkey1, 1); - let message0 = Message::new(&[ix0]); + let message0 = Message::new(&[ix0], Some(&pubkey0)); assert_eq!(calculate_fee(&fee_calculator, &[&message0]), 1); // Two messages, additive fees. let ix0 = system_instruction::transfer(&pubkey0, &pubkey1, 1); let ix1 = system_instruction::transfer(&pubkey1, &pubkey0, 1); - let message1 = Message::new(&[ix0, ix1]); + let message1 = Message::new(&[ix0, ix1], Some(&pubkey0)); assert_eq!(calculate_fee(&fee_calculator, &[&message0, &message1]), 3); } diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 23f8b53ec..d30bc94e5 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -1377,7 +1377,7 @@ fn process_deploy( program_data.len() as u64, &bpf_loader::id(), ); - let message = Message::new(&[ix]); + let message = Message::new(&[ix], Some(&config.signers[0].pubkey())); let mut create_account_tx = Transaction::new_unsigned(message); let signers = [config.signers[0], program_id]; create_account_tx.try_sign(&signers, blockhash)?; @@ -1390,7 +1390,7 @@ fn process_deploy( (i * DATA_CHUNK_SIZE) as u32, chunk.to_vec(), ); - let message = Message::new_with_payer(&[instruction], Some(&signers[0].pubkey())); + let message = Message::new(&[instruction], Some(&signers[0].pubkey())); let mut tx = Transaction::new_unsigned(message); tx.try_sign(&signers, blockhash)?; write_transactions.push(tx); @@ -1400,7 +1400,7 @@ fn process_deploy( } let instruction = loader_instruction::finalize(&program_id.pubkey(), &bpf_loader::id()); - let message = Message::new_with_payer(&[instruction], Some(&signers[0].pubkey())); + let message = Message::new(&[instruction], Some(&signers[0].pubkey())); let mut finalize_tx = Transaction::new_unsigned(message); finalize_tx.try_sign(&signers, blockhash)?; messages.push(&finalize_tx.message); @@ -1483,7 +1483,7 @@ fn process_pay( if let Some(nonce_account) = &nonce_account { Message::new_with_nonce(vec![ix], None, nonce_account, &nonce_authority.pubkey()) } else { - Message::new(&[ix]) + Message::new(&[ix], Some(&config.signers[0].pubkey())) } }; @@ -1539,7 +1539,7 @@ fn process_pay( cancelable, lamports, ); - Message::new(&ixs) + Message::new(&ixs, Some(&config.signers[0].pubkey())) }; let (message, _) = resolve_spend_tx_and_check_account_balance( rpc_client, @@ -1590,7 +1590,7 @@ fn process_pay( cancelable, lamports, ); - Message::new(&ixs) + Message::new(&ixs, Some(&config.signers[0].pubkey())) }; let (message, _) = resolve_spend_tx_and_check_account_balance( rpc_client, @@ -1633,7 +1633,7 @@ fn process_cancel(rpc_client: &RpcClient, config: &CliConfig, pubkey: &Pubkey) - pubkey, &config.signers[0].pubkey(), ); - let message = Message::new(&[ix]); + let message = Message::new(&[ix], Some(&config.signers[0].pubkey())); let mut tx = Transaction::new_unsigned(message); tx.try_sign(&config.signers, blockhash)?; check_account_for_fee_with_commitment( @@ -1663,7 +1663,7 @@ fn process_time_elapsed( .value; let ix = budget_instruction::apply_timestamp(&config.signers[0].pubkey(), pubkey, to, dt); - let message = Message::new(&[ix]); + let message = Message::new(&[ix], Some(&config.signers[0].pubkey())); let mut tx = Transaction::new_unsigned(message); tx.try_sign(&config.signers, blockhash)?; check_account_for_fee_with_commitment( @@ -1714,7 +1714,7 @@ fn process_transfer( &nonce_authority.pubkey(), ) } else { - Message::new_with_payer(&ixs, Some(&fee_payer.pubkey())) + Message::new(&ixs, Some(&fee_payer.pubkey())) } }; @@ -1765,7 +1765,7 @@ fn process_witness( .value; let ix = budget_instruction::apply_signature(&config.signers[0].pubkey(), pubkey, to); - let message = Message::new(&[ix]); + let message = Message::new(&[ix], Some(&config.signers[0].pubkey())); let mut tx = Transaction::new_unsigned(message); tx.try_sign(&config.signers, blockhash)?; check_account_for_fee_with_commitment( diff --git a/cli/src/cluster_query.rs b/cli/src/cluster_query.rs index 398c6e72e..f90e92bcf 100644 --- a/cli/src/cluster_query.rs +++ b/cli/src/cluster_query.rs @@ -892,7 +892,7 @@ pub fn process_ping( let build_message = |lamports| { let ix = system_instruction::transfer(&config.signers[0].pubkey(), &to, lamports); - Message::new(&[ix]) + Message::new(&[ix], Some(&config.signers[0].pubkey())) }; let (message, _) = resolve_spend_tx_and_check_account_balance( rpc_client, diff --git a/cli/src/nonce.rs b/cli/src/nonce.rs index 9c3719521..6703d7945 100644 --- a/cli/src/nonce.rs +++ b/cli/src/nonce.rs @@ -453,7 +453,7 @@ pub fn process_authorize_nonce_account( let nonce_authority = config.signers[nonce_authority]; let ix = authorize_nonce_account(nonce_account, &nonce_authority.pubkey(), new_authority); - let message = Message::new_with_payer(&[ix], Some(&config.signers[0].pubkey())); + let message = Message::new(&[ix], Some(&config.signers[0].pubkey())); let mut tx = Transaction::new_unsigned(message); tx.try_sign(&config.signers, recent_blockhash)?; @@ -512,7 +512,7 @@ pub fn process_create_nonce_account( lamports, ) }; - Message::new_with_payer(&ixs, Some(&config.signers[0].pubkey())) + Message::new(&ixs, Some(&config.signers[0].pubkey())) }; let (recent_blockhash, fee_calculator, _) = rpc_client @@ -600,7 +600,7 @@ pub fn process_new_nonce( let (recent_blockhash, fee_calculator, _) = rpc_client .get_recent_blockhash_with_commitment(config.commitment)? .value; - let message = Message::new_with_payer(&[ix], Some(&config.signers[0].pubkey())); + let message = Message::new(&[ix], Some(&config.signers[0].pubkey())); let mut tx = Transaction::new_unsigned(message); tx.try_sign(&config.signers, recent_blockhash)?; check_account_for_fee_with_commitment( @@ -667,7 +667,7 @@ pub fn process_withdraw_from_nonce_account( destination_account_pubkey, lamports, ); - let message = Message::new_with_payer(&[ix], Some(&config.signers[0].pubkey())); + let message = Message::new(&[ix], Some(&config.signers[0].pubkey())); let mut tx = Transaction::new_unsigned(message); tx.try_sign(&config.signers, recent_blockhash)?; check_account_for_fee_with_commitment( diff --git a/cli/src/stake.rs b/cli/src/stake.rs index 4860e1d60..653d3424c 100644 --- a/cli/src/stake.rs +++ b/cli/src/stake.rs @@ -891,7 +891,7 @@ pub fn process_create_stake_account( &nonce_authority.pubkey(), ) } else { - Message::new_with_payer(&ixs, Some(&fee_payer.pubkey())) + Message::new(&ixs, Some(&fee_payer.pubkey())) } }; @@ -996,7 +996,7 @@ pub fn process_stake_authorize( &nonce_authority.pubkey(), ) } else { - Message::new_with_payer(&ixs, Some(&fee_payer.pubkey())) + Message::new(&ixs, Some(&fee_payer.pubkey())) }; let mut tx = Transaction::new_unsigned(message); @@ -1056,7 +1056,7 @@ pub fn process_deactivate_stake_account( &nonce_authority.pubkey(), ) } else { - Message::new_with_payer(&ixs, Some(&fee_payer.pubkey())) + Message::new(&ixs, Some(&fee_payer.pubkey())) }; let mut tx = Transaction::new_unsigned(message); @@ -1125,7 +1125,7 @@ pub fn process_withdraw_stake( &nonce_authority.pubkey(), ) } else { - Message::new_with_payer(&ixs, Some(&fee_payer.pubkey())) + Message::new(&ixs, Some(&fee_payer.pubkey())) }; let mut tx = Transaction::new_unsigned(message); @@ -1265,7 +1265,7 @@ pub fn process_split_stake( &nonce_authority.pubkey(), ) } else { - Message::new_with_payer(&ixs, Some(&fee_payer.pubkey())) + Message::new(&ixs, Some(&fee_payer.pubkey())) }; let mut tx = Transaction::new_unsigned(message); @@ -1364,7 +1364,7 @@ pub fn process_merge_stake( &nonce_authority.pubkey(), ) } else { - Message::new_with_payer(&ixs, Some(&fee_payer.pubkey())) + Message::new(&ixs, Some(&fee_payer.pubkey())) }; let mut tx = Transaction::new_unsigned(message); @@ -1427,7 +1427,7 @@ pub fn process_stake_set_lockup( &nonce_authority.pubkey(), ) } else { - Message::new_with_payer(&ixs, Some(&fee_payer.pubkey())) + Message::new(&ixs, Some(&fee_payer.pubkey())) }; let mut tx = Transaction::new_unsigned(message); @@ -1712,7 +1712,7 @@ pub fn process_delegate_stake( &nonce_authority.pubkey(), ) } else { - Message::new_with_payer(&ixs, Some(&fee_payer.pubkey())) + Message::new(&ixs, Some(&fee_payer.pubkey())) }; let mut tx = Transaction::new_unsigned(message); diff --git a/cli/src/validator_info.rs b/cli/src/validator_info.rs index a03ce0693..207a2df06 100644 --- a/cli/src/validator_info.rs +++ b/cli/src/validator_info.rs @@ -346,7 +346,7 @@ pub fn process_set_validator_info( keys, &validator_info, )]); - Message::new(&instructions) + Message::new(&instructions, Some(&config.signers[0].pubkey())) } else { println!( "Updating Validator {:?} info at: {:?}", @@ -359,7 +359,7 @@ pub fn process_set_validator_info( keys, &validator_info, )]; - Message::new_with_payer(&instructions, Some(&config.signers[0].pubkey())) + Message::new(&instructions, Some(&config.signers[0].pubkey())) } }; diff --git a/cli/src/vote.rs b/cli/src/vote.rs index 672b14e42..1c45ae896 100644 --- a/cli/src/vote.rs +++ b/cli/src/vote.rs @@ -469,7 +469,7 @@ pub fn process_create_vote_account( lamports, ) }; - Message::new(&ixs) + Message::new(&ixs, Some(&config.signers[0].pubkey())) }; if let Ok(response) = @@ -540,7 +540,7 @@ pub fn process_vote_authorize( vote_authorize, // vote or withdraw )]; - let message = Message::new_with_payer(&ixs, Some(&config.signers[0].pubkey())); + let message = Message::new(&ixs, Some(&config.signers[0].pubkey())); let mut tx = Transaction::new_unsigned(message); tx.try_sign(&config.signers, recent_blockhash)?; check_account_for_fee_with_commitment( @@ -580,7 +580,7 @@ pub fn process_vote_update_validator( &new_identity_pubkey, )]; - let message = Message::new_with_payer(&ixs, Some(&config.signers[0].pubkey())); + let message = Message::new(&ixs, Some(&config.signers[0].pubkey())); let mut tx = Transaction::new_unsigned(message); tx.try_sign(&config.signers, recent_blockhash)?; check_account_for_fee_with_commitment( @@ -614,7 +614,7 @@ pub fn process_vote_update_commission( commission, )]; - let message = Message::new_with_payer(&ixs, Some(&config.signers[0].pubkey())); + let message = Message::new(&ixs, Some(&config.signers[0].pubkey())); let mut tx = Transaction::new_unsigned(message); tx.try_sign(&config.signers, recent_blockhash)?; check_account_for_fee_with_commitment( @@ -743,7 +743,7 @@ pub fn process_withdraw_from_vote_account( destination_account_pubkey, ); - let message = Message::new_with_payer(&[ix], Some(&config.signers[0].pubkey())); + let message = Message::new(&[ix], Some(&config.signers[0].pubkey())); let mut transaction = Transaction::new_unsigned(message); transaction.try_sign(&config.signers, recent_blockhash)?; check_account_for_fee_with_commitment( diff --git a/client/src/thin_client.rs b/client/src/thin_client.rs index d6ae8c4a9..dc6d951ec 100644 --- a/client/src/thin_client.rs +++ b/client/src/thin_client.rs @@ -336,7 +336,7 @@ impl SyncClient for ThinClient { keypair: &Keypair, instruction: Instruction, ) -> TransportResult { - let message = Message::new(&[instruction]); + let message = Message::new(&[instruction], Some(&keypair.pubkey())); self.send_message(&[keypair], message) } @@ -574,7 +574,7 @@ impl AsyncClient for ThinClient { instruction: Instruction, recent_blockhash: Hash, ) -> TransportResult { - let message = Message::new(&[instruction]); + let message = Message::new(&[instruction], Some(&keypair.pubkey())); self.async_send_message(&[keypair], message, recent_blockhash) } fn async_transfer( diff --git a/core/benches/banking_stage.rs b/core/benches/banking_stage.rs index 3e2b09fee..0ca4633d9 100644 --- a/core/benches/banking_stage.rs +++ b/core/benches/banking_stage.rs @@ -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 { 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() } diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 0a04c6196..808006898 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -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, diff --git a/core/src/rpc_pubsub.rs b/core/src/rpc_pubsub.rs index 78e20b73a..2acb633a4 100644 --- a/core/src/rpc_pubsub.rs +++ b/core/src/rpc_pubsub.rs @@ -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)); diff --git a/faucet/src/faucet.rs b/faucet/src/faucet.rs index cb9b99d2f..6bf82d522 100644 --- a/faucet/src/faucet.rs +++ b/faucet/src/faucet.rs @@ -125,9 +125,10 @@ impl Faucet { ); info!("Requesting airdrop of {} to {:?}", lamports, to); + let mint_pubkey = self.mint_keypair.pubkey(); let create_instruction = - system_instruction::transfer(&self.mint_keypair.pubkey(), &to, lamports); - let message = Message::new(&[create_instruction]); + system_instruction::transfer(&mint_pubkey, &to, lamports); + let message = Message::new(&[create_instruction], Some(&mint_pubkey)); Ok(Transaction::new(&[&self.mint_keypair], message, blockhash)) } else { Err(Error::new( @@ -413,7 +414,7 @@ mod tests { let keypair = Keypair::new(); let expected_instruction = system_instruction::transfer(&keypair.pubkey(), &to, lamports); - let message = Message::new(&[expected_instruction]); + let message = Message::new(&[expected_instruction], Some(&keypair.pubkey())); let expected_tx = Transaction::new(&[&keypair], message, blockhash); let expected_bytes = serialize(&expected_tx).unwrap(); let mut expected_vec_with_length = vec![0; 2]; diff --git a/faucet/tests/local-faucet.rs b/faucet/tests/local-faucet.rs index 5b1749f65..aeca323f7 100644 --- a/faucet/tests/local-faucet.rs +++ b/faucet/tests/local-faucet.rs @@ -16,7 +16,7 @@ fn test_local_faucet() { let lamports = 50; let blockhash = Hash::new(&to.as_ref()); let create_instruction = system_instruction::transfer(&keypair.pubkey(), &to, lamports); - let message = Message::new(&[create_instruction]); + let message = Message::new(&[create_instruction], Some(&keypair.pubkey())); let expected_tx = Transaction::new(&[&keypair], message, blockhash); let (sender, receiver) = channel(); diff --git a/install/src/command.rs b/install/src/command.rs index 0dac49b73..9d5ecbe94 100644 --- a/install/src/command.rs +++ b/install/src/command.rs @@ -218,9 +218,9 @@ fn new_update_manifest( lamports, vec![], // additional keys ); - let mut transaction = Transaction::new_unsigned_instructions(&instructions); + let message = Message::new(&instructions, Some(&from_keypair.pubkey())); let signers = [from_keypair, update_manifest_keypair]; - transaction.sign(&signers, recent_blockhash); + let transaction = Transaction::new(&signers, message, recent_blockhash); rpc_client.send_and_confirm_transaction(&transaction)?; } Ok(()) @@ -243,7 +243,7 @@ fn store_update_manifest( update_manifest, ); - let message = Message::new_with_payer(&[instruction], Some(&from_keypair.pubkey())); + let message = Message::new(&[instruction], Some(&from_keypair.pubkey())); let transaction = Transaction::new(&signers, message, recent_blockhash); rpc_client.send_and_confirm_transaction(&transaction)?; Ok(()) diff --git a/keygen/src/keygen.rs b/keygen/src/keygen.rs index 65c13457f..99c510785 100644 --- a/keygen/src/keygen.rs +++ b/keygen/src/keygen.rs @@ -592,11 +592,14 @@ fn do_main(matches: &ArgMatches<'_>) -> Result<(), Box> { } ("verify", Some(matches)) => { let keypair = get_keypair_from_matches(matches, config, &mut wallet_manager)?; - let simple_message = Message::new(&[Instruction::new( - Pubkey::default(), - &0, - vec![AccountMeta::new(keypair.pubkey(), true)], - )]) + let simple_message = Message::new( + &[Instruction::new( + Pubkey::default(), + &0, + vec![AccountMeta::new(keypair.pubkey(), true)], + )], + Some(&keypair.pubkey()), + ) .serialize(); let signature = keypair.try_sign_message(&simple_message)?; let pubkey_bs58 = matches.value_of("pubkey").unwrap(); diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index e380cbbc2..f7c195573 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -5225,7 +5225,7 @@ pub mod tests { timestamp, }; let vote_ix = vote_instruction::vote(&keypair.pubkey(), &keypair.pubkey(), vote); - let vote_msg = Message::new_with_payer(&[vote_ix], Some(&keypair.pubkey())); + let vote_msg = Message::new(&[vote_ix], Some(&keypair.pubkey())); let vote_tx = Transaction::new(&[keypair], vote_msg, Hash::default()); vote_entries.push(next_entry_mut(&mut Hash::default(), 0, vec![vote_tx])); diff --git a/ledger/src/entry.rs b/ledger/src/entry.rs index 2ce5acbf7..b22d540ab 100644 --- a/ledger/src/entry.rs +++ b/ledger/src/entry.rs @@ -677,6 +677,7 @@ mod tests { use solana_budget_program::budget_instruction; use solana_sdk::{ hash::{hash, Hash}, + message::Message, signature::{Keypair, Signer}, system_transaction, transaction::Transaction, @@ -687,19 +688,22 @@ mod tests { let budget_contract = Keypair::new(); let budget_pubkey = budget_contract.pubkey(); let ixs = budget_instruction::payment(&pubkey, &pubkey, &budget_pubkey, 1); - Transaction::new_signed_instructions(&[keypair, &budget_contract], &ixs, hash) + let message = Message::new(&ixs, Some(&pubkey)); + Transaction::new(&[keypair, &budget_contract], message, hash) } fn create_sample_timestamp(keypair: &Keypair, hash: Hash) -> Transaction { let pubkey = keypair.pubkey(); let ix = budget_instruction::apply_timestamp(&pubkey, &pubkey, &pubkey, Utc::now()); - Transaction::new_signed_instructions(&[keypair], &[ix], hash) + let message = Message::new(&[ix], Some(&pubkey)); + Transaction::new(&[keypair], message, hash) } fn create_sample_apply_signature(keypair: &Keypair, hash: Hash) -> Transaction { let pubkey = keypair.pubkey(); let ix = budget_instruction::apply_signature(&pubkey, &pubkey, &pubkey); - Transaction::new_signed_instructions(&[keypair], &[ix], hash) + let message = Message::new(&[ix], Some(&pubkey)); + Transaction::new(&[keypair], message, hash) } #[test] diff --git a/local-cluster/src/local_cluster.rs b/local-cluster/src/local_cluster.rs index 013f77cf7..fc752e180 100644 --- a/local-cluster/src/local_cluster.rs +++ b/local-cluster/src/local_cluster.rs @@ -21,6 +21,7 @@ use solana_sdk::{ commitment_config::CommitmentConfig, epoch_schedule::EpochSchedule, genesis_config::{GenesisConfig, OperatingMode}, + message::Message, poh_config::PohConfig, pubkey::Pubkey, signature::{Keypair, Signer}, @@ -407,19 +408,21 @@ impl LocalCluster { { // 1) Create vote account - let mut transaction = Transaction::new_signed_instructions( + let instructions = vote_instruction::create_account( + &from_account.pubkey(), + &vote_account_pubkey, + &VoteInit { + node_pubkey, + authorized_voter: vote_account_pubkey, + authorized_withdrawer: vote_account_pubkey, + commission: 0, + }, + amount, + ); + let message = Message::new(&instructions, Some(&from_account.pubkey())); + let mut transaction = Transaction::new( &[from_account.as_ref(), vote_account], - &vote_instruction::create_account( - &from_account.pubkey(), - &vote_account_pubkey, - &VoteInit { - node_pubkey, - authorized_voter: vote_account_pubkey, - authorized_withdrawer: vote_account_pubkey, - commission: 0, - }, - amount, - ), + message, client .get_recent_blockhash_with_commitment(CommitmentConfig::recent()) .unwrap() @@ -436,16 +439,18 @@ impl LocalCluster { ) .expect("get balance"); - let mut transaction = Transaction::new_signed_instructions( + let instructions = stake_instruction::create_account_and_delegate_stake( + &from_account.pubkey(), + &stake_account_pubkey, + &vote_account_pubkey, + &Authorized::auto(&stake_account_pubkey), + &Lockup::default(), + amount, + ); + let message = Message::new(&instructions, Some(&from_account.pubkey())); + let mut transaction = Transaction::new( &[from_account.as_ref(), &stake_account_keypair], - &stake_instruction::create_account_and_delegate_stake( - &from_account.pubkey(), - &stake_account_pubkey, - &vote_account_pubkey, - &Authorized::auto(&stake_account_pubkey), - &Lockup::default(), - amount, - ), + message, client .get_recent_blockhash_with_commitment(CommitmentConfig::recent()) .unwrap() diff --git a/programs/bpf/tests/programs.rs b/programs/bpf/tests/programs.rs index b36023ed2..29115b659 100644 --- a/programs/bpf/tests/programs.rs +++ b/programs/bpf/tests/programs.rs @@ -308,7 +308,6 @@ mod bpf { result.unwrap_err().unwrap(), TransactionError::InstructionError(0, InstructionError::MaxSeedLengthExceeded) ); - } } @@ -364,10 +363,12 @@ mod bpf { let derived_key2 = Pubkey::create_program_address(&[b"Lil'", b"Bits"], &invoked_program_id).unwrap(); let derived_key3 = - Pubkey::create_program_address(&[derived_key2.as_ref()], &invoked_program_id).unwrap(); + Pubkey::create_program_address(&[derived_key2.as_ref()], &invoked_program_id) + .unwrap(); + let mint_pubkey = mint_keypair.pubkey(); let account_metas = vec![ - AccountMeta::new(mint_keypair.pubkey(), true), + AccountMeta::new(mint_pubkey, true), AccountMeta::new(argument_keypair.pubkey(), true), AccountMeta::new_readonly(invoked_program_id, false), AccountMeta::new(invoked_argument_keypair.pubkey(), true), @@ -384,7 +385,7 @@ mod bpf { let instruction = Instruction::new(invoke_program_id, &TEST_SUCCESS, account_metas.clone()); - let message = Message::new(&[instruction]); + let message = Message::new(&[instruction], Some(&mint_pubkey)); assert!(bank_client .send_message( &[ @@ -404,7 +405,7 @@ mod bpf { &TEST_PRIVILEGE_ESCALATION_SIGNER, account_metas.clone(), ); - let message = Message::new(&[instruction]); + let message = Message::new(&[instruction], Some(&mint_pubkey)); assert_eq!( bank_client .send_message( @@ -426,7 +427,7 @@ mod bpf { &TEST_PRIVILEGE_ESCALATION_WRITABLE, account_metas.clone(), ); - let message = Message::new(&[instruction]); + let message = Message::new(&[instruction], Some(&mint_pubkey)); assert_eq!( bank_client .send_message( diff --git a/programs/bpf_loader/src/syscalls.rs b/programs/bpf_loader/src/syscalls.rs index 32b720b82..3a78a34bd 100644 --- a/programs/bpf_loader/src/syscalls.rs +++ b/programs/bpf_loader/src/syscalls.rs @@ -774,7 +774,7 @@ fn call<'a>( ro_regions, )?; verify_instruction(syscall, &instruction, &signers)?; - let message = Message::new_with_payer(&[instruction], None); + let message = Message::new(&[instruction], None); let callee_program_id_index = message.instructions[0].program_id_index as usize; let callee_program_id = message.account_keys[callee_program_id_index]; let (accounts, refs) = syscall.translate_accounts( diff --git a/programs/budget/src/budget_processor.rs b/programs/budget/src/budget_processor.rs index 4b4318da5..a597d2831 100644 --- a/programs/budget/src/budget_processor.rs +++ b/programs/budget/src/budget_processor.rs @@ -256,7 +256,7 @@ mod tests { budget_instruction::payment(&alice_pubkey, &bob_pubkey, &budget_pubkey, 1); instructions[1].accounts = vec![]; //