-
Notifications
You must be signed in to change notification settings - Fork 433
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
Fix/get block transactions count #4340
Conversation
16b5b50
to
4535b15
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this doesn't exactly do what it is stating. It only takes the nonce of the transaction from the pool. Those transactions don't have to be included in the next block. (Unless it should work like that just by giving you what is in the pool instead of what is in potential next block)
The main problem is that Nethermind doesn't have proper support for pending block. It should construct that block and return results based on that. That was never implemented. Also Geth team is keen on deprecating and removing the pending flag altogether.
Taking all that into account I'm more keep on just rejecting this change.
So should we just tell users to manage nonce locally? I still think there should be a way using which users can query if there are pending transactions from a particular address. |
How Geth implements it? |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Don't use _nonce, that was added only for ManagedNonce transactions explicitly.
- If you need you can go through a bucket explicitly in _transactions.
- What about potential gaps between nonces?
The way pending nonce is maintained in geth, they return the next available nonce. |
ok but it's maintained in just a dictionary? It is able to maintain that there and ignore gaps correctly? |
They do is somewhat differently. They maintain two levels in the txPool (pending and all). One where all the transactions are present and other where only the transactions that can be added in any future block. Like the transactions with sequential nonce, if there is a gap in nonce, the rest of the txn are not added in the pending pool. And the pendingNonces dict is only maintained for txns in the pending pool. Since our system is quite different, we can do it by scanning the txPool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a fix and optimizations.
- Current nonce from state was ignored. This resulted in incorrect values being returned.
- Avoid copying a bucket when doing scan.
- Avoid full collection scan if no gap.
@tanishqjasoria This needs more tests and a review.
I would prefer fairly straightforward test through RPC and sophisticated tests on TxPool.
bab7793
to
bf8268e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run a node for a while + spam it with request a bit
1. current nonce from state was ignored. 2. Avoid copying a bucket when doing scan 3. Avoid full collection scan if no gap
a8ad8da
to
1a0f6a5
Compare
Fixes getBlockTransactionCount when blockParameter is "pending". It did not take in account the pending transactions.
Changes:
Types of changes
What types of changes does your code introduce?
Put an
x
in the boxes that applyTesting
Requires testing
In case you checked yes, did you write tests??