Skip to content

Conversation

dvush
Copy link
Contributor

@dvush dvush commented Sep 15, 2025

📝 Summary

Adds a new way to seal blocks to enable it set adjust_finalized_blocks = true in the config.

If set to true blocks will be processed in two steps:

  1. block is finalized (root hash, receipts root, etc) is processed
  2. finalized blocks is sent to the bidding service
  3. When bidding service responds finalized block is adjusted with correct bid value

The advantage is that bidding response becomes faster (it takes around 0.5ms on average to adjust finalized block).

In addition this PR:

  • adds blob gas to the BlockSpace structure
  • allows only transactions payment as a way to pay a proposer

💡 Motivation and Context


✅ I have completed the following steps:

  • Run make lint
  • Run make test
  • Added tests (if applicable)

@Copilot Copilot AI review requested due to automatic review settings September 15, 2025 17:53
@dvush dvush requested a review from ZanCorDX as a code owner September 15, 2025 17:53
Copy link
Contributor

@Copilot Copilot AI left a 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 implements a new bidding optimization feature called "Better bidding 2" that introduces a pipelined block finalization process to improve bidding response times. The main purpose is to enable blocks to be "prefinalized" first and then have payment transactions adjusted later, reducing the average bidding response time to around 0.5ms.

  • Adds a new configuration option adjust_finalized_blocks to enable the pipelined finalization process
  • Implements prefinalized block processing where blocks are finalized in two steps: first finalization, then bid value adjustment
  • Removes the optional coinbase payment mode and enforces transaction-based payments to validators

Reviewed Changes

Copilot reviewed 38 out of 40 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
docs/CONFIG.md Updates documentation to remove coinbase_payment configuration option
crates/rbuilder/src/utils/receipts.rs Adds support for adjusting finalized blocks with caching optimizations
crates/rbuilder/src/building/mod.rs Removes optional coinbase payments, adds blob gas to BlockSpace, implements prefinalized block adjustment
crates/rbuilder/src/live_builder/block_output/unfinished_block_processing.rs Completely refactors block processing to support prefinalized blocks with separate threads
crates/rbuilder/src/building/builders/block_building_helper.rs Adds adjust_finalized_block method and implements prefinalized state management
crates/rbuilder/src/telemetry/metrics/mod.rs Adds new metric for tracking finalize adjust time
Comments suppressed due to low confidence (2)

crates/rbuilder/src/building/mod.rs:1

  • This hardcoded fallback to U256::ONE when the block value is non-zero seems like a magic number that could cause issues. Consider using a named constant or documenting why exactly 1 wei is used as the fallback value for contract compatibility.
use crate::{

crates/rbuilder/src/building/builders/block_building_helper.rs:1

  • The magic number 2 should be better documented. Consider adding a comment explaining what these two state changes represent (payment transaction and requests processing) as mentioned in the comment above.
use alloy_primitives::{utils::format_ether, U256};

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 366 to 377
let mut i = 0;
while i < finalized_blocks.len() {
if finalized_blocks[i].block_id.0 < bid.block_id.0 {
unused_blocks.push(finalized_blocks.remove(i));
continue;
}
if finalized_blocks[i].block_id == bid.block_id {
found_block = Some(finalized_blocks[i].clone());
break;
}
i += 1;
}
Copy link
Preview

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

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

Removing elements from the middle of a Vec using remove(i) is O(n) operation and combined with the loop this becomes O(n²). Consider using a more efficient approach like retain() or collecting indices to remove and processing them in reverse order.

Copilot uses AI. Check for mistakes.

Comment on lines 352 to 354
if adjust_finalized_block != self.prefinalize_state.is_some() {
return Err(BlockBuildingHelperError::BlockFinalizedIncorrectly);
}
Copy link
Preview

Copilot AI Sep 15, 2025

Choose a reason for hiding this comment

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

The validation logic is inverted and confusing. When adjust_finalized_block is true, we expect prefinalize_state to be Some, but the condition checks if they're different. Consider renaming the error or restructuring the logic to make the expected state more clear.

Copilot uses AI. Check for mistakes.

@dvush dvush requested a review from Copilot September 18, 2025 11:39
Copy link
Contributor

@Copilot Copilot AI left a 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 33 out of 34 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

crates/rbuilder/src/building/order_commit.rs:747

  • The field name space_used in TransactionExecutionInfo is inconsistent with the old field name gas_used that was replaced. This breaks the existing API contract and could cause confusion. Consider keeping both fields for backward compatibility or updating all call sites consistently.
        space_used: BlockSpace,

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@dvush dvush merged commit 4a75a03 into develop Sep 18, 2025
3 checks passed
@dvush dvush deleted the better_bidding_2 branch September 18, 2025 12:09
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.

2 participants