-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add list of default relays and config to enable them #321
base: develop
Are you sure you want to change the base?
Changes from 3 commits
c1c6b62
1124f4b
ccfa807
8f978a8
9963b7c
3ce1010
120a8d6
0e20616
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
log_json = true | ||
log_level = "info,rbuilder=debug" | ||
redacted_telemetry_server_port = 6061 | ||
redacted_telemetry_server_ip = "0.0.0.0" | ||
full_telemetry_server_port = 6060 | ||
full_telemetry_server_ip = "0.0.0.0" | ||
|
||
chain = "mainnet" | ||
reth_datadir = "/mnt/data/reth" | ||
|
||
coinbase_secret_key = "env:COINBASE_SECRET_KEY" | ||
relay_secret_key = "env:RELAY_SECRET_KEY" | ||
optimistic_relay_secret_key = "env:OPTIMISTIC_RELAY_SECRET_KEY" | ||
|
||
# cl_node_url can be a single value, array of values, or passed by an environment variables with values separated with a comma | ||
# cl_node_url = "http://localhost:3500" | ||
cl_node_url = ["env:CL_NODE_URL"] | ||
jsonrpc_server_port = 8645 | ||
jsonrpc_server_ip = "0.0.0.0" | ||
el_node_ipc_path = "/tmp/reth.ipc" | ||
extra_data = "β‘π€" | ||
|
||
blocklist_file_path = "./blocklist.json" | ||
|
||
dry_run = true | ||
dry_run_validation_url = "http://localhost:8545" | ||
|
||
ignore_cancellable_orders = true | ||
|
||
max_concurrent_seals = 4 | ||
|
||
# genesis_fork_version = "0x00112233" | ||
|
||
sbundle_mergeable_signers = [] | ||
live_builders = ["mp-ordering", "mgp-ordering", "merging"] | ||
|
||
enabled_relays = ["custom"] | ||
|
||
[[relays]] | ||
name = "custom" | ||
priority = 10 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
log_json = true | ||
log_level = "info,rbuilder=debug" | ||
redacted_telemetry_server_port = 6061 | ||
redacted_telemetry_server_ip = "0.0.0.0" | ||
full_telemetry_server_port = 6060 | ||
full_telemetry_server_ip = "0.0.0.0" | ||
|
||
chain = "mainnet" | ||
reth_datadir = "/mnt/data/reth" | ||
|
||
coinbase_secret_key = "env:COINBASE_SECRET_KEY" | ||
relay_secret_key = "env:RELAY_SECRET_KEY" | ||
optimistic_relay_secret_key = "env:OPTIMISTIC_RELAY_SECRET_KEY" | ||
|
||
# cl_node_url can be a single value, array of values, or passed by an environment variables with values separated with a comma | ||
# cl_node_url = "http://localhost:3500" | ||
cl_node_url = ["env:CL_NODE_URL"] | ||
jsonrpc_server_port = 8645 | ||
jsonrpc_server_ip = "0.0.0.0" | ||
el_node_ipc_path = "/tmp/reth.ipc" | ||
extra_data = "β‘π€" | ||
|
||
blocklist_file_path = "./blocklist.json" | ||
|
||
dry_run = true | ||
dry_run_validation_url = "http://localhost:8545" | ||
|
||
ignore_cancellable_orders = true | ||
|
||
max_concurrent_seals = 4 | ||
|
||
# genesis_fork_version = "0x00112233" | ||
|
||
sbundle_mergeable_signers = [] | ||
live_builders = ["mp-ordering", "mgp-ordering", "merging"] | ||
|
||
enabled_relays = ["playground"] | ||
|
||
[[relays]] | ||
name = "playground" | ||
priority = 10 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
use crate::mev_boost::{RelayClient, SubmitBlockErr, SubmitBlockRequest}; | ||
use governor::{DefaultDirectRateLimiter, Quota, RateLimiter}; | ||
use serde::{Deserialize, Deserializer}; | ||
use std::ops::BitOr; | ||
use std::{env, sync::Arc, time::Duration}; | ||
use url::Url; | ||
|
||
|
@@ -11,7 +12,8 @@ pub type MevBoostRelayID = String; | |
#[serde(deny_unknown_fields)] | ||
pub struct RelayConfig { | ||
pub name: String, | ||
pub url: String, | ||
pub url: Option<String>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A RelayConfig with no url makes no sense. Why the Option? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea is to be able to update one of the default relays like:
But this cannot be done because |
||
#[serde(default)] | ||
pub priority: usize, | ||
// true->ssz false->json | ||
#[serde(default)] | ||
|
@@ -33,7 +35,7 @@ pub struct RelayConfig { | |
impl RelayConfig { | ||
pub fn with_url(self, url: &str) -> Self { | ||
Self { | ||
url: url.to_string(), | ||
url: Some(url.to_string()), | ||
..self | ||
} | ||
} | ||
|
@@ -46,6 +48,30 @@ impl RelayConfig { | |
} | ||
} | ||
|
||
impl BitOr for RelayConfig { | ||
type Output = Self; | ||
|
||
fn bitor(self, other: Self) -> Self { | ||
if self.name != other.name { | ||
return self; | ||
} | ||
Self { | ||
name: self.name, | ||
url: other.url.or(self.url), | ||
priority: self.priority | other.priority, | ||
use_ssz_for_submit: self.use_ssz_for_submit | other.use_ssz_for_submit, | ||
use_gzip_for_submit: self.use_gzip_for_submit | other.use_gzip_for_submit, | ||
optimistic: self.optimistic | other.optimistic, | ||
authorization_header: other.authorization_header.or(self.authorization_header), | ||
builder_id_header: other.builder_id_header.or(self.builder_id_header), | ||
api_token_header: other.api_token_header.or(self.api_token_header), | ||
interval_between_submissions_ms: other | ||
.interval_between_submissions_ms | ||
.or(self.interval_between_submissions_ms), | ||
} | ||
} | ||
} | ||
|
||
/// Wrapper over RelayClient that allows to submit blocks and | ||
/// hides the particular configuration (eg: ssz, gip, optimistic). | ||
/// Sometimes the client is used externally. | ||
|
@@ -66,8 +92,13 @@ pub struct MevBoostRelay { | |
|
||
impl MevBoostRelay { | ||
pub fn from_config(config: &RelayConfig) -> eyre::Result<Self> { | ||
let url = config | ||
.url | ||
.as_ref() | ||
.ok_or_else(|| eyre::eyre!("url is required"))?; | ||
|
||
let client = { | ||
let url: Url = config.url.parse()?; | ||
let url: Url = url.parse()?; | ||
RelayClient::from_url( | ||
url, | ||
config.authorization_header.clone(), | ||
|
@@ -135,7 +166,7 @@ mod test { | |
|
||
let config: RelayConfig = toml::from_str(example).unwrap(); | ||
assert_eq!(config.name, "relay1"); | ||
assert_eq!(config.url, "url"); | ||
assert_eq!(config.url.expect("url expected"), "url"); | ||
assert_eq!(config.priority, 0); | ||
assert_eq!(config.authorization_header.unwrap(), "AAA"); | ||
assert_eq!(config.builder_id_header.unwrap(), "BBB"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it feel more natural/easy to use a map string->cfg instead of vector + find name?