-
Notifications
You must be signed in to change notification settings - Fork 360
fix(evict): Switch to LRU to prevent removed transactions from being re-gossiped from a peer instantly. #1472
Conversation
Warning Rate Limit Exceeded@itsdevbear has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 21 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe recent updates to the Cosmos runtime's transaction pool involve optimizations and refactoring, particularly in handling transactions and telemetry metrics. The logic for dropping remote transactions has been shifted to a more appropriate function, enhancing code organization and efficiency. Additionally, the transition to a more scalable cache mechanism in the comet component significantly increases its capacity, indicating a move towards handling higher volumes of data more efficiently. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (3)
- cosmos/runtime/txpool/ante.go (1 hunks)
- cosmos/runtime/txpool/comet.go (2 hunks)
- cosmos/runtime/txpool/mempool.go (1 hunks)
Additional comments: 7
cosmos/runtime/txpool/comet.go (7)
- 27-27: The import of the
lru
package fromgithub.com/ethereum/go-ethereum/common/lru
is correctly added to support the LRU caching mechanism.- 31-31: The increase of
defaultCacheSize
from 4096 to 100000 significantly enlarges the cache capacity. Ensure that this change is aligned with memory management and performance objectives, considering the potential impact on resource usage.- 44-44: Switching
timeInserted
to uselru.Cache
instead of a map is a key change. This aligns with the objective to adopt an LRU caching strategy. Ensure the type parameters[common.Hash, int64]
correctly represent the transaction hash and its insertion time.- 50-50: The instantiation of
timeInserted
withlru.NewCache[common.Hash, int64](defaultCacheSize)
correctly applies the increased cache size. This change is crucial for implementing the LRU caching strategy effectively.- 55-55: The
IsRemoteTx
method's implementation usingcrc.timeInserted.Contains(txHash)
correctly checks for the presence of a transaction hash in the cache, leveraging the LRU cache's capabilities.- 60-60: In
MarkRemoteSeen
, adding the transaction hash and the current Unix timestamp to the cache withcrc.timeInserted.Add(txHash, time.Now().Unix())
is appropriate for tracking when a transaction was first seen.- 64-65: The
TimeFirstSeen
method correctly retrieves the insertion time of a transaction hash from the cache. The omission of error handling aftercrc.timeInserted.Get(txHash)
is acceptable given the method's return type and usage context.
Summary by CodeRabbit