Skip to content

Commit

Permalink
Add V13 height conditional for sidestake registry in GetLowestRegistr…
Browse files Browse the repository at this point in the history
…yBlockHeight()

When below Block13Height, the sidestake registry will report a height of zero when
initialized. This causes the wrong clamp to be applied to contract replay. This commit
fixes that issue.
  • Loading branch information
jamescowens committed Dec 23, 2023
1 parent b4785d7 commit c7ceef6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/gridcoin/contract/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,21 @@ class RegistryBookmarks
int lowest_height = std::numeric_limits<int>::max();

for (const auto& iter : m_db_heights) {
int db_height = iter.second;

//! When below the operational range of the sidestake contracts and registry, initialization of the sidestake
//! registry will report zero for height. It is undesirable to return this in the GetLowestRegistryBlockHeight()
//! method, because it will cause the contract replay clamp to go to the Fern mandatory blockheight. Setting
//! the db_height recorded in the bookmarks at V13 height for the sidestake registry for the purpose of contract
//! replay solves the problem.
//!
//! This code can be removed after the V13 mandatory blockheight has been reached.
if (iter.first == GRC::ContractType::SIDESTAKE and db_height < Params().GetConsensus().BlockV13Height) {
db_height = Params().GetConsensus().BlockV13Height;
}

if (iter.second < lowest_height) {
lowest_height = iter.second;
lowest_height = db_height;
}
}

Expand Down

0 comments on commit c7ceef6

Please sign in to comment.