Skip to content

Commit f06fc84

Browse files
committed
refactor: remove dead EvolveEnginePayloadBuilderAttributes type
1 parent 26b11e1 commit f06fc84

2 files changed

Lines changed: 1 addition & 154 deletions

File tree

crates/node/src/attributes.rs

Lines changed: 0 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use alloy_consensus::BlockHeader;
2-
use alloy_eips::Decodable2718;
32
use alloy_primitives::{Address, Bytes, B256};
43
use alloy_rpc_types::{
54
engine::{PayloadAttributes as RpcPayloadAttributes, PayloadId},
@@ -12,11 +11,6 @@ use reth_payload_primitives::{payload_id, PayloadAttributesBuilder};
1211
use reth_primitives_traits::SealedHeader;
1312
use serde::{Deserialize, Serialize};
1413

15-
use crate::error::EvolveEngineError;
16-
use crate::tracing_ext::RecordDurationOnDrop;
17-
use ev_primitives::TransactionSigned;
18-
use tracing::{info, instrument};
19-
2014
/// Evolve payload attributes that support passing transactions via Engine API.
2115
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
2216
pub struct EvolveEnginePayloadAttributes {
@@ -58,108 +52,6 @@ impl From<RpcPayloadAttributes> for EvolveEnginePayloadAttributes {
5852
}
5953
}
6054

61-
/// Evolve payload builder attributes.
62-
///
63-
/// In reth v2.0.0, `PayloadBuilderAttributes` was removed. This type now implements
64-
/// `PayloadAttributes` directly and stores the decoded transactions from the Engine API.
65-
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
66-
pub struct EvolveEnginePayloadBuilderAttributes {
67-
/// The inner RPC payload attributes.
68-
#[serde(flatten)]
69-
pub inner: RpcPayloadAttributes,
70-
/// Parent block hash.
71-
pub parent: B256,
72-
/// Decoded transactions from the Engine API.
73-
#[serde(skip)]
74-
pub transactions: Vec<TransactionSigned>,
75-
/// Gas limit for the payload.
76-
#[serde(rename = "gasLimit")]
77-
pub gas_limit: Option<u64>,
78-
}
79-
80-
impl EvolveEnginePayloadBuilderAttributes {
81-
/// Creates builder attributes from RPC attributes with decoded transactions.
82-
#[instrument(skip(parent, attributes), fields(
83-
parent_hash = %parent,
84-
raw_tx_count = attributes.transactions.as_ref().map_or(0, |t| t.len()),
85-
gas_limit = ?attributes.gas_limit,
86-
duration_ms = tracing::field::Empty,
87-
))]
88-
pub fn try_new(
89-
parent: B256,
90-
attributes: EvolveEnginePayloadAttributes,
91-
) -> Result<Self, EvolveEngineError> {
92-
let _duration = RecordDurationOnDrop::new();
93-
94-
// Decode transactions from bytes if provided.
95-
let transactions = attributes
96-
.transactions
97-
.unwrap_or_default()
98-
.into_iter()
99-
.map(|tx_bytes| {
100-
TransactionSigned::network_decode(&mut tx_bytes.as_ref())
101-
.map_err(|e| EvolveEngineError::InvalidTransactionData(e.to_string()))
102-
})
103-
.collect::<Result<Vec<_>, _>>()?;
104-
105-
info!(
106-
decoded_tx_count = transactions.len(),
107-
"decoded payload attributes"
108-
);
109-
110-
Ok(Self {
111-
inner: attributes.inner,
112-
parent,
113-
transactions,
114-
gas_limit: attributes.gas_limit,
115-
})
116-
}
117-
118-
/// Returns the parent block hash.
119-
pub const fn parent(&self) -> B256 {
120-
self.parent
121-
}
122-
123-
/// Returns the suggested fee recipient.
124-
pub const fn suggested_fee_recipient(&self) -> Address {
125-
self.inner.suggested_fee_recipient
126-
}
127-
128-
/// Returns the prev randao value.
129-
pub const fn prev_randao(&self) -> B256 {
130-
self.inner.prev_randao
131-
}
132-
}
133-
134-
impl PayloadAttributes for EvolveEnginePayloadBuilderAttributes {
135-
fn payload_id(&self, parent_hash: &B256) -> PayloadId {
136-
payload_id(parent_hash, &self.inner)
137-
}
138-
139-
fn timestamp(&self) -> u64 {
140-
self.inner.timestamp
141-
}
142-
143-
fn withdrawals(&self) -> Option<&Vec<Withdrawal>> {
144-
self.inner.withdrawals.as_ref()
145-
}
146-
147-
fn parent_beacon_block_root(&self) -> Option<B256> {
148-
self.inner.parent_beacon_block_root
149-
}
150-
}
151-
152-
impl From<EvolveEnginePayloadAttributes> for EvolveEnginePayloadBuilderAttributes {
153-
fn from(attrs: EvolveEnginePayloadAttributes) -> Self {
154-
Self {
155-
inner: attrs.inner,
156-
parent: B256::ZERO,
157-
transactions: Vec::new(),
158-
gas_limit: attrs.gas_limit,
159-
}
160-
}
161-
}
162-
16355
impl PayloadAttributesBuilder<EvolveEnginePayloadAttributes>
16456
for LocalPayloadAttributesBuilder<reth_ethereum::chainspec::ChainSpec>
16557
{
@@ -195,48 +87,3 @@ impl PayloadAttributesBuilder<EvolveEnginePayloadAttributes>
19587
}
19688
}
19789

198-
#[cfg(test)]
199-
mod tests {
200-
use super::*;
201-
use crate::test_utils::SpanCollector;
202-
203-
#[test]
204-
fn try_new_span_has_expected_fields() {
205-
let collector = SpanCollector::new();
206-
let _guard = collector.as_default();
207-
208-
let parent = B256::random();
209-
let attrs = EvolveEnginePayloadAttributes {
210-
inner: RpcPayloadAttributes {
211-
timestamp: 1710338136,
212-
prev_randao: B256::random(),
213-
suggested_fee_recipient: Address::random(),
214-
withdrawals: Some(vec![]),
215-
parent_beacon_block_root: Some(B256::ZERO),
216-
},
217-
transactions: Some(vec![]),
218-
gas_limit: Some(30_000_000),
219-
};
220-
221-
// we only care that the span was created with the right fields.
222-
let _ = EvolveEnginePayloadBuilderAttributes::try_new(parent, attrs);
223-
224-
let span = collector
225-
.find_span("try_new")
226-
.expect("try_new span should be recorded");
227-
228-
assert!(
229-
span.has_field("parent_hash"),
230-
"span missing parent_hash field"
231-
);
232-
assert!(
233-
span.has_field("raw_tx_count"),
234-
"span missing raw_tx_count field"
235-
);
236-
assert!(span.has_field("gas_limit"), "span missing gas_limit field");
237-
assert!(
238-
span.has_field("duration_ms"),
239-
"span missing duration_ms field"
240-
);
241-
}
242-
}

crates/node/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mod test_utils;
4141

4242
// Re-export public types for convenience.
4343
pub use args::EvolveArgs;
44-
pub use attributes::{EvolveEnginePayloadAttributes, EvolveEnginePayloadBuilderAttributes};
44+
pub use attributes::EvolveEnginePayloadAttributes;
4545
pub use builder::{create_payload_builder_service, EvolvePayloadBuilder};
4646
pub use chainspec::EvolveChainSpecParser;
4747
pub use config::{ConfigError, EvolvePayloadBuilderConfig};

0 commit comments

Comments
 (0)