From 40a026d92b26231a44fe3e0dd2315b25e303ba5e Mon Sep 17 00:00:00 2001 From: Fraser Hutchison Date: Thu, 13 Feb 2025 11:13:09 +0000 Subject: [PATCH] increase mempool removal cache size --- crates/astria-sequencer/CHANGELOG.md | 12 ++++++++++-- crates/astria-sequencer/src/mempool/mod.rs | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/crates/astria-sequencer/CHANGELOG.md b/crates/astria-sequencer/CHANGELOG.md index 80192e36f..80e6e54f2 100644 --- a/crates/astria-sequencer/CHANGELOG.md +++ b/crates/astria-sequencer/CHANGELOG.md @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add more thorough unit tests for all actions [#1916](https://github.com/astriaorg/astria/pull/1916). +- Implement `BridgeTransfer` action [#1934](https://github.com/astriaorg/astria/pull/1934). + ### Changed - Bump MSRV to 1.83.0 [#1857](https://github.com/astriaorg/astria/pull/1857). @@ -19,8 +24,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Remove events reporting on state storage creation [#1892](https://github.com/astriaorg/astria/pull/1892). - Use bridge address to determine asset in bridge unlock cost estimation instead of signer [#1905](https://github.com/astriaorg/astria/pull/1905). -- Add more thorough unit tests for all actions [#1916](https://github.com/astriaorg/astria/pull/1916). -- Implement `BridgeTransfer` action [#1934](https://github.com/astriaorg/astria/pull/1934). + +### Fixed + +- Increase mempool removal cache size to be greater than default CometBFT +mempool size [#1969](https://github.com/astriaorg/astria/pull/1969). ## [1.0.0] - 2024-10-25 diff --git a/crates/astria-sequencer/src/mempool/mod.rs b/crates/astria-sequencer/src/mempool/mod.rs index de71d097e..48fbf9529 100644 --- a/crates/astria-sequencer/src/mempool/mod.rs +++ b/crates/astria-sequencer/src/mempool/mod.rs @@ -29,6 +29,7 @@ use tokio::{ use tracing::{ error, instrument, + warn, Level, }; pub(crate) use transactions_container::InsertionError; @@ -58,7 +59,7 @@ const TX_TTL: Duration = Duration::from_secs(240); const MAX_PARKED_TXS_PER_ACCOUNT: usize = 15; /// Max number of transactions to keep in the removal cache. Should be larger than the max number of /// transactions allowed in the cometBFT mempool. -const REMOVAL_CACHE_SIZE: usize = 4096; +const REMOVAL_CACHE_SIZE: usize = 50_000; /// `RemovalCache` is used to signal to `CometBFT` that a /// transaction can be removed from the `CometBFT` mempool. @@ -95,12 +96,21 @@ impl RemovalCache { }; if self.remove_queue.len() == usize::from(self.max_size) { - // make space for the new transaction by removing the oldest transaction + // This should not happen if `REMOVAL_CACHE_SIZE` is >= CometBFT's configured mempool + // size. + // + // Make space for the new transaction by removing the oldest transaction. let removed_tx = self .remove_queue .pop_front() .expect("cache should contain elements"); - // remove transaction from cache if it is present + warn!( + tx_hash = %telemetry::display::hex(&removed_tx), + removal_cache_size = REMOVAL_CACHE_SIZE, + "popped transaction from appside mempool removal cache, CometBFT will not remove \ + this transaction from its mempool - removal cache size possibly too low" + ); + // Remove transaction from cache if it is present. self.cache.remove(&removed_tx); } self.remove_queue.push_back(tx_hash);