mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
perf: only record return value if required (#3040)
Co-authored-by: Bjerg <onbjerg@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,8 @@ use crate::{
|
||||
eth::{
|
||||
error::{EthApiError, EthResult},
|
||||
revm_utils::{
|
||||
clone_into_empty_db, inspect, prepare_call_env, replay_transactions_until, EvmOverrides,
|
||||
clone_into_empty_db, inspect, prepare_call_env, replay_transactions_until,
|
||||
result_output, EvmOverrides,
|
||||
},
|
||||
EthTransactions, TransactionSource,
|
||||
},
|
||||
@@ -346,8 +347,8 @@ where
|
||||
let (res, _) =
|
||||
self.inner.eth_api.inspect_call_at(call, at, overrides, &mut inspector).await?;
|
||||
let gas_used = res.result.gas_used();
|
||||
|
||||
let frame = inspector.into_geth_builder().geth_traces(gas_used, config);
|
||||
let return_value = result_output(&res.result).unwrap_or_default().into();
|
||||
let frame = inspector.into_geth_builder().geth_traces(gas_used, return_value, config);
|
||||
|
||||
Ok(frame.into())
|
||||
}
|
||||
@@ -424,8 +425,8 @@ where
|
||||
|
||||
let (res, _) = inspect(db, env, &mut inspector)?;
|
||||
let gas_used = res.result.gas_used();
|
||||
|
||||
let frame = inspector.into_geth_builder().geth_traces(gas_used, config);
|
||||
let return_value = result_output(&res.result).unwrap_or_default().into();
|
||||
let frame = inspector.into_geth_builder().geth_traces(gas_used, return_value, config);
|
||||
|
||||
Ok((frame.into(), res.state))
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ use revm::{
|
||||
};
|
||||
use revm_primitives::{
|
||||
db::{DatabaseCommit, DatabaseRef},
|
||||
Bytecode,
|
||||
Bytecode, ExecutionResult,
|
||||
};
|
||||
use tracing::trace;
|
||||
|
||||
@@ -524,6 +524,18 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper to get the output data from a result
|
||||
///
|
||||
/// TODO: Can be phased out when <https://github.com/bluealloy/revm/pull/509> is released
|
||||
#[inline]
|
||||
pub(crate) fn result_output(res: &ExecutionResult) -> Option<bytes::Bytes> {
|
||||
match res {
|
||||
ExecutionResult::Success { output, .. } => Some(output.clone().into_data()),
|
||||
ExecutionResult::Revert { output, .. } => Some(output.clone()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user