-
Notifications
You must be signed in to change notification settings - Fork 95
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 blocklist struct #325
base: develop
Are you sure you want to change the base?
Add blocklist struct #325
Conversation
Benchmark results for
|
Date (UTC) | 2025-01-06T08:43:09+00:00 |
Commit | 81ccfc0be832d395899feaef7fe4b137958cc929 |
Base SHA | 026df71fdf2c8c6f6740682b6358d02f0e14bc09 |
Significant changes
Benchmark | Mean | Status |
---|---|---|
cloning_3000_branch_node_size_elements | -2.08% | Performance has improved. |
gather_nodes_shared_cache | 2.48% | Performance has degraded. |
gather_nodes_storage_tries | 2.22% | Performance has degraded. |
MEV-Boost SubmitBlock serialization/JSON encoding | -36.51% | Performance has improved. |
gather_nodes_empty_account | 2.74% | Performance has degraded. |
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.
Not super clear to me if the abstraction is needed, but if there is agreement it is then looks generally good!
crates/rbuilder/src/blocklist/mod.rs
Outdated
pub fn len(&self) -> usize { | ||
self.list.len() | ||
} | ||
|
||
pub fn contains(&self, address: &Address) -> bool { | ||
self.list.contains(address) | ||
} |
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.
Might want to impl
impl Deref for BlockList {
type Target = HashSet<Address>;
fn deref(&self) -> &Self::Target {
&self.list
}
}
instead of the inner methods individually
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.
Added Deref but not sure what changes I have to make to the len and contains functions.
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.
You can remove them now :)
crates/rbuilder/src/blocklist/mod.rs
Outdated
fn from(path: PathBuf) -> Self { | ||
Self::from_file(path).unwrap_or_else(|_| Self::new()) | ||
} |
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.
I would expect this type of method to return an error if the path doesn't exist instead of an empty list.
fn from(path: PathBuf) -> Self { | |
Self::from_file(path).unwrap_or_else(|_| Self::new()) | |
} | |
fn try_from(path: PathBuf) -> Result<Self, ...> { | |
Self::from_file(path).unwrap_or_else(|_| Self::new()) | |
} |
There are three benefits for this abstraction:
|
Not sure if it's needed right now, but it's done and might be useful in the future. |
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.
Do we really need DerefMut?
📝 Summary
This PR replaces raw
HashSet<Address>
usages throughout the codebase with a dedicated BlockList struct that encapsulates the blocklist functionality in a single location. The struct implements a custom deserialize operation that maintains backward compatibility: if a blocklist file exists it parses the addresses, otherwise it falls back to an empty blocklist. This behavior is fully unit tested.✅ I have completed the following steps:
make lint
make test