Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/assets/assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,15 @@ bool CAssetsCache::Flush(bool fSoftCopy, bool fFlushDB)
}

for (auto undoReissue : setNewReissueToRemove) {
// In the case the the issue and reissue are both being removed
// we can skip this call because the removal of the issue should remove all data pertaining the to asset
// Fixes the issue where the reissue data will write over the removed asset meta data that was removed above
CNewAsset asset(undoReissue.reissue.strName, 0);
CAssetCacheNewAsset testNewAssetCache(asset, "", 0 , uint256());
if (setNewAssetsToRemove.count(testNewAssetCache)) {
continue;
}

auto reissue_name = undoReissue.reissue.strName;
if (mapReissuedAssetData.count(reissue_name)) {
if(!passetsdb->WriteAssetData(mapReissuedAssetData.at(reissue_name), undoReissue.blockHeight, undoReissue.blockHash)) {
Expand Down
21 changes: 21 additions & 0 deletions test/functional/feature_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,34 @@ def ipfs_state(self):
assert_equal(1, ad['has_ipfs'])
assert_equal(ipfs_hash, ad['ipfs_hash'])

def db_corruption_regression(self):
self.log.info("Checking db corruption invalidate block...")
n0 = self.nodes[0]
asset_name = "DATA_CORRUPT"

# Test to make sure that undoing a reissue and an issue during a reorg doesn't screw up the database/cache
n0.issue(asset_name)
a = n0.generate(1)[0]
print(a)

n0.reissue(asset_name, 500, n0.getnewaddress())
b = n0.generate(1)[0]
print(b)

print(f"Invalidating {a}...")
n0.invalidateblock(a)

print(n0.listassets(asset_name, True))
assert_equal(0, len(n0.listassets(asset_name, True)))


def run_test(self):
self.activate_assets()
self.big_test()
self.issue_param_checks()
self.chain_assets()
self.ipfs_state()
self.db_corruption_regression()

if __name__ == '__main__':
AssetTest().main()
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
'mempool_limit.py',
'feature_assets.py',
'feature_assets_reorg.py',
'feature_assets_mempool.py',
'mining_prioritisetransaction.py',
'feature_maxreorgdepth.py 4 --height=60 --tip_age=0 --should_reorg=0', # Don't Reorg
'feature_maxreorgdepth.py 3 --height=60 --tip_age=0 --should_reorg=1', # Reorg (low peer count)
Expand Down