Skip to content

Feat: replace BlockCell with watch channel#397

Merged
julio4 merged 4 commits intomainfrom
feat/replace_blockcell
Mar 3, 2026
Merged

Feat: replace BlockCell with watch channel#397
julio4 merged 4 commits intomainfrom
feat/replace_blockcell

Conversation

@julio4
Copy link
Member

@julio4 julio4 commented Feb 20, 2026

📝 Summary

With #394, try_build is now an async method and we can use proper async channels and .await for flashblock timing signals.

  • Replaced BlockCell with tokio::sync::watch channel. The builder publishes its best payload to the watch channel after each completed build (fallback block + each flashblock).
  • resolve_kind can reads the latest best payload value instantly with borrow.
    • ResolvePayload resolves immediately with the pre-fetched value instead of acquiring lock/polling channel.
    • However if there's no value yet (fallback block not published), it waits on watch::Receiver::changed() until the first Some(best_payload) is published
  • deprecate build_complete field (we never poll it anywhere).

💡 Motivation and Context

The current BlockCell implementation use Mutex<Option<T>> + Notify for sharing the best payload between the builder task and engine get payload. WaitForValue::poll calls cx.waker().wake_by_ref() on every poll when no value which i think produces a waker spin loop instead of yielding back to executor and Mutex adds unnecessary resource locks (as we have only one directional PayloadBuilder publisher -> PayloadResolve consumer)

@julio4 julio4 force-pushed the feat/async_payload_builder branch from d384647 to 05d882c Compare March 3, 2026 09:35
Base automatically changed from feat/async_payload_builder to main March 3, 2026 09:47
@julio4 julio4 force-pushed the feat/replace_blockcell branch from f0b677f to 4da2ef6 Compare March 3, 2026 13:13
@julio4 julio4 force-pushed the feat/replace_blockcell branch from 4da2ef6 to b4fcd2b Compare March 3, 2026 14:12
@julio4 julio4 merged commit d95fa03 into main Mar 3, 2026
4 checks passed
@julio4 julio4 deleted the feat/replace_blockcell branch March 3, 2026 14:33
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