mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10899 from ethereum/evmhost_storage_trace
EVMHost: Add function to print storage at all addresses in the host.
This commit is contained in:
commit
ad48b71318
@ -37,6 +37,8 @@ using namespace solidity::util;
|
|||||||
using namespace solidity::test;
|
using namespace solidity::test;
|
||||||
using namespace evmc::literals;
|
using namespace evmc::literals;
|
||||||
|
|
||||||
|
using StorageMap = std::unordered_map<evmc::bytes32, evmc::storage_value>;
|
||||||
|
|
||||||
evmc::VM& EVMHost::getVM(string const& _path)
|
evmc::VM& EVMHost::getVM(string const& _path)
|
||||||
{
|
{
|
||||||
static evmc::VM NullVM{nullptr};
|
static evmc::VM NullVM{nullptr};
|
||||||
@ -754,3 +756,20 @@ evmc::result EVMHost::resultWithGas(
|
|||||||
result.output_size = _data.size();
|
result.output_size = _data.size();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EVMHost::print_all_storage(ostringstream& _os)
|
||||||
|
{
|
||||||
|
for (auto const& [addr, mockedAccount]: accounts)
|
||||||
|
{
|
||||||
|
_os << "Address: " << convertFromEVMC(addr) << endl;
|
||||||
|
for (auto const& [slot, value]: get_address_storage(addr))
|
||||||
|
if (get_storage(addr, slot))
|
||||||
|
_os << convertFromEVMC(slot) << ": " << convertFromEVMC(value.value) << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StorageMap const& EVMHost::get_address_storage(evmc::address const& _addr)
|
||||||
|
{
|
||||||
|
assertThrow(account_exists(_addr), Exception, "Account does not exist.");
|
||||||
|
return accounts[_addr].storage;
|
||||||
|
}
|
||||||
|
@ -61,6 +61,11 @@ public:
|
|||||||
tx_context.block_timestamp += 15;
|
tx_context.block_timestamp += 15;
|
||||||
recorded_logs.clear();
|
recorded_logs.clear();
|
||||||
}
|
}
|
||||||
|
/// Prints contents of storage at all addresses in host to @param _os.
|
||||||
|
void print_all_storage(std::ostringstream& _os);
|
||||||
|
|
||||||
|
/// @returns contents of storage at @param _addr.
|
||||||
|
std::unordered_map<evmc::bytes32, evmc::storage_value> const& get_address_storage(evmc::address const& _addr);
|
||||||
|
|
||||||
bool account_exists(evmc::address const& _addr) const noexcept final
|
bool account_exists(evmc::address const& _addr) const noexcept final
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user