From b7fca832cfbae18d34ef74246d25def46549899a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ege=20Okan=20=C3=9Cnald=C4=B1?= Date: Thu, 19 Dec 2024 16:57:20 +0300 Subject: [PATCH] lint --- bin/citrea/tests/evm/tracing.rs | 2 +- crates/ethereum-rpc/src/lib.rs | 6 ++---- crates/ethereum-rpc/src/trace.rs | 29 ++++++++++++++++++++++------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/bin/citrea/tests/evm/tracing.rs b/bin/citrea/tests/evm/tracing.rs index aa1b121ca..d99b05d51 100644 --- a/bin/citrea/tests/evm/tracing.rs +++ b/bin/citrea/tests/evm/tracing.rs @@ -345,7 +345,7 @@ async fn tracing_tests() -> Result<(), Box> { _ => anyhow::bail!("Unexpected trace result"), }) .collect::, _>>()?; - + assert_eq!(traces.len(), 8); assert_eq!(traces[5], CallTracer(reth_json)); assert_eq!(traces[6], CallTracer(expected_call_get_trace)); diff --git a/crates/ethereum-rpc/src/lib.rs b/crates/ethereum-rpc/src/lib.rs index fdd175c94..f0028fcfa 100644 --- a/crates/ethereum-rpc/src/lib.rs +++ b/crates/ethereum-rpc/src/lib.rs @@ -480,11 +480,9 @@ fn register_rpc_methods( opts, )?; match &traces[0] { - TraceResult::Success { result, .. } => { - Ok(result.clone()) - } + TraceResult::Success { result, .. } => Ok(result.clone()), // this should never happen since we propagate any tracing error - TraceResult::Error { error, tx_hash: _} => { + TraceResult::Error { error, tx_hash: _ } => { Err(EthApiError::EvmCustom(error.clone()).into()) } } diff --git a/crates/ethereum-rpc/src/trace.rs b/crates/ethereum-rpc/src/trace.rs index c27706dd6..f0a0c7a44 100644 --- a/crates/ethereum-rpc/src/trace.rs +++ b/crates/ethereum-rpc/src/trace.rs @@ -237,10 +237,17 @@ fn get_traces_with_requested_tracer_and_config( } _ => { traces.into_iter().for_each(|trace| { - if let TraceResult::Success { result: GethTrace::CallTracer(call_frame), tx_hash } = trace { + if let TraceResult::Success { + result: GethTrace::CallTracer(call_frame), + tx_hash, + } = trace + { let new_call_frame = apply_call_config(call_frame.clone(), call_config); - new_traces.push(TraceResult::new_success(GethTrace::CallTracer(new_call_frame), tx_hash)); + new_traces.push(TraceResult::new_success( + GethTrace::CallTracer(new_call_frame), + tx_hash, + )); } }); } @@ -249,17 +256,25 @@ fn get_traces_with_requested_tracer_and_config( } GethDebugBuiltInTracerType::FourByteTracer => { traces.into_iter().for_each(|trace| { - if let TraceResult::Success { result: GethTrace::CallTracer(call_frame), tx_hash } = trace { + if let TraceResult::Success { + result: GethTrace::CallTracer(call_frame), + tx_hash, + } = trace + { let four_byte_frame = convert_call_trace_into_4byte_frame(vec![call_frame]); - new_traces.push(TraceResult::new_success(GethTrace::FourByteTracer(four_byte_frame), tx_hash)); + new_traces.push(TraceResult::new_success( + GethTrace::FourByteTracer(four_byte_frame), + tx_hash, + )); } }); Ok(new_traces) } - GethDebugBuiltInTracerType::NoopTracer => { - Ok(vec![TraceResult::new_success(GethTrace::NoopTracer(NoopFrame::default()), None)]) - } + GethDebugBuiltInTracerType::NoopTracer => Ok(vec![TraceResult::new_success( + GethTrace::NoopTracer(NoopFrame::default()), + None, + )]), _ => Err(EthApiError::Unsupported("This tracer is not supported")), } }