Skip to content
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

feat(pbs): batch size config for validators registration #244

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ManuelBilbao
Copy link
Collaborator

@ManuelBilbao ManuelBilbao commented Jan 17, 2025

Added a new configuration validator_registration_batch_size for relays that splits the validators registration in batches.

Logs for the following setup:

1000 keys
5 relays:
    700 allowed keys to use relay-2 and relay-3
    300 allowed keys to use relay-4 and relay-5
    A default relay-1

batch sizes:
    relay-1: unlimited
    relay-2: 500
    relay-3: 400
    relay-4: 600
    relay-5: 300

stdout:

2025-01-20T11:20:31.865479Z  INFO register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}: ua="bruno-runtime/1.37.0" num_registrations=1000
2025-01-20T11:20:31.871176Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-4" retry=0}: registration successful code=200 latency=5.0075ms
2025-01-20T11:20:31.871903Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-5" retry=0}: registration successful code=200 latency=5.723209ms
2025-01-20T11:20:31.872343Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-3" retry=0}: registration successful code=200 latency=6.195667ms
2025-01-20T11:20:31.873451Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-5" retry=0}: registration successful code=200 latency=5.093ms
2025-01-20T11:20:31.873488Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-5" retry=0}: registration successful code=200 latency=7.519541ms
2025-01-20T11:20:31.873787Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-3" retry=0}: registration successful code=200 latency=7.673167ms
2025-01-20T11:20:31.874339Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-5" retry=0}: registration successful code=200 latency=8.255709ms
2025-01-20T11:20:31.874744Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-3" retry=0}: registration successful code=200 latency=8.664583ms
2025-01-20T11:20:31.874864Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-2" retry=0}: registration successful code=200 latency=8.778792ms
2025-01-20T11:20:31.874973Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-1" retry=0}: registration successful code=200 latency=9.0115ms
2025-01-20T11:20:31.875097Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-4" retry=0}: registration successful code=200 latency=6.876042ms
2025-01-20T11:20:31.875131Z DEBUG register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}:handler{relay_id="relay-2" retry=0}: registration successful code=200 latency=6.557584ms
2025-01-20T11:20:31.875308Z  INFO register_validators{req_id=163e3dc4-c94e-4114-95f4-99dbc4adbcac}: register validator successful

JSON

{"timestamp":"2025-01-20T11:20:31.865510Z","level":"INFO","fields":{"ua":"bruno-runtime/1.37.0","num_registrations":1000},"target":"cb_pbs::routes::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"}]}
{"timestamp":"2025-01-20T11:20:31.871220Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"5.0075ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-4","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.871925Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"5.723209ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-5","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.872362Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"6.195667ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-3","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.873467Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"5.093ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-5","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.873544Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"7.519541ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-5","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.873807Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"7.673167ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-3","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.874351Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"8.255709ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-5","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.874755Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"8.664583ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-3","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.874875Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"8.778792ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-2","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.874984Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"9.0115ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-1","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.875113Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"6.876042ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-4","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.875141Z","level":"DEBUG","fields":{"message":"registration successful","code":"200","latency":"6.557584ms"},"target":"cb_pbs::mev_boost::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"},{"relay_id":"relay-2","retry":0,"name":"handler"}]}
{"timestamp":"2025-01-20T11:20:31.875315Z","level":"INFO","fields":{"message":"register validator successful"},"target":"cb_pbs::routes::register_validator","spans":[{"req_id":"163e3dc4-c94e-4114-95f4-99dbc4adbcac","name":"register_validators"}]}

Close #226

@ManuelBilbao ManuelBilbao requested a review from ltitanb January 17, 2025 21:43
@ManuelBilbao ManuelBilbao marked this pull request as ready for review January 20, 2025 14:25
.in_current_span(),
));
for relay in relays.clone() {
if registrations.is_empty() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there an use case for this? i think we either avoid checking or return Ok

Comment on lines +49 to +65
for batch in registrations
.chunks(
relay.config.validator_registration_batch_size.unwrap_or(registrations.len()),
)
.map(|chunk| chunk.to_vec())
.collect::<Vec<Vec<ValidatorRegistration>>>()
{
handles.push(tokio::spawn(
send_register_validator_with_timeout(
batch,
relay.clone(),
send_headers.clone(),
state.pbs_config().timeout_register_validator_ms,
)
.in_current_span(),
));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for batch in registrations
.chunks(
relay.config.validator_registration_batch_size.unwrap_or(registrations.len()),
)
.map(|chunk| chunk.to_vec())
.collect::<Vec<Vec<ValidatorRegistration>>>()
{
handles.push(tokio::spawn(
send_register_validator_with_timeout(
batch,
relay.clone(),
send_headers.clone(),
state.pbs_config().timeout_register_validator_ms,
)
.in_current_span(),
));
}
let registrations = registrations.clone();
if let Some(batch_size) = relay.config.validator_registration_batch_size {
for batch in registrations.chunks(batch_size) {
handles.push(tokio::spawn(
send_register_validator_with_timeout(
batch.to_vec(),
relay.clone(),
send_headers.clone(),
state.pbs_config().timeout_register_validator_ms,
)
.in_current_span(),
));
}
} else {
handles.push(tokio::spawn(
send_register_validator_with_timeout(
registrations,
relay.clone(),
send_headers.clone(),
state.pbs_config().timeout_register_validator_ms,
)
.in_current_span(),
));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Add new config parameter to set batch-size for registration validators on relays
2 participants