Make space for a new Transaction::new
This commit is contained in:
parent
d497b99abb
commit
8c69c40834
|
@ -564,7 +564,10 @@ fn fund_keys(client: &ThinClient, source: &Keypair, dests: &[Keypair], lamports:
|
||||||
.map(|(k, m)| {
|
.map(|(k, m)| {
|
||||||
(
|
(
|
||||||
k.clone(),
|
k.clone(),
|
||||||
Transaction::new(SystemInstruction::new_move_many(&k.pubkey(), &m)),
|
Transaction::new_unsigned_instructions(SystemInstruction::new_move_many(
|
||||||
|
&k.pubkey(),
|
||||||
|
&m,
|
||||||
|
)),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
@ -410,7 +410,7 @@ impl Replicator {
|
||||||
self.slot,
|
self.slot,
|
||||||
Signature::new(self.signature.as_ref()),
|
Signature::new(self.signature.as_ref()),
|
||||||
);
|
);
|
||||||
let mut tx = Transaction::new(vec![ix]);
|
let mut tx = Transaction::new_unsigned_instructions(vec![ix]);
|
||||||
client
|
client
|
||||||
.retry_transfer(&self.keypair, &mut tx, 10)
|
.retry_transfer(&self.keypair, &mut tx, 10)
|
||||||
.expect("transfer didn't work!");
|
.expect("transfer didn't work!");
|
||||||
|
|
|
@ -293,7 +293,7 @@ impl StorageStage {
|
||||||
entry_id,
|
entry_id,
|
||||||
entry_height,
|
entry_height,
|
||||||
);
|
);
|
||||||
let tx = Transaction::new(vec![ix]);
|
let tx = Transaction::new_unsigned_instructions(vec![ix]);
|
||||||
tx_sender.send(tx)?;
|
tx_sender.send(tx)?;
|
||||||
|
|
||||||
seed.copy_from_slice(&signature.as_ref()[..32]);
|
seed.copy_from_slice(&signature.as_ref()[..32]);
|
||||||
|
@ -611,7 +611,7 @@ mod tests {
|
||||||
0,
|
0,
|
||||||
keypair.sign_message(b"test"),
|
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 mining_txs = vec![mining_proof_tx];
|
||||||
|
|
||||||
let proof_entries = vec![Entry::new(&Hash::default(), 1, mining_txs)];
|
let proof_entries = vec![Entry::new(&Hash::default(), 1, mining_txs)];
|
||||||
|
|
|
@ -203,7 +203,7 @@ fn new_update_manifest(
|
||||||
&update_manifest_keypair.pubkey(),
|
&update_manifest_keypair.pubkey(),
|
||||||
1, // lamports
|
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);
|
transaction.sign(&[from_keypair], recect_blockhash);
|
||||||
|
|
||||||
rpc_client.send_and_confirm_transaction(&mut transaction, from_keypair)?;
|
rpc_client.send_and_confirm_transaction(&mut transaction, from_keypair)?;
|
||||||
|
@ -225,7 +225,7 @@ fn store_update_manifest(
|
||||||
&update_manifest_keypair.pubkey(),
|
&update_manifest_keypair.pubkey(),
|
||||||
update_manifest,
|
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);
|
transaction.sign(&[from_keypair, update_manifest_keypair], recect_blockhash);
|
||||||
rpc_client.send_and_confirm_transaction(&mut transaction, from_keypair)?;
|
rpc_client.send_and_confirm_transaction(&mut transaction, from_keypair)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -196,7 +196,7 @@ mod tests {
|
||||||
alice_client.transfer(1, &mallory_pubkey).unwrap();
|
alice_client.transfer(1, &mallory_pubkey).unwrap();
|
||||||
let instruction =
|
let instruction =
|
||||||
BudgetInstruction::new_apply_signature(&mallory_pubkey, &budget_pubkey, &bob_pubkey);
|
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.
|
// Attack! Part 2: Point the instruction to the expected, but unsigned, key.
|
||||||
transaction.account_keys.push(alice_pubkey);
|
transaction.account_keys.push(alice_pubkey);
|
||||||
|
@ -243,7 +243,7 @@ mod tests {
|
||||||
&bob_pubkey,
|
&bob_pubkey,
|
||||||
dt,
|
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.
|
// Attack! Part 2: Point the instruction to the expected, but unsigned, key.
|
||||||
transaction.account_keys.push(alice_pubkey);
|
transaction.account_keys.push(alice_pubkey);
|
||||||
|
|
|
@ -131,7 +131,7 @@ mod tests {
|
||||||
let instruction = ConfigInstruction::new_store(&from_pubkey, &config_pubkey, &my_config);
|
let instruction = ConfigInstruction::new_store(&from_pubkey, &config_pubkey, &my_config);
|
||||||
|
|
||||||
// Replace instruction data with a vector that's too large
|
// 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];
|
transaction.instructions[0].data = vec![0; 123];
|
||||||
config_client.process_transaction(transaction).unwrap_err();
|
config_client.process_transaction(transaction).unwrap_err();
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,8 @@ mod tests {
|
||||||
ConfigInstruction::new_store(&from_pubkey, &config_pubkey, &my_config);
|
ConfigInstruction::new_store(&from_pubkey, &config_pubkey, &my_config);
|
||||||
|
|
||||||
// Don't sign the transaction with `config_client`
|
// 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());
|
transaction.sign_unchecked(&[&system_keypair], bank.last_blockhash());
|
||||||
let system_client = BankClient::new(&bank, system_keypair);
|
let system_client = BankClient::new(&bank, system_keypair);
|
||||||
system_client.process_transaction(transaction).unwrap_err();
|
system_client.process_transaction(transaction).unwrap_err();
|
||||||
|
|
|
@ -21,7 +21,7 @@ impl ExchangeTransaction {
|
||||||
let space = mem::size_of::<ExchangeState>() as u64;
|
let space = mem::size_of::<ExchangeState>() as u64;
|
||||||
let create_ix = SystemInstruction::new_program_account(owner_id, new, 1, space, &id());
|
let create_ix = SystemInstruction::new_program_account(owner_id, new, 1, space, &id());
|
||||||
let request_ix = ExchangeInstruction::new_account_request(owner_id, new);
|
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.fee = fee;
|
||||||
tx.sign(&[owner], recent_blockhash);
|
tx.sign(&[owner], recent_blockhash);
|
||||||
tx
|
tx
|
||||||
|
@ -39,7 +39,7 @@ impl ExchangeTransaction {
|
||||||
let owner_id = &owner.pubkey();
|
let owner_id = &owner.pubkey();
|
||||||
let request_ix =
|
let request_ix =
|
||||||
ExchangeInstruction::new_transfer_request(owner_id, to, from, token, tokens);
|
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.fee = fee;
|
||||||
tx.sign(&[owner], recent_blockhash);
|
tx.sign(&[owner], recent_blockhash);
|
||||||
tx
|
tx
|
||||||
|
@ -71,7 +71,7 @@ impl ExchangeTransaction {
|
||||||
src_account,
|
src_account,
|
||||||
dst_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.fee = fee;
|
||||||
tx.sign(&[owner], recent_blockhash);
|
tx.sign(&[owner], recent_blockhash);
|
||||||
tx
|
tx
|
||||||
|
@ -86,7 +86,7 @@ impl ExchangeTransaction {
|
||||||
) -> Transaction {
|
) -> Transaction {
|
||||||
let owner_id = &owner.pubkey();
|
let owner_id = &owner.pubkey();
|
||||||
let request_ix = ExchangeInstruction::new_trade_cancellation(owner_id, trade, account);
|
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.fee = fee;
|
||||||
tx.sign(&[owner], recent_blockhash);
|
tx.sign(&[owner], recent_blockhash);
|
||||||
tx
|
tx
|
||||||
|
@ -115,7 +115,7 @@ impl ExchangeTransaction {
|
||||||
from_trade_account,
|
from_trade_account,
|
||||||
profit_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.fee = fee;
|
||||||
tx.sign(&[owner], recent_blockhash);
|
tx.sign(&[owner], recent_blockhash);
|
||||||
tx
|
tx
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl<'a> BankClient<'a> {
|
||||||
&self,
|
&self,
|
||||||
instructions: Vec<Instruction>,
|
instructions: Vec<Instruction>,
|
||||||
) -> Result<(), TransactionError> {
|
) -> 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.
|
/// Create and process a transaction from a single instruction.
|
||||||
|
|
|
@ -83,7 +83,7 @@ impl Transaction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(instructions: Vec<Instruction>) -> Self {
|
pub fn new_unsigned_instructions(instructions: Vec<Instruction>) -> Self {
|
||||||
let message = Message::new(instructions);
|
let message = Message::new(instructions);
|
||||||
Self::new_unsigned_message(message)
|
Self::new_unsigned_message(message)
|
||||||
}
|
}
|
||||||
|
@ -576,7 +576,7 @@ mod tests {
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_transaction_missing_key() {
|
fn test_transaction_missing_key() {
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
Transaction::new(vec![]).sign(&[&keypair], Hash::default());
|
Transaction::new_unsigned_instructions(vec![]).sign(&[&keypair], Hash::default());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -586,7 +586,8 @@ mod tests {
|
||||||
let keypair0 = Keypair::new();
|
let keypair0 = Keypair::new();
|
||||||
let id0 = keypair0.pubkey();
|
let id0 = keypair0.pubkey();
|
||||||
let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]);
|
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]
|
#[test]
|
||||||
|
@ -596,7 +597,7 @@ mod tests {
|
||||||
let keypair0 = Keypair::new();
|
let keypair0 = Keypair::new();
|
||||||
let wrong_id = Pubkey::default();
|
let wrong_id = Pubkey::default();
|
||||||
let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(wrong_id, true)]);
|
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]
|
#[test]
|
||||||
|
@ -605,7 +606,7 @@ mod tests {
|
||||||
let keypair0 = Keypair::new();
|
let keypair0 = Keypair::new();
|
||||||
let id0 = keypair0.pubkey();
|
let id0 = keypair0.pubkey();
|
||||||
let ix = Instruction::new(program_id, &0, vec![AccountMeta::new(id0, true)]);
|
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());
|
tx.sign(&[&keypair0], Hash::default());
|
||||||
assert_eq!(tx.instructions[0], CompiledInstruction::new(0, &0, vec![0]));
|
assert_eq!(tx.instructions[0], CompiledInstruction::new(0, &0, vec![0]));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue