Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14864874
D17710.id52820.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
D17710.id52820.diff
View Options
diff --git a/src/avalanche/processor.h b/src/avalanche/processor.h
--- a/src/avalanche/processor.h
+++ b/src/avalanche/processor.h
@@ -390,7 +390,7 @@
EXCLUSIVE_LOCKS_REQUIRED(!cs_stakeContenderCache, !cs_stakingRewards);
void acceptStakeContender(const StakeContenderId &contenderId)
EXCLUSIVE_LOCKS_REQUIRED(!cs_stakeContenderCache);
- void invalidateStakeContender(const StakeContenderId &contenderId)
+ void rejectStakeContender(const StakeContenderId &contenderId)
EXCLUSIVE_LOCKS_REQUIRED(!cs_stakeContenderCache);
/** Promote stake contender cache entries to the latest chain tip */
diff --git a/src/avalanche/processor.cpp b/src/avalanche/processor.cpp
--- a/src/avalanche/processor.cpp
+++ b/src/avalanche/processor.cpp
@@ -1051,9 +1051,9 @@
stakeContenderCache.accept(contenderId);
}
-void Processor::invalidateStakeContender(const StakeContenderId &contenderId) {
+void Processor::rejectStakeContender(const StakeContenderId &contenderId) {
LOCK(cs_stakeContenderCache);
- stakeContenderCache.invalidate(contenderId);
+ stakeContenderCache.reject(contenderId);
}
void Processor::promoteStakeContendersToTip() {
diff --git a/src/avalanche/stakecontendercache.h b/src/avalanche/stakecontendercache.h
--- a/src/avalanche/stakecontendercache.h
+++ b/src/avalanche/stakecontendercache.h
@@ -161,7 +161,6 @@
bool accept(const StakeContenderId &contenderId);
bool finalize(const StakeContenderId &contenderId);
bool reject(const StakeContenderId &contenderId);
- bool invalidate(const StakeContenderId &contenderId);
/**
* Get contender acceptance state for avalanche voting.
diff --git a/src/avalanche/stakecontendercache.cpp b/src/avalanche/stakecontendercache.cpp
--- a/src/avalanche/stakecontendercache.cpp
+++ b/src/avalanche/stakecontendercache.cpp
@@ -120,19 +120,6 @@
});
}
-bool StakeContenderCache::invalidate(const StakeContenderId &contenderId) {
- auto &view = contenders.get<by_stakecontenderid>();
- auto it = view.find(contenderId);
- if (it == view.end()) {
- return false;
- }
-
- return contenders.modify(it, [&](StakeContenderCacheEntry &entry) {
- entry.status &= ~(StakeContenderStatus::ACCEPTED |
- StakeContenderStatus::IN_WINNER_SET);
- });
-}
-
int StakeContenderCache::getVoteStatus(const StakeContenderId &contenderId,
BlockHash &prevblockhashout) const {
auto &view = contenders.get<by_stakecontenderid>();
diff --git a/src/avalanche/test/processor_tests.cpp b/src/avalanche/test/processor_tests.cpp
--- a/src/avalanche/test/processor_tests.cpp
+++ b/src/avalanche/test/processor_tests.cpp
@@ -449,7 +449,7 @@
}
void invalidateItem(const StakeContenderId &contenderId) {
- fixture->m_processor->invalidateStakeContender(contenderId);
+ fixture->m_processor->rejectStakeContender(contenderId);
// Warning: This is a special case for stake contenders because
// invalidation does not cause isWorthPolling to return false. This is
diff --git a/src/avalanche/test/stakecontendercache_tests.cpp b/src/avalanche/test/stakecontendercache_tests.cpp
--- a/src/avalanche/test/stakecontendercache_tests.cpp
+++ b/src/avalanche/test/stakecontendercache_tests.cpp
@@ -116,9 +116,6 @@
cache.finalize(StakeContenderId(blockhash, proof->getId()));
CheckVoteStatus(cache, blockhash, proof, 0);
- cache.invalidate(StakeContenderId(blockhash, proof->getId()));
- CheckVoteStatus(cache, blockhash, proof, 1);
-
// Add the proof as a manual winner. It should always be accepted.
BOOST_CHECK(cache.setWinners(pindex, {proof->getPayoutScript()}));
CheckVoteStatus(cache, blockhash, proof, 0);
@@ -233,23 +230,16 @@
CheckWinners(cache, blockhash, moreManualWinners,
{proofs[0], proofs[2]});
- // Avalanche invalidating a contender not in the winner set makes no
- // difference
- cache.invalidate(StakeContenderId(blockhash, proofs[3]->getId()));
- CheckWinners(cache, blockhash, moreManualWinners,
- {proofs[0], proofs[2]});
-
// Avalanche finalizing a contender that wasn't in the winner set before
// makes a new winner
cache.finalize(StakeContenderId(blockhash, proofs[1]->getId()));
CheckWinners(cache, blockhash, moreManualWinners,
{proofs[0], proofs[1], proofs[2]});
- // Avalanche invalidating a contender that was in the winner set removes
- // it
- cache.invalidate(StakeContenderId(blockhash, proofs[2]->getId()));
+ // Avalanche invalidating a contender that was finalized has no effect.
+ cache.reject(StakeContenderId(blockhash, proofs[1]->getId()));
CheckWinners(cache, blockhash, moreManualWinners,
- {proofs[0], proofs[1]});
+ {proofs[0], proofs[1], proofs[2]});
pindex = pindex->pprev;
}
@@ -264,7 +254,7 @@
pindex = active_chainstate.m_chain.Tip();
for (int i = 0; i < 5; i++) {
CheckWinners(cache, pindex->GetBlockHash(), manualWinners,
- {proofs[0], proofs[1]});
+ {proofs[0], proofs[1], proofs[2]});
for (int p = 0; p < 4; p++) {
CheckVoteStatus(cache, pindex->GetBlockHash(), proofs[p], 0);
}
@@ -359,16 +349,6 @@
CheckWinners(cache, blockhashes[2], {}, {});
CheckWinners(cache, blockhashes[3], {}, {});
- // Invalidate proofs so they are no longer in the winner set
- for (const auto &proof : proofs) {
- cache.invalidate(StakeContenderId(blockhashes[1], proof->getId()));
- }
- CheckWinners(cache, blockhashes[0], {}, {});
- CheckWinners(cache, blockhashes[1], {}, {});
- CheckWinners(cache, blockhashes[2], {}, {});
- CheckWinners(cache, blockhashes[3], {}, {});
- BOOST_CHECK(!cache.isEmpty());
-
// Clean up the remaining block and the cache should be empty now
cache.promoteToBlock(active_chainstate.m_chain.Tip(), pm);
cache.cleanup(100);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 20, 22:57 (4 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5865655
Default Alt Text
D17710.id52820.diff (6 KB)
Attached To
D17710: [avalanche] Simplify contenders by treating rejection and invalidation the same
Event Timeline
Log In to Comment