Skip to content

feat: continuous-build mode#458

Open
julio4 wants to merge 1 commit into
mainfrom
feat/continuous-flashblock-build
Open

feat: continuous-build mode#458
julio4 wants to merge 1 commit into
mainfrom
feat/continuous-flashblock-build

Conversation

@julio4
Copy link
Copy Markdown
Member

@julio4 julio4 commented Apr 9, 2026

📝 Summary

Adds a continuous flashblock building mode (under --flashblocks.continuous-build flag) that pre-seals candidates between scheduler triggers, so the best block is ready for instant publish when the timer fires.

@julio4 julio4 force-pushed the reapply-async-payload-builder branch from d83dffd to cbe4b7a Compare April 15, 2026 06:45
@julio4 julio4 force-pushed the feat/continuous-flashblock-build branch from 895a4a2 to d45b137 Compare April 15, 2026 07:53
Base automatically changed from reapply-async-payload-builder to main April 16, 2026 10:21
Comment thread crates/op-rbuilder/src/builder/continuous.rs Outdated
Comment thread crates/op-rbuilder/src/metrics.rs
@julio4 julio4 force-pushed the feat/continuous-flashblock-build branch from d45b137 to 3435df5 Compare April 19, 2026 02:45
Comment thread crates/op-rbuilder/src/builder/payload.rs Outdated
Comment thread crates/op-rbuilder/src/builder/continuous.rs Outdated
Comment thread crates/op-rbuilder/src/builder/service.rs
Comment thread crates/op-rbuilder/src/builder/payload.rs Outdated
Comment thread crates/op-rbuilder/src/builder/continuous.rs Outdated
@avalonche
Copy link
Copy Markdown
Collaborator

did you push your changes correctly? don't see code changes for comments

@julio4 julio4 force-pushed the feat/continuous-flashblock-build branch 2 times, most recently from 932b00a to 88c1026 Compare April 27, 2026 09:44
Comment thread crates/op-rbuilder/src/builder/continuous.rs Outdated
Comment thread crates/op-rbuilder/src/builder/continuous.rs Outdated
Comment thread crates/op-rbuilder/src/builder/continuous.rs Outdated
Comment thread crates/op-rbuilder/src/builder/continuous.rs Outdated
Comment thread crates/op-rbuilder/src/builder/continuous.rs Outdated
@julio4 julio4 force-pushed the feat/continuous-flashblock-build branch 5 times, most recently from 9fc7ebc to 8a3b18e Compare May 6, 2026 10:17
Comment thread crates/op-rbuilder/src/builder/continuous/interval.rs
Comment thread crates/op-rbuilder/src/builder/continuous/shared_best.rs Outdated
Comment on lines +209 to +210
store_shared_best(shared_best, candidate.clone());
best = Some(candidate);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Why do you need to store the best candidate twice?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hum I see why it can seems slightly confusing but shared_best is the cross-thread channel so that the main building loop (outside of the continuous loop task, similar to the best_payload channel) always have access to "latest best candidate" without having to race anything on what continuous loop is doing. Because of that shared_best can be taken at any time hence why it's cloned here, and best is the local build state.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Has there been a gap between cancelling the candidate loop and it actually ending? I wonder how necessary it is to do this. It would be simpler if the candidate loop just returned the best candidate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, have you looked into using a tokio watch channel to track the best candidate? It seems like a natural fit to this problem

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

watch channel is not the best fit here as there's a single consumer once and take ownership of the result, the channel adds a lot of useless mechanisms.

Comment on lines +58 to +68
_ = deps.payload_cancel.cancelled() => {
Self::record_cancellation_reason(self.metrics(), deps.payload_cancel, deps.span);
self.record_flashblocks_metrics(
&interval.base_ctx,
&interval.base_fb_state,
&interval.base_info,
target_flashblocks,
deps.span,
);
return Ok(());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

payload_cancel is triggered when we receive the getPayload call, right? I figured we could publish the last flashblock then as well but here you're just exiting the loop. Is it not possible to do that? We would end up solving the race with ending block building and sending the last flashblock if possible

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

payload_cancel is triggered when one of these fire: getPayload received, payload deadline reached, new FCU received.

I assumed that last trigger should always arrive before getPayload, but I agree with you this would be a nice improvement to submit last flashblock here if it's not the case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

definitely, i think leveraging PayloadJobCancellation would be a good idea

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes but let's do this as a follow up

Comment thread crates/op-rbuilder/src/builder/continuous/transition.rs
Comment thread crates/op-rbuilder/src/builder/continuous/publish.rs Outdated
@julio4 julio4 force-pushed the feat/continuous-flashblock-build branch 2 times, most recently from 9c53758 to 64fa2f5 Compare May 7, 2026 10:12
@julio4 julio4 force-pushed the feat/continuous-flashblock-build branch from 64fa2f5 to e5e6711 Compare May 8, 2026 07:26
Comment on lines +90 to +92
pub(super) base_ctx: OpPayloadJobCtx,
pub(super) base_fb_state: FlashblocksState,
pub(super) base_info: ExecutionInfo,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are these fields just used for metrics? if so can you find a better way of recording those metrics instead of carrying these clones around? It's not clear otherwise why you would need to duplicate this info from BuildState

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