diff --git a/src/dfi/masternodes.cpp b/src/dfi/masternodes.cpp index 3d93bd4ca4..658f072d60 100644 --- a/src/dfi/masternodes.cpp +++ b/src/dfi/masternodes.cpp @@ -1436,7 +1436,7 @@ void CalcMissingRewardTempFix(CCustomCSView &mnview, const uint32_t targetHeight } } -std::pair GetDVMDBHashes(CCustomCSView &view) { +std::tuple GetDVMDBHashes(CCustomCSView &view) { auto db = view.GetStorage().GetStorageLevelDB()->GetDB(); // Create a CDBIterator @@ -1445,6 +1445,7 @@ std::pair GetDVMDBHashes(CCustomCSView &view) { // Create SHA256 hashers CSHA256 hasher; CSHA256 hasherNoUndo; + CSHA256 hasherAccount; // Seek to the beginning of the database pcursor->SeekToFirst(); @@ -1456,9 +1457,15 @@ std::pair GetDVMDBHashes(CCustomCSView &view) { auto valueSlice = pcursor->GetValue(); const auto key = std::string(keySlice.data(), keySlice.size()); - if (!key.empty() && key[0] != 'u') { - hasherNoUndo.Write((const unsigned char *)keySlice.data(), keySlice.size()); - hasherNoUndo.Write((const unsigned char *)valueSlice.data(), valueSlice.size()); + if (!key.empty()) { + if (key[0] != 'u') { + hasherNoUndo.Write((const unsigned char *)keySlice.data(), keySlice.size()); + hasherNoUndo.Write((const unsigned char *)valueSlice.data(), valueSlice.size()); + } + if (key[0] == 'a') { + hasherAccount.Write((const unsigned char *)keySlice.data(), keySlice.size()); + hasherAccount.Write((const unsigned char *)valueSlice.data(), valueSlice.size()); + } } hasher.Write((const unsigned char *)keySlice.data(), keySlice.size()); @@ -1474,12 +1481,15 @@ std::pair GetDVMDBHashes(CCustomCSView &view) { // Finalize the hashes unsigned char hash[CSHA256::OUTPUT_SIZE]; unsigned char hashNoUndo[CSHA256::OUTPUT_SIZE]; + unsigned char hashAccount[CSHA256::OUTPUT_SIZE]; hasher.Finalize(hash); hasherNoUndo.Finalize(hashNoUndo); + hasherAccount.Finalize(hashAccount); // Convert hashes to hex string const auto hashHex = HexStr(hash, hash + CSHA256::OUTPUT_SIZE); const auto hashHexNoUndo = HexStr(hashNoUndo, hashNoUndo + CSHA256::OUTPUT_SIZE); + const auto hashHexAccount = HexStr(hashAccount, hashAccount + CSHA256::OUTPUT_SIZE); - return {hashHex, hashHexNoUndo}; + return {hashHex, hashHexNoUndo, hashHexAccount}; } \ No newline at end of file diff --git a/src/dfi/masternodes.h b/src/dfi/masternodes.h index 1f2b0db9d2..0e50c4319a 100644 --- a/src/dfi/masternodes.h +++ b/src/dfi/masternodes.h @@ -51,7 +51,7 @@ CAmount GetProposalCreationFee(int height, const CCustomCSView &view, const CCre // Missing call fixed in: https://github.com/DeFiCh/ain/pull/1766 void CalcMissingRewardTempFix(CCustomCSView &mnview, const uint32_t targetHeight, const CWallet &wallet); -std::pair GetDVMDBHashes(CCustomCSView &view); +std::tuple GetDVMDBHashes(CCustomCSView &view); enum class UpdateMasternodeType : uint8_t { None = 0x00, diff --git a/src/dfi/rpc_accounts.cpp b/src/dfi/rpc_accounts.cpp index b28a759085..fc10cffeb8 100644 --- a/src/dfi/rpc_accounts.cpp +++ b/src/dfi/rpc_accounts.cpp @@ -3697,7 +3697,7 @@ UniValue logdbhashes(const JSONRPCRequest &request) { pcustomcsview->Flush(); pcustomcsDB->Flush(); - auto [hashHex, hashHexNoUndo] = GetDVMDBHashes(*pcustomcsview); + auto [hashHex, hashHexNoUndo, hashHexAccount] = GetDVMDBHashes(*pcustomcsview); // Get the current block height const auto height = ::ChainActive().Height(); @@ -3713,6 +3713,7 @@ UniValue logdbhashes(const JSONRPCRequest &request) { // - consolidaterewards at different points if pre-static addresses are involved. result.pushKV("dvmhash", hashHex); result.pushKV("dvmwithoutundohash", hashHexNoUndo); + result.pushKV("dvmaccounthashes", hashHexAccount); auto res = XResultValueLogged(evm_try_get_latest_block_hash(result)); if (res) { diff --git a/src/init.cpp b/src/init.cpp index b8fba88a61..e135c8a96f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2251,8 +2251,8 @@ bool AppInitMain(InitInterfaces& interfaces) } { - auto [hashHex, hashHexNoUndo] = GetDVMDBHashes(*pcustomcsview); - LogPrintf("Pre-consolidate rewards for DVM hash: %s hash-no-undo: %s\n", hashHex, hashHexNoUndo); + auto [hashHex, hashHexNoUndo, hashHexAccount] = GetDVMDBHashes(*pcustomcsview); + LogPrintf("Pre-consolidate rewards for DVM hash: %s hash-no-undo: %s hash-account: %s\n", hashHex, hashHexNoUndo, hashHexAccount); } if (fullRewardConsolidation) { @@ -2291,8 +2291,8 @@ bool AppInitMain(InitInterfaces& interfaces) pcustomcsDB->Flush(); { - auto [hashHex, hashHexNoUndo] = GetDVMDBHashes(*pcustomcsview); - LogPrintf("Post-consolidate rewards for DVM hash: %s hash-no-undo: %s\n", hashHex, hashHexNoUndo); + auto [hashHex, hashHexNoUndo, hashHexAccount] = GetDVMDBHashes(*pcustomcsview); + LogPrintf("Post-consolidate rewards for DVM hash: %s hash-no-undo: %s hash-account: %s\n", hashHex, hashHexNoUndo, hashHexAccount); } } diff --git a/test/functional/feature_consolidate_rewards.py b/test/functional/feature_consolidate_rewards.py index d012f2ba23..eee5b1176d 100755 --- a/test/functional/feature_consolidate_rewards.py +++ b/test/functional/feature_consolidate_rewards.py @@ -155,8 +155,8 @@ def setup(self): def pre_fork24_consolidate(self): # Compare hash before consolidation - hash_0 = self.nodes[0].logdbhashes()["dvmhash_no_undo"] - hash_1 = self.nodes[1].logdbhashes()["dvmhash_no_undo"] + hash_0 = self.nodes[0].logdbhashes()["dvmwithoutundohash"] + hash_1 = self.nodes[1].logdbhashes()["dvmwithoutundohash"] assert_equal(hash_0, hash_1) # Generate rewards @@ -186,8 +186,8 @@ def pre_fork24_consolidate(self): self.idGOOGL = list(self.nodes[0].gettoken(self.symbolGOOGL).keys())[0] # Compare hash before consolidation - hash_0 = self.nodes[0].logdbhashes()["dvmhash_no_undo"] - hash_1 = self.nodes[1].logdbhashes()["dvmhash_no_undo"] + hash_0 = self.nodes[0].logdbhashes()["dvmwithoutundohash"] + hash_1 = self.nodes[1].logdbhashes()["dvmwithoutundohash"] assert_equal(hash_0, hash_1) def post_fork24_consolidate(self): @@ -200,8 +200,8 @@ def post_fork24_consolidate(self): self.sync_blocks() # Compare hash before consolidation - hash_0 = self.nodes[0].logdbhashes()["dvmhash_no_undo"] - hash_1 = self.nodes[1].logdbhashes()["dvmhash_no_undo"] + hash_0 = self.nodes[0].logdbhashes()["dvmwithoutundohash"] + hash_1 = self.nodes[1].logdbhashes()["dvmwithoutundohash"] assert_equal(hash_0, hash_1) # Stop node @@ -224,8 +224,8 @@ def post_fork24_consolidate(self): self.sync_blocks() # Compare hash before consolidation - hash_0 = self.nodes[0].logdbhashes()["dvmhash_no_undo"] - hash_1 = self.nodes[1].logdbhashes()["dvmhash_no_undo"] + hash_0 = self.nodes[0].logdbhashes()["dvmwithoutundohash"] + hash_1 = self.nodes[1].logdbhashes()["dvmwithoutundohash"] assert_equal(hash_0, hash_1)