Skip to content

Commit

Permalink
Native: do not remove malicious conflict records during OnPersist
Browse files Browse the repository at this point in the history
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. See the discussion under #2913 (comment).

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
  • Loading branch information
AnnaShaleva committed Oct 10, 2023
1 parent 330cbea commit 024a82a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Neo/SmartContract/Native/LedgerContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit 024a82a

Please sign in to comment.