mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: phase out block_to_payload_v3 (#14140)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -2903,7 +2903,9 @@ mod tests {
|
||||
use alloy_consensus::Header;
|
||||
use alloy_primitives::Bytes;
|
||||
use alloy_rlp::Decodable;
|
||||
use alloy_rpc_types_engine::{CancunPayloadFields, ExecutionPayloadSidecar};
|
||||
use alloy_rpc_types_engine::{
|
||||
CancunPayloadFields, ExecutionPayloadSidecar, ExecutionPayloadV3,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use reth_chain_state::{test_utils::TestBlockBuilder, BlockState};
|
||||
use reth_chainspec::{ChainSpec, HOLESKY, MAINNET};
|
||||
@ -2914,7 +2916,7 @@ mod tests {
|
||||
use reth_evm::test_utils::MockExecutorProvider;
|
||||
use reth_primitives_traits::Block as _;
|
||||
use reth_provider::test_utils::MockEthProvider;
|
||||
use reth_rpc_types_compat::engine::{block_to_payload_v1, payload::block_to_payload_v3};
|
||||
use reth_rpc_types_compat::engine::block_to_payload_v1;
|
||||
use reth_trie::{updates::TrieUpdates, HashedPostState};
|
||||
use std::{
|
||||
str::FromStr,
|
||||
@ -3183,7 +3185,10 @@ mod tests {
|
||||
&mut self,
|
||||
block: RecoveredBlock<reth_ethereum_primitives::Block>,
|
||||
) {
|
||||
let payload = block_to_payload_v3(block.clone_sealed_block());
|
||||
let payload = ExecutionPayloadV3::from_block_unchecked(
|
||||
block.hash(),
|
||||
&block.clone_sealed_block().into_block(),
|
||||
);
|
||||
self.tree
|
||||
.on_new_payload(
|
||||
payload.into(),
|
||||
|
||||
@ -6,12 +6,12 @@ use alloy_primitives::{Address, B256, U256};
|
||||
use alloy_rlp::Encodable;
|
||||
use alloy_rpc_types_engine::{
|
||||
ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4,
|
||||
ExecutionPayloadFieldV2, ExecutionPayloadV1, PayloadAttributes, PayloadId,
|
||||
ExecutionPayloadFieldV2, ExecutionPayloadV1, ExecutionPayloadV3, PayloadAttributes, PayloadId,
|
||||
};
|
||||
use core::convert::Infallible;
|
||||
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
|
||||
use reth_primitives::{EthPrimitives, SealedBlock};
|
||||
use reth_rpc_types_compat::engine::payload::{block_to_payload_v1, block_to_payload_v3};
|
||||
use reth_rpc_types_compat::engine::payload::block_to_payload_v1;
|
||||
|
||||
/// Contains the built payload.
|
||||
///
|
||||
@ -142,7 +142,10 @@ impl From<EthBuiltPayload> for ExecutionPayloadEnvelopeV3 {
|
||||
let EthBuiltPayload { block, fees, sidecars, .. } = value;
|
||||
|
||||
Self {
|
||||
execution_payload: block_to_payload_v3(Arc::unwrap_or_clone(block)),
|
||||
execution_payload: ExecutionPayloadV3::from_block_unchecked(
|
||||
block.hash(),
|
||||
&Arc::unwrap_or_clone(block).into_block(),
|
||||
),
|
||||
block_value: fees,
|
||||
// From the engine API spec:
|
||||
//
|
||||
|
||||
@ -6,12 +6,11 @@ use alloy_rpc_types_beacon::relay::{
|
||||
BidTrace, BuilderBlockValidationRequestV3, BuilderBlockValidationRequestV4,
|
||||
SignedBidSubmissionV3, SignedBidSubmissionV4,
|
||||
};
|
||||
use alloy_rpc_types_engine::BlobsBundleV1;
|
||||
use alloy_rpc_types_engine::{BlobsBundleV1, ExecutionPayloadV3};
|
||||
use alloy_rpc_types_eth::TransactionRequest;
|
||||
use rand::{rngs::StdRng, Rng, SeedableRng};
|
||||
use reth_chainspec::{ChainSpecBuilder, MAINNET};
|
||||
use reth_e2e_test_utils::setup_engine;
|
||||
use reth_node_core::rpc::compat::engine::payload::block_to_payload_v3;
|
||||
use reth_node_ethereum::EthereumNode;
|
||||
use reth_payload_primitives::BuiltPayload;
|
||||
use std::sync::Arc;
|
||||
@ -161,7 +160,10 @@ async fn test_flashbots_validate_v3() -> eyre::Result<()> {
|
||||
gas_limit: payload.block().gas_limit,
|
||||
..Default::default()
|
||||
},
|
||||
execution_payload: block_to_payload_v3(payload.block().clone()),
|
||||
execution_payload: ExecutionPayloadV3::from_block_unchecked(
|
||||
payload.block().hash(),
|
||||
&payload.block().clone().into_block(),
|
||||
),
|
||||
blobs_bundle: BlobsBundleV1::new([]),
|
||||
signature: Default::default(),
|
||||
},
|
||||
@ -234,7 +236,10 @@ async fn test_flashbots_validate_v4() -> eyre::Result<()> {
|
||||
gas_limit: payload.block().gas_limit,
|
||||
..Default::default()
|
||||
},
|
||||
execution_payload: block_to_payload_v3(payload.block().clone()),
|
||||
execution_payload: ExecutionPayloadV3::from_block_unchecked(
|
||||
payload.block().hash(),
|
||||
&payload.block().clone().into_block(),
|
||||
),
|
||||
blobs_bundle: BlobsBundleV1::new([]),
|
||||
execution_requests: payload.requests().unwrap().try_into().unwrap(),
|
||||
signature: Default::default(),
|
||||
|
||||
@ -7,7 +7,8 @@ use alloy_eips::{
|
||||
use alloy_primitives::{keccak256, Address, Bytes, B256, B64, U256};
|
||||
use alloy_rlp::Encodable;
|
||||
use alloy_rpc_types_engine::{
|
||||
ExecutionPayloadEnvelopeV2, ExecutionPayloadFieldV2, ExecutionPayloadV1, PayloadId,
|
||||
ExecutionPayloadEnvelopeV2, ExecutionPayloadFieldV2, ExecutionPayloadV1, ExecutionPayloadV3,
|
||||
PayloadId,
|
||||
};
|
||||
use op_alloy_consensus::{encode_holocene_extra_data, EIP1559ParamError};
|
||||
/// Re-export for use in downstream arguments.
|
||||
@ -20,7 +21,7 @@ use reth_optimism_primitives::{OpBlock, OpPrimitives, OpTransactionSigned};
|
||||
use reth_payload_builder::EthPayloadBuilderAttributes;
|
||||
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
|
||||
use reth_primitives::{transaction::WithEncoded, SealedBlock};
|
||||
use reth_rpc_types_compat::engine::payload::{block_to_payload_v1, block_to_payload_v3};
|
||||
use reth_rpc_types_compat::engine::payload::block_to_payload_v1;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Optimism Payload Builder Attributes
|
||||
@ -258,7 +259,10 @@ impl From<OpBuiltPayload> for OpExecutionPayloadEnvelopeV3 {
|
||||
B256::ZERO
|
||||
};
|
||||
Self {
|
||||
execution_payload: block_to_payload_v3(Arc::unwrap_or_clone(block)),
|
||||
execution_payload: ExecutionPayloadV3::from_block_unchecked(
|
||||
block.hash(),
|
||||
&Arc::unwrap_or_clone(block).into_block(),
|
||||
),
|
||||
block_value: fees,
|
||||
// From the engine API spec:
|
||||
//
|
||||
@ -285,7 +289,10 @@ impl From<OpBuiltPayload> for OpExecutionPayloadEnvelopeV4 {
|
||||
B256::ZERO
|
||||
};
|
||||
Self {
|
||||
execution_payload: block_to_payload_v3(Arc::unwrap_or_clone(block)),
|
||||
execution_payload: ExecutionPayloadV3::from_block_unchecked(
|
||||
block.hash(),
|
||||
&Arc::unwrap_or_clone(block).into_block(),
|
||||
),
|
||||
block_value: fees,
|
||||
// From the engine API spec:
|
||||
//
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
use alloy_eips::{eip2718::Encodable2718, eip4895::Withdrawals};
|
||||
use alloy_primitives::U256;
|
||||
use alloy_rpc_types_engine::{
|
||||
payload::ExecutionPayloadBodyV1, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3,
|
||||
payload::ExecutionPayloadBodyV1, ExecutionPayloadV1, ExecutionPayloadV2,
|
||||
};
|
||||
use reth_primitives::{Block, SealedBlock};
|
||||
use reth_primitives_traits::{BlockBody as _, SignedTransaction};
|
||||
@ -43,17 +43,6 @@ pub fn block_to_payload_v2<T: SignedTransaction>(
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts [`SealedBlock`] to [`ExecutionPayloadV3`], and returns the parent beacon block root.
|
||||
pub fn block_to_payload_v3<T: SignedTransaction>(
|
||||
value: SealedBlock<Block<T>>,
|
||||
) -> ExecutionPayloadV3 {
|
||||
ExecutionPayloadV3 {
|
||||
blob_gas_used: value.blob_gas_used.unwrap_or_default(),
|
||||
excess_blob_gas: value.excess_blob_gas.unwrap_or_default(),
|
||||
payload_inner: block_to_payload_v2(value),
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts a [`reth_primitives_traits::Block`] to [`ExecutionPayloadBodyV1`]
|
||||
pub fn convert_to_payload_body_v1(
|
||||
value: impl reth_primitives_traits::Block,
|
||||
@ -67,14 +56,12 @@ pub fn convert_to_payload_body_v1(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::block_to_payload_v3;
|
||||
use alloy_primitives::{b256, hex, Bytes, U256};
|
||||
use alloy_rpc_types_engine::{
|
||||
CancunPayloadFields, ExecutionPayload, ExecutionPayloadSidecar, ExecutionPayloadV1,
|
||||
ExecutionPayloadV2, ExecutionPayloadV3,
|
||||
};
|
||||
use reth_primitives::{Block, TransactionSigned};
|
||||
use reth_primitives_traits::Block as _;
|
||||
|
||||
#[test]
|
||||
fn roundtrip_payload_to_block() {
|
||||
@ -113,7 +100,7 @@ mod tests {
|
||||
b256!("531cd53b8e68deef0ea65edfa3cda927a846c307b0907657af34bc3f313b5871");
|
||||
block.header.parent_beacon_block_root = Some(parent_beacon_block_root);
|
||||
|
||||
let converted_payload = block_to_payload_v3(block.seal_slow());
|
||||
let converted_payload = ExecutionPayloadV3::from_block_unchecked(block.hash_slow(), &block);
|
||||
|
||||
// ensure the payloads are the same
|
||||
assert_eq!(new_payload, converted_payload);
|
||||
|
||||
Reference in New Issue
Block a user