From 1295da1cfd1a77e2c908931889e051a8e8000a1f Mon Sep 17 00:00:00 2001 From: segfaultdoctor <17258903+segfaultdoc@users.noreply.github.com> Date: Wed, 18 Jan 2023 11:54:09 -0500 Subject: [PATCH] point to new jito-programs submod and invoke updated init tda instruction (#228) --- core/src/bundle_sanitizer.rs | 1 - core/src/bundle_stage.rs | 25 ++++++++++--------- core/src/tip_manager.rs | 47 ++++++++++++++++++------------------ validator/src/main.rs | 18 -------------- 4 files changed, 37 insertions(+), 54 deletions(-) diff --git a/core/src/bundle_sanitizer.rs b/core/src/bundle_sanitizer.rs index f27fe9be2a..ceb516def0 100644 --- a/core/src/bundle_sanitizer.rs +++ b/core/src/bundle_sanitizer.rs @@ -396,7 +396,6 @@ mod tests { tip_payment_program_id: Pubkey::new_unique(), tip_distribution_program_id: Pubkey::new_unique(), tip_distribution_account_config: TipDistributionAccountConfig { - payer: Arc::new(Keypair::new()), merkle_root_upload_authority: Pubkey::new_unique(), vote_account: Pubkey::new_unique(), commission_bps: 0, diff --git a/core/src/bundle_stage.rs b/core/src/bundle_stage.rs index f71f2fa2f2..10351bee6d 100644 --- a/core/src/bundle_stage.rs +++ b/core/src/bundle_stage.rs @@ -831,23 +831,26 @@ impl BundleStage { let maybe_init_tip_distro_config_tx = if tip_manager.should_initialize_tip_distribution_config(bank) { info!("building initialize_tip_distribution_config_tx"); - Some(tip_manager.initialize_tip_distribution_config_tx( + Some( + tip_manager + .initialize_tip_distribution_config_tx(bank.last_blockhash(), cluster_info), + ) + } else { + None + }; + + let maybe_init_tip_distro_account_tx = + if tip_manager.should_init_tip_distribution_account(bank) { + info!("building initialize_tip_distribution_account tx"); + Some(tip_manager.initialize_tip_distribution_account_tx( bank.last_blockhash(), - &cluster_info.keypair(), + bank.epoch(), + cluster_info, )) } else { None }; - let maybe_init_tip_distro_account_tx = if tip_manager - .should_init_tip_distribution_account(bank) - { - info!("building init_tip_distribution_account_tx"); - Some(tip_manager.init_tip_distribution_account_tx(bank.last_blockhash(), bank.epoch())) - } else { - None - }; - let transactions = [ maybe_init_tip_payment_config_tx, maybe_init_tip_distro_config_tx, diff --git a/core/src/tip_manager.rs b/core/src/tip_manager.rs index 2674f64239..fe15d1dc05 100644 --- a/core/src/tip_manager.rs +++ b/core/src/tip_manager.rs @@ -3,6 +3,7 @@ use { solana_program::hash::Hash, AccountDeserialize, InstructionData, ToAccountMetas, }, log::warn, + solana_gossip::cluster_info::ClusterInfo, solana_runtime::bank::Bank, solana_sdk::{ account::ReadableAccount, @@ -22,8 +23,9 @@ use { tip_distribution::sdk::{ derive_config_account_address, derive_tip_distribution_account_address, instruction::{ - init_tip_distribution_account_ix, initialize_ix, InitTipDistributionAccountAccounts, - InitTipDistributionAccountArgs, InitializeAccounts, InitializeArgs, + initialize_ix, initialize_tip_distribution_account_ix, InitializeAccounts, + InitializeArgs, InitializeTipDistributionAccountAccounts, + InitializeTipDistributionAccountArgs, }, }, tip_payment::{ @@ -61,12 +63,9 @@ struct TipDistributionProgramInfo { config_pda_and_bump: (Pubkey, u8), } -/// This config is used on each invocation to the `init_tip_distribution_account` instruction. +/// This config is used on each invocation to the `initialize_tip_distribution_account` instruction. #[derive(Debug, Clone)] pub struct TipDistributionAccountConfig { - /// The keypair paying and signing each init tx. - pub payer: Arc, - /// The account with authority to upload merkle-roots to this validator's [TipDistributionAccount]. pub merkle_root_upload_authority: Pubkey, @@ -80,7 +79,6 @@ pub struct TipDistributionAccountConfig { impl Default for TipDistributionAccountConfig { fn default() -> Self { Self { - payer: Arc::new(Keypair::new()), merkle_root_upload_authority: Pubkey::new_unique(), vote_account: Pubkey::new_unique(), commission_bps: 0, @@ -302,38 +300,39 @@ impl TipManager { pub fn initialize_tip_distribution_config_tx( &self, recent_blockhash: Hash, - my_keypair: &Keypair, + cluster_info: &Arc, ) -> SanitizedTransaction { let ix = initialize_ix( self.tip_distribution_program_info.program_id, InitializeArgs { - authority: my_keypair.pubkey(), - expired_funds_account: my_keypair.pubkey(), - num_epochs_valid: 3, - max_validator_commission_bps: 1000, + authority: cluster_info.id(), + expired_funds_account: cluster_info.id(), + num_epochs_valid: 10, + max_validator_commission_bps: 10_000, bump: self.tip_distribution_program_info.config_pda_and_bump.1, }, InitializeAccounts { config: self.tip_distribution_program_info.config_pda_and_bump.0, system_program: system_program::id(), - initializer: my_keypair.pubkey(), + initializer: cluster_info.id(), }, ); SanitizedTransaction::try_from_legacy_transaction(Transaction::new_signed_with_payer( &[ix], - Some(&my_keypair.pubkey()), - &[my_keypair], + Some(&cluster_info.id()), + &[cluster_info.keypair().as_ref()], recent_blockhash, )) .unwrap() } - /// Creates an [InitTipDistributionAccount] transaction object using the provided Epoch. - pub fn init_tip_distribution_account_tx( + /// Creates an [InitializeTipDistributionAccount] transaction object using the provided Epoch. + pub fn initialize_tip_distribution_account_tx( &self, recent_blockhash: Hash, epoch: Epoch, + cluster_info: &Arc, ) -> SanitizedTransaction { let (tip_distribution_account, bump) = derive_tip_distribution_account_address( &self.tip_distribution_program_info.program_id, @@ -341,28 +340,28 @@ impl TipManager { epoch, ); - let ix = init_tip_distribution_account_ix( + let ix = initialize_tip_distribution_account_ix( self.tip_distribution_program_info.program_id, - InitTipDistributionAccountArgs { - validator_vote_account: self.tip_distribution_account_config.vote_account, + InitializeTipDistributionAccountArgs { merkle_root_upload_authority: self .tip_distribution_account_config .merkle_root_upload_authority, validator_commission_bps: self.tip_distribution_account_config.commission_bps, bump, }, - InitTipDistributionAccountAccounts { + InitializeTipDistributionAccountAccounts { config: self.tip_distribution_program_info.config_pda_and_bump.0, tip_distribution_account, - payer: self.tip_distribution_account_config.payer.pubkey(), system_program: system_program::id(), + signer: cluster_info.id(), + validator_vote_account: self.tip_distribution_account_config.vote_account, }, ); SanitizedTransaction::try_from_legacy_transaction(Transaction::new_signed_with_payer( &[ix], - Some(&self.tip_distribution_account_config.payer.pubkey()), - &[self.tip_distribution_account_config.payer.as_ref()], + Some(&cluster_info.id()), + &[cluster_info.keypair().as_ref()], recent_blockhash, )) .unwrap() diff --git a/validator/src/main.rs b/validator/src/main.rs index 365095d4b6..e3cb0ab1de 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -1907,13 +1907,6 @@ pub fn main() { .takes_value(true) .help("The public key of the tip-distribution program.") ) - .arg( - Arg::with_name("tip_distribution_account_payer") - .long("tip-distribution-account-payer") - .value_name("TIP_DISTRIBUTION_ACCOUNT_PAYER") - .takes_value(true) - .help("The payer of my tip distribution accounts.") - ) .arg( Arg::with_name("merkle_root_upload_authority") .long("merkle-root-upload-authority") @@ -3463,17 +3456,6 @@ fn tip_manager_config_from_matches( Pubkey::new_unique() }), tip_distribution_account_config: TipDistributionAccountConfig { - payer: { - let keypair = - keypair_of(matches, "tip_distribution_account_payer").unwrap_or_else(|| { - if !voting_disabled { - panic!("--tip-distribution-account-payer argument required when validator is voting"); - } - Keypair::new() - }); - - Arc::new(keypair) - }, merkle_root_upload_authority: pubkey_of(matches, "merkle_root_upload_authority") .unwrap_or_else(|| { if !voting_disabled {