Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Changed: [#5801](https://github.com/ethereum/aleth/pull/5801) `testeth -t BlockchainTests` command now doesn't run the tests for the forks before Istanbul. To run those tests use a separate LegacyTests suite with command `testeth -t LegacyTests/Constantinople/BlockchainTests`.
- Changed: [#5807](https://github.com/ethereum/aleth/pull/5807) Optimize selfdestruct opcode in LegacyVM by reducing state accesses in certain out-of-gas scenarios.
- Changed: [#5806](https://github.com/ethereum/aleth/pull/5806) Optimize selfdestruct opcode in aleth-interpreter by reducing state accesses in certain out-of-gas scenarios.
- Changed: [#5837](https://github.com/ethereum/aleth/pull/5837) Output format of `testeth --jsontrace` command changed to better match output of geth's evm tool and to integrate with evmlab project.
- Removed: [#5760](https://github.com/ethereum/aleth/pull/5760) Official support for Visual Studio 2015 has been dropped. Compilation with this compiler is expected to stop working after migration to C++14.
- Fixed: [#5792](https://github.com/ethereum/aleth/pull/5792) Faster and cheaper execution of RPC functions which query blockchain state (e.g. getBalance).
- Fixed: [#5811](https://github.com/ethereum/aleth/pull/5811) RPC methods querying transactions (`eth_getTransactionByHash`, `eth_getBlockByNumber`) return correct `v` value.
Expand Down
37 changes: 17 additions & 20 deletions libethereum/StandardTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,14 @@ namespace eth
{
namespace
{
bool changesMemory(Instruction _inst)
bool changesStorage(Instruction _inst)
{
return _inst == Instruction::MSTORE || _inst == Instruction::MSTORE8 ||
_inst == Instruction::MLOAD || _inst == Instruction::CREATE ||
_inst == Instruction::CALL || _inst == Instruction::CALLCODE ||
_inst == Instruction::SHA3 || _inst == Instruction::CALLDATACOPY ||
_inst == Instruction::CODECOPY || _inst == Instruction::EXTCODECOPY ||
_inst == Instruction::DELEGATECALL;
return _inst == Instruction::SSTORE;
}
} // namespace

StandardTrace::StandardTrace() : m_trace(Json::arrayValue) {}

bool changesStorage(Instruction _inst)
{
return _inst == Instruction::SSTORE;
}

void StandardTrace::operator()(uint64_t _steps, uint64_t PC, Instruction inst, bigint newMemSize,
bigint gasCost, bigint gas, VMFace const* _vm, ExtVMFace const* voidExt)
{
Expand Down Expand Up @@ -78,15 +68,21 @@ void StandardTrace::operator()(uint64_t _steps, uint64_t PC, Instruction inst, b
m_lastInst.resize(ext.depth + 1);
}

Json::Value memJson(Json::arrayValue);
if (vm && !m_options.disableMemory && (changesMemory(lastInst) || newContext))
if (vm)
{
for (unsigned i = 0; i < vm->memory().size(); i += 32)
bytes const& memory = vm->memory();

Json::Value memJson(Json::arrayValue);
if (!m_options.disableMemory)
{
bytesConstRef memRef(vm->memory().data() + i, 32);
memJson.append(toHex(memRef));
for (unsigned i = 0; i < memory.size(); i += 32)
{
bytesConstRef memRef(memory.data() + i, 32);
memJson.append(toHex(memRef));
}
r["memory"] = memJson;
}
r["memory"] = memJson;
r["memSize"] = static_cast<uint64_t>(memory.size());
}

if (!m_options.disableStorage &&
Expand All @@ -99,12 +95,13 @@ void StandardTrace::operator()(uint64_t _steps, uint64_t PC, Instruction inst, b
r["storage"] = storage;
}

r["op"] = static_cast<uint8_t>(inst);
if (m_showMnemonics)
r["op"] = instructionInfo(inst).name;
r["opName"] = instructionInfo(inst).name;
r["pc"] = toString(PC);
r["gas"] = toString(gas);
r["gasCost"] = toString(gasCost);
r["depth"] = toString(ext.depth);
r["depth"] = toString(ext.depth + 1); // depth in standard trace is 1-based
if (!!newMemSize)
r["memexpand"] = toString(newMemSize);

Expand Down
5 changes: 4 additions & 1 deletion libethereum/Transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, TransactionException cons
case TransactionException::OutOfGas: _out << "OutOfGas"; break;
case TransactionException::OutOfStack: _out << "OutOfStack"; break;
case TransactionException::StackUnderflow: _out << "StackUnderflow"; break;
default: _out << "Unknown"; break;
case TransactionException::RevertInstruction:
_out << "RevertInstruction";
break;
default: _out << "Unknown"; break;
}
return _out;
}
Expand Down
11 changes: 10 additions & 1 deletion test/tools/libtesteth/ImportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,20 @@ std::tuple<eth::State, ImportTest::ExecOutput, eth::ChangeLog> ImportTest::execu
st.setOptions(Options::get().jsontraceOptions);
out = initialState.execute(_env, *se.get(), _tr, Permanence::Committed, st.onOp());
cout << st.multilineTrace();
cout << "{\"stateRoot\": \"" << initialState.rootHash().hex() << "\"}";
}
else
out = initialState.execute(_env, *se.get(), _tr, Permanence::Uncommitted);

if (Options::get().jsontrace || !Options::get().singleTestFile.empty())
{
cout << R"({"output": ")" << toHex(out.first.output) << R"(", "gasUsed": ")"
<< out.first.gasUsed;
if (out.first.excepted != TransactionException::None)
cout << R"(", "error": ")" << out.first.excepted;
cout << "\"}\n";
cout << R"({"stateRoot": ")" << initialState.rootHash().hex() << "\"}\n";
}

// the changeLog might be broken under --jsontrace, because it uses intialState.execute with Permanence::Committed rather than Permanence::Uncommitted
eth::ChangeLog changeLog = initialState.changeLog();
ImportTest::checkBalance(_preState, initialState);
Expand Down