Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
0xprames committed Jan 20, 2024
1 parent 4a7e60a commit 63faa09
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
12 changes: 6 additions & 6 deletions keepers/validator-keeper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ async fn mev_earned_loop(
// Continuously runs throughout an epoch, polling for tip distribution accounts from the prev epoch with uploaded merkle roots
// and submitting update_mev_earned (technically update_mev_comission) txs when the uploaded merkle roots are detected
match update_mev_earned(
client.clone(),
keypair.clone(),
&client,
&keypair,
&commission_history_program_id,
&tip_distribution_program_id,
&mut validators_updated,
Expand Down Expand Up @@ -399,16 +399,16 @@ async fn main() {
}

tokio::spawn(mev_commission_loop(
Arc::clone(&client),
Arc::clone(&keypair),
client.clone(),
keypair.clone(),
args.program_id,
args.tip_distribution_program_id,
args.interval,
));

tokio::spawn(mev_earned_loop(
Arc::clone(&client),
Arc::clone(&keypair),
client.clone(),
keypair.clone(),
args.program_id,
args.tip_distribution_program_id,
args.interval,
Expand Down
15 changes: 7 additions & 8 deletions keepers/validator-keeper/src/mev_commission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ pub async fn update_mev_commission(
}

pub async fn update_mev_earned(
client: Arc<RpcClient>,
keypair: Arc<Keypair>,
client: &Arc<RpcClient>,
keypair: &Arc<Keypair>,
validator_history_program_id: &Pubkey,
tip_distribution_program_id: &Pubkey,
validators_updated: &mut HashMap<Pubkey, Pubkey>,
Expand Down Expand Up @@ -224,18 +224,17 @@ pub async fn update_mev_earned(
.map(|vote_account| {
ValidatorMevCommissionEntry::new(
vote_account,
epoch - 1, // TDA derived from the prev epoch since the merkle roots are uploaded shortly after rollover
epoch.saturating_sub(1), // TDA derived from the prev epoch since the merkle roots are uploaded shortly after rollover
validator_history_program_id,
tip_distribution_program_id,
&keypair.pubkey(),
)
})
.collect::<Vec<ValidatorMevCommissionEntry>>();

let uploaded_merkleroot_entries =
get_entries_with_uploaded_merkleroot(client.clone(), &entries)
.await
.map_err(|e| (e.into(), CreateUpdateStats::default()))?;
let uploaded_merkleroot_entries = get_entries_with_uploaded_merkleroot(&client, &entries)
.await
.map_err(|e| (e.into(), CreateUpdateStats::default()))?;

let entries_to_update = uploaded_merkleroot_entries
.into_iter()
Expand Down Expand Up @@ -288,7 +287,7 @@ async fn get_existing_entries(
}

async fn get_entries_with_uploaded_merkleroot(
client: Arc<RpcClient>,
client: &Arc<RpcClient>,
entries: &[ValidatorMevCommissionEntry],
) -> Result<Vec<ValidatorMevCommissionEntry>, MultipleAccountsError> {
/* Filters tip distribution tuples to the addresses, then fetches accounts to see which ones have an uploaded merkle root */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct CopyTipDistributionAccount<'info> {
}

pub fn handler(ctx: Context<CopyTipDistributionAccount>, epoch: u64) -> Result<()> {
// Cannot set stake for future epochs
// cant set data in validator history for future epochs
if epoch > Clock::get()?.epoch {
return Err(ValidatorHistoryError::EpochOutOfRange.into());
}
Expand Down

0 comments on commit 63faa09

Please sign in to comment.