-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Adjust pending nonce update operation #21164
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
Conversation
| pool.truncatePending() | ||
| pool.truncateQueue() | ||
|
|
||
| // Update all accounts to the latest known pending nonce |
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 don't think it's correct. truncatePending will drop the overflowed transactions from the pending list. In the original code, the pending nonces will be set back.
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.
- But in
truncatePending, thenonceof the account will be updated throughpool.pendingNonces.setIfLowerwhile deleting the overflowed transaction. The account that needs to be updatednoncehas been updated in this function, so There is no need to reset the account again outside the function. - In the original code, if you are performing the
resetaction, first executetruncatePending. Since the value ofpool.pendingNonceshas been cleared in theresetfunction, the subsequent steps are executed. WhentruncatePendingdeletes the overflow transaction,pool.pendingNonces.setIfLoweractually reads thenonceinStateDBto judge, the condition is not established and will not be updated to the highestnonce, and finally by direct update All accounts are realized - So only need to update all
noncetopool.pendingNoncesat the time ofreset, and after the update is completed, then executetruncatePending, this time if the function deletes the overflow transaction,pool .pendingNonces.setIfLoweris able to update thenonceof the corresponding account
|
Can you write some benchmarks to show this change is worth the risk? |
|
Closing in favour of #22231 (same as this PR but rebased on |


truncatePendingfunction, thenoncevalue of the account will be updated immediately when the overflow transaction is deleted, so it is only necessary to update thenonceof all accounts after performingresetto avoid affecting the efficiency of inserting transactions