OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
parsec/agent/runners/evm/messages.hpp
Go to the documentation of this file.
1// Copyright (c) 2022 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_MESSAGES_H_
7#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_MESSAGES_H_
8
10#include "util/common/hash.hpp"
11
12#include <evmc/evmc.hpp>
13#include <map>
14#include <optional>
15#include <set>
16#include <vector>
17
19 // EVM Chain ID for OpenCBDC
20 static constexpr uint64_t opencbdc_chain_id = 0xcbdc;
21
23 struct evm_account {
25 evmc::uint256be m_balance{};
27 evmc::uint256be m_nonce{};
28
30 std::set<evmc::bytes32> m_modified{};
32 bool m_destruct{false};
33 };
34
36 using evm_account_code = std::vector<uint8_t>;
37
39 struct evm_sig {
40 evmc::uint256be m_r;
41 evmc::uint256be m_s;
42 evmc::uint256be m_v;
43 };
44
47 evmc::address m_address{};
48 std::vector<evmc::bytes32> m_storage_keys{};
49 auto operator==(const evm_access_tuple& rhs) const -> bool {
50 return m_address == rhs.m_address
51 && m_storage_keys == rhs.m_storage_keys;
52 };
53 };
54
56 using evm_access_list = std::vector<evm_access_tuple>;
57
59 enum class evm_tx_type : uint8_t {
60 legacy = 0,
61 access_list = 1,
62 dynamic_fee = 2
63 };
64
66 struct evm_tx {
70 std::optional<evmc::address> m_to{};
72 evmc::uint256be m_value{};
74 evmc::uint256be m_nonce{};
76 evmc::uint256be m_gas_price{};
78 evmc::uint256be m_gas_limit{};
80 evmc::uint256be m_gas_tip_cap{};
82 evmc::uint256be m_gas_fee_cap{};
84 std::vector<uint8_t> m_input{};
89 };
90
94 evmc::address m_from;
97 };
98
100 struct evm_log {
102 evmc::address m_addr{};
104 std::vector<uint8_t> m_data{};
106 std::vector<evmc::bytes32> m_topics{};
107 };
108
114 std::optional<evmc::address> m_create_address;
116 evmc::uint256be m_gas_used{};
118 std::vector<evm_log> m_logs{};
120 std::vector<uint8_t> m_output_data{};
127 uint64_t m_timestamp{};
128 // Success flag.
129 bool m_success{false};
130 };
131
141
156
171
172 // Type for account code keys.
173 struct code_key {
175 evmc::address m_addr;
176 };
177
179 struct storage_key {
181 evmc::address m_addr;
183 evmc::bytes32 m_key;
184 };
185}
186
187#endif
parsec::ticket_machine::ticket_number_type ticket_number_type
Type alias for a ticket number.
std::vector< uint8_t > evm_account_code
Type alias for EVM account code.
std::vector< evm_access_tuple > evm_access_list
Type alias for a list of storage key accesses.
std::array< unsigned char, cbdc::hash_size > hash_t
SHA256 hash container.
evmc::address m_addr
Address for the account code.
Type for tracking storage key accesses between accounts.
auto operator==(const evm_access_tuple &rhs) const -> bool
std::set< evmc::bytes32 > m_modified
Set of keys modified during contract execution.
bool m_destruct
Flag set if the account is being destructed.
interface::ticket_number_type m_ticket_number
Ticket number that emitted the logs.
std::vector< evm_log > m_logs
The logs that were emitted.
Describes the parameters of a query on EVM logs - used to transfer these parameters from the getLogs ...
std::vector< evmc::address > m_addresses
The addresses for which logs are queried.
std::vector< evmc::bytes32 > m_topics
The topics for which logs are queried.
cbdc::parsec::agent::runner::interface::ticket_number_type m_from_block
The start of the block range to query logs for.
cbdc::parsec::agent::runner::interface::ticket_number_type m_to_block
The end of the block range to query logs for.
std::vector< evmc::bytes32 > m_topics
List of log topics.
EVM pretend block is a pairing of the blocknumber (equal to the ticket number) and the transactions (...
interface::ticket_number_type m_ticket_number
Ticket number.
std::vector< evm_tx_receipt > m_transactions
Transactions executed by the ticket.
uint64_t m_timestamp
Timestamp of the transaction - needed to provide a timestamp in pretend blocks.
cbdc::parsec::agent::runner::interface::ticket_number_type m_ticket_number
Ticket number that ran this TX - needed to map to pretend blocks.
std::optional< evmc::address > m_create_address
Created contract address, if applicable.
std::vector< evm_log > m_logs
List of logs emitted during transaction.
std::vector< uint8_t > m_input
Contract input data.
evmc::uint256be m_gas_limit
Maximum gas for this transaction.
evmc::uint256be m_nonce
Nonce for from account.
evm_access_list m_access_list
List of storage key accesses.
std::optional< evmc::address > m_to
To address or std::nullopt if contract creation.