diff --git a/Cargo.lock b/Cargo.lock index 04c41732..0f2a5cd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,9 +171,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.3.1" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "499ee14d296a133d142efd215eb36bf96124829fe91cf8f5d4e5ccdd381eae00" +checksum = "f923dd5fca5f67a43d81ed3ebad0880bd41f6dd0ada930030353ac356c54cd0f" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -464,9 +464,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-beacon" -version = "0.3.1" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abbd9b6764423821bd6874477791ca68cfd0e946958d611319b57b006edf0113" +checksum = "2e7081d2206dca51ce23a06338d78d9b536931cc3f15134fc1c6535eb2b77f18" dependencies = [ "alloy-eips", "alloy-primitives 0.8.0", @@ -480,23 +480,22 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.3.1" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d79cadb52e32d40afa04847647eb50a332559d7870e66e46a0c32c33bf1c801d" +checksum = "1464c4dd646e1bdfde86ae65ce5ba168dbb29180b478011fe87117ae46b1629b" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-primitives 0.8.0", "alloy-rlp", - "alloy-rpc-types-eth", "alloy-serde", + "derive_more 1.0.0", "ethereum_ssz", "ethereum_ssz_derive", "jsonrpsee-types 0.24.3", "jsonwebtoken", "rand 0.8.5", "serde", - "thiserror", ] [[package]] @@ -4828,7 +4827,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -5664,7 +5663,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 2.0.72", diff --git a/Cargo.toml b/Cargo.toml index cf448b64..c6390ed3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,4 +74,4 @@ alloy-rpc-types-engine = { version = "0.3.0", features = [ "ssz", ] } alloy-rpc-types-eth = { version = "0.3.0" } -alloy-signer-local = { version = "0.3.0" } \ No newline at end of file +alloy-signer-local = { version = "0.3.0" } diff --git a/crates/rbuilder/src/building/mod.rs b/crates/rbuilder/src/building/mod.rs index 491e51f8..43c15123 100644 --- a/crates/rbuilder/src/building/mod.rs +++ b/crates/rbuilder/src/building/mod.rs @@ -36,7 +36,8 @@ use reth_basic_payload_builder::{commit_withdrawals, WithdrawalsOutcome}; use reth_chainspec::{ChainSpec, EthereumHardforks}; use reth_errors::ProviderError; use reth_evm::system_calls::{ - post_block_withdrawal_requests_contract_call, pre_block_beacon_root_contract_call, + post_block_consolidation_requests_contract_call, post_block_withdrawal_requests_contract_call, + pre_block_beacon_root_contract_call, pre_block_blockhashes_contract_call, }; use reth_evm_ethereum::{eip6110::parse_deposits_from_receipts, revm_spec, EthEvmConfig}; use reth_node_api::PayloadBuilderAttributes; @@ -581,18 +582,30 @@ impl PartialBlock { .chain_spec .is_prague_active_at_timestamp(ctx.attributes.timestamp()) { - let deposit_requests = - parse_deposits_from_receipts(&ctx.chain_spec, self.receipts.iter())?; + let evm_config = EthEvmConfig::default(); let mut db = state.new_db_ref(); + let deposit_requests = + parse_deposits_from_receipts(&ctx.chain_spec, self.receipts.iter())?; let withdrawal_requests = post_block_withdrawal_requests_contract_call( - &EthEvmConfig::default(), + &evm_config, + db.as_mut(), + &ctx.initialized_cfg, + &ctx.block_env, + )?; + let consolidation_requests = post_block_consolidation_requests_contract_call( + &evm_config, db.as_mut(), &ctx.initialized_cfg, &ctx.block_env, )?; - let requests = [deposit_requests, withdrawal_requests].concat(); + let requests = [ + deposit_requests, + withdrawal_requests, + consolidation_requests, + ] + .concat(); let requests_root = calculate_requests_root(&requests); (Some(requests.into()), Some(requests_root)) } else { @@ -706,15 +719,24 @@ impl PartialBlock { ctx: &BlockBuildingContext, state: &mut BlockState, ) -> eyre::Result<()> { + let evm_config = EthEvmConfig::default(); let mut db = state.new_db_ref(); pre_block_beacon_root_contract_call( db.as_mut(), - &EthEvmConfig::default(), + &evm_config, &ctx.chain_spec, &ctx.initialized_cfg, &ctx.block_env, ctx.attributes.parent_beacon_block_root(), )?; + pre_block_blockhashes_contract_call( + db.as_mut(), + &evm_config, + &ctx.chain_spec, + &ctx.initialized_cfg, + &ctx.block_env, + ctx.attributes.parent, + )?; db.as_mut().merge_transitions(BundleRetention::Reverts); Ok(()) } diff --git a/crates/rbuilder/src/mev_boost/mod.rs b/crates/rbuilder/src/mev_boost/mod.rs index 28a0d149..e968b442 100644 --- a/crates/rbuilder/src/mev_boost/mod.rs +++ b/crates/rbuilder/src/mev_boost/mod.rs @@ -6,7 +6,9 @@ pub mod sign_payload; use super::utils::u256decimal_serde_helper; use alloy_primitives::{Address, BlockHash, Bytes, U256}; -use alloy_rpc_types_beacon::relay::{BidTrace, SignedBidSubmissionV2, SignedBidSubmissionV3}; +use alloy_rpc_types_beacon::relay::{ + BidTrace, SignedBidSubmissionV2, SignedBidSubmissionV3, SignedBidSubmissionV4, +}; use flate2::{write::GzEncoder, Compression}; use primitive_types::H384; use reqwest::{ @@ -455,6 +457,7 @@ impl RelayClient { match data { SubmitBlockRequest::Capella(data) => data.0.as_ssz_bytes(), SubmitBlockRequest::Deneb(data) => data.0.as_ssz_bytes(), + SubmitBlockRequest::Electra(data) => data.0.as_ssz_bytes(), }, SSZ_CONTENT_TYPE, ) @@ -582,6 +585,9 @@ impl RelayClient { } } +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct ElectraSubmitBlockRequest(SignedBidSubmissionV4); + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct DenebSubmitBlockRequest(SignedBidSubmissionV3); @@ -599,6 +605,7 @@ pub struct CapellaSubmitBlockRequest(SignedBidSubmissionV2); pub enum SubmitBlockRequest { Capella(CapellaSubmitBlockRequest), Deneb(DenebSubmitBlockRequest), + Electra(ElectraSubmitBlockRequest), } impl SubmitBlockRequest { @@ -606,6 +613,7 @@ impl SubmitBlockRequest { match self { SubmitBlockRequest::Capella(req) => req.0.message.clone(), SubmitBlockRequest::Deneb(req) => req.0.message.clone(), + SubmitBlockRequest::Electra(req) => req.0.message.clone(), } } } diff --git a/crates/rbuilder/src/mev_boost/sign_payload.rs b/crates/rbuilder/src/mev_boost/sign_payload.rs index 313d7887..acf56dee 100644 --- a/crates/rbuilder/src/mev_boost/sign_payload.rs +++ b/crates/rbuilder/src/mev_boost/sign_payload.rs @@ -1,12 +1,15 @@ -use super::{CapellaSubmitBlockRequest, DenebSubmitBlockRequest, SubmitBlockRequest}; +use super::{ + CapellaSubmitBlockRequest, DenebSubmitBlockRequest, ElectraSubmitBlockRequest, + SubmitBlockRequest, +}; use crate::utils::u256decimal_serde_helper; use alloy_primitives::{Address, BlockHash, FixedBytes, B256, U256}; use alloy_rpc_types_beacon::{ - relay::{BidTrace, SignedBidSubmissionV2, SignedBidSubmissionV3}, + relay::{BidTrace, SignedBidSubmissionV2, SignedBidSubmissionV3, SignedBidSubmissionV4}, BlsPublicKey, }; use alloy_rpc_types_engine::{ - BlobsBundleV1, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, + BlobsBundleV1, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, ExecutionPayloadV4, }; use alloy_rpc_types_eth::Withdrawal; use ethereum_consensus::{ @@ -178,12 +181,45 @@ pub fn sign_block_for_relay( let blobs_bundle = marshal_txs_blobs_sidecars(blobs_bundle); - SubmitBlockRequest::Deneb(DenebSubmitBlockRequest(SignedBidSubmissionV3 { - message, - execution_payload, - blobs_bundle: blobs_bundle.clone(), - signature, - })) + if chain_spec.is_prague_active_at_timestamp(sealed_block.timestamp) { + let mut deposit_requests = Vec::new(); + let mut withdrawal_requests = Vec::new(); + let mut consolidation_requests = Vec::new(); + for request in sealed_block.requests.iter().flat_map(|r| &r.0) { + match request { + alloy_consensus::Request::DepositRequest(r) => { + deposit_requests.push(*r); + } + alloy_consensus::Request::WithdrawalRequest(r) => { + withdrawal_requests.push(*r); + } + alloy_consensus::Request::ConsolidationRequest(r) => { + consolidation_requests.push(*r); + } + _ => {} + }; + } + + let execution_payload = ExecutionPayloadV4 { + payload_inner: execution_payload, + deposit_requests, + withdrawal_requests, + consolidation_requests, + }; + SubmitBlockRequest::Electra(ElectraSubmitBlockRequest(SignedBidSubmissionV4 { + message, + execution_payload, + blobs_bundle, + signature, + })) + } else { + SubmitBlockRequest::Deneb(DenebSubmitBlockRequest(SignedBidSubmissionV3 { + message, + execution_payload, + blobs_bundle, + signature, + })) + } } else { let execution_payload = capella_payload; SubmitBlockRequest::Capella(CapellaSubmitBlockRequest(SignedBidSubmissionV2 { diff --git a/crates/rbuilder/src/validation_api_client.rs b/crates/rbuilder/src/validation_api_client.rs index 797fbd40..ce668db3 100644 --- a/crates/rbuilder/src/validation_api_client.rs +++ b/crates/rbuilder/src/validation_api_client.rs @@ -77,6 +77,7 @@ impl ValidationAPIClient { let method = match req { SubmitBlockRequest::Capella(_) => "flashbots_validateBuilderSubmissionV2", SubmitBlockRequest::Deneb(_) => "flashbots_validateBuilderSubmissionV3", + SubmitBlockRequest::Electra(_) => "flashbots_validateBuilderSubmissionV4", }; let request = ValidRequest { req: req.clone(),