Skip to content

Conversation

@gzalz
Copy link
Contributor

@gzalz gzalz commented Jul 23, 2025

Problem
Our rent reclamation is currently an ad-hoc script. The tip router operator should handle operations like these without a need for manual action.

Solution

  • Add tx_utils for common utils for sending bulk transactions
  • Add reclaim mod with the expired claim status account related functions
  • Add expired distribution account related functions
  • Use num_monitored_epochs as bounds for epochs to check for expired accounts
  • Call reclaim expired accounts from main.rs Run
  • Emit metrics related to expired transactions
Screenshot 2025-07-23 at 1 53 03 PM Screenshot 2025-07-24 at 12 05 02 PM

@gzalz gzalz marked this pull request as ready for review July 23, 2025 21:18
Ok((tda_accounts, pfda_accounts))
}

async fn fetch_expired_claim_statuses(
Copy link
Contributor Author

@gzalz gzalz Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has an average of 30-60 seconds latency vs 700s+ for the existing approach for fetching claims by epoch (within the claims process) using get batched accounts, not counting sourcing the pubkeys from the very large merkle tree collection.

#[allow(clippy::integer_division)]
#[allow(clippy::arithmetic_side_effects)]
#[allow(clippy::manual_div_ceil)]
pub fn pack_transactions(
Copy link
Contributor Author

@gzalz gzalz Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helps us achieve 200+ closed accounts per second on a single instance. We should re-use this where applicable. The claims process would be a great candidate.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claims can't be packed well just because the merkle proof is very long but might be able to get some improvements!

@gzalz gzalz changed the title feat: optionally reclaim claim status accounts from operator feat: optionally reclaim expired account rent from operator Jul 24, 2025
// Use default timeout and commitment config for fetching the current epoch
let rpc_client = rpc_utils::new_rpc_client(rpc_url);
let current_epoch = rpc_client.get_epoch_info().await?.epoch;
(current_epoch - num_monitored_epochs)..current_epoch
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be offset by the number of epochs the claim status are active for? what are you using for num_monitored_epochs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're filtering by the expires_at epoch in our getProgramAccounts calls so this should be correct. num_monitored_epochs will be the same as the CLI param.

The operator will claim and reclaim rent for claims that should be claimed in a monitored epoch or expire in a monitored epoch respectively.

// Use default timeout and commitment config for fetching the current epoch
let rpc_client = rpc_utils::new_rpc_client(rpc_url);
let current_epoch = rpc_client.get_epoch_info().await?.epoch;
(current_epoch - num_monitored_epochs)..current_epoch
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@gzalz
Copy link
Contributor Author

gzalz commented Aug 5, 2025

Noticed the tip claim status filter was off by one byte. Addressed in latest commit.

@gzalz gzalz merged commit 37d6339 into master Aug 5, 2025
6 checks passed
@gzalz gzalz deleted the feat/reclaim-claims branch August 5, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants