-
Notifications
You must be signed in to change notification settings - Fork 199
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
Validate debitGasFees execution in tx pool #2279
Conversation
Coverage from tests in coverage: 51.2% of statements across all listed packagescoverage: 63.2% of statements in consensus/istanbul coverage: 43.2% of statements in consensus/istanbul/announce coverage: 56.0% of statements in consensus/istanbul/backend coverage: 0.0% of statements in consensus/istanbul/backend/backendtest coverage: 24.3% of statements in consensus/istanbul/backend/internal/replica coverage: 65.9% of statements in consensus/istanbul/core coverage: 50.0% of statements in consensus/istanbul/db coverage: 0.0% of statements in consensus/istanbul/proxy coverage: 64.2% of statements in consensus/istanbul/uptime coverage: 51.8% of statements in consensus/istanbul/validator coverage: 79.2% of statements in consensus/istanbul/validator/random |
2cbd161
to
8b1b5f2
Compare
8b1b5f2
to
ac78803
Compare
We need this somewhat unusual function to check if `debitGasFees` can be successfully executed without keeping the resulting state changes.
Txs must not fail during debitGasFees execution during the state transition, so we must remove problematic txs during the tx pool validation.
ac78803
to
5f587ca
Compare
The pre-espresso case it not used anymore and can be safely removed.
5f587ca
to
cb74c28
Compare
core/tx_pool.go
Outdated
cost := new(big.Int).SetUint64(tx.Gas()) | ||
cost.Mul(cost, tx.GasFeeCap()) | ||
cost.Add(cost, tx.Value()) | ||
if tx.GatewayFeeRecipient() != nil { |
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.
Wasn't support for gateway fees removed in gingerbread, could this be cleaned up as well?
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.
Yes, and I could also remove the "(2)" comment, since only once case is left.
return ErrInsufficientFunds | ||
} | ||
} | ||
return erc20gas.TryDebitFees(tx, from, currentVMRunner) |
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.
Rather than having an else statement we could simplify this function like this:
if tx.FeeCurrency() != nil {
return erc20gas.TryDebitFees(tx, from, currentVMRunner)
}
...
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.
Looks good.
We don't need to support the pre-gingerbread behaviour of the tx pool anymore.
Description
Txs must not fail during
debitGasFees
execution during the state transition, so we must remove problematic txs during the tx pool validation. We do this by executingdebitGasFees
inside the tx pool validation and discarding the resulting state changes. This is not overly efficient, but still better than the alternatives that have been considered so far.Other changes
ExecuteAndDiscardChanges
tovm.EVMRunner
. I would have liked to avoid this change, butStaticCall
does not allow (even temporary) changes and I didn't see a better way.debitGasFeesSelector
andcreditGasFeesSelector
and updated comment to show how to generate the selector withcast
instead of python.debitGasFees
and I want to avoid duplicate workValidateTransactorBalanceCoversTx
, since we don't need to support older forks in the tx poolTested
Manually by sending txs via Viem to a local mycelo. Adding a unit test would be desirable.
I'm haven't tested that the state revert works as expected and am also not sure about the performance impact.
Backwards compatibility
At the time of writing, we don't have any fee currencies on mainnet that can fail in
debitGasFees
. The error message for fee currencies without sufficient balance will change with this PR. The new error will contain the revert message from the token'sdebitGasFees
.