Skip to content

Commit e1b5c37

Browse files
authored
feat(mux): add HTTP source in loader (#255)
1 parent 12a534a commit e1b5c37

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

config.example.toml

+7
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ validator_pubkeys = [
120120
# - SSV: SSV API
121121
# OPTIONAL
122122
loader = "./tests/data/mux_keys.example.json"
123+
# URL to HTTP endpoint returning JSON list of validator pubkeys
124+
# Example response:
125+
# [
126+
# "0x80c7f782b2467c5898c5516a8b6595d75623960b4afc4f71ee07d40985d20e117ba35e7cd352a3e75fb85a8668a3b745",
127+
# "0xa119589bb33ef52acbb8116832bec2b58fca590fe5c85eac5d3230b44d5bc09fe73ccd21f88eab31d6de16194d17782e"
128+
#]
129+
# loader = { url = "http://localhost:8000/keys" }
123130
# loader = { registry = "lido", node_operator_id = 8 }
124131
# loader = { registry = "ssv", node_operator_id = 8 }
125132
timeout_get_header_ms = 900

crates/common/src/config/mux.rs

+12
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ impl MuxConfig {
129129

130130
Some((get_mux_env(&self.id), path.to_owned(), internal_path))
131131
}
132+
MuxKeysLoader::HTTP { .. } => None,
132133
MuxKeysLoader::Registry { .. } => None,
133134
})
134135
}
@@ -139,6 +140,9 @@ impl MuxConfig {
139140
pub enum MuxKeysLoader {
140141
/// A file containing a list of validator pubkeys
141142
File(PathBuf),
143+
HTTP {
144+
url: String,
145+
},
142146
Registry {
143147
registry: NORegistry,
144148
node_operator_id: u64,
@@ -170,6 +174,14 @@ impl MuxKeysLoader {
170174
serde_json::from_str(&file).wrap_err("failed to parse mux keys file")
171175
}
172176

177+
Self::HTTP { url } => {
178+
let client = reqwest::Client::new();
179+
let response = client.get(url).send().await?;
180+
let pubkeys = response.text().await?;
181+
serde_json::from_str(&pubkeys)
182+
.wrap_err("failed to fetch mux keys from http endpoint")
183+
}
184+
173185
Self::Registry { registry, node_operator_id } => match registry {
174186
NORegistry::Lido => {
175187
let Some(rpc_url) = rpc_url else {

0 commit comments

Comments
 (0)