mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
EVMHost: Use recorded_logs from MockedHost
This commit is contained in:
parent
1718250248
commit
2683c83ad2
@ -250,23 +250,6 @@ evmc::bytes32 EVMHost::get_block_hash(int64_t _number) const noexcept
|
||||
return convertToEVMC(u256("0x3737373737373737373737373737373737373737373737373737373737373737") + _number);
|
||||
}
|
||||
|
||||
void EVMHost::emit_log(
|
||||
evmc::address const& _addr,
|
||||
uint8_t const* _data,
|
||||
size_t _dataSize,
|
||||
evmc::bytes32 const _topics[],
|
||||
size_t _topicsCount
|
||||
) noexcept
|
||||
{
|
||||
LogEntry entry;
|
||||
entry.address = convertFromEVMC(_addr);
|
||||
for (size_t i = 0; i < _topicsCount; ++i)
|
||||
entry.topics.emplace_back(convertFromEVMC(_topics[i]));
|
||||
entry.data = bytes(_data, _data + _dataSize);
|
||||
m_state.logs.emplace_back(std::move(entry));
|
||||
}
|
||||
|
||||
|
||||
Address EVMHost::convertFromEVMC(evmc::address const& _addr)
|
||||
{
|
||||
return Address(bytes(begin(_addr.bytes), end(_addr.bytes)));
|
||||
|
@ -54,19 +54,11 @@ public:
|
||||
std::map<evmc::bytes32, evmc::bytes32> storage;
|
||||
};
|
||||
|
||||
struct LogEntry
|
||||
{
|
||||
Address address;
|
||||
std::vector<h256> topics;
|
||||
bytes data;
|
||||
};
|
||||
|
||||
struct State
|
||||
{
|
||||
size_t blockNumber;
|
||||
uint64_t timestamp;
|
||||
std::map<evmc::address, Account> accounts;
|
||||
std::vector<LogEntry> logs;
|
||||
};
|
||||
|
||||
Account const* account(evmc::address const& _address) const
|
||||
@ -86,7 +78,7 @@ public:
|
||||
{
|
||||
m_state.blockNumber++;
|
||||
m_state.timestamp += 15;
|
||||
m_state.logs.clear();
|
||||
recorded_logs.clear();
|
||||
}
|
||||
|
||||
bool account_exists(evmc::address const& _addr) const noexcept final
|
||||
@ -154,14 +146,6 @@ public:
|
||||
|
||||
evmc::bytes32 get_block_hash(int64_t number) const noexcept;
|
||||
|
||||
void emit_log(
|
||||
evmc::address const& _addr,
|
||||
uint8_t const* _data,
|
||||
size_t _dataSize,
|
||||
evmc::bytes32 const _topics[],
|
||||
size_t _topicsCount
|
||||
) noexcept;
|
||||
|
||||
static Address convertFromEVMC(evmc::address const& _addr);
|
||||
static evmc::address convertToEVMC(Address const& _addr);
|
||||
static h256 convertFromEVMC(evmc::bytes32 const& _data);
|
||||
|
@ -201,27 +201,30 @@ bool ExecutionFramework::addressHasCode(Address const& _addr)
|
||||
|
||||
size_t ExecutionFramework::numLogs() const
|
||||
{
|
||||
return m_evmHost->m_state.logs.size();
|
||||
return m_evmHost->recorded_logs.size();
|
||||
}
|
||||
|
||||
size_t ExecutionFramework::numLogTopics(size_t _logIdx) const
|
||||
{
|
||||
return m_evmHost->m_state.logs.at(_logIdx).topics.size();
|
||||
return m_evmHost->recorded_logs.at(_logIdx).topics.size();
|
||||
}
|
||||
|
||||
h256 ExecutionFramework::logTopic(size_t _logIdx, size_t _topicIdx) const
|
||||
{
|
||||
return m_evmHost->m_state.logs.at(_logIdx).topics.at(_topicIdx);
|
||||
return EVMHost::convertFromEVMC(m_evmHost->recorded_logs.at(_logIdx).topics.at(_topicIdx));
|
||||
}
|
||||
|
||||
Address ExecutionFramework::logAddress(size_t _logIdx) const
|
||||
{
|
||||
return m_evmHost->m_state.logs.at(_logIdx).address;
|
||||
return EVMHost::convertFromEVMC(m_evmHost->recorded_logs.at(_logIdx).creator);
|
||||
}
|
||||
|
||||
bytes const& ExecutionFramework::logData(size_t _logIdx) const
|
||||
bytes ExecutionFramework::logData(size_t _logIdx) const
|
||||
{
|
||||
return m_evmHost->m_state.logs.at(_logIdx).data;
|
||||
const auto& data = m_evmHost->recorded_logs.at(_logIdx).data;
|
||||
// TODO: Return a copy of log data, because this is expected from REQUIRE_LOG_DATA(),
|
||||
// but reference type like string_view would be preferable.
|
||||
return {data.begin(), data.end()};
|
||||
}
|
||||
|
||||
u256 ExecutionFramework::balanceAt(Address const& _addr)
|
||||
|
@ -266,7 +266,7 @@ protected:
|
||||
size_t numLogTopics(size_t _logIdx) const;
|
||||
h256 logTopic(size_t _logIdx, size_t _topicIdx) const;
|
||||
Address logAddress(size_t _logIdx) const;
|
||||
bytes const& logData(size_t _logIdx) const;
|
||||
bytes logData(size_t _logIdx) const;
|
||||
|
||||
langutil::EVMVersion m_evmVersion;
|
||||
solidity::OptimiserSettings m_optimiserSettings = solidity::OptimiserSettings::minimal();
|
||||
|
Loading…
Reference in New Issue
Block a user