Skip to content

Commit

Permalink
#1751 case where no contract is called
Browse files Browse the repository at this point in the history
  • Loading branch information
kladkogex committed Jan 17, 2024
1 parent 706cd92 commit a557989
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
18 changes: 12 additions & 6 deletions libhistoric/PrestateTracePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,23 @@ void PrestateTracePrinter::printPre(

// geth always prints the balance of block miner balance

Address minerAddress = m_trace.getBlockAuthor();
u256 minerBalance = getMinerBalancePre( _statePre );

_jsonTrace[toHexPrefixed( minerAddress )]["balance"] =
AlethStandardTrace::toGethCompatibleCompactHexPrefixed( minerBalance );
}

u256 PrestateTracePrinter::getMinerBalancePre( const HistoricState& _statePre ) const {
auto minerAddress = m_trace.getBlockAuthor();
auto minerBalance = _statePre.balance( minerAddress );

if ( minerAddress == m_trace.getFrom() ) {
if ( m_trace.isCall() && minerAddress == m_trace.getFrom() ) {
// take into account that for calls balance is modified in the state before execution
minerBalance = m_trace.getOriginalFromBalance();
}

_jsonTrace[toHexPrefixed( minerAddress )]["balance"] =
AlethStandardTrace::toGethCompatibleCompactHexPrefixed( minerBalance );
std::cerr << _jsonTrace << "!!!" << std::endl;
return minerBalance;
}


Expand Down Expand Up @@ -96,11 +102,11 @@ void PrestateTracePrinter::printAllAccessedAccountPreValues( Json::Value& _jsonT
// geth does not print nonce for from address in debug_traceCall;
bool dontPrintNonce = m_trace.isCall() && _address == m_trace.getFrom();

if (!dontPrintNonce) {
if ( !dontPrintNonce ) {
auto preNonce = ( uint64_t ) _statePre.getNonce( _address );
auto postNonce = ( uint64_t ) _statePost.getNonce( _address );
// in calls nonce is always printed by geth
if (postNonce != preNonce || m_trace.isCall()) {
if ( postNonce != preNonce || m_trace.isCall() ) {
accountPreValues["nonce"] = preNonce;
}
}
Expand Down
3 changes: 3 additions & 0 deletions libhistoric/PrestateTracePrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class PrestateTracePrinter : public TracePrinter {

explicit PrestateTracePrinter( AlethStandardTrace& standardTrace );

[[nodiscard]] u256 getMinerBalancePre( const HistoricState& _statePre ) const;

private:
void printDiff( Json::Value& _jsonTrace, const ExecutionResult&, const HistoricState& _statePre,
const HistoricState& _statePost );
Expand All @@ -56,5 +58,6 @@ class PrestateTracePrinter : public TracePrinter {
uint64_t m_storageValuesReturnedAll = 0;
void printPre(
Json::Value& _jsonTrace, const HistoricState& _statePre, const HistoricState& _statePost );

};
} // namespace dev::eth

0 comments on commit a557989

Please sign in to comment.