From 77cd184a16388f02d49a80bfedede8039b27de3f Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Tue, 26 Dec 2023 19:35:01 +0000 Subject: [PATCH] #1748 fixing compatibiliti with geth prestate --- libhistoric/PrestateTracePrinter.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libhistoric/PrestateTracePrinter.cpp b/libhistoric/PrestateTracePrinter.cpp index 222bd43f7..fba41634a 100644 --- a/libhistoric/PrestateTracePrinter.cpp +++ b/libhistoric/PrestateTracePrinter.cpp @@ -122,18 +122,18 @@ void PrestateTracePrinter::printAccountPreDiff( Json::Value& _preDiffTrace, if ( m_standardTrace.isCall() && _address == m_standardTrace.getFrom() ) { // take into account that for calls balance is modified in the state before execution balance = m_standardTrace.getOriginalFromBalance(); + value["balance"] = AlethStandardTrace::toGethCompatibleCompactHexPrefixed( balance ); + } else if ( !_statePost.addressInUse( _address ) || _statePost.balance( _address ) != balance ) { + value["balance"] = AlethStandardTrace::toGethCompatibleCompactHexPrefixed( balance ); } + auto& code = _statePre.code( _address ); auto nonce = _statePre.getNonce( _address ); - if ( !_statePost.addressInUse( _address ) || _statePost.balance( _address ) != balance ) { - if ( m_standardTrace.isCall() && _address == m_standardTrace.getFrom() ) { - // geth does not print post balance for from account in calls - } else { - value["balance"] = toCompactHexPrefixed( balance ); - } - } - if ( !_statePost.addressInUse( _address ) || _statePost.getNonce( _address ) != nonce ) { + // geth does not print from nonce in calls + if ( m_standardTrace.isCall() && _address == m_standardTrace.getFrom() ) { + // take into account that for calls balance is modified in the state before execution + } else if ( !_statePost.addressInUse( _address ) || _statePost.getNonce( _address ) != nonce ) { value["nonce"] = ( uint64_t ) nonce; } if ( !_statePost.addressInUse( _address ) || _statePost.code( _address ) != code ) { @@ -195,7 +195,9 @@ void PrestateTracePrinter::printAccountPostDiff( Json::Value& _postDiffTrace, // if the new address, ot if the value changed, include in post trace - if ( !_statePre.addressInUse( _address ) || _statePre.balance( _address ) != balancePost ) { + if ( m_standardTrace.isCall() && _address == m_standardTrace.getFrom() ) { + // geth does not postbalance of from address in calls + } else if ( !_statePre.addressInUse( _address ) || _statePre.balance( _address ) != balancePost ) { value["balance"] = AlethStandardTrace::toGethCompatibleCompactHexPrefixed( balancePost ); } if ( !_statePre.addressInUse( _address ) || _statePre.getNonce( _address ) != noncePost ) { @@ -207,7 +209,6 @@ void PrestateTracePrinter::printAccountPostDiff( Json::Value& _postDiffTrace, } } - // post diffs for storage values if ( m_standardTrace.getAccessedStorageValues().find( _address ) != m_standardTrace.getAccessedStorageValues().end() ) {