Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Stored ClaimStatus address #96

Merged
merged 8 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions meta_merkle_tree/src/generated_merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,33 +277,21 @@ impl TreeNode {
let (claim_status_pubkey, claim_status_bump) = Pubkey::find_program_address(
&[
CLAIM_STATUS_SEED,
&delegation.staker_pubkey.to_bytes(),
&delegation.stake_account_pubkey.to_bytes(),
&tip_distribution_meta.tip_distribution_pubkey.to_bytes(),
],
&TIP_DISTRIBUTION_ID,
);
// Time-gated fix so slow rollout won't affect consensus
if tip_router_target_epoch > 737 {
Ok(Self {
claimant: delegation.stake_account_pubkey,
claim_status_pubkey,
claim_status_bump,
staker_pubkey: delegation.staker_pubkey,
withdrawer_pubkey: delegation.withdrawer_pubkey,
amount: reward_amount,
proof: None,
})
} else {
Ok(Self {
claimant: delegation.staker_pubkey,
claim_status_pubkey,
claim_status_bump,
staker_pubkey: delegation.staker_pubkey,
withdrawer_pubkey: delegation.withdrawer_pubkey,
amount: reward_amount,
proof: None,
})
}

Ok(Self {
claimant: delegation.stake_account_pubkey,
claim_status_pubkey,
claim_status_bump,
staker_pubkey: delegation.staker_pubkey,
withdrawer_pubkey: delegation.withdrawer_pubkey,
amount: reward_amount,
proof: None,
})
})
.collect::<Result<Vec<Self>, MerkleRootGeneratorError>>()?,
);
Expand Down
46 changes: 31 additions & 15 deletions tip-router-operator-cli/src/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use anchor_lang::AccountDeserialize;
use itertools::Itertools;
use jito_tip_distribution_sdk::{
jito_tip_distribution::accounts::ClaimStatus, TipDistributionAccount, CLAIM_STATUS_SEED,
CLAIM_STATUS_SIZE, CONFIG_SEED,
derive_claim_status_account_address, jito_tip_distribution::accounts::ClaimStatus,
TipDistributionAccount, CLAIM_STATUS_SEED, CLAIM_STATUS_SIZE, CONFIG_SEED,

Check failure on line 11 in tip-router-operator-cli/src/claim.rs

View workflow job for this annotation

GitHub Actions / lint

unused import: `CLAIM_STATUS_SEED`

Check failure on line 11 in tip-router-operator-cli/src/claim.rs

View workflow job for this annotation

GitHub Actions / cargo test

unused import: `CLAIM_STATUS_SEED`
};
use jito_tip_router_client::instructions::ClaimWithPayerBuilder;
use jito_tip_router_core::{account_payer::AccountPayer, config::Config};
Expand Down Expand Up @@ -81,8 +81,28 @@
let rpc_url = cli.rpc_url.clone();
let merkle_tree_coll_path =
meta_merkle_tree_dir.join(format!("generated_merkle_tree_{}.json", epoch));
let merkle_tree_coll = GeneratedMerkleTreeCollection::new_from_file(&merkle_tree_coll_path)
let mut merkle_tree_coll = GeneratedMerkleTreeCollection::new_from_file(&merkle_tree_coll_path)
.map_err(|e| anyhow::anyhow!(e))?;

let tip_router_config_address =
Config::find_program_address(&tip_router_program_id, &ncn_address).0;

// Fix wrong claim status pubkeys for 1 epoch -- noop if already correct
for tree in merkle_tree_coll.generated_merkle_trees.iter_mut() {
if tree.merkle_root_upload_authority != tip_router_config_address {
continue;
}
for node in tree.tree_nodes.iter_mut() {
let (claim_status_pubkey, claim_status_bump) = derive_claim_status_account_address(
&tip_distribution_program_id,
&node.claimant,
&tree.tip_distribution_account,
);
node.claim_status_pubkey = claim_status_pubkey;
node.claim_status_bump = claim_status_bump;
}
}

let start = Instant::now();

match claim_mev_tips(
Expand Down Expand Up @@ -153,7 +173,7 @@
while start.elapsed() <= max_loop_duration {
let mut all_claim_transactions = get_claim_transactions_for_valid_unclaimed(
&rpc_client,
merkle_trees,
&merkle_trees,

Check failure on line 176 in tip-router-operator-cli/src/claim.rs

View workflow job for this annotation

GitHub Actions / lint

this expression creates a reference which is immediately dereferenced by the compiler
tip_distribution_program_id,
tip_router_program_id,
ncn_address,
Expand Down Expand Up @@ -199,7 +219,7 @@

let transactions = get_claim_transactions_for_valid_unclaimed(
&rpc_client,
merkle_trees,
&merkle_trees,

Check failure on line 222 in tip-router-operator-cli/src/claim.rs

View workflow job for this annotation

GitHub Actions / lint

this expression creates a reference which is immediately dereferenced by the compiler
tip_distribution_program_id,
tip_router_program_id,
ncn_address,
Expand Down Expand Up @@ -265,13 +285,15 @@
) -> Result<Vec<Transaction>, ClaimMevError> {
let tip_router_config_address =
Config::find_program_address(&tip_router_program_id, &ncn_address).0;

let tree_nodes = merkle_trees
.generated_merkle_trees
.iter()
.filter_map(|tree| {
if tree.merkle_root_upload_authority != tip_router_config_address {
return None;
}

Some(&tree.tree_nodes)
})
.flatten()
Expand All @@ -290,6 +312,7 @@
.iter()
.map(|tree| tree.tip_distribution_account)
.collect_vec();

let tdas: HashMap<Pubkey, Account> = get_batched_accounts(rpc_client, &tda_pubkeys)
.await?
.into_iter()
Expand All @@ -310,6 +333,7 @@
.iter()
.map(|tree_node| tree_node.claim_status_pubkey)
.collect_vec();

let claim_statuses: HashMap<Pubkey, Account> =
get_batched_accounts(rpc_client, &claim_status_pubkeys)
.await?
Expand Down Expand Up @@ -434,14 +458,6 @@
{
continue;
}
let (claim_status_pubkey, claim_status_bump) = Pubkey::find_program_address(
&[
CLAIM_STATUS_SEED,
&node.claimant.to_bytes(),
&tree.tip_distribution_account.to_bytes(),
],
&tip_distribution_program_id,
);

let claim_with_payer_ix = ClaimWithPayerBuilder::new()
.account_payer(tip_router_account_payer)
Expand All @@ -450,12 +466,12 @@
.tip_distribution_program(tip_distribution_program_id)
.tip_distribution_config(tip_distribution_config)
.tip_distribution_account(tree.tip_distribution_account)
.claim_status(claim_status_pubkey)
.claim_status(node.claim_status_pubkey)
.claimant(node.claimant)
.system_program(system_program::id())
.proof(node.proof.clone().unwrap())
.amount(node.amount)
.bump(claim_status_bump)
.bump(node.claim_status_bump)
.instruction();

instructions.push(claim_with_payer_ix);
Expand Down
Loading