From 936b0e52e7c50c018c1b5f2eef65ae8332031ce2 Mon Sep 17 00:00:00 2001 From: Vitaly Drogan Date: Mon, 13 Oct 2025 16:48:57 +0200 Subject: [PATCH 1/3] send bundle hash to block processor --- .../rbuilder-operator/src/blocks_processor.rs | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/crates/rbuilder-operator/src/blocks_processor.rs b/crates/rbuilder-operator/src/blocks_processor.rs index 39a685ba6..9bcbea1cf 100644 --- a/crates/rbuilder-operator/src/blocks_processor.rs +++ b/crates/rbuilder-operator/src/blocks_processor.rs @@ -1,4 +1,4 @@ -use alloy_primitives::{Address, BlockHash, U256}; +use alloy_primitives::{Address, BlockHash, B256, U256}; use exponential_backoff::Backoff; use jsonrpsee::core::{client::ClientT, traits::ToRpcParams}; use rbuilder::{ @@ -45,6 +45,8 @@ struct UsedBundle { #[serde_as(as = "DisplayFromStr")] total_gas_used: u64, original_bundle: RawBundle, + #[serde_as(as = "DisplayFromStr")] + bundle_hash: B256, } /// Header used by block_consumeBuiltBlockV2. Since docs are not up to date I copied RbuilderHeader from block-processor/ports/models.go (commit b341b35) @@ -166,6 +168,7 @@ impl BlocksProcessorClient { eth_send_to_coinbase: U256::ZERO, total_gas_used: res.inplace_sim.gas_used(), original_bundle: encode_bundle_for_blocks_processor(bundle.clone()), + bundle_hash: bundle.hash, }) } else { None @@ -379,6 +382,7 @@ fn backoff() -> Backoff { #[cfg(test)] mod tests { + use alloy_primitives::fixed_bytes; use uuid::Uuid; use super::*; @@ -427,4 +431,37 @@ mod tests { assert_eq!(value_str, expected_str); } + + #[test] + fn test_used_bundle_serialize() { + let value = UsedBundle { + mev_gas_price: U256::from(100), + total_eth: U256::from(200), + eth_send_to_coinbase: U256::from(300), + total_gas_used: 21000, + original_bundle: RawBundle { + version: None, + block_number: None, + txs: Vec::new(), + reverting_tx_hashes: Vec::new(), + dropping_tx_hashes: Vec::new(), + replacement_uuid: None, + uuid: None, + signing_address: None, + refund_identity: None, + min_timestamp: None, + max_timestamp: None, + replacement_nonce: None, + refund_percent: None, + refund_recipient: None, + refund_tx_hashes: None, + delayed_refund: None, + }, + bundle_hash: fixed_bytes!("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + }; + let value_str = serde_json::to_string(&value).unwrap(); + + let expected_str = r#"{"mevGasPrice":"100","totalEth":"200","ethSendToCoinbase":"300","totalGasUsed":"21000","originalBundle":{"version":null,"blockNumber":null,"txs":[],"revertingTxHashes":[],"droppingTxHashes":[]},"bundleHash":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}"#; + assert_eq!(value_str, expected_str); + } } From 0706ec0adbd1bae8322d113d7dcf5dc3dd77a3d3 Mon Sep 17 00:00:00 2001 From: Vitaly Drogan Date: Mon, 13 Oct 2025 16:49:11 +0200 Subject: [PATCH 2/3] send bundle hash to block processor --- .../rbuilder-operator/src/blocks_processor.rs | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/crates/rbuilder-operator/src/blocks_processor.rs b/crates/rbuilder-operator/src/blocks_processor.rs index 9bcbea1cf..4a138e063 100644 --- a/crates/rbuilder-operator/src/blocks_processor.rs +++ b/crates/rbuilder-operator/src/blocks_processor.rs @@ -168,7 +168,7 @@ impl BlocksProcessorClient { eth_send_to_coinbase: U256::ZERO, total_gas_used: res.inplace_sim.gas_used(), original_bundle: encode_bundle_for_blocks_processor(bundle.clone()), - bundle_hash: bundle.hash, + bundle_hash: bundle.hash, }) } else { None @@ -434,31 +434,33 @@ mod tests { #[test] fn test_used_bundle_serialize() { - let value = UsedBundle { - mev_gas_price: U256::from(100), - total_eth: U256::from(200), - eth_send_to_coinbase: U256::from(300), - total_gas_used: 21000, - original_bundle: RawBundle { - version: None, - block_number: None, - txs: Vec::new(), - reverting_tx_hashes: Vec::new(), - dropping_tx_hashes: Vec::new(), - replacement_uuid: None, - uuid: None, - signing_address: None, - refund_identity: None, - min_timestamp: None, - max_timestamp: None, - replacement_nonce: None, - refund_percent: None, - refund_recipient: None, - refund_tx_hashes: None, - delayed_refund: None, - }, - bundle_hash: fixed_bytes!("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - }; + let value = UsedBundle { + mev_gas_price: U256::from(100), + total_eth: U256::from(200), + eth_send_to_coinbase: U256::from(300), + total_gas_used: 21000, + original_bundle: RawBundle { + version: None, + block_number: None, + txs: Vec::new(), + reverting_tx_hashes: Vec::new(), + dropping_tx_hashes: Vec::new(), + replacement_uuid: None, + uuid: None, + signing_address: None, + refund_identity: None, + min_timestamp: None, + max_timestamp: None, + replacement_nonce: None, + refund_percent: None, + refund_recipient: None, + refund_tx_hashes: None, + delayed_refund: None, + }, + bundle_hash: fixed_bytes!( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ), + }; let value_str = serde_json::to_string(&value).unwrap(); let expected_str = r#"{"mevGasPrice":"100","totalEth":"200","ethSendToCoinbase":"300","totalGasUsed":"21000","originalBundle":{"version":null,"blockNumber":null,"txs":[],"revertingTxHashes":[],"droppingTxHashes":[]},"bundleHash":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}"#; From 7f7435cd3ce644b7250ae137a6552a651afa2a9b Mon Sep 17 00:00:00 2001 From: Vitaly Drogan Date: Mon, 13 Oct 2025 17:37:08 +0200 Subject: [PATCH 3/3] rebase --- .../rbuilder-operator/src/blocks_processor.rs | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/crates/rbuilder-operator/src/blocks_processor.rs b/crates/rbuilder-operator/src/blocks_processor.rs index 4a138e063..b6b9b0cf0 100644 --- a/crates/rbuilder-operator/src/blocks_processor.rs +++ b/crates/rbuilder-operator/src/blocks_processor.rs @@ -383,6 +383,7 @@ fn backoff() -> Backoff { #[cfg(test)] mod tests { use alloy_primitives::fixed_bytes; + use rbuilder_primitives::serialize::RawBundleMetadata; use uuid::Uuid; use super::*; @@ -440,22 +441,24 @@ mod tests { eth_send_to_coinbase: U256::from(300), total_gas_used: 21000, original_bundle: RawBundle { - version: None, - block_number: None, + metadata: RawBundleMetadata { + version: None, + block_number: None, + reverting_tx_hashes: Vec::new(), + dropping_tx_hashes: Vec::new(), + replacement_uuid: None, + uuid: None, + signing_address: None, + refund_identity: None, + min_timestamp: None, + max_timestamp: None, + replacement_nonce: None, + refund_percent: None, + refund_recipient: None, + refund_tx_hashes: None, + delayed_refund: None, + }, txs: Vec::new(), - reverting_tx_hashes: Vec::new(), - dropping_tx_hashes: Vec::new(), - replacement_uuid: None, - uuid: None, - signing_address: None, - refund_identity: None, - min_timestamp: None, - max_timestamp: None, - replacement_nonce: None, - refund_percent: None, - refund_recipient: None, - refund_tx_hashes: None, - delayed_refund: None, }, bundle_hash: fixed_bytes!( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" @@ -463,7 +466,7 @@ mod tests { }; let value_str = serde_json::to_string(&value).unwrap(); - let expected_str = r#"{"mevGasPrice":"100","totalEth":"200","ethSendToCoinbase":"300","totalGasUsed":"21000","originalBundle":{"version":null,"blockNumber":null,"txs":[],"revertingTxHashes":[],"droppingTxHashes":[]},"bundleHash":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}"#; + let expected_str = r#"{"mevGasPrice":"100","totalEth":"200","ethSendToCoinbase":"300","totalGasUsed":"21000","originalBundle":{"version":null,"blockNumber":null,"revertingTxHashes":[],"droppingTxHashes":[],"txs":[]},"bundleHash":"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}"#; assert_eq!(value_str, expected_str); } }