OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
parsec/agent/runners/evm/serialization.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_SERIALIZATION_H_
7#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_SERIALIZATION_H_
8
9#include "messages.hpp"
10#include "signature.hpp"
12#include "util/common/hash.hpp"
13#include "util/common/keys.hpp"
15
16#include <evmc/evmc.hpp>
17#include <evmc/hex.hpp>
18#include <json/json.h>
19#include <memory>
20#include <secp256k1.h>
21#include <secp256k1_extrakeys.h>
22#include <secp256k1_recovery.h>
23
25 static constexpr uint64_t eip155_v_offset = 35;
26 static constexpr uint64_t pre_eip155_v_offset = 27;
27
35 uint64_t chain_id = opencbdc_chain_id,
36 bool for_sighash = false) -> cbdc::buffer;
37
46 auto tx_decode(const cbdc::buffer& buf,
47 const std::shared_ptr<logging::log>& logger,
48 uint64_t chain_id = opencbdc_chain_id)
49 -> std::optional<std::shared_ptr<cbdc::parsec::agent::runner::evm_tx>>;
50
56 auto raw_tx_from_json(const Json::Value& param)
57 -> std::optional<std::shared_ptr<cbdc::parsec::agent::runner::evm_tx>>;
58
66 auto tx_from_json(const Json::Value& json,
67 uint64_t chain_id = opencbdc_chain_id)
68 -> std::optional<std::shared_ptr<cbdc::parsec::agent::runner::evm_tx>>;
69
77 auto dryrun_tx_from_json(const Json::Value& json,
78 uint64_t chain_id = opencbdc_chain_id)
79 -> std::optional<
80 std::shared_ptr<cbdc::parsec::agent::runner::evm_dryrun_tx>>;
81
87 auto address_from_json(const Json::Value& addr)
88 -> std::optional<evmc::address>;
89
95 auto uint256be_from_json(const Json::Value& val)
96 -> std::optional<evmc::uint256be>;
97
104 auto buffer_from_json(const Json::Value& val)
105 -> std::optional<cbdc::buffer>;
106
116 auto uint256be_or_default(const Json::Value& val, evmc::uint256be def)
117 -> evmc::uint256be;
118
126 const std::shared_ptr<secp256k1_context>& ctx)
127 -> Json::Value;
128
136 const std::shared_ptr<secp256k1_context>& ctx)
137 -> Json::Value;
138
151 cbdc::hash_t txid) -> Json::Value;
152
159 -> Json::Value;
160
166 uint64_t chain_id = opencbdc_chain_id) -> cbdc::hash_t;
167}
168
169#endif
Buffer to store and retrieve byte data.
Definition buffer.hpp:15
parsec::ticket_machine::ticket_number_type ticket_number_type
Type alias for a ticket number.
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 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 address_from_json(const Json::Value &addr) -> std::optional< evmc::address >
Converts a given Json::Value to an evmc::address.
auto tx_encode(const cbdc::parsec::agent::runner::evm_tx &tx, uint64_t chain_id, bool for_sighash) -> cbdc::buffer
Converts the given transaction to an RLP encoded buffer conforming to Ethereums conventions.
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 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::Val...
auto buffer_from_json(const Json::Value &val) -> std::optional< cbdc::buffer >
Converts a given Json::Value to a cbdc::buffer.
auto dryrun_tx_from_json(const Json::Value &json, uint64_t 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 tx_from_json(const Json::Value &json, uint64_t) -> std::optional< std::shared_ptr< cbdc::parsec::agent::runner::evm_tx > >
Converts a given Json::Value to an evm_tx.
auto uint256be_from_json(const Json::Value &val) -> std::optional< evmc::uint256be >
Converts a given Json::Value to an evmc::uint256be.
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 tx_decode(const cbdc::buffer &buf, const std::shared_ptr< logging::log > &logger, uint64_t chain_id) -> std::optional< std::shared_ptr< cbdc::parsec::agent::runner::evm_tx > >
Converts a given buffer to an evm_tx.
std::vector< evm_access_tuple > evm_access_list
Type alias for a list of storage key accesses.
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 decode...
auto tx_id(const cbdc::parsec::agent::runner::evm_tx &tx, uint64_t chain_id) -> cbdc::hash_t
Calculate ethereum-compatible txid.
std::array< unsigned char, cbdc::hash_size > hash_t
SHA256 hash container.
@ buffer
A singular RLP value (byte array)