Skip to content

Commit

Permalink
Merge pull request #739 from loki-project/dev
Browse files Browse the repository at this point in the history
Merge checkpointing using wroing quorum to master
  • Loading branch information
Doy-lee authored Jul 12, 2019
2 parents 490070d + 0ec31ee commit 36d4f37
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cryptonote_core/service_node_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ namespace service_nodes
info.decommission_count++;

info.proof.timestamp = 0;
info.proof.votes.fill(true);
return true;

case new_state::recommission:
Expand All @@ -430,6 +429,7 @@ namespace service_nodes
info.active_since_height = block_height;

// Move the SN at the back of the list as if it had just registered (or just won)
info.proof.votes.fill(true);
info.last_reward_block_height = block_height;
info.last_reward_transaction_index = std::numeric_limits<uint32_t>::max();
return true;
Expand Down
20 changes: 17 additions & 3 deletions src/cryptonote_core/service_node_quorum_cop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ namespace service_nodes

bool quorum_cop::handle_vote(quorum_vote_t const &vote, cryptonote::vote_verification_context &vvc)
{
vvc = {};
uint64_t curr_height = m_core.get_blockchain_storage().get_current_blockchain_height();
if (m_core.get_nettype() == cryptonote::MAINNET &&
curr_height >= HF_VERSION_12_CHECKPOINTING_SOFT_FORK_HEIGHT &&
Expand All @@ -424,12 +425,25 @@ namespace service_nodes
return true;
}

vvc = {};
std::shared_ptr<const testing_quorum> quorum = m_core.get_testing_quorum(vote.type, vote.block_height);
uint64_t quorum_height = vote.block_height;
if (vote.type == quorum_type::checkpointing)
{
if (vote.block_height < REORG_SAFETY_BUFFER_BLOCKS_POST_HF12)
{
vvc.m_invalid_block_height = true;
LOG_ERROR("Invalid vote height: " << vote.block_height << " would overflow after offsetting height to quorum");
return false;
}

quorum_height = vote.block_height - REORG_SAFETY_BUFFER_BLOCKS_POST_HF12;
}

std::shared_ptr<const testing_quorum> quorum = m_core.get_testing_quorum(vote.type, quorum_height);
if (!quorum)
{
// TODO(loki): Fatal error
LOG_ERROR("Quorum state for height: " << vote.block_height << " was not cached in daemon!");
vvc.m_invalid_block_height = true;
LOG_ERROR("Quorum state for height: " << quorum_height << " was not cached in daemon!");
return false;
}

Expand Down

0 comments on commit 36d4f37

Please sign in to comment.