refactor(rpc): remove result_output from revm_utils (#5097)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Thomas Coratger
2023-10-19 17:46:08 +02:00
committed by GitHub
parent 78f666e62e
commit a136c33a29
2 changed files with 5 additions and 17 deletions

View File

@ -3,7 +3,7 @@ use crate::{
error::{EthApiError, EthResult}, error::{EthApiError, EthResult},
revm_utils::{ revm_utils::{
clone_into_empty_db, inspect, inspect_and_return_db, prepare_call_env, clone_into_empty_db, inspect, inspect_and_return_db, prepare_call_env,
replay_transactions_until, result_output, transact, EvmOverrides, replay_transactions_until, transact, EvmOverrides,
}, },
EthTransactions, TransactionSource, EthTransactions, TransactionSource,
}, },
@ -330,7 +330,7 @@ where
}) })
.await?; .await?;
let gas_used = res.result.gas_used(); let gas_used = res.result.gas_used();
let return_value = result_output(&res.result).unwrap_or_default(); let return_value = res.result.into_output().unwrap_or_default();
let frame = inspector.into_geth_builder().geth_traces(gas_used, return_value, config); let frame = inspector.into_geth_builder().geth_traces(gas_used, return_value, config);
Ok(frame.into()) Ok(frame.into())
@ -533,7 +533,7 @@ where
let (res, _) = inspect(db, env, &mut inspector)?; let (res, _) = inspect(db, env, &mut inspector)?;
let gas_used = res.result.gas_used(); let gas_used = res.result.gas_used();
let return_value = result_output(&res.result).unwrap_or_default(); let return_value = res.result.into_output().unwrap_or_default();
let frame = inspector.into_geth_builder().geth_traces(gas_used, return_value, config); let frame = inspector.into_geth_builder().geth_traces(gas_used, return_value, config);
Ok((frame.into(), res.state)) Ok((frame.into(), res.state))

View File

@ -2,7 +2,7 @@
use crate::eth::error::{EthApiError, EthResult, RpcInvalidTransactionError}; use crate::eth::error::{EthApiError, EthResult, RpcInvalidTransactionError};
use reth_primitives::{ use reth_primitives::{
AccessList, Address, Bytes, TransactionSigned, TransactionSignedEcRecovered, TxHash, B256, U256, AccessList, Address, TransactionSigned, TransactionSignedEcRecovered, TxHash, B256, U256,
}; };
use reth_revm::env::{fill_tx_env, fill_tx_env_with_recovered}; use reth_revm::env::{fill_tx_env, fill_tx_env_with_recovered};
use reth_rpc_types::{ use reth_rpc_types::{
@ -17,7 +17,7 @@ use revm::{
}; };
use revm_primitives::{ use revm_primitives::{
db::{DatabaseCommit, DatabaseRef}, db::{DatabaseCommit, DatabaseRef},
Bytecode, ExecutionResult, Bytecode,
}; };
use tracing::trace; use tracing::trace;
@ -580,18 +580,6 @@ 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> {
match res {
ExecutionResult::Success { output, .. } => Some(output.clone().into_data()),
ExecutionResult::Revert { output, .. } => Some(output.clone()),
_ => None,
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;