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

invoke updated init tda instruction #228

Merged
merged 2 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
105 changes: 53 additions & 52 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/src/bundle_sanitizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ 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()),
node_identity: Arc::new(Keypair::new()),
merkle_root_upload_authority: Pubkey::new_unique(),
vote_account: Pubkey::new_unique(),
commission_bps: 0,
Expand Down
7 changes: 5 additions & 2 deletions core/src/bundle_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,11 @@ impl BundleStage {
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()))
info!("building initialize_tip_distribution_account tx");
Some(
tip_manager
.initialize_tip_distribution_account_tx(bank.last_blockhash(), bank.epoch()),
)
} else {
None
};
Expand Down
29 changes: 15 additions & 14 deletions core/src/tip_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,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::{
Expand Down Expand Up @@ -61,11 +62,11 @@ 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<Keypair>,
pub node_identity: Arc<Keypair>,

/// The account with authority to upload merkle-roots to this validator's [TipDistributionAccount].
pub merkle_root_upload_authority: Pubkey,
Expand All @@ -80,7 +81,7 @@ pub struct TipDistributionAccountConfig {
impl Default for TipDistributionAccountConfig {
fn default() -> Self {
Self {
payer: Arc::new(Keypair::new()),
node_identity: Arc::new(Keypair::new()),
merkle_root_upload_authority: Pubkey::new_unique(),
vote_account: Pubkey::new_unique(),
commission_bps: 0,
Expand Down Expand Up @@ -329,8 +330,8 @@ impl TipManager {
.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,
Expand All @@ -341,28 +342,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: self.tip_distribution_account_config.node_identity.pubkey(),
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(&self.tip_distribution_account_config.node_identity.pubkey()),
&[self.tip_distribution_account_config.node_identity.as_ref()],
recent_blockhash,
))
.unwrap()
Expand Down
Loading