-
Notifications
You must be signed in to change notification settings - Fork 1.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
txpool: Respect updates to block gas limit #9363
txpool: Respect updates to block gas limit #9363
Conversation
6442500
to
23b5e7a
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.
txs are added a bit later - in: OnNewBlock
-> addTxsOnNewBlock
-> addLocked
probably you need to fix there. (and maybe in onSenderStateChange
)
I took a look in this path, but I don't understand your comment. Are you suggesting that the fix needs to be additionally there? Or that the fix should be moved to this path? The The general problem is that unlike with |
There is a bug in the txpool which can manifest either as a race condition, or in more novel network configurations. When a transaction is classified as either having `NotTooMuchGas` or its complement, this classification will never change unless a change to the sender account triggers reevaluation of that transaction. If the block gas limit changes upwards, then any transactions previously not marked as `NotTooMuchGas` will remain ineligible for promotion. Similarly, if the block gas limit changes downwards, then any transactions previously marked as `NotTooMuchGas` may inappropriately remain as pending. Although block gas limits may be relatively static in practice, there is additionally a race condition which can cause this bug to manifest. When the tx pool is first constructed, the gas limit is implicitly set to 0. Until the first update arrives with the configured gas limit, all transactions received will be categorized as using too much gas, and will never recover. This change adds a check in the `OnNewBlock` path which checks if the gas limit has changed, and if so triggers the re-evaluation of the `NotTooMuchGas` status for all transactions. In the normal case of consistent gas limits, this code path is not executed.
23b5e7a
to
4108182
Compare
Just rebased as this had gone into conflict -- happy to adapt this if there are changes needed, as the bug it resolves is real for us. |
yes, seems everything make sense. |
There is a bug in the txpool which can manifest either as a race condition, or in more novel network configurations. When a transaction is classified as either having
NotTooMuchGas
or its complement, the classification will never change (unless a change to the sender account triggers reevaluation of that transaction).If the block gas limit changes upwards, then any transactions previously not marked as
NotTooMuchGas
will remain ineligible for promotion. Similarly, if the block gas limit changes downwards, then any transactions previously marked asNotTooMuchGas
may inappropriately remain as pending.Although block gas limits may be relatively static in practice, there is additionally a race condition which can cause this bug to manifest. When the tx pool is first constructed, the gas limit is implicitly set to 0. Until the first update arrives with the configured gas limit all transactions received will be categorized as using too much gas and will never recover. This race condition was occurring in some integration tests we run.
This change adds a check in the
OnNewBlock
path which checks if the gas limit has changed, and if so triggers the re-evaluation of theNotTooMuchGas
status for all transactions.I am not an expert in the locking code for this path, but it looked like a lock was held and so these modifications should be safe. But please ensure that aspect is adequately reviewed.