Skip to content

Commit

Permalink
#1750 multiple transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
kladkogex committed Jan 12, 2024
1 parent 14c56e6 commit 67ba4c0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
7 changes: 4 additions & 3 deletions libhistoric/AlethStandardTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion libhistoric/CallTracePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
9 changes: 8 additions & 1 deletion libhistoric/FourByteTracePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 7 additions & 1 deletion libhistoric/ReplayTracePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 67ba4c0

Please sign in to comment.