celo-org / celo-blockchain

Official repository for the golang Celo Blockchain
https://celo.org
GNU Lesser General Public License v3.0
552 stars 196 forks source link

Validate debitGasFees execution in tx pool #2279

Closed karlb closed 4 months ago

karlb commented 4 months ago

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 executing debitGasFees 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

Tested

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's debitGasFees.

github-actions[bot] commented 4 months ago

Coverage from tests in ./e2e_test/... for ./consensus/istanbul/... at commit f7be29c766cc732afcdca4ca0a693e0a63b48ef7

coverage: 51.2% of statements across all listed packages
coverage:  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
github-actions[bot] commented 4 months ago
5890 passed, 45 skipped