fix(tx-pool): consider L1 data fee in validateTx (#609)

* fix(tx-pool): consider L1 data fee in validateTx

* bump version
This commit is contained in:
colin 2023-12-26 10:12:26 +08:00 committed by GitHub
parent 640b39161c
commit 5b7079b3a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -658,9 +658,14 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
if pool.currentState.GetNonce(from) > tx.Nonce() { if pool.currentState.GetNonce(from) > tx.Nonce() {
return ErrNonceTooLow return ErrNonceTooLow
} }
// Get L1 data fee in current state
l1DataFee, err := fees.CalculateL1DataFee(tx, pool.currentState)
if err != nil {
return fmt.Errorf("failed to calculate L1 data fee, err: %w", err)
}
// Transactor should have enough funds to cover the costs // Transactor should have enough funds to cover the costs
// cost == V + GP * GL // cost == V + GP * GL
if pool.currentState.GetBalance(from).Cmp(tx.Cost()) < 0 { if pool.currentState.GetBalance(from).Cmp(new(big.Int).Add(tx.Cost(), l1DataFee)) < 0 {
return ErrInsufficientFunds return ErrInsufficientFunds
} }
// Ensure the transaction has more gas than the basic tx fee. // Ensure the transaction has more gas than the basic tx fee.

View file

@ -24,7 +24,7 @@ import (
const ( const (
VersionMajor = 5 // Major version component of the current release VersionMajor = 5 // Major version component of the current release
VersionMinor = 1 // Minor version component of the current release VersionMinor = 1 // Minor version component of the current release
VersionPatch = 9 // Patch version component of the current release VersionPatch = 10 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string VersionMeta = "mainnet" // Version metadata to append to the version string
) )