From 5901d5b99038683445d224a64c5dba11522dcec3 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Fri, 12 Jan 2024 17:09:09 +0000 Subject: [PATCH] #1750 multiple transactions --- libethereum/Block.cpp | 2 +- libhistoric/AlethStandardTrace.cpp | 18 ++++++++++-------- libhistoric/AlethStandardTrace.h | 4 +++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/libethereum/Block.cpp b/libethereum/Block.cpp index 0ce672045..9004aec53 100644 --- a/libethereum/Block.cpp +++ b/libethereum/Block.cpp @@ -819,7 +819,7 @@ ExecutionResult Block::executeHistoricCall( LastBlockHashesFace const& _lh, Tran auto resultReceipt = m_state.mutableHistoricState().execute( envInfo, *m_sealEngine, _t, skale::Permanence::Uncommitted, onOp ); HistoricState stateAfter( m_state.mutableHistoricState() ); - _tracer->finalizeTrace( resultReceipt.first, stateBefore, stateAfter ); + _tracer->finalizeAndPrintTrace( resultReceipt.first, stateBefore, stateAfter ); return resultReceipt.first; } else { auto resultReceipt = m_state.mutableHistoricState().execute( diff --git a/libhistoric/AlethStandardTrace.cpp b/libhistoric/AlethStandardTrace.cpp index 95b287895..3cc1cedfa 100644 --- a/libhistoric/AlethStandardTrace.cpp +++ b/libhistoric/AlethStandardTrace.cpp @@ -367,9 +367,9 @@ string AlethStandardTrace::toGethCompatibleCompactHexPrefixed( const u256& _valu return "0x" + hexStr; } -// execution completed. Now use the tracer that the user requested -// to print the resulting trace -void eth::AlethStandardTrace::finalizeTrace( +// execution completed. Now finalize the trace and use the tracer that the user requested +// to print the resulting trace to json +void eth::AlethStandardTrace::finalizeAndPrintTrace( ExecutionResult& _er, HistoricState& _statePre, HistoricState& _statePost ) { auto totalGasUsed = ( uint64_t ) _er.gasUsed; auto statusCode = AlethExtVM::transactionExceptionToEvmcStatusCode( _er.excepted ); @@ -379,9 +379,14 @@ void eth::AlethStandardTrace::finalizeTrace( // record return of the top function. recordFunctionReturned( statusCode, _er.output, totalGasUsed ); - + // we are done. Set the trace to finalized + STATE_CHECK( !m_isFinalized.exchange( true ) ) + // now print trace + printTrace( _er, _statePre, _statePost ); +} +void eth::AlethStandardTrace::printTrace( ExecutionResult& _er, const HistoricState& _statePre, + const HistoricState& _statePost ) { // now print the trace m_jsonTrace = Json::Value( Json::objectValue ); - // now run the trace that the user wants based on options provided if ( m_tracePrinters.count( m_options.tracerType ) > 0 ) { m_tracePrinters.at( m_options.tracerType ).print( m_jsonTrace, _er, _statePre, _statePost ); @@ -391,9 +396,6 @@ void eth::AlethStandardTrace::finalizeTrace( // this should never happen STATE_CHECK( false ); } - - // we are done. Set the trace to finalized. - STATE_CHECK( !m_isFinalized.exchange( true ) ) } // print all supported traces. This is useful for testing. diff --git a/libhistoric/AlethStandardTrace.h b/libhistoric/AlethStandardTrace.h index 0e94d85ba..0e7a834d5 100644 --- a/libhistoric/AlethStandardTrace.h +++ b/libhistoric/AlethStandardTrace.h @@ -64,7 +64,7 @@ class AlethStandardTrace { } // this function will be called at the end of executions - void finalizeTrace( ExecutionResult& _er, HistoricState& _statePre, HistoricState& _statePost ); + void finalizeAndPrintTrace( ExecutionResult& _er, HistoricState& _statePre, HistoricState& _statePost ); // this is to set original from balance for calls @@ -168,5 +168,7 @@ class AlethStandardTrace { u256 m_minerPayment; u256 m_originalFromBalance; bool m_isCall; + void printTrace( + ExecutionResult& _er, const HistoricState& _statePre, const HistoricState& _statePost ); }; } // namespace dev::eth