TARAXA
|
Classes | |
class | taraxa::pillar_chain::PillarBlock |
PillarBlock contains merkle root of all finalized blocks created in the last epoch. More... | |
struct | taraxa::pillar_chain::PillarBlockData |
struct | taraxa::pillar_chain::CurrentPillarBlockDataDb |
class | taraxa::pillar_chain::PillarChainManager |
PillarChainMgr class contains functionality related to pillar chain. More... | |
class taraxa::pillar_chain::PillarBlock |
PillarBlock contains merkle root of all finalized blocks created in the last epoch.
Public Member Functions | |
PillarBlock ()=default | |
PillarBlock (const dev::RLP &rlp) | |
PillarBlock (PbftPeriod period, h256 state_root, blk_hash_t previous_pillar_block_hash, h256 bridge_root, u256 epoch, std::vector< ValidatorVoteCountChange > &&validator_votes_count_changes) | |
PillarBlock (const PillarBlock &pillar_block) | |
blk_hash_t | getHash () const |
PbftPeriod | getPeriod () const |
blk_hash_t | getPreviousBlockHash () const |
const std::vector< ValidatorVoteCountChange > & | getValidatorsVoteCountsChanges () const |
const h256 & | getStateRoot () const |
const h256 & | getBridgeRoot () const |
const uint64_t & | getEpoch () const |
dev::bytes | getRlp () const |
Json::Value | getJson () const |
dev::bytes | encodeSolidity () const |
Static Public Member Functions | |
static PillarBlock | decodeSolidity (const bytes &enc) |
Decodes solidity encoded representation of pillar block. More... | |
Static Public Attributes | |
static constexpr uint8_t | kFieldsSize = 5 |
static constexpr uint8_t | kArrayPosAndSize = 2 |
static constexpr uint8_t | kFieldsInVoteCount = 2 |
Private Attributes | |
PbftPeriod | pbft_period_ {0} |
h256 | state_root_ {} |
blk_hash_t | previous_pillar_block_hash_ {0} |
h256 | bridge_root_ {} |
uint64_t | epoch_ {} |
std::vector< ValidatorVoteCountChange > | validators_votes_count_changes_ {} |
std::optional< blk_hash_t > | hash_ |
std::shared_mutex | hash_mutex_ |
|
default |
taraxa::pillar_chain::PillarBlock::PillarBlock | ( | const dev::RLP & | rlp | ) |
taraxa::pillar_chain::PillarBlock::PillarBlock | ( | PbftPeriod | period, |
h256 | state_root, | ||
blk_hash_t | previous_pillar_block_hash, | ||
h256 | bridge_root, | ||
u256 | epoch, | ||
std::vector< ValidatorVoteCountChange > && | validator_votes_count_changes | ||
) |
taraxa::pillar_chain::PillarBlock::PillarBlock | ( | const PillarBlock & | pillar_block | ) |
|
static |
Decodes solidity encoded representation of pillar block.
enc |
dev::bytes taraxa::pillar_chain::PillarBlock::encodeSolidity | ( | ) | const |
const h256 & taraxa::pillar_chain::PillarBlock::getBridgeRoot | ( | ) | const |
const uint64_t & taraxa::pillar_chain::PillarBlock::getEpoch | ( | ) | const |
blk_hash_t taraxa::pillar_chain::PillarBlock::getHash | ( | ) | const |
Json::Value taraxa::pillar_chain::PillarBlock::getJson | ( | ) | const |
PbftPeriod taraxa::pillar_chain::PillarBlock::getPeriod | ( | ) | const |
blk_hash_t taraxa::pillar_chain::PillarBlock::getPreviousBlockHash | ( | ) | const |
dev::bytes taraxa::pillar_chain::PillarBlock::getRlp | ( | ) | const |
const h256 & taraxa::pillar_chain::PillarBlock::getStateRoot | ( | ) | const |
const std::vector< PillarBlock::ValidatorVoteCountChange > & taraxa::pillar_chain::PillarBlock::getValidatorsVoteCountsChanges | ( | ) | const |
|
private |
|
private |
|
mutableprivate |
|
mutableprivate |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
private |
|
private |
|
private |
|
private |
struct taraxa::pillar_chain::PillarBlockData |
Public Member Functions | |
PillarBlockData (std::shared_ptr< PillarBlock > block, const std::vector< std::shared_ptr< PillarVote >> &pillar_votes) | |
PillarBlockData (const dev::RLP &rlp) | |
dev::bytes | getRlp () const |
Json::Value | getJson (bool include_signatures) const |
Public Attributes | |
std::shared_ptr< PillarBlock > | block_ |
std::vector< std::shared_ptr< PillarVote > > | pillar_votes_ |
Static Public Attributes | |
static const size_t | kRlpItemCount = 2 |
taraxa::pillar_chain::PillarBlockData::PillarBlockData | ( | std::shared_ptr< PillarBlock > | block, |
const std::vector< std::shared_ptr< PillarVote >> & | pillar_votes | ||
) |
taraxa::pillar_chain::PillarBlockData::PillarBlockData | ( | const dev::RLP & | rlp | ) |
Json::Value taraxa::pillar_chain::PillarBlockData::getJson | ( | bool | include_signatures | ) | const |
dev::bytes taraxa::pillar_chain::PillarBlockData::getRlp | ( | ) | const |
std::shared_ptr<PillarBlock> taraxa::pillar_chain::PillarBlockData::block_ |
|
static |
std::vector<std::shared_ptr<PillarVote> > taraxa::pillar_chain::PillarBlockData::pillar_votes_ |
struct taraxa::pillar_chain::CurrentPillarBlockDataDb |
Class Members | ||
---|---|---|
shared_ptr< PillarBlock > | pillar_block | |
vector< ValidatorVoteCount > | vote_counts |
class taraxa::pillar_chain::PillarChainManager |
PillarChainMgr class contains functionality related to pillar chain.
Public Member Functions | |
PillarChainManager (const FicusHardforkConfig &ficus_hf_config, std::shared_ptr< DbStorage > db, std::shared_ptr< final_chain::FinalChain > final_chain, std::shared_ptr< KeyManager > key_manager, addr_t node_addr) | |
std::shared_ptr< PillarBlock > | createPillarBlock (PbftPeriod period, const std::shared_ptr< const final_chain::BlockHeader > &block_header, const h256 &bridge_root, const h256 &bridge_epoch) |
std::shared_ptr< PillarVote > | genAndPlacePillarVote (PbftPeriod period, const blk_hash_t &pillar_block_hash, const secret_t &node_sk, bool broadcast_vote) |
Generate and place pillar vote for provided pillar_block_hash in case the whole pillar block is present and valid. More... | |
void | setNetwork (std::weak_ptr< Network > network) |
Set network as a weak pointer. More... | |
bool | isRelevantPillarVote (const std::shared_ptr< PillarVote > vote) const |
Checks if vote is related to saved latest_pillar_block_ and it is not already saved. More... | |
bool | validatePillarVote (const std::shared_ptr< PillarVote > vote) const |
Validates pillar vote. More... | |
bool | isPillarBlockLatestFinalized (const blk_hash_t &block_hash) const |
std::shared_ptr< PillarBlock > | getLastFinalizedPillarBlock () const |
uint64_t | addVerifiedPillarVote (const std::shared_ptr< PillarVote > &vote) |
Add a vote to the pillar votes map. More... | |
std::vector< std::shared_ptr< PillarVote > > | finalizePillarBlock (const blk_hash_t &pillar_block_hash) |
Finalize pillar block. More... | |
std::shared_ptr< PillarBlock > | getCurrentPillarBlock () const |
std::vector< std::shared_ptr< PillarVote > > | getVerifiedPillarVotes (PbftPeriod period, const blk_hash_t pillar_block_hash, bool above_threshold=false) const |
Get all pillar votes for specified pillar block. More... | |
bool | isValidPillarBlock (const std::shared_ptr< PillarBlock > &pillar_block) const |
std::optional< uint64_t > | getPillarConsensusThreshold (PbftPeriod period) const |
Public Attributes | |
decltype(pillar_block_finalized_emitter_) const ::Subscriber & | pillar_block_finalized_ |
Private Member Functions | |
std::vector< PillarBlock::ValidatorVoteCountChange > | getOrderedValidatorsVoteCountsChanges (const std::vector< state_api::ValidatorVoteCount > ¤t_vote_counts, const std::vector< state_api::ValidatorVoteCount > &previous_pillar_block_vote_counts) |
Return a vector of validators vote counts changes between the current and previous pillar block Changes are ordered based on validators addresses. More... | |
void | saveNewPillarBlock (std::shared_ptr< PillarBlock > pillar_block, std::vector< state_api::ValidatorVoteCount > &&new_vote_counts) |
Save new pillar block into db & class data members. More... | |
Private Attributes | |
const util::EventEmitter< const PillarBlockData & > | pillar_block_finalized_emitter_ {} |
const FicusHardforkConfig & | kFicusHfConfig |
std::shared_ptr< DbStorage > | db_ |
std::weak_ptr< Network > | network_ |
std::shared_ptr< final_chain::FinalChain > | final_chain_ |
std::shared_ptr< KeyManager > | key_manager_ |
const addr_t | node_addr_ |
std::shared_ptr< PillarBlock > | last_finalized_pillar_block_ |
std::shared_ptr< PillarBlock > | current_pillar_block_ |
std::vector< state_api::ValidatorVoteCount > | current_pillar_block_vote_counts_ |
PillarVotes | pillar_votes_ |
std::shared_mutex | mutex_ |
taraxa::pillar_chain::PillarChainManager::PillarChainManager | ( | const FicusHardforkConfig & | ficus_hf_config, |
std::shared_ptr< DbStorage > | db, | ||
std::shared_ptr< final_chain::FinalChain > | final_chain, | ||
std::shared_ptr< KeyManager > | key_manager, | ||
addr_t | node_addr | ||
) |
uint64_t taraxa::pillar_chain::PillarChainManager::addVerifiedPillarVote | ( | const std::shared_ptr< PillarVote > & | vote | ) |
Add a vote to the pillar votes map.
vote | vote |
std::shared_ptr< PillarBlock > taraxa::pillar_chain::PillarChainManager::createPillarBlock | ( | PbftPeriod | period, |
const std::shared_ptr< const final_chain::BlockHeader > & | block_header, | ||
const h256 & | bridge_root, | ||
const h256 & | bridge_epoch | ||
) |
@Process Creates new pillar block
period | |
block_header | |
bridge_root | |
bridge_epoch |
std::vector< std::shared_ptr< PillarVote > > taraxa::pillar_chain::PillarChainManager::finalizePillarBlock | ( | const blk_hash_t & | pillar_block_hash | ) |
Finalize pillar block.
pillar_block_hash |
std::shared_ptr< PillarVote > taraxa::pillar_chain::PillarChainManager::genAndPlacePillarVote | ( | PbftPeriod | period, |
const blk_hash_t & | pillar_block_hash, | ||
const secret_t & | node_sk, | ||
bool | broadcast_vote | ||
) |
Generate and place pillar vote for provided pillar_block_hash in case the whole pillar block is present and valid.
period | |
pillar_block_hash | |
node_sk | |
broadcast_vote |
std::shared_ptr< PillarBlock > taraxa::pillar_chain::PillarChainManager::getCurrentPillarBlock | ( | ) | const |
std::shared_ptr< PillarBlock > taraxa::pillar_chain::PillarChainManager::getLastFinalizedPillarBlock | ( | ) | const |
|
private |
Return a vector of validators vote counts changes between the current and previous pillar block Changes are ordered based on validators addresses.
current_vote_counts | |
previous_pillar_block_vote_counts |
std::optional< uint64_t > taraxa::pillar_chain::PillarChainManager::getPillarConsensusThreshold | ( | PbftPeriod | period | ) | const |
period |
std::vector< std::shared_ptr< PillarVote > > taraxa::pillar_chain::PillarChainManager::getVerifiedPillarVotes | ( | PbftPeriod | period, |
const blk_hash_t | pillar_block_hash, | ||
bool | above_threshold = false |
||
) | const |
Get all pillar votes for specified pillar block.
period | |
pillar_block_hash | |
above_threshold |
bool taraxa::pillar_chain::PillarChainManager::isPillarBlockLatestFinalized | ( | const blk_hash_t & | block_hash | ) | const |
bool taraxa::pillar_chain::PillarChainManager::isRelevantPillarVote | ( | const std::shared_ptr< PillarVote > | vote | ) | const |
Checks if vote is related to saved latest_pillar_block_ and it is not already saved.
vote |
bool taraxa::pillar_chain::PillarChainManager::isValidPillarBlock | ( | const std::shared_ptr< PillarBlock > & | pillar_block | ) | const |
|
private |
Save new pillar block into db & class data members.
pillar_block | |
new_vote_counts |
void taraxa::pillar_chain::PillarChainManager::setNetwork | ( | std::weak_ptr< Network > | network | ) |
Set network as a weak pointer.
network | a weak pointer |
bool taraxa::pillar_chain::PillarChainManager::validatePillarVote | ( | const std::shared_ptr< PillarVote > | vote | ) | const |
Validates pillar vote.
vote |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
decltype(pillar_block_finalized_emitter_) const ::Subscriber& taraxa::pillar_chain::PillarChainManager::pillar_block_finalized_ |
|
private |
|
private |