Skip to content

Commit 9a82891

Browse files
authored
2 extra fields on table blocks (#816)
## πŸ“ Summary Added tx_hashes and sent_to_relay_at. ## βœ… I have completed the following steps: * [X] Run `make lint` * [X] Run `make test` * [ ] Added tests (if applicable)
1 parent 4b172bf commit 9a82891

File tree

7 files changed

+23
-0
lines changed

7 files changed

+23
-0
lines changed

β€Žcrates/rbuilder-operator/src/clickhouse.rsβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ pub struct BlockRow {
6363
pub delayed_payment_values: Vec<U256>,
6464

6565
pub delayed_payment_addresses: Vec<String>,
66+
pub sent_to_relay_at: i64,
67+
pub tx_hashes: Vec<String>,
6668
}
6769

6870
impl ClickhouseRowExt for BlockRow {
@@ -218,6 +220,7 @@ impl BidObserver for BuiltBlocksWriter {
218220
builder_name: String,
219221
best_bid_value: U256,
220222
_relays: &RelaySet,
223+
sent_to_relay_at: OffsetDateTime,
221224
) {
222225
let slot = slot_data.slot();
223226
let block_number = slot_data.block();
@@ -254,6 +257,11 @@ impl BidObserver for BuiltBlocksWriter {
254257
.iter()
255258
.map(|address| address.to_string().to_lowercase())
256259
.collect();
260+
let tx_hashes = built_block_trace
261+
.included_orders
262+
.iter()
263+
.flat_map(|res| res.tx_infos.iter().map(|info| info.tx.hash().to_string()))
264+
.collect();
257265
let block_row = BlockRow {
258266
block_number,
259267
profit: format_ether(submit_trace.value),
@@ -285,6 +293,8 @@ impl BidObserver for BuiltBlocksWriter {
285293
delayed_payment_sources,
286294
delayed_payment_values,
287295
delayed_payment_addresses,
296+
sent_to_relay_at: offset_date_to_clickhouse_timestamp(sent_to_relay_at),
297+
tx_hashes,
288298
};
289299
if let Err(err) = blocks_tx.try_send(block_row) {
290300
error!(?err, "Failed to send block to clickhouse");

β€Žcrates/rbuilder-operator/src/flashbots_config.rsβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use rbuilder::{
3535
use rbuilder_config::EnvOrValue;
3636
use serde::Deserialize;
3737
use serde_with::serde_as;
38+
use time::OffsetDateTime;
3839
use tokio_util::sync::CancellationToken;
3940
use tracing::{error, warn};
4041
use url::Url;
@@ -454,6 +455,7 @@ impl BidObserver for RbuilderOperatorBidObserver {
454455
builder_name: String,
455456
best_bid_value: U256,
456457
relays: &RelaySet,
458+
sent_to_relay_at: OffsetDateTime,
457459
) {
458460
if let Some(p) = self.block_processor.as_ref() {
459461
p.block_submitted(
@@ -463,6 +465,7 @@ impl BidObserver for RbuilderOperatorBidObserver {
463465
builder_name.clone(),
464466
best_bid_value,
465467
relays,
468+
sent_to_relay_at,
466469
)
467470
}
468471
if let Some(p) = self.tbv_pusher.as_ref() {
@@ -473,6 +476,7 @@ impl BidObserver for RbuilderOperatorBidObserver {
473476
builder_name,
474477
best_bid_value,
475478
relays,
479+
sent_to_relay_at,
476480
)
477481
}
478482
}

β€Žcrates/rbuilder-operator/src/true_block_value_push/best_true_value_observer.rsβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rbuilder::{
99
};
1010
use redis::RedisError;
1111
use std::sync::Arc;
12+
use time::OffsetDateTime;
1213
use tokio_util::sync::CancellationToken;
1314

1415
use super::{
@@ -80,6 +81,7 @@ impl BidObserver for BestTrueValueObserver {
8081
builder_name: String,
8182
_best_bid_value: alloy_primitives::U256,
8283
_relays: &RelaySet,
84+
_sent_to_relay_at: OffsetDateTime,
8385
) {
8486
let block_info = BuiltBlockInfo::new(
8587
slot_data.block(),

β€Žcrates/rbuilder/src/building/mod.rsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ pub struct ExecutionResult {
568568
pub inplace_sim: SimValue,
569569
pub space_used: BlockSpace,
570570
pub order: Order,
571+
/// Landed txs execution info.
571572
pub tx_infos: Vec<TransactionExecutionInfo>,
572573
/// Patch to get the executed OrderIds for merged sbundles (see: [`BundleOk::original_order_ids`],[`ShareBundleMerger`] )
573574
/// Fully dropped orders (TxRevertBehavior::AllowedExcluded allows it!) are not included.

β€Žcrates/rbuilder/src/building/order_commit.rsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ pub struct DelayedKickback {
261261
pub struct BundleOk {
262262
pub space_used: BlockSpace,
263263
pub cumulative_space_used: BlockSpace,
264+
/// Landed txs execution info.
264265
pub tx_infos: Vec<TransactionExecutionInfo>,
265266
/// nonces_updates has a set of deduplicated final nonces of the txs in the order
266267
pub nonces_updated: Vec<(Address, u64)>,

β€Žcrates/rbuilder/src/live_builder/block_output/bidding_service_interface.rsβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use crate::{
2525
#[automock]
2626
pub trait BidObserver: std::fmt::Debug {
2727
/// This should NOT block since it's executed in the submitting thread.
28+
#[allow(clippy::too_many_arguments)]
2829
fn block_submitted(
2930
&self,
3031
slot_data: &MevBoostSlotData,
@@ -33,6 +34,7 @@ pub trait BidObserver: std::fmt::Debug {
3334
builder_name: String,
3435
best_bid_value: U256,
3536
relays: &RelaySet,
37+
sent_to_relay_at: OffsetDateTime,
3638
);
3739
}
3840

@@ -48,6 +50,7 @@ impl BidObserver for NullBidObserver {
4850
_builder_name: String,
4951
_best_bid_value: U256,
5052
_relays: &RelaySet,
53+
_sent_to_relay_at: OffsetDateTime,
5154
) {
5255
}
5356
}

β€Žcrates/rbuilder/src/live_builder/block_output/relay_submit.rsβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ async fn run_submit_to_relays_job(
264264
};
265265

266266
mark_submission_start_time(block.trace.orders_sealed_at);
267+
let sent_to_relay_at = OffsetDateTime::now_utc();
267268
submit_block_to_relays(
268269
request.clone(),
269270
&bid_metadata,
@@ -283,6 +284,7 @@ async fn run_submit_to_relays_job(
283284
builder_name,
284285
bid_metadata.value.top_competitor_bid.unwrap_or_default(),
285286
&relay_set,
287+
sent_to_relay_at,
286288
);
287289
});
288290
}

0 commit comments

Comments
Β (0)