Skip to content

Commit

Permalink
Only keep track of recently used stacks in memory.
Browse files Browse the repository at this point in the history
This should - as far as we know - eliminate unbounded memory growth.
To avoid memory leaks, we only evict "root" stacks from the cache.
  • Loading branch information
d0cd authored and vicsn committed Jan 10, 2025
1 parent 0b391d2 commit 6c990e8
Show file tree
Hide file tree
Showing 11 changed files with 1,461 additions and 143 deletions.
6 changes: 1 addition & 5 deletions console/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,7 @@ pub trait Network:

/// The maximum number of stacks in the process
/// Allows for fast processing for blocks made from 4 maximally full rounds.
#[cfg(not(feature = "test"))]
const MAX_STACKS: usize = Self::MAX_TRANSMISSIONS_PER_BATCH as usize * Self::MAX_CERTIFICATES as usize * 4;
/// The maximum number of stacks in the process.
#[cfg(feature = "test")]
const MAX_STACKS: usize = 64;
const MAX_STACKS: usize = Self::MAX_PROGRAM_DEPTH * Self::MAX_IMPORTS * 10;

/// The maximum number of bytes in a transaction.
// Note: This value must **not** be decreased as it would invalidate existing transactions.
Expand Down
4 changes: 2 additions & 2 deletions ledger/query/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<N: Network, B: BlockStorage<N>> QueryTrait<N> for Query<N, B> {
}
}

/// Returns a state path for the given `commitment`.
/// Returns the current block height.
fn current_block_height(&self) -> Result<u32> {
match self {
Self::VM(block_store) => Ok(block_store.max_height().unwrap_or_default()),
Expand All @@ -159,7 +159,7 @@ impl<N: Network, B: BlockStorage<N>> QueryTrait<N> for Query<N, B> {
}
}

/// Returns a state path for the given `commitment`.
/// Returns the current block height.
#[cfg(feature = "async")]
async fn current_block_height_async(&self) -> Result<u32> {
match self {
Expand Down
Loading

0 comments on commit 6c990e8

Please sign in to comment.