Skip to content

Commit 95455b3

Browse files
committed
Add merkle root upload config to cli
1 parent 24ec5d8 commit 95455b3

File tree

2 files changed

+102
-5
lines changed
  • mev-programs
    • priority-fee-distribution-cli/src
    • tip-distribution-cli/src

2 files changed

+102
-5
lines changed

mev-programs/priority-fee-distribution-cli/src/main.rs

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{path::PathBuf, str::FromStr};
22

33
use anchor_lang::{system_program, AccountDeserialize, InstructionData, ToAccountMetas};
4+
use bs58;
45
use clap::{Parser, Subcommand};
56
use jito_priority_fee_distribution::state::{ClaimStatus, Config, PriorityFeeDistributionAccount};
67
use jito_priority_fee_distribution_sdk::{
@@ -9,10 +10,14 @@ use jito_priority_fee_distribution_sdk::{
910
use solana_client::{rpc_client::RpcClient, rpc_config::RpcSendTransactionConfig};
1011
use solana_sdk::{
1112
compute_budget::ComputeBudgetInstruction,
13+
1214
instruction::Instruction,
15+
1316
pubkey::Pubkey,
14-
signer::{keypair::read_keypair_file, Signer},
17+
18+
signer::{{keypair::read_keypair_file, Signer},
1519
transaction::Transaction,
20+
, Signer},
1621
};
1722

1823
#[derive(Parser)]
@@ -156,6 +161,17 @@ enum Commands {
156161
#[arg(long)]
157162
lamports: u64,
158163
},
164+
165+
/// Update the merkle root upload config account
166+
UpdateMerkleRootUploadConfig {
167+
/// Authority pubkey
168+
#[arg(long)]
169+
authority: String,
170+
171+
/// Original authority pubkey
172+
#[arg(long)]
173+
original_authority: String,
174+
},
159175
}
160176

161177
fn main() -> anyhow::Result<()> {
@@ -276,11 +292,11 @@ fn main() -> anyhow::Result<()> {
276292
bump,
277293
go_live_epoch,
278294
} => {
279-
let authority_pubkey = Pubkey::from_str(&authority)?;
295+
let authority_pubkey = authority_keypair.pubkey();
280296
let expired_funds_account_pubkey = Pubkey::from_str(&expired_funds_account)?;
281297

282298
let config = Config {
283-
authority: authority_pubkey,
299+
authority: Pubkey::from_str(&authority)?,
284300
expired_funds_account: expired_funds_account_pubkey,
285301
num_epochs_valid,
286302
max_validator_commission_bps,
@@ -305,7 +321,12 @@ fn main() -> anyhow::Result<()> {
305321

306322
let serialized_data = instruction.data;
307323
let base58_data = bs58::encode(serialized_data).into_string();
308-
println!("Base58 Serialized Data: {}", base58_data);
324+
println!("Base58 Serialized Data: {}", base58_data);*/
325+
let mut transaction =
326+
solana_sdk::transaction::Transaction::new_with_payer(&[instruction], None);
327+
transaction.sign(&[&authority_keypair], client.get_latest_blockhash()?);
328+
let signature = client.send_and_confirm_transaction_with_spinner(&transaction)?;
329+
println!("Transaction Signature: {}", signature);
309330
}
310331

311332
Commands::Initialize {
@@ -414,6 +435,56 @@ fn main() -> anyhow::Result<()> {
414435
println!(" Bump: {}", config.bump);
415436
}
416437

438+
Commands::UpdateMerkleRootUploadConfig {
439+
authority,
440+
original_authority,
441+
} => {
442+
let authority_pubkey = Pubkey::from_str(&authority)?;
443+
let original_authority_pubkey = Pubkey::from_str(&original_authority)?;
444+
445+
let (config_pda, _) = derive_config_account_address(&program_id);
446+
let (merkle_root_upload_config, _) =
447+
Pubkey::find_program_address(&[b"ROOT_UPLOAD_CONFIG"], &program_id);
448+
449+
let instruction = Instruction {
450+
program_id,
451+
data: jito_priority_fee_distribution::instruction::UpdateMerkleRootUploadConfig {
452+
authority: authority_pubkey,
453+
original_authority: original_authority_pubkey,
454+
}
455+
.data(),
456+
accounts: jito_priority_fee_distribution::accounts::UpdateMerkleRootUploadConfig {
457+
config: config_pda,
458+
merkle_root_upload_config,
459+
authority: authority_pubkey,
460+
system_program: solana_sdk::system_program::ID,
461+
}
462+
.to_account_metas(None),
463+
};
464+
465+
let serialized_data = instruction.data;
466+
let base58_data = bs58::encode(serialized_data).into_string();
467+
println!("Base58 Serialized Data: {}", base58_data);
468+
469+
println!("\nAccounts:");
470+
for (i, account_meta) in instruction.accounts.iter().enumerate() {
471+
let writable_status = if account_meta.is_writable {
472+
"writable"
473+
} else {
474+
"readonly"
475+
};
476+
let signer_status = if account_meta.is_signer {
477+
"signer"
478+
} else {
479+
"non-signer"
480+
};
481+
println!(
482+
" {}: {} ({}, {})",
483+
i, account_meta.pubkey, writable_status, signer_status
484+
);
485+
}
486+
}
487+
417488
Commands::TransferPriorityFeeTips {
418489
keypair_path,
419490
vote_account,

mev-programs/tip-distribution-cli/src/main.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use std::str::FromStr;
22

33
use anchor_lang::AccountDeserialize;
44
use clap::{Parser, Subcommand};
5-
use jito_tip_distribution::state::{ClaimStatus, Config, TipDistributionAccount};
5+
use jito_tip_distribution::state::{
6+
ClaimStatus, Config, MerkleRootUploadConfig, TipDistributionAccount,
7+
};
68
use jito_tip_distribution_sdk::{
79
derive_config_account_address, derive_tip_distribution_account_address,
810
instruction::{update_config_ix, UpdateConfigAccounts, UpdateConfigArgs},
@@ -60,6 +62,9 @@ enum Commands {
6062
claimant: String,
6163
},
6264

65+
/// Get the merkle root upload config account information
66+
GetMerkleRootUploadConfig,
67+
6368
/// Update the config account information
6469
UpdateConfig {
6570
/// Authority pubkey
@@ -189,6 +194,27 @@ fn main() -> anyhow::Result<()> {
189194
println!(" Bump: {}", claim_status.bump);
190195
}
191196

197+
Commands::GetMerkleRootUploadConfig => {
198+
let (merkle_root_upload_config_pda, _) =
199+
Pubkey::find_program_address(&[MerkleRootUploadConfig::SEED], &program_id);
200+
println!(
201+
"Merkle Root Upload Config Account Address: {}",
202+
merkle_root_upload_config_pda
203+
);
204+
205+
let account_data = client.get_account(&merkle_root_upload_config_pda)?.data;
206+
let config: MerkleRootUploadConfig =
207+
MerkleRootUploadConfig::try_deserialize(&mut account_data.as_slice())?;
208+
209+
println!("Merkle Root Upload Config Account Data:");
210+
println!(" Override Authority: {}", config.override_authority);
211+
println!(
212+
" Original Upload Authority: {}",
213+
config.original_upload_authority
214+
);
215+
println!(" Bump: {}", config.bump);
216+
}
217+
192218
Commands::UpdateConfig {
193219
authority,
194220
expired_funds_account,

0 commit comments

Comments
 (0)