18#include <evmc/evmc.hpp>
19#include <evmc/mocked_host.hpp>
21#include <evmc/hex.hpp>
23#include <evmone/evmone.h>
26 #define interface __STRUCT__
31#include <spdlog/spdlog.h>
32#include <absl/container/flat_hash_map.h>
61 enum class Kind : std::uint8_t
92 enum class Kind : std::uint8_t
105 EVM(asio::io_context & io_context, evmc_revision rev, std::filesystem::path solc_path);
114 asio::awaitable<bool>
addAccount(
Address address, std::uint64_t initial_gas)
noexcept;
115 asio::awaitable<bool>
setGas(
Address address, std::uint64_t gas)
noexcept;
117 asio::awaitable<bool>
compile(std::filesystem::path code_path,
118 std::filesystem::path out_dir,
119 std::filesystem::path base_path = {},
120 std::filesystem::path includes = {})
const noexcept;
122 asio::awaitable<std::expected<Address, DeployError>>
deploy(
123 std::istream & code_stream,
125 std::vector<std::uint8_t> constructor_args,
126 std::uint64_t gas_limit,
127 std::uint64_t value)
noexcept;
129 asio::awaitable<std::expected<Address, DeployError>>
deploy(
130 std::filesystem::path code_path,
132 std::vector<uint8_t> constructor_args,
133 std::uint64_t gas_limit,
134 std::uint64_t value)
noexcept;
136 asio::awaitable<std::expected<std::vector<std::uint8_t>, ExecuteError>>
execute(
139 std::vector<std::uint8_t> input_bytes,
140 std::uint64_t gas_limit,
141 std::uint64_t value)
noexcept;
147 asio::awaitable<bool>
loadPT();
150 asio::strand<asio::io_context::executor_type> _strand;
155 std::filesystem::path _solc_path;
165 asio::awaitable<std::expected<std::vector<std::uint8_t>, ExecuteError>>
fetchOwner(EVM & evm,
const Address & address);
179 std::vector<std::uint8_t> encodeAsArg<std::vector<std::uint32_t>>(
const std::vector<std::uint32_t> & vec);
182 std::vector<std::uint8_t> encodeAsArg<std::vector<std::tuple<std::uint32_t, std::uint32_t>>>(
const std::vector<std::tuple<std::uint32_t, std::uint32_t>>& vec);
193 std::vector<std::vector<std::uint32_t>>
decodeReturnedValue(
const std::vector<std::uint8_t> & bytes);
203struct std::formatter<
dcn::evm::DeployError::Kind> : std::formatter<std::string> {
223 default:
return formatter<string>::format(
"Unknown", ctx);
225 return formatter<string>::format(
"", ctx);
230struct std::formatter<
dcn::evm::ExecuteError::Kind> : std::formatter<std::string> {
236 default:
return formatter<string>::format(
"Unknown", ctx);
238 return formatter<string>::format(
"", ctx);
asio::awaitable< std::expected< std::vector< std::uint8_t >, ExecuteError > > execute(Address sender, Address recipient, std::vector< std::uint8_t > input_bytes, std::uint64_t gas_limit, std::uint64_t value) noexcept
Definition evm.cpp:564
Address getRunnerAddress() const
Definition evm.cpp:385
asio::awaitable< bool > loadPT()
Definition evm.cpp:619
EVM & operator=(EVM &&)=delete
asio::awaitable< bool > addAccount(Address address, std::uint64_t initial_gas) noexcept
Definition evm.cpp:390
asio::awaitable< std::expected< Address, DeployError > > deploy(std::istream &code_stream, Address sender, std::vector< std::uint8_t > constructor_args, std::uint64_t gas_limit, std::uint64_t value) noexcept
Definition evm.cpp:474
Address getRegistryAddress() const
Definition evm.cpp:380
asio::awaitable< bool > compile(std::filesystem::path code_path, std::filesystem::path out_dir, std::filesystem::path base_path={}, std::filesystem::path includes={}) const noexcept
Definition evm.cpp:426
asio::awaitable< bool > setGas(Address address, std::uint64_t gas) noexcept
Definition evm.cpp:412
EVM & operator=(const EVM &)=delete
std::vector< std::uint8_t > constructSelector(std::string signature)
Definition evm.cpp:5
T decodeReturnedValue(const std::vector< std::uint8_t > &bytes)
std::vector< std::uint8_t > encodeAsArg< std::string >(const std::string &str)
Definition evm.cpp:104
std::vector< std::uint8_t > encodeAsArg< Address >(const Address &address)
Definition evm.cpp:13
std::vector< std::uint8_t > encodeAsArg(const T &val)
std::vector< std::uint8_t > encodeAsArg< std::uint32_t >(const std::uint32_t &value)
Definition evm.cpp:21
evmc::address Address
Definition evm.hpp:44
asio::awaitable< std::expected< std::vector< std::uint8_t >, ExecuteError > > fetchOwner(EVM &evm, const Address &address)
Definition evm.cpp:339
Definition decentralised_art.hpp:29
enum dcn::evm::DeployError::Kind kind
Kind
Definition evm.hpp:62
@ CONDITION_ARGUMENTS_MISMATCH
@ TRANSFORMATION_ARGUMENTS_MISMATCH
@ FEATURE_ALREADY_REGISTERED
@ CONDITION_ALREADY_REGISTERED
@ TRANSFORMATION_ALREADY_REGISTERED
uint32_t code
Definition evm.hpp:87
evmc_bytes32 a
Definition evm.hpp:86
Kind
Definition evm.hpp:93
evmc_bytes32 a
Definition evm.hpp:99
enum dcn::evm::ExecuteError::Kind kind