30 class DagManager :
public std::enable_shared_from_this<DagManager> {
50 std::shared_ptr<PbftChain> pbft_chain, std::shared_ptr<final_chain::FinalChain> final_chain,
51 std::shared_ptr<DbStorage> db, std::shared_ptr<KeyManager> key_manager);
81 std::pair<VerifyBlockReturnType, SharedTransactions>
verifyBlock(
82 const DagBlock &blk,
const std::unordered_map<
trx_hash_t, std::shared_ptr<Transaction>> &trxs = {});
99 bool proposed =
false,
145 void drawGraph(std::string
const &dotfile)
const;
153 std::shared_lock lock(
mutex_);
157 std::shared_lock lock(
mutex_);
168 const std::pair<PbftPeriod, std::map<uint64_t, std::unordered_set<blk_hash_t>>>
getNonFinalizedBlocks()
const;
177 const std::tuple<PbftPeriod, std::vector<std::shared_ptr<DagBlock>>,
SharedTransactions>
240 bool finalized =
false);
242 std::unordered_map<
blk_hash_t, std::shared_ptr<DagBlock>> &expired_dag_blocks_to_remove);
245 std::pair<blk_hash_t, std::vector<blk_hash_t>>
getFrontier()
const;
255 std::shared_ptr<DbStorage>
db_;
Definition: FixedHash.h:35
DagBlock class is a DAG block class which main data is a list of transaction hashes included in the b...
Definition: dag_block.hpp:16
blk_hash_t old_anchor_
Definition: dag_manager.hpp:258
uint64_t getDagExpiryLevel()
Retrieves Dag expiry level.
Definition: dag_manager.hpp:215
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 p...
Definition: dag_manager.cpp:308
void handleExpiredDagBlocksTransactions(const std::vector< trx_hash_t > &transactions_from_expired_dag_blocks) const
Definition: dag_manager.cpp:398
const uint32_t max_levels_per_period_
Definition: dag_manager.hpp:265
const uint64_t kValidatorMaxVote
Definition: dag_manager.hpp:280
void clearLightNodeHistory(uint64_t light_node_history)
Clears light node history.
Definition: dag_manager.cpp:284
DagManager(DagManager &&)=delete
std::shared_ptr< PivotTree > pivot_tree_
Definition: dag_manager.hpp:250
std::shared_ptr< KeyManager > key_manager_
Definition: dag_manager.hpp:256
std::pair< VerifyBlockReturnType, SharedTransactions > verifyBlock(const DagBlock &blk, const std::unordered_map< trx_hash_t, std::shared_ptr< Transaction >> &trxs={})
Verifies new DAG block.
Definition: dag_manager.cpp:585
std::shared_ptr< TransactionManager > trx_mgr_
Definition: dag_manager.hpp:252
void setNetwork(std::weak_ptr< Network > network)
Definition: dag_manager.hpp:60
VerifyBlockReturnType
return type of verifyBlock
Definition: dag_manager.hpp:35
@ IncorrectTransactionsEstimation
std::weak_ptr< Network > network_
Definition: dag_manager.hpp:254
std::shared_ptr< PbftChain > pbft_chain_
Definition: dag_manager.hpp:253
const HardforksConfig kHardforks
Definition: dag_manager.hpp:279
void drawGraph(std::string const &dotfile) const
Definition: dag_manager.cpp:188
std::pair< uint64_t, uint64_t > getNumEdgesInDag() const
Definition: dag_manager.cpp:76
bool isDagBlockKnown(const blk_hash_t &hash) const
Definition: dag_manager.cpp:735
void updateFrontier()
Definition: dag_manager.cpp:230
void drawTotalGraph(std::string const &str) const
Definition: dag_manager.cpp:81
std::shared_ptr< Dag > total_dag_
Definition: dag_manager.hpp:251
DagManager & operator=(DagManager &&)=delete
blk_hash_t anchor_
Definition: dag_manager.hpp:257
DagManager & operator=(const DagManager &)=delete
bool validateBlockNotExpired(const std::shared_ptr< DagBlock > &dag_block, std::unordered_map< blk_hash_t, std::shared_ptr< DagBlock >> &expired_dag_blocks_to_remove)
Definition: dag_manager.cpp:422
void drawPivotGraph(std::string const &str) const
Definition: dag_manager.cpp:86
static dev::bytes getVdfMessage(blk_hash_t const &hash, SharedTransactions const &trxs)
Retrieves VDF message from block hash and transactions.
Definition: dag_manager.cpp:755
std::shared_mutex order_dag_blocks_mutex_
Definition: dag_manager.hpp:249
const uint32_t dag_expiry_limit_
Definition: dag_manager.hpp:266
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)
Definition: dag_manager.cpp:19
const DagConfig & getDagConfig() const
Retrieves Dag config.
Definition: dag_manager.hpp:208
SortitionParamsManager & sortitionParamsManager()
Retrieves sortition manager.
Definition: dag_manager.hpp:201
util::Event< DagManager, DagBlock > const block_verified_
Definition: dag_manager.hpp:187
std::atomic_uint64_t dag_expiry_level_
Definition: dag_manager.hpp:270
std::pair< size_t, size_t > getNonFinalizedBlocksSize() const
Definition: dag_manager.cpp:574
const uint32_t cache_delete_step_
Definition: dag_manager.hpp:275
std::shared_ptr< DbStorage > db_
Definition: dag_manager.hpp:255
SortitionParamsManager sortition_params_manager_
Definition: dag_manager.hpp:262
const uint64_t kPbftGasLimit
Definition: dag_manager.hpp:278
ExpirationCacheMap< blk_hash_t, DagBlock > seen_blocks_
Definition: dag_manager.hpp:276
std::pair< blk_hash_t, blk_hash_t > getAnchors() const
Definition: dag_manager.hpp:156
std::shared_mutex & getDagMutex()
Retrieves Dag Manager mutex, only to be used when finalizing pbft block.
Definition: dag_manager.hpp:194
std::shared_mutex mutex_
Definition: dag_manager.hpp:248
std::map< uint64_t, std::unordered_set< blk_hash_t > > non_finalized_blks_
Definition: dag_manager.hpp:260
std::pair< uint64_t, uint64_t > getNumVerticesInDag() const
Definition: dag_manager.cpp:71
DagManager(const DagManager &)=delete
std::shared_ptr< DagManager > getShared()
Definition: dag_manager.cpp:62
DagFrontier frontier_
Definition: dag_manager.hpp:261
PbftPeriod period_
Definition: dag_manager.hpp:259
std::atomic< level_t > max_level_
Definition: dag_manager.hpp:247
level_t getMaxLevel() const
Definition: dag_manager.hpp:149
std::shared_ptr< DagBlock > getDagBlock(const blk_hash_t &hash) const
Gets dag block from either local memory cache or db.
Definition: dag_manager.cpp:743
const std::shared_ptr< DagBlock > genesis_block_
Definition: dag_manager.hpp:264
PbftPeriod getLatestPeriod() const
Definition: dag_manager.hpp:152
DagFrontier getDagFrontier()
Definition: dag_manager.cpp:128
std::vector< blk_hash_t > getGhostPath() const
Retrieves ghost path which is ordered list of non finalized pivot blocks for last anchor.
Definition: dag_manager.cpp:249
std::shared_ptr< final_chain::FinalChain > final_chain_
Definition: dag_manager.hpp:277
uint32_t getDagExpiryLimit() const
Retrieves Dag expiry limit.
Definition: dag_manager.hpp:166
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 tra...
Definition: dag_manager.cpp:546
void recoverDag()
Definition: dag_manager.cpp:447
const uint32_t cache_max_size_
Definition: dag_manager.hpp:274
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 i...
Definition: dag_manager.cpp:256
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)
Definition: dag_manager.cpp:194
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
Definition: dag_manager.cpp:133
const DagConfig & dag_config_
Definition: dag_manager.hpp:263
std::pair< blk_hash_t, std::vector< blk_hash_t > > getFrontier() const
Definition: dag_manager.cpp:214
const std::pair< PbftPeriod, std::map< uint64_t, std::unordered_set< blk_hash_t > > > getNonFinalizedBlocks() const
Definition: dag_manager.cpp:539
std::pair< bool, std::vector< blk_hash_t > > pivotAndTipsAvailable(DagBlock const &blk)
Checks if block pivot and tips are in DAG.
Definition: dag_manager.cpp:91
std::optional< std::pair< blk_hash_t, std::vector< blk_hash_t > > > getLatestPivotAndTips() const
Definition: dag_manager.cpp:209
DagManager class contains in memory representation of part of the DAG that is not yet finalized in a ...
Definition: dag_manager.hpp:30
SortitionParamsManager class calculates DAG efficiency and makes VDF difficulty adjustments.
Definition: sortition_params_manager.hpp:36
#define LOG_OBJECTS_DEFINE
Definition: logger.hpp:60
std::vector<::byte > bytes
Definition: Common.h:46
std::vector< blk_hash_t > vec_blk_t
Definition: types.hpp:50
uint256_hash_t blk_hash_t
Definition: types.hpp:42
EthBlockNumber PbftPeriod
Definition: types.hpp:24
std::vector< SharedTransaction > SharedTransactions
Definition: transaction.hpp:81
uint64_t level_t
Definition: types.hpp:46
Definition: dag_config.hpp:17
Definition: dag_block.hpp:120
Definition: config.hpp:24
Definition: hardfork.hpp:93