diff --git a/cosmos/config/template.go b/cosmos/config/template.go index a4ec9ee17..ca8ff7fa7 100644 --- a/cosmos/config/template.go +++ b/cosmos/config/template.go @@ -50,7 +50,7 @@ is-validator = {{ .Polaris.Polar.IsValidator }} force-forward-recheck-txs = {{ .Polaris.Polar.ForceForwardReCheckTxs }} # Chain config -[polaris.polar.chain] +[polaris.polar.chain] cccccbgkuclekfkddebkvictfhu chain-id = "{{ .Polaris.Polar.Chain.ChainID }}" # Homestead switch block diff --git a/cosmos/runtime/txpool/ante.go b/cosmos/runtime/txpool/ante.go index 8b1d7c1df..4be7b6783 100644 --- a/cosmos/runtime/txpool/ante.go +++ b/cosmos/runtime/txpool/ante.go @@ -49,7 +49,7 @@ func (m *Mempool) AnteHandle( if wet, ok := utils.GetAs[*types.WrappedEthereumTransaction](msgs[0]); ok { ethTx := wet.Unwrap() if shouldEject := m.shouldEjectFromCometMempool( - ctx.BlockTime(), ethTx, + ethTx, ); shouldEject { telemetry.IncrCounter(float32(1), MetricKeyAnteEjectedTxs) return ctx, errors.New("eject from comet mempool") @@ -64,7 +64,7 @@ func (m *Mempool) AnteHandle( // shouldEject returns true if the transaction should be ejected from the CometBFT mempool. func (m *Mempool) shouldEjectFromCometMempool( - currentTime time.Time, tx *ethtypes.Transaction, + tx *ethtypes.Transaction, ) bool { defer telemetry.MeasureSince(time.Now(), MetricKeyTimeShouldEject) if tx == nil { @@ -72,7 +72,7 @@ func (m *Mempool) shouldEjectFromCometMempool( } // First check things that are stateless. - if m.validateStateless(tx, currentTime) { + if m.validateStateless(tx) { return true } @@ -81,20 +81,24 @@ func (m *Mempool) shouldEjectFromCometMempool( } // validateStateless returns whether the tx of the given hash is stateless. -func (m *Mempool) validateStateless(tx *ethtypes.Transaction, currentTime time.Time) bool { - // 1. If the transaction has been in the mempool for longer than the configured timeout. - expired := currentTime.Sub(m.crc.TimeFirstSeen(tx.Hash())) > m.lifetime - if expired { - telemetry.IncrCounter(float32(1), MetricKeyAnteShouldEjectExpiredTx) - } - - // 2. If the transaction's gas params are less than or equal to the configured limit. +func (m *Mempool) validateStateless(tx *ethtypes.Transaction) bool { + // 1. If the transaction's gas params are less than or equal to the configured limit. priceLeLimit := tx.GasPrice().Cmp(m.priceLimit) <= 0 if priceLeLimit { telemetry.IncrCounter(float32(1), MetricKeyAnteShouldEjectPriceLimit) } - return expired || priceLeLimit + // 2. If the transaction has been in the mempool for longer than the configured timeout. + tfs, found := m.crc.TimeFirstSeen(tx.Hash()) + if !found { + return false + } + + expired := time.Since(tfs) > m.lifetime + if expired { + telemetry.IncrCounter(float32(1), MetricKeyAnteShouldEjectExpiredTx) + } + return priceLeLimit || expired } // includedCanonicalChain returns whether the tx of the given hash is included in the canonical diff --git a/cosmos/runtime/txpool/comet.go b/cosmos/runtime/txpool/comet.go index c672ad92b..aecd06bb6 100644 --- a/cosmos/runtime/txpool/comet.go +++ b/cosmos/runtime/txpool/comet.go @@ -36,7 +36,7 @@ const ( type CometRemoteCache interface { IsRemoteTx(txHash common.Hash) bool MarkRemoteSeen(txHash common.Hash) bool - TimeFirstSeen(txHash common.Hash) time.Time + TimeFirstSeen(txHash common.Hash) (time.Time, bool) } // Thread-safe implementation of CometRemoteCache. @@ -63,7 +63,6 @@ func (crc *cometRemoteCache) MarkRemoteSeen(txHash common.Hash) bool { return false } -func (crc *cometRemoteCache) TimeFirstSeen(txHash common.Hash) time.Time { - i, _ := crc.timeInserted.Get(txHash) - return i +func (crc *cometRemoteCache) TimeFirstSeen(txHash common.Hash) (time.Time, bool) { + return crc.timeInserted.Get(txHash) }