From 87e6d92a631ee1d97981b8b6b9df08a2a1887da2 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 10 Oct 2023 17:15:20 +0300 Subject: [PATCH] Native: do not remove malicious conflict records during OnPersist It's OK to keep them and save O(n) operations during OnPersist. The storage taken by these malicious conflict records is properly paid anyway. Signed-off-by: Anna Shaleva --- src/Neo/SmartContract/Native/LedgerContract.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Neo/SmartContract/Native/LedgerContract.cs b/src/Neo/SmartContract/Native/LedgerContract.cs index 3a490e204cd..0f48c5e99fa 100644 --- a/src/Neo/SmartContract/Native/LedgerContract.cs +++ b/src/Neo/SmartContract/Native/LedgerContract.cs @@ -47,9 +47,9 @@ internal override ContractTask OnPersist(ApplicationEngine engine) engine.Snapshot.Add(CreateStorageKey(Prefix_Block).Add(engine.PersistingBlock.Hash), new StorageItem(Trim(engine.PersistingBlock).ToArray())); foreach (TransactionState tx in transactions) { - // Remove possible previously saved malicious conflict records for the transaction (if any). - foreach (var (key, _) in engine.Snapshot.Find(CreateStorageKey(Prefix_Transaction).Add(tx.Transaction.Hash).ToArray())) - engine.Snapshot.Delete(key); + // It's possible that there are previously saved malicious conflict records for this transaction. + // These records are garbage in fact and can be removed in a separate flow, but at the same time + // it won't hurt to keep them. engine.Snapshot.Add(CreateStorageKey(Prefix_Transaction).Add(tx.Transaction.Hash), new StorageItem(tx));