diff --git a/core/src/local_cluster.rs b/core/src/local_cluster.rs index 5d6ea42aa..4770d6589 100644 --- a/core/src/local_cluster.rs +++ b/core/src/local_cluster.rs @@ -300,7 +300,6 @@ impl LocalCluster { self.entry_point_info.clone(), replicator_keypair, storage_keypair, - None, ) .unwrap(); diff --git a/core/src/replicator.rs b/core/src/replicator.rs index 04936417a..5864d5e49 100644 --- a/core/src/replicator.rs +++ b/core/src/replicator.rs @@ -22,6 +22,7 @@ use solana_client::rpc_request::RpcRequest; use solana_client::thin_client::{create_client, ThinClient}; use solana_sdk::client::{AsyncClient, SyncClient}; use solana_sdk::hash::{Hash, Hasher}; +use solana_sdk::message::Message; use solana_sdk::signature::{Keypair, KeypairUtil, Signature}; use solana_sdk::system_transaction; use solana_sdk::transaction::Transaction; @@ -60,6 +61,7 @@ pub struct Replicator { exit: Arc, slot: u64, ledger_path: String, + keypair: Arc, storage_keypair: Arc, signature: ed25519_dalek::Signature, cluster_entrypoint: ContactInfo, @@ -170,8 +172,6 @@ impl Replicator { /// * `node` - The replicator node /// * `cluster_entrypoint` - ContactInfo representing an entry into the network /// * `keypair` - Keypair for this replicator - /// * `timeout` - (optional) timeout for polling for leader/downloading the ledger. Defaults to - /// 30 seconds #[allow(clippy::new_ret_no_self)] pub fn new( ledger_path: &str, @@ -179,7 +179,6 @@ impl Replicator { cluster_entrypoint: ContactInfo, keypair: Arc, storage_keypair: Arc, - _timeout: Option, ) -> Result { let exit = Arc::new(AtomicBool::new(false)); @@ -277,6 +276,7 @@ impl Replicator { exit, slot, ledger_path: ledger_path.to_string(), + keypair, storage_keypair, signature, cluster_entrypoint, @@ -443,23 +443,31 @@ impl Replicator { self.cluster_entrypoint.client_facing_addr(), FULLNODE_PORT_RANGE, ); - // No point if we've got no storage account + // No point if we've got no storage account... assert!( client .poll_get_balance(&self.storage_keypair.pubkey()) .unwrap() > 0 ); + // ...or no lamports for fees + assert!(client.poll_get_balance(&self.keypair.pubkey()).unwrap() > 0); - let ix = storage_instruction::mining_proof( + let instruction = storage_instruction::mining_proof( &self.storage_keypair.pubkey(), self.hash, self.slot, Signature::new(&self.signature.to_bytes()), ); - let mut tx = Transaction::new_unsigned_instructions(vec![ix]); + let message = Message::new_with_payer(vec![instruction], Some(&self.keypair.pubkey())); + let mut transaction = Transaction::new_unsigned(message); client - .retry_transfer(&self.storage_keypair, &mut tx, 10) + .send_and_confirm_transaction( + &[&self.keypair, &self.storage_keypair], + &mut transaction, + 10, + 0, + ) .expect("transfer didn't work!"); } diff --git a/core/src/storage_stage.rs b/core/src/storage_stage.rs index feb64d355..ab0f055e2 100644 --- a/core/src/storage_stage.rs +++ b/core/src/storage_stage.rs @@ -14,6 +14,7 @@ use rand::{Rng, SeedableRng}; use rand_chacha::ChaChaRng; use solana_sdk::hash::Hash; use solana_sdk::instruction::Instruction; +use solana_sdk::message::Message; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil, Signature}; use solana_sdk::system_instruction; @@ -238,7 +239,7 @@ impl StorageStage { let working_bank = bank_forks.read().unwrap().working_bank(); let blockhash = working_bank.confirmed_last_blockhash(); let mut instructions = vec![]; - let mut signing_keys = vec![]; + let signer_keys = vec![keypair.as_ref(), storage_keypair.as_ref()]; if working_bank .get_account(&storage_keypair.pubkey()) .is_none() @@ -252,13 +253,12 @@ impl StorageStage { &solana_storage_api::id(), ); instructions.push(create_instruction); - signing_keys.push(keypair.as_ref()); info!("storage account requested"); } instructions.push(instruction); - signing_keys.push(storage_keypair.as_ref()); - let mut transaction = Transaction::new_unsigned_instructions(instructions); - transaction.sign(&signing_keys, blockhash); + let message = Message::new_with_payer(instructions, Some(&signer_keys[0].pubkey())); + let transaction = Transaction::new(&signer_keys, message, blockhash); + transactions_socket.send_to( &bincode::serialize(&transaction).unwrap(), cluster_info.read().unwrap().my_data().tpu, diff --git a/core/tests/replicator.rs b/core/tests/replicator.rs index 12bb565ef..3bf71fd52 100644 --- a/core/tests/replicator.rs +++ b/core/tests/replicator.rs @@ -147,7 +147,6 @@ fn test_replicator_startup_2_nodes() { #[test] fn test_replicator_startup_leader_hang() { use std::net::{IpAddr, Ipv4Addr, SocketAddr}; - use std::time::Duration; solana_logger::setup(); info!("starting replicator test"); @@ -172,7 +171,6 @@ fn test_replicator_startup_leader_hang() { leader_info, replicator_keypair, storage_keypair, - Some(Duration::from_secs(3)), ); assert!(replicator_res.is_err()); @@ -207,7 +205,6 @@ fn test_replicator_startup_ledger_hang() { cluster.entry_point_info.clone(), bad_keys, storage_keypair, - Some(Duration::from_secs(3)), ); assert!(replicator_res.is_err()); diff --git a/replicator/src/main.rs b/replicator/src/main.rs index 644024ae8..1b7cef8f6 100644 --- a/replicator/src/main.rs +++ b/replicator/src/main.rs @@ -81,7 +81,6 @@ fn main() { entrypoint_info, Arc::new(keypair), storage_keypair, - None, ) .unwrap();