Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ContainsTransaction Recheck when ParallelVerifiedTransaction Received #1408

Merged
merged 7 commits into from
Jan 13, 2020
Merged
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
4 changes: 3 additions & 1 deletion src/neo/Ledger/Blockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ private void OnParallelVerified(ParallelVerified parallelVerified)
RelayResultReason reason = parallelVerified.VerifyResult;
if (reason == RelayResultReason.Succeed)
{
if (!MemPool.CanTransactionFitInPool(parallelVerified.Transaction))
if (View.ContainsTransaction(parallelVerified.Transaction.Hash))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been check in L403.

Copy link
Contributor Author

@eryeer eryeer Jan 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erikzhang But it cannot guarantee that transactions are not duplicated after asynchronous verification, because during the asynchronous verification process, there may be blocks containing the transaction that are persisted to storage.

Copy link
Member

@vncoelho vncoelho Jan 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that he mentioned that it checks but meanwhile since it not thread safe a Block can be Persisted during the Asynchronous loop. But I am not sure if I understood correctly.

Copy link
Member

@vncoelho vncoelho Jan 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aehuahuea, we sent almost together, @eryeer.

reason = RelayResultReason.AlreadyExists;
else if (!MemPool.CanTransactionFitInPool(parallelVerified.Transaction))
reason = RelayResultReason.OutOfMemory;
else if (!MemPool.TryAdd(parallelVerified.Transaction.Hash, parallelVerified.Transaction))
reason = RelayResultReason.OutOfMemory;
Expand Down