-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
Adjust pending nonce update operation #21164
Conversation
} | ||
// Ensure pool.queue and pool.pending sizes stay within the configured limits. | ||
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
, thenonce
of the account will be updated throughpool.pendingNonces.setIfLower
while deleting the overflowed transaction. The account that needs to be updatednonce
has 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
reset
action, first executetruncatePending
. Since the value ofpool.pendingNonces
has been cleared in thereset
function, the subsequent steps are executed. WhentruncatePending
deletes the overflow transaction,pool.pendingNonces.setIfLower
actually reads thenonce
inStateDB
to 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
nonce
topool.pendingNonces
at the time ofreset
, and after the update is completed, then executetruncatePending
, this time if the function deletes the overflow transaction,pool .pendingNonces.setIfLower
is able to update thenonce
of 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 |
truncatePending
function, thenonce
value of the account will be updated immediately when the overflow transaction is deleted, so it is only necessary to update thenonce
of all accounts after performingreset
to avoid affecting the efficiency of inserting transactions