Merge branch 'fix_hf_745383' into v17_master
This commit is contained in:
commit
0893beb143
5 changed files with 86 additions and 31 deletions
|
@ -3,7 +3,7 @@ AC_PREREQ([2.60])
|
|||
define(_CLIENT_VERSION_MAJOR, 0)
|
||||
define(_CLIENT_VERSION_MINOR, 17)
|
||||
define(_CLIENT_VERSION_REVISION, 4)
|
||||
define(_CLIENT_VERSION_BUILD, 4)
|
||||
define(_CLIENT_VERSION_BUILD, 5)
|
||||
define(_CLIENT_VERSION_IS_RELEASE, true)
|
||||
define(_COPYRIGHT_YEAR, 2019)
|
||||
define(_COPYRIGHT_HOLDERS,[The %s developers])
|
||||
|
|
|
@ -144,7 +144,7 @@ public:
|
|||
consensus.nAllowMinDiffMaxHeight = -1;
|
||||
consensus.nNormalizedNameForkHeight = 539940; // targeting 21 March 2019
|
||||
consensus.nMinRemovalWorkaroundHeight = 297706;
|
||||
consensus.nMaxRemovalWorkaroundHeight = 100000000;
|
||||
consensus.nMaxRemovalWorkaroundHeight = 658300;
|
||||
consensus.nWitnessForkHeight = 680770; // targeting 11 Dec 2019
|
||||
consensus.nAllClaimsInMerkleForkHeight = 658310; // targeting 30 Oct 2019
|
||||
consensus.fPowAllowMinDifficultyBlocks = false;
|
||||
|
@ -166,10 +166,10 @@ public:
|
|||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1548288000; // Jan 24, 2019
|
||||
|
||||
// The best chain should have at least this much work.
|
||||
consensus.nMinimumChainWork = uint256S("0000000000000000000000000000000000000000000002bfdb5232f364d6774e"); //700k
|
||||
consensus.nMinimumChainWork = uint256S("0000000000000000000000000000000000000000000003253077412df5b49766"); //749k
|
||||
|
||||
// By default assume that the signatures in ancestors of this block are valid.
|
||||
consensus.defaultAssumeValid = uint256S("beaf6432c9a7be3ea8c333bd7a90d4b3e07b0f20c86aa2e5dfebc9eba340201c"); //700k
|
||||
consensus.defaultAssumeValid = uint256S("b9676f45be594438a2011407c93bb530d817fa365846e7a6ecdf2790e4a0ad6b"); //749k
|
||||
|
||||
/**
|
||||
* The message start string is designed to be unlikely to occur in normal data.
|
||||
|
@ -287,10 +287,10 @@ public:
|
|||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1585849000; // Apr 2nd 2020
|
||||
|
||||
// The best chain should have at least this much work.
|
||||
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000000000004f6bb06a9");
|
||||
consensus.nMinimumChainWork = uint256S("00000000000000000000000000000000000000000000000000000054b7d280af"); // 8400
|
||||
|
||||
// By default assume that the signatures in ancestors of this block are valid.
|
||||
consensus.defaultAssumeValid = uint256S("0x079557d16edcd640c4057c9fddb81257263014fe384c4aa348c5b9d190650a46"); // 14
|
||||
consensus.defaultAssumeValid = uint256S("50b68b892f4e0f2ef649df37ef10b702e826c8913cc785c5e8ec16dd6be83f8b"); // 8400
|
||||
|
||||
pchMessageStart[0] = 0xfa;
|
||||
pchMessageStart[1] = 0xe4;
|
||||
|
|
|
@ -198,6 +198,27 @@ bool CClaimTrieCacheBase::haveSupportInQueue(const std::string& name, const COut
|
|||
return false;
|
||||
}
|
||||
|
||||
bool emptyNodeShouldExistAt(sqlite::database& db, const std::string& name, int nNextHeight, int requiredChildren) {
|
||||
auto end = name + std::string(256, std::numeric_limits<char>::max()); // 256 == MAX_CLAIM_NAME_SIZE + 1
|
||||
auto query = db << "SELECT DISTINCT nodeName FROM claim "
|
||||
"WHERE nodeName BETWEEN ?1 AND ?2 "
|
||||
"AND activationHeight < ?3 AND expirationHeight >= ?3 "
|
||||
"ORDER BY nodeName"
|
||||
<< name << end << nNextHeight;
|
||||
std::unordered_set<char> ss;
|
||||
for (auto&& row: query) {
|
||||
std::string nn;
|
||||
row >> nn;
|
||||
if (nn == name)
|
||||
return false;
|
||||
assert(nn.size() > name.size());
|
||||
ss.insert(nn[name.size()]);
|
||||
if (ss.size() >= requiredChildren)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CClaimTrieCacheBase::deleteNodeIfPossible(const std::string& name, std::string& parent, int64_t& claims)
|
||||
{
|
||||
if (name.empty()) return false;
|
||||
|
@ -676,19 +697,10 @@ bool CClaimTrieCacheBase::removeClaim(const uint160& claimId, const COutPoint& o
|
|||
// because it's a parent one and should not be effectively erased
|
||||
// we had a bug in the old code where that situation would force a zero delay on re-add
|
||||
if (nNextHeight >= base->nMinRemovalWorkaroundHeight
|
||||
&& nNextHeight < base->nMaxRemovalWorkaroundHeight) { // TODO: hard fork this out (which we already tried once but failed)
|
||||
// neither LIKE nor SUBSTR will use an index on a blob, but BETWEEN is a good, fast alternative
|
||||
auto end = nodeName + std::string( 256, std::numeric_limits<char>::max()); // 256 == MAX_CLAIM_NAME_SIZE + 1
|
||||
auto innerQuery = db << "SELECT nodeName FROM claim WHERE nodeName BETWEEN ?1 AND ?2 "
|
||||
"AND activationHeight < ?3 AND expirationHeight >= ?3 ORDER BY nodeName LIMIT 1"
|
||||
<< nodeName << end << nNextHeight;
|
||||
for (auto&& row: innerQuery) {
|
||||
std::string shortestMatch;
|
||||
row >> shortestMatch;
|
||||
if (shortestMatch != nodeName)
|
||||
// set this when there are no more claims on that name and that node still has children
|
||||
removalWorkaround.insert(nodeName);
|
||||
}
|
||||
&& nNextHeight < base->nMaxRemovalWorkaroundHeight
|
||||
) {
|
||||
if (emptyNodeShouldExistAt(db, nodeName, nNextHeight, 1))
|
||||
removalWorkaround.insert(nodeName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -845,14 +857,30 @@ int CClaimTrieCacheBase::getDelayForName(const std::string& name, const uint160&
|
|||
return 0;
|
||||
}
|
||||
|
||||
// NOTE: old code had a bug in it where nodes with no claims but with children would get left in the cache after removal.
|
||||
// This would cause the getNumBlocksOfContinuousOwnership to return zero (causing incorrect takeover height calc).
|
||||
auto hit = removalWorkaround.find(name);
|
||||
if (hit != removalWorkaround.end()) {
|
||||
removalWorkaround.erase(hit);
|
||||
return 0;
|
||||
if (nNextHeight > base->nMaxRemovalWorkaroundHeight) {
|
||||
if (!hasCurrentWinner)
|
||||
return 0;
|
||||
|
||||
// TODO: hard fork this out! It's wrong but kept for backwards compatibility
|
||||
// Plan: if we have no claims for this node but we do have multiple children
|
||||
// such that we have an implicit node here then return a 0
|
||||
if (emptyNodeShouldExistAt(db, name, nNextHeight, 2))
|
||||
return 0;
|
||||
}
|
||||
return hasCurrentWinner ? std::min((nNextHeight - winningTakeoverHeight) / base->nProportionalDelayFactor, 4032) : 0;
|
||||
else {
|
||||
// NOTE: old code had a bug in it where nodes with no claims but with children would get left in the cache after removal.
|
||||
// This would cause the getNumBlocksOfContinuousOwnership to return zero (causing incorrect takeover height calc).
|
||||
auto hit = removalWorkaround.find(name);
|
||||
if (hit != removalWorkaround.end()) {
|
||||
removalWorkaround.erase(hit);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasCurrentWinner)
|
||||
return 0;
|
||||
|
||||
return std::min((nNextHeight - winningTakeoverHeight) / base->nProportionalDelayFactor, 4032);
|
||||
}
|
||||
|
||||
std::string CClaimTrieCacheBase::adjustNameForValidHeight(const std::string& name, int validHeight) const
|
||||
|
|
|
@ -24,6 +24,32 @@ BOOST_AUTO_TEST_CASE(claim_replace_test) {
|
|||
BOOST_CHECK(fixture.is_best_claim("bassfisher", tx2));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(triple_update_test)
|
||||
{
|
||||
ClaimTrieChainFixture fixture;
|
||||
CMutableTransaction tx1 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 10);
|
||||
fixture.IncrementBlocks(1);
|
||||
CMutableTransaction tx1a = fixture.MakeClaim(fixture.GetCoinbase(), "tester", "one", 3);
|
||||
CMutableTransaction tx2 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 5);
|
||||
auto height = chainActive.Tip()->nHeight;
|
||||
fixture.IncrementBlocks(9);
|
||||
|
||||
CMutableTransaction tx3 = fixture.MakeUpdate(tx1, "test", "two", ClaimIdHash(tx1.GetHash(), 0), 10);
|
||||
CMutableTransaction tx4 = fixture.MakeUpdate(tx2, "test", "two", ClaimIdHash(tx2.GetHash(), 0), 15);
|
||||
CMutableTransaction tx5 = fixture.MakeUpdate(tx4, "test", "two", ClaimIdHash(tx2.GetHash(), 0), 5);
|
||||
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(fixture.is_best_claim("test", tx3));
|
||||
uint160 id; int takeover;
|
||||
BOOST_REQUIRE(fixture.getLastTakeoverForName("test", id, takeover));
|
||||
BOOST_CHECK_EQUAL(takeover, height);
|
||||
id = ClaimIdHash(tx2.GetHash(), 0);
|
||||
std::string name;
|
||||
CClaimValue value;
|
||||
BOOST_REQUIRE(fixture.getClaimById(id, name, value));
|
||||
BOOST_CHECK_EQUAL(value.nValidAtHeight, height+20);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(takeover_stability_test) {
|
||||
// no competing bids
|
||||
ClaimTrieChainFixture fixture;
|
||||
|
|
|
@ -823,11 +823,12 @@ BOOST_AUTO_TEST_CASE(removal_workaround_functions)
|
|||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(fixture.is_best_claim("a", tx3a));
|
||||
|
||||
fixture.IncrementBlocks(7);
|
||||
CMutableTransaction tx4a = fixture.MakeUpdate(tx2a, "b", "b", ClaimIdHash(tx2a.GetHash(), 0), 4);
|
||||
CMutableTransaction tx4b = fixture.MakeUpdate(tx2b, "b", "b", ClaimIdHash(tx2b.GetHash(), 0), 5); // trigger a takeover
|
||||
fixture.IncrementBlocks(1);
|
||||
BOOST_CHECK(fixture.is_best_claim("b", tx4b));
|
||||
// TODO: bring this back after we hard fork out the removal workaround part 2!
|
||||
// fixture.IncrementBlocks(7);
|
||||
// CMutableTransaction tx4a = fixture.MakeUpdate(tx2a, "b", "b", ClaimIdHash(tx2a.GetHash(), 0), 4);
|
||||
// CMutableTransaction tx4b = fixture.MakeUpdate(tx2b, "b", "b", ClaimIdHash(tx2b.GetHash(), 0), 5); // trigger a takeover
|
||||
// fixture.IncrementBlocks(1);
|
||||
// BOOST_CHECK(fixture.is_best_claim("b", tx4b));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
Loading…
Add table
Reference in a new issue