Skip to content

Commit 5749410

Browse files
authored
feat(mux): support lido registry (#210)
1 parent 0f8f69b commit 5749410

File tree

16 files changed

+604
-49
lines changed

16 files changed

+604
-49
lines changed

Cargo.lock

Lines changed: 287 additions & 6 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ cb-signer = { path = "crates/signer" }
2828

2929
# ethereum
3030
alloy = { version = "0.8.0", features = [
31+
"full",
3132
"rpc-types-beacon",
3233
"serde",
3334
"ssz",

bin/pbs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ async fn main() -> Result<()> {
1414
if std::env::var_os("RUST_BACKTRACE").is_none() {
1515
std::env::set_var("RUST_BACKTRACE", "1");
1616
}
17-
18-
let pbs_config = load_pbs_config()?;
1917
let _guard = initialize_pbs_tracing_log();
2018

19+
let pbs_config = load_pbs_config().await?;
20+
2121
let state = PbsState::new(pbs_config);
2222
PbsService::init_metrics()?;
2323
let server = PbsService::run::<_, DefaultBuilderApi>(state);

bin/signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ async fn main() -> Result<()> {
1414
if std::env::var_os("RUST_BACKTRACE").is_none() {
1515
std::env::set_var("RUST_BACKTRACE", "1");
1616
}
17+
let _guard = initialize_tracing_log(SIGNER_MODULE_NAME);
1718

1819
let config = StartSignerConfig::load_from_env()?;
19-
let _guard = initialize_tracing_log(SIGNER_MODULE_NAME);
2020
let server = SigningService::run(config);
2121

2222
tokio::select! {

config.example.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ late_in_slot_time_ms = 2000
5757
extra_validation_enabled = false
5858
# Execution Layer RPC url to use for extra validation
5959
# OPTIONAL
60-
rpc_url = "http://abc.xyz"
60+
rpc_url = "https://ethereum-holesky-rpc.publicnode.com"
6161

6262
# The PBS module needs one or more [[relays]] as defined below.
6363
[[relays]]
@@ -111,9 +111,12 @@ validator_pubkeys = [
111111
"0x80c7f782b2467c5898c5516a8b6595d75623960b4afc4f71ee07d40985d20e117ba35e7cd352a3e75fb85a8668a3b745",
112112
"0xa119589bb33ef52acbb8116832bec2b58fca590fe5c85eac5d3230b44d5bc09fe73ccd21f88eab31d6de16194d17782e",
113113
]
114-
# Path to a file containing a list of validator pubkeys
114+
# Path to a file containing a list of validator pubkeys or details of a registry to load keys from.
115+
# Supported registries:
116+
# - Lido: NodeOperatorsRegistry
115117
# OPTIONAL
116118
loader = "./mux_keys.example.json"
119+
# loader = { registry = "lido", node_operator_id = 8 }
117120
timeout_get_header_ms = 900
118121
late_in_slot_time_ms = 1500
119122
# For each mux, one or more [[mux.relays]] can be defined, which will be used for the matching validator pubkeys

configs/pbs-mux.toml renamed to configs/pbs_mux.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ chain = "Holesky"
66
port = 18550
77
timeout_get_header_ms = 950
88
late_in_slot_time_ms = 2000
9+
rpc_url = "https://ethereum-holesky-rpc.publicnode.com"
910

1011
# Used for all validators except the ones in the mux
1112
[[relays]]
@@ -22,8 +23,18 @@ loader = "./mux_keys.example.json"
2223
timeout_get_header_ms = 900
2324
late_in_slot_time_ms = 1500
2425

26+
2527
[[mux.relays]]
2628
id = "relay-2"
2729
url = "http://0xa119589bb33ef52acbb8116832bec2b58fca590fe5c85eac5d3230b44d5bc09fe73ccd21f88eab31d6de16194d17782e@def.xyz"
2830
enable_timing_games = true
2931
target_first_request_ms = 200
32+
33+
34+
[[mux]]
35+
id = "lido-mux"
36+
loader = { registry = "lido", node_operator_id = 8 }
37+
38+
[[mux.relays]]
39+
id = "relay-3"
40+
url = "http://0x80c7f782b2467c5898c5516a8b6595d75623960b4afc4f71ee07d40985d20e117ba35e7cd352a3e75fb85a8668a3b745@fgh.xyz"

crates/cli/src/docker_init.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ const SIGNER_NETWORK: &str = "signer_network";
3939

4040
/// Builds the docker compose file for the Commit-Boost services
4141
// TODO: do more validation for paths, images, etc
42-
pub fn handle_docker_init(config_path: String, output_dir: String) -> Result<()> {
42+
pub async fn handle_docker_init(config_path: String, output_dir: String) -> Result<()> {
4343
println!("Initializing Commit-Boost with config file: {}", config_path);
4444
let cb_config = CommitBoostConfig::from_file(&config_path)?;
45+
cb_config.validate().await?;
46+
4547
let chain_spec_path = CommitBoostConfig::chain_spec_file(&config_path);
4648

4749
let metrics_enabled = cb_config.metrics.is_some();

crates/cli/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl Args {
7373

7474
match self.cmd {
7575
Command::Init { config_path, output_path } => {
76-
docker_init::handle_docker_init(config_path, output_path)
76+
docker_init::handle_docker_init(config_path, output_path).await
7777
}
7878

7979
Command::Start { compose_path, env_path } => {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[
2+
{
3+
"constant": true,
4+
"inputs": [
5+
{
6+
"name": "_nodeOperatorId",
7+
"type": "uint256"
8+
}
9+
],
10+
"name": "getTotalSigningKeyCount",
11+
"outputs": [
12+
{
13+
"name": "",
14+
"type": "uint256"
15+
}
16+
],
17+
"payable": false,
18+
"stateMutability": "view",
19+
"type": "function"
20+
},
21+
{
22+
"constant": true,
23+
"inputs": [
24+
{
25+
"name": "_nodeOperatorId",
26+
"type": "uint256"
27+
},
28+
{
29+
"name": "_offset",
30+
"type": "uint256"
31+
},
32+
{
33+
"name": "_limit",
34+
"type": "uint256"
35+
}
36+
],
37+
"name": "getSigningKeys",
38+
"outputs": [
39+
{
40+
"name": "pubkeys",
41+
"type": "bytes"
42+
},
43+
{
44+
"name": "signatures",
45+
"type": "bytes"
46+
},
47+
{
48+
"name": "used",
49+
"type": "bool[]"
50+
}
51+
],
52+
"payable": false,
53+
"stateMutability": "view",
54+
"type": "function"
55+
}
56+
]

crates/common/src/config/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@ pub struct CommitBoostConfig {
3838

3939
impl CommitBoostConfig {
4040
/// Validate config
41-
pub fn validate(&self) -> Result<()> {
42-
self.pbs.pbs_config.validate()?;
41+
pub async fn validate(&self) -> Result<()> {
42+
self.pbs.pbs_config.validate(self.chain).await?;
4343
Ok(())
4444
}
4545

4646
pub fn from_file(path: &str) -> Result<Self> {
4747
let config: Self = load_from_file(path)?;
48-
config.validate()?;
4948
Ok(config)
5049
}
5150

@@ -83,7 +82,6 @@ impl CommitBoostConfig {
8382
logs: helper_config.logs,
8483
};
8584

86-
config.validate()?;
8785
Ok(config)
8886
}
8987

0 commit comments

Comments
 (0)