From 67ba4c027a4f0e45e5afe42fe41c2ce01ecb0e29 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 12 Jan 2024 18:20:31 +0000 Subject: [PATCH] #1750 multiple transactions --- libhistoric/AlethStandardTrace.cpp | 7 ++++--- libhistoric/CallTracePrinter.cpp | 10 +++++++++- libhistoric/FourByteTracePrinter.cpp | 9 ++++++++- libhistoric/ReplayTracePrinter.cpp | 8 +++++++- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/libhistoric/AlethStandardTrace.cpp b/libhistoric/AlethStandardTrace.cpp index 3cc1cedfa..34c9cd5ef 100644 --- a/libhistoric/AlethStandardTrace.cpp +++ b/libhistoric/AlethStandardTrace.cpp @@ -208,7 +208,6 @@ void AlethStandardTrace::recordFunctionReturned( // the getter functions are called by printer classes after the trace has been generated const shared_ptr< FunctionCallRecord >& AlethStandardTrace::getTopFunctionCall() const { STATE_CHECK( m_isFinalized ) - STATE_CHECK( m_topFunctionCall ); return m_topFunctionCall; } @@ -374,11 +373,13 @@ void eth::AlethStandardTrace::finalizeAndPrintTrace( auto totalGasUsed = ( uint64_t ) _er.gasUsed; auto statusCode = AlethExtVM::transactionExceptionToEvmcStatusCode( _er.excepted ); - STATE_CHECK( m_topFunctionCall ) STATE_CHECK( m_topFunctionCall == m_currentlyExecutingFunctionCall ) + // if transaction is not just ETH transfer // record return of the top function. - recordFunctionReturned( statusCode, _er.output, totalGasUsed ); + if (getTopFunctionCall()) { + recordFunctionReturned( statusCode, _er.output, totalGasUsed ); + } // we are done. Set the trace to finalized STATE_CHECK( !m_isFinalized.exchange( true ) ) // now print trace diff --git a/libhistoric/CallTracePrinter.cpp b/libhistoric/CallTracePrinter.cpp index 75f436a9a..2965b2831 100644 --- a/libhistoric/CallTracePrinter.cpp +++ b/libhistoric/CallTracePrinter.cpp @@ -31,7 +31,15 @@ namespace dev::eth { void CallTracePrinter::print( Json::Value& _jsonTrace, const ExecutionResult&, const HistoricState&, const HistoricState& ) { STATE_CHECK( _jsonTrace.isObject() ) - m_trace.getTopFunctionCall()->printTrace( _jsonTrace, 0, m_trace.getOptions() ); + + auto topFunctionCallRecord = m_trace.getTopFunctionCall(); + if ( !topFunctionCallRecord ) { + // no bytecodes were executed, this was purely ETH transfer + // print nothing + return; + } + + topFunctionCallRecord->printTrace( _jsonTrace, 0, m_trace.getOptions() ); } CallTracePrinter::CallTracePrinter( AlethStandardTrace& _standardTrace ) diff --git a/libhistoric/FourByteTracePrinter.cpp b/libhistoric/FourByteTracePrinter.cpp index 165163e0e..b57dc8c03 100644 --- a/libhistoric/FourByteTracePrinter.cpp +++ b/libhistoric/FourByteTracePrinter.cpp @@ -33,7 +33,14 @@ void FourByteTracePrinter::print( STATE_CHECK( _jsonTrace.isObject() ) std::map< string, uint64_t > callMap; - m_trace.getTopFunctionCall()->collectFourByteTrace( callMap ); + auto topFunctionCallRecord = m_trace.getTopFunctionCall(); + if ( !topFunctionCallRecord ) { + // no bytecodes were executed, this was purely ETH transfer + // print nothing + return; + } + + topFunctionCallRecord->collectFourByteTrace( callMap ); for ( auto&& key : callMap ) { _jsonTrace[key.first] = key.second; } diff --git a/libhistoric/ReplayTracePrinter.cpp b/libhistoric/ReplayTracePrinter.cpp index 5d465ef56..e3fe78c94 100644 --- a/libhistoric/ReplayTracePrinter.cpp +++ b/libhistoric/ReplayTracePrinter.cpp @@ -45,7 +45,13 @@ void ReplayTracePrinter::print( Json::Value& _jsonTrace, const ExecutionResult& Json::Value functionTraceArray( Json::arrayValue ); Json::Value emptyAddress( Json::arrayValue ); - m_trace.getTopFunctionCall()->printParityFunctionTrace( functionTraceArray, emptyAddress ); + auto topFunctionCallRecord = m_trace.getTopFunctionCall(); + if ( !topFunctionCallRecord ) { + // no bytecodes were executed, this was purely ETH transfer + // print nothing + } else { + topFunctionCallRecord->printParityFunctionTrace( functionTraceArray, emptyAddress ); + } _jsonTrace["trace"] = functionTraceArray; }