parent
f2b727b534
commit
1e949caa7f
|
@ -70,35 +70,6 @@ rsync_url() { # adds the 'rsync://` prefix to URLs that need it
|
||||||
echo "rsync://$url"
|
echo "rsync://$url"
|
||||||
}
|
}
|
||||||
|
|
||||||
airdrop() {
|
|
||||||
declare keypair_file=$1
|
|
||||||
declare entrypoint_ip=$2
|
|
||||||
declare amount=$3
|
|
||||||
|
|
||||||
declare address
|
|
||||||
address=$($solana_wallet --keypair "$keypair_file" address)
|
|
||||||
|
|
||||||
# TODO: Until https://github.com/solana-labs/solana/issues/2355 is resolved
|
|
||||||
# a fullnode needs N lamports as its vote account gets re-created on every
|
|
||||||
# node restart, costing it lamports
|
|
||||||
declare retries=5
|
|
||||||
|
|
||||||
while ! $solana_wallet --keypair "$keypair_file" --url "http://$entrypoint_ip:8899" airdrop "$amount"; do
|
|
||||||
|
|
||||||
# TODO: Consider moving this retry logic into `solana-wallet airdrop`
|
|
||||||
# itself, currently it does not retry on "Connection refused" errors.
|
|
||||||
((retries--))
|
|
||||||
if [[ $retries -le 0 ]]; then
|
|
||||||
echo "Airdrop to $address failed."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
echo "Airdrop to $address failed. Remaining retries: $retries"
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_vote_account() {
|
setup_vote_account() {
|
||||||
declare entrypoint_ip=$1
|
declare entrypoint_ip=$1
|
||||||
declare node_keypair_path=$2
|
declare node_keypair_path=$2
|
||||||
|
@ -114,7 +85,7 @@ setup_vote_account() {
|
||||||
if [[ -f "$vote_keypair_path".configured ]]; then
|
if [[ -f "$vote_keypair_path".configured ]]; then
|
||||||
echo "Vote account has already been configured"
|
echo "Vote account has already been configured"
|
||||||
else
|
else
|
||||||
airdrop "$node_keypair_path" "$entrypoint_ip" "$stake" || return $?
|
$solana_wallet --keypair "$node_keypair_path" --url "http://$entrypoint_ip:8899" airdrop "$stake" || return $?
|
||||||
|
|
||||||
# Fund the vote account from the node, with the node as the node_keypair
|
# Fund the vote account from the node, with the node as the node_keypair
|
||||||
$solana_wallet --keypair "$node_keypair_path" --url "http://$entrypoint_ip:8899" \
|
$solana_wallet --keypair "$node_keypair_path" --url "http://$entrypoint_ip:8899" \
|
||||||
|
|
|
@ -30,6 +30,8 @@ use solana_vote_api::vote_instruction;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::net::{IpAddr, SocketAddr};
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
use std::thread::sleep;
|
||||||
|
use std::time::Duration;
|
||||||
use std::{error, fmt, mem};
|
use std::{error, fmt, mem};
|
||||||
|
|
||||||
const USERDATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA_SIZE
|
const USERDATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA_SIZE
|
||||||
|
@ -776,7 +778,17 @@ pub fn request_and_confirm_airdrop(
|
||||||
lamports: u64,
|
lamports: u64,
|
||||||
) -> Result<(), Box<dyn error::Error>> {
|
) -> Result<(), Box<dyn error::Error>> {
|
||||||
let blockhash = rpc_client.get_recent_blockhash()?;
|
let blockhash = rpc_client.get_recent_blockhash()?;
|
||||||
let keypair = DroneKeypair::new_keypair(drone_addr, to_pubkey, lamports, blockhash)?;
|
let keypair = {
|
||||||
|
let mut retries = 5;
|
||||||
|
loop {
|
||||||
|
let result = DroneKeypair::new_keypair(drone_addr, to_pubkey, lamports, blockhash);
|
||||||
|
if result.is_ok() || retries == 0 {
|
||||||
|
break result;
|
||||||
|
}
|
||||||
|
retries -= 1;
|
||||||
|
sleep(Duration::from_secs(1));
|
||||||
|
}
|
||||||
|
}?;
|
||||||
let mut tx = keypair.airdrop_transaction();
|
let mut tx = keypair.airdrop_transaction();
|
||||||
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&keypair]);
|
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&keypair]);
|
||||||
log_instruction_custom_error::<SystemError>(result)?;
|
log_instruction_custom_error::<SystemError>(result)?;
|
||||||
|
|
Loading…
Reference in New Issue