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

Disable NonceGap check for internal transactions #4926

Merged
merged 42 commits into from
Feb 9, 2023

Conversation

deffrian
Copy link
Contributor

@deffrian deffrian commented Nov 22, 2022

Fixes | Closes | Resolves #

Changes:

  • Disables NonceGap check for internal transactions
  • Removes ReuseOwnTxNonce filter
  • All nonce management has been moved outside tx pool
  • Transaction pool can't process multiple transactions from the same address in parallel

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Testing

Tested manually with sepolia node.
Hive tests: rpc, rpc-compat

Requires testing

  • Yes
  • No

In case you checked yes, did you write tests??

  • Yes
  • No

@deffrian deffrian linked an issue Nov 22, 2022 that may be closed by this pull request
@deffrian deffrian marked this pull request as ready for review November 22, 2022 16:53
Copy link
Contributor

@marcindsobczak marcindsobczak left a comment

Choose a reason for hiding this comment

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

We have a bug in incrementing nonces. When receiving eth_sendTransaction:
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/EthRpcModule.cs#L325
we firstly reserve nonce:
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.TxPool/TxPoolSender.cs#L24
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.TxPool/TxNonceTxPoolReserveSealer.cs#L37
and then go to the filters (filters are in SubmitTx):
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.TxPool/TxPoolSender.cs#L25
If tx is rejected in filters, nonce remains incremented and for next transactions send from this endpoint nonce will be incorrect. In this form (not rejecting nonce-gap transactions) we will accept this new tx with higher nonce, but it will never be processed, as lower nonce doesn't exist, so it will be some kind of invalid in a hidden way, without notice to the sender

@deffrian deffrian marked this pull request as draft November 29, 2022 18:03
@gituser
Copy link

gituser commented Dec 1, 2022

Any update on this? @marcindsobczak @deffrian
Thanks.

@deffrian
Copy link
Contributor Author

deffrian commented Dec 1, 2022

@gituser I'm working on it right now:)

@deffrian deffrian marked this pull request as ready for review December 6, 2022 15:51
@marcindsobczak
Copy link
Contributor

There is a conflict to be resolved @deffrian

# Conflicts:
#	src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs
@deffrian
Copy link
Contributor Author

deffrian commented Dec 7, 2022

There is a conflict to be resolved @deffrian

@marcindsobczak merged

Copy link
Contributor

@marcindsobczak marcindsobczak left a comment

Choose a reason for hiding this comment

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

Copy link
Contributor

@marcindsobczak marcindsobczak left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

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

I think this design has its own problems as highlighted in the review. Do we need Set of nonces at all? Maybe we should follow what Geth is doing and always store local transactions in the pool?

Other than that it has bugs and missed things that could be improved.

deffrian and others added 2 commits February 6, 2023 13:52
# Conflicts:
#	src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nonce increment bugs
6 participants