-
Notifications
You must be signed in to change notification settings - Fork 179
Refactor: fix docs, clean up code quality #843
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
base: develop
Are you sure you want to change the base?
Conversation
1ea2cbd to
bc4a166
Compare
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.
Pull request overview
This PR refactors the live_builder order_input code with a focus on improving documentation, code quality, and idiomatic Rust patterns. The PR includes documentation improvements for OrderPool propagation, adding Copy trait implementations, cleaning up unnecessary clones, refactoring BlobTypeOrderFilter API from free functions to associated functions, and improving resource management with Weak pointers.
- Improved documentation for
OrderPooland related components to clarify order propagation behavior - Added
Copytrait implementations for types that support it (e.g.,ReplacementData<KeyType>,ValidBundleState,BundleReplacementState) - Refactored
BlobTypeOrderFilterAPI from free functions to idiomatic associated functions
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rbuilder/src/live_builder/order_input/orderpool.rs | Enhanced documentation for OrderPool and related structures; changed process_commands to use generic iterator; removed unnecessary .clone() calls |
| crates/rbuilder/src/live_builder/order_input/order_replacement_manager.rs | Improved documentation; added Copy trait to ValidBundleState and BundleReplacementState; removed .clone() calls in tests |
| crates/rbuilder/src/live_builder/order_input/mod.rs | Changed handles storage from Vec to FuturesUnordered for parallel reaping; updated AutoRemovingOrderPoolSubscriptionId to use Weak pointer; enhanced documentation |
| crates/rbuilder/src/live_builder/order_input/blob_type_order_filter.rs | Refactored from free functions to associated functions; added rule_name field; added trace event for filtered orders; changed filter logic |
| crates/rbuilder/src/live_builder/order_flow_tracing/order_flow_tracer.rs | Utilized new From trait implementations to remove .clone() calls; improved documentation |
| crates/rbuilder/src/live_builder/order_flow_tracing/events.rs | Added From trait implementations for ReplaceableOrderEvent |
| crates/rbuilder/src/live_builder/building/mod.rs | Updated to use new BlobTypeOrderFilter associated functions |
| crates/rbuilder-primitives/src/test_data_generator.rs | Removed unnecessary .clone() calls |
| crates/rbuilder-primitives/src/lib.rs | Added Copy impl for ReplacementData<KeyType>; removed unnecessary .clone() in replacement_key_and_sequence_number |
| crates/rbuilder-primitives/benches/ssz_proof.rs | Removed unnecessary default() calls and .clone() for unit-like structs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// Cancels are treated as highest-priority, and after that we must always | ||
| /// honor the replacement with highest `sequence_number`. | ||
| /// | ||
| /// Although all the structs and fields say "bundle" we always refer to Bundle |
Copilot
AI
Dec 30, 2025
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.
Spelling error: "reefer" should be "refer"
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.
copilot this error is fixeeed in the diff
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.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const TIME_TO_KEEP_BUNDLE_CANCELLATIONS: Duration = Duration::from_secs(60); | ||
| /// Push to pull for OrderSink. Just poll de UnboundedReceiver to get the orders. | ||
|
|
||
| /// Push to pull for OrderSink. Just poll de UnboundedReceiver to get the |
Copilot
AI
Dec 30, 2025
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.
Typo in documentation: "poll de UnboundedReceiver" should be "poll the UnboundedReceiver".
| /// Push to pull for OrderSink. Just poll de UnboundedReceiver to get the | |
| /// Push to pull for OrderSink. Just poll the UnboundedReceiver to get the |
| /// [EIP-7594]: https://eips.ethereum.org/EIPS/eip-7594 | ||
| pub const fn new_fusaka(sink: Box<dyn ReplaceableOrderSink>) -> Self { | ||
| fn fusaka(tx: &TransactionSignedEcRecoveredWithBlobs) -> bool { | ||
| tx.as_ref().is_eip4844() && tx.blobs_sidecar.is_eip7594() |
Copilot
AI
Dec 30, 2025
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.
The filter logic has changed incorrectly. The old implementation returned true for non-EIP-4844 transactions (allowing them through), but the new logic returns false for them. This will incorrectly filter out all non-blob transactions. The correct logic should be: !tx.as_ref().is_eip4844() || tx.blobs_sidecar.is_eip7594() to accept non-blob transactions OR blob transactions with EIP-7594 sidecars.
| tx.as_ref().is_eip4844() && tx.blobs_sidecar.is_eip7594() | |
| !tx.as_ref().is_eip4844() || tx.blobs_sidecar.is_eip7594() |
| /// [EIP-7594]: https://eips.ethereum.org/EIPS/eip-7594 | ||
| pub const fn new_pre_fusaka(sink: Box<dyn ReplaceableOrderSink>) -> Self { | ||
| fn pre_fusaka(tx: &TransactionSignedEcRecoveredWithBlobs) -> bool { | ||
| tx.as_ref().is_eip4844() && tx.blobs_sidecar.is_eip4844() |
Copilot
AI
Dec 30, 2025
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.
The filter logic has changed incorrectly. The old implementation returned true for non-EIP-4844 transactions (allowing them through), but the new logic returns false for them. This will incorrectly filter out all non-blob transactions. The correct logic should be: !tx.as_ref().is_eip4844() || tx.blobs_sidecar.is_eip4844() to accept non-blob transactions OR blob transactions with EIP-4844 sidecars.
| tx.as_ref().is_eip4844() && tx.blobs_sidecar.is_eip4844() | |
| !tx.as_ref().is_eip4844() || tx.blobs_sidecar.is_eip4844() |
| /// provided to remove pre-Fusaka [EIP-4844] blobs ([`Self::new_fusaka`]) or | ||
| /// post-Fusaka [EIP-7594] blobs ([`Self::new_pre_fusaka`]). | ||
| /// | ||
| /// Since it's very unlikely what we have many wrong blobs we only filter on |
Copilot
AI
Dec 30, 2025
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.
Typo in comment: "we only filter on" should be clearer. Consider: "Since it's very unlikely that we have many wrong blobs, we only filter on..."
| /// Since it's very unlikely what we have many wrong blobs we only filter on | |
| /// Since it's very unlikely that we have many wrong blobs, we only filter on |
| /// [EIP-7594]: https://eips.ethereum.org/EIPS/eip-7594 | ||
| pub const fn new_pre_fusaka(sink: Box<dyn ReplaceableOrderSink>) -> Self { | ||
| fn pre_fusaka(tx: &TransactionSignedEcRecoveredWithBlobs) -> bool { | ||
| !tx.as_ref().is_eip4844() || tx.blobs_sidecar.is_eip4844() |
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.
this logic relies on 4844 validity condition that transactions cannot have 0 blobs
See:
https://eips.ethereum.org/EIPS/eip-4844#blob-transaction:~:text=Execution%20layer%20validation,-On
| /// Don't like the fact that blobs_sidecar exists no matter if | ||
| /// [`Recovered<TransactionSigned>`] contains a non blob tx. | ||
| /// | ||
| /// Great effort was put in avoiding simple access to the internal tx so we |
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.
is this comment accurate? there is an AsRef<Recovered<TransactionSigned>> implementation that allows direct access to the internal tx
📝 Summary
No longer based on #842, which has been closed
Improves and corrects documentation in the live_builder, particularly around Order propagation through the OrderPool. Functionality does not change. Most significant API change is around
BlobTypeOrderFilter, by moving constructors from free functions to assoc functionsOrderPooldocumentationCopyimpl forReplacementData<KeyType>Copyimpl forNonceKeyBlobTypeOrderFilterconstruction idiomatic for Rusttrace!event toBlobTypeOrderFilterwhen filtering an orderrule_nametoBlobTypeOrderFilterto ensure behavior is clear in tracing eventFromimpls forReplaceableOrderEvent, and remove some relevant.cloneinvocationsAutoRemovingOrderPoolSubscriptionIdto useWeakto prevent them from holdingOrderPoolmemory alloc for dying subscriptionsFuturesUnorderedinstead ofVec<JoinHandle<()>>in the order pool to ensure parallelization of handle reaping✅ I have completed the following steps:
make lintmake test