Skip to content

Commit

Permalink
added more strict pos validation
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptozoidberg committed Jun 17, 2019
1 parent 7382d6c commit 8245ea6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/currency_core/blockchain_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,13 @@ bool blockchain_storage::handle_alternative_block(const block& b, const crypto::
if (abei.height >= m_core_runtime_config.pos_minimum_heigh)
cumulative_diff_delta = correct_difficulty_with_sequence_factor(sequence_factor, cumulative_diff_delta);

if (pos_block && sequence_factor > 20)
{
LOG_PRINT_RED_L0("Alternative block " << id << " @ " << abei.height << " has too big sequence factor: " << sequence_factor << ", rejected");
bvc.m_verification_failed = true;
return false;
}

abei.cumulative_diff_adjusted += cumulative_diff_delta;

abei.cumulative_diff_precise = get_last_alt_x_block_cumulative_precise_difficulty(alt_chain, abei.height, pos_block);
Expand Down Expand Up @@ -4458,6 +4465,15 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
if (bei.height >= m_core_runtime_config.pos_minimum_heigh)
cumulative_diff_delta = correct_difficulty_with_sequence_factor(sequence_factor, cumulative_diff_delta);

if (is_pos_bl && sequence_factor > 20)
{
LOG_PRINT_L0("Block with id: " << id
<< " has too big sequence_factor = " << sequence_factor);
purge_block_data_from_blockchain(bl, tx_processed_count);
bvc.m_verification_failed = true;
return false;
}

bei.cumulative_diff_adjusted += cumulative_diff_delta;

//etc
Expand Down
1 change: 1 addition & 0 deletions utils/test_api_files/exec_getblocktemplate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl --data @getblocktemplate.json http://127.0.0.1:11211/json_rpc

0 comments on commit 8245ea6

Please sign in to comment.