Remove/address some TODOs (#6923)
This commit is contained in:
parent
9246bee12b
commit
fcc2874591
|
@ -1122,7 +1122,6 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
||||||
|
|
||||||
// Quick and dirty Keypair that assumes the client will do retries but not update the
|
// Quick and dirty Keypair that assumes the client will do retries but not update the
|
||||||
// blockhash. If the client updates the blockhash, the signature will be invalid.
|
// blockhash. If the client updates the blockhash, the signature will be invalid.
|
||||||
// TODO: Parse `msg` and use that data to make a new airdrop request.
|
|
||||||
struct DroneKeypair {
|
struct DroneKeypair {
|
||||||
transaction: Transaction,
|
transaction: Transaction,
|
||||||
}
|
}
|
||||||
|
|
|
@ -775,8 +775,13 @@ impl RpcClient {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if now.elapsed().as_secs() > 15 {
|
if now.elapsed().as_secs() > 15 {
|
||||||
// TODO: Return a better error.
|
return Err(io::Error::new(
|
||||||
return Err(io::Error::new(io::ErrorKind::Other, "signature not found"));
|
io::ErrorKind::Other,
|
||||||
|
format!(
|
||||||
|
"signature not found after {} seconds",
|
||||||
|
now.elapsed().as_secs()
|
||||||
|
),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
sleep(Duration::from_millis(250));
|
sleep(Duration::from_millis(250));
|
||||||
}
|
}
|
||||||
|
@ -859,8 +864,13 @@ impl RpcClient {
|
||||||
if confirmed_blocks > 0 {
|
if confirmed_blocks > 0 {
|
||||||
return Ok(confirmed_blocks);
|
return Ok(confirmed_blocks);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Return a better error.
|
return Err(io::Error::new(
|
||||||
return Err(io::Error::new(io::ErrorKind::Other, "signature not found"));
|
io::ErrorKind::Other,
|
||||||
|
format!(
|
||||||
|
"signature not found after {} seconds",
|
||||||
|
now.elapsed().as_secs()
|
||||||
|
),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sleep(Duration::from_millis(250));
|
sleep(Duration::from_millis(250));
|
||||||
|
@ -919,8 +929,7 @@ impl RpcClient {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove
|
pub fn send(
|
||||||
pub fn retry_make_rpc_request(
|
|
||||||
&self,
|
&self,
|
||||||
request: &RpcRequest,
|
request: &RpcRequest,
|
||||||
params: Option<Value>,
|
params: Option<Value>,
|
||||||
|
@ -955,7 +964,7 @@ mod tests {
|
||||||
use std::{sync::mpsc::channel, thread};
|
use std::{sync::mpsc::channel, thread};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_make_rpc_request() {
|
fn test_send() {
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let rpc_addr = "0.0.0.0:0".parse().unwrap();
|
let rpc_addr = "0.0.0.0:0".parse().unwrap();
|
||||||
|
@ -989,7 +998,7 @@ mod tests {
|
||||||
let rpc_addr = receiver.recv().unwrap();
|
let rpc_addr = receiver.recv().unwrap();
|
||||||
let rpc_client = RpcClient::new_socket(rpc_addr);
|
let rpc_client = RpcClient::new_socket(rpc_addr);
|
||||||
|
|
||||||
let balance = rpc_client.retry_make_rpc_request(
|
let balance = rpc_client.send(
|
||||||
&RpcRequest::GetBalance,
|
&RpcRequest::GetBalance,
|
||||||
Some(json!(["deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx"])),
|
Some(json!(["deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx"])),
|
||||||
0,
|
0,
|
||||||
|
@ -997,15 +1006,14 @@ mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!(balance.unwrap().as_u64().unwrap(), 50);
|
assert_eq!(balance.unwrap().as_u64().unwrap(), 50);
|
||||||
|
|
||||||
let blockhash =
|
let blockhash = rpc_client.send(&RpcRequest::GetRecentBlockhash, None, 0, None);
|
||||||
rpc_client.retry_make_rpc_request(&RpcRequest::GetRecentBlockhash, None, 0, None);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
blockhash.unwrap().as_str().unwrap(),
|
blockhash.unwrap().as_str().unwrap(),
|
||||||
"deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx"
|
"deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhx"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send erroneous parameter
|
// Send erroneous parameter
|
||||||
let blockhash = rpc_client.retry_make_rpc_request(
|
let blockhash = rpc_client.send(
|
||||||
&RpcRequest::GetRecentBlockhash,
|
&RpcRequest::GetRecentBlockhash,
|
||||||
Some(json!("parameter")),
|
Some(json!("parameter")),
|
||||||
0,
|
0,
|
||||||
|
@ -1015,7 +1023,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_retry_make_rpc_request() {
|
fn test_retry_send() {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
@ -1044,7 +1052,7 @@ mod tests {
|
||||||
let rpc_addr = receiver.recv().unwrap();
|
let rpc_addr = receiver.recv().unwrap();
|
||||||
let rpc_client = RpcClient::new_socket(rpc_addr);
|
let rpc_client = RpcClient::new_socket(rpc_addr);
|
||||||
|
|
||||||
let balance = rpc_client.retry_make_rpc_request(
|
let balance = rpc_client.send(
|
||||||
&RpcRequest::GetBalance,
|
&RpcRequest::GetBalance,
|
||||||
Some(json!(["deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhw"])),
|
Some(json!(["deadbeefXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNHhw"])),
|
||||||
10,
|
10,
|
||||||
|
|
|
@ -67,10 +67,7 @@ impl GenericRpcClientRequest for RpcClientRequest {
|
||||||
return Ok(json["result"].clone());
|
return Ok(json["result"].clone());
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
info!(
|
info!("{:?} failed, {} retries left: {:?}", request, retries, e);
|
||||||
"make_rpc_request({:?}) failed, {} retries left: {:?}",
|
|
||||||
request, retries, e
|
|
||||||
);
|
|
||||||
if retries == 0 {
|
if retries == 0 {
|
||||||
return Err(e.into());
|
return Err(e.into());
|
||||||
}
|
}
|
||||||
|
|
|
@ -747,7 +747,7 @@ impl Archiver {
|
||||||
RpcClient::new_socket(rpc_peers[node_index].rpc)
|
RpcClient::new_socket(rpc_peers[node_index].rpc)
|
||||||
};
|
};
|
||||||
Ok(rpc_client
|
Ok(rpc_client
|
||||||
.retry_make_rpc_request(
|
.send(
|
||||||
&RpcRequest::GetSlotsPerSegment,
|
&RpcRequest::GetSlotsPerSegment,
|
||||||
None,
|
None,
|
||||||
0,
|
0,
|
||||||
|
@ -804,7 +804,7 @@ impl Archiver {
|
||||||
RpcClient::new_socket(rpc_peers[node_index].rpc)
|
RpcClient::new_socket(rpc_peers[node_index].rpc)
|
||||||
};
|
};
|
||||||
let response = rpc_client
|
let response = rpc_client
|
||||||
.retry_make_rpc_request(&RpcRequest::GetStorageTurn, None, 0, None)
|
.send(&RpcRequest::GetStorageTurn, None, 0, None)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
warn!("Error while making rpc request {:?}", err);
|
warn!("Error while making rpc request {:?}", err);
|
||||||
Error::IO(io::Error::new(ErrorKind::Other, "rpc error"))
|
Error::IO(io::Error::new(ErrorKind::Other, "rpc error"))
|
||||||
|
|
|
@ -188,7 +188,7 @@ pub fn request_airdrop_transaction(
|
||||||
"request_airdrop_transaction: drone_addr={} id={} lamports={} blockhash={}",
|
"request_airdrop_transaction: drone_addr={} id={} lamports={} blockhash={}",
|
||||||
drone_addr, id, lamports, blockhash
|
drone_addr, id, lamports, blockhash
|
||||||
);
|
);
|
||||||
// TODO: make this async tokio client
|
|
||||||
let mut stream = TcpStream::connect_timeout(drone_addr, Duration::new(3, 0))?;
|
let mut stream = TcpStream::connect_timeout(drone_addr, Duration::new(3, 0))?;
|
||||||
stream.set_read_timeout(Some(Duration::new(10, 0)))?;
|
stream.set_read_timeout(Some(Duration::new(10, 0)))?;
|
||||||
let req = DroneRequest::GetAirdrop {
|
let req = DroneRequest::GetAirdrop {
|
||||||
|
|
|
@ -56,8 +56,6 @@ impl SignedUpdateManifest {
|
||||||
|
|
||||||
impl ConfigState for SignedUpdateManifest {
|
impl ConfigState for SignedUpdateManifest {
|
||||||
fn max_space() -> u64 {
|
fn max_space() -> u64 {
|
||||||
// TODO: Use a fully populated manifest to compute a better value
|
256 // Enough space for a fully populated SignedUpdateManifest
|
||||||
// bincode::serialized_size(&Self::default()).unwrap()
|
|
||||||
256
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,6 @@ impl BankForks {
|
||||||
bank
|
bank
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: really want to kill this...
|
|
||||||
pub fn working_bank(&self) -> Arc<Bank> {
|
pub fn working_bank(&self) -> Arc<Bank> {
|
||||||
self.working_bank.clone()
|
self.working_bank.clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -428,7 +428,6 @@ fn process_next_slots(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reverse sort by slot, so the next slot to be processed can be popped
|
// Reverse sort by slot, so the next slot to be processed can be popped
|
||||||
// TODO: remove me once leader_scheduler can hang with out-of-order slots?
|
|
||||||
pending_slots.sort_by(|a, b| b.0.cmp(&a.0));
|
pending_slots.sort_by(|a, b| b.0.cmp(&a.0));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,7 +328,6 @@ pub fn process_instruction(
|
||||||
let keyed_accounts = &mut keyed_accounts.iter_mut();
|
let keyed_accounts = &mut keyed_accounts.iter_mut();
|
||||||
let me = &mut next_keyed_account(keyed_accounts)?;
|
let me = &mut next_keyed_account(keyed_accounts)?;
|
||||||
|
|
||||||
// TODO: data-driven unpack and dispatch of KeyedAccounts
|
|
||||||
match limited_deserialize(data)? {
|
match limited_deserialize(data)? {
|
||||||
StakeInstruction::Initialize(authorized, lockup) => me.initialize(
|
StakeInstruction::Initialize(authorized, lockup) => me.initialize(
|
||||||
&authorized,
|
&authorized,
|
||||||
|
|
|
@ -176,7 +176,6 @@ pub fn process_instruction(
|
||||||
let (me, rest) = &mut keyed_accounts.split_at_mut(1);
|
let (me, rest) = &mut keyed_accounts.split_at_mut(1);
|
||||||
let me = &mut me[0];
|
let me = &mut me[0];
|
||||||
|
|
||||||
// TODO: data-driven unpack and dispatch of KeyedAccounts
|
|
||||||
match limited_deserialize(data)? {
|
match limited_deserialize(data)? {
|
||||||
VoteInstruction::InitializeAccount(vote_init) => {
|
VoteInstruction::InitializeAccount(vote_init) => {
|
||||||
if rest.is_empty() {
|
if rest.is_empty() {
|
||||||
|
|
|
@ -514,7 +514,6 @@ impl Bank {
|
||||||
}
|
}
|
||||||
// if I'm the first Bank in an epoch, count, claim, disburse rewards from Inflation
|
// if I'm the first Bank in an epoch, count, claim, disburse rewards from Inflation
|
||||||
|
|
||||||
// TODO: on-chain wallclock?
|
|
||||||
// years_elapsed = slots_elapsed / slots/year
|
// years_elapsed = slots_elapsed / slots/year
|
||||||
let year = (self.epoch_schedule.get_last_slot_in_epoch(epoch)) as f64 / self.slots_per_year;
|
let year = (self.epoch_schedule.get_last_slot_in_epoch(epoch)) as f64 / self.slots_per_year;
|
||||||
|
|
||||||
|
@ -1584,7 +1583,6 @@ impl Bank {
|
||||||
let dbhq = dbank.blockhash_queue.read().unwrap();
|
let dbhq = dbank.blockhash_queue.read().unwrap();
|
||||||
assert_eq!(*bhq, *dbhq);
|
assert_eq!(*bhq, *dbhq);
|
||||||
|
|
||||||
// TODO: Uncomment once status cache serialization is done
|
|
||||||
let sc = self.src.status_cache.read().unwrap();
|
let sc = self.src.status_cache.read().unwrap();
|
||||||
let dsc = dbank.src.status_cache.read().unwrap();
|
let dsc = dbank.src.status_cache.read().unwrap();
|
||||||
assert_eq!(*sc, *dsc);
|
assert_eq!(*sc, *dsc);
|
||||||
|
|
|
@ -191,10 +191,12 @@ impl SyncClient for BankClient {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if now.elapsed().as_secs() > 15 {
|
if now.elapsed().as_secs() > 15 {
|
||||||
// TODO: Return a better error.
|
|
||||||
return Err(TransportError::IoError(io::Error::new(
|
return Err(TransportError::IoError(io::Error::new(
|
||||||
io::ErrorKind::Other,
|
io::ErrorKind::Other,
|
||||||
"signature not found",
|
format!(
|
||||||
|
"signature not found after {} seconds",
|
||||||
|
now.elapsed().as_secs()
|
||||||
|
),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
sleep(Duration::from_millis(250));
|
sleep(Duration::from_millis(250));
|
||||||
|
@ -212,10 +214,12 @@ impl SyncClient for BankClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if now.elapsed().as_secs() > 15 {
|
if now.elapsed().as_secs() > 15 {
|
||||||
// TODO: Return a better error.
|
|
||||||
return Err(TransportError::IoError(io::Error::new(
|
return Err(TransportError::IoError(io::Error::new(
|
||||||
io::ErrorKind::Other,
|
io::ErrorKind::Other,
|
||||||
"signature not found",
|
format!(
|
||||||
|
"signature not found after {} seconds",
|
||||||
|
now.elapsed().as_secs()
|
||||||
|
),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
sleep(Duration::from_millis(250));
|
sleep(Duration::from_millis(250));
|
||||||
|
|
|
@ -29,12 +29,11 @@ pub fn create_genesis_config_with_leader(
|
||||||
bootstrap_leader_stake_lamports: u64,
|
bootstrap_leader_stake_lamports: u64,
|
||||||
) -> GenesisConfigInfo {
|
) -> GenesisConfigInfo {
|
||||||
let mint_keypair = Keypair::new();
|
let mint_keypair = Keypair::new();
|
||||||
let voting_keypair = Keypair::new();
|
let bootstrap_leader_voting_keypair = Keypair::new();
|
||||||
let staking_keypair = Keypair::new();
|
let bootstrap_leader_staking_keypair = Keypair::new();
|
||||||
|
|
||||||
// TODO: de-duplicate the stake... passive staking is fully implemented
|
let bootstrap_leader_vote_account = vote_state::create_account(
|
||||||
let vote_account = vote_state::create_account(
|
&bootstrap_leader_voting_keypair.pubkey(),
|
||||||
&voting_keypair.pubkey(),
|
|
||||||
&bootstrap_leader_pubkey,
|
&bootstrap_leader_pubkey,
|
||||||
0,
|
0,
|
||||||
bootstrap_leader_stake_lamports,
|
bootstrap_leader_stake_lamports,
|
||||||
|
@ -42,30 +41,31 @@ pub fn create_genesis_config_with_leader(
|
||||||
|
|
||||||
let rent = Rent::free();
|
let rent = Rent::free();
|
||||||
|
|
||||||
let stake_account = stake_state::create_account(
|
let bootstrap_leader_stake_account = stake_state::create_account(
|
||||||
&staking_keypair.pubkey(),
|
&bootstrap_leader_staking_keypair.pubkey(),
|
||||||
&voting_keypair.pubkey(),
|
&bootstrap_leader_voting_keypair.pubkey(),
|
||||||
&vote_account,
|
&bootstrap_leader_vote_account,
|
||||||
&rent,
|
&rent,
|
||||||
bootstrap_leader_stake_lamports,
|
bootstrap_leader_stake_lamports,
|
||||||
);
|
);
|
||||||
|
|
||||||
let accounts = vec![
|
let accounts = vec![
|
||||||
// the mint
|
|
||||||
(
|
(
|
||||||
mint_keypair.pubkey(),
|
mint_keypair.pubkey(),
|
||||||
Account::new(mint_lamports, 0, &system_program::id()),
|
Account::new(mint_lamports, 0, &system_program::id()),
|
||||||
),
|
),
|
||||||
// node needs an account to issue votes and storage proofs from, this will require
|
|
||||||
// airdrops at some point to cover fees...
|
|
||||||
(
|
(
|
||||||
*bootstrap_leader_pubkey,
|
*bootstrap_leader_pubkey,
|
||||||
Account::new(BOOTSTRAP_LEADER_LAMPORTS, 0, &system_program::id()),
|
Account::new(BOOTSTRAP_LEADER_LAMPORTS, 0, &system_program::id()),
|
||||||
),
|
),
|
||||||
// where votes go to
|
(
|
||||||
(voting_keypair.pubkey(), vote_account),
|
bootstrap_leader_voting_keypair.pubkey(),
|
||||||
// passive bootstrap leader stake, duplicates above temporarily
|
bootstrap_leader_vote_account,
|
||||||
(staking_keypair.pubkey(), stake_account),
|
),
|
||||||
|
(
|
||||||
|
bootstrap_leader_staking_keypair.pubkey(),
|
||||||
|
bootstrap_leader_stake_account,
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Bare minimum program set
|
// Bare minimum program set
|
||||||
|
@ -75,8 +75,8 @@ pub fn create_genesis_config_with_leader(
|
||||||
solana_vote_program!(),
|
solana_vote_program!(),
|
||||||
solana_stake_program!(),
|
solana_stake_program!(),
|
||||||
];
|
];
|
||||||
let fee_calculator = FeeCalculator::new(0, 0); // most tests don't want fees
|
|
||||||
|
|
||||||
|
let fee_calculator = FeeCalculator::new(0, 0); // most tests can't handle transaction fees
|
||||||
let mut genesis_config = GenesisConfig {
|
let mut genesis_config = GenesisConfig {
|
||||||
accounts,
|
accounts,
|
||||||
native_instruction_processors,
|
native_instruction_processors,
|
||||||
|
@ -91,6 +91,6 @@ pub fn create_genesis_config_with_leader(
|
||||||
GenesisConfigInfo {
|
GenesisConfigInfo {
|
||||||
genesis_config,
|
genesis_config,
|
||||||
mint_keypair,
|
mint_keypair,
|
||||||
voting_keypair,
|
voting_keypair: bootstrap_leader_voting_keypair,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,6 @@ impl<T: Serialize + Clone> StatusCache<T> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO: wallets should send the Transactions recent blockhash as well
|
|
||||||
pub fn get_signature_status_slow(
|
pub fn get_signature_status_slow(
|
||||||
&self,
|
&self,
|
||||||
sig: &Signature,
|
sig: &Signature,
|
||||||
|
|
|
@ -238,7 +238,6 @@ function launchTestnet() {
|
||||||
|
|
||||||
cd "$(dirname "$0")/../.."
|
cd "$(dirname "$0")/../.."
|
||||||
|
|
||||||
# TODO: Make sure a dB named $TESTNET_TAG exists in the influxDB host, or can be created
|
|
||||||
[[ -n $TESTNET_TAG ]] || TESTNET_TAG=testnet-automation
|
[[ -n $TESTNET_TAG ]] || TESTNET_TAG=testnet-automation
|
||||||
[[ -n $INFLUX_HOST ]] || INFLUX_HOST=https://metrics.solana.com:8086
|
[[ -n $INFLUX_HOST ]] || INFLUX_HOST=https://metrics.solana.com:8086
|
||||||
[[ -n $RAMP_UP_TIME ]] || RAMP_UP_TIME=0
|
[[ -n $RAMP_UP_TIME ]] || RAMP_UP_TIME=0
|
||||||
|
|
Loading…
Reference in New Issue