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>
48 enum class Kind : std::uint8_t
82 enum class Kind : std::uint8_t
95 EVM(asio::io_context & io_context, evmc_revision rev, std::filesystem::path solc_path, std::filesystem::path pt_path);
104 asio::awaitable<bool>
addAccount(
Address address, std::uint64_t initial_gas)
noexcept;
105 asio::awaitable<bool>
setGas(
Address address, std::uint64_t gas)
noexcept;
107 asio::awaitable<bool>
compile(std::filesystem::path code_path,
108 std::filesystem::path out_dir,
109 std::filesystem::path base_path = {},
110 std::filesystem::path includes = {})
const noexcept;
112 asio::awaitable<std::expected<Address, DeployError>>
deploy(
113 std::istream & code_stream,
115 std::vector<std::uint8_t> constructor_args,
116 std::uint64_t gas_limit,
117 std::uint64_t value)
noexcept;
119 asio::awaitable<std::expected<Address, DeployError>>
deploy(
120 std::filesystem::path code_path,
122 std::vector<uint8_t> constructor_args,
123 std::uint64_t gas_limit,
124 std::uint64_t value)
noexcept;
126 asio::awaitable<std::expected<std::vector<std::uint8_t>, ExecuteError>>
execute(
129 std::vector<std::uint8_t> input_bytes,
130 std::uint64_t gas_limit,
131 std::uint64_t value)
noexcept;
137 const std::filesystem::path &
getPTPath()
const;
140 asio::awaitable<bool>
loadPT();
143 asio::strand<asio::io_context::executor_type> _strand;
148 std::filesystem::path _solc_path;
149 std::filesystem::path _pt_path;
159 asio::awaitable<std::expected<std::vector<std::uint8_t>, ExecuteError>>
fetchOwner(EVM & evm,
const Address & address);
173 std::vector<std::uint8_t> encodeAsArg<std::vector<std::uint32_t>>(
const std::vector<std::uint32_t> & vec);
176 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);
187 std::vector<std::vector<std::uint32_t>>
decodeReturnedValue(
const std::vector<std::uint8_t> & bytes);
197struct std::formatter<
dcn::evm::DeployError::Kind> : std::formatter<std::string> {
221 default:
return formatter<string>::format(
"Unknown", ctx);
223 return formatter<string>::format(
"", ctx);
228struct std::formatter<
dcn::evm::ExecuteError::Kind> : std::formatter<std::string> {
234 default:
return formatter<string>::format(
"Unknown", ctx);
236 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:593
Address getRunnerAddress() const
Definition evm.cpp:404
asio::awaitable< bool > loadPT()
Definition evm.cpp:648
const std::filesystem::path & getPTPath() const
Definition evm.cpp:414
EVM & operator=(EVM &&)=delete
asio::awaitable< bool > addAccount(Address address, std::uint64_t initial_gas) noexcept
Definition evm.cpp:419
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:503
Address getRegistryAddress() const
Definition evm.cpp:399
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:455
const std::filesystem::path & getSolcPath() const
Definition evm.cpp:409
asio::awaitable< bool > setGas(Address address, std::uint64_t gas) noexcept
Definition evm.cpp:441
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:357
Definition decentralised_art.hpp:30
enum dcn::evm::DeployError::Kind kind
Kind
Definition evm.hpp:49
@ CONDITION_ARGUMENTS_MISMATCH
@ TRANSFORMATION_ARGUMENTS_MISMATCH
@ FEATURE_ALREADY_REGISTERED
@ CONDITION_ALREADY_REGISTERED
@ TRANSFORMATION_ALREADY_REGISTERED
@ PARTICLE_ALREADY_REGISTERED
@ PARTICLE_DIMENSIONS_MISMATCH
uint32_t code
Definition evm.hpp:77
evmc_bytes32 a
Definition evm.hpp:76
Kind
Definition evm.hpp:83
evmc_bytes32 a
Definition evm.hpp:89
enum dcn::evm::ExecuteError::Kind kind