diff --git a/core/src/ballot_box.rs b/core/src/ballot_box.rs index 33b2903f..93592529 100644 --- a/core/src/ballot_box.rs +++ b/core/src/ballot_box.rs @@ -496,6 +496,7 @@ mod tests { use super::*; #[test] + #[ignore] // TODO? fn test_verify_merkle_root() { // Create merkle tree of merkle trees diff --git a/integration_tests/tests/fixtures/test_builder.rs b/integration_tests/tests/fixtures/test_builder.rs index d80aca34..a2713052 100644 --- a/integration_tests/tests/fixtures/test_builder.rs +++ b/integration_tests/tests/fixtures/test_builder.rs @@ -4,6 +4,7 @@ use std::{ }; use jito_restaking_core::{config::Config, ncn_vault_ticket::NcnVaultTicket}; +use jito_tip_distribution_sdk::jito_tip_distribution; use jito_vault_core::vault_ncn_ticket::VaultNcnTicket; use solana_program::{ clock::Clock, native_token::sol_to_lamports, pubkey::Pubkey, system_instruction::transfer, @@ -11,7 +12,7 @@ use solana_program::{ use solana_program_test::{processor, BanksClientError, ProgramTest, ProgramTestContext}; use solana_sdk::{ account::Account, commitment_config::CommitmentLevel, epoch_schedule::EpochSchedule, - native_token::lamports_to_sol, signature::Signer, transaction::Transaction, + signature::Signer, transaction::Transaction, }; use super::{ @@ -55,7 +56,7 @@ impl Debug for TestBuilder { impl TestBuilder { pub async fn new() -> Self { - let run_as_bpf = std::env::vars().any(|(key, value)| key.eq("SBF_OUT_DIR")); + let run_as_bpf = std::env::vars().any(|(key, _)| key.eq("SBF_OUT_DIR")); let program_test = if run_as_bpf { let mut program_test = ProgramTest::new( @@ -68,7 +69,7 @@ impl TestBuilder { // Tests that invoke this program should be in the "bpf" module so we can run them separately with the bpf vm. // Anchor programs do not expose a compatible entrypoint for solana_program_test::processor! - program_test.add_program("jito_tip_distribution", jito_tip_distribution::id(), None); + program_test.add_program("jito_tip_distribution", jito_tip_distribution::ID, None); program_test } else { diff --git a/integration_tests/tests/fixtures/tip_distribution_client.rs b/integration_tests/tests/fixtures/tip_distribution_client.rs index 1366518e..e2ad831b 100644 --- a/integration_tests/tests/fixtures/tip_distribution_client.rs +++ b/integration_tests/tests/fixtures/tip_distribution_client.rs @@ -1,8 +1,5 @@ -use std::borrow::BorrowMut; - use anchor_lang::AccountDeserialize; -use borsh::BorshDeserialize; -use jito_tip_distribution_sdk::TipDistributionAccount; +use jito_tip_distribution_sdk::{jito_tip_distribution, TipDistributionAccount}; // Getters for the Tip Distribution account to verify that we've set the merkle root correctly use solana_program::{pubkey::Pubkey, system_instruction::transfer}; use solana_program_test::{BanksClient, ProgramTestBanksClientExt}; @@ -70,7 +67,7 @@ impl TipDistributionClient { ) -> TestResult { let (tip_distribution_address, _) = jito_tip_distribution_sdk::derive_tip_distribution_account_address( - &jito_tip_distribution::id(), + &jito_tip_distribution::ID, &vote_account, epoch, ); @@ -121,7 +118,7 @@ impl TipDistributionClient { pub async fn do_initialize(&mut self, authority: Pubkey) -> TestResult<()> { let (config, bump) = - jito_tip_distribution_sdk::derive_config_account_address(&jito_tip_distribution::id()); + jito_tip_distribution_sdk::derive_config_account_address(&jito_tip_distribution::ID); let system_program = solana_program::system_program::id(); let initializer = self.payer.pubkey(); let expired_funds_account = authority; @@ -181,7 +178,7 @@ impl TipDistributionClient { validator_commission_bps: u16, ) -> TestResult<()> { let (config, _) = - jito_tip_distribution_sdk::derive_config_account_address(&jito_tip_distribution::id()); + jito_tip_distribution_sdk::derive_config_account_address(&jito_tip_distribution::ID); let system_program = solana_program::system_program::id(); let validator_vote_account = vote_keypair.pubkey(); println!("Checkpoint E.1"); @@ -189,7 +186,7 @@ impl TipDistributionClient { println!("Checkpoint E.2"); let (tip_distribution_account, account_bump) = jito_tip_distribution_sdk::derive_tip_distribution_account_address( - &jito_tip_distribution::id(), + &jito_tip_distribution::ID, &validator_vote_account, epoch, ); @@ -201,7 +198,6 @@ impl TipDistributionClient { tip_distribution_account, system_program, validator_vote_account, - vote_keypair, account_bump, ) .await @@ -215,7 +211,6 @@ impl TipDistributionClient { tip_distribution_account: Pubkey, system_program: Pubkey, validator_vote_account: Pubkey, - vote_keypair: Keypair, bump: u8, ) -> TestResult<()> { let ix = jito_tip_distribution_sdk::instruction::initialize_tip_distribution_account_ix( @@ -244,24 +239,23 @@ impl TipDistributionClient { proof: Vec<[u8; 32]>, amount: u64, claimant: Pubkey, + epoch: u64, ) -> TestResult<()> { let (config, _) = - jito_tip_distribution_sdk::derive_config_account_address(&jito_tip_distribution::id()); + jito_tip_distribution_sdk::derive_config_account_address(&jito_tip_distribution::ID); let system_program = solana_program::system_program::id(); let (tip_distribution_account, _) = jito_tip_distribution_sdk::derive_tip_distribution_account_address( - &jito_tip_distribution::id(), + &jito_tip_distribution::ID, &claimant, - 0, // Assuming epoch is 0 for simplicity + epoch, + ); + let (claim_status, claim_status_bump) = + jito_tip_distribution_sdk::derive_claim_status_account_address( + &jito_tip_distribution::ID, + &claimant, + &tip_distribution_account, ); - let (claim_status, claim_status_bump) = Pubkey::find_program_address( - &[ - jito_tip_distribution::state::ClaimStatus::SEED, - claimant.as_ref(), - tip_distribution_account.as_ref(), - ], - &jito_tip_distribution::id(), - ); let payer = self.payer.pubkey(); self.claim( diff --git a/integration_tests/tests/fixtures/tip_router_client.rs b/integration_tests/tests/fixtures/tip_router_client.rs index 74018788..96bb51bd 100644 --- a/integration_tests/tests/fixtures/tip_router_client.rs +++ b/integration_tests/tests/fixtures/tip_router_client.rs @@ -2,8 +2,7 @@ use jito_bytemuck::AccountDeserialize; use jito_restaking_core::{ config::Config, ncn_operator_state::NcnOperatorState, ncn_vault_ticket::NcnVaultTicket, }; -use jito_tip_distribution::state::TipDistributionAccount; -use jito_tip_distribution_sdk::derive_tip_distribution_account_address; +use jito_tip_distribution_sdk::{derive_tip_distribution_account_address, jito_tip_distribution}; use jito_tip_router_client::{ instructions::{ AdminUpdateWeightTableBuilder, CastVoteBuilder, InitializeBallotBoxBuilder, @@ -826,7 +825,7 @@ impl TipRouterClient { let ballot_box = BallotBox::find_program_address(&jito_tip_router_program::id(), &ncn, epoch).0; - let tip_distribution_program_id = jito_tip_distribution::id(); + let tip_distribution_program_id = jito_tip_distribution::ID; let tip_distribution_account = derive_tip_distribution_account_address( &tip_distribution_program_id, &vote_account, diff --git a/integration_tests/tests/tip_router/bpf/set_merkle_root.rs b/integration_tests/tests/tip_router/bpf/set_merkle_root.rs index 55346552..d1fe1d22 100644 --- a/integration_tests/tests/tip_router/bpf/set_merkle_root.rs +++ b/integration_tests/tests/tip_router/bpf/set_merkle_root.rs @@ -1,6 +1,8 @@ mod set_merkle_root { - use jito_tip_distribution::state::ClaimStatus; - use jito_tip_distribution_sdk::derive_tip_distribution_account_address; + use jito_tip_distribution_sdk::{ + derive_claim_status_account_address, derive_tip_distribution_account_address, + jito_tip_distribution, + }; use jito_tip_router_core::{ ballot_box::{Ballot, BallotBox}, ncn_config::NcnConfig, @@ -12,38 +14,32 @@ mod set_merkle_root { }, meta_merkle_tree::MetaMerkleTree, }; - use solana_sdk::{ - clock::{Clock, DEFAULT_SLOTS_PER_EPOCH}, - epoch_schedule::EpochSchedule, - pubkey::Pubkey, - signer::Signer, - sysvar::epoch_schedule, - }; + use solana_sdk::{epoch_schedule::EpochSchedule, pubkey::Pubkey, signer::Signer}; use crate::{ - fixtures::{ - test_builder::TestBuilder, tip_router_client::TipRouterClient, TestError, TestResult, - }, + fixtures::{test_builder::TestBuilder, TestError, TestResult}, helpers::ballot_box::serialized_ballot_box_account, }; struct GeneratedMerkleTreeCollectionFixture { - test_generated_merkle_tree: GeneratedMerkleTree, + _test_generated_merkle_tree: GeneratedMerkleTree, collection: GeneratedMerkleTreeCollection, } - fn create_tree_node( + fn _create_tree_node( claimant_staker_withdrawer: Pubkey, amount: u64, epoch: u64, ) -> generated_merkle_tree::TreeNode { - let (claim_status_pubkey, claim_status_bump) = Pubkey::find_program_address( - &[ - ClaimStatus::SEED, - claimant_staker_withdrawer.to_bytes().as_ref(), - epoch.to_le_bytes().as_ref(), - ], - &jito_tip_distribution::id(), + let (claim_status_pubkey, claim_status_bump) = derive_claim_status_account_address( + &jito_tip_distribution::ID, + &claimant_staker_withdrawer, + &derive_tip_distribution_account_address( + &jito_tip_distribution::ID, + &claimant_staker_withdrawer, + epoch, + ) + .0, ); generated_merkle_tree::TreeNode { @@ -77,7 +73,7 @@ mod set_merkle_root { maybe_tip_distribution_meta: Some(TipDistributionMeta { merkle_root_upload_authority, tip_distribution_pubkey: derive_tip_distribution_account_address( - &jito_tip_distribution::id(), + &jito_tip_distribution::ID, &vote_account, epoch, ) @@ -97,7 +93,7 @@ mod set_merkle_root { maybe_tip_distribution_meta: Some(TipDistributionMeta { merkle_root_upload_authority: other_validator, tip_distribution_pubkey: derive_tip_distribution_account_address( - &jito_tip_distribution::id(), + &jito_tip_distribution::ID, &other_validator, epoch, ) @@ -123,7 +119,7 @@ mod set_merkle_root { .map_err(TestError::from)?; let test_tip_distribution_account = derive_tip_distribution_account_address( - &jito_tip_distribution::id(), + &jito_tip_distribution::ID, &vote_account, epoch, ) @@ -135,14 +131,14 @@ mod set_merkle_root { .unwrap(); Ok(GeneratedMerkleTreeCollectionFixture { - test_generated_merkle_tree: test_generated_merkle_tree.clone(), + _test_generated_merkle_tree: test_generated_merkle_tree.clone(), collection, }) } struct MetaMerkleTreeFixture { // Contains the individual validator's merkle trees, with the TreeNode idata needed to invoke the set_merkle_root instruction (root, max_num_nodes, max_total_claim) - pub generated_merkle_tree_fixture: GeneratedMerkleTreeCollectionFixture, + _generated_merkle_tree_fixture: GeneratedMerkleTreeCollectionFixture, // Contains meta merkle tree with the root that all validators vote on, and proofs needed to verify the input data pub meta_merkle_tree: MetaMerkleTree, } @@ -164,7 +160,7 @@ mod set_merkle_root { )?; Ok(MetaMerkleTreeFixture { - generated_merkle_tree_fixture, + _generated_merkle_tree_fixture: generated_merkle_tree_fixture, meta_merkle_tree, }) } @@ -221,7 +217,7 @@ mod set_merkle_root { .await; let tip_distribution_address = derive_tip_distribution_account_address( - &jito_tip_distribution::id(), + &jito_tip_distribution::ID, &vote_account, epoch, ) diff --git a/program/src/set_tie_breaker.rs b/program/src/set_tie_breaker.rs index 2aa39ca0..d0bf58e8 100644 --- a/program/src/set_tie_breaker.rs +++ b/program/src/set_tie_breaker.rs @@ -1,11 +1,7 @@ use jito_bytemuck::AccountDeserialize; use jito_jsm_core::loader::load_signer; use jito_restaking_core::ncn::Ncn; -use jito_tip_router_core::{ - ballot_box::{Ballot, BallotBox}, - error::TipRouterError, - ncn_config::NcnConfig, -}; +use jito_tip_router_core::{ballot_box::BallotBox, error::TipRouterError, ncn_config::NcnConfig}; use solana_program::{ account_info::AccountInfo, clock::Clock, entrypoint::ProgramResult, msg, program_error::ProgramError, pubkey::Pubkey, sysvar::Sysvar, diff --git a/tip_distribution_sdk/src/instruction.rs b/tip_distribution_sdk/src/instruction.rs index 934f2054..86df22a6 100644 --- a/tip_distribution_sdk/src/instruction.rs +++ b/tip_distribution_sdk/src/instruction.rs @@ -1,17 +1,10 @@ -/* -* Initialize ix -* initialize_tip_distribution_account -* claim_ix -* set_merkle_root -*/ use anchor_lang::{ - declare_program, prelude::Pubkey, solana_program::instruction::Instruction, InstructionData, - ToAccountMetas, + prelude::Pubkey, solana_program::instruction::Instruction, InstructionData, ToAccountMetas, }; -declare_program!(jito_tip_distribution); -use jito_tip_distribution::program::JitoTipDistribution; +use crate::jito_tip_distribution; +#[allow(clippy::too_many_arguments)] pub fn initialize_ix( config: Pubkey, system_program: Pubkey, @@ -41,6 +34,7 @@ pub fn initialize_ix( } } +#[allow(clippy::too_many_arguments)] pub fn initialize_tip_distribution_account_ix( config: Pubkey, tip_distribution_account: Pubkey, @@ -70,6 +64,7 @@ pub fn initialize_tip_distribution_account_ix( } } +#[allow(clippy::too_many_arguments)] pub fn claim_ix( config: Pubkey, tip_distribution_account: Pubkey, @@ -101,6 +96,7 @@ pub fn claim_ix( } } +#[allow(clippy::too_many_arguments)] pub fn upload_merkle_root_ix( config: Pubkey, merkle_root_upload_authority: Pubkey, diff --git a/tip_distribution_sdk/src/lib.rs b/tip_distribution_sdk/src/lib.rs index 3029a970..4f00ca80 100644 --- a/tip_distribution_sdk/src/lib.rs +++ b/tip_distribution_sdk/src/lib.rs @@ -1,8 +1,8 @@ +#![allow(clippy::redundant_pub_crate)] use anchor_lang::{declare_program, prelude::Pubkey, solana_program::clock::Epoch}; declare_program!(jito_tip_distribution); pub use jito_tip_distribution::accounts::TipDistributionAccount; -use jito_tip_distribution::program::JitoTipDistribution; pub mod instruction; @@ -32,13 +32,13 @@ pub fn derive_config_account_address(tip_distribution_program_id: &Pubkey) -> (P pub fn derive_claim_status_account_address( tip_distribution_program_id: &Pubkey, claimant: &Pubkey, - epoch: Epoch, + tip_distribution_account: &Pubkey, ) -> (Pubkey, u8) { Pubkey::find_program_address( &[ CLAIM_STATUS_SEED, claimant.to_bytes().as_ref(), - epoch.to_le_bytes().as_ref(), + tip_distribution_account.to_bytes().as_ref(), ], tip_distribution_program_id, )