OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::parsec::agent::runner Namespace Reference

Data Structures

struct  code_key
 
struct  evm_access_tuple
 Type for tracking storage key accesses between accounts. More...
 
struct  evm_account
 EVM account type. More...
 
struct  evm_dryrun_tx
 Dry-run EVM transaction type. More...
 
class  evm_host
 Implementation of the evmc::Host interface using PARSEC as the backend database. More...
 
struct  evm_log
 EVM log output type. More...
 
struct  evm_log_index
 Index data for evm logs. More...
 
struct  evm_log_query
 Describes the parameters of a query on EVM logs - used to transfer these parameters from the getLogs API method to the runner. More...
 
struct  evm_pretend_block
 EVM pretend block is a pairing of the blocknumber (equal to the ticket number) and the transactions (currently always a single one) "inside the block" (executed by that ticket) More...
 
class  evm_runner
 Executes EVM transactions, implementing the runner interface. More...
 
struct  evm_sig
 EVM signature type. More...
 
struct  evm_tx
 EVM transaction type. More...
 
struct  evm_tx_receipt
 EVM transaction receipt type. More...
 
class  factory
 Runner factory for agents to intiantiate new runners of a particular type while only worrying about the runner interface. More...
 
class  interface
 Interface for a contract runner. More...
 
class  lua_runner
 Lua function executor. More...
 
struct  storage_key
 Type for account storage keys. More...
 

Typedefs

using evm_account_code = std::vector<uint8_t>
 Type alias for EVM account code.
 
using evm_access_list = std::vector<evm_access_tuple>
 Type alias for a list of storage key accesses.
 

Enumerations

enum class  evm_runner_function : uint8_t {
  execute_transaction , read_account , dryrun_transaction , read_account_code ,
  get_transaction , get_transaction_receipt , get_block_number , get_block ,
  get_logs , read_account_storage
}
 Commands accepted by the EVM contract runner. More...
 
enum class  evm_tx_type : uint8_t { legacy = 0 , access_list = 1 , dynamic_fee = 2 }
  EVM transaction types. More...
 

Functions

auto contract_address (const evmc::address &sender, const evmc::uint256be &nonce) -> evmc::address
 Calculates a contract address for the CREATE call keccak256(rlp([sender,nonce]))
 
auto contract_address2 (const evmc::address &sender, const evmc::bytes32 &salt, const cbdc::hash_t &bytecode_hash) -> evmc::address
 Calculates a contract address for the CREATE2 call keccak256(0xFF | sender | salt | keccak256(bytecode))
 
auto eth_addr (const std::unique_ptr< secp256k1_pubkey > &pk, const std::shared_ptr< secp256k1_context > &ctx) -> evmc::address
 Calculates an eth address from a public key.
 
auto eth_addr (const cbdc::privkey_t &key, const std::shared_ptr< secp256k1_context > &ctx) -> evmc::address
 Calculates an eth address from a private key.
 
auto operator+ (const evmc::uint256be &lhs, const evmc::uint256be &rhs) -> evmc::uint256be
 Adds two uint256be values.
 
auto operator- (const evmc::uint256be &lhs, const evmc::uint256be &rhs) -> evmc::uint256be
 Subtracts two uint256be values.
 
auto operator* (const evmc::uint256be &lhs, const evmc::uint256be &rhs) -> evmc::uint256be
 Multiplies two uint256be values.
 
auto operator<< (const evmc::uint256be &lhs, size_t count) -> evmc::uint256be
 Left shifts a uint256be value by a given number of bytes.
 
auto tx_id (const cbdc::parsec::agent::runner::evm_tx &tx, uint64_t chain_id=opencbdc_chain_id) -> cbdc::hash_t
 Calculate ethereum-compatible txid.
 
auto is_valid_rlp_tx (evm_tx_type type, const rlp_value &rlp_tx) -> bool
 
auto check_tx_decode (const cbdc::buffer &buf, const std::shared_ptr< logging::log > &logger, const std::shared_ptr< cbdc::parsec::agent::runner::evm_tx > &tx) -> std::optional< rlp_value >
 
auto tx_decode (const cbdc::buffer &buf, const std::shared_ptr< logging::log > &logger, uint64_t chain_id=opencbdc_chain_id) -> std::optional< std::shared_ptr< cbdc::parsec::agent::runner::evm_tx > >
 Converts a given buffer to an evm_tx.
 
auto tx_encode (const cbdc::parsec::agent::runner::evm_tx &tx, uint64_t chain_id=opencbdc_chain_id, bool for_sighash=false) -> cbdc::buffer
 Converts the given transaction to an RLP encoded buffer conforming to Ethereums conventions.
 
auto dryrun_tx_from_json (const Json::Value &json, uint64_t chain_id=opencbdc_chain_id) -> std::optional< std::shared_ptr< cbdc::parsec::agent::runner::evm_dryrun_tx > >
 Converts a given Json::Value to an evm_dryrun_tx.
 
auto address_from_json (const Json::Value &addr) -> std::optional< evmc::address >
 Converts a given Json::Value to an evmc::address.
 
auto uint256be_from_json (const Json::Value &val) -> std::optional< evmc::uint256be >
 Converts a given Json::Value to an evmc::uint256be.
 
auto buffer_from_json (const Json::Value &val) -> std::optional< cbdc::buffer >
 Converts a given Json::Value to a cbdc::buffer.
 
auto uint256be_or_default (const Json::Value &val, evmc::uint256be def) -> evmc::uint256be
 Converts a given Json::Value to an evmc::uint256be, returning a default value if none could be decoded.
 
auto raw_tx_from_json (const Json::Value &param) -> std::optional< std::shared_ptr< cbdc::parsec::agent::runner::evm_tx > >
 Converts a given Json::Value to an evm_tx.
 
auto tx_from_json (const Json::Value &json, uint64_t chain_id=opencbdc_chain_id) -> std::optional< std::shared_ptr< cbdc::parsec::agent::runner::evm_tx > >
 Converts a given Json::Value to an evm_tx.
 
auto tx_to_json (cbdc::parsec::agent::runner::evm_tx &tx, const std::shared_ptr< secp256k1_context > &ctx) -> Json::Value
 Encodes the given transaction into a eth-RPC compatible representation in JSON - as Json::Value.
 
auto tx_receipt_to_json (cbdc::parsec::agent::runner::evm_tx_receipt &rcpt, const std::shared_ptr< secp256k1_context > &ctx) -> Json::Value
 Encodes the given transaction receipt into a eth-RPC compatible representation in JSON - as Json::Value.
 
auto tx_log_to_json (cbdc::parsec::agent::runner::evm_log &log, interface::ticket_number_type tn, cbdc::hash_t txid) -> Json::Value
 Encodes the given transaction log into a eth-RPC compatible representation in JSON - as Json::Value.
 
auto access_list_to_json (cbdc::parsec::agent::runner::evm_access_list &al) -> Json::Value
 Encodes the given access list into a eth-RPC compatible representation in JSON - as Json::Value.
 
auto secp256k1_ecdsa_recoverable_signature_to_evm_sig (secp256k1_ecdsa_recoverable_signature &sig, evm_tx_type type, uint64_t chain_id) -> evm_sig
 
auto evm_sig_to_secp256k1_ecdsa_recoverable_signature (const evm_sig &esig, evm_tx_type type, uint64_t chain_id) -> std::optional< secp256k1_ecdsa_recoverable_signature >
 
auto eth_sign (const privkey_t &key, hash_t &hash, evm_tx_type type, const std::shared_ptr< secp256k1_context > &ctx, uint64_t chain_id=opencbdc_chain_id) -> evm_sig
 Signs a hash using a privkey_t using ecdsa and produces an evm_sig struct Used primarily in unit tests for signature checking.
 
auto check_signature (const cbdc::parsec::agent::runner::evm_tx &tx, const std::shared_ptr< secp256k1_context > &ctx, uint64_t chain_id=opencbdc_chain_id) -> std::optional< evmc::address >
 Checks the signature of an EVM transaction.
 
auto sig_hash (const cbdc::parsec::agent::runner::evm_tx &tx, uint64_t chain_id=opencbdc_chain_id) -> hash_t
 Calculates the hash for creating / validating the signature.
 
auto to_uint64 (const evmc::uint256be &v) -> uint64_t
 Converts an uint256be to a uint64_t, ignoring higher order bits.
 
auto to_hex (const evmc::address &addr) -> std::string
 
auto to_hex (const evmc::bytes32 &b) -> std::string
 
auto to_hex_trimmed (const evmc::bytes32 &b, const std::string &prefix) -> std::string
 
void add_to_bloom (cbdc::buffer &bloom, const cbdc::buffer &entry)
 Adds an entry to a bloom value.
 
auto uint256be_from_hex (const std::string &hex) -> std::optional< evmc::uint256be >
 Generates a uint256be from a hex string.
 
auto mint_initial_accounts (const std::shared_ptr< logging::log > &log, const std::shared_ptr< parsec::broker::interface > &broker) -> bool
 Mints a set of initial accounts with funds, bypassing the agent.
 
template<typename T >
auto to_hex (const T &v) -> std::string
 Converts a bytes-like object to a hex string.
 
template<typename T >
auto from_hex (const std::string &hex) -> typename std::enable_if_t< std::is_same< T, evmc::bytes32 >::value||std::is_same< T, evmc::address >::value, std::optional< T > >
 Parses hexadecimal representation in string format to T.
 

Typedef Documentation

◆ evm_access_list

Type alias for a list of storage key accesses.

Definition at line 56 of file parsec/agent/runners/evm/messages.hpp.

◆ evm_account_code

using cbdc::parsec::agent::runner::evm_account_code = std::vector<uint8_t>

Type alias for EVM account code.

Definition at line 36 of file parsec/agent/runners/evm/messages.hpp.

Enumeration Type Documentation

◆ evm_runner_function

Commands accepted by the EVM contract runner.

Enumerator
execute_transaction 

Execute a normal transaction.

read_account 

Read the metadata of an account.

dryrun_transaction 

Execute a transaction without applying any changes.

read_account_code 

Read the contract code of an account.

get_transaction 

Return a previously completed transaction.

get_transaction_receipt 

Return the receipt for a transaction.

get_block_number 

Return just the ticket number to simulate getting the latest block.

get_block 

Return a pretend block that is based on the ticket number, and the transaction (potentially) corresponding to it.

get_logs 

Query the logs for a particular address, block range and topic filter.

read_account_storage 

Read a specific key of an account's storage.

Definition at line 19 of file agent/runners/evm/impl.hpp.

◆ evm_tx_type

enum class cbdc::parsec::agent::runner::evm_tx_type : uint8_t
strong

 EVM transaction types.

Enumerator
legacy 
access_list 
dynamic_fee 

Definition at line 59 of file parsec/agent/runners/evm/messages.hpp.

Function Documentation

◆ access_list_to_json()

auto cbdc::parsec::agent::runner::access_list_to_json ( cbdc::parsec::agent::runner::evm_access_list & al) -> Json::Value

Encodes the given access list into a eth-RPC compatible representation in JSON - as Json::Value.

Parameters
alThe access list to represent as json
Returns
a Json::Value containing the json representation of the access list

Definition at line 464 of file parsec/agent/runners/evm/serialization.cpp.

References to_hex().

Referenced by tx_to_json().

Here is the call graph for this function:

◆ add_to_bloom()

void cbdc::parsec::agent::runner::add_to_bloom ( cbdc::buffer & bloom,
const cbdc::buffer & entry )

Adds an entry to a bloom value.

Parameters
bloomthe existing bloom value
entrythe entry to add
See also
https://ethereum.github.io/execution-specs/autoapi/ethereum/ paris/bloom/index.html

Definition at line 58 of file agent/runners/evm/util.cpp.

References cbdc::buffer, cbdc::buffer::data(), cbdc::buffer::data_at(), cbdc::from_buffer(), cbdc::keccak_data(), cbdc::make_buffer(), and cbdc::buffer::size().

Referenced by tx_receipt_to_json().

Here is the call graph for this function:

◆ address_from_json()

auto cbdc::parsec::agent::runner::address_from_json ( const Json::Value & addr) -> std::optional< evmc::address >

Converts a given Json::Value to an evmc::address.

Parameters
addrJson::Value containing the address to decode. Is expected to be a string in 0x... format
Returns
the evmc::address that was decoded or std::nullopt if no valid value could be decoded

Definition at line 226 of file parsec/agent/runners/evm/serialization.cpp.

References cbdc::from_buffer(), and cbdc::buffer::from_hex().

Referenced by dryrun_tx_from_json(), and tx_from_json().

Here is the call graph for this function:

◆ buffer_from_json()

auto cbdc::parsec::agent::runner::buffer_from_json ( const Json::Value & val) -> std::optional< cbdc::buffer >

Converts a given Json::Value to a cbdc::buffer.

Parameters
valJson::Value containing the buffer to decode. Is expected to be a string in 0x... format containing valid hexadecimal representation of the buffer
Returns
the cbdc::buffer that was decoded or std::nullopt if no valid value could be decoded

Definition at line 258 of file parsec/agent/runners/evm/serialization.cpp.

References cbdc::buffer::from_hex().

Referenced by tx_from_json(), and uint256be_from_json().

Here is the call graph for this function:

◆ check_signature()

auto cbdc::parsec::agent::runner::check_signature ( const cbdc::parsec::agent::runner::evm_tx & tx,
const std::shared_ptr< secp256k1_context > & ctx,
uint64_t chain_id = opencbdc_chain_id ) -> std::optional< evmc::address >

Checks the signature of an EVM transaction.

Parameters
txtransaction to check signature for
chain_idchain_id for which the transaction is meant
ctxsecp256k1 context to use
Returns
the signer's address if the signature is valid and recoverable, nullopt otherwise

Definition at line 104 of file signature.cpp.

References eth_addr(), evm_sig_to_secp256k1_ecdsa_recoverable_signature(), and sig_hash().

Referenced by tx_to_json().

Here is the call graph for this function:

◆ check_tx_decode()

auto cbdc::parsec::agent::runner::check_tx_decode ( const cbdc::buffer & buf,
const std::shared_ptr< logging::log > & logger,
const std::shared_ptr< cbdc::parsec::agent::runner::evm_tx > & tx ) -> std::optional<rlp_value>

Definition at line 47 of file parsec/agent/runners/evm/serialization.cpp.

References cbdc::buffer, cbdc::from_buffer(), and is_valid_rlp_tx().

Referenced by tx_decode().

Here is the call graph for this function:

◆ contract_address()

auto cbdc::parsec::agent::runner::contract_address ( const evmc::address & sender,
const evmc::uint256be & nonce ) -> evmc::address

Calculates a contract address for the CREATE call keccak256(rlp([sender,nonce]))

Parameters
senderthe sender account creating the contract
noncethe account nonce of the sender at the time of creation
Returns
the contract address

Definition at line 20 of file address.cpp.

References cbdc::keccak_data(), cbdc::make_buffer(), cbdc::make_rlp_array(), and cbdc::make_rlp_value().

Here is the call graph for this function:

◆ contract_address2()

auto cbdc::parsec::agent::runner::contract_address2 ( const evmc::address & sender,
const evmc::bytes32 & salt,
const cbdc::hash_t & bytecode_hash ) -> evmc::address

Calculates a contract address for the CREATE2 call keccak256(0xFF | sender | salt | keccak256(bytecode))

Parameters
senderthe sender account creating the contract
saltthe salt value
bytecode_hashthe keccak256 hash of the bytecode of the contract
Returns
the contract address

Definition at line 33 of file address.cpp.

References cbdc::buffer, and cbdc::keccak_data().

Here is the call graph for this function:

◆ dryrun_tx_from_json()

auto cbdc::parsec::agent::runner::dryrun_tx_from_json ( const Json::Value & json,
uint64_t chain_id = opencbdc_chain_id ) -> std::optional< std::shared_ptr< cbdc::parsec::agent::runner::evm_dryrun_tx > >

Converts a given Json::Value to an evm_dryrun_tx.

Parameters
jsonJson::Value containing the transaction to decode
chain_idthe expected chain ID for the transaction. If the transaction contains a different chain ID this method will return std::nullopt
Returns
the evm_dryrun_tx that was decoded or std::nullopt if no valid value could be decoded

Definition at line 208 of file parsec/agent/runners/evm/serialization.cpp.

References address_from_json(), and tx_from_json().

Here is the call graph for this function:

◆ eth_addr() [1/2]

auto cbdc::parsec::agent::runner::eth_addr ( const cbdc::privkey_t & key,
const std::shared_ptr< secp256k1_context > & ctx ) -> evmc::address

Calculates an eth address from a private key.

Parameters
keykey to calculate the address for
ctxsecp256k1 context to use
Returns
the address corresponding to the passed private key

Definition at line 87 of file address.cpp.

References eth_addr().

Here is the call graph for this function:

◆ eth_addr() [2/2]

auto cbdc::parsec::agent::runner::eth_addr ( const std::unique_ptr< secp256k1_pubkey > & pk,
const std::shared_ptr< secp256k1_context > & ctx ) -> evmc::address

Calculates an eth address from a public key.

Parameters
pkkey to calculate the address for
ctxsecp256k1 context to use
Returns
the address corresponding to the passed public key

Definition at line 56 of file address.cpp.

References cbdc::buffer, and cbdc::keccak_data().

Referenced by check_signature(), and eth_addr().

Here is the call graph for this function:

◆ eth_sign()

auto cbdc::parsec::agent::runner::eth_sign ( const privkey_t & key,
hash_t & hash,
evm_tx_type type,
const std::shared_ptr< secp256k1_context > & ctx,
uint64_t chain_id = opencbdc_chain_id ) -> evm_sig

Signs a hash using a privkey_t using ecdsa and produces an evm_sig struct Used primarily in unit tests for signature checking.

Parameters
keykey to sign with
hashhash to sign
typethe transaction type
ctxsecp256k1 context to use
chain_idthe chain_id we are signing for (defaults to opencbdc)
Returns
the signature value encoded in r,s,v values in an evm_sig struct

Definition at line 85 of file signature.cpp.

References secp256k1_ecdsa_recoverable_signature_to_evm_sig().

Here is the call graph for this function:

◆ evm_sig_to_secp256k1_ecdsa_recoverable_signature()

auto cbdc::parsec::agent::runner::evm_sig_to_secp256k1_ecdsa_recoverable_signature ( const evm_sig & esig,
evm_tx_type type,
uint64_t chain_id ) -> std::optional<secp256k1_ecdsa_recoverable_signature>

Definition at line 54 of file signature.cpp.

References legacy, and to_uint64().

Referenced by check_signature().

Here is the call graph for this function:

◆ from_hex()

template<typename T >
auto cbdc::parsec::agent::runner::from_hex ( const std::string & hex) -> typename std::enable_if_t<std::is_same<T, evmc::bytes32>::value || std::is_same<T, evmc::address>::value, std::optional<T>>

Parses hexadecimal representation in string format to T.

Template Parameters
Ttype to convert from hex to.
Parameters
hexhex string to parse. May be prefixed with 0x
Returns
object containing the parsed T or std::nullopt if parse failed

Definition at line 54 of file parsec/agent/runners/evm/util.hpp.

References cbdc::buffer::from_hex_prefixed().

Here is the call graph for this function:

◆ is_valid_rlp_tx()

auto cbdc::parsec::agent::runner::is_valid_rlp_tx ( evm_tx_type type,
const rlp_value & rlp_tx ) -> bool

Definition at line 27 of file parsec/agent/runners/evm/serialization.cpp.

References access_list, dynamic_fee, and legacy.

Referenced by check_tx_decode().

◆ mint_initial_accounts()

auto cbdc::parsec::agent::runner::mint_initial_accounts ( const std::shared_ptr< logging::log > & log,
const std::shared_ptr< parsec::broker::interface > & broker ) -> bool

Mints a set of initial accounts with funds, bypassing the agent.

Parameters
loglogger instance.
brokerbroker instance to mint with.

Definition at line 101 of file agent/runners/evm/util.cpp.

References cbdc::buffer::from_hex(), cbdc::parsec::agent::init_addresses_for_testing, cbdc::make_buffer(), and cbdc::parsec::put_row().

Referenced by main().

Here is the call graph for this function:

◆ operator*()

auto cbdc::parsec::agent::runner::operator* ( const evmc::uint256be & lhs,
const evmc::uint256be & rhs ) -> evmc::uint256be

Multiplies two uint256be values.

Parameters
lhsfirst value.
rhssecond value.
Returns
lhs * rhs

Definition at line 46 of file math.cpp.

◆ operator+()

auto cbdc::parsec::agent::runner::operator+ ( const evmc::uint256be & lhs,
const evmc::uint256be & rhs ) -> evmc::uint256be

Adds two uint256be values.

Parameters
lhsfirst value.
rhssecond value.
Returns
sum of both values.

Definition at line 14 of file math.cpp.

◆ operator-()

auto cbdc::parsec::agent::runner::operator- ( const evmc::uint256be & lhs,
const evmc::uint256be & rhs ) -> evmc::uint256be

Subtracts two uint256be values.

Parameters
lhsvalue to subtract from.
rhsvalue to subtract.
Returns
lhs - rhs

Definition at line 28 of file math.cpp.

◆ operator<<()

auto cbdc::parsec::agent::runner::operator<< ( const evmc::uint256be & lhs,
size_t count ) -> evmc::uint256be

Left shifts a uint256be value by a given number of bytes.

Parameters
lhsvalue to shift.
countnumber of bytes to shift by.
Returns
lhs left shifted by count bytes.

Definition at line 74 of file math.cpp.

◆ raw_tx_from_json()

auto cbdc::parsec::agent::runner::raw_tx_from_json ( const Json::Value & param) -> std::optional< std::shared_ptr< cbdc::parsec::agent::runner::evm_tx > >

Converts a given Json::Value to an evm_tx.

Parameters
paramJson::Value containing the raw transaction to decode in (0x prefixed) hexadecimal format
Returns
the evm_tx that was decoded or std::nullopt if no valid value could be decoded

Definition at line 278 of file parsec/agent/runners/evm/serialization.cpp.

References cbdc::buffer::from_hex(), and tx_decode().

Here is the call graph for this function:

◆ secp256k1_ecdsa_recoverable_signature_to_evm_sig()

auto cbdc::parsec::agent::runner::secp256k1_ecdsa_recoverable_signature_to_evm_sig ( secp256k1_ecdsa_recoverable_signature & sig,
evm_tx_type type,
uint64_t chain_id ) -> evm_sig

Definition at line 22 of file signature.cpp.

References legacy.

Referenced by eth_sign().

◆ sig_hash()

auto cbdc::parsec::agent::runner::sig_hash ( const cbdc::parsec::agent::runner::evm_tx & tx,
uint64_t chain_id = opencbdc_chain_id ) -> hash_t

Calculates the hash for creating / validating the signature.

Parameters
txtransaction to calculate the sighash for
chain_idunique chain ID, defaults to 0xcbdc.
Returns
the sighash of the transaction

Definition at line 134 of file signature.cpp.

References cbdc::keccak_data(), and tx_encode().

Referenced by check_signature().

Here is the call graph for this function:

◆ to_hex() [1/3]

◆ to_hex() [2/3]

auto cbdc::parsec::agent::runner::to_hex ( const evmc::bytes32 & b) -> std::string

Definition at line 31 of file agent/runners/evm/util.cpp.

◆ to_hex() [3/3]

template<typename T >
auto cbdc::parsec::agent::runner::to_hex ( const T & v) -> std::string

Converts a bytes-like object to a hex string.

Template Parameters
Ttype to convert from.
Parameters
vvalue to convert.
Returns
hex string representation of v.

Definition at line 34 of file parsec/agent/runners/evm/util.hpp.

◆ to_hex_trimmed()

auto cbdc::parsec::agent::runner::to_hex_trimmed ( const evmc::bytes32 & b,
const std::string & prefix ) -> std::string

Definition at line 35 of file agent/runners/evm/util.cpp.

Referenced by tx_log_to_json(), tx_receipt_to_json(), and tx_to_json().

◆ to_uint64()

auto cbdc::parsec::agent::runner::to_uint64 ( const evmc::uint256be & v) -> uint64_t

Converts an uint256be to a uint64_t, ignoring higher order bits.

Parameters
vbignum to convert.
Returns
converted bignum.

Definition at line 23 of file agent/runners/evm/util.cpp.

Referenced by evm_sig_to_secp256k1_ecdsa_recoverable_signature(), and tx_decode().

◆ tx_decode()

auto cbdc::parsec::agent::runner::tx_decode ( const cbdc::buffer & buf,
const std::shared_ptr< logging::log > & logger,
uint64_t chain_id = opencbdc_chain_id ) -> std::optional< std::shared_ptr< cbdc::parsec::agent::runner::evm_tx > >

Converts a given buffer to an evm_tx.

Parameters
bufbuffer containing the transaction to decode
loggerlogger to output any parsing errors to
chain_idthe expected chain ID for the transaction. If the transaction contains a different chain ID this method will return std::nullopt
Returns
the evm_tx that was decoded or std::nullopt if no valid value could be decoded

Definition at line 78 of file parsec/agent/runners/evm/serialization.cpp.

References access_list, check_tx_decode(), dynamic_fee, legacy, cbdc::rlp_decode_access_list(), and to_uint64().

Referenced by raw_tx_from_json().

Here is the call graph for this function:

◆ tx_encode()

auto cbdc::parsec::agent::runner::tx_encode ( const cbdc::parsec::agent::runner::evm_tx & tx,
uint64_t chain_id = opencbdc_chain_id,
bool for_sighash = false ) -> cbdc::buffer

Converts the given transaction to an RLP encoded buffer conforming to Ethereums conventions.

Parameters
txtransaction to encode
chain_idthe chain ID for which to encode the transaction
for_sighashuse the formatting needed to calculate the sighash
Returns
the rlp representation of the transaction

Definition at line 155 of file parsec/agent/runners/evm/serialization.cpp.

References access_list, cbdc::array, cbdc::buffer, dynamic_fee, legacy, cbdc::make_rlp_value(), and cbdc::rlp_encode_access_list().

Referenced by sig_hash(), and tx_id().

Here is the call graph for this function:

◆ tx_from_json()

auto cbdc::parsec::agent::runner::tx_from_json ( const Json::Value & json,
uint64_t chain_id = opencbdc_chain_id ) -> std::optional< std::shared_ptr< cbdc::parsec::agent::runner::evm_tx > >

Converts a given Json::Value to an evm_tx.

Parameters
jsonJson::Value containing the transaction to decode
chain_idthe expected chain ID for the transaction. If the transaction contains a different chain ID this method will return std::nullopt
Returns
the evm_tx that was decoded or std::nullopt if no valid value could be decoded

Definition at line 293 of file parsec/agent/runners/evm/serialization.cpp.

References address_from_json(), buffer_from_json(), legacy, and uint256be_or_default().

Referenced by dryrun_tx_from_json().

Here is the call graph for this function:

◆ tx_id()

auto cbdc::parsec::agent::runner::tx_id ( const cbdc::parsec::agent::runner::evm_tx & tx,
uint64_t chain_id = opencbdc_chain_id ) -> cbdc::hash_t

Calculate ethereum-compatible txid.

Parameters
txtransaction to calculate ID for
chain_idunique chain ID, defaults to 0xcbdc.
Returns
the eth compatible txid of the transaction

Definition at line 21 of file parsec/agent/runners/evm/serialization.cpp.

References cbdc::keccak_data(), and tx_encode().

Referenced by cbdc::parsec::agent::runner::evm_host::get_state_updates(), tx_receipt_to_json(), and tx_to_json().

Here is the call graph for this function:

◆ tx_log_to_json()

auto cbdc::parsec::agent::runner::tx_log_to_json ( cbdc::parsec::agent::runner::evm_log & log,
interface::ticket_number_type tn,
cbdc::hash_t txid ) -> Json::Value

Encodes the given transaction log into a eth-RPC compatible representation in JSON - as Json::Value.

Parameters
logThe transaction log to represent as json
tnThe ticket number this log was emitted by. Used to generate a pretend blockhash. The evm_log does not contain this data - so it has to be passed in.
txidThe transaction ID this log was emitted by. The evm_log does not contain this data - so it has to be passed in.
Returns
a Json::Value containing the json representation of the transaction log

Definition at line 436 of file parsec/agent/runners/evm/serialization.cpp.

References cbdc::buffer, to_hex(), to_hex_trimmed(), and cbdc::to_string().

Referenced by tx_receipt_to_json().

Here is the call graph for this function:

◆ tx_receipt_to_json()

auto cbdc::parsec::agent::runner::tx_receipt_to_json ( cbdc::parsec::agent::runner::evm_tx_receipt & rcpt,
const std::shared_ptr< secp256k1_context > & ctx ) -> Json::Value

Encodes the given transaction receipt into a eth-RPC compatible representation in JSON - as Json::Value.

Parameters
rcptThe transaction receipt to represent as json
ctxThe secp256k1 context to use for deriving the from address
Returns
a Json::Value containing the json representation of the transaction receipt

Definition at line 386 of file parsec/agent/runners/evm/serialization.cpp.

References add_to_bloom(), cbdc::buffer, cbdc::make_buffer(), to_hex(), to_hex_trimmed(), cbdc::to_string(), tx_id(), tx_log_to_json(), and tx_to_json().

Here is the call graph for this function:

◆ tx_to_json()

auto cbdc::parsec::agent::runner::tx_to_json ( cbdc::parsec::agent::runner::evm_tx & tx,
const std::shared_ptr< secp256k1_context > & ctx ) -> Json::Value

Encodes the given transaction into a eth-RPC compatible representation in JSON - as Json::Value.

Parameters
txThe transaction to represent as json
ctxThe secp256k1 context to use for deriving the from address
Returns
a Json::Value containing the json representation of the transaction

Definition at line 337 of file parsec/agent/runners/evm/serialization.cpp.

References access_list_to_json(), cbdc::buffer, check_signature(), dynamic_fee, legacy, to_hex(), to_hex_trimmed(), cbdc::to_string(), and tx_id().

Referenced by tx_receipt_to_json().

Here is the call graph for this function:

◆ uint256be_from_hex()

auto cbdc::parsec::agent::runner::uint256be_from_hex ( const std::string & hex) -> std::optional< evmc::uint256be >

Generates a uint256be from a hex string.

Parameters
hexstring to parse.
Returns
uint256be from string, or std::nullopt if input is not a valid hex string.

Definition at line 81 of file agent/runners/evm/util.cpp.

References cbdc::buffer, and cbdc::buffer::from_hex_prefixed().

Here is the call graph for this function:

◆ uint256be_from_json()

auto cbdc::parsec::agent::runner::uint256be_from_json ( const Json::Value & val) -> std::optional< evmc::uint256be >

Converts a given Json::Value to an evmc::uint256be.

Parameters
valJson::Value containing the uint256be to decode. Is expected to be a string in 0x... format
Returns
the evmc::uint256be that was decoded or std::nullopt if no valid value could be decoded

Definition at line 245 of file parsec/agent/runners/evm/serialization.cpp.

References buffer_from_json(), and cbdc::from_buffer().

Referenced by uint256be_or_default().

Here is the call graph for this function:

◆ uint256be_or_default()

auto cbdc::parsec::agent::runner::uint256be_or_default ( const Json::Value & val,
evmc::uint256be def ) -> evmc::uint256be

Converts a given Json::Value to an evmc::uint256be, returning a default value if none could be decoded.

Parameters
valJson::Value containing the buffer to decode. Is expected to be a string in 0x... format containing valid hexadecimal representation of the buffer
defThe value to return if no valid value could be decoded from val
Returns
the evmc::uint256be that was decoded or the value of def if no value could be decoded

Definition at line 269 of file parsec/agent/runners/evm/serialization.cpp.

References uint256be_from_json().

Referenced by tx_from_json().

Here is the call graph for this function: