Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPM-939 more logs for prefix chain tree #85

Merged
merged 1 commit into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ struct chain_type {
};


class NodeNotFoundError : public std::exception {};


template <typename NodeType>
class prefix_chain_tree {
using node_ptr = std::shared_ptr<NodeType>;
Expand Down Expand Up @@ -86,6 +83,15 @@ class prefix_chain_tree {
prefix_chain_tree() = delete;
prefix_chain_tree(const prefix_chain_tree&) = delete;

block_ids_type get_blocks() const {
block_ids_type blocks;
blocks.reserve(block_index.size());
for (const auto& block : block_index) {
blocks.push_back(block.first);
}
return blocks;
}

node_ptr find(const block_id_type& block_id) const {
auto itr = block_index.find(block_id);
return itr != block_index.end() ? itr->second.lock() : nullptr;
Expand All @@ -101,8 +107,6 @@ class prefix_chain_tree {
return nullptr;
}
return _add_confirmations(node, blocks, sender_key, conf);


}

void remove_confirmations() {
Expand All @@ -114,18 +118,20 @@ class prefix_chain_tree {
}
}

void insert(const chain_type& chain,
/// Try to insert chain blocks into tree. Returns false if base_block or one of blocks exists in prefix tree.
bool insert(const chain_type& chain,
const public_key_type& creator_key,
const std::set<public_key_type>& active_bp_keys) {
node_ptr node = nullptr;
block_ids_type blocks;
std::tie(node, blocks) = get_tree_node(chain);

if (!node) {
throw NodeNotFoundError();
return false;
}

insert_blocks(node, blocks, creator_key, active_bp_keys);
return true;
}

node_ptr get_final_chain_head(size_t confirmation_number) const {
Expand Down
9 changes: 4 additions & 5 deletions plugins/randpa_plugin/include/eosio/randpa_plugin/randpa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,12 @@ class randpa {
("bpk", event.active_bp_keys)
);

try {
_prefix_tree->insert({event.prev_block_id, {event.block_id}},
event.creator_key, event.active_bp_keys);
} catch (const NodeNotFoundError& e) {
randpa_elog("Randpa cannot insert block into tree, base_block: ${base_id}, block: ${id}",
bool ok = _prefix_tree->insert({event.prev_block_id, {event.block_id}}, event.creator_key, event.active_bp_keys);
if (!ok) {
randpa_elog("Randpa cannot insert block into tree, base_block: ${base_id}, block: ${id}, block_index: ${bi}",
("base_id", event.prev_block_id)
("id", event.block_id)
("bi", _prefix_tree->get_blocks())
);
return;
}
Expand Down
3 changes: 3 additions & 0 deletions scripts/config-product.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ PRODUCT_NAME="${PRODUCT_NAME,,}" # to lower case
# core symbol name
case "$PRODUCT_NAME" in
(*daobet*)
PRODUCT_NAME=daobet
PRODUCT_NAME_OFFICIAL="DAOBet"
CORE_SYMBOL_NAME=BET
;;
(*haya*)
PRODUCT_NAME=haya
PRODUCT_NAME_OFFICIAL="Haya"
CORE_SYMBOL_NAME=SYS
;;
esac
readonly PRODUCT_NAME PRODUCT_NAME_OFFICIAL CORE_SYMBOL_NAME