Skip to content

Commit

Permalink
Fix error in no undo hash (#3116)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushstar authored Nov 8, 2024
1 parent 7720b2f commit 8abe263
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/dfi/masternodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ std::pair<std::string, std::string> GetDVMDBHashes(CCustomCSView &view) {
unsigned char hash[CSHA256::OUTPUT_SIZE];
unsigned char hashNoUndo[CSHA256::OUTPUT_SIZE];
hasher.Finalize(hash);
hasher.Finalize(hashNoUndo);
hasherNoUndo.Finalize(hashNoUndo);

// Convert hashes to hex string
const auto hashHex = HexStr(hash, hash + CSHA256::OUTPUT_SIZE);
Expand Down
3 changes: 3 additions & 0 deletions src/dfi/rpc_accounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3668,6 +3668,9 @@ UniValue logdvmstate(const JSONRPCRequest &request) {
pcursor->Next();
}

// Delete iterator
delete pcursor;

if (outFile.is_open()) {
outFile.close();
}
Expand Down
20 changes: 10 additions & 10 deletions test/functional/feature_consolidate_rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def setup(self):
def pre_fork24_consolidate(self):

# Compare hash before consolidation
hash_0 = self.nodes[0].logdbhashes()["dvmhash"]
hash_1 = self.nodes[1].logdbhashes()["dvmhash"]
hash_0 = self.nodes[0].logdbhashes()["dvmhash_no_undo"]
hash_1 = self.nodes[1].logdbhashes()["dvmhash_no_undo"]
assert_equal(hash_0, hash_1)

# Generate rewards
Expand All @@ -167,7 +167,7 @@ def pre_fork24_consolidate(self):
self.stop_node(1)

# Start node with consolidation
self.args.append(f"-consolidaterewards={self.symbolGOOGL}")
self.args.append(f"-consolidaterewards={self.symbolGD}")
self.start_node(1, self.args)
connect_nodes_bi(self.nodes, 0, 1)

Expand All @@ -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"]
hash_1 = self.nodes[1].logdbhashes()["dvmhash"]
hash_0 = self.nodes[0].logdbhashes()["dvmhash_no_undo"]
hash_1 = self.nodes[1].logdbhashes()["dvmhash_no_undo"]
assert_equal(hash_0, hash_1)

def post_fork24_consolidate(self):
Expand All @@ -200,15 +200,15 @@ def post_fork24_consolidate(self):
self.sync_blocks()

# Compare hash before consolidation
hash_0 = self.nodes[0].logdbhashes()["dvmhash"]
hash_1 = self.nodes[1].logdbhashes()["dvmhash"]
hash_0 = self.nodes[0].logdbhashes()["dvmhash_no_undo"]
hash_1 = self.nodes[1].logdbhashes()["dvmhash_no_undo"]
assert_equal(hash_0, hash_1)

# Stop node
self.stop_node(1)

# Start node with consolidation
self.args.append(f"-consolidaterewards={self.symbolGOOGL}")
self.args.append(f"-consolidaterewards={self.symbolGD}")
self.start_node(1, self.args)
connect_nodes_bi(self.nodes, 0, 1)

Expand All @@ -224,8 +224,8 @@ def post_fork24_consolidate(self):
self.sync_blocks()

# Compare hash before consolidation
hash_0 = self.nodes[0].logdbhashes()["dvmhash"]
hash_1 = self.nodes[1].logdbhashes()["dvmhash"]
hash_0 = self.nodes[0].logdbhashes()["dvmhash_no_undo"]
hash_1 = self.nodes[1].logdbhashes()["dvmhash_no_undo"]
assert_equal(hash_0, hash_1)


Expand Down

0 comments on commit 8abe263

Please sign in to comment.