TARAXA
|
Classes | |
class | taraxa::Dag |
Thread safe. Labelled graph. More... | |
class | taraxa::PivotTree |
class | taraxa::vertex_label_writer< Property1 > |
class | taraxa::edge_label_writer< Property > |
class | taraxa::DagBlockProposer |
DagBlockProposer class proposes new DAG blocks using transactions retrieved from TransactionManager. More... | |
class | taraxa::DagManager |
DagManager class contains in memory representation of part of the DAG that is not yet finalized in a pbft block and validates DAG blocks. More... | |
struct | taraxa::SortitionParamsChange |
Changing vrf params for DAG blocks generation. More... | |
class | taraxa::SortitionParamsManager |
SortitionParamsManager class calculates DAG efficiency and makes VDF difficulty adjustments. More... | |
Functions | |
dev::bytes | taraxa::encodeDAGBlocksBundleRlp (const std::vector< DagBlock > &blocks) |
Encodes pbft blocks into optimized blocks bundle rlp. More... | |
std::vector< DagBlock > | taraxa::decodeDAGBlocksBundleRlp (const dev::RLP &blocks_bundle_rlp) |
Decodes pbft blocks from optimized blocks bundle rlp. More... | |
std::shared_ptr< DagBlock > | taraxa::decodeDAGBlockBundleRlp (uint64_t index, const dev::RLP &blocks_bundle_rlp) |
Decodes single dag block from optimized blocks bundle rlp. More... | |
Variables | |
constexpr static size_t | taraxa::kDAGBlocksBundleRlpSize {3} |
class taraxa::Dag |
Thread safe. Labelled graph.
Public Types | |
using | vertex_property_t = boost::property< boost::vertex_index_t, blk_hash_t, boost::property< boost::vertex_index1_t, uint64_t > > |
using | edge_property_t = boost::property< boost::edge_index_t, uint64_t > |
using | adj_list_t = boost::adjacency_list< boost::setS, boost::hash_setS, boost::directedS, vertex_property_t, edge_property_t > |
using | graph_t = boost::labeled_graph< adj_list_t, blk_hash_t, boost::hash_mapS > |
using | vertex_t = boost::graph_traits< graph_t >::vertex_descriptor |
using | edge_t = boost::graph_traits< graph_t >::edge_descriptor |
using | vertex_iter_t = boost::graph_traits< graph_t >::vertex_iterator |
using | edge_iter_t = boost::graph_traits< graph_t >::edge_iterator |
using | vertex_adj_iter_t = boost::graph_traits< graph_t >::adjacency_iterator |
using | vertex_index_map_const_t = boost::property_map< graph_t, boost::vertex_index_t >::const_type |
using | vertex_index_map_t = boost::property_map< graph_t, boost::vertex_index_t >::type |
using | vertex_period_map_const_t = boost::property_map< graph_t, boost::vertex_index1_t >::const_type |
using | vertex_period_map_t = boost::property_map< graph_t, boost::vertex_index1_t >::type |
using | edge_index_map_const_t = boost::property_map< graph_t, boost::edge_index_t >::const_type |
using | edge_index_map_t = boost::property_map< graph_t, boost::edge_index_t >::type |
Public Member Functions | |
Dag (blk_hash_t const &dag_genesis_block_hash, addr_t node_addr) | |
virtual | ~Dag ()=default |
Dag (const Dag &)=default | |
Dag (Dag &&)=default | |
Dag & | operator= (const Dag &)=default |
Dag & | operator= (Dag &&)=default |
uint64_t | getNumVertices () const |
uint64_t | getNumEdges () const |
bool | hasVertex (blk_hash_t const &v) const |
bool | addVEEs (blk_hash_t const &new_vertex, blk_hash_t const &pivot, std::vector< blk_hash_t > const &tips) |
void | getLeaves (std::vector< blk_hash_t > &tips) const |
void | drawGraph (std::string const &filename) const |
bool | computeOrder (const blk_hash_t &anchor, std::vector< blk_hash_t > &ordered_period_vertices, const std::map< uint64_t, std::unordered_set< blk_hash_t >> &non_finalized_blks) |
void | clear () |
Public Attributes | |
friend | DagManager |
Protected Member Functions | |
bool | reachable (vertex_t const &from, vertex_t const &to) const |
void | collectLeafVertices (std::vector< vertex_t > &leaves) const |
Protected Attributes | |
graph_t | graph_ |
using taraxa::Dag::adj_list_t = boost::adjacency_list<boost::setS, boost::hash_setS, boost::directedS, vertex_property_t, edge_property_t> |
using taraxa::Dag::edge_index_map_const_t = boost::property_map<graph_t, boost::edge_index_t>::const_type |
using taraxa::Dag::edge_index_map_t = boost::property_map<graph_t, boost::edge_index_t>::type |
using taraxa::Dag::edge_iter_t = boost::graph_traits<graph_t>::edge_iterator |
using taraxa::Dag::edge_property_t = boost::property<boost::edge_index_t, uint64_t> |
using taraxa::Dag::edge_t = boost::graph_traits<graph_t>::edge_descriptor |
using taraxa::Dag::graph_t = boost::labeled_graph<adj_list_t, blk_hash_t, boost::hash_mapS> |
using taraxa::Dag::vertex_adj_iter_t = boost::graph_traits<graph_t>::adjacency_iterator |
using taraxa::Dag::vertex_index_map_const_t = boost::property_map<graph_t, boost::vertex_index_t>::const_type |
using taraxa::Dag::vertex_index_map_t = boost::property_map<graph_t, boost::vertex_index_t>::type |
using taraxa::Dag::vertex_iter_t = boost::graph_traits<graph_t>::vertex_iterator |
using taraxa::Dag::vertex_period_map_const_t = boost::property_map<graph_t, boost::vertex_index1_t>::const_type |
using taraxa::Dag::vertex_period_map_t = boost::property_map<graph_t, boost::vertex_index1_t>::type |
using taraxa::Dag::vertex_property_t = boost::property<boost::vertex_index_t, blk_hash_t, boost::property<boost::vertex_index1_t, uint64_t> > |
using taraxa::Dag::vertex_t = boost::graph_traits<graph_t>::vertex_descriptor |
|
explicit |
|
virtualdefault |
|
default |
|
default |
bool taraxa::Dag::addVEEs | ( | blk_hash_t const & | new_vertex, |
blk_hash_t const & | pivot, | ||
std::vector< blk_hash_t > const & | tips | ||
) |
void taraxa::Dag::clear | ( | ) |
|
protected |
bool taraxa::Dag::computeOrder | ( | const blk_hash_t & | anchor, |
std::vector< blk_hash_t > & | ordered_period_vertices, | ||
const std::map< uint64_t, std::unordered_set< blk_hash_t >> & | non_finalized_blks | ||
) |
void taraxa::Dag::drawGraph | ( | std::string const & | filename | ) | const |
void taraxa::Dag::getLeaves | ( | std::vector< blk_hash_t > & | tips | ) | const |
uint64_t taraxa::Dag::getNumEdges | ( | ) | const |
uint64_t taraxa::Dag::getNumVertices | ( | ) | const |
bool taraxa::Dag::hasVertex | ( | blk_hash_t const & | v | ) | const |
friend taraxa::Dag::DagManager |
|
protected |
class taraxa::PivotTree |
PivotTree is a special DAG, every vertex only has one out-edge, therefore, there is no convergent tree
Public Types | |
using | vertex_adj_iter_t = boost::graph_traits< graph_t >::adjacency_iterator |
using | vertex_index_map_const_t = boost::property_map< graph_t, boost::vertex_index_t >::const_type |
using | vertex_t = boost::graph_traits< graph_t >::vertex_descriptor |
Public Types inherited from taraxa::Dag | |
using | vertex_property_t = boost::property< boost::vertex_index_t, blk_hash_t, boost::property< boost::vertex_index1_t, uint64_t > > |
using | edge_property_t = boost::property< boost::edge_index_t, uint64_t > |
using | adj_list_t = boost::adjacency_list< boost::setS, boost::hash_setS, boost::directedS, vertex_property_t, edge_property_t > |
using | graph_t = boost::labeled_graph< adj_list_t, blk_hash_t, boost::hash_mapS > |
using | vertex_t = boost::graph_traits< graph_t >::vertex_descriptor |
using | edge_t = boost::graph_traits< graph_t >::edge_descriptor |
using | vertex_iter_t = boost::graph_traits< graph_t >::vertex_iterator |
using | edge_iter_t = boost::graph_traits< graph_t >::edge_iterator |
using | vertex_adj_iter_t = boost::graph_traits< graph_t >::adjacency_iterator |
using | vertex_index_map_const_t = boost::property_map< graph_t, boost::vertex_index_t >::const_type |
using | vertex_index_map_t = boost::property_map< graph_t, boost::vertex_index_t >::type |
using | vertex_period_map_const_t = boost::property_map< graph_t, boost::vertex_index1_t >::const_type |
using | vertex_period_map_t = boost::property_map< graph_t, boost::vertex_index1_t >::type |
using | edge_index_map_const_t = boost::property_map< graph_t, boost::edge_index_t >::const_type |
using | edge_index_map_t = boost::property_map< graph_t, boost::edge_index_t >::type |
Public Member Functions | |
PivotTree (blk_hash_t const &dag_genesis_block_hash, addr_t node_addr) | |
virtual | ~PivotTree ()=default |
PivotTree (const PivotTree &)=default | |
PivotTree (PivotTree &&)=default | |
PivotTree & | operator= (const PivotTree &)=default |
PivotTree & | operator= (PivotTree &&)=default |
std::vector< blk_hash_t > | getGhostPath (const blk_hash_t &vertex) const |
Public Member Functions inherited from taraxa::Dag | |
Dag (blk_hash_t const &dag_genesis_block_hash, addr_t node_addr) | |
virtual | ~Dag ()=default |
Dag (const Dag &)=default | |
Dag (Dag &&)=default | |
Dag & | operator= (const Dag &)=default |
Dag & | operator= (Dag &&)=default |
uint64_t | getNumVertices () const |
uint64_t | getNumEdges () const |
bool | hasVertex (blk_hash_t const &v) const |
bool | addVEEs (blk_hash_t const &new_vertex, blk_hash_t const &pivot, std::vector< blk_hash_t > const &tips) |
void | getLeaves (std::vector< blk_hash_t > &tips) const |
void | drawGraph (std::string const &filename) const |
bool | computeOrder (const blk_hash_t &anchor, std::vector< blk_hash_t > &ordered_period_vertices, const std::map< uint64_t, std::unordered_set< blk_hash_t >> &non_finalized_blks) |
void | clear () |
Public Attributes | |
friend | DagManager |
Public Attributes inherited from taraxa::Dag | |
friend | DagManager |
Additional Inherited Members | |
Protected Member Functions inherited from taraxa::Dag | |
bool | reachable (vertex_t const &from, vertex_t const &to) const |
void | collectLeafVertices (std::vector< vertex_t > &leaves) const |
Protected Attributes inherited from taraxa::Dag | |
graph_t | graph_ |
using taraxa::Dag::vertex_adj_iter_t = boost::graph_traits<graph_t>::adjacency_iterator |
using taraxa::Dag::vertex_index_map_const_t = boost::property_map<graph_t, boost::vertex_index_t>::const_type |
using taraxa::Dag::vertex_t = boost::graph_traits<graph_t>::vertex_descriptor |
|
inlineexplicit |
|
virtualdefault |
|
default |
|
default |
std::vector< blk_hash_t > taraxa::PivotTree::getGhostPath | ( | const blk_hash_t & | vertex | ) | const |
Iterative version Steps rounds
friend taraxa::PivotTree::DagManager |
class taraxa::vertex_label_writer |
Public Member Functions | |
vertex_label_writer (Property1 name) | |
template<class Vertex > | |
void | operator() (std::ostream &out, const Vertex &v) const |
Private Attributes | |
Property1 | name |
|
inline |
|
inline |
|
private |
class taraxa::edge_label_writer |
Public Member Functions | |
edge_label_writer (Property weight) | |
template<class Edge > | |
void | operator() (std::ostream &out, const Edge &e) const |
Private Attributes | |
Property | weight |
|
inlineexplicit |
|
inline |
|
private |
class taraxa::DagBlockProposer |
DagBlockProposer class proposes new DAG blocks using transactions retrieved from TransactionManager.
Class is running a proposer thread which will try to propose DAG blocks if eligible to propose. Dag block proposal consists of calculating VDF if required. VDF calculation is asynchronous and it is interrupted if another node on the network has produced a valid block at the same level. Proposal includes stale block proposal in case no block is produced on the network for extended period of time.
Public Member Functions | |
DagBlockProposer (const FullNodeConfig &config, std::shared_ptr< DagManager > dag_mgr, std::shared_ptr< TransactionManager > trx_mgr, std::shared_ptr< final_chain::FinalChain > final_chain, std::shared_ptr< DbStorage > db, std::shared_ptr< KeyManager > key_manager) | |
~DagBlockProposer () | |
DagBlockProposer (const DagBlockProposer &)=delete | |
DagBlockProposer (DagBlockProposer &&)=delete | |
DagBlockProposer & | operator= (const DagBlockProposer &)=delete |
DagBlockProposer & | operator= (DagBlockProposer &&)=delete |
void | start () |
Start the worker thread proposing new DAG blocks. More... | |
void | stop () |
Stop the worker thread. More... | |
bool | proposeDagBlock () |
Tries to propose new dag block. More... | |
void | setNetwork (std::weak_ptr< Network > network) |
Sets network. More... | |
uint64_t | getProposedBlocksCount () const |
vec_blk_t | selectDagBlockTips (const vec_blk_t &frontier_tips, uint64_t gas_limit) const |
Select tips for DagBlock proposal up to max allowed. More... | |
Private Member Functions | |
DagBlock | createDagBlock (DagFrontier &&frontier, level_t level, const SharedTransactions &trxs, std::vector< uint64_t > &&estimations, VdfSortition &&vdf) const |
Creates a new block with provided data. More... | |
std::pair< SharedTransactions, std::vector< uint64_t > > | getShardedTrxs (PbftPeriod proposal_period, uint64_t weight_limit) const |
Gets transactions to include in the block - sharding not supported yet. More... | |
level_t | getProposeLevel (blk_hash_t const &pivot, vec_blk_t const &tips) const |
Gets current propose level for provided pivot and tips. More... | |
bool | isValidDposProposer (PbftPeriod propose_period) const |
Checks if node is valid proposer for provided level. More... | |
Private Attributes | |
uint16_t | max_num_tries_ {20} |
uint16_t | num_tries_ {0} |
uint64_t | last_propose_level_ {0} |
util::ThreadPool | executor_ {1} |
std::atomic< uint64_t > | proposed_blocks_count_ {0} |
std::atomic< bool > | stopped_ {true} |
const DagBlockProposerConfig | bp_config_ |
const uint16_t | total_trx_shards_ |
uint16_t | my_trx_shard_ |
std::shared_ptr< DagManager > | dag_mgr_ |
std::shared_ptr< TransactionManager > | trx_mgr_ |
std::shared_ptr< final_chain::FinalChain > | final_chain_ |
std::shared_ptr< KeyManager > | key_manager_ |
std::shared_ptr< DbStorage > | db_ |
std::shared_ptr< std::thread > | proposer_worker_ |
std::weak_ptr< Network > | network_ |
const addr_t | node_addr_ |
const secret_t | node_sk_ |
const vrf_wrapper::vrf_sk_t | vrf_sk_ |
const vrf_wrapper::vrf_pk_t | vrf_pk_ |
const uint64_t | kPbftGasLimit |
const uint64_t | kDagGasLimit |
const HardforksConfig | kHardforks |
const uint64_t | kValidatorMaxVote |
taraxa::DagBlockProposer::DagBlockProposer | ( | const FullNodeConfig & | config, |
std::shared_ptr< DagManager > | dag_mgr, | ||
std::shared_ptr< TransactionManager > | trx_mgr, | ||
std::shared_ptr< final_chain::FinalChain > | final_chain, | ||
std::shared_ptr< DbStorage > | db, | ||
std::shared_ptr< KeyManager > | key_manager | ||
) |
|
inline |
|
delete |
|
delete |
|
private |
Creates a new block with provided data.
frontier | frontier to use for pivot and tips of the new block |
level | level of the new block |
trxs | transactions to be included in the block |
estimations | transactions gas estimation |
vdf | vdf with correct difficulty calculation |
|
inline |
|
private |
Gets current propose level for provided pivot and tips.
pivot | pivot block hash |
tips | tips blocks hashes |
|
private |
Gets transactions to include in the block - sharding not supported yet.
proposal_period | proposal period |
weight_limit | weight limit |
|
private |
Checks if node is valid proposer for provided level.
level | level of the new block |
|
delete |
|
delete |
bool taraxa::DagBlockProposer::proposeDagBlock | ( | ) |
Tries to propose new dag block.
vec_blk_t taraxa::DagBlockProposer::selectDagBlockTips | ( | const vec_blk_t & | frontier_tips, |
uint64_t | gas_limit | ||
) | const |
Select tips for DagBlock proposal up to max allowed.
frontier_tips | |
gas_limit | gas limit for the tips |
void taraxa::DagBlockProposer::setNetwork | ( | std::weak_ptr< Network > | network | ) |
Sets network.
network |
void taraxa::DagBlockProposer::start | ( | ) |
Start the worker thread proposing new DAG blocks.
void taraxa::DagBlockProposer::stop | ( | ) |
Stop the worker thread.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
class taraxa::DagManager |
DagManager class contains in memory representation of part of the DAG that is not yet finalized in a pbft block and validates DAG blocks.
DagManager validates incoming dag blocks and provides ordering of non-finalized DAG block with getDagOrder method. Once a pbft block is finalized setDagBlockOrder is invoked which removes all the finalized DAG blocks from in memory DAG. DagManager class is thread safe in general with exception of function setDagBlockOrder. See details in function descriptions.
Public Types | |
enum class | VerifyBlockReturnType : uint32_t { Verified = 0 , MissingTransaction , AheadBlock , FailedVdfVerification , FutureBlock , NotEligible , ExpiredBlock , IncorrectTransactionsEstimation , BlockTooBig , FailedTipsVerification , MissingTip } |
return type of verifyBlock More... | |
Public Member Functions | |
DagManager (const FullNodeConfig &config, addr_t node_addr, std::shared_ptr< TransactionManager > trx_mgr, std::shared_ptr< PbftChain > pbft_chain, std::shared_ptr< final_chain::FinalChain > final_chain, std::shared_ptr< DbStorage > db, std::shared_ptr< KeyManager > key_manager) | |
DagManager (const DagManager &)=delete | |
DagManager (DagManager &&)=delete | |
DagManager & | operator= (const DagManager &)=delete |
DagManager & | operator= (DagManager &&)=delete |
std::shared_ptr< DagManager > | getShared () |
void | setNetwork (std::weak_ptr< Network > network) |
bool | isDagBlockKnown (const blk_hash_t &hash) const |
std::shared_ptr< DagBlock > | getDagBlock (const blk_hash_t &hash) const |
Gets dag block from either local memory cache or db. More... | |
std::pair< VerifyBlockReturnType, SharedTransactions > | verifyBlock (const DagBlock &blk, const std::unordered_map< trx_hash_t, std::shared_ptr< Transaction >> &trxs={}) |
Verifies new DAG block. More... | |
std::pair< bool, std::vector< blk_hash_t > > | pivotAndTipsAvailable (DagBlock const &blk) |
Checks if block pivot and tips are in DAG. More... | |
std::pair< bool, std::vector< blk_hash_t > > | addDagBlock (DagBlock &&blk, SharedTransactions &&trxs={}, bool proposed=false, bool save=true) |
adds verified DAG block in the DAG More... | |
vec_blk_t | getDagBlockOrder (blk_hash_t const &anchor, PbftPeriod period) |
Retrieves DAG block order for specified anchor. Order should always be the same for the same anchor in the same period. More... | |
uint | setDagBlockOrder (blk_hash_t const &anchor, PbftPeriod period, vec_blk_t const &dag_order) |
Sets the dag block order on finalizing PBFT block IMPORTANT: This method is invoked on finalizing a pbft block, it needs to be protected with mutex_ but the mutex is locked from pbft manager for the entire pbft finalization to make the finalization atomic. More... | |
std::optional< std::pair< blk_hash_t, std::vector< blk_hash_t > > > | getLatestPivotAndTips () const |
std::vector< blk_hash_t > | getGhostPath (const blk_hash_t &source) const |
Retrieves ghost path which is ordered list of non finalized pivot blocks for a specific source block. More... | |
std::vector< blk_hash_t > | getGhostPath () const |
Retrieves ghost path which is ordered list of non finalized pivot blocks for last anchor. More... | |
void | drawTotalGraph (std::string const &str) const |
void | drawPivotGraph (std::string const &str) const |
void | drawGraph (std::string const &dotfile) const |
std::pair< uint64_t, uint64_t > | getNumVerticesInDag () const |
std::pair< uint64_t, uint64_t > | getNumEdgesInDag () const |
level_t | getMaxLevel () const |
PbftPeriod | getLatestPeriod () const |
std::pair< blk_hash_t, blk_hash_t > | getAnchors () const |
uint32_t | getDagExpiryLimit () const |
Retrieves Dag expiry limit. More... | |
const std::pair< PbftPeriod, std::map< uint64_t, std::unordered_set< blk_hash_t > > > | getNonFinalizedBlocks () const |
const std::tuple< PbftPeriod, std::vector< std::shared_ptr< DagBlock > >, SharedTransactions > | getNonFinalizedBlocksWithTransactions (const std::unordered_set< blk_hash_t > &known_hashes) const |
Retrieves current period together with non finalized blocks with the unique list of non finalized transactions from these blocks. More... | |
DagFrontier | getDagFrontier () |
std::pair< size_t, size_t > | getNonFinalizedBlocksSize () const |
std::shared_mutex & | getDagMutex () |
Retrieves Dag Manager mutex, only to be used when finalizing pbft block. More... | |
SortitionParamsManager & | sortitionParamsManager () |
Retrieves sortition manager. More... | |
const DagConfig & | getDagConfig () const |
Retrieves Dag config. More... | |
uint64_t | getDagExpiryLevel () |
Retrieves Dag expiry level. More... | |
void | clearLightNodeHistory (uint64_t light_node_history) |
Clears light node history. More... | |
Static Public Member Functions | |
static dev::bytes | getVdfMessage (blk_hash_t const &hash, SharedTransactions const &trxs) |
Retrieves VDF message from block hash and transactions. More... | |
static dev::bytes | getVdfMessage (blk_hash_t const &hash, std::vector< trx_hash_t > const &trx_hashes) |
Retrieves VDF message from block hash and transactions. More... | |
Public Attributes | |
util::Event< DagManager, DagBlock > const | block_verified_ {} |
Private Member Functions | |
void | recoverDag () |
void | addToDag (blk_hash_t const &hash, blk_hash_t const &pivot, std::vector< blk_hash_t > const &tips, uint64_t level, bool finalized=false) |
bool | validateBlockNotExpired (const std::shared_ptr< DagBlock > &dag_block, std::unordered_map< blk_hash_t, std::shared_ptr< DagBlock >> &expired_dag_blocks_to_remove) |
void | handleExpiredDagBlocksTransactions (const std::vector< trx_hash_t > &transactions_from_expired_dag_blocks) const |
std::pair< blk_hash_t, std::vector< blk_hash_t > > | getFrontier () const |
void | updateFrontier () |
Private Attributes | |
std::atomic< level_t > | max_level_ = 0 |
std::shared_mutex | mutex_ |
std::shared_mutex | order_dag_blocks_mutex_ |
std::shared_ptr< PivotTree > | pivot_tree_ |
std::shared_ptr< Dag > | total_dag_ |
std::shared_ptr< TransactionManager > | trx_mgr_ |
std::shared_ptr< PbftChain > | pbft_chain_ |
std::weak_ptr< Network > | network_ |
std::shared_ptr< DbStorage > | db_ |
std::shared_ptr< KeyManager > | key_manager_ |
blk_hash_t | anchor_ |
blk_hash_t | old_anchor_ |
PbftPeriod | period_ |
std::map< uint64_t, std::unordered_set< blk_hash_t > > | non_finalized_blks_ |
DagFrontier | frontier_ |
SortitionParamsManager | sortition_params_manager_ |
const DagConfig & | dag_config_ |
const std::shared_ptr< DagBlock > | genesis_block_ |
const uint32_t | max_levels_per_period_ |
const uint32_t | dag_expiry_limit_ |
std::atomic_uint64_t | dag_expiry_level_ |
const uint32_t | cache_max_size_ = 10000 |
const uint32_t | cache_delete_step_ = 100 |
ExpirationCacheMap< blk_hash_t, DagBlock > | seen_blocks_ |
std::shared_ptr< final_chain::FinalChain > | final_chain_ |
const uint64_t | kPbftGasLimit |
const HardforksConfig | kHardforks |
const uint64_t | kValidatorMaxVote |
|
strong |
|
explicit |
|
delete |
|
delete |
std::pair< bool, std::vector< blk_hash_t > > taraxa::DagManager::addDagBlock | ( | DagBlock && | blk, |
SharedTransactions && | trxs = {} , |
||
bool | proposed = false , |
||
bool | save = true |
||
) |
adds verified DAG block in the DAG
trxs | Block transactions |
proposed | if this node proposed the block |
save | if true save block and transactions to database |
|
private |
void taraxa::DagManager::clearLightNodeHistory | ( | uint64_t | light_node_history | ) |
Clears light node history.
void taraxa::DagManager::drawGraph | ( | std::string const & | dotfile | ) | const |
void taraxa::DagManager::drawPivotGraph | ( | std::string const & | str | ) | const |
void taraxa::DagManager::drawTotalGraph | ( | std::string const & | str | ) | const |
|
inline |
std::shared_ptr< DagBlock > taraxa::DagManager::getDagBlock | ( | const blk_hash_t & | hash | ) | const |
Gets dag block from either local memory cache or db.
hash | Block hash |
std::vector< blk_hash_t > taraxa::DagManager::getDagBlockOrder | ( | blk_hash_t const & | anchor, |
PbftPeriod | period | ||
) |
Retrieves DAG block order for specified anchor. Order should always be the same for the same anchor in the same period.
anchor | anchor block |
period | period |
|
inline |
Retrieves Dag config.
|
inline |
Retrieves Dag expiry level.
|
inline |
Retrieves Dag expiry limit.
DagFrontier taraxa::DagManager::getDagFrontier | ( | ) |
|
inline |
Retrieves Dag Manager mutex, only to be used when finalizing pbft block.
|
private |
std::vector< blk_hash_t > taraxa::DagManager::getGhostPath | ( | ) | const |
Retrieves ghost path which is ordered list of non finalized pivot blocks for last anchor.
std::vector< blk_hash_t > taraxa::DagManager::getGhostPath | ( | const blk_hash_t & | source | ) | const |
Retrieves ghost path which is ordered list of non finalized pivot blocks for a specific source block.
source | source block |
|
inline |
std::optional< std::pair< blk_hash_t, std::vector< blk_hash_t > > > taraxa::DagManager::getLatestPivotAndTips | ( | ) | const |
|
inline |
const std::pair< PbftPeriod, std::map< uint64_t, std::unordered_set< blk_hash_t > > > taraxa::DagManager::getNonFinalizedBlocks | ( | ) | const |
std::pair< size_t, size_t > taraxa::DagManager::getNonFinalizedBlocksSize | ( | ) | const |
const std::tuple< PbftPeriod, std::vector< std::shared_ptr< DagBlock > >, SharedTransactions > taraxa::DagManager::getNonFinalizedBlocksWithTransactions | ( | const std::unordered_set< blk_hash_t > & | known_hashes | ) | const |
Retrieves current period together with non finalized blocks with the unique list of non finalized transactions from these blocks.
known_hashes | excludes known hashes from result |
std::pair< uint64_t, uint64_t > taraxa::DagManager::getNumEdgesInDag | ( | ) | const |
std::pair< uint64_t, uint64_t > taraxa::DagManager::getNumVerticesInDag | ( | ) | const |
std::shared_ptr< DagManager > taraxa::DagManager::getShared | ( | ) |
|
static |
Retrieves VDF message from block hash and transactions.
|
static |
Retrieves VDF message from block hash and transactions.
|
private |
bool taraxa::DagManager::isDagBlockKnown | ( | const blk_hash_t & | hash | ) | const |
hash |
|
delete |
|
delete |
std::pair< bool, std::vector< blk_hash_t > > taraxa::DagManager::pivotAndTipsAvailable | ( | DagBlock const & | blk | ) |
Checks if block pivot and tips are in DAG.
blk | Block to check |
|
private |
uint taraxa::DagManager::setDagBlockOrder | ( | blk_hash_t const & | anchor, |
PbftPeriod | period, | ||
vec_blk_t const & | dag_order | ||
) |
Sets the dag block order on finalizing PBFT block IMPORTANT: This method is invoked on finalizing a pbft block, it needs to be protected with mutex_ but the mutex is locked from pbft manager for the entire pbft finalization to make the finalization atomic.
anchor | Anchor of the finalized pbft block |
period | Period finalized |
dag_order | Dag order of the finalized pbft block |
|
inline |
|
inline |
Retrieves sortition manager.
|
private |
|
private |
std::pair< DagManager::VerifyBlockReturnType, SharedTransactions > taraxa::DagManager::verifyBlock | ( | const DagBlock & | blk, |
const std::unordered_map< trx_hash_t, std::shared_ptr< Transaction >> & | trxs = {} |
||
) |
Verifies new DAG block.
blk | Block to verify |
transactions | Optional block transactions |
|
private |
util::Event<DagManager, DagBlock> const taraxa::DagManager::block_verified_ {} |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
struct taraxa::SortitionParamsChange |
Changing vrf params for DAG blocks generation.
Public Member Functions | |
SortitionParamsChange ()=default | |
SortitionParamsChange (PbftPeriod period, uint16_t efficiency, const VrfParams &vrf) | |
bytes | rlp () const |
Static Public Member Functions | |
static SortitionParamsChange | from_rlp (const dev::RLP &rlp) |
Public Attributes | |
PbftPeriod | period = 0 |
VrfParams | vrf_params |
uint16_t | interval_efficiency = 0 |
|
default |
taraxa::SortitionParamsChange::SortitionParamsChange | ( | PbftPeriod | period, |
uint16_t | efficiency, | ||
const VrfParams & | vrf | ||
) |
|
static |
bytes taraxa::SortitionParamsChange::rlp | ( | ) | const |
uint16_t taraxa::SortitionParamsChange::interval_efficiency = 0 |
PbftPeriod taraxa::SortitionParamsChange::period = 0 |
VrfParams taraxa::SortitionParamsChange::vrf_params |
class taraxa::SortitionParamsManager |
SortitionParamsManager class calculates DAG efficiency and makes VDF difficulty adjustments.
On each new pbft block that is finalized DAG efficiency calculation is performed with calculateDagEfficiency. On config specified intervals a difficulty adjustment is performed using getNewUpperRange to keep the efficiency in the desired range.
Public Member Functions | |
SortitionParamsManager (const addr_t &node_addr, SortitionConfig sort_conf, std::shared_ptr< DbStorage > db) | |
SortitionParams | getSortitionParams (std::optional< PbftPeriod > for_period={}) const |
uint16_t | calculateDagEfficiency (const PeriodData &block) const |
void | pbftBlockPushed (const PeriodData &block, Batch &batch, PbftPeriod non_empty_pbft_chain_size) |
uint16_t | averageDagEfficiency () |
const std::deque< SortitionParamsChange > & | getParamsChanges () const |
Protected Member Functions | |
SortitionParamsChange | calculateChange (PbftPeriod period) |
EfficienciesMap | getEfficienciesToUpperRange (uint16_t efficiency, int32_t threshold) const |
int32_t | getNewUpperRange (uint16_t efficiency) const |
void | cleanup () |
Protected Attributes | |
SortitionConfig | config_ |
std::shared_ptr< DbStorage > | db_ |
std::deque< uint16_t > | dag_efficiencies_ |
uint32_t | ignored_efficiency_counter_ = 0 |
std::deque< SortitionParamsChange > | params_changes_ |
taraxa::SortitionParamsManager::SortitionParamsManager | ( | const addr_t & | node_addr, |
SortitionConfig | sort_conf, | ||
std::shared_ptr< DbStorage > | db | ||
) |
uint16_t taraxa::SortitionParamsManager::averageDagEfficiency | ( | ) |
Calculate average DAG efficiency from dag_efficiencies_. Used at the end of interval.
|
protected |
uint16_t taraxa::SortitionParamsManager::calculateDagEfficiency | ( | const PeriodData & | block | ) | const |
Calculating DAG efficiency in passed PeriodData(PBFT) DAG efficiency is count of unique transactions over all DAG blocks in a PBFT block divided by the count over all DAG blocks in a PBFT block.
block | PeriodData to calculate its efficiency |
|
protected |
|
protected |
|
protected |
|
inline |
Get memory params changes, used only for unit tests
SortitionParams taraxa::SortitionParamsManager::getSortitionParams | ( | std::optional< PbftPeriod > | for_period = {} | ) | const |
void taraxa::SortitionParamsManager::pbftBlockPushed | ( | const PeriodData & | block, |
Batch & | batch, | ||
PbftPeriod | non_empty_pbft_chain_size | ||
) |
Called from PbftManager.pushPbftBlock_() Calculates and stores needed data on every block. Every computation_interval
blocks from config launches recalculate
based on previous data
block | PeriodData to process |
batch | DB batch in which all changes will be added |
non_empty_pbft_chain_size | PBFT chain size excluding pbft blocks with null anchor |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
std::shared_ptr< DagBlock > taraxa::decodeDAGBlockBundleRlp | ( | uint64_t | index, |
const dev::RLP & | blocks_bundle_rlp | ||
) |
Decodes single dag block from optimized blocks bundle rlp.
blocks_bundle_rlp |
Decodes pbft blocks from optimized blocks bundle rlp.
blocks_bundle_rlp |
dev::bytes taraxa::encodeDAGBlocksBundleRlp | ( | const std::vector< DagBlock > & | blocks | ) |
Encodes pbft blocks into optimized blocks bundle rlp.
blocks |
|
staticconstexpr |