Skip to content

Commit

Permalink
Fix conflicting tx fees accounting
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaShaleva committed Mar 9, 2023
1 parent 000b130 commit 8a041a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Neo/Ledger/TransactionVerificationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Neo.Persistence;
using Neo.SmartContract.Native;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace Neo.Ledger
Expand Down Expand Up @@ -59,7 +60,7 @@ public bool CheckTransaction(Transaction tx, IEnumerable<Transaction> conflictin
senderFee.TryGetValue(tx.Sender, out var totalSenderFeeFromPool);

BigInteger fee = tx.SystemFee + tx.NetworkFee + totalSenderFeeFromPool;
foreach (var conflictTx in conflictingTxs)
foreach (var conflictTx in conflictingTxs.Where(c => c.Sender.Equals(tx.Sender)))
{
fee -= conflictTx.NetworkFee + conflictTx.SystemFee;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Neo/Network/P2P/Payloads/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public JObject ToJson(ProtocolSettings settings)
/// <param name="settings">The <see cref="ProtocolSettings"/> used to verify the transaction.</param>
/// <param name="snapshot">The snapshot used to verify the transaction.</param>
/// <param name="context">The <see cref="TransactionVerificationContext"/> used to verify the transaction.</param>
/// <param name="conflictsList">The list of conflicting <see cref="Transaction"/> those fee should be excluded from sender's overall fee during <see cref="TransactionVerificationContext"/>-based verification.</param>
/// <param name="conflictsList">The list of conflicting <see cref="Transaction"/> those fee should be excluded from sender's overall fee during <see cref="TransactionVerificationContext"/>-based verification in case of sender's match.</param>
/// <returns>The result of the verification.</returns>
public VerifyResult Verify(ProtocolSettings settings, DataCache snapshot, TransactionVerificationContext context, IEnumerable<Transaction> conflictsList)
{
Expand All @@ -353,7 +353,7 @@ public VerifyResult Verify(ProtocolSettings settings, DataCache snapshot, Transa
/// <param name="settings">The <see cref="ProtocolSettings"/> used to verify the transaction.</param>
/// <param name="snapshot">The snapshot used to verify the transaction.</param>
/// <param name="context">The <see cref="TransactionVerificationContext"/> used to verify the transaction.</param>
/// <param name="conflictsList">The list of conflicting <see cref="Transaction"/> those fee should be excluded from sender's overall fee during <see cref="TransactionVerificationContext"/>-based verification.</param>
/// <param name="conflictsList">The list of conflicting <see cref="Transaction"/> those fee should be excluded from sender's overall fee during <see cref="TransactionVerificationContext"/>-based verification in case of sender's match.</param>
/// <returns>The result of the verification.</returns>
public virtual VerifyResult VerifyStateDependent(ProtocolSettings settings, DataCache snapshot, TransactionVerificationContext context, IEnumerable<Transaction> conflictsList)
{
Expand Down

0 comments on commit 8a041a6

Please sign in to comment.