Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions config-live-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ dry_run_validation_url = "http://localhost:8545"

ignore_cancellable_orders = true

max_concurrent_seals = 4

# genesis_fork_version = "0x00112233"

sbundle_mergeable_signers = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ pub struct BiddableUnfinishedBlock {
true_block_value: U256,
}

impl Clone for BiddableUnfinishedBlock {
fn clone(&self) -> Self {
Self {
block: self.block.box_clone(),
true_block_value: self.true_block_value,
}
}
}

impl BiddableUnfinishedBlock {
pub fn new(block: Box<dyn BlockBuildingHelper>) -> Result<Self, BlockBuildingHelperError> {
let true_block_value = block.true_block_value()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct MockBlockBuildingHelper {
built_block_trace: BuiltBlockTrace,
block_building_context: BlockBuildingContext,
can_add_payout_tx: bool,
builder_name: String,
}

impl MockBlockBuildingHelper {
Expand All @@ -41,8 +42,20 @@ impl MockBlockBuildingHelper {
built_block_trace,
block_building_context: BlockBuildingContext::dummy_for_testing(),
can_add_payout_tx,
builder_name: "Mock".to_string(),
}
}

pub fn with_builder_name(self, builder_name: String) -> Self {
Self {
builder_name,
..self
}
}

pub fn built_block_trace_mut_ref(&mut self) -> &mut BuiltBlockTrace {
&mut self.built_block_trace
}
}

impl BlockBuildingHelper for MockBlockBuildingHelper {
Expand Down Expand Up @@ -114,7 +127,7 @@ impl BlockBuildingHelper for MockBlockBuildingHelper {
}

fn builder_name(&self) -> &str {
"Mock"
&self.builder_name
}
}

Expand Down
16 changes: 14 additions & 2 deletions crates/rbuilder/src/building/built_block_trace.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::{BundleErr, ExecutionError, ExecutionResult, OrderErr};
use crate::primitives::{Order, OrderId, OrderReplacementKey};
use ahash::{HashMap, HashSet};
use ahash::{AHasher, HashMap, HashSet};
use alloy_primitives::{Address, TxHash, U256};
use std::{collections::hash_map, time::Duration};
use std::{collections::hash_map, hash::Hasher, time::Duration};
use time::OffsetDateTime;

/// Structs for recording data about a built block, such as what bundles were included, and where txs came from.
Expand Down Expand Up @@ -164,4 +164,16 @@ impl BuiltBlockTrace {

Ok(())
}

/// Generates a cheap hash to identify the tx content.
pub fn transactions_hash(&self) -> u64 {
let mut hasher = AHasher::default();
for execution_result in &self.included_orders {
for tx in &execution_result.txs {
let tx_hash = tx.hash();
hasher.write(tx_hash.as_slice());
}
}
hasher.finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ struct BestBidSyncSourceInner {

impl BidValueObs for BestBidSyncSourceInner {
fn update_new_bid(&self, bid: U256) {
let mut best_bid = self.best_bid.lock();
if best_bid.map_or(true, |old_bid| old_bid < bid) {
*best_bid = Some(bid);
}
*self.best_bid.lock() = Some(bid);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod interfaces;
pub mod parallel_sealer_bid_maker;
pub mod sequential_sealer_bid_maker;
pub mod true_block_value_bidder;
pub mod wallet_balance_watcher;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use tracing::error;
use super::{
bid_value_source::interfaces::{BidValueObs, BidValueSource},
bidding::{
interfaces::{BidMaker, BiddingService, SlotBidder},
parallel_sealer_bid_maker::ParallelSealerBidMaker,
interfaces::{BiddingService, SlotBidder},
sequential_sealer_bid_maker::SequentialSealerBidMaker,
wallet_balance_watcher::WalletBalanceWatcher,
},
Expand All @@ -34,8 +33,6 @@ pub struct BlockSealingBidderFactory<P> {
/// SlotBidder are subscribed to the proper block in the bid_value_source.
competition_bid_value_source: Arc<dyn BidValueSource + Send + Sync>,
wallet_balance_watcher: WalletBalanceWatcher<P>,
/// See [ParallelSealerBidMaker]
max_concurrent_seals: usize,
}

impl<P> Debug for BlockSealingBidderFactory<P> {
Expand All @@ -47,7 +44,6 @@ impl<P> Debug for BlockSealingBidderFactory<P> {
"competition_bid_value_source",
&self.competition_bid_value_source,
)
.field("max_concurrent_seals", &self.max_concurrent_seals)
.finish()
}
}
Expand All @@ -58,14 +54,12 @@ impl<P> BlockSealingBidderFactory<P> {
block_sink_factory: Box<dyn BuilderSinkFactory>,
competition_bid_value_source: Arc<dyn BidValueSource + Send + Sync>,
wallet_balance_watcher: WalletBalanceWatcher<P>,
max_concurrent_seals: usize,
) -> Self {
Self {
bidding_service,
block_sink_factory,
competition_bid_value_source,
wallet_balance_watcher,
max_concurrent_seals,
}
}
}
Expand Down Expand Up @@ -110,18 +104,10 @@ where
self.competition_bid_value_source.clone(),
cancel.clone(),
);
let sealer: Box<dyn BidMaker + Send + Sync> = if self.max_concurrent_seals == 1 {
Box::new(SequentialSealerBidMaker::new(
Arc::from(finished_block_sink),
cancel.clone(),
))
} else {
Box::new(ParallelSealerBidMaker::new(
self.max_concurrent_seals,
Arc::from(finished_block_sink),
cancel.clone(),
))
};
let sealer = Box::new(SequentialSealerBidMaker::new(
Arc::from(finished_block_sink),
cancel.clone(),
));

let slot_bidder: Arc<dyn SlotBidder> = self.bidding_service.create_slot_bidder(
slot_data.block(),
Expand All @@ -143,12 +129,13 @@ where

/// Helper object containing the bidder.
/// It just forwards new blocks and new competitions bids (via SlotBidderToBidValueObs) to the bidder.
#[derive(Debug)]
struct BlockSealingBidder {
/// Bidder we ask how to finish the blocks.
/// Used to unsubscribe on drop.
bid_value_source_to_unsubscribe: Arc<dyn BidValueObs + Send + Sync>,
/// Used to unsubscribe on drop.
competition_bid_value_source: Arc<dyn BidValueSource + Send + Sync>,
/// We forward best block and competition bids to the bidder.
/// It will bid with the BidMaker it received on creation.
bidder: Arc<dyn SlotBidder>,
}

Expand Down Expand Up @@ -178,10 +165,9 @@ impl BlockSealingBidder {
}

impl UnfinishedBlockBuildingSink for BlockSealingBidder {
fn new_block(&self, block: BiddableUnfinishedBlock) {
self.bidder.new_block(block);
fn new_block(&self, biddable_block: BiddableUnfinishedBlock) {
self.bidder.new_block(biddable_block);
}

fn can_use_suggested_fee_recipient_as_coinbase(&self) -> bool {
self.bidder.can_use_suggested_fee_recipient_as_coinbase()
}
Expand All @@ -193,3 +179,9 @@ impl Drop for BlockSealingBidder {
.unsubscribe(self.bid_value_source_to_unsubscribe.clone());
}
}

impl Debug for BlockSealingBidder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("BlockSealingBidder").finish()
}
}
Loading
Loading