19namespace pillar_chain {
 
   20class PillarChainManager;
 
   64    const std::vector<std::pair<bool, WalletConfig>> &
getWallets(
PbftPeriod current_pbft_period) 
const;
 
 
   80    std::shared_ptr<PbftVote> 
vote;
 
 
   83  using time_point = std::chrono::system_clock::time_point;
 
   87              std::shared_ptr<VoteManager> vote_mgr, std::shared_ptr<DagManager> dag_mgr,
 
   88              std::shared_ptr<TransactionManager> trx_mgr, std::shared_ptr<final_chain::FinalChain> final_chain,
 
   89              std::shared_ptr<pillar_chain::PillarChainManager> pillar_chain_mgr);
 
  100  void setNetwork(std::weak_ptr<Network> network);
 
  178                                                     const std::optional<PbftBlockExtraData> &extra_data,
 
  179                                                     const std::vector<WalletConfig> &eligible_wallets);
 
  220                           std::vector<std::shared_ptr<PbftVote>> &¤t_block_cert_votes);
 
  313  void gossipVote(
const std::shared_ptr<PbftVote> &vote, 
const std::shared_ptr<PbftBlock> &voted_block,
 
  314                  bool rebroadcast = 
false);
 
  326  std::map<PbftPeriod, std::vector<std::shared_ptr<PbftBlock>>> 
getProposedBlocks() 
const;
 
  442                       const blk_hash_t &block_hash, std::shared_ptr<PbftBlock> pbft_block = 
nullptr);
 
  452                              std::vector<std::shared_ptr<PbftVote>> &&reward_votes);
 
  460  void gossipNewOwnVote(
const std::shared_ptr<PbftVote> &vote, 
const std::shared_ptr<PbftBlock> &voted_block);
 
  490  std::optional<std::pair<std::shared_ptr<PbftBlock>, std::shared_ptr<PbftVote>>> 
identifyLeaderBlock(
 
  491      const ProposedBlocks &propose_blocks, std::vector<std::shared_ptr<PbftVote>> &&propose_votes);
 
  498  h256 
getProposal(
const std::shared_ptr<PbftVote> &vote) 
const;
 
  535                                        std::vector<std::shared_ptr<PbftVote>> &¤t_round_cert_votes);
 
  544                 bool synchronous_processing = 
false);
 
  568  std::optional<std::pair<PeriodData, std::vector<std::shared_ptr<PbftVote>>>> 
processPeriodData();
 
  578                                  const std::vector<std::shared_ptr<PbftVote>> &cert_votes) 
const;
 
  621  std::shared_ptr<DbStorage> 
db_;
 
  632  std::shared_ptr<util::ThreadPool>
 
 
Definition pbft_manager.hpp:60
 
std::vector< std::pair< bool, WalletConfig > > wallets_
Definition pbft_manager.hpp:74
 
const std::vector< std::pair< bool, WalletConfig > > & getWallets(PbftPeriod current_pbft_period) const
Definition pbft_manager.cpp:2485
 
PbftPeriod period_
Definition pbft_manager.hpp:73
 
void updateWalletsEligibility(PbftPeriod period, const std::shared_ptr< final_chain::FinalChain > &final_chain)
Definition pbft_manager.cpp:2473
 
PbftPeriod getWalletsEligiblePeriod() const
Definition pbft_manager.cpp:2492
 
class ProposedBlocks holds proposed pbft blocks together with propose votes hashes per period & round
Definition proposed_blocks.hpp:18
 
std::optional< ProposedBlockData > generatePbftBlock(PbftPeriod propose_period, const blk_hash_t &prev_blk_hash, const blk_hash_t &anchor_hash, const blk_hash_t &order_hash, const std::optional< PbftBlockExtraData > &extra_data, const std::vector< WalletConfig > &eligible_wallets)
Generate PBFT block, push into unverified queue, and broadcast to peers.
Definition pbft_manager.cpp:1307
 
std::vector< std::shared_ptr< PbftVote > > reward_votes
Definition pbft_manager.hpp:79
 
std::chrono::system_clock::time_point time_point
Definition pbft_manager.hpp:83
 
uint32_t rebroadcast_reward_votes_counter_
Definition pbft_manager.hpp:646
 
std::shared_ptr< pillar_chain::PillarChainManager > pillar_chain_mgr_
Definition pbft_manager.hpp:628
 
void secondFinish_()
PBFT finish polling state: Happens at odd number steps from step 5. Place a next vote at finishing va...
Definition pbft_manager.cpp:1238
 
std::atomic< PbftRound > round_
Definition pbft_manager.hpp:649
 
void testBroadcastVotesFunctionality()
Test/enforce broadcastVotes() to actually send votes.
Definition pbft_manager.cpp:752
 
void processProposedBlock(const std::shared_ptr< PbftBlock > &proposed_block)
Push proposed block into the proposed_blocks_ in case it is not there yet.
Definition pbft_manager.cpp:1388
 
std::shared_ptr< PbftChain > pbft_chain_
Definition pbft_manager.hpp:622
 
void setPbftStep(PbftStep pbft_step)
Set PBFT step.
Definition pbft_manager.cpp:289
 
const blk_hash_t dag_genesis_block_hash_
Definition pbft_manager.hpp:674
 
std::shared_ptr< PbftBlock > getValidPbftProposedBlock(PbftPeriod period, const blk_hash_t &block_hash)
Get valid proposed pbft block. It will retrieve block from proposed_blocks and then validate it if no...
Definition pbft_manager.cpp:822
 
bool executed_pbft_block_
Definition pbft_manager.hpp:663
 
void start()
Start PBFT daemon.
Definition pbft_manager.cpp:123
 
void setFilterState_()
Set PBFT filter state.
Definition pbft_manager.cpp:617
 
std::optional< std::pair< std::shared_ptr< PbftBlock >, std::shared_ptr< PbftVote > > > identifyLeaderBlock(const ProposedBlocks &propose_blocks, std::vector< std::shared_ptr< PbftVote > > &&propose_votes)
Identify a leader block from all received proposed PBFT blocks for the current round by using minimum...
Definition pbft_manager.cpp:1606
 
std::shared_ptr< PbftVote > vote
Definition pbft_manager.hpp:80
 
void gossipVote(const std::shared_ptr< PbftVote > &vote, const std::shared_ptr< PbftBlock > &voted_block, bool rebroadcast=false)
Gossips vote to the other peers.
Definition pbft_manager.cpp:1000
 
uint32_t rebroadcast_votes_counter_
Definition pbft_manager.hpp:644
 
EligibleWallets eligible_wallets_
Definition pbft_manager.hpp:687
 
std::shared_ptr< TransactionManager > trx_mgr_
Definition pbft_manager.hpp:626
 
bool already_next_voted_null_block_hash_
Definition pbft_manager.hpp:665
 
std::shared_ptr< util::ThreadPool > sync_thread_pool_
Definition pbft_manager.hpp:633
 
void setFinishState_()
Set PBFT finish state.
Definition pbft_manager.cpp:630
 
std::pair< bool, PbftPeriod > getDagBlockPeriod(const blk_hash_t &hash)
Get a DAG block period number.
Definition pbft_manager.cpp:204
 
void sleep_()
Time to sleep for PBFT protocol.
Definition pbft_manager.cpp:516
 
static blk_hash_t calculateOrderHash(const std::vector< blk_hash_t > &dag_block_hashes)
Calculate DAG blocks ordering hash.
Definition pbft_manager.cpp:1396
 
~PbftManager()
Definition pbft_manager.cpp:119
 
const uint32_t kSyncingThreadPoolSize
Definition pbft_manager.hpp:631
 
size_t periodDataQueueSize() const
Get PBFT blocks syncing queue size.
Definition pbft_manager.cpp:2442
 
bool go_finish_state_
Definition pbft_manager.hpp:666
 
void setNetwork(std::weak_ptr< Network > network)
Set network as a weak pointer.
Definition pbft_manager.cpp:121
 
void setCertifyState_()
Set PBFT certify state.
Definition pbft_manager.cpp:623
 
PbftPeriod pbftSyncingPeriod() const
Get PBFT blocks synced period.
Definition pbft_manager.cpp:2102
 
size_t getPbftCommitteeSize() const
Get PBFT committee size.
Definition pbft_manager.hpp:278
 
bool pushCertVotedPbftBlockIntoChain_(const std::shared_ptr< PbftBlock > &pbft_block, std::vector< std::shared_ptr< PbftVote > > &¤t_round_cert_votes)
If there are enough certify votes, push the vote PBFT block in PBFT chain.
Definition pbft_manager.cpp:1822
 
bool advanceRound()
If node receives 2t+1 next votes for some block(including kNullBlockHash), advance round to + 1.
Definition pbft_manager.cpp:388
 
PbftStates state_
Definition pbft_manager.hpp:648
 
PbftStep getPbftStep() const
Get PBFT step number.
Definition pbft_manager.cpp:224
 
void identifyBlock_()
PBFT filter state. PBFT step 2. Identify a leader block from all received proposed blocks for the cur...
Definition pbft_manager.cpp:1077
 
std::optional< uint64_t > getCurrentNodeVotesCount() const
Get current node DPOS votes count.
Definition pbft_manager.cpp:253
 
void gossipNewOwnVotesBundle(const std::vector< std::shared_ptr< PbftVote > > &votes)
Gossips newly generated own votes bundle to the other peers.
Definition pbft_manager.cpp:980
 
uint32_t dynamic_lambda_
Definition pbft_manager.hpp:638
 
uint32_t broadcast_reward_votes_counter_
Definition pbft_manager.hpp:645
 
bool stateOperations_()
If there are any synced PBFT blocks from peers, push the synced blocks in PBFT chain....
Definition pbft_manager.cpp:781
 
time_point second_finish_step_start_datetime_
Definition pbft_manager.hpp:660
 
std::atomic< bool > stopped_
Definition pbft_manager.hpp:614
 
std::shared_ptr< DagManager > dag_mgr_
Definition pbft_manager.hpp:624
 
bool validatePbftBlockExtraData(const std::shared_ptr< PbftBlock > &pbft_block) const
Validates pbft block extra data presence:
Definition pbft_manager.cpp:1672
 
std::chrono::milliseconds next_step_time_ms_
Definition pbft_manager.hpp:661
 
h256 getProposal(const std::shared_ptr< PbftVote > &vote) const
Calculate the lowest hash of a vote by vote weight.
Definition pbft_manager.cpp:1595
 
uint32_t broadcast_votes_counter_
Definition pbft_manager.hpp:643
 
std::shared_ptr< PbftBlock > pbft_block
Definition pbft_manager.hpp:78
 
void printVotingSummary() const
Prints all votes generated by node in current round.
Definition pbft_manager.cpp:760
 
std::shared_ptr< final_chain::FinalChain > final_chain_
Definition pbft_manager.hpp:627
 
PbftPeriod getPbftPeriod() const
Get current PBFT period number.
Definition pbft_manager.cpp:216
 
std::shared_ptr< PbftBlock > getPbftProposedBlock(PbftPeriod period, const blk_hash_t &block_hash) const
Get a proposed PBFT block based on specified period and block hash.
Definition pbft_manager.cpp:2457
 
const FullNodeConfig kConfig
Definition pbft_manager.hpp:630
 
void firstFinish_()
PBFT finish state. Happens at even number steps from step 4. Place a next vote at finishing value for...
Definition pbft_manager.cpp:1189
 
bool canParticipateInConsensus(PbftPeriod period, const addr_t &node_addr) const
Definition pbft_manager.cpp:2384
 
std::mutex stop_mtx_
Definition pbft_manager.hpp:679
 
bool validatePbftBlock(const std::shared_ptr< PbftBlock > &pbft_block) const
Validates pbft block. It checks if:
Definition pbft_manager.cpp:1728
 
std::optional< uint64_t > getCurrentDposTotalVotesCount() const
Get current total DPOS votes count.
Definition pbft_manager.cpp:241
 
void pushSyncedPbftBlocksIntoChain()
Check PBFT blocks syncing queue. If there are synced PBFT blocks in queue, push it to PBFT chain.
Definition pbft_manager.cpp:1858
 
void resetPbftConsensus(PbftRound round)
Resets pbft consensus: current pbft round is set to round, step is set to the beginning value.
Definition pbft_manager.cpp:406
 
PbftPeriod last_placed_pillar_vote_period_
Definition pbft_manager.hpp:668
 
void setPbftRound(PbftRound round)
Set PBFT round number.
Definition pbft_manager.cpp:226
 
std::unordered_map< blk_hash_t, std::vector< std::shared_ptr< DagBlock > > > anchor_dag_block_order_cache_
Definition pbft_manager.hpp:618
 
PeriodDataQueue sync_queue_
Definition pbft_manager.hpp:681
 
bool validatePbftBlockCertVotes(const std::shared_ptr< PbftBlock > pbft_block, const std::vector< std::shared_ptr< PbftVote > > &cert_votes) const
Validates PBFT block cert votes.
Definition pbft_manager.cpp:2238
 
PbftManager & operator=(const PbftManager &)=delete
 
blk_hash_t getLastPbftBlockHash()
Definition pbft_manager.cpp:2455
 
std::chrono::milliseconds elapsedTimeInMs(const time_point &start_time)
Definition pbft_manager.cpp:512
 
PbftStateRootValidation validateFinalChainHash(const std::shared_ptr< PbftBlock > &pbft_block) const
Validates pbft block final chain hash.
Definition pbft_manager.cpp:1654
 
void gossipNewOwnVote(const std::shared_ptr< PbftVote > &vote, const std::shared_ptr< PbftBlock > &voted_block)
Gossips newly generated own vote to the other peers.
Definition pbft_manager.cpp:966
 
bool checkBlockWeight(const std::vector< std::shared_ptr< DagBlock > > &dag_blocks, PbftPeriod period) const
Check a block weight of gas estimation.
Definition pbft_manager.cpp:2444
 
ProposedBlocks proposed_blocks_
Definition pbft_manager.hpp:684
 
std::optional< ProposedBlockData > proposePbftBlock()
Propose a new PBFT block.
Definition pbft_manager.cpp:1436
 
void adjustDynamicLambda(PbftPeriod finalized_period, PbftRound finalized_round)
Adjust dynamic lambda.
Definition pbft_manager.cpp:473
 
std::optional< PbftBlockExtraData > createPbftBlockExtraData(PbftPeriod pbft_period) const
Creates pbft block extra data.
Definition pbft_manager.cpp:1573
 
bool pushPbftBlock_(PeriodData &&period_data, std::vector< std::shared_ptr< PbftVote > > &&cert_votes)
Push a new PBFT block into the PBFT chain.
Definition pbft_manager.cpp:1958
 
const std::chrono::milliseconds kMaxExponentialLambda
Definition pbft_manager.hpp:635
 
void certifyBlock_()
PBFT certify state. PBFT step 3. If receive enough soft votes and pass verification,...
Definition pbft_manager.cpp:1114
 
std::condition_variable stop_cv_
Definition pbft_manager.hpp:678
 
void setFinishPollingState_()
Set PBFT finish polling state.
Definition pbft_manager.cpp:637
 
const GenesisConfig & kGenesisConfig
Definition pbft_manager.hpp:676
 
void finalize_(PeriodData &&period_data, std::vector< h256 > &&finalized_dag_blk_hashes, bool synchronous_processing=false)
Final chain executes a finalized PBFT block.
Definition pbft_manager.cpp:1938
 
bool loop_back_finish_state_
Definition pbft_manager.hpp:667
 
bool printSecondFinishStepInfo_
Definition pbft_manager.hpp:671
 
static void reorderTransactions(SharedTransactions &transactions)
Reorder transactions data if DAG reordering caused transactions with same sender to have nonce in inc...
Definition pbft_manager.cpp:1885
 
void stop()
Stop PBFT daemon.
Definition pbft_manager.cpp:132
 
std::optional< std::pair< PeriodData, std::vector< std::shared_ptr< PbftVote > > > > processPeriodData()
Process synced PBFT blocks if PBFT syncing queue is not empty.
Definition pbft_manager.cpp:2106
 
PbftManager(const PbftManager &)=delete
 
bool periodDataQueueEmpty() const
Returns true if queue is empty.
Definition pbft_manager.cpp:2409
 
std::weak_ptr< Network > network_
Definition pbft_manager.hpp:625
 
time_point current_round_start_datetime_
Definition pbft_manager.hpp:658
 
void broadcastVotes()
Broadcast or rebroadcast 2t+1 soft/reward/previous round next votes + all own votes if needed.
Definition pbft_manager.cpp:663
 
bool already_next_voted_value_
Definition pbft_manager.hpp:664
 
bool validatePillarDataInPeriodData(const PeriodData &period_data) const
Validates pbft block extra data presence + pillar votes presence based on pbft block number and ficus...
Definition pbft_manager.cpp:1705
 
bool validatePbftBlockPillarVotes(const PeriodData &period_data) const
Validates PBFT block pillar votes.
Definition pbft_manager.cpp:2321
 
blk_hash_t lastPbftBlockHashFromQueueOrChain()
Get last pbft block hash from queue or if queue empty, from chain.
Definition pbft_manager.cpp:2401
 
bool genAndPlaceProposeVote(const std::shared_ptr< PbftBlock > &proposed_block, std::vector< std::shared_ptr< PbftVote > > &&reward_votes)
Generate propose vote for provided block place (gossip) it.
Definition pbft_manager.cpp:938
 
bool advancePeriod()
If node receives 2t+1 cert votes for some valid block and pushes it to the chain, advance period to +...
Definition pbft_manager.cpp:363
 
bool tryPushCertVotesBlock()
Check if there is 2t+1 cert votes for some valid block, if yes - push it into the chain.
Definition pbft_manager.cpp:336
 
std::chrono::milliseconds current_round_lambda_
Definition pbft_manager.hpp:639
 
std::map< blk_hash_t, std::vector< PbftStep > > current_round_broadcasted_votes_
Definition pbft_manager.hpp:656
 
std::map< PbftPeriod, std::vector< std::shared_ptr< PbftBlock > > > getProposedBlocks() const
Definition pbft_manager.cpp:2397
 
std::unique_ptr< std::thread > daemon_
Definition pbft_manager.hpp:620
 
void periodDataQueuePush(PeriodData &&period_data, dev::p2p::NodeID const &node_id, std::vector< std::shared_ptr< PbftVote > > &¤t_block_cert_votes)
Push synced period data in syncing queue.
Definition pbft_manager.cpp:2411
 
bool genAndPlaceVote(PbftVoteTypes vote_type, PbftPeriod period, PbftRound round, PbftStep step, const blk_hash_t &block_hash, std::shared_ptr< PbftBlock > pbft_block=nullptr)
Generate and place(gossip) vote.
Definition pbft_manager.cpp:845
 
void initialState()
Initial PBFT states when node start PBFT.
Definition pbft_manager.cpp:533
 
const uint32_t kBroadcastVotesLambdaTime
Definition pbft_manager.hpp:641
 
void run()
Run PBFT daemon.
Definition pbft_manager.cpp:155
 
PbftRound getPbftRound() const
Get current PBFT round number.
Definition pbft_manager.cpp:218
 
std::chrono::milliseconds getPbftDeadline(PbftPeriod period) const
Definition pbft_manager.cpp:2494
 
PbftManager & operator=(PbftManager &&)=delete
 
std::pair< PbftRound, PbftPeriod > getPbftRoundAndPeriod() const
Get PBFT round & period number.
Definition pbft_manager.cpp:220
 
PbftStep step_
Definition pbft_manager.hpp:650
 
void waitForPeriodFinalization()
wait for DPOS period finalization
Definition pbft_manager.cpp:231
 
void proposeBlock_()
PBFT proposal state. PBFT step 1. Propose a PBFT block and place a proposal vote on the block hash.
Definition pbft_manager.cpp:1014
 
PbftManager(PbftManager &&)=delete
 
uint32_t rounds_count_dynamic_lambda_
Definition pbft_manager.hpp:637
 
void processPillarBlock(PbftPeriod period)
Creates pillar block (and pillar vote in case node is eligible to vote & is not syncing)
Definition pbft_manager.cpp:2067
 
std::shared_ptr< VoteManager > vote_mgr_
Definition pbft_manager.hpp:623
 
const uint32_t kRebroadcastVotesLambdaTime
Definition pbft_manager.hpp:642
 
std::optional< std::shared_ptr< PbftBlock > > cert_voted_block_for_round_
Definition pbft_manager.hpp:653
 
bool printCertStepInfo_
Definition pbft_manager.hpp:672
 
void loopBackFinishState_()
Set back to PBFT finish state from PBFT finish polling state.
Definition pbft_manager.cpp:651
 
std::shared_ptr< DbStorage > db_
Definition pbft_manager.hpp:621
 
time_point current_period_start_datetime_
Definition pbft_manager.hpp:659
 
PbftManager class is a daemon that is used to finalize a bench of directed acyclic graph (DAG) blocks...
Definition pbft_manager.hpp:58
 
PeriodData class is for block execution, that includes PBFT block, certify votes, DAG blocks,...
Definition period_data.hpp:26
 
PeriodDataQueue class is a syncing queue, the queue stores blocks synced from peers.
Definition period_data_queue.hpp:20
 
PbftStateRootValidation
Definition pbft_manager.hpp:27
 
PbftStates
Definition pbft_manager.hpp:26
 
@ finish_state
Definition pbft_manager.hpp:26
 
@ certify_state
Definition pbft_manager.hpp:26
 
@ value_proposal_state
Definition pbft_manager.hpp:26
 
@ finish_polling_state
Definition pbft_manager.hpp:26
 
@ filter_state
Definition pbft_manager.hpp:26
 
Definition pbft_manager.hpp:77
 
PbftVoteTypes
Definition vrf_sortition.hpp:21
 
#define LOG_OBJECTS_DEFINE
Definition logger.hpp:60
 
uint32_t PbftStep
Definition types.hpp:26
 
uint32_t PbftRound
Definition types.hpp:25
 
EthBlockNumber PbftPeriod
Definition types.hpp:24
 
std::vector< SharedTransaction > SharedTransactions
Definition transaction.hpp:86
 
Definition genesis.hpp:23
 
PbftConfig pbft
Definition genesis.hpp:28
 
uint32_t committee_size
Definition pbft_config.hpp:11