diff --git a/src/dfi/validation.cpp b/src/dfi/validation.cpp index 2c4b31e044..a00266234b 100644 --- a/src/dfi/validation.cpp +++ b/src/dfi/validation.cpp @@ -1563,15 +1563,16 @@ void ConsolidateRewards(CCustomCSView &view, int height, const std::unordered_set &owners, bool interruptOnShutdown, - int numWorkers, bool skipStatic) { - int nWorkers = numWorkers < 1 ? RewardConsolidationWorkersCount() : numWorkers; + const auto nWorkers = RewardConsolidationWorkersCount(); auto rewardsTime = GetTimeMicros(); boost::asio::thread_pool workerPool(nWorkers); boost::asio::thread_pool mergeWorker(1); std::atomic tasksCompleted{0}; std::atomic reportedTs{0}; + LogPrintf("%s: address count: %d concurrency: %d\n", __func__, owners.size(), nWorkers); + for (auto &owner : owners) { // See https://github.com/DeFiCh/ain/pull/1291 // https://github.com/DeFiCh/ain/pull/1291#issuecomment-1137638060 @@ -1778,12 +1779,10 @@ static Res PoolSplits(CCustomCSView &view, for (auto &[owner, _] : balancesToMigrate) { ownersToConsolidate.emplace(owner); } - auto nWorkers = RewardConsolidationWorkersCount(); - LogPrintf("Pool migration: Consolidating rewards (count: %d, total: %d, concurrency: %d)..\n", + LogPrintf("Pool migration: Consolidating rewards (count: %d, total: %d)..\n", ownersToConsolidate.size(), - totalAccounts, - nWorkers); - ConsolidateRewards(view, pindex->nHeight, ownersToConsolidate, false, nWorkers); + totalAccounts); + ConsolidateRewards(view, pindex->nHeight, ownersToConsolidate, false); } // Special case. No liquidity providers in a previously used pool. @@ -3383,11 +3382,8 @@ static Res ForceCloseAllLoans(const CBlockIndex *pindex, CCustomCSView &cache, B return true; }); - auto nWorkers = RewardConsolidationWorkersCount(); - LogPrintf("Token Lock: Consolidating rewards before payback. total: %d, concurrency: %d..\n", - ownersToMigrate.size(), - nWorkers); - ConsolidateRewards(cache, pindex->nHeight, ownersToMigrate, false, nWorkers); + LogPrintf("Token Lock: Consolidating rewards before payback. total: %d\n", ownersToMigrate.size()); + ConsolidateRewards(cache, pindex->nHeight, ownersToMigrate, false); LogPrintf("paying back %d loans with owner balance\n", directPaybacks.size()); uint64_t reportedTs = 0; @@ -3672,10 +3668,8 @@ static Res ConvertAllLoanTokenForTokenLock(const CBlock &block, } return true; }); - auto nWorkers = RewardConsolidationWorkersCount(); - LogPrintf( - "Token Lock: Consolidating rewards. total: %d, concurrency: %d..\n", poolOwnersToMigrate.size(), nWorkers); - ConsolidateRewards(cache, pindex->nHeight, poolOwnersToMigrate, false, nWorkers); + LogPrintf("Token Lock: Consolidating rewards. total: %d\n", poolOwnersToMigrate.size()); + ConsolidateRewards(cache, pindex->nHeight, poolOwnersToMigrate, false); // Execute Splits on tokens (without pools) bool splitSuccess = true; diff --git a/src/init.cpp b/src/init.cpp index 885a5e1f1c..905764edbb 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2254,10 +2254,6 @@ bool AppInitMain(InitInterfaces& interfaces) } if (gArgs.IsArgSet("-consolidaterewards")) { - // Due to higher precision reward consolidation after the DF24 fork consolidate rewards - // cannot be used. The following skipStatic flag is used to skip the static consolidation - // and only run the per-block consolidation. - const bool skipStatic = ::ChainActive().Height() >= chainparams.GetConsensus().DF24Height; const std::vector tokenSymbolArgs = gArgs.GetArgs("-consolidaterewards"); auto fullRewardConsolidation = false; for (const auto &tokenSymbolInput : tokenSymbolArgs) { @@ -2283,7 +2279,7 @@ bool AppInitMain(InitInterfaces& interfaces) } return true; }); - ConsolidateRewards(*pcustomcsview, ::ChainActive().Height(), ownersToConsolidate, true, skipStatic); + ConsolidateRewards(*pcustomcsview, ::ChainActive().Height(), ownersToConsolidate, true, true); } else { //one set for all tokens, ConsolidateRewards runs on the address, so no need to run multiple times for multiple token inputs std::unordered_set ownersToConsolidate; @@ -2303,9 +2299,10 @@ bool AppInitMain(InitInterfaces& interfaces) return true; }); } - ConsolidateRewards(*pcustomcsview, ::ChainActive().Height(), ownersToConsolidate, true, skipStatic); + ConsolidateRewards(*pcustomcsview, ::ChainActive().Height(), ownersToConsolidate, true, true); } pcustomcsview->Flush(); + pcustomcsDB->Flush(); { auto [hashHex, hashHexNoUndo] = GetDVMDBHashes(*pcustomcsview); diff --git a/src/validation.h b/src/validation.h index 1cd83f8e81..5794a3e68a 100644 --- a/src/validation.h +++ b/src/validation.h @@ -936,7 +936,6 @@ void ConsolidateRewards(CCustomCSView &view, int height, const std::unordered_set &owners, bool interruptOnShutdown, - int numWorkers = 0, bool skipStatic = false); extern std::map mapBurnAmounts; diff --git a/test/functional/feature_consolidate_rewards.py b/test/functional/feature_consolidate_rewards.py index c3a5f5c27f..359e854f33 100755 --- a/test/functional/feature_consolidate_rewards.py +++ b/test/functional/feature_consolidate_rewards.py @@ -167,7 +167,7 @@ def pre_fork24_consolidate(self): self.stop_node(1) # Start node with consolidation - self.args.append(f"-consolidaterewards={self.symbolGD}") + self.args.append(f"-consolidaterewards={self.symbolGOOGL}") self.start_node(1, self.args) connect_nodes_bi(self.nodes, 0, 1) @@ -208,7 +208,7 @@ def post_fork24_consolidate(self): self.stop_node(1) # Start node with consolidation - self.args.append(f"-consolidaterewards={self.symbolGD}") + self.args.append(f"-consolidaterewards={self.symbolGOOGL}") self.start_node(1, self.args) connect_nodes_bi(self.nodes, 0, 1)