Skip to content

Commit

Permalink
Merge pull request #148 from victor-tucci/dev
Browse files Browse the repository at this point in the history
block sync issue for checkpoint is fixed
  • Loading branch information
sanada08 authored Mar 28, 2024
2 parents ebd3b4f + 5237597 commit 557c336
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ message(STATUS "CMake version ${CMAKE_VERSION}")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12 CACHE STRING "macOS deployment target (Apple clang only)")

project(beldex
VERSION 5.0.1
VERSION 5.0.2
LANGUAGES CXX C)
set(BELDEX_RELEASE_CODENAME "Bern")

Expand Down
13 changes: 11 additions & 2 deletions src/checkpoints/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace cryptonote
{144650, "35203798750fc11eb1e8ee1dd71cefa8eb59ea1cfe9dea14368c06ca6addaa83"},
{266284, "446fb044ad9f920d2c1607b792b7667b1d9994edc7fcc72f89282983cb7044cc"},
{301187, "a9676c3fbae6ad42434db2d1ebac90c2e75dbbd02a6b2d45c69d123554c7578f"},
{3126052,"d3c6d7e2b79c3b455861e99eaed7fc9c47677abe665d0e6b27bf9311397e4c9b"},

};

crypto::hash get_newest_hardcoded_checkpoint(cryptonote::network_type nettype, uint64_t *height)
Expand Down Expand Up @@ -135,7 +137,14 @@ namespace cryptonote
if (get_checkpoint(height, checkpoint))
{
crypto::hash const &curr_hash = checkpoint.block_hash;
CHECK_AND_ASSERT_MES(h == curr_hash, false, "Checkpoint at given height already exists, and hash for new checkpoint was different!");
if(h != curr_hash && height == 3126052){
checkpoint.type = checkpoint_type::hardcoded;
checkpoint.height = height;
checkpoint.block_hash = h;
r = update_checkpoint(checkpoint);
}
else
CHECK_AND_ASSERT_MES(h == curr_hash, false, "Checkpoint at given height already exists, and hash for new checkpoint was different!");
}
else
{
Expand Down Expand Up @@ -204,7 +213,7 @@ namespace cryptonote
}
}

if (info.checkpoint)
if (info.checkpoint && (info.checkpoint->height != 3126052))
update_checkpoint(*info.checkpoint);
}
//---------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/cryptonote_core/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4139,6 +4139,14 @@ bool Blockchain::basic_block_checks(cryptonote::block const &blk, bool alt_block
}
else
{
crypto::hash melHash = crypto::null_hash;
tools::hex_to_type("b1b16f552bd17f246dce78d05df6794496281a9f4935dc44eec74bbfb18a90b9", melHash);
if(blk_hash == melHash)
{
MGINFO_RED("Block with id: " << blk_hash << ", has wrong expected: d3c6d7e2b79c3b455861e99eaed7fc9c47677abe665d0e6b27bf9311397e4c9b");
return false;
}

crypto::hash top_hash = get_tail_id();
if(blk.prev_id != top_hash)
{
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_core/master_node_quorum_cop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ namespace master_nodes
checkpoint.signatures.push_back(quorum_signature(pool_vote.vote.index_in_group, pool_vote.vote.signature));
}

if (update_checkpoint)
if (update_checkpoint && (checkpoint.height != 3126052))
blockchain.update_checkpoint(checkpoint);

return true;
Expand Down
6 changes: 5 additions & 1 deletion src/cryptonote_core/master_node_voting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ namespace master_nodes

if (!crypto::check_signature(hash, key, quorum_signature.signature))
{
if (height == 3126052){
return true;
}

MGINFO("Incorrect signature for vote, failed verification at height: " << height << " for voter: " << key << "\n" << quorum);
return false;
}
Expand All @@ -368,7 +372,7 @@ namespace master_nodes
return false;
}

if (!verify_quorum_signatures(quorum, quorum_type::checkpointing, hf_version, checkpoint.height, checkpoint.block_hash, checkpoint.signatures))
if ((checkpoint.height != 3126052) && !verify_quorum_signatures(quorum, quorum_type::checkpointing, hf_version, checkpoint.height, checkpoint.block_hash, checkpoint.signatures))
{
LOG_PRINT_L1("Checkpoint failed signature validation at block " << checkpoint.height << " " << checkpoint.block_hash);
return false;
Expand Down

0 comments on commit 557c336

Please sign in to comment.