Skip to content

chore: minor cleanup flashblocks logic #357

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

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

Conversation

0xKitsune
Copy link
Collaborator

This PR simplifies and cleans up components of the flashblocks service implementation:

  • Simplifies index and base validation logic in FlashblockBuilder::extend().
  • Replaces flat_map collectors with a single fold for more efficient transaction/withdrawal aggregation.
  • Deletes the unused impl From<FlashblocksError> for RpcClientError.
  • Refactors get_best_payload to return a single Result<Envelope> instead of an Option wrapper.
  • Minor consistency improvements (naming, formatting).

Copy link

vercel bot commented Jun 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
rollup-boost ⬜️ Ignored (Inspect) Jun 27, 2025 4:48pm

@0xKitsune 0xKitsune changed the title chore: cleanup flashblocks logic chore: minor cleanup flashblocks logic Jun 27, 2025
Copy link
Collaborator

@0xOsiris 0xOsiris left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -193,7 +182,7 @@ pub struct FlashblocksService {
}

impl FlashblocksService {
pub fn new(client: RpcClient, outbound_addr: SocketAddr) -> eyre::Result<Self> {
pub fn new(client: RpcClient, outbound_addr: SocketAddr) -> io::Result<Self> {
Copy link
Collaborator

@SozinM SozinM Jun 30, 2025

Choose a reason for hiding this comment

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

Why are we using io in here?
We should keep eyre (or better use anyhow)
FlashblocksService::new should not return specialized io error IMO

Copy link
Collaborator Author

@0xKitsune 0xKitsune Jun 30, 2025

Choose a reason for hiding this comment

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

I used io::Result here because the only fallible operation in FlashblocksService::new() is constructing the WebSocketPublisher which returns an io::Result. Since this is the sole error source, returning the specific error type is more explicit and avoids unnecessary dynamic error wrapping and keeps the API clear. Lmk if I am overlooking something but I do not see a downside in this case to using io::Result as it accurately reflects exactly what can fail.

With that being said I understand the argument for using eyre or anyhow for consistency or simplicity but I chose to go with the above approach to prefer being explicit. If there is a strong preference go with eyre, Im happy to adjust.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is do prefer general approach to errors, because you could always specialize later in case you really need to
I think we could ask some more people on that matter, @ferranbt @0xOsiris wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also main concern that if we add something to the new we will need to change return types.
At some point i was thinking of adding redis to keep traces ids between builder and boost. It that case i would need to change to general type again, because redis error won't cast into io (maybe it would)

// Validate the index is contiguous
if payload.index != self.flashblocks.len() as u64 {
return Err(FlashblocksError::InvalidIndex);
}

// Check base payload rules
if payload.index == 0 {
Copy link
Collaborator

@ferranbt ferranbt Jun 30, 2025

Choose a reason for hiding this comment

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

I would like to add a test for this before rewriting it to make sure the migration works as expected. I can do this today.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

4 participants