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 22, 2024
1 parent 8f6e7b1 commit 1a06864
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 0 additions & 1 deletion libethereum/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,6 @@ Json::Value Client::traceBlock( BlockNumber _blockNumber, Json::Value const& _js
auto cachedResult = m_blockTraceCache.getIfExists( key );
if ( cachedResult.has_value() ) {
return std::any_cast< Json::Value >( cachedResult );
cerr << "match !!!" << endl;
}

for ( unsigned k = 0; k < transactions.size(); k++ ) {
Expand Down
12 changes: 10 additions & 2 deletions libhistoric/AlethStandardTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void AlethStandardTrace::analyzeInstructionAndRecordNeededInformation( uint64_t,
// record the instruction
m_lastOpRecord = OpExecutionRecord( _ext.depth, _inst, _gasRemaining, _lastOpGas );
}

void AlethStandardTrace::processFunctionCallOrReturnIfHappened(
const AlethExtVM& _ext, const LegacyVM* _vm, uint64_t _gasRemaining ) {
STATE_CHECK( !m_isFinalized )
Expand Down Expand Up @@ -150,7 +151,6 @@ vector< uint8_t > AlethStandardTrace::extractSmartContractMemoryByteArrayFromSta
return result;
}


void AlethStandardTrace::recordFunctionIsCalled( const Address& _from, const Address& _to,
uint64_t _gasLimit, const vector< uint8_t >& _inputData, const u256& _value ) {
STATE_CHECK( !m_isFinalized )
Expand Down Expand Up @@ -216,6 +216,7 @@ Json::Value AlethStandardTrace::getJSONResult() const {
STATE_CHECK( !m_jsonTrace.isNull() )
return m_jsonTrace;
}

uint64_t AlethStandardTrace::getTotalGasUsed() const {
return m_totalGasUsed;
}
Expand Down Expand Up @@ -258,6 +259,7 @@ AlethStandardTrace::AlethStandardTrace(
m_accessedAccounts.insert( m_from );
m_accessedAccounts.insert( m_to );
}

const u256& AlethStandardTrace::getGasLimit() const {
return m_gasLimit;
}
Expand Down Expand Up @@ -395,6 +397,7 @@ void eth::AlethStandardTrace::finalizeAndPrintTrace(
// 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 );
Expand Down Expand Up @@ -457,27 +460,31 @@ void AlethStandardTrace::setCurrentlyExecutingFunctionCall(
STATE_CHECK( _currentlyExecutingFunctionCall )
m_currentlyExecutingFunctionCall = _currentlyExecutingFunctionCall;
}

const Address& AlethStandardTrace::getBlockAuthor() const {
return m_blockAuthor;
}

const u256& AlethStandardTrace::getMinerPayment() const {
return m_minerPayment;
}

void AlethStandardTrace::recordMinerPayment( u256 _minerGasPayment ) {
STATE_CHECK( !m_isFinalized )
m_minerPayment = _minerGasPayment;
// add miner to the list of accessed accounts, since the miner is paid
// transaction fee
m_accessedAccounts.insert( m_blockAuthor );
}

bool AlethStandardTrace::isCall() const {
return m_isCall;
}

const u256& AlethStandardTrace::getOriginalFromBalance() const {
return m_originalFromBalance;
}


const bytes& AlethStandardTrace::getInputData() const {
return m_inputData;
}
Expand All @@ -487,6 +494,7 @@ const u256& AlethStandardTrace::getValue() const {
const Address& AlethStandardTrace::getTo() const {
return m_to;
}

const u256& AlethStandardTrace::getGasPrice() const {
return m_gasPrice;
}
Expand Down
10 changes: 6 additions & 4 deletions libhistoric/ReplayTracePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ void ReplayTracePrinter::print( Json::Value& _jsonTrace, const ExecutionResult&
Json::Value emptyAddress( Json::arrayValue );

auto topFunctionCallRecord = m_trace.getTopFunctionCall();
if ( !topFunctionCallRecord ) {
// no bytecodes were executed, this was purely ETH transfer
// print nothing
} else {


// if topFunctionCallRecord is null
// it means that no bytecodes were executed, this was purely ETH transfer
// print nothing
if ( topFunctionCallRecord ) {
topFunctionCallRecord->printParityFunctionTrace( functionTraceArray, emptyAddress );
}
_jsonTrace["trace"] = functionTraceArray;
Expand Down

0 comments on commit 1a06864

Please sign in to comment.