TARAXA
FinalChain

Classes

struct  taraxa::final_chain::BlockHeaderData
 
struct  taraxa::final_chain::BlockHeader
 
struct  taraxa::final_chain::LogEntry
 
struct  taraxa::final_chain::TransactionReceipt
 
struct  taraxa::final_chain::TransactionLocation
 
struct  taraxa::final_chain::NewBlock
 
struct  taraxa::final_chain::FinalizationResult
 
class  taraxa::final_chain::FinalChain
 main responsibility is blocks execution in EVM, getting data from EVM state More...
 
class  taraxa::state_api::StateAPI
 
struct  taraxa::state_api::TaraxaEVMError
 
struct  taraxa::state_api::ErrFutureBlock
 
struct  taraxa::state_api::EVMBlock
 
struct  taraxa::state_api::EVMTransaction
 
struct  taraxa::state_api::UncleBlock
 
struct  taraxa::state_api::LogRecord
 
struct  taraxa::state_api::ExecutionResult
 
struct  taraxa::state_api::TransactionsExecutionResult
 
struct  taraxa::state_api::RewardsDistributionResult
 
struct  taraxa::state_api::StateDescriptor
 
struct  taraxa::state_api::Tracing
 
struct  taraxa::state_api::ValidatorStake
 
struct  taraxa::state_api::ValidatorVoteCount
 

Typedefs

using taraxa::final_chain::LogBloom = dev::h2048
 
using taraxa::final_chain::LogBlooms = std::vector< LogBloom >
 
using taraxa::final_chain::Nonce = dev::h64
 
using taraxa::final_chain::BlocksBlooms = std::array< LogBloom, c_bloomIndexSize >
 
using taraxa::final_chain::LogEntries = std::vector< LogEntry >
 
using taraxa::final_chain::TransactionReceipts = std::vector< TransactionReceipt >
 

Variables

static constexpr auto taraxa::final_chain::c_bloomIndexSize = 16
 
static constexpr auto taraxa::final_chain::c_bloomIndexLevels = 2
 
struct taraxa::state_api::Account taraxa::state_api::ZeroAccount
 

Detailed Description


Class Documentation

◆ taraxa::final_chain::BlockHeaderData

struct taraxa::final_chain::BlockHeaderData
Collaboration diagram for taraxa::final_chain::BlockHeaderData:

Public Member Functions

dev::bytes serializeForDB () const
 

Public Attributes

h256 parent_hash
 
h256 state_root
 
h256 transactions_root
 
h256 receipts_root
 
LogBloom log_bloom
 
uint64_t gas_used = 0
 
u256 total_reward
 

Member Function Documentation

◆ serializeForDB()

dev::bytes taraxa::final_chain::BlockHeaderData::serializeForDB ( ) const

Member Data Documentation

◆ gas_used

uint64_t taraxa::final_chain::BlockHeaderData::gas_used = 0

◆ log_bloom

LogBloom taraxa::final_chain::BlockHeaderData::log_bloom

◆ parent_hash

h256 taraxa::final_chain::BlockHeaderData::parent_hash

◆ receipts_root

h256 taraxa::final_chain::BlockHeaderData::receipts_root

◆ state_root

h256 taraxa::final_chain::BlockHeaderData::state_root

◆ total_reward

u256 taraxa::final_chain::BlockHeaderData::total_reward

◆ transactions_root

h256 taraxa::final_chain::BlockHeaderData::transactions_root

◆ taraxa::final_chain::BlockHeader

struct taraxa::final_chain::BlockHeader
Collaboration diagram for taraxa::final_chain::BlockHeader:

Public Member Functions

 BlockHeader ()=default
 
 BlockHeader (std::string &&raw_header_data)
 
 BlockHeader (std::string &&raw_header_data, const PbftBlock &pbft, uint64_t gas_limit)
 
void setFromPbft (const PbftBlock &pbft)
 
dev::bytes ethereumRlp () const
 
- Public Member Functions inherited from taraxa::final_chain::BlockHeaderData
dev::bytes serializeForDB () const
 

Static Public Member Functions

static h256 const & unclesHash ()
 
static Nonce const & nonce ()
 
static u256 const & difficulty ()
 
static h256 const & mixHash ()
 

Public Attributes

h256 hash
 
Address author
 
uint64_t gas_limit = 0
 
uint64_t timestamp = 0
 
EthBlockNumber number = 0
 
bytes extra_data
 
- Public Attributes inherited from taraxa::final_chain::BlockHeaderData
h256 parent_hash
 
h256 state_root
 
h256 transactions_root
 
h256 receipts_root
 
LogBloom log_bloom
 
uint64_t gas_used = 0
 
u256 total_reward
 

Constructor & Destructor Documentation

◆ BlockHeader() [1/3]

taraxa::final_chain::BlockHeader::BlockHeader ( )
default

◆ BlockHeader() [2/3]

taraxa::final_chain::BlockHeader::BlockHeader ( std::string &&  raw_header_data)

◆ BlockHeader() [3/3]

taraxa::final_chain::BlockHeader::BlockHeader ( std::string &&  raw_header_data,
const PbftBlock pbft,
uint64_t  gas_limit 
)

Member Function Documentation

◆ difficulty()

u256 const & taraxa::final_chain::BlockHeader::difficulty ( )
static

◆ ethereumRlp()

dev::bytes taraxa::final_chain::BlockHeader::ethereumRlp ( ) const

◆ mixHash()

h256 const & taraxa::final_chain::BlockHeader::mixHash ( )
static

◆ nonce()

Nonce const & taraxa::final_chain::BlockHeader::nonce ( )
static

◆ setFromPbft()

void taraxa::final_chain::BlockHeader::setFromPbft ( const PbftBlock pbft)

◆ unclesHash()

h256 const & taraxa::final_chain::BlockHeader::unclesHash ( )
static

Member Data Documentation

◆ author

Address taraxa::final_chain::BlockHeader::author

◆ extra_data

bytes taraxa::final_chain::BlockHeader::extra_data

◆ gas_limit

uint64_t taraxa::final_chain::BlockHeader::gas_limit = 0

◆ hash

h256 taraxa::final_chain::BlockHeader::hash

◆ number

EthBlockNumber taraxa::final_chain::BlockHeader::number = 0

◆ timestamp

uint64_t taraxa::final_chain::BlockHeader::timestamp = 0

◆ taraxa::final_chain::LogEntry

struct taraxa::final_chain::LogEntry
Collaboration diagram for taraxa::final_chain::LogEntry:

Public Member Functions

HAS_RLP_FIELDS LogBloom bloom () const
 

Public Attributes

Address address
 
h256s topics
 
bytes data
 

Member Function Documentation

◆ bloom()

LogBloom taraxa::final_chain::LogEntry::bloom ( ) const

Member Data Documentation

◆ address

Address taraxa::final_chain::LogEntry::address

◆ data

bytes taraxa::final_chain::LogEntry::data

◆ topics

h256s taraxa::final_chain::LogEntry::topics

◆ taraxa::final_chain::TransactionReceipt

struct taraxa::final_chain::TransactionReceipt

Public Member Functions

HAS_RLP_FIELDS LogBloom bloom () const
 

Public Attributes

uint8_t status_code = 0
 
uint64_t gas_used = 0
 
uint64_t cumulative_gas_used = 0
 
LogEntries logs
 
std::optional< Addressnew_contract_address
 

Member Function Documentation

◆ bloom()

LogBloom taraxa::final_chain::TransactionReceipt::bloom ( ) const

Member Data Documentation

◆ cumulative_gas_used

uint64_t taraxa::final_chain::TransactionReceipt::cumulative_gas_used = 0

◆ gas_used

uint64_t taraxa::final_chain::TransactionReceipt::gas_used = 0

◆ logs

LogEntries taraxa::final_chain::TransactionReceipt::logs

◆ new_contract_address

std::optional<Address> taraxa::final_chain::TransactionReceipt::new_contract_address

◆ status_code

uint8_t taraxa::final_chain::TransactionReceipt::status_code = 0

◆ taraxa::final_chain::TransactionLocation

struct taraxa::final_chain::TransactionLocation

Public Attributes

EthBlockNumber period = 0
 
uint32_t position = 0
 
bool is_system = false
 

Member Data Documentation

◆ is_system

bool taraxa::final_chain::TransactionLocation::is_system = false

◆ period

EthBlockNumber taraxa::final_chain::TransactionLocation::period = 0

◆ position

uint32_t taraxa::final_chain::TransactionLocation::position = 0

◆ taraxa::final_chain::NewBlock

struct taraxa::final_chain::NewBlock
Collaboration diagram for taraxa::final_chain::NewBlock:

Public Attributes

addr_t author
 
uint64_t timestamp
 
std::vector< h256dag_blk_hashes
 
h256 hash
 

Member Data Documentation

◆ author

addr_t taraxa::final_chain::NewBlock::author

◆ dag_blk_hashes

std::vector<h256> taraxa::final_chain::NewBlock::dag_blk_hashes

◆ hash

h256 taraxa::final_chain::NewBlock::hash

◆ timestamp

uint64_t taraxa::final_chain::NewBlock::timestamp

◆ taraxa::final_chain::FinalizationResult

struct taraxa::final_chain::FinalizationResult
Collaboration diagram for taraxa::final_chain::FinalizationResult:

Public Attributes

std::shared_ptr< BlockHeader const > final_chain_blk
 
SharedTransactions trxs
 
TransactionReceipts trx_receipts
 
- Public Attributes inherited from taraxa::final_chain::NewBlock
addr_t author
 
uint64_t timestamp
 
std::vector< h256dag_blk_hashes
 
h256 hash
 

Member Data Documentation

◆ final_chain_blk

std::shared_ptr<BlockHeader const> taraxa::final_chain::FinalizationResult::final_chain_blk

◆ trx_receipts

TransactionReceipts taraxa::final_chain::FinalizationResult::trx_receipts

◆ trxs

SharedTransactions taraxa::final_chain::FinalizationResult::trxs

◆ taraxa::final_chain::FinalChain

class taraxa::final_chain::FinalChain

main responsibility is blocks execution in EVM, getting data from EVM state

Class have methods which you can call to get info from EVM and related state. Main thing here is finalize() method, that is called to execute some pbft block. It implements few events and implements methods related to Ethereum API

Collaboration diagram for taraxa::final_chain::FinalChain:

Public Member Functions

 ~FinalChain ()=default
 
 FinalChain (const std::shared_ptr< DbStorage > &db, const taraxa::FullNodeConfig &config, const addr_t &node_addr)
 
 FinalChain (const FinalChain &)=delete
 
 FinalChain (FinalChain &&)=delete
 
FinalChainoperator= (const FinalChain &)=delete
 
FinalChainoperator= (FinalChain &&)=delete
 
void stop ()
 
EthBlockNumber delegationDelay () const
 
std::future< std::shared_ptr< const FinalizationResult > > finalize (PeriodData &&period_data, std::vector< h256 > &&finalized_dag_blk_hashes, std::shared_ptr< DagBlock > &&anchor=nullptr)
 Method which finalizes a block and executes it in EVM. More...
 
std::shared_ptr< const BlockHeaderblockHeader (std::optional< EthBlockNumber > n={}) const
 Method to get block header by block number. More...
 
EthBlockNumber lastBlockNumber () const
 Method to get last block number(chain size) More...
 
std::optional< EthBlockNumberblockNumber (h256 const &h) const
 Method to get block number by hash. More...
 
std::optional< h256blockHash (std::optional< EthBlockNumber > n={}) const
 Method to get block hash by block number. More...
 
std::optional< h256finalChainHash (EthBlockNumber n) const
 Method to get the final chain hash by block number. More...
 
void updateStateConfig (const state_api::Config &new_config)
 Needed if we are changing params with hardfork and it affects Go part of code. For example DPOS contract. More...
 
std::shared_ptr< const TransactionHashestransactionHashes (std::optional< EthBlockNumber > n={}) const
 Method to get all transaction hashes from the block. More...
 
const SharedTransactions transactions (std::optional< EthBlockNumber > n={}) const
 Method to get all transactions from the block. More...
 
std::optional< TransactionLocationtransactionLocation (h256 const &trx_hash) const
 Method to get transaction location by hash. More...
 
std::optional< TransactionReceipttransactionReceipt (h256 const &_transactionHash) const
 Method to get transaction receipt by hash. More...
 
uint64_t transactionCount (std::optional< EthBlockNumber > n={}) const
 Method to get transactions count in block. More...
 
std::vector< EthBlockNumberwithBlockBloom (LogBloom const &b, EthBlockNumber from, EthBlockNumber to) const
 Method used to search for contract logs with bloom filter. More...
 
std::optional< state_api::AccountgetAccount (addr_t const &addr, std::optional< EthBlockNumber > blk_n={}) const
 Method to get account information. More...
 
h256 getAccountStorage (addr_t const &addr, u256 const &key, std::optional< EthBlockNumber > blk_n={}) const
 Returns the value from a storage position at a given address. More...
 
bytes getCode (addr_t const &addr, std::optional< EthBlockNumber > blk_n={}) const
 Returns code at a given address. More...
 
state_api::ExecutionResult call (state_api::EVMTransaction const &trx, std::optional< EthBlockNumber > blk_n={}) const
 Executes a new message call immediately without creating a transaction on the block chain. That means that state would be reverted and not saved anywhere. More...
 
std::string trace (std::vector< state_api::EVMTransaction > trx, EthBlockNumber blk_n, std::optional< state_api::Tracing > params={}) const
 Trace execution of a new message call immediately without creating a transactions on the block chain. That means that state would be reverted and not saved anywhere. More...
 
uint64_t dposEligibleTotalVoteCount (EthBlockNumber blk_num) const
 total count of eligible votes are in DPOS precompiled contract More...
 
uint64_t dposEligibleVoteCount (EthBlockNumber blk_num, addr_t const &addr) const
 total count of eligible votes account has in DPOS precompiled contract More...
 
bool dposIsEligible (EthBlockNumber blk_num, addr_t const &addr) const
 method to check if address have enough votes to participate in consensus More...
 
vrf_wrapper::vrf_pk_t dposGetVrfKey (EthBlockNumber blk_n, const addr_t &addr) const
 Get the vrf key object from DPOS state. More...
 
void prune (EthBlockNumber blk_n)
 Prune state db for all blocks older than blk_n. More...
 
void waitForFinalized ()
 Wait until next block is finalized. More...
 
std::vector< state_api::ValidatorStakedposValidatorsTotalStakes (EthBlockNumber blk_num) const
 
uint256_t dposTotalAmountDelegated (EthBlockNumber blk_num) const
 
std::vector< state_api::ValidatorVoteCountdposValidatorsVoteCounts (EthBlockNumber blk_num) const
 
uint64_t dposYield (EthBlockNumber blk_num) const
 
u256 dposTotalSupply (EthBlockNumber blk_num) const
 
h256 getBridgeRoot (EthBlockNumber blk_num) const
 
h256 getBridgeEpoch (EthBlockNumber blk_num) const
 
std::pair< val_t, bool > getBalance (addr_t const &addr) const
 
std::shared_ptr< const FinalizationResultfinalize_ (PeriodData &&new_blk, std::vector< h256 > &&finalized_dag_blk_hashes, std::shared_ptr< DagBlock > &&anchor)
 

Public Attributes

decltype(block_finalized_emitter_) ::Subscriber const & block_finalized_ = block_finalized_emitter_
 
decltype(block_applying_emitter_) ::Subscriber const & block_applying_ = block_applying_emitter_
 

Protected Attributes

util::EventEmitter< std::shared_ptr< FinalizationResult > > const block_finalized_emitter_ {}
 
util::EventEmitter< uint64_t > const block_applying_emitter_ {}
 

Private Member Functions

std::shared_ptr< TransactionHashesgetTransactionHashes (std::optional< EthBlockNumber > n={}) const
 
const SharedTransactions getTransactions (std::optional< EthBlockNumber > n={}) const
 
std::shared_ptr< const BlockHeadergetBlockHeader (EthBlockNumber n) const
 
std::optional< h256getBlockHash (EthBlockNumber n) const
 
EthBlockNumber lastIfAbsent (const std::optional< EthBlockNumber > &client_blk_n) const
 
BlocksBlooms blockBlooms (const h256 &chunk_id) const
 
std::vector< EthBlockNumberwithBlockBloom (const LogBloom &b, EthBlockNumber from, EthBlockNumber to, EthBlockNumber level, EthBlockNumber index) const
 
bool isNeedToFinalize (EthBlockNumber blk_num) const
 
SharedTransaction makeBridgeFinalizationTransaction ()
 
std::vector< SharedTransactionmakeSystemTransactions (PbftPeriod blk_num)
 
std::shared_ptr< BlockHeadermakeGenesisHeader (std::string &&raw_header) const
 
std::shared_ptr< BlockHeadermakeGenesisHeader (const h256 &state_root) const
 
std::shared_ptr< BlockHeaderappendBlock (Batch &batch, const PbftBlock &pbft_blk, const h256 &state_root, u256 total_reward, const SharedTransactions &transactions={}, const TransactionReceipts &receipts={})
 
std::shared_ptr< BlockHeaderappendBlock (Batch &batch, std::shared_ptr< BlockHeader > header, const SharedTransactions &transactions={}, const TransactionReceipts &receipts={})
 

Static Private Member Functions

static state_api::EVMTransaction toEvmTransaction (const SharedTransaction &trx)
 
static void appendEvmTransactions (std::vector< state_api::EVMTransaction > &evm_trxs, const SharedTransactions &trxs)
 
static h256 blockBloomsChunkId (EthBlockNumber level, EthBlockNumber index)
 

Private Attributes

std::shared_ptr< DbStoragedb_
 
const uint64_t kBlockGasLimit
 
StateAPI state_api_
 
const bool kLightNode = false
 
const uint32_t kMaxLevelsPerPeriod
 
rewards::Stats rewards_
 
boost::asio::thread_pool executor_thread_ {1}
 
std::atomic< uint64_t > num_executed_dag_blk_ = 0
 
std::atomic< uint64_t > num_executed_trx_ = 0
 
EthBlockNumber delegation_delay_
 
ValueByBlockCache< std::shared_ptr< const BlockHeader > > block_headers_cache_
 
ValueByBlockCache< std::optional< const h256 > > block_hashes_cache_
 
ValueByBlockCache< const SharedTransactionstransactions_cache_
 
ValueByBlockCache< std::shared_ptr< const TransactionHashes > > transaction_hashes_cache_
 
MapByBlockCache< addr_t, std::optional< const state_api::Account > > accounts_cache_
 
ValueByBlockCache< uint64_t > total_vote_count_cache_
 
MapByBlockCache< addr_t, uint64_t > dpos_vote_count_cache_
 
MapByBlockCache< addr_t, uint64_t > dpos_is_eligible_cache_
 
std::condition_variable finalized_cv_
 
std::mutex finalized_mtx_
 
std::atomic< EthBlockNumberlast_block_number_
 
const FullNodeConfigkConfig
 

Constructor & Destructor Documentation

◆ ~FinalChain()

taraxa::final_chain::FinalChain::~FinalChain ( )
default

◆ FinalChain() [1/3]

taraxa::final_chain::FinalChain::FinalChain ( const std::shared_ptr< DbStorage > &  db,
const taraxa::FullNodeConfig config,
const addr_t node_addr 
)

◆ FinalChain() [2/3]

taraxa::final_chain::FinalChain::FinalChain ( const FinalChain )
delete

◆ FinalChain() [3/3]

taraxa::final_chain::FinalChain::FinalChain ( FinalChain &&  )
delete

Member Function Documentation

◆ appendBlock() [1/2]

std::shared_ptr< BlockHeader > taraxa::final_chain::FinalChain::appendBlock ( Batch batch,
const PbftBlock pbft_blk,
const h256 state_root,
u256  total_reward,
const SharedTransactions transactions = {},
const TransactionReceipts receipts = {} 
)
private

◆ appendBlock() [2/2]

std::shared_ptr< BlockHeader > taraxa::final_chain::FinalChain::appendBlock ( Batch batch,
std::shared_ptr< BlockHeader header,
const SharedTransactions transactions = {},
const TransactionReceipts receipts = {} 
)
private

◆ appendEvmTransactions()

void taraxa::final_chain::FinalChain::appendEvmTransactions ( std::vector< state_api::EVMTransaction > &  evm_trxs,
const SharedTransactions trxs 
)
staticprivate

◆ blockBlooms()

BlocksBlooms taraxa::final_chain::FinalChain::blockBlooms ( const h256 chunk_id) const
private

◆ blockBloomsChunkId()

h256 taraxa::final_chain::FinalChain::blockBloomsChunkId ( EthBlockNumber  level,
EthBlockNumber  index 
)
staticprivate

◆ blockHash()

std::optional< h256 > taraxa::final_chain::FinalChain::blockHash ( std::optional< EthBlockNumber n = {}) const

Method to get block hash by block number.

Parameters
nEthBlockNumber
Returns
BlockHash h256

◆ blockHeader()

std::shared_ptr< const BlockHeader > taraxa::final_chain::FinalChain::blockHeader ( std::optional< EthBlockNumber n = {}) const

Method to get block header by block number.

Parameters
nblock number of header to get. If not specified then it returns latest
Returns
BlockHeader

◆ blockNumber()

std::optional< EthBlockNumber > taraxa::final_chain::FinalChain::blockNumber ( h256 const &  h) const

Method to get block number by hash.

Parameters
hblock hash
Returns
EthBlockNumber

◆ call()

state_api::ExecutionResult taraxa::final_chain::FinalChain::call ( state_api::EVMTransaction const &  trx,
std::optional< EthBlockNumber blk_n = {} 
) const

Executes a new message call immediately without creating a transaction on the block chain. That means that state would be reverted and not saved anywhere.

Parameters
trxstate_api::EVMTransaction
blk_nEthBlockNumber number of block we are getting state from
Returns
state_api::ExecutionResult

◆ delegationDelay()

EthBlockNumber taraxa::final_chain::FinalChain::delegationDelay ( ) const

◆ dposEligibleTotalVoteCount()

uint64_t taraxa::final_chain::FinalChain::dposEligibleTotalVoteCount ( EthBlockNumber  blk_num) const

total count of eligible votes are in DPOS precompiled contract

Parameters
blk_numEthBlockNumber number of block we are getting state from
Returns
total count of eligible votes

◆ dposEligibleVoteCount()

uint64_t taraxa::final_chain::FinalChain::dposEligibleVoteCount ( EthBlockNumber  blk_num,
addr_t const &  addr 
) const

total count of eligible votes account has in DPOS precompiled contract

Parameters
blk_numEthBlockNumber number of block we are getting state from
addraccount address
Returns
address eligible votes count

◆ dposGetVrfKey()

vrf_wrapper::vrf_pk_t taraxa::final_chain::FinalChain::dposGetVrfKey ( EthBlockNumber  blk_n,
const addr_t addr 
) const

Get the vrf key object from DPOS state.

Parameters
addraccount address
blk_nnumber of block we are getting state from
Returns
vrf_wrapper::vrf_pk_t

◆ dposIsEligible()

bool taraxa::final_chain::FinalChain::dposIsEligible ( EthBlockNumber  blk_num,
addr_t const &  addr 
) const

method to check if address have enough votes to participate in consensus

Parameters
blk_numEthBlockNumber number of block we are getting state from
addraccount address
Returns
is address eligible

◆ dposTotalAmountDelegated()

uint256_t taraxa::final_chain::FinalChain::dposTotalAmountDelegated ( EthBlockNumber  blk_num) const

◆ dposTotalSupply()

u256 taraxa::final_chain::FinalChain::dposTotalSupply ( EthBlockNumber  blk_num) const
Parameters
blk_num
Returns
total supply

◆ dposValidatorsTotalStakes()

std::vector< state_api::ValidatorStake > taraxa::final_chain::FinalChain::dposValidatorsTotalStakes ( EthBlockNumber  blk_num) const

◆ dposValidatorsVoteCounts()

std::vector< state_api::ValidatorVoteCount > taraxa::final_chain::FinalChain::dposValidatorsVoteCounts ( EthBlockNumber  blk_num) const
Parameters
blk_num
Returns
vector of validators vote counts for provided blk_num

◆ dposYield()

uint64_t taraxa::final_chain::FinalChain::dposYield ( EthBlockNumber  blk_num) const
Parameters
blk_num
Returns
yield

◆ finalChainHash()

std::optional< h256 > taraxa::final_chain::FinalChain::finalChainHash ( EthBlockNumber  n) const

Method to get the final chain hash by block number.

Parameters
nblock number
Returns
std::optional<h256> final chain hash or nullopt

◆ finalize()

std::future< std::shared_ptr< const FinalizationResult > > taraxa::final_chain::FinalChain::finalize ( PeriodData &&  period_data,
std::vector< h256 > &&  finalized_dag_blk_hashes,
std::shared_ptr< DagBlock > &&  anchor = nullptr 
)

Method which finalizes a block and executes it in EVM.

Parameters
period_dataFull period data with transactions
finalized_dag_blk_hashes
precommit_ext
Returns
finalization result

◆ finalize_()

std::shared_ptr< const FinalizationResult > taraxa::final_chain::FinalChain::finalize_ ( PeriodData &&  new_blk,
std::vector< h256 > &&  finalized_dag_blk_hashes,
std::shared_ptr< DagBlock > &&  anchor 
)

◆ getAccount()

std::optional< state_api::Account > taraxa::final_chain::FinalChain::getAccount ( addr_t const &  addr,
std::optional< EthBlockNumber blk_n = {} 
) const

Method to get account information.

See also
state_api::Account
Parameters
addraccount address
blk_nnumber of block we are getting state from
Returns
std::optional<state_api::Account> account object or nullopt if account wasn't found

◆ getAccountStorage()

h256 taraxa::final_chain::FinalChain::getAccountStorage ( addr_t const &  addr,
u256 const &  key,
std::optional< EthBlockNumber blk_n = {} 
) const

Returns the value from a storage position at a given address.

Parameters
addraccount address
keyposition in the storage
blk_nnumber of block we are getting state from
Returns
the value at this storage position

◆ getBalance()

std::pair< val_t, bool > taraxa::final_chain::FinalChain::getBalance ( addr_t const &  addr) const

◆ getBlockHash()

std::optional< h256 > taraxa::final_chain::FinalChain::getBlockHash ( EthBlockNumber  n) const
private

◆ getBlockHeader()

std::shared_ptr< const BlockHeader > taraxa::final_chain::FinalChain::getBlockHeader ( EthBlockNumber  n) const
private

◆ getBridgeEpoch()

h256 taraxa::final_chain::FinalChain::getBridgeEpoch ( EthBlockNumber  blk_num) const
Parameters
blk_num
Returns
bridge epoch

◆ getBridgeRoot()

h256 taraxa::final_chain::FinalChain::getBridgeRoot ( EthBlockNumber  blk_num) const
Parameters
blk_num
Returns
bridge root

◆ getCode()

bytes taraxa::final_chain::FinalChain::getCode ( addr_t const &  addr,
std::optional< EthBlockNumber blk_n = {} 
) const

Returns code at a given address.

Parameters
addraccount address
blk_nnumber of block we are getting state from
Returns
code at a given address.

◆ getTransactionHashes()

std::shared_ptr< TransactionHashes > taraxa::final_chain::FinalChain::getTransactionHashes ( std::optional< EthBlockNumber n = {}) const
private

◆ getTransactions()

const SharedTransactions taraxa::final_chain::FinalChain::getTransactions ( std::optional< EthBlockNumber n = {}) const
private

◆ isNeedToFinalize()

bool taraxa::final_chain::FinalChain::isNeedToFinalize ( EthBlockNumber  blk_num) const
private

◆ lastBlockNumber()

EthBlockNumber taraxa::final_chain::FinalChain::lastBlockNumber ( ) const

Method to get last block number(chain size)

Returns
EthBlockNumber

◆ lastIfAbsent()

EthBlockNumber taraxa::final_chain::FinalChain::lastIfAbsent ( const std::optional< EthBlockNumber > &  client_blk_n) const
private

◆ makeBridgeFinalizationTransaction()

SharedTransaction taraxa::final_chain::FinalChain::makeBridgeFinalizationTransaction ( )
private

◆ makeGenesisHeader() [1/2]

std::shared_ptr< BlockHeader > taraxa::final_chain::FinalChain::makeGenesisHeader ( const h256 state_root) const
private

◆ makeGenesisHeader() [2/2]

std::shared_ptr< BlockHeader > taraxa::final_chain::FinalChain::makeGenesisHeader ( std::string &&  raw_header) const
private

◆ makeSystemTransactions()

std::vector< SharedTransaction > taraxa::final_chain::FinalChain::makeSystemTransactions ( PbftPeriod  blk_num)
private

◆ operator=() [1/2]

FinalChain& taraxa::final_chain::FinalChain::operator= ( const FinalChain )
delete

◆ operator=() [2/2]

FinalChain& taraxa::final_chain::FinalChain::operator= ( FinalChain &&  )
delete

◆ prune()

void taraxa::final_chain::FinalChain::prune ( EthBlockNumber  blk_n)

Prune state db for all blocks older than blk_n.

Parameters
blk_nnumber of block we are getting state from

◆ stop()

void taraxa::final_chain::FinalChain::stop ( )

◆ toEvmTransaction()

state_api::EVMTransaction taraxa::final_chain::FinalChain::toEvmTransaction ( const SharedTransaction trx)
staticprivate

◆ trace()

std::string taraxa::final_chain::FinalChain::trace ( std::vector< state_api::EVMTransaction trx,
EthBlockNumber  blk_n,
std::optional< state_api::Tracing params = {} 
) const

Trace execution of a new message call immediately without creating a transactions on the block chain. That means that state would be reverted and not saved anywhere.

Parameters
trxsstd::vector<state_api::EVMTransaction> vector of transaction to trace
blk_nEthBlockNumber number of block we are getting state from
Returns
std::string

◆ transactionCount()

uint64_t taraxa::final_chain::FinalChain::transactionCount ( std::optional< EthBlockNumber n = {}) const

Method to get transactions count in block.

Parameters
nblock number
Returns
count of transactions in block

◆ transactionHashes()

std::shared_ptr< const TransactionHashes > taraxa::final_chain::FinalChain::transactionHashes ( std::optional< EthBlockNumber n = {}) const

Method to get all transaction hashes from the block.

Parameters
nEthBlockNumber
Returns
TransactionHashes list if transaction hashes

◆ transactionLocation()

std::optional< TransactionLocation > taraxa::final_chain::FinalChain::transactionLocation ( h256 const &  trx_hash) const

Method to get transaction location by hash.

Parameters
trx_hashhash of transaction to get location for
Returns
std::optional<TransactionLocation> transaction location or nullopt

◆ transactionReceipt()

std::optional< TransactionReceipt > taraxa::final_chain::FinalChain::transactionReceipt ( h256 const &  _transactionHash) const

Method to get transaction receipt by hash.

Parameters
_transactionHashhash of transaction to get receipt for
Returns
std::optional<TransactionReceipt> transaction receipt or nullopt

◆ transactions()

const SharedTransactions taraxa::final_chain::FinalChain::transactions ( std::optional< EthBlockNumber n = {}) const

Method to get all transactions from the block.

Parameters
nEthBlockNumber
Returns
SharedTransactions vector of shared_ptrs to Transaction

◆ updateStateConfig()

void taraxa::final_chain::FinalChain::updateStateConfig ( const state_api::Config new_config)

Needed if we are changing params with hardfork and it affects Go part of code. For example DPOS contract.

Parameters
new_configstate_api::Config

◆ waitForFinalized()

void taraxa::final_chain::FinalChain::waitForFinalized ( )

Wait until next block is finalized.

◆ withBlockBloom() [1/2]

std::vector< EthBlockNumber > taraxa::final_chain::FinalChain::withBlockBloom ( const LogBloom b,
EthBlockNumber  from,
EthBlockNumber  to,
EthBlockNumber  level,
EthBlockNumber  index 
) const
private

◆ withBlockBloom() [2/2]

std::vector< EthBlockNumber > taraxa::final_chain::FinalChain::withBlockBloom ( LogBloom const &  b,
EthBlockNumber  from,
EthBlockNumber  to 
) const

Method used to search for contract logs with bloom filter.

Parameters
bLogBloom
fromEthBlockNumber block to start search
toEthBlockNumber block to end search
Returns
block that matches specified bloom filter

Member Data Documentation

◆ accounts_cache_

MapByBlockCache<addr_t, std::optional<const state_api::Account> > taraxa::final_chain::FinalChain::accounts_cache_
private

◆ block_applying_

decltype(block_applying_emitter_) ::Subscriber const& taraxa::final_chain::FinalChain::block_applying_ = block_applying_emitter_

◆ block_applying_emitter_

util::EventEmitter<uint64_t> const taraxa::final_chain::FinalChain::block_applying_emitter_ {}
protected

◆ block_finalized_

decltype(block_finalized_emitter_) ::Subscriber const& taraxa::final_chain::FinalChain::block_finalized_ = block_finalized_emitter_

◆ block_finalized_emitter_

util::EventEmitter<std::shared_ptr<FinalizationResult> > const taraxa::final_chain::FinalChain::block_finalized_emitter_ {}
protected

◆ block_hashes_cache_

ValueByBlockCache<std::optional<const h256> > taraxa::final_chain::FinalChain::block_hashes_cache_
private

◆ block_headers_cache_

ValueByBlockCache<std::shared_ptr<const BlockHeader> > taraxa::final_chain::FinalChain::block_headers_cache_
private

◆ db_

std::shared_ptr<DbStorage> taraxa::final_chain::FinalChain::db_
private

◆ delegation_delay_

EthBlockNumber taraxa::final_chain::FinalChain::delegation_delay_
private

◆ dpos_is_eligible_cache_

MapByBlockCache<addr_t, uint64_t> taraxa::final_chain::FinalChain::dpos_is_eligible_cache_
private

◆ dpos_vote_count_cache_

MapByBlockCache<addr_t, uint64_t> taraxa::final_chain::FinalChain::dpos_vote_count_cache_
private

◆ executor_thread_

boost::asio::thread_pool taraxa::final_chain::FinalChain::executor_thread_ {1}
private

◆ finalized_cv_

std::condition_variable taraxa::final_chain::FinalChain::finalized_cv_
private

◆ finalized_mtx_

std::mutex taraxa::final_chain::FinalChain::finalized_mtx_
private

◆ kBlockGasLimit

const uint64_t taraxa::final_chain::FinalChain::kBlockGasLimit
private

◆ kConfig

const FullNodeConfig& taraxa::final_chain::FinalChain::kConfig
private

◆ kLightNode

const bool taraxa::final_chain::FinalChain::kLightNode = false
private

◆ kMaxLevelsPerPeriod

const uint32_t taraxa::final_chain::FinalChain::kMaxLevelsPerPeriod
private

◆ last_block_number_

std::atomic<EthBlockNumber> taraxa::final_chain::FinalChain::last_block_number_
private

◆ num_executed_dag_blk_

std::atomic<uint64_t> taraxa::final_chain::FinalChain::num_executed_dag_blk_ = 0
private

◆ num_executed_trx_

std::atomic<uint64_t> taraxa::final_chain::FinalChain::num_executed_trx_ = 0
private

◆ rewards_

rewards::Stats taraxa::final_chain::FinalChain::rewards_
private

◆ state_api_

StateAPI taraxa::final_chain::FinalChain::state_api_
private

◆ total_vote_count_cache_

ValueByBlockCache<uint64_t> taraxa::final_chain::FinalChain::total_vote_count_cache_
private

◆ transaction_hashes_cache_

ValueByBlockCache<std::shared_ptr<const TransactionHashes> > taraxa::final_chain::FinalChain::transaction_hashes_cache_
private

◆ transactions_cache_

ValueByBlockCache<const SharedTransactions> taraxa::final_chain::FinalChain::transactions_cache_
private

◆ taraxa::state_api::StateAPI

class taraxa::state_api::StateAPI
Collaboration diagram for taraxa::state_api::StateAPI:

Public Member Functions

 StateAPI (std::function< h256(EthBlockNumber)> get_blk_hash, const Config &state_config, const Opts &opts, const OptsDB &opts_db)
 
 ~StateAPI ()
 
 StateAPI (const StateAPI &)=default
 
 StateAPI (StateAPI &&)=default
 
StateAPIoperator= (const StateAPI &)=default
 
StateAPIoperator= (StateAPI &&)=default
 
void update_state_config (const Config &new_config)
 
std::optional< Accountget_account (EthBlockNumber blk_num, const addr_t &addr) const
 
h256 get_account_storage (EthBlockNumber blk_num, const addr_t &addr, const u256 &key) const
 
bytes get_code_by_address (EthBlockNumber blk_num, const addr_t &addr) const
 
ExecutionResult dry_run_transaction (EthBlockNumber blk_num, const EVMBlock &blk, const EVMTransaction &trx) const
 
bytes trace (EthBlockNumber blk_num, const EVMBlock &blk, const std::vector< EVMTransaction > trx, std::optional< Tracing > params={}) const
 
StateDescriptor get_last_committed_state_descriptor () const
 
const TransactionsExecutionResultexecute_transactions (const EVMBlock &block, const std::vector< EVMTransaction > &transactions)
 
const RewardsDistributionResultdistribute_rewards (const std::vector< rewards::BlockStats > &rewards_stats)
 
void transition_state_commit ()
 
void create_snapshot (PbftPeriod period)
 
void prune (const std::vector< dev::h256 > &state_root_to_keep, EthBlockNumber blk_num)
 
uint64_t dpos_eligible_total_vote_count (EthBlockNumber blk_num) const
 
uint64_t dpos_eligible_vote_count (EthBlockNumber blk_num, const addr_t &addr) const
 
bool dpos_is_eligible (EthBlockNumber blk_num, const addr_t &addr) const
 
u256 get_staking_balance (EthBlockNumber blk_num, const addr_t &addr) const
 
vrf_wrapper::vrf_pk_t dpos_get_vrf_key (EthBlockNumber blk_num, const addr_t &addr) const
 
std::vector< ValidatorStakedpos_validators_total_stakes (EthBlockNumber blk_num) const
 
std::vector< ValidatorVoteCountdpos_validators_vote_counts (EthBlockNumber blk_num) const
 
uint64_t dpos_yield (EthBlockNumber blk_num) const
 
u256 dpos_total_supply (EthBlockNumber blk_num) const
 
u256 dpos_total_amount_delegated (EthBlockNumber blk_num) const
 

Private Attributes

std::function< h256(EthBlockNumber)> get_blk_hash_
 
taraxa_evm_GetBlockHash get_blk_hash_c_
 
taraxa_evm_state_API_ptr this_c_
 
dev::RLPStream rlp_enc_execution_result_
 
TransactionsExecutionResult result_buf_execution_result_
 
dev::RLPStream rlp_enc_rewards_distribution_
 
RewardsDistributionResult result_buf_rewards_distribution_
 
string db_path_
 

Constructor & Destructor Documentation

◆ StateAPI() [1/3]

taraxa::state_api::StateAPI::StateAPI ( std::function< h256(EthBlockNumber)>  get_blk_hash,
const Config state_config,
const Opts opts,
const OptsDB opts_db 
)

◆ ~StateAPI()

taraxa::state_api::StateAPI::~StateAPI ( )

◆ StateAPI() [2/3]

taraxa::state_api::StateAPI::StateAPI ( const StateAPI )
default

◆ StateAPI() [3/3]

taraxa::state_api::StateAPI::StateAPI ( StateAPI &&  )
default

Member Function Documentation

◆ create_snapshot()

void taraxa::state_api::StateAPI::create_snapshot ( PbftPeriod  period)

◆ distribute_rewards()

const RewardsDistributionResult & taraxa::state_api::StateAPI::distribute_rewards ( const std::vector< rewards::BlockStats > &  rewards_stats)

◆ dpos_eligible_total_vote_count()

uint64_t taraxa::state_api::StateAPI::dpos_eligible_total_vote_count ( EthBlockNumber  blk_num) const

◆ dpos_eligible_vote_count()

uint64_t taraxa::state_api::StateAPI::dpos_eligible_vote_count ( EthBlockNumber  blk_num,
const addr_t addr 
) const

◆ dpos_get_vrf_key()

vrf_wrapper::vrf_pk_t taraxa::state_api::StateAPI::dpos_get_vrf_key ( EthBlockNumber  blk_num,
const addr_t addr 
) const

◆ dpos_is_eligible()

bool taraxa::state_api::StateAPI::dpos_is_eligible ( EthBlockNumber  blk_num,
const addr_t addr 
) const

◆ dpos_total_amount_delegated()

u256 taraxa::state_api::StateAPI::dpos_total_amount_delegated ( EthBlockNumber  blk_num) const

◆ dpos_total_supply()

u256 taraxa::state_api::StateAPI::dpos_total_supply ( EthBlockNumber  blk_num) const

◆ dpos_validators_total_stakes()

std::vector< ValidatorStake > taraxa::state_api::StateAPI::dpos_validators_total_stakes ( EthBlockNumber  blk_num) const

◆ dpos_validators_vote_counts()

std::vector< ValidatorVoteCount > taraxa::state_api::StateAPI::dpos_validators_vote_counts ( EthBlockNumber  blk_num) const

◆ dpos_yield()

uint64_t taraxa::state_api::StateAPI::dpos_yield ( EthBlockNumber  blk_num) const

◆ dry_run_transaction()

ExecutionResult taraxa::state_api::StateAPI::dry_run_transaction ( EthBlockNumber  blk_num,
const EVMBlock blk,
const EVMTransaction trx 
) const

◆ execute_transactions()

const TransactionsExecutionResult & taraxa::state_api::StateAPI::execute_transactions ( const EVMBlock block,
const std::vector< EVMTransaction > &  transactions 
)

◆ get_account()

std::optional< Account > taraxa::state_api::StateAPI::get_account ( EthBlockNumber  blk_num,
const addr_t addr 
) const

◆ get_account_storage()

h256 taraxa::state_api::StateAPI::get_account_storage ( EthBlockNumber  blk_num,
const addr_t addr,
const u256 key 
) const

◆ get_code_by_address()

bytes taraxa::state_api::StateAPI::get_code_by_address ( EthBlockNumber  blk_num,
const addr_t addr 
) const

◆ get_last_committed_state_descriptor()

StateDescriptor taraxa::state_api::StateAPI::get_last_committed_state_descriptor ( ) const

◆ get_staking_balance()

u256 taraxa::state_api::StateAPI::get_staking_balance ( EthBlockNumber  blk_num,
const addr_t addr 
) const

◆ operator=() [1/2]

StateAPI& taraxa::state_api::StateAPI::operator= ( const StateAPI )
default

◆ operator=() [2/2]

StateAPI& taraxa::state_api::StateAPI::operator= ( StateAPI &&  )
default

◆ prune()

void taraxa::state_api::StateAPI::prune ( const std::vector< dev::h256 > &  state_root_to_keep,
EthBlockNumber  blk_num 
)

◆ trace()

bytes taraxa::state_api::StateAPI::trace ( EthBlockNumber  blk_num,
const EVMBlock blk,
const std::vector< EVMTransaction trx,
std::optional< Tracing params = {} 
) const

◆ transition_state_commit()

void taraxa::state_api::StateAPI::transition_state_commit ( )

◆ update_state_config()

void taraxa::state_api::StateAPI::update_state_config ( const Config new_config)

Member Data Documentation

◆ db_path_

string taraxa::state_api::StateAPI::db_path_
private

◆ get_blk_hash_

std::function<h256(EthBlockNumber)> taraxa::state_api::StateAPI::get_blk_hash_
private

◆ get_blk_hash_c_

taraxa_evm_GetBlockHash taraxa::state_api::StateAPI::get_blk_hash_c_
private

◆ result_buf_execution_result_

TransactionsExecutionResult taraxa::state_api::StateAPI::result_buf_execution_result_
private

◆ result_buf_rewards_distribution_

RewardsDistributionResult taraxa::state_api::StateAPI::result_buf_rewards_distribution_
private

◆ rlp_enc_execution_result_

dev::RLPStream taraxa::state_api::StateAPI::rlp_enc_execution_result_
private

◆ rlp_enc_rewards_distribution_

dev::RLPStream taraxa::state_api::StateAPI::rlp_enc_rewards_distribution_
private

◆ this_c_

taraxa_evm_state_API_ptr taraxa::state_api::StateAPI::this_c_
private

◆ taraxa::state_api::TaraxaEVMError

struct taraxa::state_api::TaraxaEVMError
Collaboration diagram for taraxa::state_api::TaraxaEVMError:

Public Member Functions

 TaraxaEVMError (std::string &&type, const std::string &msg)
 

Public Attributes

std::string const type
 

Constructor & Destructor Documentation

◆ TaraxaEVMError()

taraxa::state_api::TaraxaEVMError::TaraxaEVMError ( std::string &&  type,
const std::string &  msg 
)

Member Data Documentation

◆ type

std::string const taraxa::state_api::TaraxaEVMError::type

◆ taraxa::state_api::ErrFutureBlock

struct taraxa::state_api::ErrFutureBlock
Collaboration diagram for taraxa::state_api::ErrFutureBlock:

Public Member Functions

 TaraxaEVMError (std::string &&type, const std::string &msg)
 
- Public Member Functions inherited from taraxa::state_api::TaraxaEVMError
 TaraxaEVMError (std::string &&type, const std::string &msg)
 

Additional Inherited Members

- Public Attributes inherited from taraxa::state_api::TaraxaEVMError
std::string const type
 

Member Function Documentation

◆ TaraxaEVMError()

taraxa::state_api::TaraxaEVMError::TaraxaEVMError

◆ taraxa::state_api::EVMBlock

struct taraxa::state_api::EVMBlock
Collaboration diagram for taraxa::state_api::EVMBlock:
Class Members
addr_t author
u256 difficulty
gas_t gas_limit
uint64_t time

◆ taraxa::state_api::EVMTransaction

struct taraxa::state_api::EVMTransaction
Collaboration diagram for taraxa::state_api::EVMTransaction:
Class Members
addr_t from
gas_t gas
u256 gas_price
bytes input
trx_nonce_t nonce
optional< addr_t > to
val_t value

◆ taraxa::state_api::UncleBlock

struct taraxa::state_api::UncleBlock
Collaboration diagram for taraxa::state_api::UncleBlock:
Class Members
addr_t author
EthBlockNumber number

◆ taraxa::state_api::LogRecord

struct taraxa::state_api::LogRecord
Collaboration diagram for taraxa::state_api::LogRecord:
Class Members
addr_t address
bytes data
vector< h256 > topics

◆ taraxa::state_api::ExecutionResult

struct taraxa::state_api::ExecutionResult
Collaboration diagram for taraxa::state_api::ExecutionResult:
Class Members
string code_err
bytes code_retval
string consensus_err
gas_t gas_used
vector< LogRecord > logs
addr_t new_contract_addr

◆ taraxa::state_api::TransactionsExecutionResult

struct taraxa::state_api::TransactionsExecutionResult
Class Members
vector< ExecutionResult > execution_results

◆ taraxa::state_api::RewardsDistributionResult

struct taraxa::state_api::RewardsDistributionResult
Collaboration diagram for taraxa::state_api::RewardsDistributionResult:
Class Members
h256 state_root
u256 total_reward

◆ taraxa::state_api::Account

struct taraxa::state_api::Account
Collaboration diagram for taraxa::state_api::Account:

Public Member Functions

HAS_RLP_FIELDS h256 const & storage_root_eth () const
 

Public Attributes

trx_nonce_t nonce = 0
 
u256 balance
 
h256 storage_root_hash
 
h256 code_hash
 
uint64_t code_size = 0
 

Member Function Documentation

◆ storage_root_eth()

h256 const & taraxa::state_api::Account::storage_root_eth ( ) const

Member Data Documentation

◆ balance

u256 taraxa::state_api::Account::balance

◆ code_hash

h256 taraxa::state_api::Account::code_hash

◆ code_size

uint64_t taraxa::state_api::Account::code_size = 0

◆ nonce

trx_nonce_t taraxa::state_api::Account::nonce = 0

◆ storage_root_hash

h256 taraxa::state_api::Account::storage_root_hash

◆ taraxa::state_api::StateDescriptor

struct taraxa::state_api::StateDescriptor
Collaboration diagram for taraxa::state_api::StateDescriptor:
Class Members
EthBlockNumber blk_num
h256 state_root

◆ taraxa::state_api::Tracing

struct taraxa::state_api::Tracing
Class Members
bool stateDiff
bool trace
bool vmTrace

◆ taraxa::state_api::ValidatorStake

struct taraxa::state_api::ValidatorStake
Collaboration diagram for taraxa::state_api::ValidatorStake:
Class Members
addr_t addr
u256 stake

◆ taraxa::state_api::ValidatorVoteCount

struct taraxa::state_api::ValidatorVoteCount
Collaboration diagram for taraxa::state_api::ValidatorVoteCount:
Class Members
addr_t addr
uint64_t vote_count

Typedef Documentation

◆ BlocksBlooms

◆ LogBloom

◆ LogBlooms

using taraxa::final_chain::LogBlooms = typedef std::vector<LogBloom>

◆ LogEntries

using taraxa::final_chain::LogEntries = typedef std::vector<LogEntry>

◆ Nonce

◆ TransactionReceipts

Variable Documentation

◆ c_bloomIndexLevels

constexpr auto taraxa::final_chain::c_bloomIndexLevels = 2
staticconstexpr

◆ c_bloomIndexSize

constexpr auto taraxa::final_chain::c_bloomIndexSize = 16
staticconstexpr

◆ ZeroAccount

struct taraxa::state_api::Account taraxa::state_api::ZeroAccount