Skip to content

Commit 8dbca52

Browse files
committed
refactor: log undecodable tx warnings and extract fee recipient helper
1 parent 9bd9ba7 commit 8dbca52

1 file changed

Lines changed: 37 additions & 25 deletions

File tree

crates/node/src/payload_service.rs

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,29 @@ where
125125
}
126126
}
127127

128+
impl<Client, Pool> EvolveEnginePayloadBuilder<Client, Pool>
129+
where
130+
Client: Clone,
131+
{
132+
/// Resolves the fee recipient: uses the suggested value from attributes, falling back
133+
/// to the configured base-fee sink when the suggested value is zero.
134+
fn resolve_fee_recipient(&self, suggested: Address, block_number: u64) -> Address {
135+
if suggested != Address::ZERO {
136+
return suggested;
137+
}
138+
if let Some(sink) = self.config.base_fee_sink_for_block(block_number) {
139+
info!(
140+
target: "ev-reth",
141+
fee_sink = ?sink,
142+
block_number,
143+
"Suggested fee recipient missing; defaulting to base-fee sink"
144+
);
145+
return sink;
146+
}
147+
suggested
148+
}
149+
}
150+
128151
impl<Client, Pool> PayloadBuilder for EvolveEnginePayloadBuilder<Client, Pool>
129152
where
130153
Client: reth_ethereum::provider::StateProviderFactory
@@ -173,18 +196,8 @@ where
173196
set_current_block_gas_limit(effective_gas_limit);
174197

175198
let block_number = parent_header.number + 1;
176-
let mut fee_recipient = attributes.inner.suggested_fee_recipient;
177-
if fee_recipient == Address::ZERO {
178-
if let Some(sink) = self.config.base_fee_sink_for_block(block_number) {
179-
info!(
180-
target: "ev-reth",
181-
fee_sink = ?sink,
182-
block_number,
183-
"Suggested fee recipient missing; defaulting to base-fee sink"
184-
);
185-
fee_recipient = sink;
186-
}
187-
}
199+
let fee_recipient =
200+
self.resolve_fee_recipient(attributes.inner.suggested_fee_recipient, block_number);
188201

189202
// In dev mode, pull pending transactions from the txpool.
190203
// In production, transactions come exclusively from Engine API attributes.
@@ -210,7 +223,16 @@ where
210223
.unwrap_or_default()
211224
.into_iter()
212225
.filter_map(|tx_bytes| {
213-
TransactionSigned::network_decode(&mut tx_bytes.as_ref()).ok()
226+
match TransactionSigned::network_decode(&mut tx_bytes.as_ref()) {
227+
Ok(tx) => Some(tx),
228+
Err(err) => {
229+
tracing::warn!(
230+
%err,
231+
"dropping undecodable transaction from payload attributes"
232+
);
233+
None
234+
}
235+
}
214236
})
215237
.collect()
216238
};
@@ -279,18 +301,8 @@ where
279301
set_current_block_gas_limit(effective_gas_limit);
280302

281303
let block_number = parent_header.number + 1;
282-
let mut fee_recipient = attributes.inner.suggested_fee_recipient;
283-
if fee_recipient == Address::ZERO {
284-
if let Some(sink) = self.config.base_fee_sink_for_block(block_number) {
285-
info!(
286-
target: "ev-reth",
287-
fee_sink = ?sink,
288-
block_number,
289-
"Suggested fee recipient missing; defaulting to base-fee sink"
290-
);
291-
fee_recipient = sink;
292-
}
293-
}
304+
let fee_recipient =
305+
self.resolve_fee_recipient(attributes.inner.suggested_fee_recipient, block_number);
294306

295307
let evolve_attrs = EvolvePayloadAttributes::new(
296308
vec![],

0 commit comments

Comments
 (0)