Skip to content

Commit 6a3ca1d

Browse files
authored
Add auto-registration to Vault and NCN in Operator Client (#165)
- Fixes #85 ``` cargo r --bin tip-router-operator-cli -- \ --keypair-path ~/.config/solana/id.json \ --operator-address 2jXCuwLFGZ69FwBRSsrx6AjRhPx1wohB24Lsap7422Zr \ --ledger-path ./ \ --backup-snapshots-dir ./backup \ --snapshot-output-dir ./snapshot \ --full-snapshots-path ./snapshot \ --save-path ./ \ --rpc-url "" \ run \ --ncn-address 2jXCuwLFGZ69FwBRSsrx6AjRhPx1wohB24Lsap7422Zr \ --tip-distribution-program-id 2jXCuwLFGZ69FwBRSsrx6AjRhPx1wohB24Lsap7422Zr \ --priority-fee-distribution-program-id 2jXCuwLFGZ69FwBRSsrx6AjRhPx1wohB24Lsap7422Zr \ --tip-payment-program-id 2jXCuwLFGZ69FwBRSsrx6AjRhPx1wohB24Lsap7422Zr ```
1 parent 756b13a commit 6a3ca1d

File tree

8 files changed

+269
-22
lines changed

8 files changed

+269
-22
lines changed

Cargo.lock

Lines changed: 27 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ spl-token-2022 = { version = "=7.0.0", features = ["no-entrypoint"] }
119119
switchboard-on-demand = "0.3.4"
120120
syn = "2.0.72"
121121
thiserror = "1.0.57"
122-
tokio = { version = "1.36.0", features = ["full"] }
122+
tokio = { version = "1.47.1", features = ["full"] }
123123

124124
[profile.release]
125125
overflow-checks = true

tip-router-operator-cli/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description = "CLI for Jito Tip Router"
77
[dependencies]
88
anchor-lang = { workspace = true }
99
anyhow = { workspace = true }
10-
base64 = "0.13"
10+
base64 = { workspace = true }
1111
clap = { workspace = true }
1212
clap_old = { workspace = true }
1313
crossbeam-channel = "0.5.15"
@@ -17,6 +17,9 @@ im = "15.1"
1717
itertools = "0.11"
1818
jito-bytemuck = { workspace = true }
1919
jito-priority-fee-distribution-sdk = { workspace = true }
20+
jito-restaking-client = { workspace = true }
21+
jito-restaking-core = { workspace = true }
22+
jito-restaking-program = { workspace = true }
2023
jito-tip-distribution-sdk = { workspace = true }
2124
jito-tip-payment-sdk = { workspace = true }
2225
jito-tip-router-client = { workspace = true }

tip-router-operator-cli/src/bin/serialize-accounts.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{fs::File, io::Write, str::FromStr};
22

33
use anchor_lang::prelude::*;
4+
use base64::{engine::general_purpose, Engine};
45
use clap::Parser;
56
use jito_tip_distribution_sdk::{
67
derive_tip_distribution_account_address, TipDistributionAccount, TIP_DISTRIBUTION_SIZE,
@@ -71,7 +72,7 @@ fn main() {
7172
.expect("Failed to serialize account");
7273

7374
// Encode the binary data as base64
74-
let base64_data = base64::encode(binary_data);
75+
let base64_data = general_purpose::STANDARD.encode(binary_data);
7576

7677
// Create the JSON structure
7778
let json_data = json!({

tip-router-operator-cli/src/cli.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ pub enum Commands {
148148
#[arg(long, env)]
149149
tip_router_program_id: Pubkey,
150150

151+
#[arg(long, env, default_value = "jito_restaking_program::id()")]
152+
restaking_program_id: Pubkey,
153+
151154
#[arg(long, env, default_value = "3")]
152155
num_monitored_epochs: u64,
153156

tip-router-operator-cli/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod load_and_process_ledger;
1212
pub mod priority_fees;
1313
pub mod process_epoch;
1414
pub mod reclaim;
15+
pub mod restaking;
1516
pub mod rpc_utils;
1617
pub mod solana_cli;
1718
pub mod submit;

tip-router-operator-cli/src/main.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
use ::{
33
anyhow::Result,
44
clap::Parser,
5+
jito_restaking_core::config::Config as RestakingConfig,
56
log::{error, info},
67
solana_metrics::{datapoint_error, datapoint_info, set_host_id},
78
solana_rpc_client::nonblocking::rpc_client::RpcClient,
89
solana_sdk::{pubkey::Pubkey, signer::keypair::read_keypair_file},
9-
std::process::Command,
10-
std::{str::FromStr, sync::Arc, time::Duration},
10+
std::{process::Command, str::FromStr, sync::Arc, time::Duration},
1111
tip_router_operator_cli::{
1212
backup_snapshots::BackupSnapshotMonitor,
1313
claim::{claim_mev_tips_with_emit, emit_claim_mev_tips_metrics},
@@ -16,6 +16,7 @@ use ::{
1616
ledger_utils::get_bank_from_snapshot_at_slot,
1717
load_bank_from_snapshot, meta_merkle_tree_path, process_epoch, read_merkle_tree_collection,
1818
read_stake_meta_collection, reclaim,
19+
restaking::RestakingHandler,
1920
submit::{submit_recent_epochs_to_ncn, submit_to_ncn},
2021
tip_distribution_stats::get_tip_distribution_stats,
2122
tip_router::get_ncn_config,
@@ -96,6 +97,7 @@ async fn main() -> Result<()> {
9697
priority_fee_distribution_program_id,
9798
tip_payment_program_id,
9899
tip_router_program_id,
100+
restaking_program_id,
99101
save_snapshot,
100102
num_monitored_epochs,
101103
override_target_slot,
@@ -132,6 +134,21 @@ async fn main() -> Result<()> {
132134
let rpc_url = cli.rpc_url.clone();
133135
let claim_tips_epoch_filepath = cli.claim_tips_epoch_filepath.clone();
134136
let cli_clone: Cli = cli.clone();
137+
let operator_address = cli.operator_address.clone();
138+
let cluster = cli.cluster.clone();
139+
let restaking_config_address =
140+
RestakingConfig::find_program_address(&restaking_program_id).0;
141+
142+
let restaking_handler = RestakingHandler::new(
143+
rpc_client.clone(),
144+
restaking_program_id,
145+
restaking_config_address,
146+
ncn_address,
147+
Pubkey::from_str(cli.operator_address.as_str()).unwrap(),
148+
keypair.clone(),
149+
);
150+
restaking_handler.warmup_operator().await?;
151+
restaking_handler.create_operator_vault_tickets().await?;
135152

136153
if !backup_snapshots_dir.exists() {
137154
info!(
@@ -141,9 +158,6 @@ async fn main() -> Result<()> {
141158
std::fs::create_dir_all(&backup_snapshots_dir)?;
142159
}
143160

144-
let operator_address = cli.operator_address.clone();
145-
let cluster = cli.cluster.clone();
146-
147161
let try_catchup = tip_router_operator_cli::solana_cli::catchup(
148162
cli.rpc_url.to_owned(),
149163
cli.localhost_port,

0 commit comments

Comments
 (0)