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

Add option pattern for Optimistic Relay mode #323

Merged
merged 6 commits into from
Jan 3, 2025

Conversation

ferranbt
Copy link
Contributor

📝 Summary

This PR introduces a new OptimisitcConfig for the relayer with an option pattern for its fields. This replaces the current optimistic_enabled boolean to signal whether to use the subset of Optimistic configs or not.

💡 Motivation and Context


✅ I have completed the following steps:

  • Run make lint
  • Run make test
  • Added tests (if applicable)

Copy link

github-actions bot commented Dec 31, 2024

Benchmark results for df6ea7f

Report: https://flashbots-rbuilder-ci-stats.s3.us-east-2.amazonaws.com/benchmark/df6ea7f-39ac5f7/report/index.html

Date (UTC) 2025-01-03T15:22:09+00:00
Commit df6ea7f04fd03007f9effef1f8bebceef1da4bb9
Base SHA 39ac5f760f8f0fd187f224de60b15121188338cb

Significant changes

Benchmark Mean Status
gather_nodes_shared_cache -2.25% Performance has improved.
gather_nodes_account_trie 7.39% Performance has degraded.
gather_nodes_big_changes_account 11.73% Performance has degraded.
MEV-Boost SubmitBlock serialization/JSON encoding -36.62% Performance has improved.

Comment on lines 105 to 114
pub optimisitic_config: Option<OptimisticConfig>,
pub bid_observer: Box<dyn BidObserver + Send + Sync>,
}

#[derive(Debug, Clone)]
pub struct OptimisticConfig {
pub signer: BLSBlockSigner,
pub max_bid_value: U256,
pub prevalidate_optimistic_blocks: bool,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Some doc comments on what the optimistic config and its behavior would be nice.

pub optimistic_enabled: bool,
pub optimistic_signer: BLSBlockSigner,
pub optimistic_max_bid_value: U256,
pub optimistic_prevalidate_optimistic_blocks: bool,

pub optimisitic_config: Option<OptimisticConfig>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously optimistic config fields were mandatory, what's the rationale making them optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The relay optimistic functionality is optional, only enabled if optimistic_enabled is set to true. When it is set to false, those fields have default null values. That to me is kind of the same as an Option config.

if submission_optimistic {
let can_submit = if config.optimistic_prevalidate_optimistic_blocks {
if let Some(optimistic_signed_submission) = &optimistic_signed_submission {
let optimistic_config = optimistic_config.expect("optimistic config is not None");
Copy link
Contributor

Choose a reason for hiding this comment

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

expect always makes me a bit nervous. it might hold true for now, but it's not guaranteed to hold in the future.

maybe ln 257 can return Some((res, optimistic_config)), which will bring the safely unwrapped config into scope here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a nice pattern :) Fixed!

@ferranbt ferranbt merged commit 2c64632 into develop Jan 3, 2025
6 checks passed
@ferranbt ferranbt deleted the ferranbt/relay-optimistic-option-pattern branch January 3, 2025 16:00
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.

3 participants