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

Investigating mempool behavior with similar transactions #1148

Closed
vncoelho opened this issue Oct 5, 2019 · 4 comments
Closed

Investigating mempool behavior with similar transactions #1148

vncoelho opened this issue Oct 5, 2019 · 4 comments
Labels
consensus Module - Changes that affect the consensus protocol or internal verification logic discussion Initial issue state - proposed but not yet accepted enhancement Type - Changes that may affect performance, usability or add new features to existing modules. ledger Module - The ledger is our 'database', this is used to tag changes about how we store information p2p Module - peer-to-peer message exchange and network optimisations, at TCP or UDP level (not HTTP).

Comments

@vncoelho
Copy link
Member

vncoelho commented Oct 5, 2019

Summary
As previously reported by @belane and @shargon, currently, it was wondered if someone could possibly spam different speakers with similar txs, which would make backups reject such block and deteriorate performance, among others...

@belane and @shargon, could you please double check. I am not sure if this problem actually exists, because OnTransaction event of ConsensusService looks independent from the OnNewTransaction (which will probably discard the transaction here public virtual bool Reverify(Snapshot snapshot, IEnumerable<Transaction> mempool)). What do you think, @erikzhang?

Do you have any solution you want to propose?
Most would happen due to a transaction becoming invalid in terms of network and system fees.
In this sense, we need to track senders and their GAS. By doing that we could still accept transactions proposed by `Speaker.

This feature could be implemented together with the possible PR of #1140.

Where in the software does this update applies to?

  • Consensus
  • Ledger
  • P2P (TCP)
@vncoelho vncoelho added the discussion Initial issue state - proposed but not yet accepted label Oct 5, 2019
@vncoelho
Copy link
Member Author

vncoelho commented Oct 18, 2019

Perhaps it will fail on Consensus OnTransaction event because of

fee += mempool.Where(p => p != this && p.Sender.Equals(Sender)).Select(p => (BigInteger)(p.SystemFee + p.NetworkFee)).Sum();

Consensus Service AddTransaction calls if (verify && !tx.Verify(context.Snapshot, context.Transactions.Values)), which calls Reverify.

In this sense, perhaps we need a better strategy for the CN to temporally accept that TX only for Consensus purposes, not adding it to its own mempool, but trying to verify the proposed block.
Consequently, if the block is persisted its mempool will be clear for that Sender.

Do you agree with the description, @shargon @belane?
If so, maybe the proposed solution may work.

@vncoelho
Copy link
Member Author

In fact, I think not!

I just noticed that Consensus Service simulates the mempool in its call of Verify.

@shargon
Copy link
Member

shargon commented Oct 23, 2019

I need more time to review this, sorry @vncoelho

@vncoelho
Copy link
Member Author

@shargon, this is not critical, it is mostly a discussion.

I my opinion, the problem does not occurs and we are resilient enough with the current design of CN transaction checking.

However, let's make it clear with code comments and variable renaming. It is not good that we do not clearly see that.

@lock9 lock9 added consensus Module - Changes that affect the consensus protocol or internal verification logic ledger Module - The ledger is our 'database', this is used to tag changes about how we store information p2p Module - peer-to-peer message exchange and network optimisations, at TCP or UDP level (not HTTP). enhancement Type - Changes that may affect performance, usability or add new features to existing modules. labels Nov 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus Module - Changes that affect the consensus protocol or internal verification logic discussion Initial issue state - proposed but not yet accepted enhancement Type - Changes that may affect performance, usability or add new features to existing modules. ledger Module - The ledger is our 'database', this is used to tag changes about how we store information p2p Module - peer-to-peer message exchange and network optimisations, at TCP or UDP level (not HTTP).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants