Storage transactions are now paid for by a system account (#4193)
* Pay program loading fees from a system account * Pay transaction fees from a system account
This commit is contained in:
parent
d9e18a71ec
commit
55e3b7d380
|
@ -300,7 +300,6 @@ impl LocalCluster {
|
|||
self.entry_point_info.clone(),
|
||||
replicator_keypair,
|
||||
storage_keypair,
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -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<AtomicBool>,
|
||||
slot: u64,
|
||||
ledger_path: String,
|
||||
keypair: Arc<Keypair>,
|
||||
storage_keypair: Arc<Keypair>,
|
||||
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<Keypair>,
|
||||
storage_keypair: Arc<Keypair>,
|
||||
_timeout: Option<Duration>,
|
||||
) -> Result<Self> {
|
||||
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!");
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -81,7 +81,6 @@ fn main() {
|
|||
entrypoint_info,
|
||||
Arc::new(keypair),
|
||||
storage_keypair,
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
Loading…
Reference in New Issue