Skip to content

Commit 4958676

Browse files
committed
Merge branch 'main' into mb/add_num_registrations
2 parents 03e4366 + 2dc01d1 commit 4958676

31 files changed

Lines changed: 349 additions & 55 deletions

File tree

api/signer-api.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ info:
55
description: API that allows commit modules to request generic signatures from validators
66
tags:
77
- name: Signer
8+
- name: Management
89
paths:
910
/signer/v1/get_pubkeys:
1011
get:
@@ -254,6 +255,20 @@ paths:
254255
type: string
255256
example: "Internal error"
256257

258+
/status:
259+
get:
260+
summary: Get the status of the Signer API module
261+
tags:
262+
- Management
263+
responses:
264+
"200":
265+
description: Success
266+
content:
267+
text/plain:
268+
schema:
269+
type: string
270+
example: "OK"
271+
257272
components:
258273
securitySchemes:
259274
BearerAuth:

benches/pbs/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ fn get_mock_validator(bench: BenchConfig) -> RelayClient {
160160
enable_timing_games: false,
161161
target_first_request_ms: None,
162162
frequency_get_header_ms: None,
163+
validator_registration_batch_size: None,
163164
};
164165

165166
RelayClient::new(config).unwrap()

bin/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub mod prelude {
2020
pub use cb_metrics::provider::MetricsProvider;
2121
pub use cb_pbs::{
2222
get_header, get_status, register_validator, submit_block, BuilderApi, BuilderApiState,
23-
DefaultBuilderApi, PbsService, PbsState,
23+
DefaultBuilderApi, PbsService, PbsState, PbsStateGuard,
2424
};
2525
// The TreeHash derive macro requires tree_hash as import
2626
pub mod tree_hash {

config.example.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ target_first_request_ms = 200
9696
# Frequency in ms to send get_header requests
9797
# OPTIONAL
9898
frequency_get_header_ms = 300
99+
# Maximum number of validators to register in a single request.
100+
# OPTIONAL, DEFAULT: "" (unlimited)
101+
validator_registration_batch_size = ""
99102

100103
# Configuration for the PBS multiplexers, which enable different configs to be used for get header requests, depending on validator pubkey
101104
# Note that:

crates/common/src/commit/constants.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ pub const GET_PUBKEYS_PATH: &str = "/signer/v1/get_pubkeys";
22
pub const REQUEST_SIGNATURE_PATH: &str = "/signer/v1/request_signature";
33
pub const GENERATE_PROXY_KEY_PATH: &str = "/signer/v1/generate_proxy_key";
44
pub const STATUS_PATH: &str = "/status";
5+
pub const RELOAD_PATH: &str = "/reload";

crates/common/src/config/pbs.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,30 @@ pub struct RelayConfig {
5050
pub target_first_request_ms: Option<u64>,
5151
/// Frequency in ms to send get_header requests
5252
pub frequency_get_header_ms: Option<u64>,
53+
/// Maximum number of validators to send to relays in one registration
54+
/// request
55+
#[serde(deserialize_with = "empty_string_as_none", default)]
56+
pub validator_registration_batch_size: Option<usize>,
57+
}
58+
59+
fn empty_string_as_none<'de, D>(deserializer: D) -> Result<Option<usize>, D::Error>
60+
where
61+
D: serde::Deserializer<'de>,
62+
{
63+
#[derive(Deserialize)]
64+
#[serde(untagged)]
65+
enum Helper {
66+
Str(String),
67+
Number(usize),
68+
}
69+
70+
match Helper::deserialize(deserializer)? {
71+
Helper::Str(str) if str.is_empty() => Ok(None),
72+
Helper::Str(str) => Ok(Some(str.parse().map_err(|_| {
73+
serde::de::Error::custom("Expected empty string or number".to_string())
74+
})?)),
75+
Helper::Number(number) => Ok(Some(number)),
76+
}
5377
}
5478

5579
impl RelayConfig {

crates/common/src/pbs/constants.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub const GET_HEADER_PATH: &str = "/header/{slot}/{parent_hash}/{pubkey}";
66
pub const GET_STATUS_PATH: &str = "/status";
77
pub const REGISTER_VALIDATOR_PATH: &str = "/validators";
88
pub const SUBMIT_BLOCK_PATH: &str = "/blinded_blocks";
9+
pub const RELOAD_PATH: &str = "/reload";
910

1011
// https://ethereum.github.io/builder-specs/#/Builder
1112

crates/common/src/pbs/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub enum PbsError {
1717
#[error("json decode error: {err:?}, raw: {raw}")]
1818
JsonDecode { err: serde_json::Error, raw: String },
1919

20-
#[error("relay response error. Code: {code}, err: {error_msg}")]
20+
#[error("relay response error. Code: {code}, err: {error_msg:?}")]
2121
RelayResponse { error_msg: String, code: u16 },
2222

2323
#[error("response size exceeds max size: max: {max} raw: {raw}")]

crates/common/src/pbs/event.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ pub enum BuilderEvent {
3737
},
3838
RegisterValidatorRequest(Vec<ValidatorRegistration>),
3939
RegisterValidatorResponse,
40+
ReloadEvent,
41+
ReloadResponse,
4042
}
4143

4244
#[derive(Debug, Clone)]

crates/pbs/src/api.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ use cb_common::pbs::{
77

88
use crate::{
99
mev_boost,
10-
state::{BuilderApiState, PbsState},
10+
state::{BuilderApiState, PbsState, PbsStateGuard},
1111
};
1212

1313
#[async_trait]
1414
pub trait BuilderApi<S: BuilderApiState>: 'static {
1515
/// Use to extend the BuilderApi
16-
fn extra_routes() -> Option<Router<PbsState<S>>> {
16+
fn extra_routes() -> Option<Router<PbsStateGuard<S>>> {
1717
None
1818
}
1919

@@ -48,6 +48,10 @@ pub trait BuilderApi<S: BuilderApiState>: 'static {
4848
) -> eyre::Result<()> {
4949
mev_boost::register_validator(registrations, req_headers, state).await
5050
}
51+
52+
async fn reload(state: PbsState<S>) -> eyre::Result<PbsState<S>> {
53+
mev_boost::reload(state).await
54+
}
5155
}
5256

5357
pub struct DefaultBuilderApi;

0 commit comments

Comments
 (0)