From ac749be772b3922445952a5d67102c12df639b34 Mon Sep 17 00:00:00 2001 From: Stan Kladko <13399135+kladkogex@users.noreply.github.com> Date: Tue, 26 Dec 2023 17:27:23 +0000 Subject: [PATCH] #1748 fixing compatibiliti with geth prestate --- libhistoric/AlethStandardTrace.cpp | 3 +++ libhistoric/AlethStandardTrace.h | 1 + libhistoric/PrestateTracePrinter.cpp | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libhistoric/AlethStandardTrace.cpp b/libhistoric/AlethStandardTrace.cpp index 6f13d2b2c..4c7dfb1c1 100644 --- a/libhistoric/AlethStandardTrace.cpp +++ b/libhistoric/AlethStandardTrace.cpp @@ -127,6 +127,9 @@ void AlethStandardTrace::processFunctionCallOrReturnIfHappened( STATE_CHECK( currentDepth == m_lastOpRecord.m_depth ) } } +const Address& AlethStandardTrace::getFrom() const { + return m_from; +} vector< uint8_t > AlethStandardTrace::extractSmartContractMemoryByteArrayFromStackPointer( const LegacyVM* _vm ) { diff --git a/libhistoric/AlethStandardTrace.h b/libhistoric/AlethStandardTrace.h index ac0691075..1d9eea6bc 100644 --- a/libhistoric/AlethStandardTrace.h +++ b/libhistoric/AlethStandardTrace.h @@ -93,6 +93,7 @@ class AlethStandardTrace { static string toGethCompatibleCompactHexPrefixed( const u256& _value ); + const Address& getFrom() const; private: // this operator will be executed by skaled on each EVM instruction diff --git a/libhistoric/PrestateTracePrinter.cpp b/libhistoric/PrestateTracePrinter.cpp index 3c01b1777..72dcea77f 100644 --- a/libhistoric/PrestateTracePrinter.cpp +++ b/libhistoric/PrestateTracePrinter.cpp @@ -68,13 +68,13 @@ void PrestateTracePrinter::printAllAccessedAccountPreValues( auto balance = _statePre.balance( _address ); - if (m_standardTrace.isCall()) { + 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(); } storagePreValues["balance"] = - AlethStandardTrace::toGethCompatibleCompactHexPrefixed( _statePre.balance( _address ) ); + AlethStandardTrace::toGethCompatibleCompactHexPrefixed( balance ); storagePreValues["nonce"] = ( uint64_t ) _statePre.getNonce( _address ); bytes const& code = _statePre.code( _address );