Skip to content

Allow for optional configured authorization_token for relayer #169

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

Merged
merged 1 commit into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-agent"
version = "3.0.4"
version = "3.0.5"
edition = "2024"

[[bin]]
Expand Down
13 changes: 12 additions & 1 deletion src/agent/services/lazer_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub struct Config {
pub history_url: Url,
pub relayer_urls: Vec<Url>,
pub publish_keypair_path: PathBuf,
pub authorization_token: Option<String>,
#[serde(with = "humantime_serde", default = "default_publish_interval")]
pub publish_interval_duration: Duration,
#[serde(with = "humantime_serde", default = "default_symbol_fetch_interval")]
Expand Down Expand Up @@ -292,13 +293,22 @@ pub fn lazer_exporter(config: Config, state: Arc<state::State>) -> Vec<JoinHandl
let pubkey_base64 = BASE64_STANDARD.encode(signing_key.verifying_key().to_bytes());
tracing::info!("Loaded Lazer signing key; pubkey in base64: {pubkey_base64}");

let authorization_token = if let Some(authorization_token) = config.authorization_token.clone()
{
// If authorization_token is configured, use it.
authorization_token
} else {
// Otherwise, use the base64 pubkey.
pubkey_base64
};

// can safely drop first receiver for ease of iteration
let (relayer_sender, _) = broadcast::channel(RELAYER_CHANNEL_CAPACITY);

for url in config.relayer_urls.iter() {
let mut task = RelayerSessionTask {
url: url.clone(),
token: pubkey_base64.clone(),
token: authorization_token.clone(),
receiver: relayer_sender.subscribe(),
};
handles.push(tokio::spawn(async move { task.run().await }));
Expand Down Expand Up @@ -725,6 +735,7 @@ mod tests {
history_url: Url::parse("http://127.0.0.1:12345").unwrap(),
relayer_urls: vec![Url::parse("http://127.0.0.1:12346").unwrap()],
publish_keypair_path: PathBuf::from(private_key_file.path()),
authorization_token: None,
publish_interval_duration: Duration::from_secs(1),
symbol_fetch_interval_duration: Duration::from_secs(60 * 60),
};
Expand Down
Loading