Skip to content

Commit 2f2bd11

Browse files
authored
Merge pull request #146 from jito-foundation/jm/actually-add-squads
Add basic Squads v3/v4 alerting
2 parents 80094ae + 5681ea1 commit 2f2bd11

27 files changed

Lines changed: 872 additions & 580 deletions

Cargo.lock

Lines changed: 16 additions & 471 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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["examples/token-program", "jito-bell", "twitterust"]
2+
members = ["jito-bell", "twitterust"]
33
resolver = "2"
44

55
[workspace.dependencies]
@@ -21,7 +21,6 @@ log = "0.4.17"
2121
maplit = "1.0.2"
2222
num-derive = "0.4.2"
2323
num-traits = "0.2.19"
24-
openssl = { version = "0.10.72", features = ["vendored"] }
2524
percent-encoding = "2.3"
2625
rand = "0.8"
2726
reqwest = { version = "0.11.0", features = ["json"] }
@@ -41,12 +40,6 @@ thiserror = "2.0.12"
4140
tokio = { version = "1.0.1", features = ["full"] }
4241
toml = "0.8.22"
4342
tonic = { version = "0.13.1" }
44-
tracing = "0.1.41"
45-
tracing-appender = "0.2.3"
46-
tracing-subscriber = "0.3.19"
4743
twitterust = { path = "./twitterust" }
4844
yellowstone-grpc-client = "2.0.0"
4945
yellowstone-grpc-proto = { version = "2.0.0", default-features = false }
50-
yellowstone-vixen = "0.3.0"
51-
yellowstone-vixen-core = "0.3.0"
52-
yellowstone-vixen-parser = "0.3.0"

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
container_name: jito-bell
88
environment:
99
- RUST_LOG=${RUST_LOG:-debug}
10-
- ENDPOINT=${ENDPOINT}
10+
- YELLOWSTONE_URL=${YELLOWSTONE_URL}
1111
- X_TOKEN=${X_TOKEN}
1212
- ACCOUNT_INCLUDE=${ACCOUNT_INCLUDE}
1313
- CONFIG_FILE=${CONFIG_FILE}

examples/token-program/Cargo.toml

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/token-program/src/main.rs

Lines changed: 0 additions & 41 deletions
This file was deleted.

jito-bell/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jito-vault-client = { workspace = true }
2626
jito-vault-sdk = { workspace = true }
2727
log = { workspace = true }
2828
maplit = { workspace = true }
29-
openssl = { workspace = true }
3029
reqwest = { workspace = true }
3130
serde = { workspace = true }
3231
serde_json = { workspace = true }
@@ -42,9 +41,6 @@ spl-token-2022 = { workspace = true }
4241
thiserror = { workspace = true }
4342
tokio = { workspace = true }
4443
tonic = { workspace = true }
45-
tracing = { workspace = true }
46-
tracing-appender = { workspace = true }
47-
tracing-subscriber = { workspace = true }
4844
twitterust = { workspace = true }
4945
yellowstone-grpc-client = { workspace = true }
5046
yellowstone-grpc-proto = { workspace = true }

jito-bell/src/bin/main.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ use yellowstone_grpc_proto::geyser::CommitmentLevel;
1313
async fn main() -> anyhow::Result<()> {
1414
dotenvy::dotenv().ok();
1515

16+
if env::var("YELLOWSTONE_URL").is_err() {
17+
if let Ok(endpoint) = env::var("ENDPOINT") {
18+
env::set_var("YELLOWSTONE_URL", endpoint);
19+
}
20+
}
21+
1622
let log_path =
1723
env::var("LOG_FILE_PATH").unwrap_or_else(|_| "/var/log/jito-bell/app.log".to_string());
1824

@@ -43,7 +49,10 @@ async fn main() -> anyhow::Result<()> {
4349

4450
let args = Args::parse();
4551

46-
info!("Starting Jito Bell with endpoint: {}", args.endpoint);
52+
info!(
53+
"Starting Jito Bell with yellowstone URL: {}",
54+
args.yellowstone_url
55+
);
4756

4857
let hostname_cmd = Command::new("hostname")
4958
.output()
@@ -62,7 +71,7 @@ async fn main() -> anyhow::Result<()> {
6271

6372
let commitment = CommitmentConfig::confirmed();
6473
let mut handler = JitoBellHandler::new(
65-
args.endpoint.clone(),
74+
args.yellowstone_url.clone(),
6675
commitment,
6776
args.config_file,
6877
subscribe_option,

jito-bell/src/cli_args.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use yellowstone_grpc_proto::geyser::CommitmentLevel;
66
#[derive(Debug, Clone, Parser)]
77
#[clap(author, version, about)]
88
pub struct Args {
9-
#[clap(short, long, env = "ENDPOINT")]
10-
/// Service endpoint
11-
pub endpoint: String,
9+
#[clap(long, env = "YELLOWSTONE_URL")]
10+
/// Yellowstone gRPC endpoint URL
11+
pub yellowstone_url: String,
1212

1313
#[clap(long, env = "X_TOKEN")]
1414
pub x_token: Option<String>,

jito-bell/src/config.rs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,28 @@ use std::collections::HashMap;
22

33
use serde::Deserialize;
44

5-
use crate::program::{EventConfig, Program, ProgramName};
5+
use crate::program::{EventConfig, ProgramConfig, ProgramName};
66

77
#[derive(Deserialize)]
88
pub struct JitoBellConfig {
99
/// Programs Configuration
10-
pub programs: HashMap<ProgramName, Program>,
10+
pub programs: HashMap<ProgramName, ProgramConfig>,
1111

1212
/// Block explorer url
1313
pub explorer_url: String,
1414

15+
/// Squads app URL template
16+
#[serde(default = "default_squads_app_url_template")]
17+
pub squads_app_url_template: String,
18+
1519
/// Message Templates
1620
pub message_templates: HashMap<String, String>,
1721
}
1822

23+
fn default_squads_app_url_template() -> String {
24+
"https://app.squads.so/squads/{{multisig}}/transactions/{{transaction}}".to_string()
25+
}
26+
1927
impl JitoBellConfig {
2028
/// Get a message template by name, falling back to default
2129
pub fn get_template(&self, name: &str) -> Option<&String> {
@@ -25,9 +33,30 @@ impl JitoBellConfig {
2533
}
2634
}
2735

36+
#[cfg(test)]
37+
mod tests {
38+
use super::JitoBellConfig;
39+
40+
#[test]
41+
fn sample_config_parses() {
42+
let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
43+
.parent()
44+
.unwrap()
45+
.join("jito_bell_config_sample.yaml");
46+
let yaml = std::fs::read_to_string(path).expect("sample config file not found");
47+
serde_yaml::from_str::<JitoBellConfig>(&yaml)
48+
.expect("sample config should deserialize without error");
49+
}
50+
}
51+
2852
impl std::fmt::Display for JitoBellConfig {
2953
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3054
writeln!(f, "Explorer URL: {}", self.explorer_url)?;
55+
writeln!(
56+
f,
57+
"Squads App URL Template: {}",
58+
self.squads_app_url_template
59+
)?;
3160

3261
writeln!(f, "Message Templates:")?;
3362
for (name, template) in &self.message_templates {
@@ -41,6 +70,8 @@ impl std::fmt::Display for JitoBellConfig {
4170
ProgramName::SplToken2022 => "spl_token2022",
4271
ProgramName::SplStakePool => "spl_stake_pool",
4372
ProgramName::JitoVault => "jito_vault",
73+
ProgramName::SquadsV3 => "squads_v3",
74+
ProgramName::SquadsV4 => "squads_v4",
4475
};
4576
writeln!(f, " Program Name: {}", program_name)?;
4677
writeln!(f, " Program ID: {}", program.program_id)?;

jito-bell/src/event_parser/jito_steward.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
use std::str::FromStr;
2-
31
use base64::{engine::general_purpose::STANDARD, Engine};
42
use borsh::BorshDeserialize;
53
use log::error;
6-
use solana_pubkey::Pubkey;
4+
use solana_pubkey::{pubkey, Pubkey};
75

86
use crate::events::jito_steward::{
97
AutoAddValidatorEvent, AutoRemoveValidatorEvent, DecreaseComponents, DirectedRebalanceEvent,
@@ -46,7 +44,7 @@ impl std::fmt::Display for JitoStewardEvent {
4644
impl JitoStewardEvent {
4745
/// Retrieve Program ID of Jito Steward Program
4846
pub fn program_id() -> Pubkey {
49-
Pubkey::from_str("Stewardf95sJbmtcZsyagb2dg4Mo8eVQho8gpECvLx8").unwrap()
47+
pubkey!("Stewardf95sJbmtcZsyagb2dg4Mo8eVQho8gpECvLx8")
5048
}
5149

5250
/// Parse a log message and extract any events

0 commit comments

Comments
 (0)