Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
ante imprvs
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Jan 18, 2024
1 parent 25fbe13 commit 4fd0475
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions cosmos/runtime/txpool/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
)

Expand Down Expand Up @@ -67,20 +66,35 @@ func (m *Mempool) shouldEjectFromCometMempool(
if tx == nil {
return false
}
txHash := tx.Hash()

// 1. If the transaction has been included in a block.
// 2. If the transaction has been in the mempool for longer than the configured timeout.
// 3. If the transaction's gas params are over the configured limit.
includedInBlock := m.includedCanonicalChain(txHash)
// First check things that are stateless.
if m.validateStateless(tx, currentTime) {
return true
}

// Then check for things that are stateful.
return m.validateStateful(tx)
}

// validateStateless returns whether the tx of the given hash is stateless.
func (m *Mempool) validateStateless(tx *ethtypes.Transaction, currentTime int64) bool {
txHash := tx.Hash()
// 1. If the transaction has been in the mempool for longer than the configured timeout.
// 2. If the transaction's gas params are over the configured limit.
expired := currentTime-m.crc.TimeFirstSeen(txHash) > m.lifetime
priceOverLimit := tx.GasPrice().Cmp(m.priceLimit) <= 0

return includedInBlock || expired || priceOverLimit
return expired || priceOverLimit
}

// includedCanonicalChain returns whether the tx of the given hash is included in the canonical
// Eth chain.
func (m *Mempool) includedCanonicalChain(hash common.Hash) bool {
return m.chain.GetTransactionLookup(hash) != nil
func (m *Mempool) validateStateful(tx *ethtypes.Transaction) bool {
// // 1. If the transaction has been included in a block.
// signer := ethtypes.LatestSignerForChainID(m.chainConfig.ChainID)
// if _, err := ethtypes.Sender(signer, tx); err != nil {
// return true
// }

// tx.Nonce() <
return m.chain.GetTransactionLookup(tx.Hash()) != nil
}

0 comments on commit 4fd0475

Please sign in to comment.