Skip to content

Commit

Permalink
update lockfiles, address clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
segfaultdoc authored and buffalu committed Feb 22, 2023
1 parent 5f40816 commit 4955264
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 26 deletions.
6 changes: 5 additions & 1 deletion cli-output/src/cli_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,11 @@ impl fmt::Display for CliBlock {
self.encoded_confirmed_block.previous_blockhash
)?;
if let Some(block_time) = self.encoded_confirmed_block.block_time {
writeln!(f, "Block Time: {:?}", Local.timestamp(block_time, 0))?;
writeln!(
f,
"Block Time: {:?}",
Local.timestamp_opt(block_time, 0).unwrap()
)?;
}
if let Some(block_height) = self.encoded_confirmed_block.block_height {
writeln!(f, "Block Height: {:?}", block_height)?;
Expand Down
4 changes: 2 additions & 2 deletions cli-output/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ fn write_block_time<W: io::Write>(
) -> io::Result<()> {
if let Some(block_time) = block_time {
let block_time_output = match timezone {
CliTimezone::Local => format!("{:?}", Local.timestamp(block_time, 0)),
CliTimezone::Utc => format!("{:?}", Utc.timestamp(block_time, 0)),
CliTimezone::Local => format!("{:?}", Local.timestamp_opt(block_time, 0).unwrap()),
CliTimezone::Utc => format!("{:?}", Utc.timestamp_opt(block_time, 0).unwrap()),
};
writeln!(w, "{}Block Time: {}", prefix, block_time_output,)?;
}
Expand Down
2 changes: 0 additions & 2 deletions multinode-demo/bootstrap-validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ done

# These keypairs are created by ./setup.sh and included in the genesis config
identity=$SOLANA_CONFIG_DIR/bootstrap-validator/identity.json
tip_distribution_account_payer=$SOLANA_CONFIG_DIR/bootstrap-validator/identity.json
vote_account="$SOLANA_CONFIG_DIR"/bootstrap-validator/vote-account.json

ledger_dir="$SOLANA_CONFIG_DIR"/bootstrap-validator
Expand All @@ -181,7 +180,6 @@ args+=(
--no-incremental-snapshots
--identity "$identity"
--vote-account "$vote_account"
--tip-distribution-account-payer "$tip_distribution_account_payer"
--merkle-root-upload-authority "$identity"
--rpc-faucet-address 127.0.0.1:9900
--no-poh-speed-test
Expand Down
4 changes: 0 additions & 4 deletions multinode-demo/validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ while [[ -n $1 ]]; do
elif [[ $1 == --relayer-auth-service-address ]]; then
args+=("$1" "$2")
shift 2
elif [[ $1 = --tip-distribution-account-payer ]]; then
args+=("$1" "$2")
shift 2
elif [[ $1 = --merkle-root-upload-authority ]]; then
args+=("$1" "$2")
shift 2
Expand Down Expand Up @@ -295,7 +292,6 @@ fi
default_arg --identity "$identity"
default_arg --vote-account "$vote_account"
default_arg --merkle-root-upload-authority "$identity"
default_arg --tip-distribution-account-payer "$identity"
default_arg --tip-payment-program-pubkey "DThZmRNNXh7kvTQW9hXeGoWGPKktK8pgVAyoTLjH7UrT"
default_arg --tip-distribution-program-pubkey "FjrdANjvo76aCYQ4kf9FM1R8aESUcEE6F8V7qyoVUQcM"
default_arg --commission-bps 0
Expand Down
13 changes: 8 additions & 5 deletions programs/config/src/date_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bincode::{deserialize, serialized_size};
use {
crate::{config_instruction, ConfigState},
chrono::{
prelude::{Date, DateTime, TimeZone, Utc},
prelude::{DateTime, TimeZone, Utc},
serde::ts_seconds,
},
serde_derive::{Deserialize, Serialize},
Expand All @@ -21,14 +21,17 @@ pub struct DateConfig {
impl Default for DateConfig {
fn default() -> Self {
Self {
date_time: Utc.timestamp(0, 0),
date_time: Utc.timestamp_opt(0, 0).unwrap(),
}
}
}
impl DateConfig {
pub fn new(date: Date<Utc>) -> Self {
pub fn new(date: DateTime<Utc>) -> Self {
Self {
date_time: date.and_hms(0, 0, 0),
date_time: DateTime::from_utc(
date.date_naive().and_hms_opt(0, 0, 0).unwrap(),
*date.offset(),
),
}
}

Expand All @@ -54,7 +57,7 @@ pub fn create_account(

/// Set the date in the date account. The account pubkey must be signed in the
/// transaction containing this instruction.
pub fn store(date_pubkey: &Pubkey, date: Date<Utc>) -> Instruction {
pub fn store(date_pubkey: &Pubkey, date: DateTime<Utc>) -> Instruction {
let date_config = DateConfig::new(date);
config_instruction::store(date_pubkey, true, vec![], &date_config)
}
1 change: 0 additions & 1 deletion scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ args=(
--ledger "$ledgerDir"
--tip-payment-program-pubkey "DThZmRNNXh7kvTQW9hXeGoWGPKktK8pgVAyoTLjH7UrT"
--tip-distribution-program-pubkey "FjrdANjvo76aCYQ4kf9FM1R8aESUcEE6F8V7qyoVUQcM"
--tip-distribution-account-payer "$validator_identity"
--merkle-root-upload-authority "$validator_identity"
--commission-bps 0
--gossip-port 8001
Expand Down
4 changes: 3 additions & 1 deletion sdk/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ impl fmt::Display for GenesisConfig {
Native instruction processors: {:#?}\n\
Rewards pool: {:#?}\n\
",
Utc.timestamp(self.creation_time, 0).to_rfc3339(),
Utc.timestamp_opt(self.creation_time, 0)
.unwrap()
.to_rfc3339(),
self.cluster_type,
self.hash(),
compute_shred_version(&self.hash(), None),
Expand Down
16 changes: 8 additions & 8 deletions tip-distributor/src/claim_mev_workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ pub fn claim_mev_tips(
// most amounts are for 0 lamports. had 1736 non-zero claims out of 164742
let node_count = merkle_trees.generated_merkle_trees.iter().flat_map(|tree| &tree.tree_nodes).filter(|node| node.amount > 0).count();
let min_rent_per_claim = rpc_client.get_minimum_balance_for_rent_exemption(ClaimStatus::SIZE).await.expect("Failed to calculate min rent");
let desired_balance = node_count as u64 * (min_rent_per_claim + DEFAULT_TARGET_LAMPORTS_PER_SIGNATURE);
let desired_balance = (node_count as u64).checked_mul(min_rent_per_claim.checked_add(DEFAULT_TARGET_LAMPORTS_PER_SIGNATURE).unwrap()).unwrap();
if start_balance < desired_balance {
let sol_to_deposit = (desired_balance - start_balance + LAMPORTS_PER_SOL - 1) / LAMPORTS_PER_SOL; // rounds up to nearest sol
let sol_to_deposit = desired_balance.checked_sub(start_balance).unwrap().checked_add(LAMPORTS_PER_SOL).unwrap().checked_sub(1).unwrap().checked_div(LAMPORTS_PER_SOL).unwrap(); // rounds up to nearest sol
panic!("Expected to have at least {} lamports in {}, current balance is {} lamports, deposit {} SOL to continue.",
desired_balance, &keypair.pubkey(), start_balance, sol_to_deposit)
}
}
let stake_acct_min_rent = rpc_client.get_minimum_balance_for_rent_exemption(StakeState::size_of()).await.expect("Failed to calculate min rent");
let mut below_min_rent_count = 0;
let mut zero_lamports_count = 0;
let mut below_min_rent_count: usize = 0;
let mut zero_lamports_count: usize = 0;
for tree in merkle_trees.generated_merkle_trees {
// only claim for ones that have merkle root on-chain
let account = rpc_client.get_account(&tree.tip_distribution_account).await.expect("expected to fetch tip distribution account");
Expand All @@ -88,7 +88,7 @@ pub fn claim_mev_tips(
}
for node in tree.tree_nodes {
if node.amount == 0 {
zero_lamports_count += 1;
zero_lamports_count = zero_lamports_count.checked_add(1).unwrap();
continue;
}

Expand All @@ -106,10 +106,10 @@ pub fn claim_mev_tips(
let current_balance = rpc_client.get_balance(&node.claimant).await.expect("Failed to get balance");
// some older accounts can be rent-paying
// any new transfers will need to make the account rent-exempt (runtime enforced)
if current_balance + node.amount < stake_acct_min_rent {
if current_balance.checked_add(node.amount).unwrap() < stake_acct_min_rent {
warn!("Current balance + tip claim amount of {} is less than required rent-exempt of {} for pubkey: {}. Skipping.",
current_balance + node.amount, stake_acct_min_rent, node.claimant);
below_min_rent_count += 1;
current_balance.checked_add(node.amount).unwrap(), stake_acct_min_rent, node.claimant);
below_min_rent_count = below_min_rent_count.checked_add(1).unwrap();
continue;
}
let ix = Instruction {
Expand Down
4 changes: 2 additions & 2 deletions tip-distributor/src/merkle_root_upload_workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ pub fn upload_merkle_root(
// heuristic to make sure we have enough funds to cover execution, assumes all trees need updating
{
let initial_balance = rpc_client.get_balance(&keypair.pubkey()).await.expect("failed to get balance");
let desired_balance = trees.len() as u64 * DEFAULT_TARGET_LAMPORTS_PER_SIGNATURE;
let desired_balance = (trees.len() as u64).checked_mul(DEFAULT_TARGET_LAMPORTS_PER_SIGNATURE).unwrap();
if initial_balance < desired_balance {
let sol_to_deposit = (desired_balance - initial_balance + LAMPORTS_PER_SOL - 1) / LAMPORTS_PER_SOL; // rounds up to nearest sol
let sol_to_deposit = desired_balance.checked_sub(initial_balance).unwrap().checked_add(LAMPORTS_PER_SOL).unwrap().checked_sub(1).unwrap().checked_div(LAMPORTS_PER_SOL).unwrap(); // rounds up to nearest sol
panic!("Expected to have at least {} lamports in {}, current balance is {} lamports, deposit {} SOL to continue.",
desired_balance, &keypair.pubkey(), initial_balance, sol_to_deposit)
}
Expand Down

0 comments on commit 4955264

Please sign in to comment.